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

int main() {
    int l;
    cin >> l;
    vector<int> v;
    while(l != 1) {
        if(l & 1) v.push_back(1), l--;
        else v.push_back(0), l /= 2;
    }
    int n = 1, m, x = 1;
    typedef array<int, 3> edge;
    vector<edge> e;
    for(int i = v.size() - 1; i >= 0; i--) {
        if(v[i]) {
            e.push_back(edge{1, n, x});
            x++;
        } else {
            for(int i = 0; i < e.size(); i++) {
                e[i][2] *= 2;
            }
            e.push_back(edge{n, n+1, 0});
            e.push_back(edge{n, n+1, 1});
            n++;
            x *= 2;
        }
    }
    cout << n << " " << e.size() << '\n';
    for(auto& ee : e) {
        cout << ee[0] << " " << ee[1] << " " << ee[2] << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
import math

a = list(map(int,input().split()))
A = a[0]
B = a[1]
H = a[2]
M = a[3]
x = math.sqrt(A*A + B*B - 2*A*B*math.cos(math.radians(6*M - 30*H -  0.5*M)))
print(x)

Measured memory_bytes: 9560
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

const int MAX_N = 20;

// グラフ.
int G[MAX_N][MAX_N];
// visited[v] := 頂点 v を訪れたかどうか.
bool visited[MAX_N];
// 葉を除いたグラフで一番コストのかかる経路のコスト
int max_cost;

// 初期化.
void init(){
	for(int i=0 ; i < MAX_N ; i++ ){
		visited[i] = false;
		for(int j=0 ; j < MAX_N ; j++ ){
			G[i][j] = 0;
		}
	}
}

// 辺の追加.
void add_edge(int u, int v, int cost){
	G[u][v] = G[v][u] = cost;
}

// 頂点 0 以外の葉を探す.
void search_leaf(int u, vector<int>& leaf){
	visited[u] = true;
	
	int cnt = 0;
	for(int v=0 ; v < MAX_N ; v++ ){
		if( G[u][v] == 0 ) continue;
		cnt++;
		if( visited[v] ) continue;
		search_leaf(v,leaf);
	}
	if( u != 0 && cnt == 1 ){
		leaf.push_back( u );
	}
}

// 一番コストのかかる経路を探す.
void dfs(int u, int sum){
	visited[u] = true;
	max_cost = max( max_cost , sum );
	
	for(int v=0 ; v < MAX_N ; v++ ){
		if( G[u][v] == 0 || visited[v] ) continue;
		dfs( v , sum + G[u][v] );
	}
}

int main(){
	int n;
	while( cin >> n , n ){
		// 初期化.
		init();
		
		// sum := コストの総和.
		int sum = 0;
		for(int i=0 ; i < n-1 ; i++ ){
			int u, v, cost;
			cin >> u >> v >> cost;
			u--; v--; sum += cost;
			add_edge( u , v , cost );
		}
		// 葉を探す.
		vector<int> leaf;
		search_leaf( 0 , leaf );
		// 葉と隣接するエッジのコストを 0 にする. (葉は訪れる必要がない)
		for(int i=0 ; i < leaf.size() ; i++ ){
			int u = leaf[i];
			for(int v=0 ; v < MAX_N ; v++ ){
				if( G[u][v] ){
					sum -= G[u][v];
					G[u][v] = G[v][u] = 0;
				}
			}
		}
		// 一番コストのかかる経路を探す.
		max_cost = 0;
		for(int i=0 ; i < MAX_N ; i++ ) visited[i] = false;
		dfs( 0 , 0 );
		cout << sum*2 - max_cost << endl;
	}
}

Measured memory_bytes: 0
/*         Abhijith        */
#include<bits/stdc++.h>
#define lld long long int
#define ld long double
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,a,b)	for(lld i=a;i<=b;i++)
#define repr(i,a,b) for(lld i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int main()
{
     ios;
    vector<vector<lld> > ans(105,vector<lld> (4));
    ans[1][0]=1;
    ans[1][1]=1;
    ans[1][2]=1;
    ans[1][3]=1;
    ans[2][0]=4;
    ans[2][1]=4;
    ans[2][2]=4;
    ans[2][3]=4;
    ans[3][0]=16;
    ans[3][1]=14;
    ans[3][2]=15;
    ans[3][3]=16;
    rep(i,4,101)
    {
        ans[i][0]=(ans[i-1][0]+ans[i-1][1]+ans[i-1][2]+ans[i-1][3])%mod;
        ans[i][3]=ans[i][0];
        ans[i][1]=(((ans[i][0]-ans[i-3][0]*3-ans[i-2][0]*1-ans[i-2][2])%mod)+mod)%mod;
        ans[i][2]=(((ans[i][0]-ans[i-3][0]-ans[i-3][1]-ans[i-3][3])%mod)+mod)%mod;
    }
    lld n;
    cin>>n;
    cout<<ans[n+1][0]<<endl;
    return 0;
}


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

using namespace std;
const int N = 100100;
ll Size[N],par[N],n,x[N],y[N];

void init(){
    for(int i=1;i<=n;i++)  Size[i]=1,par[i]=i;
}


int getparent(int x)
{
    if(x==par[x])  return x;
    return par[x]=getparent(par[x]);
}

void Merge(int x , int y){

    x = getparent(x);
    y = getparent(y);
    if(x==y)  return ;
    if(Size[x] < Size[y])  swap(x,y);

    Size[x]+=Size[y];
    par[y] = x;
}

vector < ll > v;

int main()
{
    int m;
    cin >> n >> m;
    for(int i = 0 ; i<m ;i++){
        cin >> x[i] >> y[i];
    }
    init();
    ll Ans = 0;
    for(int i = m - 1 ; i>=0;i--){
        v.push_back((n * (n - 1))/2 - Ans);
        int u = x[i];
        int v = y[i];
        if(getparent(u) == getparent(v))  continue;
        Ans-=(Size[getparent(u)] * (Size[getparent(u)]  - 1))/2;
        Ans-=(Size[getparent(v)] * (Size[getparent(v)] - 1))/2;
        Merge(u , v);
        Ans+=(Size[getparent(u)] * (Size[getparent(u)]  - 1))/2;
    }
    reverse(v.begin() , v.end());
    for(auto x : v)  cout << x << '\n';
    return 0;
}


Measured memory_bytes: 5364
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
const int N=2e5+5;
vector<pii>up,le,dw,ri;
int h,w,n;
int f(int x,int y){return x==0||x==h||y==0||y==w;}
void g(int x,int y,int i){
    if(!x)up.pb(y,i);
    else if(x==h)dw.pb(-y,i);
    else if(!y)le.pb(-x,i);
    else ri.pb(x,i);
}
int s[N],m=-1;
void kek(int i){
    if(m>=0&&s[m]==i)m--;
    else s[++m]=i;
}
int32_t main(){
    cin>>h>>w>>n;
    for(int i=1;i<=n;++i){
        int x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;
        if(f(x1,y1)&&f(x2,y2)){
            g(x1,y1,i);
            g(x2,y2,i);
        }
    }
    sort(up.begin(),up.end());
    for(pii p:up)kek(p.s);
    sort(ri.begin(),ri.end());
    for(pii p:ri)kek(p.s);
    sort(dw.begin(),dw.end());
    for(pii p:dw)kek(p.s);
    sort(le.begin(),le.end());
    for(pii p:le)kek(p.s);
    if(m==-1)cout<<"YES\n";
    else cout<<"NO\n";    
    return 0;
}

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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n]={};
  int i;
  int color[9]={};
  for(i=0;i<n;i++){
    cin >> a[i];
    if(a[i]<3200)color[a[i]/400]++;
    else color[8]++;
  }
  int cnt = 0;
  for(i=0;i<=7;i++){
    if(color[i]>0) cnt++;
  }
  int maxx = cnt+color[8];
  int minn = max(1,cnt);

  cout << minn << " " << maxx;
}

