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

#define int long long

#define mod (int)1000000007
#define inf (int)1000000007

#define rep(i, n) for(int i = 0; i < (n); i++)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define trrep(i, n) for(int i = (n); i >= 0; i--)
#define For(i, s, t) for(int i = (s); i < (t); i++)
#define tfor(i, s, t) for(int i = (s); i <= (t); i++)
#define rfor(i, s, t) for(int i = (t) - 1; i >= (s); i--)
#define trfor(i, s, t) for(int i = (t); i >= (s); i--)

int pow(int x, int n) {
  int r = 1;
  while(n > 0) {
    if(n & 1) {
      r = r * x % mod;
    }
    x = x * x % mod;
    n >>= 1;
  }
  return r;
}

int inv(int x) {
  return pow(x, mod - 2);
}

int perm[222222];

signed main() {
  perm[0] = 1;
  For(i, 1, 222222) {
    perm[i] = perm[i - 1] * i % mod;
  }
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  h--;
  w--;
  a--;
  b--;
  int x = b + 1;
  int y = h - a - 1;
  int now = 0;
  while(x <= w && y >= 0) {
    now = (now + perm[x + y] * inv(perm[x]) % mod * inv(perm[y]) % mod * perm[(w - x) + (h - y)] % mod * inv(perm[w - x]) % mod * inv(perm[h - y])) % mod;
    x++;
    y--;
  }
  cout << now << endl;
}


Measured memory_bytes: 1920
using System;
using System.Linq;

class Program {
  static void Main() {
    var arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
    int d = arr[0];
    int n = arr[1];
    if (n < 100) {
      Console.WriteLine(Math.Pow(100, d) * n);
    } else {
      Console.WriteLine(Math.Pow(100, d) * 101);
    }
  }
}

Measured memory_bytes: 13268
#pragma warning(disable : 4996)
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
// https://atcoder.jp/contests/abc174/tasks/abc174_a
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll x;
    cin >> x;
    bool isAnswer = false;
    if(x >= 30)
        isAnswer = true;
    if(isAnswer)
        cout << "Yes";
    else
        cout << "No";

    return 0; 
}

Measured memory_bytes: 3644
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
   ll n, x, e;
   cin >> n >> x;
   vector<ll> A(n);
   rep(i, n) cin >> A[i];
   ll res = 0;

   rep(i, n-1){
     e = max((ll)0, (A[i] + A[i+1]) - x); //減らす数
     res += e;
     A[i+1] = max((ll)0, A[i+1] - e);
   }
  cout << res << ln;

}


Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

int main() {
  
  int n,k;
  cin>>n>>k;
  
  int A[n];
  rep(i,n) A[i]=0;
  
  rep(i,k){
    int d;
    cin>>d;
    rep(j,d){
      int a;
      cin>>a;
      A[a-1]++;
    }
  }
  
  int ans=0;
  rep(i,n){
    if(A[i]==0) ans++;
  }
  
  cout<<ans<<endl;
    
  
  return 0;
}

Measured memory_bytes: 3596
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.14159265358979323846
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}

ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

string Toupper(string s){
  string ans="";
  rep(i,s.size()){
    if('a'<=s[i] && s[i]<='z') ans+=(char)s[i]-32;
    else ans+=s[i];
  }
  return ans;
}
string Tolower(string s){
  string ans="";
  rep(i,s.size()){
    if('A'<=s[i] && s[i]<='Z') ans+=(char)s[i]+32;
    else ans+=s[i];
  }
  return ans;
}


const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*bool cmp(pint a, pint b) { return a.second < b.second; }*/

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,k;
  cin>>n>>k;
  cout<<(n+k-3)/(k-1)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
const int N=3005;
typedef long long ll;
ll dp[N][N],a[N];
bool vis[N][N];
int n;
ll min_(ll a,ll b){return a<b?a:b;}
ll max_(ll a,ll b){return a>b?a:b;}
ll dfs(int l,int r){
	if(l>r) return 0LL;
	if(vis[l][r]) return dp[l][r];
	vis[l][r]=1;
	int d=n-(r-l+1);
	if(d&1) dp[l][r]=min_(dfs(l+1,r)-a[l],dfs(l,r-1)-a[r]);
	else dp[l][r]=max_(dfs(l+1,r)+a[l],dfs(l,r-1)+a[r]);
	return dp[l][r];
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	printf("%lld\n",dfs(1,n));
}

Measured memory_bytes: 78464
#include <iostream>
#include <algorithm>
#include <array>

using namespace std;

