akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <set>
#include <list>
#include <cstdio>
#include <cmath>
#include <deque>
#include <stack>
#include <bitset>
#include <cctype>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define fr first
#define sc second
#define mp make_pair

typedef long long int64;
typedef pair< int, int > iP;
typedef pair< iP, int > iiP;

const int INF = 2 << 28;
const double EPS = 1e-10;

int main() {
    
    int n, m;
    while(cin >> n >> m, n) {
        int sumt = 0, sumh = 0;
        vector< int > ts(n), hs(m);
        for(int i = 0; i < n; i++) {
            cin >> ts[i]; sumt += ts[i];
        }
        for(int i = 0; i < m; i++) {
            cin >> hs[i]; sumh += hs[i];
        }
        int mint = INF, minh = INF;
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m; j++) {
                if(sumt - ts[i] + hs[j] == sumh - hs[j] + ts[i] && mint + minh > ts[i] + hs[j])
                    mint = ts[i], minh = hs[j];
            }
        }
        if(mint == INF) cout << -1 << endl;
        else cout << mint << " " << minh << endl;
    }
}

Measured memory_bytes: 1196
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const ll INF = 1e19 + 7;
const int MAXN = 1e5 + 5;
const double eps = 1e-9;
ll dp[MAXN];

int main()
{
    fill(dp, dp + MAXN, INF);
    int n, w;
    scanf("%d %d", &n, &w);
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        int wi, vi;
        scanf("%d %d", &wi, &vi);
        for (int j = MAXN - 1 - vi; j >= 0; j--)
            if (dp[j] != INF || j == 0)
                dp[j + vi] = min(dp[j + vi], dp[j] + wi);
    }
    ll ans = 0;
    for (int i = MAXN - 1; i >= 0; i--)
        if (dp[i] <= w) {
            ans = i;
            break;
        }
    prl(ans);
    return 0;
}


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

int main() {
    int N,K;
    cin >> N >> K;
    vector<int> h(N);
    rep(i, N) cin >> h[i];
    vector<int> dp(N);

    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);

    for(int i = 2;i<N;i++){
        int m = 1e9 + 7;
        for(int k = 1;k<=K;k++){
            if(i-k < 0) continue;
            m = min(m,dp[i-k] + abs(h[i]-h[i-k]));
        }
        dp[i] = m;
    }

    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1024
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        String s = sc.next();
        System.out.println(Math.min(count(s,'1'),count(s,'0')));
        sc.close();
    }
    static int count(String s,char c){
        char pre = c;
        int cnt = 0;
        if(pre != s.charAt(0)) ++cnt;
        for(int i = 1; i<s.length(); i++){
            //System.out.println(pre);
            if(s.charAt(i) == pre) cnt++;
            if(pre == '1') pre = '0';
            else pre = '1';
        }
        return cnt;
    }
}

Measured memory_bytes: 26828
//Volume0-0048
import java.util.*;

public class Main {

	public static void main(String[] args) {
		
		//declare
		float weight;
		String class_;
		
		//input
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			weight = sc.nextFloat();
			
			//calculate
			class_ = null;
			if     (91.00 < weight){class_ = "heavy";       }
			else if(81.00 < weight){class_ = "light heavy"; }
			else if(75.00 < weight){class_ = "middle";      }
			else if(69.00 < weight){class_ = "light middle";}
			else if(64.00 < weight){class_ = "welter";      }
			else if(60.00 < weight){class_ = "light welter";}
			else if(57.00 < weight){class_ = "light";       }
			else if(54.00 < weight){class_ = "feather";     }
			else if(51.00 < weight){class_ = "bantam";      }
			else if(48.00 < weight){class_ = "fly";         }
			else                   {class_ = "light fly";   }
			
			//output
			System.out.println(class_);
		}
	}
}

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

typedef long long ll;
typedef pair<int, int> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int solve(string s) {
  int sum = 0;
  int num = 1;
  dep(i, s.length() - 1, 0) {
    sum += ((int)s[i] - 48) * num;
    num *= 10;
  }
  return sum;
}

int main() {
  int a, b;
  while(cin >> a >> b && a) {
    int aa[a];
    rep(i, 0, a) aa[i] = i + 1;
    aa[a - 1] = 0;
    int sum = 0;
    string s;
    int z = a - 1, i = 0;
    rep(j, 0, b) {
      sum++;
      cin >> s;
      if(!(sum % 5) && !(sum % 3)) {
        if(s == "FizzBuzz") {z = i; i = aa[i]; continue;}
      }else if(!(sum % 5)) {
        if(s == "Buzz") {z = i; i = aa[i]; continue;}
      }else if(!(sum % 3)) {
        if(s == "Fizz") {z = i; i = aa[i]; continue;}
      }else {
        if(s[0] >= '0' && s[0] <= '9') {
          if(sum == solve(s)) {z = i; i = aa[i]; continue;}
        }
      }
      if(aa[z] == aa[i]) {
        aa[0] = -3;
        break;
      }
      aa[z] = aa[i];
      i = aa[i];
    }
    while(1) {
      if(aa[i] <= i) {
        i = aa[i];
        break;
      }
      i = aa[i];
    }
    bool first = true;
    while(1) {
      if(aa[i] == -1) break;
      if(!first) cout << " ";
      first = false;
      cout << i + 1;
      int sum = aa[i];
      aa[i] = -1;
      i = sum;
    }
    cout << endl;
  }
}

