akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <complex>
#include <iomanip>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

long double EPS = 1e-10;
long double add(long double a, long double b){
  if(abs(a+b)< EPS * (abs(a)+abs(b))) return 0;
  return a+b;
}
struct P{
  double x, y;
  P(){}
  P(long double x, long double y) : x(x), y(y){}
  P operator + (P p) {return P(add(x, p.x), add(y, p.y));}
  P operator - (P p) {return P(add(x,-p.x), add(y, -p.y));}
  P operator * (long double d) {return P(x*d, y*d);}
  long double dot(P p) {return add(x*p.x, y*p.y);}
  long double det(P p) {return add(x*p.y, -y*p.x);}
};
bool cmp_x(const P &p, const P &q){
  if(p.x != q.x) return p.x < q.x;
  return p.y < q.y;
}
vector<P> convex_hull(vector<P> ps, int n){
  sort(ps.begin(), ps.end(), cmp_x);
  int k=0;
  vector<P> qs(n*2);
  for(int i=0;i<n;i++){
    while(k>1 && (qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1]) <= 0) k--;
    qs[k++] = ps[i];
  }
  for(int i=n-2, t=k;i>=0;i--){
    while(k > t && (qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0) k--;
    qs[k++] = ps[i];
  }
  qs.resize(k-1);
  return qs;
}
long double rad(long double r){
  if(r >= 0) return (r/M_PI)*180;
  else return ((M_PI + r)/M_PI)*180 + 180;
}
long double check_ar(P &p, P &q){
  complex<long double> a((q.y-p.y), -(q.x-p.x));
  return rad(arg(a));
}
int main(int argc, char const *argv[]) {
  ll N, v, h;
  std::cin >> N;
  std::vector<P> ps(N), pp(N);
  for(int i=0;i<N;i++) {
    std::cin >> v >> h;
    ps[i].x = v;
    ps[i].y = h;
    pp[i].x = v;
    pp[i].y = h;
  }
  if(N==2){
    std::cout << 0.5 << '\n';
    std::cout << 0.5 << '\n';
    return 0;
  }
  vector<P> p = convex_hull(ps, N);
  vector<long double> ar(p.size()), ans(N, 0);
  vector<int> pn(p.size());
  for(int i=0;i<p.size();i++) for(int j=0;j<N;j++) if(pp[j].x==p[i].x&&pp[j].y==p[i].y)  pn[i] = j;
  for(int i=0;i<p.size();i++) {
    ar[i] = check_ar(p[i], (i==p.size()-1?p[0]:p[i+1]));
  }
  for(int i=0;i<p.size();i++){
    ans[pn[i]] = ar[i] - (i==0?ar[p.size()-1]:ar[i-1]);
    if(ans[pn[i]]<0) ans[pn[i]] += 360;
  }
  for(int i=0;i<N;i++) std::cout << fixed << setprecision(20)<< (ans[i]/360.0) << '\n';
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rbf(a, x) for (auto& a : x)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define drep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define Maxe(x) *max_element(all(x))
#define Mine(x) *min_element(all(x))
#define Size(x) ((ll)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
#define Fi first
#define Se second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo
//mint,dijkstra,gyakugen

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n;
        cin>>n;
        ll res=0;
        umap<ll,ll> m;
        rep(i,n){
            ll a;
            cin>>a;
            m[a]++;
            res+=a;
        }
        ll q;
        cin>>q;
        rep(i,q){
            ll b,c;
            cin>>b>>c;
            ll x=m[b];
            m[b]=0;
            m[c]+=x;
            res-=b*x;
            res+=c*x;
            cout<<res<<endl;
        }
    }

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

using namespace std;

int n, a[105];

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	sort(a, a+n);
	cout << a[n-1] - a[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100010],x[100010],y[100010];
