akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		int n=scanner.nextInt();
		int k=scanner.nextInt();
		int cnt=1;
		for(int i=n;i>=k;i/=k){
			cnt++;
		}
		System.out.println(cnt);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    long long k;
    cin>>n>>k;
    long long h[n];
    for(long long i=0;i<n;i++){
        cin>>h[i];
    }
    sort(h,h+n);
    long long ans=0;
    for(long long i=0;i<n-k;i++){
        ans+=h[i];
    }
    cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define fst	first
#define scn second
#define bicnt(x)	__buildin__popcount(x)
#define debug(x)	cout<<"debug: "<<x<<endl

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;
const ld eps = 1e-18;
const int dx[] = { 0,1,0,-1 };
const int dy[] = { 1,0,-1,0 };

static char server(string s) {
	int n = 100;
	if (s[0] == '?') {
		ll k = stol(s.substr(2));
		if (k <= n&&s.substr(2) <= to_string(n))	return 'Y';
		if (k > n&&s.substr(2) > to_string(n))	return 'Y';
		else	return 'N';
	}
	else {
		ll k = stol(s.substr(2));
		if (k == n) {
			cout << "suceed!!" << endl;
			exit(0);
		}
		else {
			cout << "failed..." << endl;
			exit(0);
		}
	}
}

char query(ll k) {
	cout << "? " << k << endl;
	//char ret = server("? " + to_string(k));
	char ret;	cin >> ret;
	return ret;
}

void answer(ll k) {
	cout << "! " << k << endl;
	//char ret = server("! " + to_string(k));
}