int main(void)
{
	array<int, 10> input;

	for(int i = 0; i < 10; i++){
		cin >> input[i];
	}

	sort(begin(input), end(input));

	for(int i = 0; i < 3; i++){
		cout << input[9-i] << endl;
	}


	return 0;
}

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


int N;
double dp[310][310][310];

double rec(int i, int j, int k){
    if(dp[i][j][k] >= 0) return dp[i][j][k];
    if(i == 0 && j == 0 && k == 0) return 0.0;

    double res = 0.0;
    if(k > 0) res += rec(i,j+1,k-1) * k;
    if(j > 0) res += rec(i+1,j-1,k) * j;
    if(i > 0) res += rec(i-1,j,k) * i;
    res += N;
    res *= 1.0 / (i+j+k);

    return dp[i][j][k] = res;
}

int main(){
    cin >> N;
    int i=0,j=0,k=0;
    rep(idx, N){
        int a; cin >> a;
        if(a==1) i++;
        else if(a==2) j++;
        else k++;
    }

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

    cout << fixed << setprecision(10) << rec(i,j,k) << endl;
}

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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);

    int a,b,k;
    cin>>a>>b>>k;

    cout<< a-min(a,k)<< " "<<b-min(b,k-min(a,k));

    return 0;
}


Measured memory_bytes: 3620
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,ans=-INF,l=0,r=0; cin>>n;
    vector<ll> a(3*n,0),le(n+1,0),ri(n+1,0);
    priority_queue<ll> sr;
    priority_queue<ll, vector<ll>, greater<ll>> sl;
    rep(i,3*n){
        cin>>a[i];
        if(i<n){
            l+=a[i];
            sl.push(a[i]);
        }
        if(i>=2*n){
            r+=a[i];
            sr.push(a[i]);
        }
    }
    le[0]=l; ri[n]=r;
    rep(i,n){
        l+=a[n+i];
        sl.push(a[n+i]);
        l-=sl.top(); sl.pop();
        le[i+1]=l;

        r+=a[2*n-i-1];
        sr.push(a[2*n-i-1]);
        r-=sr.top(); sr.pop();
        ri[n-i-1]=r;
    }
    rep(i,n+1) ans=max(ans,le[i]-ri[i]);
    cout<<ans<<endl;
}

Measured memory_bytes: 6516
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=998244353;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};




int main(){
    int n;cin >> n;
    if(n == 1){
        cout << 1 << endl;
        cout << 1 << endl;
    }
    else if(n == 2){
        cout << 2 << endl;
        cout << 0 << endl;
        cout << 11 << endl;
    }
    else{
        vector<string> ans;
        for (int i = 2; i <= n; i++) {
            string tmp = "1";
            for (int j = 0; j < i-2; j++) {
                tmp += '0';
            }
            tmp += '1';
            ans.pb(tmp);
        }
        cout << ans.size() << endl;
        for (int i = 0; i < ans.size(); i++) {
            cout << ans[i] << endl;
        }
    }
    return 0;
}



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

using namespace std;

int main(){
    int s1l, s2l;
    string s1, s2;

    cin >> s1 >> s2;
    s1l = s1.length();
    s2l = s2.length();

    if(s1l == s2l){
        if(s1 == s2){
            cout << "EQUAL" << endl;
        }else{
            cout << (s1 > s2 ? "GREATER" : "LESS") << endl;
        }
    }else{
        cout << (s1l > s2l ? "GREATER" : "LESS") << endl;
    }
}

Measured memory_bytes: 3624
from decimal import *

a,b = map(Decimal,input().split())

import math
# a_1, a_2 = math.modf(a)
# b_1, b_2 =math.modf(b)

# total = math.floor(a_1*b_1) + math.floor(a_1*b_2) + math.floor(a_2*b_1) + math.floor(a_2 * b_2)

b*=100

ans = a*b

ans = ans //100

print(ans)

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

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    for(ll i=0;i<N;++i){
        cin >> A[i];
    }
    ll count = 0;
    bool finished = false;

    while(!finished){
        for(ll i=0;i<N;++i){
            if((A[i]%2)==0){
                A[i] = A[i]/2;
            }else{
                finished = true;
            }
        }
        count++;
    }
    cout << count -1 << endl;
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)

sum = b.inject(:+)
pre = -100
n.times do |i|
  if a[i] == pre + 1
    sum += c[pre - 1]
  end

  pre = a[i]
end

