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

using namespace std;
using ll=long long;
using vl=vector<ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<n;i++)
#define LINF ((ll)1ll<<60)

int main(){
    vs f(8);
    rep(i,8)cin>>f[i];
    int turn=0, finish=0;
    while(1){
        int my,mx,mv=-1;
        rep(i,8)rep(j,8){
            int y=(turn==0?i:7-i);
            int x=(turn==0?j:7-j);
            if(f[y][x]!='.')continue;
            int val=0;
            rep(k,8){
                int dy=vl{1,1,1,0,0,-1,-1,-1}[k];
                int dx=vl{1,0,-1,1,-1,1,0,-1}[k];
                int del=0, cx=x, cy=y, cnt=0;
                while(1){
                    cx+=dx, cy+=dy;
                    if(cx<0 or cy<0 or cx>7 or cy>7) break;
                    char self=(turn==0?'o':'x');
                    char other=(turn==0?'x':'o');
                    if(f[cy][cx]==self){
                        val+=cnt;
                        break;
                    }else if(f[cy][cx]==other){
                        cnt++;
                    }else{
                        break;
                    }
                }
            }
            if(val!=0){
                if(mv<val){
                    mv=val;
                    my=y, mx=x;
                }
            }
        }
        if(mv==-1){
            finish++;
        }else{
            finish=0;
            rep(k,8){
                int dy=vl{1,1,1,0,0,-1,-1,-1}[k];
                int dx=vl{1,0,-1,1,-1,1,0,-1}[k];
                int del=0, cx=mx, cy=my, cnt=0;
                while(1){
                    bool fin=false;
                    cx+=dx, cy+=dy;
                    if(cx<0 or cy<0 or cx>7 or cy>7) break;
                    char self=(turn==0?'o':'x');
                    char other=(turn==0?'x':'o');
                    if(f[cy][cx]==self){
                        fin=true;
                    }else if(f[cy][cx]==other){
                        cnt++;
                    }else{
                        break;
                    }
                    if(fin){
                        cx=mx, cy=my;
                        rep(_,cnt+1){
                            f[cy][cx]=self;
                            cx+=dx, cy+=dy;
                        }
                        break;
                    }
                }
            }
        }
        if(finish==2)break;
        turn=1-turn;
    }
    rep(i,8)cout<<f[i]<<endl;
}


Measured memory_bytes: 3228
#include<iostream>
#include<array>
#include<vector>
#include <algorithm>
#include <stdio.h>
#include <string>
using namespace std;

namespace CsF {
	string ConvertBit(int N, int e) {
		string s = "";
		int r = 0;
		while (N != 0) {
			r = N % e;
			s = to_string(r) + s;
			N -= r;
			N /= e;
		}
		return s;
	}
}

using namespace CsF;


int main() {
	int N;
	cin >> N;
	array<array<int, 10>, 100> F;
	array<array<int, 11>, 100> P;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 10; j++)cin >> F[i][j];
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 11; j++)cin >> P[i][j];
	}
	array<int, 10> box;
	string s;
	int max = 0;
	int ans = -1e9;
	int count = 0;
	for (int bit = 1; bit < 1024; bit++) {
		s = ConvertBit(bit, 2);
		for (int i = s.length(); i < 10; i++) {
			s = "0" + s;
		}
		for (int i = 0; i < 10; i++) {
			box[i] = stoi(string() + s[i]);
		}
		for (int i = 0; i < N; i++) {
			count = 0;
			for (int j = 0; j < 10; j++) {
				if (box[j] == F[i][j] && box[j] == 1)count++;
			}
			max += P[i][count];
		}
		if (ans < max)ans = max;
		max = 0;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
k, n = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

r = k - a[-1] + a[0]
ans = [r]
for i in range(1, n):
    ans.append(a[i] - a[i - 1])
ans.remove(max(ans))
print(sum(ans))


Measured memory_bytes: 26420
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	slice := make([]int, n)

	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}

	odd := 0

	for i := 0; i < n; i++ {
		if slice[i]%2 == 1 {
			odd++
		}
	}

	if odd%2 == 0 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 998244353;
const ld PI = acosl(-1);

ll N, A, B, C, D;
ll dfs(ll x, map<ll, ll> &mp) {
    if (mp.find(x) != mp.end())
        return mp[x];

    ll mi = LLONG_MAX;
    auto func = [&](ll y, ll div, ll cost) -> void {
        ll tmp = y / div, mo = y % div, res;
        res = dfs(tmp, mp);
        mi = min(mi, res + cost + mo * D);
        if ((mi - res) / D >= y - tmp)
            mi = res + (y - tmp) * D;
        if (mo) {
            res = dfs(tmp + 1, mp);
            mi = min(mi, res + cost + (div - mo) * D);
            if ((mi - res) / D >= y - tmp - 1)
                mi = res + (y - tmp - 1) * D;
        }
    };

    func(x, 2, A);
    func(x, 3, B);
    func(x, 5, C);
    return mp[x] = mi;
}

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

    int T;
    cin >> T;
    for (int i = 0; i < T; ++i) {
        cin >> N >> A >> B >> C >> D;
        map<ll, ll> mp;
        mp[0] = 0;
        mp[1] = D;
        cout << dfs(N, mp) << endl;
    }

    return 0;
}


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  int n;
  bool flag = false;
  string col;

  cin >> n;

  REP (i, n) {
    cin >> col;
    if (col == "Y") flag = true;
  }

  printf("%s\n", flag ? "Four" : "Three");
}