int main() {
	if (query(1000000001) == 'Y') {
		ll ans = 10;
		while (query(ans - 1) == 'N')	ans *= 10;
		answer(ans / 10);
		return 0;
	}
	ll ans = 1LL;
	while (true) {
		char s = query(ans);
		if (s == 'N') {
			ans /= 10;
			break;
		}
		else {
			ans *= 10;
			if (ans > mod) {
				answer(1e9);
				return 0;
			}
		}
	}
	ll left = ans, right = ans * 10;
	while (left + 5 < right) {
		ll mid = (left + right) / 2;
		char s = query(mid * 10);
		if (s == 'Y')	right = mid;
		else	left = mid;
	}
	for (ll i = left; i <= right; i++) {
		char s = query(i * 10);
		if (s == 'Y') {
			answer(i);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 596
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int count = 0;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            while (a % 2 == 0) {
                count++;
                a /= 2;
            }
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 48456
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	string S;
	cin >> S;

	string SS = "CODEFESTIVAL2016";

	int count = 0;
	for (int i = 0; i < S.length(); i++) {
		if (S[i] != SS[i]) {
			count++;
		}
	}
	cout << count << endl;

}






Measured memory_bytes: 3624
//#typedef int ll
// include
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <tuple>
// namespace
using namespace std;
// typedef
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pint;
// const
const int inf = 1e9;
const int mod = ((int)1e9 + 7);
// loop
#define rep(i, n) for(int i = 0, i##_mx = n; i < i##_mx; i++)
#define brep(i, b, e) for(int i = b; i < e; i++)
#define erep(i, b, e) for(int i = b; i <= e; i++)
#define rrep(i, b, e) for(int i = b; i >= e; i--)
// STL
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
// function
int gcd(int a, int b){return b ? gcd(b, a % b) : a;}
void prime(vint& v, int n){brep(i, 2, n){bool fg = false; for(auto e : v){if(i % e == 0){fg = true;}} if(fg){continue;} v.pb(i);}}
void in(vint& v){for(auto& i : v){cin >> i;}}

signed main(){
    int p, q, r;
    cin >> p >> q >> r;
    cout << p + q + r - max({p, q, r}) << endl;
	
	return 0;
}

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

int main() {
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	if (e - a > k) {
		cout << ":(" << endl;
	}
	else {
		cout << "Yay!" << endl;
	}


	return 0;
}

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

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr ll inf = 1ll<<60;
int main(){
    unsigned long long C[55][55];
    C[0][0] = 1ull;
    for(int i=1;i<51;i++){
        for(int j=0;j<=i;++j){
            if(j == i or j==0) C[i][j] = 1ull;
            else C[i][j] = C[i-1][j-1] + C[i-1][j];
        }
    }
    int n,a,b;
    cin>>n>>a>>b;
    vector<ll> v(n);
    for(auto &a : v) cin>>a;
    sort(v.rbegin(),v.rend());
    ll ret = 0;
    ll cur = v[a-1];
    int count = 0;
    for(int i=0;i<a;++i){
        ret += v[i];
        if(cur == v[i]) count++;
    }
    bool all = false;
    if(v[0] == cur){
        all = true;
    }
    reverse(v.begin(),v.end());
    int countm = upper_bound(v.begin(),v.end(),cur) - lower_bound(v.begin(),v.end(),cur);
    unsigned long long retc = 0ull;
    if(!all)retc = C[countm][count];
    else {
        for(int i=a;i<=b;++i){
            retc += C[countm][i];
        }
    }
    cout<< fixed << setprecision(20) << 1.0 * ret/a << endl;
    cout << retc << endl;
    return 0;
}



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

const int N = 100005;
int main() {
	int n, a[100005],b[100005];
	cin >> n;
	for (int i = 0; i < N; i++) {
		a[i] = 0;
		b[i] = 0;
	}

	for (int i = 0; i < n; i++) {
		int t; 
		cin >> t;
		a[t]++;
	}
	
	int ans = 0;
	for (int i = 0; i < N - 2; i++) {
		b[i] = a[i] + a[i + 1] + a[i + 2];
		ans = max(ans, b[i]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
 
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<VVLL> VVVLL;

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORL(i,a,b) for(LL i=(a);i<(b);++i)
#define REPL(i,n)  FORL(i,0,n)
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         rotate(k,itr2,last);
         return true;
      }
   }
   rotate(first,k,last);
   return false;
}

inline double get_time_sec(void){
    return static_cast<double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count())/1000000000;
}

template<typename T>
T gcd(T a, T b) {
    if(a > b) swap(a, b);
    if(a == 0) return b;
    else return gcd(b%a, a);
}

template<typename T>
map<T, T> prime_list(T n) {
    map<T, T> ret;
    for(T i = 2; i*i <= n; i++) {
        if(n % i == 0) {
            ret[i] = 0;
            while(n % i == 0) {
                n /= i;
                ret[i]++;
            }
        } 
    }
    if(n != 1) ret[n]++;
    return ret;
}

#define MOD 1000000007

LL mypow(LL a, LL n) {
    if(n == 1) return a % MOD;
    if(n % 2 == 1) return (a * mypow(a, n-1)) % MOD;
    LL t = mypow(a, n/2);
    return (t * t) % MOD; 
}

int n, y;

void dfs(int rem, VI v) {
    if(v.size() == 0) {
        REP(i, 1 + rem / 10000) {
            VI vtmp(v);
            vtmp.push_back(i);
            dfs(rem - i * 10000, vtmp);
        }
    }
    if(v.size() == 1) {
        REP(i, 1 + rem / 5000) {
            VI vtmp(v);
            vtmp.push_back(i);
            dfs(rem - i * 5000, vtmp);
        }
    }
    if(v.size() == 2) {
        if(v[0] + v[1] + rem/1000 == n) {
            cout << v[0] << " " << v[1] << " " << rem/1000 << endl;
            exit(0);
        }
    }
}

int main(void) {
    cin >> n >> y;
    VI v;
    dfs(y, v);
    cout << "-1 -1 -1" << endl;
}

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

ll min(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    else return b;
}

int main() {
    double w,h,x,y;
    cin>>w>>h>>x>>y;
    double ans;
    ans=(w*h)/2;
    w=w/3.0;
    w=w*3.0;
    cout<<ans<<' ';
    if(x==w/2 & y==h/2){
        cout<<1<<endl;
    }else{
        cout<<0<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
    char a[10];
    while(cin>>a[1]){
        for(int i=2;i<10;i++){
            cin>>a[i];

        }
        char str;
        if(a[1]==a[2]&&a[2]==a[3]&&a[1]!='s')str=a[1];
        else if(a[4]==a[5]&&a[5]==a[6]&&a[4]!='s')str=a[4];
        else if(a[7]==a[8]&&a[8]==a[9]&&a[7]!='s')str=a[7];
        else if(a[1]==a[4]&&a[4]==a[7]&&a[1]!='s')str=a[1];
        else if(a[2]==a[5]&&a[5]==a[8]&&a[2]!='s')str=a[2];
        else if(a[3]==a[6]&&a[6]==a[9]&&a[3]!='s')str=a[3];
        else if(a[1]==a[5]&&a[5]==a[9]&&a[1]!='s')str=a[1];
        else if(a[3]==a[5]&&a[5]==a[7]&&a[3]!='s')str=a[3];
        else str='d';
        cout<<str<<endl;
    }


    return 0;
}

Measured memory_bytes: 1128
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

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

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int h1,m1,h2,m2,k;cin>>h1>>m1>>h2>>m2>>k;
    int m=(h2-h1)*60+(m2-m1);
    
    cout<<max(0,m-k)<<endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 3652
n,m=map(int,input().split())
l=[0 for i in range(m)]
r=[0 for i in range(m)]
for i in range(m):
  l[i],r[i]=map(int,input().split())
maxl=max(l)
minr=min(r)
if minr-maxl<0:
  print(0)
else:
  print(minr-maxl+1)

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

int main(){
    int n;
    cin >> n;
    ll m, a, sum[n], cnt = 0;
    map<ll, ll> mp;
    memset(sum, 0, sizeof(sum));
    mp[0] = 1;
    cin >> m;
    for(int i = 0; i < n; i++){
        cin >> a;
        sum[i+1] = sum[i] + a;
        cnt += mp[sum[i+1] % m];
        mp[sum[i+1] % m]++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  long long int p, n, t = 0;
  char c;
  for(int i = 0; i < N; ++i){
    cin >> p >> c >> n;
    if(c == '(') t += n;
    else t -= n;
    if(!t) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

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

int main(){
  int N;
  cin>>N;
  vector<vector<int>> A(N+1,vector<int>(3));
  A[0]={0,0,0};
  for(int i=1;i<=N;i++)
    for(int &j:A[i])
      cin>>j;
  for(int i=1;i<=N;i++)
    if(A[i][0]-A[i-1][0]<abs(A[i][1]-A[i-1][1])+abs(A[i][2]-A[i-1][2]) || (A[i][0]-A[i-1][0])%2!=(abs(A[i][1]-A[i-1][1])+abs(A[i][2]-A[i-1][2]))%2){
      cout<<"No"<<endl;
      return 0;
    }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 8752
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int W=sc.nextInt();
        int H=sc.nextInt();
        int x=sc.nextInt();
        int y=sc.nextInt();
        int r=sc.nextInt();
        if(r<=x&&x<=W-r&&r<=y&&y<=H-r)System.out.println("Yes");
        else System.out.println("No");
    }
}


Measured memory_bytes: 26340
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#define MOD 1000000007LL
using namespace std;

int main(){
	string s;
	cin >> s;
	int Sn = 0, Tn = 0;
	int max = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'S') Sn++;
		else Tn++;
		if(Tn - Sn > max) max = (Tn - Sn);
	}
	cout << 2 * max << endl;
	return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1 << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;
struct range {
	int l, r, c;
	range(int l = 0, int r = 0, int c = 0) : l(l), r(r), c(c) {}
	bool operator<(const range &rhs) const {
		return l < rhs.l;
	}
};
bool cmp(const range &r1, const range &r2) {
	if (r1.c != r2.c)
		return r1.c < r2.c;
	else
		return r1.l < r2.l;
}
int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	int C;
	cin >> C;
	vector< range > R(N);
	rep(i, N) cin >> R[i].l >> R[i].r >> R[i].c;
	sort(R.begin(), R.end(), cmp);
	vector< range > R2;
	range tmp = R[0];
	for (int i = 1; i < N; i++) {
		if (tmp.c == R[i].c && tmp.r == R[i].l) {
			tmp.r = R[i].r;
		} else {
			R2.push_back(tmp);
			tmp = R[i];
		}
	}
	R2.push_back(tmp);
	sort(R2.begin(), R2.end());
	//rep(i, R2.size()) cout << R2[i].l << " " << R2[i].r << " " << R2[i].c << endl;
	vector< int > A;
	rep(i, R2.size()) {
		range r = R2[i];
		bool f = true;
		rep(j, A.size()) {
			if (A[j] < r.l) {
				f = false;
				A[j] = r.r;
				break;
			}
		}
		if (f)
			A.push_back(r.r);
	}
	cout << A.size() << endl;
	return 0;
}

Measured memory_bytes: 7156
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;

int main()
{
    int n, m;
    vector<pair<int, int>> shops;
    ll money = 0;
    int n_drink = 0;

    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        shops.push_back(make_pair(a, b));
    }

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

    for (int i = 0; i < n; i++)
    {
        for (int j = shops[i].second; j > 0; j--)
        {
            n_drink++;
            money += shops[i].first;
            if (n_drink >= m)
            {
                cout << money << endl;
                return 0;
            }
        }
    }

    return 0;
}

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

int main()
{
  int n;
  cin >> n;
  ll mp[5] = {};
  for (int i = 0; i < n; ++i)
  {
    string s;
    cin >> s;
    if (s[0] == 'M')
      mp[0]++;
    else if (s[0] == 'A')
      mp[1]++;
    else if (s[0] == 'R')
      mp[2]++;
    if (s[0] == 'C')
      mp[3]++;
    if (s[0] == 'H')
      mp[4]++;
  }
  int cnt = 0;
  for (int i = 0; i < 5; ++i)
    if (mp[i] > 0)
      cnt++;
  ll ans = 0;
  if (cnt >= 3)
  {
    for (int i = 0; i < 5; ++i)
    {
      for (int j = i + 1; j < 5; ++j)
      {
        for (int k = j + 1; k < 5; ++k)
        {
          ans += (mp[i] * mp[j] * mp[k]);
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
#if DEBUG
            Test.Run();
#else
            Solve(Console.In, Console.Out);
#endif
        }

        public static void Solve(TextReader ci, TextWriter co)
        {
            int x,y;
            ReadInts(ci, out x, out y);
            co.WriteLine(x+y/2);
            co.Flush();
        }

        public static int ReadInt(TextReader ci) => int.Parse(ci.ReadLine());

        public static void ReadInts(TextReader ci, out int a, out int b)
        {
            var array = IntArrayFrom(ci.ReadLine());
            a = array[0];
            b = array[1];
        }

        public static void ReadInts(TextReader ci, out int a, out int b, out int c)
        {
            var array = IntArrayFrom(ci.ReadLine());
            a = array[0];
            b = array[1];
            c = array[2];
        }

        public static int[] IntArrayFrom(string s)
            => s.Split(' ').Select(p => int.Parse(p)).ToArray();

    }

}


Measured memory_bytes: 13396
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
int main(void){

	int ah,am,as,ah2,am2,as2;
	int bh,bm,bs,bh2,bm2,bs2;
	int ch,cm,cs,ch2,cm2,cs2;
	cin >> ah;
	cin >> am;
	cin >> as;
    cin >> ah2;
	cin >> am2;
	cin >> as2;
	as+=ah*3600;
	as+=am*60;
	as2+=ah2*3600;
	as2+=am2*60;
	as=as2-as;
	ah=0,am=0;
	for(;;){
        if(as>=3600)ah++,as-=3600;
        else if(as>=60)am++,as-=60;
        else break;
	}
	cin >> bh;
	cin >> bm;
	cin >> bs;
    cin >> bh2;
	cin >> bm2;
	cin >> bs2;
	bs+=bh*3600;
	bs+=bm*60;
	bs2+=bh2*3600;
	bs2+=bm2*60;
	bs=bs2-bs;
	bh=0,bm=0;
	for(;;){
        if(bs>=3600)bh++,bs-=3600;
        else if(bs>=60)bm++,bs-=60;
        else break;
	}
	cin >> ch;
	cin >> cm;
	cin >> cs;
    cin >> ch2;
	cin >> cm2;
	cin >> cs2;
	cs+=ch*3600;
	cs+=cm*60;
	cs2+=ch2*3600;
	cs2+=cm2*60;
	cs=cs2-cs;
	ch=0,cm=0;
	for(;;){
        if(cs>=3600)ch++,cs-=3600;
        else if(cs>=60)cm++,cs-=60;
        else break;
	}
	cout<<ah<<" "<<am<<" "<<as<<endl;
    cout<<bh<<" "<<bm<<" "<<bs<<endl;
    cout<<ch<<" "<<cm<<" "<<cs<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12

int main(void)
{
  string str;
  cin >> str;

  bool n = false, w = false, s = false, e = false;
  REP(i, str.size()) {
    if(str[i] == 'N') n = true;
    else if(str[i] == 'W') w = true;
    else if(str[i] == 'S') s = true;
    else if(str[i] == 'E') e = true;
    if(n && w && s && e) break;
  }

  /*if(n) cout << "N" << " ";
  if(w) cout << "W" << " ";
  if(s) cout << "S" << " ";
  if(e) cout << "E ";
  cout << endl;*/
  if(n == s && w == e) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
        int a,b,c;
        int max,mid,min;
        scanf("%d %d %d", &a, &b, &c);

        if(a < b)
        {
                min = a;
                max = b;
        }
        else
        {
                min = b;
                max = a;
        }
        if(c < min)
        {
                mid = min;
                min = c;
        }
        else
        {
                if(max < c)
                {
                        mid = max;
                        max = c;
                }
                else
                {
                        mid = c;
                }
        }

        printf("%d %d %d\n", min, mid, max);
        return 0;
}

Measured memory_bytes: 596
#define _CRT_SECURE_NO_WARNINGS
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <map>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <unordered_set>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define FILL(A,val) memset(A,val,sizeof(A))
#define ITER(it,a) for(__typeof(a.begin()) it=a.begin();it!=a.end();++it)
#define DBG1(a) cerr<<#a<<"="<<(a)<<"\n"
#define DBG2(a,b) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"

#define ALL(V) V.begin(),V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
#define y1 frgrwegreg

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;

const double PI = acos(-1.0);
const int MOD = 1000 * 1000 * 1000 + 7;
const int MAX = 131072;

int n;
int a[200000];
int ans = 0;

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	//ios::sync_with_stdio(0);

	cin >> n;
	FOR (i,0,n) cin >> a[i];
	FOR (i,0,n)
	if (a[a[i]-1]-1 == i) ans ++;
	cout << ans/2;

	return 0;
}


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

const int maxn = 105;
int n, W;
int full[4];
int w[maxn], v[maxn];
vector <int> vec[4];

bool cmp(int a, int b) {
	return v[a] > v[b];
}

int main() {
	scanf("%d%d", &n, &W);
	for (int i = 0; i < n; i ++) {
		scanf("%d%d", &w[i], &v[i]);
	}
	for (int i = 0; i < n; i ++) {
		vec[w[i] - w[0]].push_back(i);
	}
	for (int i = 0; i < 4; i ++) {
		sort(vec[i].begin(), vec[i].end(), cmp);
		for (int j = 0; j < (int) vec[i].size(); j ++) {
			full[i] += v[vec[i][j]];
		}
	}
	int ans = 0;
	int nw = 0;
	long long nwwei = 0;
	for (int i = 0; i <= (int) vec[0].size(); i ++) {
		for (int j = 0; j <= (int) vec[1].size(); j ++) {
			for (int k = 0; k <= (int) vec[2].size(); k ++) {
				for (int l = 0; l <= (int) vec[3].size(); l ++) {
					nwwei = nw = 0;
					for (int c = 0; c < i; c ++) nwwei += w[vec[0][c]], nw += v[vec[0][c]];
					for (int c = 0; c < j; c ++) nwwei += w[vec[1][c]], nw += v[vec[1][c]];
					for (int c = 0; c < k; c ++) nwwei += w[vec[2][c]], nw += v[vec[2][c]];
					for (int c = 0; c < l; c ++) nwwei += w[vec[3][c]], nw += v[vec[3][c]];
					if (nwwei <= W && nw > ans) ans = nw;
				}
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
import sys
import math
import os

input = sys.stdin.readline

a,b,x = (int(x) for x in input().split())

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


Measured memory_bytes: 3060
#include <iostream>
#include <complex>
using namespace std;
int N;
int A[50];
int h;
int main(void) {
	cin >> N;
	for (int n = 0; n < N; ++n) {
		cin >> A[n];
		if (abs(A[n]) > abs(A[h])) h = n;
	}
	cout << 2 * N - 1 << endl;
	for (int i = 0; i < N; ++i) cout << h + 1 << " " << i + 1 << endl;
	if (A[h] > 0) {
		for (int i = 0; i < N - 1; ++i) cout << i + 1 << " " << i + 2 << endl;
	}
	else {
		for (int i = N; i > 1; --i) cout << i << " " << i - 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtcoderC
{
    class Program
    {
        /*static void Main(string[] args)
        {
        }*/
        //ABC132C
        //全探索法
        /*static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int min = input.Min();
            int max = input.Max();
            int countARC = 0;
            int countABC = 0;
            int Answer = 0;
            for (int i = min; i <= max; i++)
            {
                countABC = 0;
                countARC = 0;
                foreach (int n in input)
                {
                    if (n > i)
                    {
                        countARC++;
                    }
                    else
                    {
                        countABC++;
                    }
                }
                if (countABC == countARC)
                {
                    Answer++;
                }
            }
            Console.WriteLine(Answer);
        }*/
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(input);
            int min = input[(N / 2) - 1];
            int max = input[N / 2];
            Console.WriteLine(max - min);
        }
    }
}


Measured memory_bytes: 20064
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <map>
#include <vector>
#include <set>
#include <algorithm>
#include <sstream>
#include <queue>
#include <cctype>
#include <cmath>
#include <fstream>

using namespace std;

typedef long long ll;
#define REP(i,k) for(int (i)=0;(i)<(k);(i)++)
#define INF ~(1<<31)
#define CLR(a) memset((a),0,sizeof((a)))
#define EPS 1e-9
#define DBG 1
#define D(s,v) if(DBG) cout<<(s)<<": "<<(v)<<endl;
#define DVEC(s,v) if(DBG) {cout<<(s)<<": "; for(int i=0;i<(v).size();i++) cout<<(v)[i]<<" "; cout<<endl;}
#define DARR(s,v,n) if(DBG) {cout<<(s)<<": "; for(int i=0;i<n;i++) cout<<(v)[i]<<" "; cout<<endl;}

int main(){
    ios_base::sync_with_stdio(0);
    string s;
    while(getline(cin,s)){
        cout<<"2018/01/"<<s.substr(8)<<endl;
    }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def io_generator():
	return input()

#+++++++++++++++++++

def main(io):
	a,b,c= map(int, io().split())
	ret='No'
	if a>0 and a==b and b==c:
		ret='Yes'
	return ret

#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	print (main(io))

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

using namespace std;

bool comp(tuple<int, string, int> t1, tuple<int, string, int> t2) {
    if (get<1>(t1) < get<1>(t2)) {
        return true;
    }
    else if (get<1>(t1) == get<1>(t2) && get<2>(t1) > get<2>(t2)) {
        return true;
    }
    else {
        return false;
    }
}

int main() {
	int n, score; 
	string name;
	vector<tuple<int, string, int>> r;
	cin >> n;
	for (int id = 0 ; id < n; ++id){
		cin >> name >> score;
		r.emplace_back(make_tuple(id + 1, name, score));
	}
	sort(r.begin(), r.end(), comp);
	for (int i = 0; i < n; ++i)
		cout << get<0>(r[i]) << '\n';
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll a,b,c;
  	ci(a>>b>>c);
  if(b-a==c-b) co("YES")
    else co("NO")
    }

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        s: chars,
    }
    let mut ans = 0;
    for i in 2..n {
        if s[i - 2] == 'A' && s[i - 1] == 'B' && s[i] == 'C' {
            ans += 1;
        }
    }

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

Measured memory_bytes: 4352
#include<iostream>

using namespace std;

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

Measured memory_bytes: 256
//Vatsal Gupta
#ifdef __APPLE__
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <cctype>
#include <stack>
#include <list>
#include <queue>
#include <map>
#include <sstream>
#include <cmath>
#include <limits>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>
#else
#include<bits/stdc++.h>
#endif

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define lli long long int
#define ulli unsigned long long int

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define ALL(a) a.begin(),a.end()
#define SZ(a) (int)(a.size())

#define loop(i,a,b) for(int i=a; i<b; i++)

int gcd(int a, int b) {return b==0?a:gcd(b,a%b);}
int lcm(int a, int b) {return a*(b/gcd(a,b));}

#define INF 1000000000  //(10^9)
#define MOD 1000000007  //(10^9+7)

//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);

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

	string s;
	cin>> s;
	int changes=0, win=-1;
	loop(i,1,s.length()-1)
	{
		if(s[i-1]!=s[i+1])
			changes++;
	}
	if(changes==0)
		win= 2;
	else
	{
		int x;
		x= s.length()-2;
		if(s[0]!=s[s.length()-1])
		{
			if(x%2==0)
				win= 2;
			else
				win= 1;
		}
		else 
		{
			x= x-1;
			if(x%2==0)
				win= 2;
			else
				win= 1;
		}
	}

	if(win==1)
		cout<< "First\n";
	else
		cout<< "Second\n";


	return 0;
}


Measured memory_bytes: 640
// 23/01/20 // 11:34 AM //

#include <bits/stdc++.h>

using namespace std;

const int MAXN = (int)(3e3)+2;

int n;
double p, memo[2][MAXN];

int main(){

    cin >> n;

    for(int i=0; i<=n; i++){
        if(i>0)
            cin >> p;
        for(int j=0; j<=n; j++){
            if(i==0){
                if(2*(n-j)<n) memo[0][j] = 0;
                else memo[0][j] = 1;
            }
            else
                memo[i&1][j] = p*memo[~i&1][j-1] + (1-p)*memo[~i&1][j];
        }
    }


    cout.precision(10);
    cout.setf(ios::fixed);
    cout << memo[n&1][n]<< endl;

    return 0;
}



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

#ifdef DEBUG
#define debug(x) cout << #x << ": " << x << endl
#else
#define debug(x)
#endif

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPS(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()

#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;

const ll INF = 1e18;
const ll MOD = 1e9+7;

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


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    ll N, M, X; cin >> N >> M >> X;
    vl C(N);
    vector<vl> A(N, vl(M));
    REP(i, N)
    {
        cin >> C[i];
        REP(j, M) cin >> A[i][j];
    }

    ll ans = INF;

    for(int i = 0; i < (1 << 12); i++)
    {
        vl sum(M);
        ll cost = 0;
        REP(j, N)
        {
            if(i & (1 << j))
            {
                cost += C[j];
                REP(k, M) sum[k] += A[j][k];
            }
        }
        if(*min_element(ALL(sum)) >= X)
        {
            chmin(ans, cost);
        }
    }
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int maxSum(int arr[], int n)
{
    int sum = 0;

    sort(arr, arr + n);
    for (int i = 0; i < n/2; i++)
    {
        sum -= (2 * arr[i]);
        sum += (2 * arr[n - i - 1]);
    }

    return sum;
}

int main()
 {
 int n;
 cin>>n;
 ll a[2*100000];
 for(int i=0;i<n;i++)
 {
     cin>>a[i];
 }
sort(a,a+n);
int l=a[n-1]; //left
int r=l;             // right
int i=0,j=n-2;
long long int sum=0;
while(i<j){
        int li=abs(l-a[i]),ri=abs(r-a[i]);
        int lj=abs(l-a[j]),rj=abs(r-a[j]);
        if(li>ri||lj>rj){ //left side
                if(li>lj){
                        sum+=li;
                        l=a[i++];
                }else{
                        sum+=lj;
                        l=a[j--];
                }
        }else{
                if(ri>rj){
                        sum+=ri;
                        r=a[i++];
                }else{
                        sum+=rj;
                        r=a[j--];
                }
        }
        //cout<<l<<"---"<<r<<"------"<<i<<"---"<<j<<"----------"<<sum<<endl;
}
sum+=max(abs(l-a[i]),abs(r-a[i]));
cout<<sum<<endl;

}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 2010


int main() {
	char a[N][N];
	char b[N][N];
	int c[N][N];
	f(i, N) {
		f(j, N) {
			a[i][j] = 0;
			b[i][j] = 0;
			c[i][j] = 0;
		}
	}
	queue<int>q;
	int n, m;
	int x, y, z;
	int s, ans;
	bool v = true;
	scanf("%d %d", &n, &m);
	f(i,n)scanf("%s", b[i]);
	f(i, m+2) {
		a[0][i] = '#';
		a[n + 1][i] = '#';
	}
	f(i, n) {
		a[i + 1][0] = '#';
		a[i + 1][m + 1] = '#';
		f(j, m)a[i + 1][j + 1] = b[i][j];
	}
	for (int i = 1; i <= n; i++) {
		f(j, m + 2) {
			if (a[i][j] == '.') {
				y++;
				q.push(j);
			}
			else {
				while (!q.empty()) {
					x = q.front();
					c[i][x] += y;
					q.pop();
				}
				y = 0;
			}
		}
	}
	for (int i = 1; i <= m; i++) {
		f(j, n + 2) {
			if (a[j][i] == '.') {
				y++;
				q.push(j);
			}
			else {
				while (!q.empty()) {
					x = q.front();
					c[x][i] += y;
					q.pop();
				}
				y = 0;
			}
		}
	}
	ans = 0;
	f(i, n + 2) {
		f(j, m + 2) {
			ans = max(ans, c[i][j]);
		}
	}

	printf("%d\n", ans-1);


	return 0;
}

Measured memory_bytes: 24064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>
#include <map>
#include<cmath>
#include<queue>

typedef long long ll;
using namespace std;
#define mod 10007
int f(int n, int k){
	if(n==1) return 0;
	return (f(n-1,k)+k)%n;
}

int main(){
	while(1){
		int n,k,m;
    cin >> n >> k >> m;
		if(n==0) return 0;
		cout << (f(n-1,k)+m)%n+1 << endl;
	}
}



Measured memory_bytes: 3320
#include<bits/stdc++.h>
using namespace std;
int a,b;
int Digit(int num){
    int cnt=0;
    while(num>0){cnt++;num/=10;}
    return cnt;
}
int main(){
    while(cin>>a>>b){
        cout<<Digit(a+b)<<endl;
    }
}



Measured memory_bytes: 3100
use proconio::{fastout, input};

const M: usize = 1e+9 as usize + 1;
// const M: usize = 99;

#[derive(Debug, Clone)]
struct Node {
    a: usize,
    v: usize,
    ns: Vec<usize>,
}

// 二分探索（配列は昇順にソートされているものとする）
fn bisect<T: PartialOrd>(a: &mut [T], v: T, lo: usize, hi: usize) -> usize {
    if hi - lo < 2 {
        if v > a[lo] {
            return lo + 1;
        } else {
            return lo;
        }
    } else {
        let m = (lo + hi) / 2;

        if v <= a[m] {
            return bisect(a, v, lo, m);
        } else {
            return bisect(a, v, m, hi);
        }
    }
}

fn dfs(nodes: &mut [Node], idx: usize, lines: &mut [usize]) {
    let i = bisect(lines, nodes[idx].a, 0, lines.len());
    let v = lines[i];

    lines[i] = nodes[idx].a;
    nodes[idx].v = bisect(lines, M, 0, lines.len()) - 1;

    for n in nodes[idx].ns.clone().iter() {
        if nodes[*n].v != 0 {
            continue;
        }

        dfs(nodes, *n, lines);
    }

    lines[i] = v;
}

#[fastout]
fn main() {
    input! {in_n: usize, in_a: [usize; in_n], in_v: [[usize; 2]; in_n - 1]};
    let mut nodes = Vec::with_capacity(in_n);
    let mut lines = vec![M; in_n + 1];

    for a in in_a.iter() {
        nodes.push(Node {
            a: *a,
            v: 0,
            ns: vec![],
        })
    }

    for v in in_v.iter() {
        nodes[v[0] - 1].ns.push(v[1] - 1);
        nodes[v[1] - 1].ns.push(v[0] - 1);
    }

    lines[0] = 0;

    dfs(&mut nodes, 0, &mut lines);

    for n in nodes.iter() {
        println!("{}", n.v);
    }
}


Measured memory_bytes: 59180
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <iterator>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define SI size()
#define VE vector<int>
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define LL long long
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
  LL N;
  LL A[100000];
  cin>>N;
  FOR(i,0,N){
    cin>>A[i];
  }
  sort(A,A+N,greater<int>());
  LL B[100001];
  B[N]=0;
  ROF(i,0,N){
    B[i]=B[i+1]+A[i];
  }
  LL ans=1;
  LL now=1;
  while(now<N){
    if(A[now-1]<=2*(B[now])){
      ans++;
      now++;
    }else{
      break;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;cin>>s;
    if (s=="SUN")
    {
        cout << 7 << endl;
    }
    else if (s=="MON")
    {
        cout << 6 << endl;
    }
    else if (s=="TUE")
    {
        cout << 5 << endl;
    }
    else if (s=="WED")
    {
        cout << 4 << endl;
    }
    else if (s=="THU")
    {
        cout << 3 << endl;
    }
    else if (s=="FRI")
    {
        cout << 2 << endl;
    }
    else if (s=="SAT")
    {
        cout << 1 << endl;
    }
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using std::cout ;
using std::endl ;
using std::cin ;
using std::string ;
using std::vector ;
using std::pair ;
#define rep(i,n) for(int i=0, i##_end=(n); i<i##_end; i++)
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
template<class T>bool updatemMax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool updateMin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif


int main()
{
    int N;
    cin >> N;
    
    vector<int> A(N, 0);
    
    rep(i, N-1) {
        int j;
        cin >> j;
        A[j-1]++;
    }
    
    rep(i, N) {
        cout << A[i] << endl;
    }
    return 0;
}


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

int main() {
    vector<vector<int>> A(3, vector<int>(3));
    rep(i, 3) rep(j, 3) cin >> A[i][j];
    int N; cin >> N;
    set<int> st;
    rep(i, N) {
        int b; cin >> b;
        st.insert(b);
    }
    auto bingo = [&](int a, int b, int c) -> bool {
        return st.count(a) && st.count(b) && st.count(c);
    };
    bool ok = false;
    rep(i, 3) {
        ok |= bingo(A[i][0], A[i][1], A[i][2]);
        ok |= bingo(A[0][i], A[1][i], A[2][i]);
    }
    ok |= bingo(A[0][0], A[1][1], A[2][2]);
    ok |= bingo(A[0][2], A[1][1], A[2][0]);
    cout << (ok ? "Yes" : "No") << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int x = 0,y = 0,blank;

  scanf("%d%d",&x,&y);
  if(x >= y){
    while(y != 0){
      blank = y;
      y = x % y;
      x = blank;
    }
    printf("%d\n",x);
  }

  if(y >= x){
    while(x != 0){
      blank = x;
      x = y % x;
      y = blank;
    }
    printf("%d\n",y);
  }

  return 0;
}

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

using namespace std;

typedef long long int lli;

int main() {
    int n, a;
    string s;
    pair<string, pair<int, int>> pr[100];

    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> s >> a;
        pr[i] = make_pair(s, make_pair(-a, i+1));
    }

    sort(pr, pr+n);

    for (int i=0; i<n; i++) {
        cout << pr[i].second.second << endl;
    }

    return 0;
}


Measured memory_bytes: 256