puts sum

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int food[] = new int[M + 1];

		for (int i = 0; i < food.length; i++) {
			food[i] = 0;
		}

		for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			for (int j = 0; j < K; j++) {
				food[sc.nextInt()] += 1;
			}
		}

		int sum = 0;
		for (int i = 0; i < food.length; i++) {
			if (food[i] == N) {
				sum++;
			}
		}

		System.out.println(sum);
	}
}

Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {
	//java11

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		long B = sc.nextLong();
		long N = sc.nextLong();

		long x = 1;
		if(B >= 2) {
			x = Math.min(B-1, N);
		}

		long ans = (long)Math.floor((double)A*x/B) - A * (long)Math.floor((double)x/B);

		System.out.println(ans);

	}


}


Measured memory_bytes: 35584
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
    --y;
  }

  return sum;
}

/*考えを書くスペース


*/

//main.cpp----------------------------
bool dfs(int x, int y);

#define MAX 1000

ll n, k;
string s;

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

  char c = s[k-1];

  rep(i, n) {
    if(s[i]!=c) cout << '*';
    else cout << s[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }

    sort(s.begin(), s.end());

    for (int i = 0; i < n; i++) {
        cout << s[i];
    }
    cout << endl;

    return 0;
}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var k = int.Parse(Console.ReadLine());
            Console.WriteLine(input.Sum() - input.Max() + input.Max() * Math.Pow(2, k));
        }
    }
}

Measured memory_bytes: 13396
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<int,int> P;
ll longinf=1ll<<60;
int inf=1<<29;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int cost[300][300];
int mincost[300];
bool used[300];
int V;


int N;
ll A[300][300];
ll B[300][300];
ll C[300][300];
int main (){
      cin>>N;
      rep0(i,N)rep0(j,N) cin>>A[i][j];
      rep0(i,N)rep0(j,N) B[i][j]=A[i][j];
      rep0(k,N)rep0(i,N)rep0(j,N) B[i][j]=min(B[i][j],B[i][k]+B[k][j]);
      ll ans=0;
      rep0(i,N)rep0(j,N){
            if(A[i][j]>B[i][j]){
                  cout<<-1<<endl;
                  return 0;
            }
      }
      rep0(i,N)rep0(j,N) C[i][j]=0;
      rep0(k,N)rep0(i,N)rep0(j,N){
            if(B[i][j]==B[i][k]+B[k][j]&&k!=i&&k!=j){
                  C[i][j]=B[i][j];
            }
      }
      rep0(i,N)rep0(j,N){
            ans=ans+B[i][j]-C[i][j];
      }
      ans/=2;
      cout<<ans<<endl;
      
      return 0;
}


Measured memory_bytes: 2304
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#define rep(i,n) for (int i = 0; i < (n);i++)
typedef long long ll;
using namespace std;
/*#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;*/


void Main()
{
	int n; cin>>n;
	vector<int> a(n); rep(i,n) cin>>a.at(i);
	vector<int> ball(n,0);
	for(int i=1+n/2;i<=n;i++) ball.at(i-1) = a.at(i-1);
	if (n!=1){
		for(int i=n/2;i>0;i--){
			int sum = 0;
			for(int j = i;j<=n;j+=i){
				sum+=ball.at(j-1);
			}
			if(sum%2!=a.at(i-1)) ball.at(i-1) = 1;
			else ball.at(i-1) = 0; 
		}
		int m = 0;
		rep(i,n) m+=ball.at(i);
		cout<<m<<endl;
		rep(i,n) {
			if (ball.at(i) == 1)
				cout<<i+1<<endl;
		}
	}
	else{
		cout<<a.at(0) <<endl;
		if(a.at(0)==1) cout<< 1 << endl;
	}
}

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

Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;

