akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX=2e5+5;

ll ara[MX];

int main(){
     ll i, j, k;
     ll n;
     cin >> n;
     for(i=0; i<n; ++i) cin >> ara[i];
     sort(ara, ara+n);
     ll ans=ara[n-1], last=n-1, cnt=0;
     n-=2;
     while(n--){
          if(cnt%2==0) last--;
          ans+=ara[last];
          cnt++;
     }
     cout << ans << endl;
}


Measured memory_bytes: 5204
#include <stdbool.h>
#include <stdio.h>
int a[200000], tmpa[200000], light[200010] = {0};
typedef long long ll;
int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}

	for (int i = 0; i < n; i++) {
		int r, l;
		r = i - a[i];
		l = i + a[i];
		light[(r < 0 ? 0 : r)]++;
		light[(l + 1 > n ? n + 1 : l + 1)]--;
	}
	// for (int i = 0; i <= n; i++) {
	// 	printf("%d ", light[i]);
	// }
	// printf("\n");
	for (int i = 0; i < k; i++) {
		int sum = 0;
		for (int j = 0; j < n; j++) {
			tmpa[j] = a[j];
			sum += light[j];
			a[j] = sum;
		}
		for (int j = 0; j < n; j++) {
			int r = j - tmpa[j];
			int l = j + tmpa[j];
			light[(r < 0 ? 0 : r)]--;
			light[(l + 1 > n ? n + 1 : l + 1)]++;
			r = j - a[j];
			l = j + a[j];
			light[(r < 0 ? 0 : r)]++;
			light[(l + 1 > n ? n + 1 : l + 1)]--;
		}
		bool isSame = true;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] != a[j + 1]) {
				isSame = false;
				break;
			}
		}
		if (isSame && a[0] == n) {
			break;
		}
		// for (int j = 0; j < n; j++) {
		// 	printf("%d", a[j]);
		// 	printf(j == n - 1 ? "\n" : " ");
		// }
	}
	for (int j = 0; j < n; j++) {
		printf("%d", a[j]);
		printf(j == n - 1 ? "\n" : " ");
	}
	return 0;
}

Measured memory_bytes: 4068
#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 ans[100002];
    ll n;
    cin >> n;
    ll a;
    for (ll i=1;i<=n;i++){
        cin >> a;
        ans[a] = i;
    }
    for(ll i=1;i<=n;i++){
        cout << ans[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
 
using namespace std;
 
int main (){
  
  int a[5][5];
  
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++)
      cin >> a[i][j];
  }
  
   for(int i=1;i<3;i++){
     
       
       if(a[0][1]-a[0][0] != a[i][1]-a[i][0]){
         cout << "No" << endl;
       
       return 0;
       }
       else if(a[0][2]-a[0][1] != a[i][2]-a[i][1]){
         cout << "No" << endl;
          
          return 0;
        }
   }
  for(int j=1;j<3;j++){
       if(a[1][0] -a[0][0] != a[1][j]-a[0][j]){
         
         cout << "No" << endl;
         
         return 0;
       }
      else if(a[2][0]-a[1][0] != a[2][j]-a[1][j]){
         
         cout << "No" << endl;
         
         return 0;
       }
     }
   
  
  cout << "Yes" << endl;
  
  return 0;
}
  
 


Measured memory_bytes: 384
n = int(input())
lst = []

while (n!=0):
    r = int(n%2)
    if(r<0):
        r += 2
    lst.append(r)
    n = (n-r)/(-2)

if len(lst) ==0:
    print("0")
else:
    for i in range(len(lst)):
        print(lst[-1-i],end="")
    print()

Measured memory_bytes: 3060
a,b,c,x,y = map(int,input().split())

price = a * x + b * y


for i in range(max(x,y) + 1):
    ab = 2 * i
    cand = ab * c + a * max(0, x - i) + b * max(0, y-i)

    price = min(price, cand)

print(price)
  


Measured memory_bytes: 8924
use std::io::{stdin, BufRead};

fn main() {
    let stdin = stdin();
    let cin = stdin.lock();
    let mut lines = cin.lines();
    let n = {
        let line = lines.next().unwrap().unwrap();
        line.parse::<usize>().unwrap()
    };
    let mut aa = Vec::with_capacity(n);
    for _ in 0..n {
        aa.push({
          let line = lines.next().unwrap().unwrap();
            line.parse::<i32>().unwrap()
        });
    }
    let mut bb = aa.clone();
    bb.sort();
    let b0 = bb.pop().unwrap();
    let b1 = bb.pop().unwrap();
    for a in aa {
        if a < b0 {
            println!("{}", b0);
        } else {
            println!("{}", b1);
        }
    }
}


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

using namespace std;