char s[100010];
int main()
{
	int n,k,i,now,gs,m,ans,l,r;
	scanf("%d %d",&n,&k);
	scanf("\n%s",s+1);
	for(i=1;i<=n;i++)a[i]=s[i]-'0';
	now=a[1];gs=1;m=0;
	for(i=2;i<=n;i++)
	{
		if(a[i]==now)
		{
			gs++;
		}
		else
		{
			x[++m]=now;
			y[m]=gs;
			now=a[i];gs=1;
		}
	}
	x[++m]=now;y[m]=gs;
	ans=0;
	for(i=1;i<=m;i++)
	{
		y[i]+=y[i-1];
	}
	for(i=1;i<=m;i++)
	{
		if(x[i]==1)
		{
			l=i;r=i+(2*k+1)-1;
			r=min(r,m);
			ans=max(ans,y[r]-y[l-1]);
		}
		else
		{
			l=i;r=i+(2*k)-1;
			r=min(r,m);
			ans=max(ans,y[r]-y[l-1]);
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1536
import math

a, b, x = map(int, input().split())

if x <= b * a**2 / 2:
    rad = math.atan(b / ((2*x) / (a*b)))
    res = math.degrees(rad)
    print(res)
else:
    rad = math.atan(2*(b-(x/(a**2)))/a)
    res = math.degrees(rad)
    print(res)

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

typedef long long ll;
 
int main(){
  int n;
  cin >> n;
  int a[100004]={}, atri[100004]={};
  for(int i=0; i<n; i++){
    int b;
    cin >> b;
    a[b]++;
  }
  int ans=a[0]+a[1];
  for(int i=1; i<=100000; i++){
    ans = max(ans, a[i-1] + a[i] + a[i+1]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
# import math
# import bisect
# import heapq
# from collections import deque
# import numpy as np

n,k = map(int, input().split())

# n = int(input())
h = list(map(int,input().split()))

h.sort()
ans = 0
for i in range(n-k):
    ans += h[i]

print(ans)

Measured memory_bytes: 26764
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	bool x;
	cin >> x;
	x ^= 1;
	cout << x << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

// 二部グラフの最大重みマッチング
class Hungarian {
    int n, p, q;
    vvi mat;
    vi fx, fy, x, y;
    const i64 INF = 1e9;

public:
    Hungarian(const vvi& mat) : mat(mat) {
        n = mat.size();
        fx.assign(n, INF);
        fy.assign(n, 0);
        x.assign(n, -1);
        y.assign(n, -1);
    }

    i64 run() {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                fx[i] = max(fx[i], mat[i][j]);
            }
        }

        for (int i = 0; i < n;) {
            vi t(n, -1), s(n + 1, i);
            for (p = q = 0; p <= q && x[i] < 0; p++) {
                for (int k = s[p], j = 0; j < n && x[i] < 0; j++) {
                    if (fx[k] + fy[j] == mat[k][j] && t[j] < 0) {
                        s[++q] = y[j];
                        t[j] = k;
                        if (s[q] < 0) {
                            for (p = j; p >= 0; j = p) {
                                y[j] = k = t[j];
                                p = x[k];
                                x[k] = j;
                            }
                        }
                    }
                }
            }
            if (x[i] < 0) {
                i64 d = INF;
                for (int k = 0; k <= q; k++) {
                    for (int j = 0; j < n; j++) {
                        if (t[j] < 0) {
                            d = min(d, fx[s[k]] + fy[j] - mat[s[k]][j]);
                        }
                    }
                }
                for (int j = 0; j < n; j++) {
                    fy[j] += (t[j] < 0 ? 0 : d);
                }
                for (int k = 0; k <= q; k++) {
                    fx[s[k]] -= d;
                }
            } else {
                i++;
            }
        }
        i64 ret = 0;
        for (int i = 0; i < n; i++) {
            ret += mat[i][x[i]];
        }
        return ret;
    }

    int match_y(int k) {
        return x[k];
    }

    int match_x(int k) {
        return y[k];
    }
};

int main() {
    int n;
    while (cin >> n) {
        if (n == 0) break;
        long long sum = 0;
        vector<vector<int>> as(n);
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 3; j++) {
                int a;
                cin >> a;
                as[i].push_back(a);
            }
            sum += as[i][0] * as[i][1] * as[i][2];
            sort(as[i].begin(), as[i].end());
        }
        vvi mat(n, vi(n));
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                bool ok = true;
                for (int k = 0; k < 3; k++) {
                    if (as[i][k] >= as[j][k]) ok = false;
                }
                if (ok) {
                    mat[i][j] = as[i][0] * as[i][1] * as[i][2];
                }
            }
        }
        Hungarian h(mat);
        cout << sum - h.run() << endl;
    }
}


Measured memory_bytes: 3264
#include<bits/stdc++.h>
using namespace std;
void solve(){
string s,l;
int c=0;
cin>>s;
cin>>l;
assert(s.length()==l.length());
for(int i=0;i<s.length();i++){
    if(s[i]!=l[i]){c++;}
}

  cout<<c;
   
   
   
   
}

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

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

using namespace std; 

int main(){
	
	
	char c; 
	
	cin >> c;
	
	char ans = c=='A'?'T':c=='T'?'A':c=='C'?'G':'C';
	
	cout << ans  << endl;
	
    return 0;
}


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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)

#define F first
#define S second

typedef pair<li, li> PI;
map<PI, li> cnt;