namespace ForATCODER
{
    public class Program
    {
        public static void Main(string[] args)
        {



            long[] sw = s2larray(Console.ReadLine().Split(' '));
       for(int i = 0;i < int.MaxValue;i++)
            {
                if(i%2==0)
                {
                    sw[2] -= sw[1];
                    if(sw[2]<=0)
                    {
                        RESULT("Yes");
                        return;
                    }
                }
                else
                {
                    sw[0] -= sw[3];
                    if (sw[0] <= 0)
                    {
                        RESULT("No");
                        return;
                    }
                }
            }


        }
    
    



    
      
      
        static int s2i(String s)
        {
            return Convert.ToInt32(s);
        }
        static long s2l(String s)
        {
            return Convert.ToInt64(s);
        }
        static void RESULT(double res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(long res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(ulong res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(int res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(String res)
        {
            Console.WriteLine(res);
        }
        static String[] ReadLineAll(int count)
        {
            String[] res = new String[count];
            for (int i = 0; i < count; i++)
            {
                res[i] = Console.ReadLine();
            }
            return res;
        }

        static int[] s2iarray(String[] src)
        {
            int len = src.Length;
            int[] res = new int[len];
            for (int i = 0; i < len; i++)
            {
                res[i] = Convert.ToInt32(src[i]);
            }
            return res;
        }
        static long[] s2larray(String[] src)
        {
            int len = src.Length;
            long[] res = new long[len];
            for (int i = 0; i < len; i++)
            {
                res[i] = Convert.ToInt64(src[i]);
            }
            return res;
        }
    }
}


Measured memory_bytes: 27496
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string S, T;
	cin >> S >> T;

	vector<char> pairS(26, '?'), pairT(26, '?');
	for (int i = 0; i < S.length(); i++) {

		if (pairS[S[i] - 'a'] == '?') pairS[S[i] - 'a'] = T[i];
		else if (pairS[S[i] - 'a'] != T[i]) { 
			cout << "No" << "\n";
			return 0;
		}

		if (pairT[T[i] - 'a'] == '?') pairT[T[i] - 'a'] = S[i];
		else if (pairT[T[i] - 'a'] != S[i]) {
			cout << "No" << "\n";
			return 0;
		}

	}

	cout << "Yes" << "\n";

	return 0;
}

Measured memory_bytes: 916
import sys
Lines = sys.stdin.readlines()

for i in range(0, len(Lines), 2):
    Anumbers = list(map(int, Lines[i].split()))
    Bnumbers = list(map(int, Lines[i+1].split()))
    Hit = 0    
    for j in range(len(Anumbers)):
        Hit += 1 if (Anumbers[j] == Bnumbers[j]) else 0
    Blow = len(set(Anumbers) & set(Bnumbers)) - Hit
    print(Hit, Blow)

Measured memory_bytes: 7544
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main()
{
   ll d,n;
   cin >> d >> n;
   ll ans = 0;
   ll x = 1;
   if(d==0&&n==100)
   {
      cout<<101<<endl;
      return 0;
   }
   if(d==1&&n==100)
   {
      cout<<10100<<endl;
      return 0;
   }
   if(d==2&&n==100)
   {
      cout<<1010000<<endl;
      return 0;
   }
   rep(i,d)
   {
      x *= 100;
   }
   cout<<x*n<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

using ll = long long;

const std::string LRUD = "LRUD";
const ll dj[4] = { -1, 1, 0, 0 }, di[4] = { 0, 0, -1, 1 };

ll H, W, N, sr, sc;
std::string S, T;

int main()
{
  std::cin >> H >> W >> N >> sr >> sc >> S >> T;

  --sr, --sc;

  ll l = 0, r = W;

  if( S[N-1] == 'L' )
    ++l;
  else if( S[N-1] == 'R' )
    --r;

  for( int i = N-2; i >= 0; --i )
  { 
    if( T[i] == 'L' )
      r = std::min( r+1, W );
    else if( T[i] == 'R' )
      l = std::max( l-1, 0ll );

    if( r-l <= 0 )
    {
      puts("NO");

      return 0;
    }

    if( S[i] == 'L' )
      ++l;
    else if( S[i] == 'R' )
      --r;

    if( r-l <= 0 )
    {
      puts("NO");

      return 0;
    }
  }

  if( !(l <= sc && sc < r) )
  {
    puts("NO");

    return 0;
  }

  l = 0, r = H;

  if( S[N-1] == 'U' )
    ++l;
  else if( S[N-1] == 'D' )
    --r;

  for( int i = N-2; i >= 0; --i )
  {

    if( T[i] == 'U' )
      r = std::min( r+1, H );
    else if( T[i] == 'D' )
      l = std::max( l-1, 0ll );

    if( r-l <= 0 )
    {
      puts("NO");

      return 0;
    }

    if( S[i] == 'U' )
      ++l;
    else if( S[i] == 'D' )
      --r;

    if( r-l <= 0 )
    {
      puts("NO");

      return 0;
    }
  }

  if( !(l <= sr && sr < r) )
  {
    puts("NO");

    return 0;
  }

  puts("YES");

  return 0;
}

Measured memory_bytes: 776
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class B
{
	public static void Main()	
	{
		int N = GetInt();
		int M = GetInt();
		int[] num = new int[N+1];
		for(int i = 0; i < M; i++)
		{
			int a = GetInt();
			int b = GetInt();
			num[a]++;
			num[b]++;
		}

		for(int i = 1; i <= N; i++)
			Console.WriteLine(num[i]);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int dp[100009][4];
int  a[109], n, k;

int solve(int k, int ch)
{
    if(k == 0)
        return (ch == 1)? 0: 1;
    int& ans = dp[k][ch];
    if(ans != -1)
        return ans;
    //cout<<k<<" ";
    (ch == 1)? ans = 0: ans = 1;
    for(int i = 1; i <= n; i++){
        if(k - a[i] >= 0){
            if(ch == 1){
                ans |= solve(k - a[i], 2);
            }
            else{
                ans &= solve(k - a[i], 1);
            }
        }
    }
    return ans;
}
main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    memset(dp, -1, sizeof(dp));
    if(solve(k, 1))
        cout<<"First";
    else
        cout << "Second";
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

map<ll, ll> mp;
ll a, b, c, d;
ll solve(ll n){
    if(mp[n])return mp[n];
    ll ans = inf;
    if(n == 0)return 0;
    else{
        ll m;
        if(d <= inf / n)ans = n * d;
        m = n/2*2;
        chmin(ans, abs(m-n)*d + solve(m/2) + a);
        m = (n+1)/2*2;
        chmin(ans, abs(n-m)*d + solve(m/2) + a);
        m = n/3*3;
        chmin(ans, abs(m-n)*d + solve(m/3) + b);
        m = (n+2)/3*3;
        chmin(ans, abs(n-m)*d + solve(m/3) + b);
        m = n/5*5;
        chmin(ans, abs(m-n)*d + solve(m/5) + c);
        m = (n+4)/5*5;
        chmin(ans, abs(n-m)*d + solve(m/5) + c);
        mp[n] = ans;
        return ans;
    }
}

int main() {
    int t;
    cin >> t;
    rep(i, t){
        ll n;
        cin >> n >> a >> b >> c >> d;
        mp[1] = d;
        cout << solve(n) << endl;
        mp.clear();
    }    
}


Measured memory_bytes: 4272
#include <bits/stdc++.h>
int main() {

    int N;
    std::cin >> N;
    std::vector<std::string> s(N);
    for (auto& i : s)std::cin >> i;
    int ans = 0;
    int a = 0;
    int b = 0;
    int ba = 0;
    for (auto& str : s) {
        int count = 0;
        for (int i = 0; i < str.size() - 1; ++i) {
            if (str[i] == 'A' && str[i + 1] == 'B')++ans;
        }
        if (str.back() == 'A'&&str.front() == 'B')++ba;
        else{
        	if (str.back() == 'A')++a;
        	if (str.front() == 'B')++b;
        }
    }
    
    if(ba==0)
    	ans += std::min(a,b);
    else if(a+b>0)
    	ans += ba + std::min(a,b);
    else
    	ans += ba-1;

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


Measured memory_bytes: 768
for _ in [0] * int(raw_input()):
  h, m = map(int, raw_input().split(':'))
  x = abs(h*60 - m*11)
  if x>360:
    x = 720 - x
  if x<60:
    print 'alert'
  elif 180<=x:
    print 'safe'
  else:
    print 'warning'

Measured memory_bytes: 4204
# 写経
N, M = map(int, input().split())


sw = []
for i in range(M):
    k, *s = map(int, input().split())
    sw.append(s)


p = list(map(int, input().split()))


ans = 0
# N 個のスイッチの状態を N bit の二進数で表現する
for bit in range(2 ** N):
    flag = False
    # 電球につながってるスイッチを調べる
    for m in range(M):
        cnt = 0
        for s in sw[m]:
            # 割り当てたスイッチの番目に bit が立っているかどうか調べる
            if (1 << (s - 1)) & bit:
                cnt += 1
        # 電球が点灯する条件ならそのまま次の電球へ
        if cnt % 2 == p[m]:
            continue
        # 点灯しなければ次の点灯候補（bit）を更新する
        else:
            flag = True
            break
    if not flag:
        ans += 1


print(ans)


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

int main(){
int answer[10];
int a,b;
b=0;
stack<int> train;
while(cin>>a){
if(a==0){
cout<<train.top()<<endl;
train.pop();}
if(a!=0){
	train.push(a);}}}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

class Graph{
	private:
	int n;
	vvi g;
	public:
	vi match,used;
	bool BM_dfs(int v){
		used[v]=1;
		for(auto u:g[v]){
			int w=match[u];
			if(w<0||!used[w]&&BM_dfs(w)){
				match[v]=u;
				match[u]=v;
				return 1;
			}
		}
		return 0;
	}
	int BM(){
		int res=0;
		match=vi(n,-1);
		for(int i=0;i<n;i++) if(match[i]<0){
			used=vi(n);
			if(BM_dfs(i)) res++;
		}
		return res;
	}
	Graph(int v){
		n=v;
		g=vvi(v);
	}
	void add_edge(int s,int t){
		g[s].push_back(t);
		g[t].push_back(s);
	}
};

int n;
vi a;

int main(){
	cin>>n;
	a=vi(n);
	for(auto &i:a) cin>>i;
	vvi b(2);
	for(int i=0;i<n;i++){
		if(i==0||a[i-1]!=a[i]-1){
			b[a[i]%2].push_back(a[i]);
		}
		if(i==n-1||a[i]!=a[i+1]-1){
			b[(a[i]+1)%2].push_back(a[i]+1);
		}
	}
	int n1=b[0].size(),n2=b[1].size();
	Graph g(n1+n2);
	for(int i=0;i<n1;i++) for(int j=0;j<n2;j++){
		int t=abs(b[0][i]-b[1][j]);
		bool B=1;
		for(int k=2;k*k<=t&&B;k++) if(t%k==0) B=0;
		if(t==1) B=0;
		if(B) g.add_edge(i,n1+j);
	}
	int t=g.BM(),res=t;
	n1-=t;n2-=t;
	res+=n1/2*2+n2/2*2;
	if(n1%2==1) res+=3;
	cout<<res<<endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

void prime_factor(int n, map<int, int>& mp){
    for(int i = 2; i * i <= n; i++){
        int k = 0;
        while(n % i == 0) n /= i, k++;
        if(k > 0) mp[i] += k;
    }
    if(n > 1) mp[n]++;
}

int main(){
    Stream io;
    
    int N;
    io.read(N);
    map<int, int> mp;
    for(int i = 2; i <= N; i++){
        prime_factor(i, mp);
    }
    vector<vector<int>> dp(mp.size() + 1, vector<int>(76, 0));
    dp[0][1] = 1;
    int i = 1;
    for(auto& x : mp){
        for(int j = 1; j <= 75; j++){
            for(int k = 0; k <= x.second; k++){
                if((k + 1) * j <= 75) {
                    dp[i][(k + 1) * j] += dp[i - 1][j];
                }
            }
        }
        i++;
    }
    cout << dp[mp.size()][75];
    return 0;
}


Measured memory_bytes: 3600
N = int(input())
d = list()

ans = 1

for a in range(N):
    d.append(input())

Newd = sorted(d)


for i in range(N-1):
    if Newd[i] < Newd[i+1]:
        ans = ans + 1
    elif Newd[i] == Newd[i+1]:
        ans = ans
    else:
        break

print(ans)

Measured memory_bytes: 3060
def main():    
    N, M = map(int, input().split())
    S = input()
    p = N
    a = []
    while p > 0:
        for i in range(min(M, p), 0, -1):
            if S[p - i] == '0':
                p = p - i
                a.append(str(i))
                break
        else:
            return -1
    return ' '.join(i for i in reversed(a))
print(main())


Measured memory_bytes: 10528
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

int main(){

    ll N, A = 0, B = 0;
    cin >> N;
    V a(N), b(N);
    rep(i, N){
        cin >> a[i];
        A += a[i];
    }
    rep(i, N){
        cin >> b[i];
        B += b[i];
    }
    ll C = B - A;
    if(C < 0){
        cout << "No" << endl;
        return 0;
    }
    A = C;
    B = C;
    rep(i, N){
        ll d = abs(b[i] - a[i]);
        if(d % 2){
            B--;
            b[i]++;
            d = abs(b[i] - a[i]);
        }
        if(a[i] < b[i]){
            A -= d / 2;
        }
        else{
            B -= d;
        }
    }
    if(A < 0 || B < 0)cout << "No" << endl;
    else if(A * 2 == B)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 384
### subroutines

def check_relation(prts, a, b, rel)	# check if 'a is rel of b' is true
  return false if a == b
  
  case rel
  when 'child'
    return (prts[a] == b)
  when 'parent'
    return (prts[b] == a)
  when 'ancestor'
    while prts[b]
      return true if (prts[b] == a)
      b = prts[b]
    end
    return false
  when 'descendant'
    while prts[a]
      return true if (prts[a] == b)
      a = prts[a]
    end
    return false
  when 'sibling'
    return (prts[a] == prts[b])
  else
    puts "undefined relation: #{rel}"
  end
  nil
end

### main

loop do
  n, m = gets.split.map(&:to_i)
  break if (n | m) == 0

  prts = {}
  ancs = []
  cur = nil
  idt = 0
  
  n.times do
    line = gets.rstrip
    name = line.lstrip
    i = line.index(/[^ ]/)
    #p [name, i, prt, idt]

    if idt < i
      ancs << cur
      idt = i
    elsif idt > i
      ancs.pop(idt - i)
      idt = i
    end

    prts[name] = ancs.last
    cur = name
  end
  #p prts

  m.times do
    cols = gets.strip.split
    aname = cols[0]
    bname = cols[5].delete('.')
    rel = cols[3]
    #p [aname, bname, rel]

    puts (check_relation(prts, aname, bname, rel) ? 'True' : 'False')
  end
  puts
end

Measured memory_bytes: 6140
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;


int main() {
    
    ll n,k;
    cin >> n >> k;
    ll h;
    ll ans = 0;
    for (ll i=0;i<n;i++){
        cin >> h;
        if(h >= k){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>

int main(void)
{
        int n,c=0,i,d;
        scanf("%d",&n);

        d=n;
        while(d>0){
                c+=d%10;
                d=d/10;
        }
        if(n%c==0)printf("Yes\n");
        else printf("No\n");
        return 0;
}


Measured memory_bytes: 1648
#include <bits/stdc++.h>
using namespace std;
 
//Made with <3 by MinumCoklatPanas
typedef long long ll;
const int INF = 1e9;
const ll INFF = 1e18;
const int MAXN = 510;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double INFD = 1E9;
const double EPS = 1e-9;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int k;
	cin >> k;
	int ans = 0;
	for (int i = 1 ; i <= k ; i++)
		for (int j = 1 ; j <= k ; j++)
			for (int l = 1 ; l <= k ; l++)
			{
				ans += __gcd(__gcd(i,j),l);
			}
	cout << ans << endl;
	return 0;
}

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

#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using int32 = int;
using int64 = long long;

const int   mod   = 1e9 + 7;
const int32 inf   = 1001001001;
const int64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 10){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = int64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solver() {
  int N = input();
  vector< int > A(N);
  cin >> A;

  whole(sort, A);

  cout << A.back() - A.front() << endl;
}

signed main(int argc, char *argv[]) {
  solver();
}


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

int main() {
	int N;
	cin >> N;
	vector<int> button(N);
	vector<int> used(N, 0);

	for (int i = 0; i < N; i++) {
		cin >> button.at(i);
	}

	int tmp = button.at(0), flag = 0, cnt = 1;
	while (1) {
		if (tmp == 2) break;
		if (used.at(tmp - 1) == -1) {
			flag = 1;
			break;
		}
		cnt++;
		used.at(tmp - 1) = -1;
		tmp = button.at(tmp - 1);
	}

	if (flag == 1) cout << -1 << endl;
	else cout << cnt << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main()
{
      ll n,m;
      cin>>n>>m;

      ll gcd=__gcd(n,m);
      ll lcm=(n*m)/gcd;

      cout<<lcm<<"\n";
return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define f first
#define s second
#define endl "\n"
#define M 1000000007
#define pb push_back
#define pf push_front
#define eb emplace_back
#define MM_PI 3.14159265358979323846
#define TEST_CASE int t;cin>>t;while(t--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
//template<typename T> T pow(T a, T b, long long m) {T ans = 1; while (b > 0) { if (b % 2 == 1) ans = (ans * a) % m; b /= 2; a = (a * a) % m; } return ans % m; }
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
const int maxn = 1e5 + 10;

void solve() {
	ll n, k;
	cin >> n >> k;
	vll arr(n);
	for (int i = 0; i < n; i++)cin >> arr[i];
	vll dp(n);
	dp[0] = 0;
	ll val1;
	for (int i = 1; i < n; i++) {
		ll val = 1e9;
		for (int j = 1; j <= k; j++) {
			if (i - j < 0)break;
			val1 = dp[i - j] + abs(arr[i] - arr[i - j]);
			val = min(val, val1);
		}
		dp[i] = val;
	}
	cout << dp[n - 1] << endl;
}
int main() {

// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	//IOS
	//make();
	//TEST_CASE
	solve();
	return 0;
}



Measured memory_bytes: 1792
def sumNum(num, sums):
    if num == 0:
        return sums
    sums += num % 10
    num = num // 10
    return sumNum(num, sums)

N = int(input())
f_x = sumNum(N, 0)
if (N % f_x) == 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		String[] tmp = sc.nextLine().split(" ");
		long[] list = new long[n];
		long ans   = 0;


		list[0] = Long.parseLong(tmp[0]);
		for(int i = 1; i < n; i++) {

			list[i] = Long.parseLong(tmp[i]);

			if(list[i - 1] > list[i]) {

				ans += list[i - 1] - list[i];
				list[i] = list[i - 1];

			}
		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 83156
s = input()
cnt = 0
while len(s) > 0:
    if s[0] == s[-1]:
        s = s[1:-1]
    else:
        if s[0] == "x":
            cnt += 1
            s = s[1:]
        elif s[-1] == "x":
            cnt += 1
            s = s[:-1]
        else:
            cnt = -1
            break
print(cnt)

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

int dp[2000][2000];
int main() {
	string a, b; cin >> a >> b;
	dp[0][0] = 1;
	rep(i, a.size())rep(j, b.size() + 1) {
		if (j < b.size() && a[i] == b[j])(dp[i + 1][j + 1] += dp[i][j]) %= MOD;
		(dp[i + 1][j] += dp[i][j]) %= MOD;
	}
	printf("%d\n", dp[a.size()][b.size()]);
}

Measured memory_bytes: 10976
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

#define all(v) (v).begin(), (v).end()
using namespace std;

struct info
{
    int type, value;

    info(){}

    info(int T, int V)
    {
        type = T, value = V;
    }

    const int operator<(info &A)
    {
        return (value < A.value);
    }
};

int main()
{
    int no_of_elements, no_of_choices;
    cin >> no_of_elements >> no_of_choices;

    vector <info> A(no_of_elements);
    for(int i = 0; i < no_of_elements; i++)
        cin >> A[i].type >> A[i].value;

    sort(all(A));
    reverse(all(A));

    vector <int> used(no_of_elements + 1, false);
    priority_queue <long long,vector<long long>, greater<long long> >Q;

    long long sum = 0, distinct_types = 0;
    for(int i = 0; i < no_of_choices; i++)
    {
        sum += A[i].value;

        if(!used[A[i].type])
        {
            used[A[i].type] = true;
            distinct_types++;
        }
        else
        {
            Q.push(A[i].value);
        }
    }
    sum += distinct_types*distinct_types; //cout << sum << endl;

    long long new_sum = sum;

    for(int i = no_of_choices; i < no_of_elements; i++)
    {
        if(used[A[i].type] || Q.size() == 0) continue;

        long long smallest = Q.top(); //cout << "T = " << smallest <<  " V = " << A[i].value;

        new_sum += (A[i].value - smallest) + (distinct_types + 1)*(distinct_types + 1) - (distinct_types*distinct_types);// cout << " N = " << new_sum << endl;

        Q.pop();

            distinct_types++;

            used[A[i].type] = true;

        /*if(new_sum > sum)
        {
            sum = new_sum;

            Q.pop();

            distinct_types++;

            used[A[i].type] = true; cout << sum << endl;
        }*/

        sum = max(sum, new_sum);
    }

    //sum = max(sum, new_sum);

    cout << sum;
    return 0;
}


Measured memory_bytes: 2044
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        mut a: [i128; n],
    }
    a.sort();
    let ans: i128 = if a[0] == 0 {
        0
    } else {
        let mut prod: i128 = 1;
        for v in a {
            prod = prod * v;
            prod = if prod > 1_000_000_000_000_000_000 {
                prod = -1;
                break;
            } else {
                prod
            }
        }
        prod
    };
    println!("{}", ans);
}


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

int main (void){
  int k,s,ans = 0;
  cin >> k >> s;

  for(int i = 0;i <= k;i++){
    for(int j = 0;j <= k;j++){
      if(s-i-j <= k && s-i-j >=0){
        ans++;
      }
    }
  }

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

Measured memory_bytes: 3564
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
int main(void){
    long long n,sum=0;
    vector<int> v(3,0);
    cin>>n;
    rep(i,n){
        int a,b;
        cin>>a>>b;
        sum+=b-a+1;
    }
    cout<<sum<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

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

    int N;
    cin >> N;

    int ans = 0;
    for (int i = 0; 2*i+1 <= N; i++) {
        int x = 2*i+1;
        int num = 1;
        for (int j = 1; j <= x/2; j++) {
            if (x % j == 0) num++;
        }
        if (num == 8) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256