Measured memory_bytes: 3140
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

int main()
{
    int R, G, B, n;
    cin >> R >> G >> B >> n;
    int ans = 0;
        for(int g = 0; g < n/G + 1; g++){
            for(int b = 0; b < n/B + 1; b++){
                if((n-b*B-g*G)%R == 0 && n-b*B-g*G>=0) ans++;
            }
        }   
    cout << ans << endl;
    return 0;
}

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

int main() {
  int H,W;
  char n;
  cin>>H>>W;
  for(int i=0;i<W+2;i++){
  cout<<"#";}
  cout<<endl;
  for(int i=0;i<H;i++){
    cout<<'#';
  for(int j=0;j<W;j++){
    cin>>n;
  cout<<n;}
  cout<<'#'<<endl;}
  for(int i=0;i<W+2;i++){
  cout<<"#";}
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;


int main(){

	int a[3],box;
	cin >> a[0] >> a[1] >> a[2];

	for(int i =0;i < 2;i++){
		if(a[0] > a[1]){
			box = a[0];
			a[0] = a[1];
			a[1] = box;
		}
		if(a[1] > a[2]){
			box = a[1];
			a[1] = a[2];
			a[2] = box;
		}
	}

	cout << a[0] << " " << a[1] << " " <<a[2] <<"\n";

	return 0;
}



Measured memory_bytes: 3092
s=[input() for _ in range(int(input()))]
def c(b):return str(s.count(b))
x=' x '
n='\n'
a='AC'
w='WA'
t='TLE'
r='RE'
print(a+x+c(a)+n+w+x+c(w)+n+t+x+c(t)+n+r+x+c(r))

Measured memory_bytes: 16308
X, Y, A, B, C = list(map(int, input().split()))
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P.sort(reverse=True)
Q.sort(reverse=True)

P = P[:X]
Q = Q[:Y]

P.sort()
Q.sort()
R.sort(reverse=True)

p_i = 0
q_i = 0

for ri in R:
    if p_i >= len(P) and q_i >= len(Q):
        break
    if p_i >= len(P):
        if ri >= Q[q_i]:
            Q[q_i] = ri
            q_i += 1
    elif q_i >= len(Q):
        if ri >= P[p_i]:
            P[p_i] = ri
            p_i += 1
    elif ri < P[p_i] and ri < Q[q_i]:
        break
    elif ri > P[p_i] and ri > Q[q_i]:
        d1 = ri - P[p_i]
        d2 = ri - Q[q_i]
        if d1 > d2:
            P[p_i] = ri
            p_i += 1
        else:
            Q[q_i] = ri
            q_i += 1
    elif ri > P[p_i] and ri < Q[q_i]:
        P[p_i] = ri
        p_i += 1
    else:
        Q[q_i] = ri
        q_i += 1


# print(P, Q)
ans = sum(P) + sum(Q)
print(ans)



Measured memory_bytes: 23328
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける
const ll llMAX=9223372036854775807LL; 
const ll llMIN=-9223372036854775808LL;

ll x,k,d;

//bbbは正の数
ll floordiv(ll aaa,ll bbb)
{
  if (aaa<0){
    return (aaa-bbb+1)/bbb;
  }else{
    return aaa/bbb;
  }
}
ll floormod(ll aaa,ll bbb)
{
  ll ret=aaa%bbb;
  if (ret<0)ret+=bbb;
  return ret;
}



int main(){
  ll ans=0;
  cin>>x>>k>>d;
  ll ansp=floordiv(x,d);
  ll pmodx=x-d*ansp;
  ll mmodx=pmodx-d;
  ll ansm=ansp-1;
  ansp=abs(ansp);
  ansm=abs(ansm);

  if ((ansp>k)&(ansm>k)){
    x-=d*k*(1-2*(x<0));
    ans=x;
  }else{
    if (floormod(ansp,2)==k%2)ans=pmodx;
    if (floormod(ansm,2)==k%2)ans=mmodx;
  }
  



  
  cout<<abs(ans)<<endl;
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

void solve()
{
	string s;
	cin >> s;
	cout << s[0];
	cout << s.size() - 2;
	cout << s[s.size() - 1] << endl;
}

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

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

#define make_it_fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define ll long long
#define ld long double
#define endl "\n"
#define ff first
#define ss second
#define imn INT_MIN
#define imx INT_MAX

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}

template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}

void _print() {cerr << "]\n";}

template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...) 20
#endif

ll power(ll a,ll b,ll m=1e9+7)
{
    a%=m;
    if(b==1)
    return a;
    if(b==0)
    return 1;
    ll ret=power(a,b/2);
    ret=(ret*ret)%m;
    if(b&1)
    ret=(ret*a)%m;
    return ret;
}

ll lcm(ll a,ll b)
{
    return (a*b)/(__gcd(a,b));
}

void solve()
{
    ll n,i,m=1e9+7;
    cin>>n;
    if(n==1)
    {
        cout<<0<<endl;
        return;
    }
    if(n==2)
    {
        cout<<2<<endl;
        return;
    }
    ll ans=power(10,n);
    ans=(ans+power(8,n)+m)%m;
    ans=(ans-(2*power(9,n))%m+m)%m;
    cout<<ans<<endl;
}