int main(void)
{
	li n;
	cin>>n;
	li res=0;
	li prev = 0;
	rep(i,n){
		li a;
		cin>>a;
		res += max(0ll, prev-a);
		prev=max(prev, a);
	}
	cout<<res<<endl;


	return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<cmath>
using namespace std;

typedef long long int llint;

int main(){
	int Aloc=0,Zloc=0;
	string S;
	cin >> S;
	for(auto itr=S.begin();itr!=S.end();itr++){
		if(*itr=='A')break;
		Aloc++;
	}
	for(auto itr=S.rbegin();itr!=S.rend();itr++){
		if(*itr=='Z')break;
		Zloc++;
	}
	cout << ((S.length()-Zloc-1)-Aloc+1) << endl;
	return 0;
}


Measured memory_bytes: 640
N = int(input())
RED = [input() for _ in range(N)]
M = int(input())
BLUE = [input() for _ in range(M)]

counts = {}

for r in RED:
    counts[r] = (counts.get(r) or 0) + 1
    
for b in BLUE:
    counts[b] = (counts.get(b) or 0) - 1
    
print(max(max(counts.values()),0))

Measured memory_bytes: 38620
#include<stdio.h>

//macro
#define SIZE 1000000

//typedef
typedef struct{
	int posx[SIZE];
	int posy[SIZE];
	int turn[SIZE];
	int save;
	int load;
} queue_t;

//global
queue_t q;
int x,y,n;
int inix,iniy,initurn;
char field[1000][1000]={};
int map[1000][1000]={};
char cheese;
int answer=0;

void input(void){
	int loop1,loop2;
	char temp;
	scanf("%d%d%d",&y,&x,&n);
	for(loop1=0;loop1<y;loop1++){
		for(loop2=0;loop2<x;loop2++){
			scanf("%c",&temp);
			if(temp!='\n'){
				field[loop2][loop1]=temp;
			}
			else{
				loop2--;
			}
			if(field[loop2][loop1]=='S'){
				inix=loop2;
				iniy=loop1;
			}
		}
	}
}

void initialize(int inix,int iniy){
	int loop1,loop2;
	q.posx[0]=inix;
	q.posy[0]=iniy;
	q.turn[0]=0;
	for(loop1=1;loop1<SIZE;loop1++){
		q.posx[loop1]=0;
		q.posy[loop1]=0;
		q.turn[loop1]=0;
	}
	for(loop1=0;loop1<1000;loop1++){
		for(loop2=0;loop2<1000;loop2++){
			map[loop1][loop2]=0;
		}
	}
	map[inix][iniy]++;
	q.save=1;
	q.load=0;
	//printf("initialized: %d %d %d",q.posx[q.load],q.posy[q.load],q.turn[q.load]);
}
int search(int cheesenum){
	sprintf(&cheese,"%d",cheesenum);
	//printf("mouse: I'm going to eat cheese No.%c\n",cheese);
	while(field[q.posx[q.load]][q.posy[q.load]]!=cheese){
		while(q.turn[q.load]>1000000){
			q.load++;
		}
		if(q.posx[q.load]+1<x && field[q.posx[q.load]+1][q.posy[q.load]]!='X' && map[q.posx[q.load]+1][q.posy[q.load]]==0){
			map[q.posx[q.load]+1][q.posy[q.load]]++;
			q.posx[q.save]=q.posx[q.load]+1;
			q.posy[q.save]=q.posy[q.load];
			q.turn[q.save]=q.turn[q.load]+1;
			//printf("I'm at %d %d, time is %d\n",q.posx[q.save],q.posy[q.save],q.turn[q.save]);
			q.save++;
			
		}
		if(q.posx[q.load]-1>=0 && field[q.posx[q.load]-1][q.posy[q.load]]!='X' && map[q.posx[q.load]-1][q.posy[q.load]]==0){
			map[q.posx[q.load]-1][q.posy[q.load]]++;
			q.posx[q.save]=q.posx[q.load]-1;
			q.posy[q.save]=q.posy[q.load];
			q.turn[q.save]=q.turn[q.load]+1;
			//printf("I'm at %d %d, time is %d\n",q.posx[q.save],q.posy[q.save],q.turn[q.save]);
			q.save++;
		}
		if(q.posy[q.load]+1<y && field[q.posx[q.load]][q.posy[q.load]+1]!='X'  && map[q.posx[q.load]][q.posy[q.load]+1]==0){
			map[q.posx[q.load]][q.posy[q.load]+1]++;
			q.posx[q.save]=q.posx[q.load];
			q.posy[q.save]=q.posy[q.load]+1;
			q.turn[q.save]=q.turn[q.load]+1;
			//printf("I'm at %d %d, time is %d\n",q.posx[q.save],q.posy[q.save],q.turn[q.save]);
			q.save++;
		}
		if(q.posy[q.load]-1>=0 && field[q.posx[q.load]][q.posy[q.load]-1]!='X' && map[q.posx[q.load]][q.posy[q.load]-1]==0){
			map[q.posx[q.load]][q.posy[q.load]-1]++;
			q.posx[q.save]=q.posx[q.load];
			q.posy[q.save]=q.posy[q.load]-1;
			q.turn[q.save]=q.turn[q.load]+1;
			//printf("I'm at %d %d, time is %d\n",q.posx[q.save],q.posy[q.save],q.turn[q.save]);
			q.save++;
		}
		//printf("------\n");
		q.load++;
	}
	inix=q.posx[q.load];
	iniy=q.posy[q.load];
	return q.turn[q.load];
}

int main(void){
	int loop1;
	input();
	for(loop1=1;loop1<=n;loop1++){
		initialize(inix,iniy);
		answer+=search(loop1);
	}
	printf("%d\n",answer);
	
	return 0;
}
	

Measured memory_bytes: 18452
//Heaplax
#include<bits/stdc++.h>
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
int n,h,in[405],out[405],f[405];
bool vis[405];
int find(int x)
{
	return f[x]==x?x:f[x]=find(f[x]);
}
int main()
{
	re(n),re(h);
	for(int i=1;i<=h*2;++i)f[i]=i;
	for(int i=1,a,b,c,d;i<=n;++i)
	{
		re(a),re(b),re(c),re(d);
		int l=0,r=0;
		if(c)l=c;else l=h+a;
		if(d)r=h+d;else r=b;
		if(find(l)!=find(r))f[f[l]]=f[r];
		++out[l];++in[r];
	}
	for(int i=1;i<=h;++i)if(out[i]>in[i])return puts("NO"),0;
	for(int i=h+1;i<=h+h;++i)if(out[i]<in[i])return puts("NO"),0;
	for(int i=1;i<=h+h;++i)if(in[i]!=out[i])vis[find(i)]=1;
	for(int i=1;i<=h+h;++i)if(in[i]&&out[i]&&!vis[find(i)])return puts("NO"),0;
	puts("YES");
}


Measured memory_bytes: 256
#include<iostream>
int main(){for(float a,b,c,d,e,f,y,s;s=!(std::cin>>a>>b>>c>>d>>e>>f).eof();s&&printf("%.3f %.3f\n",d?f/d-e*y/d:c/a-b*y/a,y))y=c*d-a*f,y/=b*d-a*e;}

Measured memory_bytes: 0
/**
*    author:  velengel
*    created: 29.05.2020 15:17:40
*    to run & test the code, type below command.
*    cptest abc000_a
**/

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

int n,m,q;
int ans = 0;
vector<int> a,b,c,d;


int dfs(vector<int> &A){
  int ans = 0;
  if(A.size() == n){
    rep(i, q)
    {
      if(A[b[i]]-A[a[i]]==c[i]){
        ans += d[i];
      }
    }
    return ans;
  }
  int last = 1;
  if(!A.empty())
    last = A.back();
  for (int v = last; v <= m; ++v)
  {
    A.push_back(v);
    ans = max(ans,dfs(A));
    A.pop_back();
  }
  return ans;
}

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

  cin >> n >> m >> q;
  a.resize(q), b.resize(q), c.resize(q), d.resize(q);
  rep(i, q)
  {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--, b[i]--;
  }

  vector<int> A;
  cout<<dfs(A)<<endl;
  return 0;
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 4e5 + 5;

string s;

stack<char> stk;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  //cout << fixed << setprecision(6);
  cin>>s;
  for (auto c: s) {
    if (!stk.empty() && stk.top() != c) {
      stk.pop();
    } else {
      stk.push(c);
    }
  }

  int ans = (int)s.length() - (int)stk.size();
  cout<<ans<<endl;
  

  return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
	int area1;
	int area2;
	int A,B,C,D;
	cin>>A>>B>>C>>D;
	area1=A*B;
	area2=C*D;
	 if(area1>area2)
	cout<<area1<<"\n";
	else if(area2>area1)
	cout<<area2<<"\n";
	else
	cout<<area1<<"\n";
}