Measured memory_bytes: 256
if __name__ == "__main__":
    n,k = map(int,input().split())
    arr = list(map(int,input().split()))
    dp = [-1]*len(arr)
    curr = 1 
    dp[0] = 0
    dp[1] = abs(arr[1]-arr[0])
    cost = 0
    for i in range(2,len(arr)):
        m = float("inf")
        x = i-1
        c = 0
        while(x>=0 and c<k):
            m= min(m,dp[x]+abs(arr[i]-arr[x]))
            x -= 1
            c += 1 
        dp[i] = m
    print(dp[-1])

Measured memory_bytes: 52448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){
    string s,t;cin>>s>>t;
    ll a,b;cin>>a>>b;
    string x;cin>>x;
    if(x==s){
        cout<<a-1<<' '<<b<<endl;
    }else{
        cout<<a<<' '<<b-1<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI(N);
  map<string, ll> mp;
  string s = "ACG";
  FOR(i, 4) {
    s[0] = "ACGT"[i];
    FOR(j, 4) {
      s[1] = "ACGT"[j];
      FOR(k, 4) {
        s[2] = "ACGT"[k];
        if (s != "AGC" && s != "ACG" && s != "GAC") {
          mp["T" + s]++;
        }
      }
    }
  }
  FOR(i, N - 3) {
    map<string, ll> new_mp;
    for (pair<string, ll> p : mp) {
      string now = p.first;
      ll cnt = p.second;
      FOR(j, 4) {
        string news = now.substr(1, 3) + "ACGT"[j];
        if (news.substr(1, 3) != "AGC" && news.substr(1, 3) != "ACG" &&
            news.substr(1, 3) != "GAC" &&
            !(news[0] == 'A' && news[2] == 'G' && news[3] == 'C') &&
            !(news[0] == 'A' && news[1] == 'G' && news[3] == 'C')) {
          new_mp[news] = (new_mp[news] + cnt) % MOD;
        }
      }
    }
    mp = new_mp;
  }
  ll ans = 0;
  for (pair<string, ll> p : mp)
    ans = (ans + p.second) % MOD;
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int i, n, q, a, b;
	string s;
	int min[100000], max[100000];
	int sum[100000];
	sum[0] = 0;
	cin >> n >> q;
	cin >> s;
	for (i = 0; i < q;i++)
	{
		cin >> min[i] >> max[i];
	}
	for (i = 0; i < n- 1; i++)
	{
		if ((s[i] == 'A') && (s[i + 1] == 'C'))
		{
			sum[i + 1] = sum[i] + 1;
		}
		else
		{
			sum[i + 1] = sum[i];
		}
	}
	for (i = 0; i < q;i++)
	{
		a = max[i] - 1;
		b = min[i] - 1;
		cout << sum[a] - sum[b] << "\n";
	}
 
	return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>//Graph I - Depth First Search

void DFS();
void ReVisit(int);
void print();

int Adj[100][100];
int d[100];//v ????????????????????????????????????????¨????????????????
int f[100];// v ?????£??\???????????????????????????????????????????¨????????????????
int n, i, j, count;

int main() {
  int u, v, k;

  scanf("%d",&n);//??????????????? G ???????????° n ????????????????????????

  for( i=0 ; i<n ; i++ ) {
    d[i] = 0;//?????????
    f[i] = 0;//?????????
    for( j=0 ; j<n ; j++ ) Adj[i][j] = 0;//?????????
  }
  
  for( i=0 ; i<n ; i++ ) {
    scanf("%d%d",&u,&k);//u ?????????????????????k ??? u ???????¬???°
    for( j=0 ; j<k ; j++ ) {
      scanf("%d",&v);
      Adj[i][v-1] = 1;
    }
  }

  DFS();
  print();

  return 0;
}

void DFS() {
  count = 1;
 
  for( i=0 ; i<n ; i++ ) {
      if(d[i] == 0)
    ReVisit(i);
    }
}
 
void ReVisit(int u) {
  int l;
  d[u] = count++;
  for( l=0 ; l<n ; l++ ) {
    if(Adj[u][l] == 1 && d[l] == 0) ReVisit(l);
  }
  f[u] = count++;
}

void print() {
  for( i=0 ; i<n ;i++ )
    printf("%d %d %d\n",i+1,d[i],f[i]);
}

Measured memory_bytes: 636
#include <iostream> 
using namespace std;
#define ll long long
int main() {
  ll n,m,k; cin >> n >> m >> k;
  ll arr[n+1],brr[m+1]; arr[0] = 0;brr[0] = 0;
  for (int i=1; i<=n; i++) cin >> arr[i];
  for (int i=1; i<=m; i++) cin >> brr[i];
  for (int i=1; i<=n; i++) arr[i] += arr[i-1];
  for (int i=1; i<=m; i++) brr[i] += brr[i-1];
  ll best = m,res=0;
  for (int i=0; i<=n; i++) {
    if (arr[i] > k) break;
    while ( best >= 0 && arr[i] + brr[best] > k) best--;
    res = max(i + best,res);
  }
  cout << res << endl;
}

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

int P,Q,R;
priority_queue<int,vector<int>, greater<int>> que;

int main() {
  cin >> P >> Q >> R;
  //for(int i=0;i<H;i++) cin >> s_list[i];

  // A->B: P
  // B->C: Q
  // C->A: R

  int ans = 0;
  que.push(P);
  que.push(Q);
  que.push(R);
  for (int i=0;i<2;i++){
    auto s = que.top();
    que.pop();
    ans += s;
    //cout << s << ",";
  }
  //cout << "\n";
  cout << ans << "\n";
#if 0
  que.push(1);
  que.push(10);
  que.push(3);
  //for(auto s: que) cout << s << " "; 
  while(!que.empty()) {
    auto s = que.top();
    que.pop();
    cout << s << ",";
  }
  cout << "\n";
#endif


#if 0
  cout << P << " " << Q << " " << R << "\n";
  //for(auto s: s_list) cout << s << "\n"; 
#endif
  return 0;
}

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

int main(void){
  int n, a, min = INT_MAX, max = INT_MIN;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a;
    if(a < min) min = a;
    if(a > max) max = a;
  }
  cout << abs(max-min) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {

  int i, a, b;

  for(i = 0; i < 3000; i++) {
    scanf("%d %d", &a, &b);
    if(a == 0 && b == 0)
      break;
    else {
      if(a > b) {
        int temp = a;
        a = b;
        b = temp;
      }
      printf("%d %d\n", a, b);
    }
  }

  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <stdio.h>
#include <stdlib.h> //rand() 0~RAND_MAX2147483647
#include <math.h>
#include <time.h>   //srand((unsigned int)time(NULL));
#include <unistd.h> //sleep
#include <algorithm>
#include <cmath>
#include <vector>
#include <regex> //正規表現
#include <map>
#include <unordered_map>
#include <set>
#include <cassert> //assart
#include <numeric>
#include <iterator>
#include <list>

using namespace std;
#define ll long long int
#define FOR(i,min,max) for(int i=(min);i<(max);i++)
#define FOReq(i,min,max) for(int i=(min);i<=(max);i++)
#define FORREV(i,max,min) for(int i=(max)-1;i>=(min);i--)
#define FORREVeq(i,max,min) for(int i=(max);i>=(min);i--)
const int MOD=1e9+7;
const int MOD2=998244353;
const int not0=1;
const int INF=2000000001;
const ll INFll=2e18;
//const int MAX_V=10000;
const double  Micro=1e-5;

int UnUsedVariable(){
    if(INF || Micro || MOD || INFll || MOD2){;}
    return 0;
}

#define pf printf
#define sf scanf
#define inarray(array,min,max) FOR(i,min,max){cin>>array[i];}
#define inarrayW(arrayA,arrayB,min,max) FOR(i,min,max){cin>>arrayA[i]>>arrayB[i];}
#define br printf("\n");
#define OutputAndReturn0(x) {cout<<(x)<<endl;return 0;}
#define elif else if

#define issame(a,b,c,d) ((a)==(b) and (b)==(c) and (c)==(d))
#define isdiff3(a,b,c) ((a)!=(b) and (b)!=(c) and (c)!=(a))
#define isdiff4(a,b,c,d) ((a)!=(b) and (b)!=(c) and (c)!=(a) and (d)!=(a) and (d)!=(b) and (d)!=(c))
#define Func3(f,a,b,c) (f)((f)((a),(b)),(c))
#define Func4(f,a,b,c,d) (f)((f)((f)((a),(b)),(c)),(d))

inline int isEven(int x){return x%2==0;}
inline int isOdd (int x){return x%2==1;}
inline ll  gcd(ll a,ll b){ if(b==0)return a;else return gcd(b,a%b);}//最大公約数 なお一方が0なら答えは他方になるので番兵は０で良い また、負の数もOK -4%3=-1となるため
inline ll  lcm(ll a,ll b){return a*b/gcd(a,b);}//MODやオーバーフローには注意！
//inline ll  ceil(double a){return (ll)a+1;}
//ans = accumulate(A, A+N, 0, [](int a, int b) {return gcd(a,b);});

//Eと名のつくのはデバッグ用！
int EintN(ll array[],const ll num){
    for(int i=0;i<num;i++){cerr<<array[i]<<" ";}
    br;
    return 0;
}
int EintNN(const int heighth,const int width,int array[heighth][width]){
    FOR(i, 0, heighth){
        FOR(k, 0, width){
            {cerr<<array[i][k]<<" ";}
        }
        br;
    }
    br;
    return 0;
}
int Eint(string str,const ll num){
    cerr<<str<<" is "<<num<<" now."<<endl;
    return 0;
}













int prob(){
    ll ans;ans=0;
    ll N,M;
    cin>>N>>M;
    ll X[M];
    inarray(X, 0, M);
    sort(X,X+M);
    
    ll dif[M-1];
    FOR(i, 0, M-1){
        dif[i]=X[i+1]-X[i];
    }
    sort(dif,dif+M-1);
    FOR(i, 0, M-N){
        ans+=dif[i];
    }
    
    OutputAndReturn0(ans);
    return 0;
}


signed main(){
    prob();
    return 0;
}


Measured memory_bytes: 1792
N=int(input())

tmp = [[[0],0]]
for _ in [0]*(N-1):
    tmp2 = []
    for s,m in tmp:
        for c in range(m+1):
            tmp2.append([s+[c],m])
        tmp2.append([s+[m+1],m+1])
    tmp = tmp2
for ans in tmp:
    s = "".join(["abcdefghij"[i] for i in ans[0]])
    print(s)

Measured memory_bytes: 38260
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define badi_val 1000000007
int n;
int pd[1100];
const int mo=1e9+7;
int main(){
	long long h , x = 2LL;
  	cin >> h;
  	int cnt = 0;
  	while(h > 0){
     	h /= x;
      	cnt++;
    }
  	cout << setprecision(20) << pow(2 , cnt) - 1 << endl;
 	return 0; 
}

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

typedef long long ll;
#define MOD = 1000000007;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
void yes(bool f){cout<<(f?"yes":"no")<<endl;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
void YES(bool f){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl


int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int H, W; cin >> H >> W;
    vector<string> v;;

    rep(i, H) {
        string s;
        cin >> s;
        if (!all_of(ALL(s), [](char x){return x=='.';}))
            v.push_back(s);
    }

    rep(j, W) {
        bool all_white = true;
        rep(i, v.size()) {
            if (v[i][j] != '.') {
                all_white = false;
                break;
            }
        }
        if (all_white) {
            rep(i, v.size()) {
                v[i].erase(j, 1);
            }
            j--;
        }
    }
    rep(k, v.size())
        cout << v[k] << endl;
    
}


Measured memory_bytes: 256
s=list(input())
t=list(input())
ans='U'
for i in range(len(s)-len(t),-1,-1):
  if s[i]==t[0] or s[i]=='?':
    cnt=1
    for j in range(1,len(t)):
      if s[i+j]==t[j] or s[i+j]=='?':
        cnt+=1
    if cnt==len(t):
      s[i:i+len(t)]=t
      u=''
      for k in s:
        u+=k
      u=u.replace('?','a')
      print(u)
      exit()
      
print('UNRESTORABLE')


Measured memory_bytes: 9072
#include <iostream>
#include<math.h>
#include<vector>
#include<map>
#include<queue>
#include <algorithm>
#include<string.h>
#define ll long long
#define ull unsigned long long
using namespace std;
typedef pair<int, int> P;
const int maxn = 400005;
const ll mod = 1000000007;
ll n, x, y, gt;
ll power(ll a, ll b)
{
	ll ans = 1;
	while (b)
	{
		if (b & 1) ans = ans * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return ans;
}
ll C(ll a, ll b)
{
	ll ans = 1, tp = 1;
	for (ll i = b - a + 1; i <= b; i++)
		ans = ans * i % mod;
	for (ll i = 2; i <= a; i++)
		tp = tp * i % mod;
	ans = ans * power(tp, mod - 2) % mod;
	return ans;
}
signed main() 
{
	while (~scanf("%lld%lld%lld", &n, &x, &y))
	{
		gt = power(2, n) - 1;
		gt -= C(x, n) + C(y, n);
		if (x == y)	gt += C(x, n);
		printf("%lld\n", (gt % mod + mod) % mod);
	}
}


Measured memory_bytes: 256
n,m=map(int,input().split())
f=[0]*n
ac=0
w=[0]*n
wa=0
for i in range(m):
    p,q=map(str,input().split())
    p=int(p)-1
    if f[p]==0:
        if q=='AC':
            f[p]=1
            ac+=1
            wa+=w[p]
        else:
            w[p]+=1
print(ac,wa)
        


Measured memory_bytes: 4596
H,W,M = gets.split.map(&:to_i)
bombs = Hash.new{false}
r = Array.new(H){0}
c = Array.new(W){0}
M.times{
	h,w = gets.split.map{|i|i.to_i - 1}
	bombs[[h,w]] = true
	r[h] += 1
	c[w] += 1
}
max_rows = []
max_r = 0
H.times{|h|
	if max_r < r[h]
		max_r = r[h]
		max_rows = []
	end
	if max_r == r[h]
		max_rows << h
	end
}
warn max_r
warn max_rows.inspect
max_cols = []
max_c = 0
W.times{|w|
	if max_c < c[w]
		max_c = c[w]
		max_cols = []
	end
	if max_c == c[w]
		max_cols << w
	end
}
warn max_c
warn max_cols.inspect
s = max_r + max_c - 1
f = false
max_rows.each{|h|
	max_cols.each{|w|
		if !bombs[[h,w]]
			warn [h,w].inspect
			s += 1
			f = true
			break
		end
	}
	break if f
}
puts s


Measured memory_bytes: 59832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define INF 1007654321
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }

const ll MAXN = 100 + 10;
ll w[MAXN], v[MAXN];
ll dp[MAXN][MAXN][3*MAXN+1];

int main() {
    FAST_IO();
    ll N, W; cin >> N >> W;
    repp(i, 1, N) cin >> w[i] >> v[i];
    for(ll i = 1; i <= N; ++i) {
        for(ll k = 1; k <= i; ++k) {
            for(ll x = 0; x <= 3*N; ++x) {
                if(i == 1) dp[i][k][x] = v[1];
                else {
                    if(x - w[i] + w[1] >= 0 && i == k) dp[i][k][x] = dp[i-1][k-1][x - w[i] + w[1]] + v[i];
                    else if(x - w[i] + w[1] >= 0 && i != k) dp[i][k][x] = max(dp[i-1][k][x], dp[i-1][k-1][x - w[i] + w[1]] + v[i]);
                    else dp[i][k][x] = dp[i-1][k][x];
                }
            } 
        }
    }
    
    ll ans = 0;
    for(int k = 1; k <= N; ++k) {
        if(W - k * w[1] < 0) continue;
        if(W - k * w[1] <= 3*k) ans = max(ans, dp[N][k][W - k*w[1]]);
        else ans = max(ans, dp[N][k][3*k]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 29056
N,M = gets.split.map(&:to_i)
A = N.times.map{ gets.split.map(&:to_i) }
SIGN = [-1,1]
puts SIGN.repeated_permutation(3).map{|sx,sy,sz| A.map{|x,y,z| sx * x + sy * y + sz * z }.sort.reverse[0,M].inject(0,&:+) }.max


Measured memory_bytes: 2040
R = dict(zip("IVXLCDM",[1,5,10,50,100,500,1000]))
while 1:
    try:
        ans = 0; n = 0;
        s = raw_input();
        for i in xrange(len(s)-1):
            n += R[s[i]]
            if R[s[i]]<R[s[i+1]]:
                ans -= n; n = 0;
            elif R[s[i]]>R[s[i+1]]:
                ans += n; n = 0;
        ans += n + R[s[len(s)-1]]
        print ans
    except EOFError:
        break

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

int main() {
    string s; cin >> s;
    int k; cin >> k;
    int n = s.length();
    vector<string> subs;
    vector<vector<int>> index(26);
    for(int i = 0; i < n; i ++) {
        index[s[i]-97].push_back(i);
    }
    vector<int> priority;
    for(int i = 0; i < 26; i ++) {
        priority.insert(priority.end(), index[i].begin(), index[i].end());
    }
    for(int i = 0; i < n; i ++) {
        string tmp = "";
        for(int j = priority[i]; j < n; j ++) {
            tmp += s[j];
            subs.push_back(tmp);
            if(tmp.length() > k) break;
        }
    }
    sort(subs.begin(), subs.end());
    unique(subs.begin(), subs.end());
    cout << subs[k-1] << endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

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

const ll INF=(ll)1e19;
//const int INF=(1<<30);

int main(){
  int d;
  cin >> d;
  cout << "Christmas";
  REP(i,25-d){
    cout << " Eve";
  }
  cout << endl;
}



Measured memory_bytes: 256
x, y = map(int, input().split())
if x in [1, 3, 5, 7, 8, 10, 12] and y in [1, 3, 5, 7, 8, 10, 12]:
	print('Yes')
elif x in [4, 6, 9, 11] and y in [4, 6, 9, 11]:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 3060
def main():
  inps = list(input().split(" "))
  # print(inps)

  stack = []
  for inp in inps:
    if inp == "+":
      a = int(stack.pop(-2))
      b = int(stack.pop(-1))
      stack.append(a+b)
    elif inp == "-":
      a = int(stack.pop(-2))
      b = int(stack.pop(-1))
      stack.append(a-b)
    elif inp == "*":
      a = int(stack.pop(-2))
      b = int(stack.pop(-1))
      stack.append(a*b)
    else:
      stack.append(inp)
    # print(inp, type(inp), stack)
  print(int(stack[0]))

main()


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    ll n,in,am=0,bm=0,ans=1;
    cin>>n;
    vector<ll> a(n),b(n),c(n);
    for(int i=0;i<n;i++){
        cin>>in;
        a[i]=in;
    }
    for(int i=0;i<n;i++){
        cin>>in;
        b[i]=in;
    }
    for(int i=0;i<n;i++){
        c[i]=min(a[i],b[i]);
    }
    c[0]=1;c[n-1]=1;
    for(int i=1;i<n;i++){
        if(a[i]!=a[i-1]){
            c[i]=1;am=i;
        }
    }
    for(int i=n-2;i>=0;i--){
        if(b[i]!=b[i+1]){
            c[i]=1;bm=i;
        }
    }
    for(int i=0;i<n;i++){
        ans*=c[i];
        ans%=1000000007;
    }
    cout<<((bm-am>=0&&a[n-1]==b[0])?ans:0)<<endl;
}

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

int main(){
	double xa, ya;
	double xb, yb;
	double xc, yc;
	double xd, yd;
	while(cin >> xa >> ya >> xb >> yb
		>> xc >> yc >> xd >> yd)
	{
		double dx1 = xb - xa, dy1 = yb - ya;
		double dx2 = xd - xc, dy2 = yd - yc;
		if(dx1 * dx2 + dy1 * dy2 == 0){
			cout << "YES" << endl;
		} else {
			cout <<"NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, n, ans = 0, be, x, a;
  scanf("%lld%lld", &n, &x);
  for(i = 0; i < n; ++i) {
    scanf("%lld", &a);
    if(i) {
      if(be + a > x) ans += be + a - x, a = x - be;
    } else {
      if(a > x) ans += a - x, a = x;
    }
    be = a;
  }
  printf("%lld", ans);
  return 0;
}

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

ll N;

void lcs(string a, string b){
    int DP[a.size()+1][b.size()+1]={{0}};
    for(int i=0;i<=a.size();i++) DP[i][0]=0;
    for(int i=0;i<=b.size();i++) DP[0][i]=0;
    for(int i=1;i<=a.size();i++){
        for(int j=1;j<=b.size();j++){
            if(a[i-1]==b[j-1]) DP[i][j] = DP[i-1][j-1] + 1;
            else DP[i][j] = max(DP[i][j-1], DP[i-1][j]);
            //cout << " " << DP[i][j];
        }
        //cout << endl;
    }
    cout << DP[a.size()][b.size()] << endl;
    return;
}

signed main(){
    cin >> N;
    for(int i=0;i<N;i++){
        string A, B;
        cin >> A >> B;
        lcs(A, B);
    }
    return 0;
}


Measured memory_bytes: 10924
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<string>
#include<utility>
#include<iomanip>
#include<bitset>
#include<math.h>
using namespace std;
 
 
int main(){
 
	int n;
	cin >> n;
	string ans = "Yes";
	vector<int> v(n);
	for (int i = 0; i < n; i++)
	{
		cin >> v[i];
	}
	for (int i = 1; i < n; i++)
	{
		if(v[i-1] - v[i] >= 2){
			ans = "No";
			break;
		}else if(v[i-1] - v[i] == 1){
			v[i]++;
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.*;
/*
NOTES:
-more than 10 digits (10^10), use long
-prefix sum of 1's and -1's to control flow of highlighting a region
-log(a)/log(b) = log base b of a
-create a position array if trying to see if elements show up next to each other sequentially
 i.e. elements 1,2,3 are within 3 spots of each other in an array
      arr[scannedInt - 1] = i; (position of i at p[i] in original)
- use a freq array when counting instances of an element occurring
- increment the counter first before simulating anything turn-based (two player game)

 */

public class Main {
    static long mod = (long)(Math.pow(10, 9) + 7);
    public static String alpha = "zabcdefghijklmnopqrstuvwxy";
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int t =1;
        while (t-- > 0) {
           long a = scan.nextLong();
           long[] arr = new long[(int)a+1];
           for(int i = 1; i<=a; i++){
               for(int j = i; j<=a; j+=i){
                   ++arr[j];
               }
           }
           long ans = 0;
           for(int i = 1; i<=a; i++){
               ans += i*arr[i];
           }
           System.out.println(ans);
        }
        scan.close();
    }

    static ArrayList factors(int n ){
        ArrayList<Integer> facts = new ArrayList<>();
        for(int i = 1; i<=(int)Math.sqrt(n); i++){
            if(n%i == 0){
                if( i == Math.sqrt(n)) facts.add(i);
                else{
                    facts.add(i);
                    facts.add(n/i);
                }
            }
        }
        Collections.sort(facts);
        return facts;
    }

    static boolean isPrime (int n){
        if(factors(n).size() ==2) return true;
        else return false;
    }





    static int GCD(int a, int b) {
        // Everything divides 0
        if (a == 0) return b;
        if (b == 0) return a;

        // base case
        if (a == b) return a;

        // a is greater
        if (a > b) return GCD(a-b, b);
        return GCD(a, b-a);
    }
    static int LCM(int a, int b){
        return (a*b)/(GCD(a,b));
    }
    static String rev(String s){
        char[] arr = s.toCharArray();
        for(int i = 0; i<(s.length()+1)/2; i++){
            char temp = arr[i];
            arr[i] = arr[s.length()-i-1];
            arr[s.length()-i-1] = temp;
        }
        String fin = new String(arr);
        return fin;
    }
    static long pow(long a, long N) {
        if (N == 0) return 1;
        else if (N == 1) return a;
        else {
            long R = pow(a,N/2);
            if (N % 2 == 0) {
                return R*R;
            }
            else {
                return R*R*a;
            }
        }
    }

    static long powMod(long a, long N) {
        if (N == 0) return 1;
        else if (N == 1) return a % mod;
        else {
            long R = powMod(a,N/2) % mod;
            R *= R;
            R %= mod;
            if (N % 2 == 1) {
                R *= a;
                R %= mod;
            }
            return R % mod;
        }
    }

}

Measured memory_bytes: 115980
#include <bits/stdc++.h>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf = 1e9;

ll a, b, c, N, M;
string s;

int main() {
    cin>>N>>M;

    p((1900*M+(N-M)*100)*pow(2,M));
    
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>
#include<cstdio>
using namespace std;
long long x,a[200001],n,i,ans=9223372036854775806;
int main(){
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>x;
		a[i]=a[i-1]+x;
	}
	for(i=1;i<n;i++){
		ans=min(ans,abs((a[n]-a[i])-a[i]));
	}
	cout<<ans<<endl;
  return 0;
}


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

using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
#define clr(ar) memset(ar, 0, sizeof(ar))
#define FOR(i,j,k) for(int i=j;i<=k;i++)
#define REV(i,j,k) for(int i=j;i>=k;i--)
#define inf         freopen("in.txt", "r", stdin)
#define outf        freopen("out.txt", "w", stdout)
#define pf          printf
#define sf(n)       scanf("%d", &n)
#define sff(a,b)    scanf("%d %d", &a, &b)
#define PB push_back
#define F first
#define S second
#define MP make_pair

typedef pair<int,int> pii;
typedef long long LL;

const int MAX = 5005, INF = (1e9) + 10;

pii ara[MAX];
int n, dp[MAX][MAX];

int miin(int x,int y)
{
    if(min(x, y) == -1) return max(x, y);
    return min(x, y);
}

int main()
{
    ios::sync_with_stdio(false);
    //inf;
    //outf;

    cin >> n;
    FOR(i,0,n-1) cin >> ara[i].F >> ara[i].S;
    sort(ara, ara + n, [](pii x,pii y)
         {
             return x.F + x.S < y.F + y.S;
         });

    mem(dp, -1);
    dp[0][0] = 0;
    FOR(p,0,n-1)
        FOR(nisi,0,n)
        {
            if(dp[p][nisi] == -1) continue;

            if(ara[p].F >= dp[p][nisi])
                dp[p + 1][nisi + 1] = miin(dp[p + 1][nisi + 1], dp[p][nisi] + ara[p].S);

            dp[p + 1][nisi] = miin(dp[p + 1][nisi], dp[p][nisi]);
        }

    int prin = 0;
    REV(nisi,n,0)
    {
        if(dp[n][nisi] == -1) continue;
        prin = nisi;
        break;
    }
    cout << prin << endl;
    return 0;
}


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

int main () {
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int a = x2 - x1, b = y2 - y1;

	cout << x2 - b << " " << y2 + a << " " << x1 - b << " " << y1 + a << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[101];
int main()
{
	int n;
	cin>>n;
	int b;
	for(int i=1;i<=n;i++)
	{
		cin>>b;
		a[b]++;
	}
	int s=0;
	for(int i=1;i<=100;i++)
	{
		if(a[i]!=0)
		{
			s++;
		}
	}
	cout<<s;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int a,b,c,d,e,k,r,i;
    k=0;
    i=0;
    scanf("%d\n%d\n%d\n%d\n%d",&a,&b,&c,&d,&e);
    if (a%10!=0){
         k=a%10;
         a=((int)(a/10))*10+10;
         i++;
    }
    if (b%10!=0){
        if (k>(b%10))
        k=b%10;
        b=b/10;
        b=b*10+10;
        i++;
    }
    if (c%10!=0){
    if (k>(c%10))
        k=c%10;
    c=((int)(c/10))*10+10;
    i++;
    }
    if (d%10!=0){
    if (k>(d%10))
        k=d%10;
    d=((int)(d/10))*10+10;
    i++;
    }
    if (e%10!=0){
        if (k>(e%10))
        k=e%10;
        e=((int)(e/10))*10+10;
        i++;
    }
    if (i!=0&&i!=1)
        r=a+b+c+d+e+k-10;
    else
        r=a+b+c+d+e+k;
    printf("%d",r);
    return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    A = list(map(int, input().split()))
    F = [int()] * n
    F[0] = A[0]
    for b in range(1, n):
        F[b] = F[b - 1] + A[b]

    res = [0]*4
    data = [10 ** 18] * 2
    ex = [0]*4
    ans = 10 ** 18
    s = 0
    t = 2
    for i in range(1, n - 2):
        bl = [True, True]
        for j in range(s, i):
            res[0] = F[j]
            res[1] = F[i] - F[j]
            if not bl[0]:
                break
            if data[0] > abs(res[1] - res[0]) or j == s:
                s = j
                ex[0] = res[0]
                ex[1] = res[1]
                data[0] = abs(res[1] - res[0])
            else:
                bl[0] = False
        for k in range(t, n):
            res[2] = F[k] - F[i]
            res[3] = F[n - 1] - F[k]
            if not bl[1]:
                break
            if data[1] > abs(res[3] - res[2]) or k == t:
                t = k
                ex[2] = res[2]
                ex[3] = res[3]
                data[1] = abs(res[3] - res[2])
            else:
                bl[1] = False
        ans = min(ans, max(ex) - min(ex))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 24136
#include<stdio.h>
#define N 1000

int sq_count(char map[N][N],int y,int x){
  int i,j;

  for(i=1;;i++){
    for(j=0;j<=i;j++){
      if( map[y+i][x+j]!='.' ||
          map[y+j][x+i]!='.')
        return i;
    }
  }
}

int main(void){
  int i,j;
  int n;
  char map[N][N];
  char hoge;
  int SQnum,maxSQnum;

  for(;;){
    scanf("%d",&n);
    if(n==0)
      break;

    for(i=0;i<n;i++){
      scanf("%c",&hoge);
      for(j=0;j<n;j++)
        scanf("%c",&map[i][j]);
    }

    maxSQnum=0;
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
        if(map[i][j]=='.'){
          SQnum=sq_count(map,i,j);
          if(maxSQnum<SQnum)
            maxSQnum=SQnum;
        }
      }
    }
    printf("%d\n",maxSQnum);
  }

  return 0;
}

Measured memory_bytes: 1176
fun main(args: Array<String>){
    val s = readLine()!!
    val list = mutableListOf<String>()
    for(i in s.indices){
        if(s[i] == 'B'){
            if(list.isNotEmpty()){
                list.removeAt(list.size - 1)
            }
        }else if(s[i] == '0'){
            list.add("0")
        }else if(s[i] == '1'){
            list.add("1")
        }
    }
    println(list.toTypedArray().joinToString(separator = ""))
}

Measured memory_bytes: 36040
#include <bits/stdc++.h>
using namespace std;
#define INF 0X3f3f3f3f
#define M 1000000007
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define mp make_pair
#define pb push_back 
#define fi first
#define se second
#define endl "\n"
#define PI acos(-1)
#define fastcin ios_base::sync_with_stdio(false);
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int,int> ii;
typedef complex<double> base;

int n;
vi v;

int main(void){
	scanf("%d", &n);

	int x;
	for(int i = 0; i < n; i++){
		scanf("%d", &x);
		v.pb(x);
	}

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

	v.resize(unique(v.begin(), v.end()) - v.begin());

	cout << v.size() << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>

using std::list;
using std::max;
using std::min;
using std::vector;

int main()
{
  int n;
  scanf("%d", &n);
  vector<int> data(n+1);
  for(int i = 1; i <= n; i++) {
    scanf("%d", &data[i]);
  }
  if(n == 1) {
    printf("%d\n", 0);
    return 0;
  } else if(n == 2) {
    printf("%d\n", abs(data[1] - data[2]));
    return 0;
  }
  for(int i = 1; i <= n; i++) {
    data[i] -= i;
  }
  std::sort(data.begin()+1, data.end());
  int base1 = data[n/2];
  int base2 = data[n/2-1];
  int base3 = data[n/2+1];
  //printf("%lld\n", base);
  long long result1 = 0;
  long long result2 = 0;
  long long result3 = 0;
  for(int i = 1; i <= n; i++) {
    result1 += (long long)abs(data[i] - base1);
    result2 += (long long)abs(data[i] - base2);
    result3 += (long long)abs(data[i] - base3);
  }
  printf("%lld\n", min(result1, min(result2, result3)));
  return 0;
}


Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            out.print(1110 - n);
        }

    }
}



Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;


// bool field[ 2000 ][ 2000 ] = {};
// int blight[ 2000 ][ 2000 ] = {};
int main( void ){
	int H, W;
	cin >> H >> W;
	vector<vector<bool>> field(H, vector<bool>(W));
	vector<vector<int>>  blight(H, vector<int>(W));
	rep( i, 0, H ){
		rep( j, 0, W ){
			string s( "a" );
			if (!scanf( "%1s", &s[ 0 ] ))
				return -1;
			field[ i ][ j ] = ( s == "." ) ? true : false;
		}
	}
	rep( i, 0, H ){
		int cnt = 0;
		bool is_end = false;
		rep( j, 0, W ){
			if (!field[ i ][ j ]){
				rep( k, 1, cnt + 1 ){
					blight[ i ][ j - k ] = cnt;
				}
				blight[ i ][ j ] = 0;
				cnt = 0;
				if (j == W - 1)
					is_end = true;
			}
			else {
				cnt++;
			}
		}
		if (!is_end){
			rep( j, 1, cnt + 1 ){
				blight[ i ][ W - j ] = cnt;
			}
		}
	}
	int maximum = 0;
	rep( i, 0, W ){
		int cnt = 0;
		bool is_end = false;
		rep( j, 0, H ){
			if (!field[ j ][ i ]){
				rep( k, 1, cnt + 1 )
				maximum = max( maximum, cnt + blight[ j - k ][ i ] - 1 );
				cnt = 0;
			}
			else
				cnt++;
		}
		if (!is_end){
			rep( j, 1, cnt + 1 )
			maximum = max( maximum, cnt + blight[ H - j ][ i ] - 1 );
		}
	}
	cout << maximum << endl;

}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  int L[M], R[M];
  for (int i = 0; i < M; i++) cin >> L[i] >> R[i];
  sort(L, L+M);
  sort(R, R+M);

  cout << (R[0] - L[M-1] >= 0 ? R[0] - L[M-1] + 1 : 0) << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<stdio.h>
using namespace std;
int n,s,ma,sum;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&s);
		ma=max(ma,s);
		sum+=s;
	}
	sum-=ma/2;
	printf("%d\n",sum);
}


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

int main()
{
	bool b[]={true,false,false};
	char c1,c,c2;
	while(cin >> c1 >> c >> c2)
	{
		swap(b[c1-'A'],b[c2-'A']);
	}
	for(int i=0; i<3; i++)
	{
		if(b[i]) cout << (char)(i+'A') << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n,m;
int cnt[2100][2100];
int dp[2100][2100];
int val[130];
char s[15];
int dfs(int s1,int s2) {
    if (cnt[s1][s2]<=1) return 0;
    if (dp[s1][s2]!=-1) return dp[s1][s2];
    for (int i=0;i<m;i++) {
        if (s1&(1<<i)) continue;
        int now=max(dfs(s1|(1<<i),s2),dfs(s1|(1<<i),s2^(1<<i)))+1;
        if (dp[s1][s2]==-1) dp[s1][s2]=now;
        else dp[s1][s2]=min(dp[s1][s2],now);
    }
    return dp[s1][s2];
}
int main() {
    while (~scanf("%d%d",&m,&n)) {
        if (n==0&&m==0) break;
        memset(cnt,0,sizeof(cnt));
        memset(val,0,sizeof(val));
        for (int i=1; i<=n; i++) {
            scanf("%s",s);
            for (int j=0;j<m;j++) val[i]=val[i]*2+s[j]-'0';
        }
        for (int i=0;i<(1<<m);i++)
            for (int j=1;j<=n;j++)
                cnt[i][i&val[j]]++;
        memset(dp,-1,sizeof(dp));
        printf("%d\n",dfs(0,0));
    }
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < n;i++)

int main()
{
    int N;
    cin >> N;
    cout << (N % 10 == 9 || N / 10 == 9 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; 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 FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 100000000001
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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


int main()
{
    int s, w;
    cin >> s >> w;
    if(s <= w) cout << "unsafe" << endl;
    else cout << "safe" << endl;
}


Measured memory_bytes: 3592
#include<iostream>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    long long n,m ;
    cin >> n >> m ;
    vector<pair<long, long> > ba(n);

    for(int i=0;i<n;i++) cin >> ba[i].first >> ba[i].second;

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

    vector<long long> tmp(n+1,0) ;
    for(int i=1;i<n+1;i++)
    {
        tmp[i]=tmp[i-1]+ba[i-1].first ;
        //cout << tmp[i] << " " ;
    }
    //cout << endl ;
 
    long long cnt = 0 ;
    long long ans = 0 ;
    cnt = 0 ;
    for(int i=0;i<n;i++){
        //if(i!=(ind-2)){
         if((m-cnt)>ba[i].second){
           cnt += ba[i].second ;
           ans+=ba[i].first*ba[i].second ;
        }else{
           ans+=ba[i].first*(m-cnt) ;
           break ;
        } 
           // cout << ans << endl ;
    }

            cout << ans << endl ;

    //cout << ba[0].second << " " << ba[0].first << endl ;

	return 0;
}



Measured memory_bytes: 2560
import java.util.Scanner;
import java.util.Formatter;
public class Main
{
	public static void main(String args[])
	{
		Scanner inp = new Scanner(System.in);
		Formatter f1 = new Formatter();
		Formatter f2 = new Formatter();
		double r;
		r = inp.nextDouble();
		f1.format("%.6f",r*r*Math.PI);
		f2.format("%.6f",2*r*Math.PI);
		System.out.println(f1 + " " + f2);
	}
}

Measured memory_bytes: 28200
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long yokin = sc.nextLong();
        long yokin2 = 100l;
        int year = 0;
        while(true){
            yokin2 += yokin2*0.01;
            year += 1;
            if(yokin <= yokin2){
                break;
            }
        }
        System.out.println(year);
    }
}


Measured memory_bytes: 35720
#include<cstdio>
int A,s[110],t[110];
int main()
{
	int n,res=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&A);
		s[i]=s[i-1]+A;
	}
	for(int i=1;i<=n;i++)scanf("%d",&t[i]);
	for(int i=n;i;i--)t[i]+=t[i+1];
	for(int i=1;i<=n;i++)if(s[i]+t[i]>res)res=s[i]+t[i];
	printf("%d",res);
	return 0;
}

Measured memory_bytes: 128