int main()
{
    make_it_fast;
    int TEST_CASES=1;
    // cin>>TEST_CASES;
    while(TEST_CASES--)
    {
        solve();
    }
    return 0;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <int, int> ii;

const int mod = 1e9 + 7;
const ll INF = (1LL<<50);
const double EPSILON = 0.001;
const int N = 200005;
int main(){
	fastio;
	ll ones, zer, none, k, ans = 0;
	cin >> ones >> zer >> none >> k;
	if(ones >= k){
		ans = k;
		k = 0;
	}else{
		ans += ones;
		k -= ans;
	}
	if(k > 0){
		if(zer >= k)
			k = 0;
		else
			k -= zer;
	}
	if(k > 0){
		ans -= min(k,none);
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3624
// Problem : E - Count Median
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define vii vector<pii>
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}
 
ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 


int solve(){
	int n;cin>>n;
	int a[n];int b[n];
	// inputarr(a,n);
	rep0(n) cin>>a[i]>>b[i];
	// inputarr(b,n);
	sort(a,a+n);
	sort(b,b+n);
	if(n%2){
		// trace(b[n/2],a[n/2]);
		cout<<b[n/2]-a[n/2]+1<<endl;r0
	}
	cout<<b[n/2]-a[n/2] + b[(n-1)/2]-a[(n-1)/2] + 1<<endl;



    return 0;
}
signed main(){
    asdf
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 6744
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep2(i,n) for(int i=1; i<=(n); ++i)
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(),(x).end())
#define Sort2(x) sort((x).begin(),(x).end(), greater<int>())
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

/*
Ctrl+@ でコンソールを開け、以下で実行。
g++ c.cpp
./a.out

サンプルのダウンロードは oj d URL
テストは oj t
コード変えたらコンパイルする
不正解ならWAが出る
*/

Measured memory_bytes: 4048
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define mpair(v1, v2)    make_pair(v1, v2);
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

//----------------------------------------------------------------

int main(void) {
  int n, m;
  cin >> n >> m;
  vpairll drink(n);
  rep(i,n){
    ll a, b;
    cin >> a >> b;
    drink[i] = mpair(a, b);
  }

  sortall(drink);

  int id=0;
  ll ans=0;
  while(m>0){
    if(drink[id].second>0){
      ans+=drink[id].first;
      drink[id].second--;
      m--;
    } else {
      id++;
    }
  }

  prt(ans);

}


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

int main() {
	string s,t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	
	if(s<t) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int x,y,h,w;
    
    while(1){
        scanf("%d %d\n",&x,&y);
        if(0 == x && 0 == y){
            break;
        }else{
            for(h = 0; h < x; h++){
                for(w = 0; w < y; w++){
                    printf("#");
                }
                printf("\n");
            }
            printf("\n");
        }
    }
    
    return 0;
}

Measured memory_bytes: 1804
#include <stdio.h>
#define N 100000
#define NIL -1

typedef struct{int p, l, r;}Tree;

Tree t[N];
int n, d[N], k[N];

int Depth(int x, int p)
{
  d[x] = p;
  if(t[x].r != NIL) Depth(t[x].r, p);
  if(t[x].l != NIL) Depth(t[x].l, p+1);
}

void print(int x)
{
  int i, j, c;
  printf("node %d: parent = %d, depth = %d, ", x, t[x].p, d[x]);

  if(t[x].p == NIL) printf("root, ");
  else if(t[x].l == NIL) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for(i = 0, c = t[x].l; c != NIL; i++, c = t[c].r){
    if(i > 0) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
}

int main()
{
  int i, j, c, id, d, l, r;

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    t[i].p = NIL;
    t[i].l = NIL;
    t[i].r = NIL;
  }
  
  for(i = 0; i < n; i++){
    scanf("%d%d", &id, &k[i]);
    for(j = 0; j < k[i]; j++){
      scanf("%d", &c);
      if(j == 0) t[id].l = c;
      else t[l].r = c;
      l = c;
      t[c].p = id;
    }
  }

  for(i = 0; i < n; i++){
    if(t[i].p == NIL) r =i;
  }
  Depth(r, 0);
  for(i = 0; i < n; i++) print(i);

  return 0;
}

Measured memory_bytes: 5688
import java.util.*;
import java.io.*;
import java.math.BigDecimal;

public class Main {	

	private static void solve(){
		//Implement solution here.
		int K = ni();
		long result = 0;
		for(int i = 1; i <= K; i++) {
			for(int j = 1; j <= K; j++) {
				for(int k = 1; k <= K; k++) {
					result += gcd(gcd(i,j),k);
				}	
			}	
		}
		System.out.println(result);
	}

	//Find greatest common divisor
	static int gcd (int a, int b) {
		return b > 0 ? gcd(b, a%b) : a;
	}
	
	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 25912
N=int(input())
Alist=list(map(int,input().split()))
Blist=list(map(int,input().split()))
Clist=list(map(int,input().split()))

Cplus=0
for n in range (N-1):
  if Alist[n+1] == Alist[n]+1:
    Cplus += Clist[Alist[n]-1]

print(sum(Blist)+Cplus)

Measured memory_bytes: 3064
N=int(input())
s=list(map(int, input().split()))

maxans=0
pre=s[0]
tmpans=0
for i in range(1,N):
  now=s[i]
  if pre>=now:
    tmpans+=1
  else:
    tmpans=0
  pre=now
  maxans=max(tmpans, maxans)
print(maxans)

Measured memory_bytes: 15020
def merge_sort(arr, &block)
  return arr if arr.size <= 1

  mid = arr.size / 2

  arr1 = arr[0...mid]
  arr2 = arr[mid..-1]

  merge(merge_sort(arr1, &block), merge_sort(arr2, &block), &block)
end

def merge(arr1, arr2, &block)
  ret = []

  until arr1.empty? || arr2.empty?
    if arr1.first <= arr2.first
      ret << arr1.shift
    else
      ret << arr2.shift
    end

    block.call
  end

  unless arr1.empty?
    ret.push(*arr1)
    arr1.size.times { block.call }
  end

  unless arr2.empty?
    ret.push(*arr2)
    arr2.size.times { block.call }
  end

  ret
end

n = gets.to_i
arr = gets.split.map(&:to_i)

count = 0

puts merge_sort(arr) { count += 1 }.join(' ')

puts count

Measured memory_bytes: 70112
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(int i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

//M桁め以下の、０でない数字が１この整数
int count(vector<int> & N, int M) {
	if (M == 0) return 0;
	return N[M] + 9 * (M - 1);
}

int msn0(vector<int>& N, int M) {
	while (N[M] == 0 && M > 0) --M;
	return M;
}

int count2(vector<int>& N, int M) {
	if (M <= 1)return 0;
	ll ans = 0;
	ans += count(N, msn0(N, M - 1));
	ans += 9 * (N[M] - 1) * (M - 1);
	ans += 81 * (M - 1) * (M - 2) / 2;
	return ans;
}

int count3(vector<int>& N, int M) {
	ll ans = 0;
	ans += count2(N, msn0(N, M - 1));
	ans += 81 * (N[M] - 1) * (M - 1) * (M - 2) / 2;
	ans += 81 * 9 * (M - 1) * (M - 2) * (M - 3) / 6;
	return ans;
}

int main() {
	string s;
	int K;
	int M;
	cin >> s >> K;
	M = s.size();
	vector<int> N(M + 1);
	for (int i = 0; i < M; ++i) N[M - i] = s[i] - '0';
	if (M < K) PRI(0);
	else if (K == 1) PRI(count(N, M));
	else if (K == 2) PRI(count2(N, M));
	else PRI(count3(N, M));
	return 0;
}




Measured memory_bytes: 3628
#include <iostream>
#include<algorithm>
using namespace std;
int main()
{
	long int n;
    cin>>n;
    long int a[n+1][3];
    for(int i=0;i<n;i++)
    {
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    long int dp[n+1][3];
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    for(int i=1;i<n;i++)
    {
        dp[i][0] = max(dp[i-1][1],dp[i-1][2])+a[i][0];
        dp[i][1] = max(dp[i-1][0],dp[i-1][2])+a[i][1];
        dp[i][2] = max(dp[i-1][1],dp[i-1][0])+a[i][2];
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
using ld=long double;
//template
//main
signed main(){
  int N;cin>>N;
  std::vector<ld> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  sort(v.begin(),v.end());
  for(int i=1;i<N;i++)v[i]=(v[i]+v[i-1])/2;
  cout<<fixed<<setprecision(12)<<v[N-1]<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        String s = sc.next();
        LinkedList<Integer> list = new LinkedList<>();
        for (int i = 0;i < s.length();i++) {
            int v = (int)s.charAt(i);
            if (v==83) {
                list.addLast(v);
            } else {
                if (!list.isEmpty()&&list.getLast()==83) {
                    list.pollLast();
                } else {
                    list.addLast(v);
                }
            }
        }
        System.out.println(list.size());
    }
}


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

int main(void){
  string s;
  int mon, day;
  string out;
  
  cin >> s;
  
  mon = atoi(s.substr(5, 2).c_str());
  day = atoi(s.substr(8, 2).c_str());
  
  if(mon < 4){
    out = "Heisei";
  }else if(mon==4){
    if(day<=30){
      out = "Heisei";
    }
  }else{
    out = "TBD";
  }
  cout << out << endl;
  return 0;
}

Measured memory_bytes: 256
x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

ab = []
for i in range(x):
    for j in range(y):
        ab.append(a[i] + b[j])
ab.sort(reverse = True)

abc = []
for i in range(min(k,len(ab))):
    for j in range(z):
        abc.append(ab[i] + c[j])

abc.sort(reverse = True)

for i in range(k):
    print(abc[i])

Measured memory_bytes: 147776
#include <bits/stdc++.h>
using namespace std;
 
int main() {
string S;
cin >> S;
if (S == "Sunny"){
    cout << "Cloudy" << endl;
}else if(S == "Cloudy"){
    cout << "Rainy" << endl;
}else{
    cout << "Sunny" << endl;
}
}
    


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N; cin >> N;
    VS s(N); REP(i,N) cin >> s[i];
    int M; cin >> M;
    VS t(M); REP(i,M) cin >> t[i];
    map<string, int> ms;
    REP(i,N){
        if(EXIST(ms, s[i])) ms[s[i]]++;
        else ms[s[i]] = 1;
    }
    REP(i,M){
        if(EXIST(ms, t[i])) ms[t[i]]--;
    }
    int ans = 0;
    for(auto p : ms){
        ans = max(ans, p.second);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//#define _USE_MATH_DEFINES
//#include <cmath>
#include <iostream>
//#include <stdio.h>
//#include <stdlib.h>
//#include <iomanip>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <functional>
//#include <time.h>
//#include <sstream>
#include <queue>

using namespace std;


int main(){

	int buf;
	priority_queue <int> pq;

	while (cin >> buf){
		pq.push(buf);
	}

	while (pq.size()>1){
		cout << pq.top() << " ";
		pq.pop();
	}
	cout << pq.top() << endl;

	return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
int n,p1,a[3];
int main() {
    cin>>n;
    for (int i=0; i<n; i++) {
        cin>>p1;
        if (p1%4==0) a[2]++;
        else if (p1%2==0) a[1]++;
        else a[0]++;
    }
    if (a[2]>=a[0]+a[1]) cout<<"Yes\n";
    else {
        if (a[2]>a[0]) cout<<"Yes\n";
        else {
            a[0]-=a[2];
            if (a[0]>1) cout<<"No\n";
            else if (a[0]==1) {
                if (a[1]>0) cout<<"No\n";
                else cout<<"Yes\n";
            }
            else cout<<"Yes\n";
        }
    }
}

Measured memory_bytes: 3592
#!/usr/bin/env python3
def fun(x):
	res = [x, 1, x+1, 0]
	return res[x%4]
# same as res = [x, 1, x+1, 0][x%4]
# two dimensional array : 
# list1 = [[0]*3]*2 -> [[0, 0, 0], [0, 0, 0]]
# list2 = [[0 for i in range(3)] for j in range(2)] 
# 			-> [[0, 0, 0], [0, 0, 0]]
# list3 = [[1, 2, 3], [10, 20, 30], [100, 200, 300]]
# 			-> [[1, 2, 3], [10, 20, 30], [100, 200, 300]]

a, b = map(int, input().split())
print(fun(b)^fun(a-1))


Measured memory_bytes: 2940
/*
#include <boost/multiprecision/cpp_int.hpp>
typedef boost::multiprecision::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,(n))
#define  red(i,n) for(li i=n-1;i>=0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;


int main()
{
    int n,m,sum=0,p,x;
    cin>>n;
    int t[n];
    rep(i,n) cin>>t[i],sum+=t[i];
    cin>>m;
    rep(i,m){
        cin>>p>>x;
        cout<<sum+x-t[p-1]<<endl;
    }  
    return 0;
}

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

long long N, K;
int main(){
	cin >> N >> K;
	set<long long> s;

	for(long long i = 0; i < K; i++) {
		long long d;
		cin >> d;
		for(long long j = 0; j < d; j++) {
			long long tmp;
			cin >> tmp;
			s.insert(tmp);
		}
	}
	cout << N - s.size() << endl;
}


Measured memory_bytes: 3580
package main

import (
	"fmt"
	"io/ioutil"
	"os"
	"strconv"
	"strings"
)

func insertSort(arr []int) {
	fmt.Println(join(arr, " "))
	for i, l := 1, len(arr); i < l; i++ {
		for j := i; j > 0 && arr[j] < arr[j-1]; j-- {
			arr[j], arr[j-1] = arr[j-1], arr[j]
		}
		fmt.Println(join(arr, " "))
	}
}

func join(arr []int, sep string) string {
	s := strconv.Itoa(arr[0])
	for i, l := 1, len(arr); i < l; i++ {
		s += sep + strconv.Itoa(arr[i])
	}
	return s
}

func main() {

	buf, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		fmt.Fprint(os.Stderr, err)
	}
	str := string(buf)
	arr := strings.Split(str, "\n")
	arr = strings.Split(arr[1], " ")
	var arr2 []int
	for _, v := range arr {
		v, err := strconv.ParseInt(v, 10, 32)
		if err != nil {
			os.Exit(1)
		}
		arr2 = append(arr2, int(v))
	}
	insertSort(arr2)
}



Measured memory_bytes: 3296
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define deb(x) cout<<#x<<" "<<x<<endl;
#define print(arr,n) for(int i=0;i<n;++i) { cout<<arr[i]<<" "; } cout<<endl;
#define ub(x,el) upper_bound(x.begin(),x.end(),el) - x.begin()
#define lb(x,el) lower_bound(x.begin(),x.end(),el) - x.begin();
#define bs(x,el) binary_search(x.begin(),x.end(),el)
#define MOD 1000000007
#define finish return 0
using namespace std;
using namespace __gnu_pbds; 
typedef long long int ll;
typedef tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
inline ll mod(ll x) { return x%MOD; }
ll power(ll x,ll y, ll p) { ll res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res*x) % p; y = y>>1; x = (x*x) % p;   } return res; } 
ll power(ll x,ll y) { ll res = 1; while (y > 0) { if (y & 1) res = (res*x); y = y>>1; x = (x*x);   } return res; } 
ll mod(ll num, ll den){ return mod(mod(num) * power(den,MOD-2,MOD)); }
void func(vector<ll> &a, vector<ll> &b, vector<ll> &c, ll &ans)
{
	for(ll i=0;i<a.size();++i)
	{
		ll idx = lb(b,a[i]);
		for(ll j=idx;j<b.size();++j)
		{
			ll val1 = b[j] - a[i];
			ll idx2 = lb(c,b[j]);
			ans += (c.size()-idx2);
			if(binary_search(c.begin()+idx2,c.end(),val1+b[j])) ans--;
		}
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n;
	cin>>n;
	string s;
	cin>>s;
	vector<ll> r,g,b;
	for(ll i=0;i<n;++i)
	{
		if(s[i] == 'R') r.push_back(i);
		else if(s[i] == 'G' ) g.push_back(i);
		else b.push_back(i);
	}
	ll ans = 0;
	func(r,g,b,ans);
//	deb(ans);
	func(r,b,g,ans);
//	deb(ans);
	func(g,r,b,ans);
//	deb(ans);
	func(g,b,r,ans);
//	deb(ans);
	func(b,r,g,ans);
//	deb(ans);
	func(b,g,r,ans);
//	deb(ans);
	cout<<ans<<endl;
}

Measured memory_bytes: 3676
#include<stdio.h>
#define N 100

int m[N][N],p[N];

int main(){
  int n, i, q, l, k, j;
  
  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d %d",&p[i-1],&p[i]);
  }

  for(i=1;i<=n;i++){
    m[i][i] = 0;
  }
  
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j = i + l - 1;
      m[i][j] = 10000000;
      for(k = i; k <= j - 1; k++){
	q = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];
	if(m[i][j] < q){
	  m[i][j] = m[i][j];
	}else{
	  m[i][j] = q;
	}
      }
    }
  }
  
  printf("%d\n",m[1][n]);

  return 0;
}



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

using namespace std;

typedef long long ll;
#define pb push_back
#define dbg(x) cerr << #x << " " << x << "\n"

int main() {

    ios::sync_with_stdio (false);
    cin.tie (0); cout.tie (0);

    ll n, a, b;
    cin >> n >> a >> b;

    if ((b - a) % 2 == 0) {
        cout << (b - a) / 2;
        return 0;
    }

    /// get a to 1

    ll moves = a;
    ll b2 = b;
    b2 -= moves;
    ll ans = (b2 - 1) / 2 + moves;
    moves = (n - b + 1);
    ll a2 = a;
    a2 += moves;
    ans = min (ans, (n - a2) / 2 + moves);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
let () = Scanf.scanf "%d\n%s" @@ fun n s ->
  print_endline @@
  if
    ( < ) 0
    @@ Array.fold_left (fun acc c ->
      acc + if c = 'R' then 1 else -1) 0
    @@ Array.init n @@ String.get s
  then "Yes"
  else "No"


Measured memory_bytes: 384
package main

import "fmt"

const MAXN = 110

func main() {
	var N int
	fmt.Scanf("%d\n", &N)

	var a [2][MAXN]int
	for j := 0; j < 2; j++ {
		for i := 0; i < N; i++ {
			fmt.Scanf("%d", &a[j][i])
		}
	}

	ret := 0
	for i := 0; i < N; i++ {
		score := 0
		for j := 0; j < N; j++ {
			if j <= i {
				score += a[0][j]
			}
			if j >= i {
				score += a[1][j]
			}
		}
		if score > ret {
			ret = score
		}
	}
	fmt.Printf("%d\n", ret)
}


Measured memory_bytes: 512
#include <stdio.h>
#define MAX 101
#define INF 1000000
#define NIL -2
#define WHITE 0
#define BLACK 1

int main() {
  int n, i, j, adj[MAX][MAX], d[MAX], pi[MAX], c[MAX], mincost, u, answer=0;
  
  scanf( "%d" , &n );
  for ( i=1; i<=n; i++ ) {
    for ( j=1; j<=n; j++ ) scanf( "%d" , &adj[i][j] );
    if ( i == 1 ) d[i] = 0; else d[i] = INF;
    pi[i] = NIL;
    c[i] = WHITE;
  }

  while ( 1 ) {
    mincost = INF;
    for ( i=1; i<=n; i++ )
      if ( (c[i] != BLACK) && (d[i] < mincost) ) {
	mincost = d[i];
	u = i;
      }
    if ( mincost == INF ) break;
    c[u] = BLACK;
    for ( j=1; j<=n; j++ )
      if ( (adj[u][j] != -1) && (c[j] != BLACK) && (adj[u][j] < d[j]) ) {
	pi[j] = u;
	d[j] = adj[u][j];
      }
  }

  //for ( i=1; i<=n; i++ ) printf("%d %d %d %d\n",i,d[i],pi[i],c[i]);
  //printf("%d\n",mincost);//3864

  for ( i=1; i<=n; i++ ) if ( pi[i] != NIL ) answer += adj[i][pi[i]];
  printf( "%d\n" , answer );
  
  return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
#define Max 1000001
#define inf INT_MAX
#define llinf LONG_LONG_MAX
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define endl '\n'
const ll N=2e5+5,mod=1000000007,bit=60;
signed main()
{
    fast;
    ll pro=1,temp,t,i,j,l,r,n,m,mid,z,k,x,y,rem,carry=0,ind,ans=0,mx=-llinf,mn=llinf,cnt=0,curr=0,prev,next,sum=0,flag=1,i1=-1,i2=-1,u,v;
    string s;
    cin>>s;
    n=s.length();
    i=n-1;
    while(s[i]=='0' && i>=0)
    {
    	i--;
    }
    s.erase(i+1,(n-i));
    n=s.length();
    if(n==0)
    {
    	return cout<<0,0;
    }
    ll dp[n+1][2];
    dp[n-1][0]=(s[n-1]-'0');
    dp[n-1][1]=10-(s[n-1]-'0');
    for(i=n-2;i>=0;i--)
    {
    	dp[i][0]=min(dp[i+1][0],1+dp[i+1][1])+(s[i]-'0');
    	dp[i][1]=9-(s[i]-'0')+min(dp[i+1][1],1+dp[i+1][0]);
    }
    cout<<min(dp[0][0],dp[0][1]+1)<<endl;
	return 0;
}	

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

int main()
{
	int i, N, M;
	char A[52][52] = {}, B[52][52] = {};
	scanf("%d %d", &N, &M);
	for (i = 1; i <= N; i++) scanf("%s", &(A[i][1]));
	for (i = 1; i <= M; i++) scanf("%s", &(B[i][1]));
	
	int j, k, l, flag = 0;
	for (i = 0; i <= N - M; i++) {
		for (j = 0; j <= N - M; j++) {
			for (k = 1; k <= M; k++) {
				for (l = 1; l <= M; l++) {
					if (A[i+k][j+l] != B[k][l]) break;
				}
				if (l <= M) break;
			}
			if (k > M) flag = 1;
		}
	}
	
	if (flag == 1) printf("Yes\n");
	else printf("No\n");
	fflush(stdout);
	return 0;
}

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

int main(){
  int N;
  vector<int> v;
  cin >> N;
  for(int i=0; i<N; i++){
    int x; cin >> x;
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  int count=1;
  int pre = v[0];
  for(int i=1; i<N; i++){
    if(v[i]!=pre){
      count++;
      pre = v[i];
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int compare(const void *a,const void *b){
    return *(int*)a-*(int*)b;
}
int main(){
    int n,i,a[100001],r;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    qsort(a,n,sizeof(int),compare);
    
    int dis=a[n-1];
    
    if(a[n-1]%2==1){
        for(i=0;i<n;i++){
        if(dis>abs((a[n-1]+1)/2-a[i])){
            dis=abs((a[n-1]+1)/2-a[i]);
            r=a[i];
            }
        }
    }else{
        for(i=0;i<n;i++){
            if(dis>abs(a[n-1]/2-a[i])){
                dis=abs(a[n-1]/2-a[i]);
                r=a[i];
            }
        }
    }
    printf("%d %d",a[n-1],r);
    return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);
using namespace std;

const int N=100005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x=(x+y)%mod;}
template<class T> inline void read(T &x){
	x=0;char ch=getchar(),rev=0;
	while(ch>'9'||ch<'0') rev=(ch=='-'),ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	x=rev?-x:x;
}
template<class T> inline void print(T x){
	if(!x){puts("0");return;}
	if(x<0){putchar('-');x=-x;}
	int a[20],m=0;
	while(x) a[m++]=x%10,x/=10;
	while(m--) putchar(a[m]+'0');puts("");
}
inline int exp(int x,int y){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

int n,m,si[N];
set<pii> a,b;
queue<pii> q;
void insa(int u,int v){
	a.insert(mp(u,v));
	a.insert(mp(v,u));
	si[u]++;si[v]++;
}
void insb(int u,int v){
	b.insert(mp(u,v));
	b.insert(mp(v,u));
	si[u]++;si[v]++;
}
void dela(int u,int v){
	a.erase(mp(u,v));
	a.erase(mp(v,u));
}
void delb(int u,int v){
	b.erase(mp(u,v));
	b.erase(mp(v,u));
}
vi tmp;
void merge(int u,int v){
	if(si[u]<si[v]) swap(u,v);
	si[u]+=si[v];m++;
	set<pii>::iterator it=a.lower_bound(mp(v,0));
	tmp.clear();
	for(;it!=a.end();it++)
		if((*it).FF!=v) break; else tmp.pb((*it).SS);
	for(int i=0;i<tmp.size();i++){
		int y=tmp[i];
		dela(v,y);insa(u,y);
//		printf("a:(%d,%d)->(%d,%d)\n",v,y,u,y);
		if(b.find(mp(u,y))!=b.end()) q.push(mp(u,y));
	}
	it=b.lower_bound(mp(v,0));
	tmp.clear();
	for(;it!=b.end();it++)
		if((*it).FF!=v) break; else tmp.pb((*it).SS);
	for(int i=0;i<tmp.size();i++){
		int y=tmp[i];
		delb(v,y);insb(u,y);
//		printf("b:(%d,%d)->(%d,%d)\n",v,y,u,y);
		if(a.find(mp(u,y))!=a.end()) q.push(mp(u,y));
	}
}

int main(){
#ifdef rqgao2014
	freopen("input.txt","r",stdin);
	srand(time(0));
#endif
	ios::sync_with_stdio(0);
	read(n);
	for(int i=1;i<n;i++){
		int u,v;read(u);read(v);
		insa(u,v);
	}
	for(int i=1;i<n;i++){
		int u,v;read(u),read(v);
		insb(u,v);
		if(a.find(mp(u,v))!=a.end()) 
			q.push(mp(u,v));
	}
	while(!q.empty()){
		int x=q.front().FF,y=q.front().SS;q.pop();
//		printf("%d %d\n",x,y);
		if(a.find(mp(x,y))==a.end()) continue;
		dela(x,y);delb(x,y);
		merge(x,y);
	}
	if(m==n-1) puts("YES"); else puts("NO");
#ifdef rqgao2014
	time_tester(1);
#endif
	return 0;
}


Measured memory_bytes: 21760
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    int a;
    readf("%s", &a);
    readln;
    auto s = readln.chomp;
    
    if (a >= 3200) { writeln(s); }
    else { writeln("red"); }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<utility>
#include<queue>
#include<stdbool.h>
#include<math.h>
#include<sstream>
typedef long long ll;
#define N (1000000000+7)
using namespace std;
typedef pair<int, int> P;

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

int main(void) {
	int a, b;
	cin >> a >> b;
	if (b%a == 0)cout << a + b << endl;
	else cout << b - a << endl;
	return 0;
}

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

#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    int X, SupN;
    scanf("%d", &X);
    int Number, Digit;
    Number = X / 100;
    Digit  = X - Number * 100;
    SupN = 0;
    for( int i = 5; i >= 1; i-- ){
        SupN += Digit / i;
        if ( SupN <= Number ){
            Digit = Digit % i;
        }
        else{
            printf("0\n");
            return 0;
        }
    }
    printf("1\n");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if(a > b){
        cout << "a > b" << endl;
    } else if(a == b){
        cout << "a == b" << endl;
    } else{
        cout << "a < b" << endl;
    }
    return 0;
}



Measured memory_bytes: 3084
import bisect
import collections
import sys

sys.setrecursionlimit(100000)
input = sys.stdin.readline
ACMOD = 1000000007
INF = 1 << 32


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


def llmi(n):
    return [lmi() for _ in range(n)]


H, W = lmi()
if H == 1 or W==1:
    print(1)
    exit()
movable = (H*W+1)//2
print(movable)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define LL long long
#define M 1000005 
using namespace std;
const int P=1e9+7;
int main(){
	char s[10];
	scanf("%s",s);
	sort(s,s+4);
	if(s[0]==s[1]&&s[1]!=s[2]&&s[2]==s[3])puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 384
line_one = gets.chomp.split
road_count = line_one[1].to_i
city_count = line_one[0].to_i
line = ""
road_count.times do |r|
  line = "#{line} #{gets.chomp}"
end

city_count.times do |i|
  p line.split.count((i+1).to_s)
end

Measured memory_bytes: 14200
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define swap(p,q) r=(p);(p)=(q);(q)=r
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;




int main(void)
{
	//変数の宣言
	int n,m,a,b;

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp,temp1,temp2;
	int max,min;
	int len;
	int sum=0;
	int ok,ng;



	//データの読み込み


	scanf("%d %d %d %d",&n,&m,&a,&b);
//	scanf_s("%d %d %d %d",&n,&m,&a,&b);

//	for(i=0;i<n;i++){
//		scanf("%lld %lld",&drink[i].cost,&drink[i].num);
//		scanf_s("%lld %lld",&drink[i].cost,&drink[i].num);
//	}

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	ans=(n-a)*(m-b);

	//	printf("計算部分終了\n");

	//出力


	printf("%d",ans);


	//	printf("結果の出力終了\n");


	return 0;
}



Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from itertools import combinations_with_replacement


def getPoint(data, A, q):
    res = 0
    for i in range(q):
        a, b, c, d = data[i]
        if A[b]-A[a] == c:
            res += d
    return res

def main():
    n, m, q = map(int, readline().split())    
    data = []
    for _ in range(q):
        a, b, c, d = map(int, readline().split())
        a-=1
        b-=1
        data.append((a, b, c, d))
    p = [int(i) for i in range(1, m+1)]
    ans = 0
    for A in combinations_with_replacement(p, n):
        ans = max(getPoint(data, A, q), ans)
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 9284
#include <iostream>

using namespace std;
int main(){
    unsigned int ss;
    cin>>ss;
    unsigned int h,m,s;
    s = ss % 60;
    m = ss / 60 % 60;
    h = ss / 60 / 60 % 24;
    cout<<h<<":"<<m<<":"<<s<<endl;
    return 0;
}

Measured memory_bytes: 3084
h,n=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n)]
dp=[float('inf')]*(h+10**4+1)
dp[0]=0
for i in range(h+10**4+1):
  for j in range(n):
    if i-ab[j][0]>=0:
      dp[i]=min(dp[i-ab[j][0]]+ab[j][1],dp[i])
print(min(dp[h:]))

Measured memory_bytes: 43116