Measured memory_bytes: 256
A,B,C=map(int,input().split())
K = int(input())

flag = False
cnt = 0

while(A>=B):
    if cnt > K :
        break
    B = 2*B
    cnt += 1

while(B>=C):
    if cnt >= K:
        break
    C = 2*C
    cnt += 1

#print(A,B,C)
if A < B and B < C:
    flag = True

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9196
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        int a, b;
        String ans;
        Scanner s = new Scanner(System.in);
        a = s.nextInt();
        b = s.nextInt();
        
        if (a == b){
            ans = "==";
        }else if (a > b){
            ans = ">";
        }else{
            ans = "<";
        }
        System.out.println("a "+ans+" b");
    }
}


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

ll gcd(int n, int m){
  if(n < m) swap(n,m);

  if(m==0) return 0;
  while(m > 0){
    int res = n%m;
    n = m;
    m = res;
  }
  return n;
}

int lcm(int n, int m){
  return m*n/gcd(n,m);
}


int main(){
  ll n,m;
  string s,t;
  cin >> n >> m >> s >> t;

  ll l = lcm(n,m);
  bool ok = true;
  rep(i,gcd(n,m)) ok &= s[l/m*i]==t[l/n*i];
  cout<< (ok ? l : -1) << '\n';
  return 0;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
//ll

int main(){
  string s;cin>>s;
  ll ans = 0;
  for(int i = (1<<(s.length()-1)); i < (1<<(s.length()));i++){
    int lastPos = 0;
    rep(j,s.length()){
      if(i&(1<<j)){
        ans += stoll(s.substr(lastPos,j-lastPos+1));
        lastPos = j+1;
      }
    }
  }
  cout << ans << endl;
}

//      while(after[i]<0)after[i] += l;


Measured memory_bytes: 256
a,b,k=map(int,input().split())
def rule(a,b):
    if a%2==0:
        return a//2,b+a//2     
    else:
        return (a-1)//2,b+(a-1)//2

for i in range(k):
    if i%2==0:
        a,b=rule(a,b)
    else:
        b,a=rule(b,a)
print(a,b)

Measured memory_bytes: 9036
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

struct Edge {
	int to;
	int cost;
	unsigned int rev_num;
};

vector<vector<Edge>>edge;
vector<int>dis;
vector<int>iter;

int flow(int v, int t, int f) {
	if (v == t) {
		return f;
	}
	for (int &i = iter[v]; i < edge[v].size(); i++) {
		Edge &e = edge[v][i];
		if (e.cost > 0 && dis[v] < dis[e.to]) {
			int d = flow(e.to, t, min(f, e.cost));
			if (d > 0) {
				e.cost -= d;
				edge[e.to][e.rev_num].cost += d;
				return d;
			}
		}
	}
	return 0;
}

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

	cin >> H >> W;
	edge.resize(202);
	dis.resize(202);
	iter.resize(202);
	vector<string>s(H);
	for (int i = 0; i < H; i++) {
		cin >> s[i];
	}
	int sy, sx, gy, gx;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (s[i][j] == 'S') {
				sy = i;
				sx = j;
				edge[200].push_back(Edge{ i,10000,edge[i].size() });
				edge[i].push_back(Edge{ 200,0,edge[200].size() - 1 });
				edge[200].push_back(Edge{ j + 100,10000,edge[j + 100].size() });
				edge[j + 100].push_back(Edge{ 200,0,edge[200].size() });
			}
			else if (s[i][j] == 'T') {
				gy = i;
				gx = j;
				edge[i].push_back(Edge{ 201,10000,edge[201].size() });
				edge[201].push_back(Edge{ i,0,edge[i].size() });
				edge[j + 100].push_back(Edge{ 201,10000,edge[201].size() });
				edge[201].push_back(Edge{ j+100,0,edge[j+100].size() });
			}
		}
	}
	if (sy == gy || sx == gx) {
		cout << "-1\n";
		return 0;
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (s[i][j] != '.') {
				edge[i].push_back(Edge{ j + 100,1,edge[j + 100].size() });
				edge[j + 100].push_back(Edge{ i,1,edge[i].size() - 1 });
			}
		}
	}
	int ans = 0;
	while (1) {
		for (int i = 0; i < 202; i++) {
			dis[i] = INT_MAX;
		}
		dis[200] = 0;
		queue<int>Q;
		Q.push(200);
		while (!Q.empty()) {
			int cn = Q.front();
			Q.pop();
			for (auto i : edge[cn]) {
				if (i.cost >= 1) {
					if (dis[i.to] > dis[cn] + 1) {
						dis[i.to] = dis[cn] + 1;
						Q.push({ i.to });
					}
				}
			}
		}
		if (dis[201] == INT_MAX) {
			cout << ans << endl;
			return 0;
		}
		for (int i = 0; i < 202; i++) {
			iter[i] = 0;
		}
		int f;
		while ((f = flow(200, 201, INT_MAX)) > 0) {
			ans += f;
		}
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
long long N;
cin>>N;
long long a;
long long counter=1;
for(long long i=1;i*i<=N;i++){
if(N%i==0){
counter=i;}}
a=counter+N/counter-2;
cout<<a<<endl;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int K, A, B;
    cin >> K >> A >> B;
    bool flag = false;
    repd(i, A, B + 1) {
        if (i % K == 0) flag = true;
    }

    if (flag) cout << "OK" << endl;
    else cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

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

int bfs (vector<string> &g, int sy, int sx, int ty, int tx) {
    queue<P> q;
    vector<vector<int>> dp(h, vector<int>(w, INF));
    dp[sy][sx] = 0;
    q.push(P(sy,sx));
    while (q.size()) {
        P v = q.front(); q.pop();
        int vy = v.first; int vx = v.second;
        rep(i,4) {
            int ny = vy+dy[i]; int nx = vx+dx[i];
            if (ny<0 || ny>=h || nx<0 || nx>=w) continue;
            if (g[ny][nx]=='#') continue;
            if (dp[ny][nx] > dp[vy][vx]+1) {
                dp[ny][nx] = dp[vy][vx]+1;
                q.push(P(ny,nx));
            }
        }
    }
    return dp[ty][tx];
}

int main(int argc, char const *argv[]) {
    cin>>h>>w;
    vector<string> s(h);
    rep(i,h) cin>>s[i];
    ll ans = 0;
    rep(i,h) {
        rep(j,w) {
            rep(k,h) {
                rep(l,w) {
                    if (s[i][j] == '.' && s[k][l] == '.') {
                        ll tmp = bfs(s,i,j,k,l);
                        if (tmp!=INF) chmax(ans,tmp);
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

string shuffle(string str, int n)
{
    string leftString = str.substr(0, n);
    string rightString = str.substr(n, str.size());

    return rightString + leftString;
}

int main()
{
    string str;
    int m, n;

    while (true) {
        cin >> str;

        if (!str.compare("-")) {
            return 0;
        }

        cin >> m;

        for (int i = 0; i < m; i++) {
            cin >> n;
            str = shuffle(str, n);
        }

        cout << str << endl;
    }
}

Measured memory_bytes: 1216
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <deque>

using namespace std;

char s[100001];
int l;

bool pos(int k) {
	int tar = s[0] - '0';
	deque<int> dq;
	bool ok = true;
	for (int i = 1; i < k; i++) {
		while (!dq.empty() && dq.front() <= i - k) dq.pop_front();
		int cur = s[i] - '0';
		if ((cur + dq.size() % 2) % 2 != tar) {
			if (i + k - 1 >= l) {
				ok = false; break;
			}
			else dq.push_back(i);
		}
	}
	if (ok) return true;
	dq.clear();
	ok = true;
	reverse(s, s + l);
	tar = s[0] - '0';
	for (int i = 1; i < k; i++) {
		while (!dq.empty() && dq.front() <= i - k) dq.pop_front();
		int cur = s[i] - '0';
		if ((cur + dq.size() % 2) % 2 != tar) {
			if (i + k - 1 >= l) {
				ok = false; break;
			}
			else dq.push_back(i);
		}
	}
	reverse(s, s + l);
	return ok;
}

int main() {
	scanf("%s", s);
	l = strlen(s);
	if (pos(l)) {
		printf("%d\n", l);
		return 0;
	}
	int lo = 1, hi = l;
	while (lo + 1 < hi) {
		int mid = (lo + hi) / 2;
		if (pos(mid)) lo = mid;
		else hi = mid;
	}
	printf("%d\n", lo);
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>


int main(void)
{
int t, sec, min, hour;

scanf("%d", &t);

sec = t % 60;
t = (t - sec) / 60;
min = t % 60;
hour = (t - min) / 60;
printf("%d:%d:%d\n", hour, min, sec);

return 0;
}

Measured memory_bytes: 592
from collections import Counter

n = int(input())
d = list(map(int, input().split()))
d_c = Counter(d)
m = int(input())
t = sorted(list(map(int, input().split())), reverse=True)

for i in range(m):
    if d_c[t[i]] > 0:
        d_c[t[i]] -= 1
    else:
        print('NO')
        exit()
print('YES')


Measured memory_bytes: 52376
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();

		int A[][] = new int[N][M];
		int b[] = new int[M];

		for (int i = 0; i < N; i++) {
			for (int j = 0; j < M; j++) {
				A[i][j] = sc.nextInt();
			}
		}

		for (int i = 0; i < M; i++) {
			b[i] = sc.nextInt();
		}

		int ans;

		for (int i = 0; i < N; i++) {
			ans = 0;
			for (int j = 0; j < M; j++) {
				ans += (A[i][j] * b[j]);
			}
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 40272
#include<iostream>

using namespace std;

int main(){

  int sum[6], n;
  double in;

  for(int i = 0; i < 6; i++){
    sum[i] = 0;
  }

  cin >> n;

  for(int i = 0; i < n; i++){
    cin >> in;

    if(in >= 185){
      sum[5]++;
    }else if(in >= 180){
      sum[4]++;
    }else if(in >= 175){
      sum[3]++;
    }else if(in >= 170){
      sum[2]++;
    }else if(in >= 165){
      sum[1]++;
    }else{
      sum[0]++;
    }

  }

  for(int i = 0; i <= 5; i++){
    cout << i+1 << ":";
    for(int j = 0; j < sum[i]; j++){
      cout << "*";
    }
    cout <<endl;
  }

  return 0;
}

Measured memory_bytes: 0
class UnionFind
  def initialize(n)
    @root = Array.new(n)
    @rank = Array.new(n)
    @size = Array.new(n)
    (0...n).each do |i|
      @root[i] = i
      @rank[i] = 0
      @size[i] = 1
    end
  end

  def find(x)
    if @root[x] == x
      x
    else
      @root[x] = find(@root[x])
    end
  end

  def unite(x, y)
    x_root = find(x)
    y_root = find(y)
    return if x_root == y_root

    if @rank[x_root] < @rank[y_root]
      @root[x_root] = y_root
      @size[y_root] += @size[x_root]
    else
      @root[y_root] = x_root
      @size[x_root] += @size[y_root]
      if @rank[x_root] == @rank[y_root]
        @rank[x_root] += 1
      end
    end
    nil
  end

  def size(x)
    x_root = find(x)
    @size[x_root]
  end

  def same?(x, y)
    find(x) == find(y)
  end
end

N, M = gets.split.map(&:to_i)
xyzs = M.times.map { gets.split.map(&:to_i) }
uf = UnionFind.new(N + 1)
xyzs.each do |(x, y, z)|
  uf.unite(x, y)
end
ans = 0
used = {}
(1..N).each do |n|
  root = uf.find(n)
  next if used[root]
  used[root] = true
  ans += 1
end
puts ans

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

using namespace std;

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 ANTHRO(x...) cerr << "[" << #x << "] = [", _print(x)
#else
#define ANTHRO(x...)
#endif


#define ll long long
#define MOD 1000000007
#define INF (ll)1e18
#define EPS 1e-9
/*
	XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    No, nothing good starts in a getaway car
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
*/

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m; cin>>n>>m;
    vector<ll> inp(m);
    ll s=0;
    for(ll i=0;i<m;i++){
		cin>>inp[i]; s+=inp[i];
	}
	if(s>n) cout<<-1<<endl;
	else cout<<abs(s-n)<<endl;
    return 0;
}


Measured memory_bytes: 3692
p = 10**9 + 7
N, A, B, C = map(int, input().split())
inv100 = pow(100,p-2,p)
A = A * pow(100-C,p-2,p) % p
B = B * pow(100-C,p-2,p) % p
C = C * inv100 % p

a = [None] * (2*N+1)
inva = [None] * (2*N+1)
a[0] = 1

for i in range(1, 2*N+1):
    a[i] = i * a[i-1] % p

inva[2*N] = pow(a[2*N],p-2,p)
for i in range(2*N):
    inva[2*N-i-1] = inva[2*N-i] * (2*N-i) % p

ans = 0
prevN = pow(A,N,p) * pow(pow(B,N,p),p-2,p) % p

for m in range(N,2*N):
    tmp = (a[m-1] * inva[N-1] % p) * inva[m-N] % p
    tmp *= m
    tmp %= p
    tmp *= ((pow(A,m-N,p) * pow(B,N,p) % p) + (pow(B,m-N,p) * pow(A,N,p) % p)) % p
    tmp %= p
    ans += tmp
    ans %= p
print(ans * pow(1-C,p-2,p)%p)

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

int main() {
  int n;
  cin >> n;
  if(n < 600) cout << 8 << endl;
  else if(n < 800) cout << 7 << endl;
  else if(n < 1000) cout << 6 << endl;
  else if(n < 1200) cout << 5 << endl;
  else if(n < 1400) cout << 4 << endl;
  else if(n < 1600) cout << 3 << endl;
  else if(n < 1800) cout << 2 << endl;
  else cout << 1 << endl;
}

Measured memory_bytes: 3580
void call(int n)
{
	int i = 1;
	int x;

	do {
		x = i;
		if (x % 3 == 0) {
			printf(" %d", i);
		}
		else {
			do {
				if (x % 10 == 3) {
					printf(" %d", i);
					x = 0;
				}
				else x /= 10;
			} while (x);
		}
	} while (++i <= n);
	putchar('\n');
}

#if 1
int main()
{
	int n;

	scanf("%d", &n);
	call(n);
	return 0;
}
#endif


Measured memory_bytes: 2056
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int w = sc.nextInt();
			int d = sc.nextInt();
			if (w == 0 && d == 0)
				break;
			int[] h1 = new int[w];
			int[] h2 = new int[d];
			int[] count1 = new int[21];
			int ans = 0;
			for (int i = 0; i < h1.length; ++i) {
				h1[i] = sc.nextInt();
				++count1[h1[i]];
				ans += h1[i];
			}
			for (int i = 0; i < h2.length; ++i) {
				h2[i] = sc.nextInt();
				ans += h2[i];
				if (count1[h2[i]] > 0) {
					ans -= h2[i];
					--count1[h2[i]];
				}
			}
			System.out.println(ans);
		}
	}
}

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

int main() {
  int H,W,h,w;
  cin >> H >> W >> h >> w;
  cout << (H-h) * (W-w) << endl;
  return 0;
}


Measured memory_bytes: 3636
//JSD
#include<algorithm>
#include<iostream>
#include<set>
#define ll long long 
using namespace std;
int main(){
	ll n;
	cin>>n;;
	if(n%2==1){
		cout<<"0\n";		
	}
	else{		
		ll nn=n/2;
		ll ans=0;
		ll k=5;
		while(nn>=k){
			ans+=(nn/k)	;
			k*=5;
		}
		cout<<ans<<"\n";
	}	
	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	N, _ := strconv.Atoi(sc.Text())
	problems := make([]int, N)
	for i := 0; i < N; i++ {
		sc.Scan()
		problems[i], _ = strconv.Atoi(sc.Text())
	}

	sort.Ints(problems)
	halfN := N / 2
	fmt.Println(problems[halfN] - problems[halfN-1])
}


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

int main(void)
{
    string s;
    int count = 0;
    cin >> s;
    for (size_t i = 0; i < s.size(); i++) {
        if (s[i] == '+') count++;
        else count--;
    }
    cout << count << endl;
}


Measured memory_bytes: 3560
//???1:AC?????????
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int N;
int* BIT;
int* table;
ll* weight;
int* hanten_num;
ll* mult;

void add(int loc,int value){

	BIT[loc] += value;

	loc += loc & -loc;

	while(loc <= N){
		BIT[loc] += value;
		loc += loc & -loc;
	}
}

int getSum(int loc){

	int sum = BIT[loc];

	loc -= loc & -loc;

	while(loc > 0){
		sum += BIT[loc];
		loc -= loc & -loc;
	}
	return sum;
}

void func(){

	for(int i = 1; i <= N; i++){
		BIT[i] = 0;
	}

	for(int i = 1; i <= N; i++){
		table[i] = i;
	}

	weight[N] = 0;
	weight[N-1] = 1;
	for(int digit = N-2; digit >= 1; digit--){
		weight[digit] = mult[N-(digit)];
	}

	int R;
	scanf("%d",&R);

	int left,right;
	for(int loop = 0; loop < R; loop++){
		scanf("%d %d",&left,&right);
		swap(table[left],table[right]);
	}

	for(int digit = N; digit >= 1; digit--){
		hanten_num[digit] = getSum(table[digit]);
		add(table[digit],1);
	}

	ll ans = 0;

	for(int digit = 1; digit <= N-1; digit++){
		ans += (weight[digit]*hanten_num[digit])%MOD;
		ans %= MOD;
	}

	printf("%lld\n",ans%MOD);
}



int main(){

	BIT = new int[100001];
	table = new int[100001];
	weight = new ll[100001];
	hanten_num = new int[100001];
	mult = new ll[100001];

	mult[1] = 1;

	for(int i = 2; i <= 100000; i++){
		mult[i] = mult[i-1]*i;
		mult[i] %= MOD;
	}

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 5952
#include <bits/stdc++.h>
using namespace std;
int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}
int a[105];
int main(){
	ios::sync_with_stdio(false);
	int n;cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);
	int ans=1;int _x=a[1]; 
	for(int i=2;i<=n;i++){
		if(a[i]!=_x){
			ans++;_x=a[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll MOD2 = 998244353;
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()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int A, B, C; cin >> A >> B >> C;
  //main
  
  
  // output
  cout << min(B/A, C) << endl;

  return 0;
}


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

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    int r = scanf("%d", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    int r = scanf("%lld", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, double i)
{
    printf("%.20f", i);
    return my;
}

constexpr char BR = '\n';


class UnionFind
{
    vector<size_t> parent;
    vector<size_t> tsize;

public:
    UnionFind(int N)
    : parent(N), tsize(N, 1)
    {
        for(int i = 0; i < N; i++)
            parent[i] = i;
    }

    size_t root(size_t x)
    {
        if (parent[x] == x)
             return x;
        
        return parent[x] = root(parent[x]);
    }

    void unite(size_t x, size_t y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;

        if (tsize[rx] < tsize[ry])
             swap(rx, ry);
        
        tsize[rx] += tsize[ry];
        parent[ry] = rx;
    }

    bool same(size_t x, size_t y)
    {
        return root(x) == root(y);
    }

    size_t size(size_t x)
    {
        return tsize[root(x)];
    }
};


///////////////////////////////////////////////////

int main()
{
    int N, M;
    io >> N >> M;
    
    UnionFind uft(N);
    for (int i = 0; i < M; i++)
    {
        int a, b;
        io >> a >> b;
        uft.unite(a-1, b-1);
    }
    
    size_t ans = 0;
    for (int i = 0; i < N; i++)
    {
        ans = max(ans, uft.size(i));
    }
    cout << ans << BR;
}

Measured memory_bytes: 6448
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
inline int read()
{
	int x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x;
}
#define MN 100000
struct coin{int x,y;}c[MN+5];
bool cmp(const coin&a,const coin&b){return a.x>b.x;}
struct CMP1{bool operator()(int a,int b){return c[a].y-c[a].x<c[b].y-c[b].x;}};
struct CMP2{bool operator()(int a,int b){return c[a].y<c[b].y;}};
priority_queue<int,vector<int>,CMP1> pq1;
priority_queue<int,vector<int>,CMP2> pq2;
long long ans,mx=-1e18,s1[MN+5],s2;
int main()
{
	int x,y,z,i,v;
	x=read();y=read();z=read();
	for(i=1;i<=x+y+z;++i)ans+=v=read(),c[i].x=read()-v,c[i].y=read()-v;
	sort(c+1,c+x+y+z+1,cmp);
	for(i=1;i<=y+z;++i)
	{
		s1[i]=s1[i-1]+c[i].x;pq1.push(i);
		if(i>y)v=pq1.top(),pq1.pop(),s1[i]+=c[v].y-c[v].x;
	}
	for(i=x+y+z;i>y;--i)
	{
		pq2.push(i);
		if(i<=y+z)s2+=c[pq2.top()].y,pq2.pop();
		if(i-1<=y+z)mx=max(mx,s1[i-1]+s2);
	}
	printf("%lld",ans+mx);
}

Measured memory_bytes: 2296
import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int n = scanner.nextInt();
        int ans = 0;
        int pre = scanner.nextInt();
        for (int i = 1, cnt = 0; i < n; ++i) {
            int cur = scanner.nextInt();
            if (cur <= pre) {
                ++cnt;
                ans = Math.max(ans, cnt);
            } else {
                cnt = 0;
            }
            pre = cur;
        }
        writer.println(ans);
        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        private void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        private char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        private String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        private int nextInt() {
            return Integer.valueOf(next());
        }

        private long nextLong() {
            return Long.valueOf(next());
        }

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

Measured memory_bytes: 40976
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,a[100005],k,K=orz;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        scanf("%d",a+i);
        k=max(k,a[i]);
        K=min(K,a[i]);
    }
    if(k==K){
        if(k==n-1||k<=n/2)puts("Yes");
        else puts("No");
        return 0;
    }
    if(K<k-1){
        puts("No");
        return 0;
    }
    K=0;
    for(int i=1;i<=n;++i)if(a[i]<k)++K;
    n-=K,k-=K;
    if(k>0&&k<=n/2)puts("Yes");
    else puts("No");
    //system("pause");
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;

int n, m;
int a[100000];
int imos[300001];
int sub[100000];

void input() {
	int i;
	
	cin >> n >> m;
	for (i = 0; i < n; i++) cin >> a[i];
	for (i = 0; i < n; i++) a[i]--;
	
	for (i = 0; i < n - 1; i++) {
		int l = (a[i + 1] - a[i] + m) % m;
		if (l < 2) continue;
		int r = a[i + 1]; if (a[i + 1] < a[i]) r += m;
		imos[r + 1] += l - 1;
		imos[r + 2] -= l - 1;
		imos[a[i] + 2] -= 1;
		imos[r + 1] += 1;
	}
	
	for (i = 1; i < 3 * m; i++) imos[i] += imos[i - 1];

	for (i = 0; i < m; i++) {
		sub[i] = imos[i] + imos[m + i] + imos[2 * m + 1];
	}
}

signed main() {
	input();
	
	int def = 0;
	for (int i = 0; i < n - 1; i++) {
		int X = (a[i + 1] - a[i] + m) % m;
		int Z = a[i + 1] + 1;
		def += min(X, Z);
	}

	int now = def;
	int ans = def;
	for (int i = 1; i < m; i++) {
		now += sub[i];
		ans = min(now, ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  string S;
  cin >> N >> S;
  int ans = 0;
  for (int i = 0; i <= N - 3; i++)
  {
    if (S.at(i) == 'A' && S.at(i + 1) == 'B' && S.at(i + 2) == 'C')
    {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int i, j, total=0;
    long N, num, cate, dum;
    scanf("%ld", &N);
    long arg[N];
    scanf("%ld", &cate);

    for(i=0; i<N; i++) {
        scanf("%ld", &num);
        arg[i] = num;
    }

    for(i=0;i<N; i++) {
        for(j=i; j<N; j++) {
            if(arg[j]<arg[i]) {
                dum = arg[i];
                arg[i] = arg[j];
                arg[j] = dum;
            }
        }
    }

    for(i=0; i<cate; i++) {
        total += arg[i];
    }

    printf("%d\n", total);

    return 0;
}

Measured memory_bytes: 1732