int main(){
  int n;
  cin >> n;
  
  vector<int> a(n-1);
  long long b = 0;
  for(int i = 0; i < n-1; i++) cin >> a[i];
  b += a[0];
  for(int i = 0; i < n-1; i++){
    if(i == n - 2){
     b += a[i];
   }else{
     if(a[i] < a[i+1]) b += a[i];
     else b += a[i+1];
   }
  }
  
  cout << b << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Main  implements Runnable {

    public static void main(String[] args) {

        new Thread(null, new Main(), "", 16 * 1024 * 1024).start();

    }

    public void run() {
    	FastScanner sc = new FastScanner(System.in);
		//long n = Long.parseLong(sc.next());
    	//int[] ar = new int[3];
    	//ar[0]=Integer.parseInt(sc.next());
    	//ar[1]=Integer.parseInt(sc.next());
    	//ar[2]=Integer.parseInt(sc.next());
    	//Arrays.parallelSort(ar);
		int w = Integer.parseInt(sc.next());
		int h = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next());
		int y = Integer.parseInt(sc.next());
		//int k = Integer.parseInt(sc.next());
		//String s = sc.next();
		//int k = Integer.parseInt(sc.next());
		//int m = Integer.parseInt(sc.next());
		//int x2000 = Integer.parseInt(sc.next());
		//int t = Integer.parseInt(sc.next());
		//int k = 0;
		//int k = Integer.parseInt(sc.next());
		///String str = sc.next();
		//char c[] = str.toCharArray();
		//char a[][] = new char[n];
		//int atmp[] = new int[h];
		//int max= 0;
		//int blackar[][] = new int[h*w][2];
		//int p=0;
		//ArrayList<Integer> lists = new ArrayList<Integer>();
		//lists = new ArrayList;
		PrintWriter out = new PrintWriter(System.out);
		double ans = ((double)w*(double)h/2.0);
		if(x*2==w && y*2==h)
		{
			out.println(ans+" "+1);
		}
		else
		{
			out.println(ans+" "+0);
		}





		out.flush();
	}

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;
        public FastScanner(String in) {
        	StringReader sr = new StringReader(in);
            reader = new BufferedReader(new BufferedReader(sr));
            tokenizer = null;
        }
        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

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

        public long nextInt() {
            return Integer.parseInt(next());
        }

    }

}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;


const ll MAX = 510010;
const ll mod = 1000000007;
vector<ll> fac(MAX), finv(MAX), inv(MAX);
bool init_called = false;
//=============modinv============================
void COMinit() {
  init_called = true;
  fac.at(0) = 1;
  fac.at(1) = 1;
  finv.at(0) = 1;
  finv.at(1) = 1;
  inv.at(1) = 1;
  for (ll i = 2; i < MAX; i++){
    fac.at(i) = fac.at(i - 1) * i % mod;
    inv.at(i) = mod - inv.at(mod % i) * (mod / i) % mod;
    finv.at(i) = finv.at(i - 1) * inv.at(i) % mod;
  }
}

ll COM(ll n, ll k){
  if (!init_called) {
    COMinit();
  }
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac.at(n) * (finv.at(k) * finv.at(n - k) % mod) % mod;
}
//=================================================


//=============prime_factor============================
vector<pll> prime_factor(ll N)
{
  vector<pll> res;
  for (ll i = 2; i * i <= N; ++i) {
    if (N % i == 0) {
      ll cnt = 0;
      while (N % i == 0) {
        N /= i;
        cnt += 1;
      }
      res.push_back({i, cnt});
    }
  }
  if (N != 1) {
    res.push_back({N, 1});
  }
  return res;
}
//=================================================


int main()
{
  ll N, M;
  cin >> N >> M;
  vector<pll> factor = prime_factor(M);
  ll ans = 1;
  for (ll i = 0; i < factor.size(); ++i) {
    pll now = factor.at(i);
    ans = (ans * COM(now.second + N - 1, now.second)) % mod;
  }
  cout << ans << "\n";
}


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



// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    string temp;
    cin >> temp;

    std::smatch smatch;
    if (std::regex_search(temp, smatch, std::regex("[a-z]"))){
        cout << "a" << endl;
    } else{
        cout << "A" << endl;
    }

    return 0;
}


Measured memory_bytes: 3700
// --https://kenkoooo.com/atcoder/#/table/soma62jp
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>

using namespace std;