Measured memory_bytes: 256
def main():
    s = input().rstrip()
    f = False
    for i in range(len(s)-1):
        if s[i] == "A" and s[i+1] == "C":
            f = True
    if f:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#define _[2<<17]
n,i;A _,B _,T _,F _;long M,D _,P _,R _;s(u,i,p,I){R[i]=i?s(u,T[i],p),(I=B[i])-p?s(I,F[I],u),D[u]=D[u]*-~D[I]%M:D[u]:++D[u];}S(u,x,p,i,I){for(i=F[u];I=B[i];I-p?S(I,R[i]*x%M+1,u),x=x*-~D[I]%M:0)i=T[i];P[u]=x%M;}main(u,v){for(;~scanf("%d%d",&u,&v);)i++?A[i-1]=B[i]=u,B[i-1]=A[i++]=v:(n=u,M=v);for(;--i;F[A[i]]=i)T[i]=F[A[i]];s(1,F[1],0);for(S(1,1);i++<n;)printf("%d ",P[i]);}

Measured memory_bytes: 14592
#include <bits/stdc++.h>
using namespace std;
const int N = 100001;
typedef unsigned long long ll;
int n,k;
int a[N];
int main() {
    cin >> n >> k;

    while(n > 0) {
        for (int i = 0; i < k; i++) {
            if (n - 1 >= 0) {
                a[i]++;
                n--;
            }
        }
    }

    int ans1 = INT_MAX;
    int ans2 = INT_MIN;
    for(int i = 0; i < k; i++)
        if (a[i] < ans1){
            ans1 = a[i];
        }
    for(int i = 0; i < k; i++)
        if (a[i] > ans2){
            ans2 = a[i];
        }
        cout << abs(ans1 - ans2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;
typedef long long  ll;
typedef long double ld;
typedef pair<ll,ll> pp;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> super_set;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> multi_set;
#define x1 dfds
#define y1 dsfdsfe
#define pb push_back
#define forn(i,n) for(ll i = 1;i<=n;++i)
#define fi first
#define sc second
#define endl '\n'
#define po(x) (1ll<<x)
const ll DIM = 2E5+7;
ll A[DIM];
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n,k;
    cin>>k>>n;
    forn(i,n)cin>>A[i];
    sort(A+1,A+1+n);
    ll res = A[n]-A[1];
    for(ll i = 2;i<=n;++i){
        ll r = k-A[i]+A[i-1];
        res = min(res,r);
    }
    cout<<res<<endl;
    return 0;
}



Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MN 4005
using namespace std;
int fac[MN],inv[MN],n,k,ans[MN];
const int mod=998244353;
int C(int x,int y){return (x<y)?0:1ll*fac[x]*inv[y]%mod*inv[x-y]%mod;}
void inc(int &x,int y){(x+=y)>=mod?x-=mod:0;}
void dec(int &x,int y){(x-=y)<0?x+=mod:0;}
int calc(int x,int y,int z){
    int ans=0;
    for(int i=0;i<=min(x/2,y/2);++i){
        int tmp=1ll*C(x/2,i)*C(y+z-i*2-1,y-1)%mod;
        if(i%2==0)inc(ans,tmp);else dec(ans,tmp);
    }return ans;
}
int main(){
	fac[0]=fac[1]=inv[0]=inv[1]=1;
	for(int i=2;i<=4000;i++)fac[i]=1ll*fac[i-1]*i%mod,inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
	for(int i=2;i<=4000;i++)inv[i]=1ll*inv[i-1]*inv[i]%mod;
	scanf("%d%d",&k,&n);
	for(int i=1;i<=k;i++){
		if(i&1)ans[i]=(calc(i,k-1,n)+calc(i,k-1,n-1))%mod;
        else ans[i]=calc(i,k,n);
	}
	for(int i=1;i<=k;i++)printf("%d\n",ans[i]);
	for(int i=k-1;i>=1;i--)printf("%d\n",ans[i]);
}

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


using namespace std;

int main(){
  int N; cin >> N;
  
  if( N == 0){ cout << 0; return 0;}
  
  vector<int> A; 
  
  while( N != 0){
    if( N % 2 == 0){ N = -N/2; A.push_back(0);}
    else{ N = -(N-1) / 2; A.push_back(1);}
    }
  reverse(A.begin(),A.end());
  for(int i = 0; i < A.size(); i++){
    
  cout << A[i];}
  
  return 0;}


Measured memory_bytes: 256
def main():
    N,X,M = map(int,input().split())
    A = X
    ans = A
    LIST = [A]
    C = 0
    flag = False
    for n in range(N-1):
        A = (A**2)%M
        if A in LIST:
            ind = LIST.index(A)
            C = sum(LIST[:ind])
            LIST = LIST[ind:]
            flag = True
            break
        else:
            LIST.append(A)
        ans += A
    else:
        print(ans)
        
    if flag:
        ANS = [0]
        S = 0
        for L in LIST:
            S += L
            ANS.append(S)
            
        a = (N - ind) // len(LIST)
        b = (N - ind) % len(LIST)
        ans = sum(LIST)*a + ANS[b] + C
        
        print(ans)
    
if __name__ == '__main__':
    main()

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

int main() {
  int N; cin >> N;
  string str = "";
  while (N != 0) {
    /* N を 2 で割ったあまりを求める */
    int r = N % 2;

    /* N から余りを取り除いて -2 で割る */
    if(r < 0) r += 2;
    N = (N - r) / (-2);

    /* 答えに追加 */
    str += (char)('0' + r);
  }
  /* 向きが逆なので反転 */
  reverse(str.begin(), str.end());
  if (str == "") str = "0"; // N = 0 のときは空文字列になってしまうので例外処理
  cout << str << endl;
}

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

double c, s;

void printkoch(int n, double p1x, double p1y, double p2x, double p2y){
    double sx = (p1x * 2 + p2x) / 3;
    double sy = (p1y * 2 + p2y) / 3;
    double tx = (p1x + p2x * 2) / 3;
    double ty = (p1y + p2y * 2) / 3;
    double ux = sx + (tx - sx) * c - (ty - sy) * s;
    double uy = sy + (tx - sx) * s + (ty - sy) * c;
    if(n == 0){
        printf("%f %f\n", p1x, p1y);
    }else{
        printkoch(n-1, p1x, p1y, sx, sy);
        printkoch(n-1, sx, sy, ux, uy);
        printkoch(n-1, ux, uy, tx, ty);
        printkoch(n-1, tx, ty, p2x, p2y);
    }
}

int main(){
    c = cos(M_PI/3);
    s = sin(M_PI/3);
    int n;
    scanf("%d", &n);
    printkoch(n, 0.0, 0.0, 100.0, 0.0);
    printf("%f %f\n", 100.0, 0.0);
}



Measured memory_bytes: 2100
#include <stdio.h>

inline long long in() {
  long long n = 0;
  char c = getchar_unlocked();
  while ('0' <= c && c <= '9') {
    n = n * 10 + (c - '0');
    c = getchar_unlocked();
  }
  return n;
}

int main() {
  long long I = in(), O = in(), T = in(), J = in(), L = in();
  long long n = (I&1?I-1:I) + (J&1?J-1:J) + (L&1?L-1:L);
  if (I && J && L) {
    long m = (I&1?I-1:I-2) + (J&1?J-1:J-2) + (L&1?L-1:L-2) + 3;
    printf("%lld", (n<m?m:n) + O);
  } else {
    printf("%lld", n + O);
  }
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include  "bits/stdc++.h"
using namespace std;
#define I_AM_SPEED  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define printclock  cerr <<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<" sec\n";
#define mp(a , b)   make_pair(a , b)
#define eb(a)       emplace_back(a)
#define anal         '\n'
#define mod 1000000007
#define fst first
#define sec second
//const double PI = acos(-1.0);
typedef long long ll;
typedef unsigned long long ull;

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
  
//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
    
int main(){
I_AM_SPEED;
#ifndef ONLINE_JUDGE  
      freopen("input.in", "r", stdin);
      freopen("output.in", "w", stdout);
#endif 

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
    
        int n;
        cin >> n;
        if(n%1000 == 0){
             cout << "0";
        }
        else{
           cout << 1000 - (n%1000);
        }


//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
//printclock; 
return  0 ;      
}        



   

Measured memory_bytes: 3648
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val lr = (0 until n).map { sc.next().toInt() to sc.next().toInt() }
    println(problem073b(n, lr))
}

fun problem073b(n: Int, lr: List<Pair<Int, Int>>): Int {
    var sum = 0
    for (i in 0 until n) {
        sum += lr[i].second - lr[i].first + 1
    }
    return sum
}

Measured memory_bytes: 30924
#include<stdio.h>
 int main(){
   int a[100],N,i,j,k,key;
   scanf("%d",&N);
    for(i=1;i<N+1;i++){
     scanf("%d",&a[i]);
   }
   for(j=1;j<N+1;j++){
     key=a[j];
     i=j-1;
     while( i>0 && a[i]>key){
       a[i+1]=a[i];
       i--;
       a[i+1]=key;
     }
     for(k=1;k<N;k++){
	 printf("%d ",a[k]);
   }
     printf("%d",a[N]);
       printf("\n");
   }
     
     return 0;
 }

Measured memory_bytes: 604
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {


		int N=nextInt();
		Pair[] pair = new Pair[N];

		for(int i=0;i<N;i++){
			pair[i]= new Pair(nextString(),nextInt(),i+1);

		}

		Comparator<Pair> comparator = Comparator.comparing(Pair::getS).thenComparing(Pair::getP,Comparator.reverseOrder());
		Arrays.sort(pair,comparator);
		for (Pair pair2 : pair) {
			System.out.println(pair2.n);
		}
	}

	public static class Pair{
		String S;
		int P;
		int n;
		Pair(String S,int P,int n){
			this.S=S;
			this.P=P;
			this.n=n;
		}

		public String getS(){
			return S;
		}
		public int getP(){
			return P;
		}

	}


	public static String[] toStringArray(String s){
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for(int i=0;i<tmp.length;i++){
			tmp[i]=String.valueOf(c[i]);
		}
		return tmp;
	}
	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed up
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed down
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed down
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(15);


    i64 n, p, a, even = 0, odd = 0;
    cin >> n >> p;
    rep(i,n) {
        cin >> a;
        if(a&1) ++odd;
        else ++even;
    }
    
    if(p&1 && odd == 0) {
        cout << 0 << '\n';
        return 0;
    }

    /**
     * 奇数の袋と偶数の袋からいくつか選ぶ.
     */

    i64 ans = 1;
    // 偶数はいくらでも
    rep(i, even) ans *= 2;

    if(p&1) {
        // 奇数が奇数個 + 偶数がいくらでも
        // 奇数の個数をbinomialで立式してwolfすると2^(odd-1)になる
        rep(i, odd-1) ans *= 2;
    }
    else {
        // 奇数が偶数 + 偶数がいくらでも
        // こっちも奇数の個数をbinomialで立式してwolfするとなんか2^(odd-1)になる(多分二項定理)
        rep(i, odd-1) ans *= 2;
    }

    cout << ans << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int mypow(int a,int b,int c){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
signed main(){
	int a,b,z=INF,ans=0;
	cin>>a;
	f(i,a){
		cin>>b;
		if(b>z)ans++;
		z=b;
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 3116
// Virtual

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

// Utility
#define ALL(X) (X).begin(), (X).end()
#define RANGE(I, X, Y) for (int I = (X); I < (Y); I++)
using ll = int64_t;
using ull = uint64_t;
namespace std {
template<class ...Ts>        istream& operator>>(istream& i, tuple<Ts...>& x) { apply([&](auto&&... ys){ ((i >> ys), ...); }, x); return i; }
template<class T1, class T2> istream& operator>>(istream& i, pair<T1, T2>& x) { i >> x.first >> x.second; return i; }
template<class T>            istream& operator>>(istream& i, vector<T>& x)    { for (auto& y : x) { i >> y; } return i; }
}

// Debugging
#define DD(X) std::cout << #X ": " << (X) << std::endl << std::flush
namespace std {
template<class ...Ts>        ostream& operator<<(ostream& o, const tuple<Ts...>& x) { o << "("; apply([&](auto&& y, auto&&... ys){ o << y; ((o << ", " << ys), ...); }, x); o << ")"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const pair<T1, T2>& x) { o << tie(x.first, x.second); return o; }
template<class T>            ostream& operator<<(ostream& o, const vector<T>& x)    { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const set<T1, T2>& x)  { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const map<T1, T2>& x)  { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
}

// Main
void mainCase() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;

  // [ Naive ]
  // double tm = 60 * h + m;
  // double s1 = 2 * M_PI * tm / (12 * 60);
  // double s2 = 2 * M_PI * tm / 60;
  // double x1 = a * cos(s1), y1 = a * sin(s1);
  // double x2 = b * cos(s2), y2 = b * sin(s2);
  // double dx = x1 - x2;
  // double dy = y1 - y2;
  // double l = sqrt(dx * dx + dy * dy);
  // cout << l << endl;

  // [ A bit more algebra ]
  // |v1 - v2|^2 = |v1|^2 + |v2|^2 - 2<v1, v2>
  //             = a^2 + b^2 - 2ab(cos(s1)cos(s2) + sin(s1)sin(s2))
  //             = a^2 + b^2 - 2ab cos(s1 - s2)
  double s = 2 * M_PI * (60 * h + m - 12 * m) / (12 * 60);
  double l2 = a * a + b * b - 2 * a * b * cos(s);
  double l = sqrt(l2);
  cout << setprecision(numeric_limits<double>::digits10 + 1) << l << endl;
}

int main() {
  mainCase();
  return 0;
}

Measured memory_bytes: 4224
#define _USE_MATH_DEFINES // M_PI
#include<cmath>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,a,n) for(int (i)=(n)-1; (i)>=(a);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 2147483647;
constexpr ll mod = 1000000007;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int n; cin >> n;
	vector<int>h(n);
	rep(i, n)cin >> h[i];
	int ans = 0;
	int cnt = 0;
	rep(i, n - 1) {
		if (h[i] >= h[i+1]) {
			++cnt;
			chmax(ans, cnt);
		}
		else cnt = 0;
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using i64=int_fast64_t;
using pii=pair<int,int>;
template <class T> constexpr T inf=numeric_limits<T>::max() / (T)2;
template <class T> using minheap=priority_queue<T,vector<T>,greater<T>>;
#define fir first
#define sec second
#define mkp make_pair
#define mkt make_tuple
#define emb emplace_back
#define all(v) begin(v),end(v)
void ios_untie() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}
void file_setup() {
    if(!freopen("stderr.txt","wt",stderr)) {
        std::cerr << "Failed to open the stderr file\n";
        freopen("CON","wt",stderr);
    }
    if(!freopen("stdout.txt","wt",stdout)) {
        std::cerr << "Failed to open the stdout file\n";
        freopen("CON","wt",stdout);
    }
    if(!freopen("stdin.txt","rt",stdin)) {
        std::cerr << "Failed to open the stdin file.\n";
        freopen("CON","rt",stdin);
    }
}
i64 binry(i64 ok, i64 ng, const function<bool(i64)> &f) {
    while(abs(ok-ng)>1) {
        i64 mid=(ok+ng)/2;
        (f(mid) ? ok : ng) = mid;
    }
    return ok;
}

int n,m;
int h[16];
int d[128];
int dp[1<<16];
int itr[1<<16];
int heat[1<<16];

void solve() {
    for(int i=0; i<n; ++i) {
        cin>>h[i];
    }
    for(int i=0; i<m; ++i) {
        cin>>d[i];
    }
    sort(d,d+m);
    fill(all(dp),inf<int>);
    dp[0]=0;
    for(int s=0; s<1<<n; ++s) {
        for(int i=0; i<n; ++i) {
            if(s>>i&1) continue;
            int t=s|1<<i;
            heat[t]=heat[s]+h[i];
            int j=itr[s];
            int tmp=0;
            while(j<m && d[j]<heat[t]) {
                tmp+=min(d[j]-heat[s],heat[t]-d[j]);
                ++j;
            }
            dp[t]=min(dp[t],tmp+dp[s]);
            itr[t]=j;
        }
    }
    int ans=dp[(1<<n)-1];
    for(int i=itr[(1<<n)-1]; i<m; ++i) {
        ans+=d[i]-heat[(1<<n)-1];
    }
    cout<<ans<<"\n";
}

signed main() {
    //ios_untie();
    //file_setup();
    while(cin>>n>>m, n) {
        solve();
    }
}


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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	ll x,y,z,k;
	cin>>x>>y>>z>>k;
    vector<ll> A(x),B(y),C(z);
    rep(i,x){
        cin>>A[i];
    }
    rep(i,y){
        cin>>B[i];
    }
    rep(i,k){
        cin>>C[i];
    }
    vector<ll> AB(max(3000ll,x*y));
	rep(i,x){
        rep(j,y){
            AB[y*i+j] = A[i]+ B[j];
        }
    }
    sort(AB.begin(),AB.end(),greater<ll>());
    vector<ll> ABC(3000*y);
    rep(i,3000){
        rep(j,y){
            ABC[i*y+j] = AB[i]+C[j];
        }
    }
    sort(ABC.begin(),ABC.end(),greater<ll>());

    rep(i,k){
        cout<<ABC[i]<<"\n";
    }

	return 0;
}

Measured memory_bytes: 31616
#ifdef __LOCAL
  #define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;}
#define itn int
#define fi first
#define se second
#define intmax numeric_limits<int>::max()
#define llmax numeric_limits<ll>::max()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;
const ll lnf=1ll<<60;


int main(){
  ll n,x,m; cin >> n >> x >> m;
  if(x==0||m==1){
    cout << 0 << endl;
    return 0;
  }
  if(x==1){
    cout << n << endl;
    return 0;
  }
  vector<int> v;
  map<int,int> mp;
  vector<int> cycle;
  ll ans=0;
  itn T=n;
  while(T--){
    if(mp.count(x)){
      rep(i,mp[x]) ans+=v[i];
      for(int i=mp[x];i<v.size();i++) cycle.push_back(v[i]);
      break;
    }
    mp[x]=v.size();
    v.push_back(x);
    x=x*x%m;
  }
  if(cycle.empty()){
    rep(i,n) ans+=v[i];
    cout << ans << endl;
    return 0;
  }
  vector<ll> s((cycle.size())+1);
  rep(i,cycle.size()) s[i+1]=s[i]+cycle[i];
  ans+=(n-mp[x])/cycle.size()*s[cycle.size()];
  ans+=s[(n-mp[x])%cycle.size()];
  cout << ans << endl;
}

Measured memory_bytes: 6580
use proconio::input;

fn main() {
    input! {
        n: i32,
        p: [i32; n],
        q: [i32; n]
    }

    let n_us = n as usize;
    let mut sum1: i32 = 0;
    let mut sum2: i32 = 0;
    let mut vec1: Vec<i32> = Vec::new();
    let mut vec2: Vec<i32> = Vec::new();

    for i_us in 0..n_us {
        let i = i_us as i32;
        let c1 = less_used_count(p[i_us], &vec1);
        let c2 = less_used_count(q[i_us], &vec2);
        sum1 += (p[i_us] - 1 - c1) * factorial(n - i - 1) + p[i_us];
        sum2 += (q[i_us] - 1 - c2) * factorial(n - i - 1) + q[i_us];

        vec1.push(p[i_us]);
        vec2.push(q[i_us]);
    }

    let ans = sum1 - sum2;

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

fn factorial(n: i32) -> i32 {
    if n == 0 || n == 1 {
        return 1;
    };
    return n * factorial(n - 1);
}

fn less_used_count(target: i32, vec: &[i32]) -> i32 {
    let mut count = 0;

    for &v in vec {
        if v < target {
            count += 1;
        }
    }

    return count;
}


Measured memory_bytes: 2128
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

int a[3005];
int b[3005];
//ll d[3005][3005];//k番目までw分
int dp1[3005][3005];//0~iでj秒いないで食べられる美味しさ
int dp2[3005][3005];//i~n-1でj秒いないで食べられる美味しさ
    

int main(){
    int n,t;
    cin >> n>>t;
    rep(i,n){
        cin >> a[i] >> b[i];
    }
    rep(j,t){
        if(j<a[0])dp1[0][j]=0;
        else dp1[0][j]=b[0];
    }
    rep(i,n-1){
        rep(j,t){
            if(j>=a[i+1])dp1[i+1][j]=max(dp1[i][j],dp1[i][j-a[i+1]]+b[i+1]);
            else dp1[i+1][j]=dp1[i][j];
        }
    }
    rep(j,t){
        if(j<a[n-1])dp2[n-1][j]=0;
        else dp2[n-1][j]=b[n-1];
    }
    for(int i=n-1;i>0;i--){
        rep(j,t){
            if(j>=a[i-1])dp2[i-1][j]=max(dp2[i][j],dp2[i][j-a[i-1]]+b[i-1]);
            else dp2[i-1][j]=dp2[i][j];
        }
    }
    int ans=0;
    rep(i,n){
        rep(j,t){
            if(i==0){
                ans=max(ans,dp2[i+1][t-j-1]+b[i]);
            }else if(i==n-1){
                ans=max(ans,dp1[i-1][j]+b[i]);
            }else{
                ans=max(ans,dp1[i-1][j]+dp2[i+1][t-j-1]+b[i]);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int main(void)
{
    string s;
    cin >> s;
    int sum = 0;
    int cnt0 = 0;
    for (int i = 0; i < s.length(); i++){
        if(s.at(i)=='1')
            sum++;
        else
            cnt0++;
    }
    cout << min(sum, cnt0) *2 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
#define INF 1e8;
using namespace std;
using ll = long long;
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; }

int V,E;
int to[17][17];
int dp[(1<<20)+1][17];

int dfs(){
    rep(i,(1<<V)){
        rep(j,V){
            if(!((1<<j)&i)){
                rep(k,V){
                    dp[i|(1<<j)][j] = min(dp[i|(1<<j)][j],dp[i][k]+to[k][j]);
                }
            }
        }
    }
    if(dp[(1<<V)-1][0] == 1e8) return -1;
    return dp[(1<<V)-1][0];
}
int main(){
    cin >> V >> E;
    rep(i,17) rep(j,17) to[i][j] = 1e8;
    rep(i,(1<<20)) rep(j,17) dp[i][j] = 1e8;
    int a,b,d;
    rep(i,E){
        cin >> a >> b >> d;
        to[a][b] = d;
    }
    dp[0][0] = 0;
    PRINT(dfs());
}



Measured memory_bytes: 72740
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <bitset>
#include <list>
#include <cmath>
using namespace std;

int main() {
	int n;
	cin >> n;
	map<string, int> map;
	for (int i = 0; i < n; ++i) {
		string tmp;
		cin >> tmp;
		map[tmp]++;
	}
	int max = 0;
	for (const auto& p: map) {
		max = std::max(max, p.second);
	}
	for (const auto& p: map) {
		if (p.second == max) {
			cout << p.first << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define DEBUG2(x, y) cerr << #x << ": " << x << " " << #y << ": " << y << "\n"
#define DEBUG3(x, y, z) cerr << #x << ": " << x << " " << #y << ": " << y << " " << #z << ": " << z << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cerr << v << " ";  \
  }                    \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
#define pint pair<int, int>
#define ld long double
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T> void print2(const T &x, const T &y) { cout << x << " " << y << "\n"; }
template <class T> void print3(const T &x, const T &y, const T &z) { cout << x << " " << y << " " << z << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
struct Sushi {
  int val, kind;
  bool operator<(const Sushi &another) const { return val == another.val ? kind < another.kind : val < another.val; };
};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N, K;
  cin >> N >> K;
  vec<pint> a(N);
  priority_queue<int> res;
  REP(i, N) {
    int p, q;
    cin >> p >> q;
    p--;
    a[i] = mp(q, p);
  }
  sort(ALL(a));
  reverse(ALL(a));
  //  FORA(e, a) DEBUG2(e.fst, e.snd);
  vec<bool> flg(N, false);
  vec<int> best;
  int base = 0;
  int kind = 0;
  int ans = 0;
  FORA(e, a) {
    if (kind < K && !flg[e.snd]) {
      flg[e.snd] = true;
      best.pb(e.fst);
      base += e.fst;
      kind++;
    } else {
      res.push(e.fst);
    }
  }
  int bestS = best.size();
  REP(i, K - bestS) {
    base += res.top();
    res.pop();
  }
  ans = base + kind * kind;
  //  DEBUG(ans);
  REPR(i, bestS - 1) {
    base -= best[i];
    res.push(best[i]);
    int val = res.top();
    base += val;
    kind -= 1;
    res.pop();
    chmax(ans, base + kind * kind);
  }
  print(ans);
}
//残った中からN-x個選んでよいという考えはなかった。
//とにかくx種類で一番大きなやつを選べば大丈夫。
//解は悪化しない。
//最初A＝K個の強い寿司　B= N-K個の他の寿司
// Bに加えて最大値を出し　という操作をし続ける。

Measured memory_bytes: 3192
package main

import (
	"fmt"
	)

func max(a int, b int) int{
	if a < b {
		return b
	}
	return a
}

	
func main() {
	var n int
	fmt.Scan(&n)
	a:=[][]int{}
	dp:=make([][3]int,n+1)
	for i:=0;i<n;i++{
		var ai,bi,ci int
		fmt.Scan(&ai,&bi,&ci)
		a=append(a,[]int{ai,bi,ci})
	}
	
	for i:=0;i<n;i++{
		for j:=0;j<3;j++{
			if j == 0{
				dp[i+1][j] = max(dp[i][1], dp[i][2]) + a[i][j]
			} else if j == 1 {
				dp[i+1][j] = max(dp[i][0], dp[i][2]) + a[i][j]
			} else if j == 2 {
				dp[i+1][j] += max(dp[i][0], dp[i][1]) + a[i][j]
			}
		}
	}

	fmt.Println(max(max(dp[n][0],dp[n][1]),dp[n][2]))
}


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

bool isChain( int* num, int i, int r ){
	if ( i >= 15 ) return false;
	if ( num[ i ] == 1 ){
		r -= 1;
		if ( !r ){
			return true;
		}else{
			return isChain( num, i+1, r );
		}
	}
	return false;
}


string checkHand( int* c ){
	int number[ 15 ] = {0};
	int max1 = 0, max1num = 0, max2 = 0, max2num = 0;

	for ( int i = 0; i < 5; ++i ){
		int n = c[ i ];
		++number[ n ];
		if ( number[ n ] > max1 ){
			if ( n == max1num ){
				max1 = number[ n ];
				max1num = n;
			}else{
				max2 = max1;
				max2num = max1num;
				max1 = number[ n ];
				max1num = n;
			}
		}else if ( number[ n ] > max2 ){
			max2 = number[ n ];
			max2num = n;
		}
		if ( n == 1 ) ++number[ 14 ];
	}

	if ( max1 == 4 ){
		return "four card";
	}else if ( max1 == 3 ){
		if ( max2 == 2 ){
			return "full house";
		}else{
			return "three card";
		}
	}else if ( max1 == 2 ){
		if ( max2 == 2 ){
			return "two pair";
		}else{
			return "one pair";
		}
	}

	for ( int i = 1; i <= 10; ++i ){
		if ( number[ i ] == 1 ){
			if ( isChain( number, i+1, 5-1 ) ){
				return "straight";
			}
		}
	}


	return "null";
}

int main(){
	int card[ 5 ];
	char c;

	while ( cin >> card[ 0 ] >> c >> card[ 1 ] >> c >> card [ 2 ] >> c
				>> card[ 3 ] >> c >> card[ 4 ] ){

		cout << checkHand( card ) << endl;

	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <climits>

const int MAX_N = 100000;
const int MAX_K = 100000;

bool calculateWeight(int n, int k, int w[], int maxWeight) {
  int j = 0;
  int m = 0;

  int sum = 0;

  bool success = false;

  while ((j < n) && (m < k)) {
    if (w[j] > maxWeight) {
      return false;
    }
      
    if ((sum + w[j]) <= maxWeight) {
      sum += w[j];
      j++;
    } else {
      m++;
      sum = 0;
    }
  }
    
  if (j == n) {
    success = true;
  }

  return success;
}

int main() {
  std::ios_base::sync_with_stdio(false);
  
  int n = 0;
  int k = 0;

  int w[MAX_N] = {0};

  std:: cin >> n;
  std:: cin >> k;

  int minWeight = INT_MAX;
  int maxWeight = 0;

  for (int i = 0; i < n; i++) {
    std:: cin >> w[i];

    if (w[i] < minWeight) {
      minWeight = w[i];
    }

    maxWeight += w[i];
  }

  int weight = INT_MAX;

  int left = minWeight;
  int right = maxWeight;
  
  while (left <= right) {
    int middle = (left + right) / 2;

    //    std::cout << left << " " << middle << " " << right << std::endl;    

    if (calculateWeight(n, k, w, middle) && (middle < weight)) {
      weight = middle;
      right = middle - 1;
    } else {
      left = middle + 1;
    }
  }

  std::cout << weight << std::endl;

  return 0;
}

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

int main() {
  int n,ans,d;
  ans=0;
  cin >> n;
  vector<int> l(101,0);
  for (int i=0;i<n;i++)
  {cin>>d;if (l[d]==0){ans++;l[d]=1;}}
  cout<<ans;
}


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

// ??\???
int n, W;
int weight[110], value[110];

// DP????????????
int dp[110][10010];

int main() {
  cin >> n >> W;
  for (int i = 0; i < n; ++i) cin >> value[i] >> weight[i];

  // DP???????????¶: dp[0][w] = 0
  for (int w = 0; w <= W; ++w) dp[0][w] = 0;

  // DP?????????
  for (int i = 0; i < n; ++i) {
    for (int w = 0; w <= W; ++w) {
      if (w >= weight[i]) dp[i+1][w] = max(dp[i][w-weight[i]] + value[i], dp[i][w]);
      else dp[i+1][w] = dp[i][w];
    }
  }

  cout << dp[n][W] << endl;
  return 0;
}

Measured memory_bytes: 7060
#!/usr/bin/perl

use strict;
use warnings;

my $N = <>;
chomp(my $in = <STDIN>);
my($S, $T) = split(" ", $in);

my $ans = "";
for (my $i=0; $i<$N; $i++) {
    $ans = $ans . substr($S, $i, 1);
    $ans = $ans . substr($T, $i, 1);
}
print "$ans\n";


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

int main(void){
    int n;
    cin >> n;
    int r[210000];
    for(int i=1; i<=n; i++){
        cin >> r[i];
    }

    int maxR[210000];
    maxR[n-1] = r[n];
    for(int i=n-2; i>=1; i--){
        maxR[i] = max(maxR[i+1], r[i+1]);
    }

    int ans = maxR[1] - r[1];
    for(int i=2; i<n; i++){
        ans = max(ans, maxR[i] - r[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4664
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N,M = map(int,input().split())
    H = list(map(int,input().split()))
    AB = [list(map(int,input().split())) for i in range(M)]

    next = [set([]) for i in range(N)]

    for i in range(M):
        temp1 = AB[i][0]
        temp2 = AB[i][1]
        next[temp1-1].add(temp2)
        next[temp2-1].add(temp1)

    res = 0

    for i in range(N):
        nownext = next[i]
        nowH = H[i]
        isGood = True
        for j in nownext:
            if H[j-1] >= nowH:
                isGood = False
                break
        if isGood:
            res += 1

    print(res)



main()


Measured memory_bytes: 57252
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t;
int cev;
string s;
vector<int> v;

int main(void){
	scanf("%d %d",&n,&m);
	printf("%d\n",n*(n-1)/2+m*(m-1)/2);
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int s;
    scanf("%d", &s);
    int a = s/100;
    int b = s%100;
    
    if(a <= 12 && a > 0){
        if(b > 0 && b <= 13 ) printf("AMBIGUOUS\n");
        else printf("MMYY\n");
        return 0;
    }else{
        if(b > 0 && b <= 12){
            printf("YYMM\n");
            return 0;
        } 
    }
    printf("NA\n");
    return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    A_ = [(a, i%2) for i, a in enumerate(A)]
    A_.sort()

    ans = 0
    for i, (_, j) in enumerate(A_):
        if i % 2 != j:
            ans += 1
    return ans // 2


def main():
    N = read_int()
    A = [read_int() for _ in range(N)]
    print(slv(N, A))


if __name__ == '__main__':
    main()


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

vector<int> v[10000], rev[10000], order, group(10000, 0);
vector<bool> vis(10000);

void dfs(int x){
    vis[x] = true;
    for(int j : v[x]){
        if(!vis[j]) dfs(j);
    }
    order.push_back(x);
}

void rdfs(int x, int k){
    group[x] = k;
    vis[x] = true;
    for(int j : rev[x]){
        if(!vis[j]) rdfs(j, k);
    }
}

int main(){
    int n, m;
    cin >> n >> m;
    while(m--){
        int s, t;
        cin >> s >> t;
        v[s].push_back(t);
        rev[t].push_back(s);
    }
    fill(vis.begin(),vis.end(),0);
    for(int i = 0; i < n; i++){
        if(!vis[i]) dfs(i);
    }
    fill(vis.begin(),vis.end(),0);
    int k = 0;
    for(int i = order.size()-1; i >= 0; i--){
        if(!vis[order[i]]) rdfs(order[i], k++);
    }
    int q;
    cin >> q;
    while(q--){
        int u, v;
        cin >> u >> v;
        cout << (group[u]==group[v]) << endl;
    }
    return 0;
}


Measured memory_bytes: 4824
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll a,b,c;cin>>a>>b>>c;
  ll d = a-b;
  ll ans = c-d;
  if(ans<0) ans = 0;
  cout<<ans<<endl;


}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<complex>
#include<string>
#include<cstring>

using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
int n;
string s;
vector<int> array;
int hai[5]={5,7,5,7,7};
int now;
int Count;
int flag;
int owari;
int main()
{
	while(1)
	{
		owari=0;
		array.clear();
		cin>>n;
		if(n==0)break;
		rep(i,n)
		{
			cin>>s;
			array.push_back(s.size());
		}
		rep(i,n)
		{
			flag=0;
			now=i;
			Count=0;
			while(1)
			{
				if(now==n)break;
				Count+=array[now];
				if(Count>hai[flag])break;
				else if(Count==hai[flag])
				{
					if(flag!=4)
					{
						flag++;
						Count=0;
					}
					else
					{
						cout<<i+1<<endl;
						owari=1;
						break;
					}
				}
				now++;
			}
			if(owari==1)break;
		}
	}
	return 0;
}

Measured memory_bytes: 1224
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n+2];
        a[0] = 0;
        for(int i=1;i<=n;i++){
            a[i] = sc.nextInt();
        }
        a[n+1] = 0;
        int[] b = new int[n+1];
        int sum = 0;
        for(int i=0;i<=n;i++){
            b[i] = 0;
            sum += Math.abs(a[i+1]-a[i]);
        }
        for(int i=1;i<=n;i++){
            b[i] = sum - Math.abs(a[i]-a[i-1]) - Math.abs(a[i+1]-a[i]) 
                    + Math.abs(a[i+1]-a[i-1]);
            System.out.println(b[i]);
        }
        
    }
}

Measured memory_bytes: 64072
class MyGraph
  attr_accessor :distance, :vec

  def initialize(n)
    @distance = Array.new(n+1,-1)
    @vec = Array.new(n+1,nil)
  end

  def breadth_search(n,dist)
    #p "begin:#{n}"
    #p "  dist:#{dist}"
    #p "  destance:#{@distance}"
    if @distance[n]==-1 or @distance[n]>dist
      @distance[n]=dist
    else
      return
    end
    @vec[n].each do |v|
      self.breadth_search(v,dist+1)
    end
    #p "end:#{n}"
  end

  def print_distance
    1.upto(@distance.length-1) do |i|
      print "#{i} #{@distance[i]}\n"
    end
  end
end

n = STDIN.gets().to_i

graph = MyGraph.new(n)

n.times do |i|
  u, k, *v = STDIN.gets().split(' ').map{ |i| i.to_i }
  graph.vec[u]=v
end

graph.breadth_search(1,0)

graph.print_distance

Measured memory_bytes: 8912
from heapq import *
def prim_heap():
    used = [False] * n
    e_lst = []
    for e in edge[0]:
        heappush(e_lst,e)
    used[0] = True
    res = 0
    while e_lst:
        e_min = heappop(e_lst)
        v = e_min[1]
        if used[v]: continue
        used[v] = True
        for e in edge[v]:
            if not used[e[1]]:
                heappush(e_lst, e)
        res += e_min[0]
    return res

n, k = map(int, input().split())
edge = [[] for _ in range(n)]
for _ in range(k):
    s, t, w = map(int, input().split())
    edge[s].append((w, t))
    edge[t].append((w, s))
print(prim_heap())


Measured memory_bytes: 31812