int main(int argc, char* argv[]) {

	int A, B, C, K;
	int max, ans;

	cin >> A >> B >> C;
	cin >> K;

	max = std::max(A, std::max(B, C));
	ans = A + B + C - max;

	for (int i = 0; i < K; i++) {
		max *= 2;
	}

	ans += max;

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
signed main(){
    int N,K,sum=0;
    scanf("%d %d",&N,&K);
    int p[N],i,sa;
    sa=N-K;
    for(i=0;i<N;i++){
        scanf("%d",&p[i]);
    }
    int j,above=0,c=0;
    int high[1000]={};
    for(i=0;i<N;i++){
        sum+=p[i];
    }
    for(j=0;j<sa;j++){
        c=0;
        above=0;
        for(i=0;i<N;i++){
            if(p[i]>above){
                above=p[i];
            }
        }
        high[j]=above;
        for(i=0;i<N;i++){
            if(p[i]==above && c==0){
                p[i]=0;
                c++;
            }
        }
    }
    for(j=0;j<sa;j++){
        sum-=high[j];
    }
    printf("%d\n",sum);
    return(0);
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,H,W,M,K,L,R,N,num=0,sum=0,flag=0;string S,T;
  cin >> A >> B >> C;
  lli a=0,b=0,c=0,d=2;
  rep(i,0,40){
    if(A%d==0)a++;
    if(B%d==0)b++;
    if(C%d==0)c++;
    d*=2;
  }
  if(A%2==1||B%2==1||C%2==1)Out(0);
  else if(A==B&&B==C)Out(-1);
  else if(a==b&&b==c)Out(a+1);
  else Out(min(a,min(b,c)));
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    int ai, bi, ci;
    ai = bi = ci = 0;
    string sa, sb, sc;
    cin >> sa;
    cin >> sb;
    cin >> sc;
    int now = 0;

    while (true){
        if (now == 0){
            if (ai > sa.size()-1){
                cout << "A" << endl;
                exit(0);
            }
            char ci = sa[ai];
            if (ci == 'a')now = 0;
            else if (ci == 'b')now = 1;
            else now = 2;
            ai++;
            continue;
        }
        if (now == 1){
            if (bi > sb.size()-1){
                cout << "B" << endl;
                exit(0);
            }
            char ci = sb[bi];
            if (ci == 'a')now = 0;
            else if (ci == 'b')now = 1;
            else now = 2;
            bi++;
            continue;
        }
        else {
            if (ci > sc.size()-1){
                cout << "C" << endl;
                exit(0);
            }
            char ch = sc[ci];
            if (ch == 'a')now = 0;
            else if (ch == 'b')now = 1;
            else now = 2;
            ci++;
            continue;
        }
    }
}

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

int main()
{
    int i, n, ac, wa, tle, re;
    cin >> n;

    string s;
    ac=wa=tle=re=0;
    for(i=0; i<n; i+=1)
    {
        cin >> s;
        if(s=="AC")
            ac+=1;
        else if(s=="WA")
            wa+=1;
        else if(s=="TLE")
            tle+=1;
        else
            re+=1;
    }    

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define int long long
#define MOD 1000000007
#define mod 998244353
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define vvi vector<vi>
#define endl "\n"
using namespace std;

int colour[100005];
int vis[100005];
void solve1();
void solve()
{
    int T=10;cin>>T;
    for(int z=1;z<=T;z++)
    {
        solve1();
    }
}
signed main()
{
    std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    solve1();
    return 0;
}
void solve1()
{
    int n,s;cin>>n>>s;
    int p[n+1],c[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>p[i];
    }
    for(int i=1;i<=n;i++)
    {
        cin>>c[i];
    }
    int a=0,b=0,c1=0,ans=-MOD;
    for(int i=1;i<=n;i++)
    {
        int arr[n]={0};
        int j=p[i],k=0;a=0;c1=0;
        while(j!=i)
        {
            a+=c[j];j=p[j];
            arr[k]=a;k++;
            //cout<<a<<" ";
        }//cout<<endl;
        a+=c[i];arr[k]=a;
        k++;
        if(a>0)
        {
            if(s>2*k)
            {
                c1+=((s-k)/k)*a;
                int m=s%k;
                sort(arr,arr+m);
                int z=0;
                if(m>0)z=arr[m-1];
                sort(arr,arr+k);
                int q=arr[k-1];
                c1+=max(q,z+a);
            }
            else if(s>k)
            {
                int m=s%k;
                sort(arr,arr+m);
                int z=0;
                if(m>0)z=arr[m-1];
                sort(arr,arr+k);
                int q=arr[k-1];
                c1+=max(q,z+a);
            }
            else
            {
                sort(arr,arr+s);
                c1+=arr[s-1];
            }
            ans=max(ans,c1);
        }
        else
        {
            if(s>k)
            {
                sort(arr,arr+k);c1+=arr[k-1];
            }
            else
            {
                sort(arr,arr+s);c1+=arr[s-1];
            }
            ans=max(ans,c1);
        }
    }
    cout<<ans<<endl;
}


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

int main(){
  int n;
  cin>>n;
  map<string,int> data;
  set<string> dic;
  int ma = 0;

  for(int i=0; i<n; i++){
    string s;
    cin>>s;
    if(!dic.count(s))data.insert(make_pair(s,0));
    else{
      data[s]++;
    }

    ma = max(data[s],ma);
    dic.insert(s);
  }

  vector<string> ans;

  for(auto itr =  data.begin(); itr != data.end(); itr++){
    if(itr->second != ma) continue;
    ans.push_back(itr->first);
  }

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

  for(int i=0; i<ans.size(); i++){
    cout<<ans[i]<<endl;
  }

  return 0;
}


Measured memory_bytes: 38004
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
//#include <unordered_set>
//#include <unordered_map>
#include <stdio.h>

#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INPUT1(n, a) for(int i##n = 0; i##n < n; i##n++) {cin >> a[i##n]; } //n = count, a = vector 
#define OUTPUT1(n, a) cout << "---count---" << endl << n << endl << "---content---" << endl; for(const auto b : a){cout << b << endl; }
#define INPUT2(x, y, field) for(int i##x = 0; i##x < y; i##x++) { for(int j##x = 0; j##x < x; j##x++) { cin >> field[i##x][j##x]; } }
#define OUTPUT2(x, y, field) cout << "---count---" << endl << x << " " << y << endl <<"---content---" << endl; for(int i##x = 0; i##x < y; i##x++) { cout << i##x << "   "; for(int j##x = 0; j##x < x; j##x++) { cout << field[i##x][j##x] << " "; } cout << endl; }

using namespace std;
//using ll = long long;

const int INF = 1001001001;

int main()
{
    int x(0), y(0);
	rep(i, 10000){
	    cin>>x>>y;
	    if(x==0&&y==0)break;
	    cout<<min(x,y)<<" "<<max(x, y)<<endl;
	}
}


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

int main(){
  long long N,M=0,flag=1;
  cin >> N;
  vector<long long> vec(N);
  for(int i=0;i<N;i++){
    cin >> vec[i];
  }
  for(int j=0;j<N;j++){
    if(M>vec[j]){
      flag=0;
      break;
    }
    else
      M=max(M,vec[j]-1);
  }
  if(flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

string S;

void solve(){
    string days[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    cin >> S;

    for(int i=0; i<7; i++){
        if(S == days[i]){
            cout << 7-i << endl;
        }
    }
}

int main(){
    solve();
}

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

public class Main {

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

		int n = Integer.parseInt( br.readLine() );
		String[] temp;

//		int[] S = new int[n];
		int[] S = new int[n+1];
		temp = br.readLine().split(" ");
		for (int i=0; i < n; i++) {
			S[i] = Integer.parseInt(temp[i]);
		}

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

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

		int count = 0;
		for (int i=0; i < T.length; i++) {
			S[n] = T[i]; // bannpei
//			for (int j=0; j < S.length; j++) {
//				if (T[i] == S[j]) {
//					count++;
//					break;
//				}
//			}
//			int j = 0;
//			while (true) {
//				if (T[i] == S[j]) {
//					if (j != n) count++;
//					break;
//				}
//				j++;
//			}

			int j = 0;
			while (T[i] != S[j]) {
				j++;
			}
			if (j==n) continue;
			count++;
		}

		System.out.println(count);
	}

}

Measured memory_bytes: 27004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
    int n;cin>>n;
    int ans=1;
    rep(i,n+1){
        int tmp=i*i;
        if(tmp>n){
            cout<<ans<<endl;
            return 0;
        }
        if(tmp==n){
            cout<<tmp<<endl;
            return 0;
        }
        ans=tmp;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define inf 10e18
typedef long long ll;

int main(void) {
  ll i, j, k, n, m;
  scanf("%lld%lld%lld", &n, &m, &k);
  ll a[n], **sum, dp[n];
  sum = (ll**)malloc(sizeof(ll*) * (n + 10));
  for(i = 0; i < n; ++i) sum[i] = (ll*)malloc(sizeof(ll) * (m + 10));
  for(i = 0; i < n; ++i) scanf("%lld", &a[i]);
  for(i = 0; i < n; ++i) dp[i] = inf;
  dp[0] = k;
  for(i = 0; i < n; ++i) {
    ll min = inf, max = 0;
    for(j = 0; j < m; ++j) {
      if(i - j >= 0) {
        if(min > a[i - j]) min = a[i - j];
        if(max < a[i - j]) max = a[i - j];
        sum[i][j] = k + (j + 1) * (max - min);
      }
    }
  }
  for(i = 1; i < n; ++i) {
    for(j = 0; j < m; ++j) {
      if(i - j > 0) {
        if(dp[i] > sum[i][j] + dp[i - j - 1]) dp[i] = sum[i][j] + dp[i - j - 1];
      } else if(!(i - j)) {
        if(dp[i] > sum[i][j]) dp[i] = sum[i][j];
      }
    }
  }
  printf("%lld\n", dp[n - 1]);
  for(i = 0; i < n; ++i) free(sum[i]);
  free(sum);
  return 0;
}


Measured memory_bytes: 159908
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c) {
    stack<int> S;
    S.push(r);
    color[r] = c;
    while( !S.empty() ) {
        int u = S.top();
        S.pop();
        for (int i = 0; i < G[u].size(); i++) {
            int v = G[u][i];
            if(color[v] == NIL) {
                color[v] = c;
                S.push(v);
            }        
        }
    }
}

void assignColor() {
    int id = 1;
    for (int i = 0; i < n; i++) color[i] = NIL;
    for (int u = 0; u < n; u++) {
        if (color[u] == NIL) dfs(u, id++);
    }
}

int main() {
    int s, t, m, q;
    
    cin >> n >> m;
    
    for (int i = 0; i < m; i++) {
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    
    assignColor();
    
    cin >> q;
    
    for (int i = 0; i < q; i++) {
        cin >> s >> t;
        if (color[s] == color[t] ) {
            cout << "yes" << endl;
        }
        else {
            cout << "no" << endl;
        }
    }
    
    return 0;
}


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

int64_t floorint(long double a,long double b){
  int64_t kotae = a * b;
  return kotae;
}

int main() {
  long double A;
  long double B;
  cin >> A;
  cin >> B;
  
  cout << floorint(A,B) << endl;
}




Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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;}


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
signed main(){
  Int r,c,n;
  cin>>r>>c>>n;
  vector<Int> x1(n),y1(n),x2(n),y2(n);
  for(Int i=0;i<n;i++)
    cin>>x1[i]>>y1[i]>>x2[i]>>y2[i];

  auto on_edge=
    [&](Int x,Int y){
      if(x==0) return 1;
      if(x==r) return 1;
      if(y==0) return 1;
      if(y==c) return 1;
      return 0;
    };
  auto idx=
    [&](Int x,Int y){
      assert(on_edge(x,y));
      if(y==0) return x;
      if(x==r) return r+y;
      if(y==c) return r+c+(r-x);
      return r+c+r+(c-y);
    };

  using P = pair<Int, Int>;
  vector<P> vp;
  for(Int i=0;i<n;i++){
    if(!on_edge(x1[i],y1[i])) continue;
    if(!on_edge(x2[i],y2[i])) continue;
    Int p=idx(x1[i],y1[i]);
    Int q=idx(x2[i],y2[i]);
    vp.emplace_back(minmax({p,q}));
  }
  sort(vp.begin(),vp.end());

  set<Int> ss;
  ss.emplace(r+c+r+c+1);
  for(auto p:vp){
    auto it=ss.upper_bound(p.first);
    if(*it<=p.second) drop("NO");
    ss.emplace(p.second);
  }
  drop("YES");
  return 0;
}


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

typedef long long LL;
static LL INF = (1LL<<62);


LL S;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	LL N;
	vector<LL> B;
	vector<LL> A;

	cin >> N;
	for(int i=0; i<N; i++){
		LL b;
		cin >> b;
		B.push_back(b);
	}
	
	while(B.size()>0){
		int found = 0;
		for(int j=B.size()-1; j>=0; j--){
			if(B[j] == j+1){
				found = 1;
				A.push_back(B[j]);
				B.erase(B.begin() + j);
				break;
			}
		}
		if(found == 0){
			break;
		}
	}

	if(B.size() == 0){
		for(int i=A.size()-1; i>=0; i--){
			printf("%lld\n", A[i]);
		}
	}
	else{
		printf("-1\n");
	}
	return 0;
}

Measured memory_bytes: 3720
n,m=map(int,input().split())
ans=[float("inf")]*(2**n)
ans[0]=0
for i in range(m):
    a,b=map(int,input().split())
    c=list(map(int,input().split()))
    tmp=0
    for j in c:
        tmp+=2**(j-1)
    na=ans.copy()
    for j in range(2**n):
        if ans[j|tmp]>na[j]+a:
            ans[j|tmp]=na[j]+a
if ans[2**n-1]==float("inf"):
    print(-1)
else:
    print(ans[2**n-1])

Measured memory_bytes: 71556
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()

int main(){
	int H,W;
	cin >> H >> W;
	string s[H];

	FOR(i,0,H){
		cin >> s[i];
	}

	string ret[H+2];
	FOR(i,0,H+2){
		if(i == 0 || i == H+1) ret[i] = string(W+2,'#');
		else ret[i] = "#" + s[i-1] + "#";
	}

	FOR(i,0,H+2){
		cout << ret[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 256
def bb
    n,d = gets.chomp.split(/\s/).map{|x| x.to_i}
    if n <= d
        puts 1
        return
    end

    x = d*2 + 1
    if n <= x
        puts 1
        return
    end
    puts (n/x).floor + (n%x == 0 ? 0 : 1)
end

bb

Measured memory_bytes: 1788
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto rd = readln.split.to!(size_t[]), n = rd[0], m = rd[1];
  auto a = new string[](n), b = new string[](m);
  foreach (i; 0..n) a[i] = readln.chomp;
  foreach (i; 0..m) b[i] = readln.chomp;

  auto isSame(size_t i, size_t j)
  {
    foreach (k; 0..m)
      if (a[i+k][j..j+m] != b[k]) return false;
    return true;
  }

  foreach (i; 0..n-m+1)
    foreach (j; 0..n-m+1)
      if (isSame(i, j)) {
        writeln("Yes");
        return;
      }

  writeln("No");
}


Measured memory_bytes: 256
# ABC168C

from numpy import pi, cos

a, b, h, m = map(int, input().split())

theta = (m / 60 - (h + m / 60) / 12) * 2 * pi

c2 = a**2 + b**2 - 2 * a * b * cos(theta)
print(c2 ** 0.5)



Measured memory_bytes: 27192
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
#include <numeric>
#include <math.h>
using namespace std;

long euclidean_gcd(long a, long b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}

int main(void){
    long A,B,C,D;
    cin >> A >> B >> C >> D;
    
    long C_N = (B/C) - ((A-1)/C);
    long D_N = (B/D) - ((A-1)/D);
    long CD = C*D / euclidean_gcd(C,D);
    long CD_N = (B/CD) - ((A-1)/CD);

    cout << (B -(A-1)) - (C_N + D_N - CD_N) << endl;
    return 0;
}

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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

int main() {
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    ll ans = 0;
    int b = 0;
    fori(i, 0, s.size()) {
        if(s[i] == 'B') {
            b++;
        }
        else {
            ans += b;
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<ii, int>;
#define vt vector
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int N = 1e3 + 5;
const int M = 1e4 + 5;

int h, n;
int a[N], b[N];
int dp[N][M];

int f(int idx, int hp) {
    if(hp <= 0) return 0;
    if(idx > n) return INF;
    int &sol = dp[idx][hp];
    if(sol != -1) return sol;
    return sol = min(f(idx + 1, hp), f(idx, hp - a[idx]) + b[idx]);
}

void solve() {
    cin >> h >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i] >> b[i];
    }
    memset(dp, -1, sizeof(dp));
    cout << f(1, h) << "\n";
}

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

Measured memory_bytes: 43348
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N;
	int sum = 0;
	vector<int> A, B;
	
	cin>>N;
	
	A.resize(N+1);
	B.resize(N);
	
	for(int i = 0; i <= N; i++){
		cin>>A[i];
	}
	
	for(int i = 0; i < N; i++){
		cin>>B[i];
		
		int x = min(A[i], B[i]);
		
		B[i] -= x;
		
		sum += x;
		
		x = min(A[i+1], B[i]);
		
		A[i+1] -= x;
		
		sum += x;
		
	}
	
	cout<<sum<<endl;
	
	return 0;
}

Measured memory_bytes: 1792
n, q = gets.split(' ').map(&:to_i)
s = gets.rstrip
lrs = []
q.times{lrs << gets.split(' ').map(&:to_i)}

ms = Array.new(n+1, 0)
0.upto(n-1) do | i |
  add = s[i, 2] == 'AC' ? 1 : 0
  ms[i+1] = ms[i] + add
end
lrs.each do | lr |
  p ms[lr[1]-1] - ms[lr[0]-1]
end

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

#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
const int inf = 1000000000; // 10^9

int main(){
   char s[2][3];
   scanf("%s",s[0]);
   scanf("%s",s[1]);
   if(s[0][0]==s[1][2]&&s[0][1]==s[1][1]&&s[0][2]==s[1][0])printf("YES");
   else printf("NO");
}

Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.OptionalInt;
import java.io.UncheckedIOException;
import java.util.stream.Stream;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

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

    static class AMultipleArray {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int n = in.ints();
            int[] a = new int[n];
            int[] b = new int[n];
            in.ints(a, b);
            long d = 0;
            for (int i = n - 1; i >= 0; i--) {
                d += (b[i] - ((a[i] + d) % b[i])) % b[i];
            }
            out.println(d);
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

        public void ints(int[]... arrays) {
            int l = Arrays.stream(arrays).mapToInt(a -> a.length).min().orElse(0);
            for (int i = 0; i < l; i++) {
                for (int j = 0; j < arrays.length; j++) {
                    arrays[j][i] = ints();
                }
            }
        }

    }
}



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

int main()
{
	int A,B;
	cin >> A >> B;
	if (A <= 9 && B <= 9)
	{
		cout << A*B << endl;
	}
	else
	{
		cout << "-1" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define ll long long
#define pp pair<int,int> 
#define Sort(a) a.begin(),a.end()
#define v(T) vector<T>
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
const int INF = 1001001001;
//int 2×10の9乗
//vector<vector<int>> a(n, vector<int>(m));
  //rep(i,n) rep(j,m) cin >> a[i][j]; 
//cout << fixed << setprecision(10);
//int gcd(int x, int y){
  //if(y==0) return x;
  //return gcd(y, x%y);
//}
//sort小さい順
 
int main(){
  int n;
  cin >> n;
  v(int) l(n);
  rep(i,n) cin >> l[i];
  sort(l.begin(), l.end());
  int M=l[n-1];
  int sum=0;
  rep(i,n-1) sum+=l[i];
  if(M<sum) cout << "Yes" << endl;
  else cout << "No" << endl;
  }    

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

int main(){
    int a, b;
    cin >> a >> b;

    if(a == b){
        cout << "Yay!" << endl;
    }
    else if(a > b){
        int tmp1 = 16 - b * 2;
        int tmp2 = a - b;
        if(tmp2 * 2 <= tmp1){
            cout << "Yay!" << endl;
        }
        else{
            cout << ":(" << endl;
        }
    }
    else{
        int tmp1 = 16 - a * 2;
        int tmp2 = b - a;
        if(tmp2 * 2 <= tmp1){
            cout << "Yay!" << endl;
        }
        else{
            cout << ":(" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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

public class Main {
    static int[] w = new int[100010];
    static int[] v = new int[100010];
    static int[][] dp = new int[110][100010];
    static int k;

    static int chmin(int a, int b) {
        if (a > b) {
            a = b;
            return a;
        }
        return a;
    }

    static int chmax(int a, int b) {
        if (a < b) {
            a = b;
            return a;
        }
        return a;
    }

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int a=fs.nextInt();
        int b=fs.nextInt();
        int c = fs.nextInt();
        if (a == b)
            System.out.println(c);
        else if (a == c)
            System.out.println(b);
        else
            System.out.println(a);
    }
}


Measured memory_bytes: 78804
#include <stdio.h>
#include <stdlib.h>

int gcd( int x, int y )
{
        int tmp = x % y;
        int count = 1;
        int answer = 0;

        if ( y == 0 )
        {
                return x;
        }

        while ( count <= y )
        {
                if ( x % count == 0 )
                {
                        if ( y % count == 0 )
                        {
                                answer = count;
                        }
                }
                count = count + 1;
        }

        return answer;
}

int main()
{
        int a, b, answer;

        scanf("%d %d", &a, &b);
        if ( b < a )
        {
                answer = gcd( b, a % b );
        }
        else if ( b > a )
        {
                answer = gcd( a, b % a );
        }
        else  if ( b == a )
        {
                answer = a;
        }

        printf("%d\n", answer );
        return 0;
}

Measured memory_bytes: 592
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
????????????
???????????????????¨???????????????????????????????????????????????¨???°????????°??????????????°??????????¨???°???????¨??????§??????
????????°????????¬?????????????¨??????§?¨???°???????????°??? (1+2)*(5+4) ??????
???????????????????¨??????§??? 1 2 + 5 4 + * ??¨?¨???°???????????????
???????????????????¨??????§?????????????¨??????§????????¨????????¬??§???????????§???????????¨????????????????????????????????????

???????????????????¨??????§?????????????????°???????¨????????????????????????????????????????

"""

# ?????????
INP = list(input().strip().split())
TMP = []
res = 0
for i in INP:
    if i == "+":
        b = TMP.pop()
        a = TMP.pop()
        TMP.append(a + b)
#        print("{} - {} = {}".format(a,b,a+b))
    elif i == "-":
        b = TMP.pop()
        a = TMP.pop()
        TMP.append(a - b)
#        print("{} - {} = {}".format(a,b,a-b))
    elif i == "*":
        b = TMP.pop()
        a = TMP.pop()
        TMP.append(a * b)
#        print("{} * {} = {}".format(a,b,a*b))
    else:
        TMP.append(int(i))

print(TMP.pop())

Measured memory_bytes: 7640
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);


    long long D, T, S;
    cin >> D >> T >> S;

    if (S * T >= D) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 3616
a = input().split()
x = 0
if a[0] == "1" and a[1] == "1":
    x = 1000000
elif a[0] == "1":
    x = x + 300000
elif a[1] == "1":
    x = x + 300000
if a[0] == "2":
    x = x + 200000
if a[0] == "3":
    x = x + 100000
if a[1] == "2":
    x = x + 200000
if a[1] == "3":
    x = x + 100000
print(x)

Measured memory_bytes: 3060
n,m=map(int,input().split())
a=[list(input()) for i in range(n)]
b=[list(input()) for i in range(m)]
count=0
flag=False
for i in range(len(a)-len(b)+1):
  for j in range((len(a[0])-len(b[0])+1)):
    s=[]
    for k in range(i,i+len(b)):
      s.append(a[k][j:j+len(b[0])])
    count=0
    for l in range(m):
      if s[l]==b[l]:
        count+=1
      if count==m:
        flag=True
if flag:
  print("Yes")
else:
  print("No")

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

using namespace std;
using ll = long long;
using pint = pair<int, int>;

int main() {
	int A, B, C, X;
	cin >> A >> B >> C >> X;

	int ans = 0;
	for (int i = 0; i <= A; ++i) {
		for (int j = 0; j <= B; ++j) {
			for (int k = 0; k <= C; ++k) {
				if (i * 500 + j * 100 + k * 50 == X) {
					ans++;

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

Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
typedef pair<int,int> P;
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define rep(i, n) for (lint i = 0; i < (n); i++)
#define INF LLONG_MAX
#define all(x) (x).begin(),(x).end()
#define pb push_back
int main(){
    int n;
    cin >>n;
    set<int>s;
    while(n--){
        int a;
        cin >>a;
        auto itr=s.find(a);
        if(itr==s.end()){
            s.insert(a);
        }
    }
    cout<<s.size()<<endl;



    return 0;
}


Measured memory_bytes: 256
n = int(input())
hist = [tuple(map(int,input().split())) for _ in range(n)]
hist.sort(key=lambda x: x[2], reverse=1)

cands = []
x0,y0,h0 = hist[0]

for i in range(0,101):
  for j in range(0,101):
    if h0 == 0:
      cands.append((i,j,1))
    else:
      cands.append((i,j, h0+abs(i-x0)+abs(j-y0)))
    
for X,Y,H in cands:
  for x,y,h in hist:
    if max(H-abs(X-x)-abs(Y-y),0) == h:
      continue
    else:
      break
  else:
    print(X,Y,H)
    break
    



Measured memory_bytes: 4084
#include <bits/stdc++.h>
#define N 100001
#define prob "DP_A"
#define io freopen(prob".inp","r",stdin); freopen(prob".out","w",stdout);
using namespace std;
int n,h[N];
int f[N][2];
void read()
{
    cin>>n;
    for(int i=1;i<=n;i++) cin>>h[i];
    f[2][0]=f[2][1]=abs(h[2]-h[1]);
    for(int i=3;i<=n;i++)
    {
        f[i][0]=min(f[i-1][0],f[i-1][1])+abs(h[i]-h[i-1]);
        f[i][1]=min(f[i-2][0],f[i-2][1])+abs(h[i]-h[i-2]);
    }
    cout<<min(f[n][0],f[n][1]);
}
int main()
{
 //   io
    read();
}


Measured memory_bytes: 1408
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int N, M, K;

int main(void)
{
	cin >> N >> M >> K;
	for (int i = 0; i <= N; ++i)
	{
		for (int j = 0; j <= M; ++j)
		{
			int c = i * j + (N - i) * (M - j);
			if (K == c)
			{
				cout << "Yes\n";
				return 0;
			}
		}
	}
	cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<ctype.h>
int main(){
    char moji;
    int num, i, count[26] = {};

    for(;/* scanf("%c", &moji) != EOF*/;){
    //    scanf("%c", &moji);
    if ( scanf("%c", &moji) == EOF ){
            break;
        }
        if( islower( moji ) ){
        num = moji - 'a';
        count[ num ] += 1;

//        printf("%d", num);
        }else if( isupper( moji ) ){
            num = moji - 'A';
            count[ num ] += 1;
        }

    }
    for( i = 0; i < 26; i++ ){
        printf("%c : %d\n", i + 'a', count[i]);
    }
    return 0;
}

Measured memory_bytes: 544
N=gets.to_i
S=gets.chomp
ret=""
h=0
(N-1).downto(0) do |n|
    if S[n]=="("
        if h>0
            ret="("+ret
            h-=1
        else
            ret="("+ret+")"
        end
    else
        h+=1
        ret=")"+ret
    end
end
puts "("*h+ret


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const double PI = acos(-1.0);
 
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    int n;
    cin >> n;
     
    for(int i = 1; i <= n; i++) {
        bool flag = false;
        if(i % 3 == 0) {
            flag = true;
        }
        int j = i;
        while(1) {
            int r = j % 10;
            j /= 10;
            if(r == 3) {
                flag = true;
                break;
            }
            if(j == 0) break;
        }
        if(flag) cout << " " << i;
    }
     
    cout << "\n";
     
    return 0;
}

Measured memory_bytes: 3184
#include<stdio.h>

int main(){
  int A, B, C;
  
  scanf("%d %d %d", &A, &B, &C);
  if((A == 5 && B == 5 && C == 7) || (A == 5 && B == 7 && C == 5) || (A == 7 && B == 5 && C == 5))
    printf("YES\n");
  else printf("NO\n");
  
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
import java.lang.Math;


public class Main
{
	public static void main(String[] args)
	{
		Scanner cin = new Scanner(System.in);

		int n;
		double x1,x2,x3;
		double y1,y2,y3;
		double X2,Y2,Z2;
		double X3,Y3,Z3;
		double cx,cy,cr;
		
		n = cin.nextInt();
		while(n-- > 0)
		{
			x1 = cin.nextDouble();
			y1 = cin.nextDouble();
			x2 = cin.nextDouble();
			y2 = cin.nextDouble();
			x3 = cin.nextDouble();
			y3 = cin.nextDouble();
			
			X2 = (x2-x1);
			Y2 = (y2-y1);
			Z2 = (x1*x1)+(y1*y1)-(x2*x2)-(y2*y2);
			X3 = (x3-x1);
			Y3 = (y3-y1);
			Z3 = (x1*x1)+(y1*y1)-(x3*x3)-(y3*y3);
			
			cx = -0.5*(Y2*Z3-Y3*Z2)/(Y2*X3-Y3*X2);
			cy = -0.5*(X2*Z3-X3*Z2)/(X2*Y3-X3*Y2);
			cr=Math.sqrt((x1-cx)*(x1-cx)+(y1-cy)*(y1-cy));		
			
			cx=(cx==0.0?0.0:cx);
			cy=(cy==0.0?0.0:cy);
			cr=(cr==0.0?0.0:cr);	
			System.out.printf("%.3f %.3f %.3f\n",cx,cy,cr);	
		}
		

	}
}

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

const int64_t MAX=2e5+5;
int64_t Cur[26],Next[MAX][26];
char s1[MAX];
string s2;

int main() 
{
	ios_base::sync_with_stdio(false);
	// freopen("E.inp","r",stdin);
	cin>>(s1+1)>>s2;
	int64_t n=strlen(s1+1);
	for(int64_t i=1;i<=n;i++)
		s1[i+n]=s1[i];
	for(int64_t i=0;i<26;i++)
		Cur[i]=-1;
	for(int64_t i=2*n;i>=0;i--)
	{
		for(int64_t j=0;j<26;j++)
			Next[i][j]=Cur[j];
		if(i>0)
			Cur[s1[i]-'a']=i;
	}
	int64_t i=0,rs=0;
	for(char c:s2)
	{
		int64_t next=Next[i][c-'a'];
		if(next==-1)
		{
			cout<<-1;
			return 0;
		}
		rs+=next-i;
		i=next;
		if(i>n)
			i-=n;
	}
	cout<<rs;
}

Measured memory_bytes: 41344