akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int n,c[210];
int G[210][210];
int d[210][210];
bool bi=true;

void dfs(int s){
    //cout << s << endl;
    rep(i,n){
        if(i==s) continue;
        if(G[s][i]==0) continue;
        if(c[i]==c[s]){
            bi=false;
            return;
        }
        if(c[i]==-1){
            c[i]=1-c[s];
            dfs(i);
        }
    }
}

void solve(){
    cin >> n;
    rep(i,n){
        string s;
        c[i]=-1;
        cin >> s;
        rep(j,n){
            d[i][j]=mod;
            if(s[j]=='1') {
                G[i][j]=1;
                d[i][j]=1;
            }
        }
    }
    c[0]=1;
    rep(i,n){
        d[i][i]=0;
    }
    rep(k,n){
        rep(i,n){
            rep(j,n){
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    dfs(0);
    if(!bi){
        cout << -1 << endl;
        return;
    }
    int ans=0;
    rep(i,n){
        rep(j,n){
            ans=max(ans,d[i][j]);
        }
    }
    cout << ans+1 << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();									// N角形
		List<Integer> lengthList = new ArrayList<>(); 			// 辺の長さを入れる配列

		/* データ入力 */
		for (int i = 0; i < N ; i++) {
			lengthList.add(scan.nextInt());
		}

		int sum = lengthList.stream().mapToInt(i -> i).sum();
		int max = Collections.max(lengthList);

		System.out.println(max < sum - max ? "Yes" : "No");
		scan.close();
	}

}

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

#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,a,b)     for(int i=b;i>=a;i--)

int a,b,c;
set<int> s;
int main()
{
    cin>>a>>b>>c;
    s.insert(a),s.insert(b),s.insert(c);
    cout<<s.size();
}




Measured memory_bytes: 256
import io
import sys


def IN_S():
  return input()


def IN_I():
  return int(input())


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


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


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


test_str = '''
5 2
'''


def MAIN():
  # T_IN()
  A()


def A():
  n, l = IN_L_I()
  li = list([ i + l for i in range(0,  n)])
  if li.count(0) == 0:
    j = li.pop(0)
    k = li.pop(-1)
    if abs(j) < abs(k):
      li.append(k)
    else:
      li.append(j)

  print(sum(li))

  return None
 

def B():
  return None


def C():
  return None


MAIN()


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

#define PI 3.1415926535
#define MOD 1000000007
#define pb push_back
#define mp make_pair
//#define f first
//#define s second
#define FOR(i,x,y) for(int i=x;i<y;i++)
#define fill(a)  memset(a, 0, sizeof (a))
#define in(n) scanf("%d",&n)
#define out(n) printf("%d\n",n)
#define SORT(v)  sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define MAX(v) *max_element(v.begin(), v.end())
#define MIN(v) *min_element(v.begin(), v.end())
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define watch(x) cout << (#x) << " is " << (x) << endl;
const long long int MAXX = 15e6;
const long long int MINN = 1e2;
const long long int inf = 1e7;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef pair<ll,ii> iii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector< iii > viii;


ll lcm(ll a, ll b) {
   return a / __gcd(a, b) * b;
}
int XOR(int x, int y){
  return (x | y) & (~x | ~y);
}
bool cmp(const pair<int,int> &a,const pair<int,int> &b) {
    return (a.second < b.second);
}
// __builtin_popcount(x)  - Returns the number of set bits in x
const long long int N = 4e6+5;
const int MAXN = 105;
int binsearch(int lo, int hi){
	while(lo<hi){
		int mid=(lo+hi)/2;
		if((mid))   // check(mid)
			hi=mid;
		else
			lo=mid+1;
	}
	return lo;
}
ll power(ll x,ll y){
    ll res=1;
    while(y>0){
      if(y&1) res=(res*x)%MOD;

      y/=2;
      x=(x*x)%MOD;
    }
    return res%MOD;
}
vii v;
map<ii,int> m;
int main(){
      FAST
      int n,i,j;
      cin>>n;
      int x[n],y[n];
      for(i=0;i<n;i++)
     { cin>>x[i]>>y[i]; v.pb({x[i],y[i]});}
     sort(v.begin(),v.end());
      int ans=0;
      for(i=0;i<n;i++){
          x[i]=v[i].first;
          y[i]=v[i].second;
          for(j=i+1;j<n;j++){
              x[j]=v[j].first;
              y[j]=v[j].second;
              m[{x[j]-x[i],y[j]-y[i]}]++;
              ans= max(ans,m[{x[j]-x[i],y[j]-y[i]}]);
          }
      }
      cout<<n-ans;
      return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <stack>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;
const ll INF = 100100100100100100;

ll H,W;
ll s_x,s_y,t_x,t_y;
string s[110];
struct edge{ ll to,cap,rev;};
vector<edge> G[20100];//to,rev
bool used[20100];

void add_edge(ll from,ll to,ll cost){
  edge tmp;
  tmp.to = to;
  tmp.cap = cost;
  tmp.rev=G[to].size();
  G[from].push_back(tmp);
  tmp.to = from;
  tmp.cap = 0;
  tmp.rev=G[from].size() -1;
  G[to].push_back(tmp);
}

ll dfs(ll v,ll t ,ll f){
  if(v == t) return f;
  used[v] = true;
  for(int i=0;i<G[v].size();i++){
    edge &e = G[v][i];
    if(!used[e.to] && e.cap > 0){
      ll d = dfs(e.to,t,min(f,e.cap));
      if(d > 0){
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}
ll max_flow(ll s, ll t){
  ll flow = 0;
  for(;;){
    rep(i,10100){
      used[i] = 0;
    }
    ll f = dfs(s,t,100100100100100100);
    if(f == 0) return flow;
    flow += f;
  }
}

int main(){
  cin >> H >> W;
  rep(i,H){
    cin >> s[i];
    rep(j,W){
      if(s[i][j] == 'S'){
        s_x = j;
        s_y = i;
      }
      else if(s[i][j] == 'T'){
        t_x = j;
        t_y = i;
      }
    }
  }
  if(s_x == t_x || s_y == t_y){
    cout << "-1" << endl;
    return 0;
  }
  rep(i,H){
    rep(j,W){
      if(s[i][j] != '.'){
        if(s[i][j] == 'S'){
          add_edge(10000,i,INF);
          add_edge(10000,j+1000,INF);
        }
        else if(s[i][j] == 'T'){
          add_edge(i,10001,INF);
          add_edge(j+1000,10001,INF);
        }
        else{
          add_edge(i,j+1000,1);
          add_edge(j+1000,i,1);
        }
      }
    }
  }
  cout << max_flow(10000,10001) << endl;
}


Measured memory_bytes: 2048
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    A, B, C, D = map(int, input().split())
    print('Yes'if (	abs(A - B) <= D and abs(B - C) <= D)
          or abs(A - C) <= D else 'No')


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
using Graph = vector<vector<int>>;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}

bool isgood(vector<ll> vec){
  int n = SZ(vec) ;
  int gc = vec[0] ;
  REP(i,n){
    gc = gcd(gc,vec[i]) ;
  }
  REP(i,n){
    if(vec[i]/gc%2==0){
      return true ;
    }
  }
  return false ;
}

    


//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, m ;
  cin >> n >> m ;
  vector<ll> num(n) ;
  REP(i,n){
    cin >> num[i] ;
  } 
  if(isgood(num)){
    cout << 0 <<endl ;
  }
  else{
    int lc = num[0] ;
    REP(i,n){
      lc = lcm(lc,num[i]) ;
      if(lc/2>m){
        cout << 0 <<endl ;
        return 0 ;
      }
    }
    cout << (m+lc/2)/lc <<endl ;
  }
    
 
    
  return 0 ;
}

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

int main()
{
    int N, K, sum;

    std::cin >> N >> K;

    int arr[N];

    for(int i=0; i<N; i++)
        std::cin >> arr[i];

    std::sort(arr, arr+N);

    sum = 0;
    for(int i=0; i<K; i++)
        sum += arr[i];

    std::cout << sum << std::endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
	ll N;
	cin>>N;
	vector<ll> W(N);
	for(ll i=0;i<N;i++) cin>>W[i];
	ll S1=0,S2=0;
	ll sum=0;
	ll T=1;
	ll minn=34872847394;
	while(N!=T){
		for(ll i=0;i<N;i++){
			if(T>i)
				S1+=W[i];
			else
				S2+=W[i];
		}
		minn=min(minn,abs(S1-S2));
		S1=0;
		S2=0;
		T++;
	}
	cout<<minn<<endl;
}

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

int main() {
  int a, b;
  cin >> a >> b;

  if (a == b) cout << 0 << endl;
  else if ((a+b) % 2 == 0) cout << (a+b)/2 << endl;
  else cout << "IMPOSSIBLE" << endl;
}


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


int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    const ll p = 1000000007;
    ll ans = 0;
    ll b = a.at(0)%p;
    for (int i = 1; i < n; i++) {
        ans += (a.at(i)%p) * (b%p);
        ans %= p;
        b += a.at(i) % p;
        b %= p;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4820
#include <stdio.h>
#include <memory.h>
#define S 0
#define H 1
#define C 2
#define D 3

int main(void) {
	int i, j, size, num;
	char c;
	char FIG[] = {'S', 'H', 'C', 'D'};
	int card[4];
	memset((char*)card, 0x00, sizeof(card));
	
	scanf("%d\n", &size);
	for(i=0;i<size;i++) {
		scanf("%c %d\n", &c, &num);
		switch(c) {
			case 'S':
				card[S] |= 1 << num;
			break;
			case 'H':
				card[H] |= 1 << num;
			break;
			case 'C':
				card[C] |= 1 << num;
			break;
			case 'D':
				card[D] |= 1 << num;
			break;
		}
	}
	
	for(i=0;i<4;i++) {
		for(j=1;j<=13;j++) {
			if((card[i] & (1 << j)) == 0) {
				printf("%c %d\n", FIG[i], j);
			}
		}
	}

	return 0;
}

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

int month_day[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main(){
    int m, d;
    int day;

    while(1){
        day = 0;
        cin >> m >> d;
        if(m == 0 && d == 0) break;

        for(int i=1; i<m; i++){
            day += month_day[i-1];
        }
        day += d;

        switch(day % 7){
            case 0:
                cout << "Wednesday" << endl;
                break;
            case 1:
                cout << "Thursday" << endl;
                break;
            case 2:
                cout << "Friday" << endl;
                break;
            case 3:
                cout << "Saturday" << endl;
                break;
            case 4:
                cout << "Sunday" << endl;
                break;
            case 5:
                cout << "Monday" << endl;
                break;
            case 6:
                cout << "Tuesday" << endl;
                break;
        }
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll h,w,n,k;

int main(){
	cin>>h>>w>>n>>k;
	ll res=0,t=1,cnt=0;
	for(int i=0;i<h;i++) for(int j=0;j<w;j++){
		cout<<"? "<<i<<' '<<j<<' '<<i<<' '<<j<<endl;
		int x;
		cin>>x;
		if(x==1) (res+=t)%=k;
		(t*=2)%=k;
		cnt+=x;
		if(cnt==n) break;
	}
	cout<<"! "<<res<<endl;
}

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

int main(){
    int n;
    cin >> n;
    int l[200];
    int ans=0;
    for(int i=0;i<2*n;i++)cin >>l[i];
    sort(l,l+2*n);
    for(int i=0;i<2*n;i+=2)ans+=l[i];
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	static Scanner s=new Scanner(System.in);
	static int gInt(){return Integer.parseInt(s.next());}
	public static void main(String[]$){
		long[]l=new long[87];
		l[0]=2;
		l[1]=1;
		for(int i=2;i<87;++i)
			l[i]=l[i-1]+l[i-2];
		System.out.println(l[gInt()]);
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

void solve()
{
    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    ll t=x/d;
    if(k<=t)
    {
        ll ans=x-k*d;
        cout<<ans<<endl;
    }
    else
    {
        k=k-t;
        ll ans=x-t*d;
        if(k%2==0)
        {
            cout<<ans<<endl;
        }
        else
        {
            ans=abs(ans-d);
            cout<<ans<<endl;
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3648
/*
Author:
Prob:
Link:
Tag:
Comp:
*/

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

#define ll long long
#define ull unsigned long long
#define ii pair<int,int>
#define iii pair<ii, int>

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ep emplace_back
#define sz(a) (int) a.size()
#define cl(a) a.clear()

#define vi vector<int>
#define vii vector<ii>

#define FOR(x,a,b) for (int x=a;x<=b;x++)
#define FOD(x,a,b) for (int x=a;x>=b;x--)
#define REP(x,a,b) for (int x=a;x<b;x++)
#define RED(x,a,b) for (int x=a;x>b;x--)

const int MAX = 1e6 + 10;
const int MAXN = 1e6 + 10;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double pi = acos(-1.0);
const double eps = 1e-6;

int main(){
	// freopen("test.in", "rt", stdin);
	ios::sync_with_stdio(false);

	int n, a, b, na = 0, nb = 0;
	string s;

	cin >> n >> a >> b;
	cin >> s;
	REP(i,0,n)
		if (s[i] == 'c')
			cout << "No\n";
		else{
			// cout << (na + nb < a + b) << " " << char(s[i]) << "\n";
			if (s[i] == 'a'){
				if (na + nb < a + b){
					cout << "Yes\n";
					na++;
				}
				else
					cout << "No\n";
			}
			else{
				if (na + nb < a+b && nb < b){
					cout << "Yes\n";
					nb++;
				}
				else
					cout << "No\n";
			}
		}

	return 0;
}

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

int H, W, N;
vector<int> a;
int B[111][111];

signed main() {
   //  入力
   cin >> H >> W >> N;
   a.resize(N);
   for (int i = 0; i < N; i++) {
      cin >> a[i];
   }

   // 列挙する数字をあらかじめ配列として用意しておく
   vector<int> v;
   for (int i = 0; i < a.size(); i++) {
      for (int j = 0; j < a[i]; j++) {
         v.push_back(i+1);
      }
   }
   // 念のためソートする
   sort(v.begin(), v.end());

   int idx = 0;
   for (int yi = 0; yi < H; yi++) {
      // 偶数なら右へ、奇数なら左へ進む
      if (yi % 2 == 0) {
         for (int xi = 0; xi < W; xi++) {
            B[yi][xi] = v[idx];
            idx++;
         }
      } else {
         for (int xi = W-1; xi >= 0; xi--) {
            B[yi][xi] = v[idx];
            idx++;
         }
      }
   }

   // 出力
   for (int i = 0; i < H; i++) {
      for (int j = 0; j < W-1; j++) {
         cout << B[i][j] << " ";
      }
      cout << B[i][W-1] << endl;
   }

   return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define pb push_back
#define N 100009
#define inf 1e18
int mod=1e9+7;
//int mod=998244353;
#define P pair<int,int>
#define F first
#define S second
#define ll long long
#define all(v) v.begin(),v.end()

#define ordered_set tree<P, null_type,less<P>, rb_tree_tag,tree_order_statistics_node_update> 

void solve(){
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int z=min(k,a);
	k-=z;
	if(k>0){
		int x=min(b,k);
		k-=x;
	}
	if(k>0){
		int x=min(k,c);
		z-=x;
	}
	cout<<z<<"\n";
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;//cin>>t;
	while(t--){
		solve();
	}
    return 0;
}

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

long long n;
vector<long long> sum[2], a[2], memo[2];

long long solve();
long long myabs(long long x) { return max(x, -x); }

int main() {
  cin >> n;
  a[0].resize(n);
  for(int i = 0; i < n; ++i) cin >> a[0][i];
  a[1] = a[0];
  reverse(a[1].begin(), a[1].end());
  for(int t = 0; t < 2; ++t) {
    sum[t].assign(n, a[t][0]);
    for(int i = 1; i < n; ++i)
      sum[t][i] = sum[t][i - 1] + a[t][i];
  }
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 10000000000000000;
  for(int t = 0; t < 2; ++t) {
    memo[t].assign(n, 0);
    for(int l = 1, r = 1; r < n; ++r) {
      while(r > l && myabs(sum[t][r] - 2 * sum[t][l - 1]) >
                         myabs(sum[t][r] - 2 * sum[t][l]))
        ++l;
      memo[t][r] = l;
    }
  }
  for(int i = 1; i < n - 2; ++i) {
    long long maxn = -1, minn = 1000000000000000;
    maxn = max(maxn, sum[0][i] - sum[0][memo[0][i] - 1]);
    minn = min(minn, sum[0][i] - sum[0][memo[0][i] - 1]);
    maxn = max(maxn, sum[0][memo[0][i] - 1]);
    minn = min(minn, sum[0][memo[0][i] - 1]);
    maxn = max(maxn, sum[1][n - i - 2] -
                         sum[1][memo[1][n - i - 2] - 1]);
    minn = min(minn, sum[1][n - i - 2] -
                         sum[1][memo[1][n - i - 2] - 1]);
    maxn = max(maxn, sum[1][memo[1][n - i - 2] - 1]);
    minn = min(minn, sum[1][memo[1][n - i - 2] - 1]);
    ans = min(ans, myabs(maxn - minn));
  }
  return ans;
}


Measured memory_bytes: 9600
n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [list(map(int, input().split())) for _ in range(m)]
bc.sort(key = lambda x: x[1], reverse = True)
t = 0
for b, c in bc:
  a.extend([c] * b)
  t += b
  if t > n:
    break
a.sort(reverse = True)
print(sum(a[:n]))

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  cin >> n;
  ll sq = sqrt(n);
  REP(i,sq){
    ll v = sq-i;
    if(n%v==0){
      ll xd = v-1;
      ll yd = n/v -1;
      cout << xd+yd << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
// sum of bitwise OR of all pairs 
#include <bits/stdc++.h> 
using namespace std; 
#define mod 1000000007
 
// Returns sum of bitwise OR 
// of all pairs 
 
long long  arr[300005];
long long n;
long long func(int p)
{
	if(p==0) return 1;
	long long ans = 1;
	for(int i = 1; i <= p; i++)
	{
		ans = ((ans%mod) * (2%mod))%mod;
	}
	return ans;
}
long long sumXOR() 
{ 
    long long int sum = 0; 
    for (int i = 0; i < 60; i++)  
    { 
        //  Count of zeros and ones 
        long long  zc = 0, oc = 0;  
          
        // Individual sum at each bit position 
        long long idsum = 0;  
        for (int j = 0; j < n; j++) 
        { 
            if (arr[j] % 2 == 0) 
                zc++; 
            else
                oc++; 
            arr[j] /= 2; 
        } 
          
        // calculating individual bit sum  
        idsum = ((oc%mod) * (zc%mod))%mod;
        idsum = ((idsum%mod)*(func(i)%mod))%mod;  
  
        // final sum     
        sum = ((sum%mod) + (idsum%mod))%mod;  
    } 
    return sum; 
} 
  
int main() 
{ 
    cin >> n;
    for(int i = 0; i < n; i++) cin >> arr[i]; 
    long long  sum = sumXOR(); 
    cout << sum << endl; 
    return 0; 
} 


Measured memory_bytes: 2560
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools



#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

A,B,C,K = map(int,input().split())
ans = 0
if(A>=K):
    ans+=K
    K=0
else:
    ans+=A
    K -= A
if(B>=K):
    K=0
else:
    K -= B
if(K != 0):
    ans -= K

print(ans)


Measured memory_bytes: 68684
#include <iostream>
using namespace std;
typedef long long ll;
ll n, x;

ll gcd(ll s, ll t, ll res){
    if (t == 0){
        return res - s;
    } else {
        res += s / t * 2 * t;
        return gcd(t, s % t, res);
    }
}

int main(void){
    // Your code here!
    cin >> n >> x;
    cout << gcd(n - x, x, n) << endl;
}


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

namespace AtTest.C_Challenge
{
    class ABC_074
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] vals = ReadInts();
            float density = 0;
            int grams = vals[0] * 100, sugars = 0;
            for (int i = 1; i <= vals[5]/100; i++)
            {
                int xTemp = -1, yTemp = -1;
                //Ax+By=iになるか判定
                for (int j = 0; j * vals[0] <= i; j++)
                {
                    if ((i - j * vals[0]) % vals[1] == 0)
                    {
                        xTemp = j;
                        yTemp = (i - j * vals[0]) / vals[1];
                        break;
                    }
                }
                if (xTemp == -1) continue;

                //最大の砂糖の量を計算
                int limit = i * vals[4];
                if (limit > vals[5] - i * 100)
                {
                    limit = vals[5] - i * 100;
                }
                int maxSugars = 0;
                int pTemp = 0, qTemp =0;
                for(int j = 0; j * vals[2] <= limit; j++)
                {
                    int sugarsTemp
                        = vals[2] * j
                        + (limit - j * vals[2]) / vals[3] * vals[3];
                    if (sugarsTemp > maxSugars)
                    {
                        pTemp = j;
                        qTemp = (limit - j * vals[2]) / vals[3];
                        maxSugars = sugarsTemp;
                    }
                }

                int gramsTemp = (vals[0] * xTemp + vals[1] * yTemp) * 100
                    + maxSugars;
                float densityTemp = 100.0f
                    * maxSugars / gramsTemp;
                if (densityTemp > density)
                {
                    sugars = maxSugars;
                    grams = gramsTemp;
                    density = densityTemp;
                }
            }
            /*Console.WriteLine(x);
            Console.WriteLine(y);
            Console.WriteLine(p);
            Console.WriteLine(q);
            Console.WriteLine(density);*/
            Console.Write(grams);
            Console.Write(" ");
            Console.Write(sugars);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11220
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c; cin >> a >> b >> c;
	if (a == b && b == c)
		cout << "No" << endl;
	else if (a == b || b == c || a == c) {
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
#define MAX 200200
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
struct Line{int v,next,col;}e[MAX<<2];
int h[MAX],cnt=1,E[MAX][2];
inline void Add(int u,int v,int col){e[cnt]=(Line){v,h[u],col};h[u]=cnt++;}
int dfn[MAX],tim,fa[MAX],dep[MAX],low[MAX],dis[MAX],X,Y,n;
bool inf[MAX],vis[MAX];
void dfs(int u,int ff)
{
	dfn[u]=++tim;fa[u]=ff;dep[u]=dep[ff]+1;
	for(int i=h[u];i;i=e[i].next)
		if(e[i].col&&e[i].v!=ff)
			dfs(e[i].v,u);
	low[u]=++tim;
}
bool check(int x,int y)
{
	if(dfn[x]>dfn[y])swap(x,y);
	if(low[x]>=low[y])return dep[y]-dep[x]>2;
	if(fa[x]==fa[y])return false;
	return true;
}
void BFS()
{
	queue<int> Q;vis[X]=true;Q.push(X);
	while(!Q.empty())
	{
		int u=Q.front();Q.pop();
		for(int i=h[u];i;i=e[i].next)
			if(!e[i].col&&!vis[e[i].v])
			{
				dis[e[i].v]=dis[u]+1;
				if(dis[e[i].v]<dep[e[i].v])
					vis[e[i].v]=true,Q.push(e[i].v);
			}
	}
}
int main()
{
	n=read();X=read();Y=read();
	for(int i=1;i<n;++i)E[i][0]=read(),E[i][1]=read();
	for(int i=1;i<n;++i)
	{
		int u=read(),v=read();
		Add(u,v,1);Add(v,u,1);
	}
	dep[0]=-1;dfs(Y,0);
	for(int i=1;i<n;++i)
	{
		int u=E[i][0],v=E[i][1];
		if(check(u,v))inf[u]=inf[v]=true;
		else Add(u,v,0),Add(v,u,0);
	}
	BFS();
	for(int i=1;i<=n;++i)if(vis[i]&&inf[i]){puts("-1");return 0;}
	int ans=0;
	for(int i=1;i<=n;++i)if(vis[i])ans=max(ans,dep[i]<<1);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 24064
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNextLine()){
			int n = Integer.parseInt(sc.nextLine());
			int count = 0;
			for(int i=0;i<10;i++){
				for(int u=0;u<10;u++){
					for(int y=0;y<10;y++){
						for(int t=0;t<10;t++){
							if(i+u+y+t == n){
								count++;
							}
						}
					}
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 18828
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<(n);i++)
const int MOD = 1e9 + 7 ;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=100005;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int n,k;
      cin>>n>>k;
      int v[n+2];
      for(int i=1;i<=n;i++)
      {
            cin>>v[i];
      }
      v[n+1]=0;
      v[0]=0;
      set <int> neg;
      int s=0;
      int cnt1=0;
      int ans=0;
      for(int i=0;i<=n;i++)
      {
            s+=v[i];
            if(i!=0)
            cnt1++;
            if(v[i]<0)
            {
                  neg.insert(v[i]);
            }
            set<int>neg1;
            int s1=0;
            int cnt2=0;
            for(int j=n+1;j>i;j--)
            {
                  s1+=v[j];
                  if(j!=n+1)
                  cnt2++;
                  if(v[j]<0)
                  {
                        neg1.insert(v[j]);
                  }
                  if(cnt1+cnt2<=k)
                  {
                        int rem=(k-(cnt1+cnt2));
                        set<int> negg;
                        for(auto x:neg)
                        {
                              negg.insert(x);
                        }
                        for(auto x:neg1)
                        {
                              negg.insert(x);
                        }  
                        int oo=0;
                        int so=0;
                        for(auto x:negg)
                        {
                              oo++;
                              if(oo>rem) break;
                              so+=abs(x);
                        }
                        //if(i==3&&j==n+1) cout<<cnt2; 
                        ans=max(ans,s+s1+so);
                  }
            }
      }
      cout<<ans;
}     


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

using namespace std;

int main(){
    char ch;
    cin >> ch;
    switch(ch){
        case 'a':
        case 'i':
        case 'u':
        case 'e':
        case 'o':
            cout << "vowel" << endl;
            break;
            
        default:
            cout << "consonant" << endl;
            break;
    }
    return 0;
}

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

if A >= K:
  ans_A = A - K
  ans_B = B
elif A + B >= K:
  ans_A = 0
  ans_B = B - (K - A)
else:
  ans_A = 0
  ans_B = 0

print(ans_A,ans_B)

Measured memory_bytes: 3060
#include<iostream>

int main() {
    unsigned long a, b, c, d, e, n;
    unsigned long cap[5];
    unsigned long cap_min;
    unsigned long total = 0;
    std::cin >> n;
    std::cin >> a;
    std::cin >> b;
    std::cin >> c;
    std::cin >> d;
    std::cin >> e;

    cap[0] = a; cap[1] = b; cap[2] = c;
    cap[3] = d; cap[4] = e;

    cap_min = cap[0];
    for(int i=1; i<5; i++) {
      if(cap[i] < cap_min) {
        cap_min = cap[i];
      }
    }

    if(n % cap_min == 0) {
      total = (n / cap_min) + 4;
    }
    else {
      total = (n / cap_min) + 1 + 4;
    }

    //std::cout << cap_min << std::endl;
    //std::cout << (cap_min / n) << std::endl;
    std::cout << total;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
    
    public class Main {
    	public static void main(String[] args){
    		Scanner sc = new Scanner(System.in);
    		// 整数の入力
    		int a = sc.nextInt();
    		String b = sc.next();
    		
    		if(a>=b.length()) {
    			System.out.println(b);
    		}else {
    			System.out.println(b.substring(0,a)+"...");
    		}
    	}
    }

Measured memory_bytes: 38476
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <vector>

#define DEBUG1  false
#define DEBUG2  false
#define DEBUG3  false
#define DEBUG4  false
#define DEBUG5  false

int cost(int x, int y)
{
#if DEBUG3
    std::cout << "DEBUG3: r: " << std::pow(x - y, 2) << " x: " << x << " y: " << y << std::endl;
#endif
    return std::pow(x - y, 2);
}

int cost(std::vector<int>& A, int y)
{
    int c = 0;
    for (auto itr = A.begin(); itr != A.end(); ++itr)
    {
        c += cost(*itr, y);
#if DEBUG4
    std::cout << "DEBUG4: c: " << c << std::endl;
#endif
    }
    return c;
}

int middle(int l, int r)
{
    return (l - r) / 2 + r;
}

int main(void)
{
    int N;
    std::cin >> N;
#if DEBUG1
    std::cout << "DEBUG1: N: " << N << std::endl;
#endif

    std::vector<int> A;
    while (N)
    {
        int a;
        std::cin >> a;
        A.push_back(a);
        N--;
    }
#if DEBUG2
    std::cout << "DEBUG2: A:";
    for (auto itr = A.begin(); itr != A.end(); ++itr)
    {
        std::cout << " " << *itr;
    }
    std::cout << std::endl;
#endif

    int L = *std::min_element(A.begin(), A.end());
    int R = *std::max_element(A.begin(), A.end());
    int M = middle(L, R);
    std::map<int, int> costs;
    costs[L] = cost(A, L);
    costs[R] = cost(A, R);
    int c = (costs[L] < costs[R] ? costs[R] : costs[L]);
    while (true)
    {
        if (!costs.count(M))
        {
            costs[M] = cost(A, M);
            if (costs[M] < c)
            {
                c = costs[M];
            }
        }
        else
        {
            break;
        }
        if (costs[L] < costs[R])
        {
            R = M;
            M = middle(L, M);
        }
        else
        {
            L = M;
            M = middle(M, R);
        }
    }
#if DEBUG5
    for (auto itr = costs.begin(); itr != costs.end(); ++itr)
    {
        std::cout << "DEBUG5: " << itr->first << " " << itr->second << std::endl;
    }
#endif
    std::cout << c << std::endl;

    return 0;
}

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

int main(){
	int i,j,in,jn,t,m,st[2360]={},flag=0;
	
	cin>>in;
	for(i=0;i<in;i++){
		cin>>t>>m;
		st[100*t+m]=1;
		}
		
	cin>>jn;
	for(j=0;j<jn;j++){
		cin>>t>>m;
		st[100*t+m]=1;
		}
	for(i=0;i<2360;i++){
		if(st[i]==1){
			if(flag==0){
			printf("%d:%02d",i/100,i%100);
			flag++;
			}else{
			printf(" %d:%02d",i/100,i%100);
			}
		}
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Mid ((l+r)/2)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define drep(i,a,b) for(int i=(a);i>=(b);--i)
#define file(a) freopen(#a".in","r",stdin),freopen(#a".out","w",stdout);
const int maxn=1e5+5,mod=1e9+7,inf=0x3f3f3f3f;
int n,m,Q,K,T;
int read(){
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}

signed main(){
    //file(a);
    n=read();
    if(n>=30)puts("Yes");
    else puts("No");


    return 0;
}


Measured memory_bytes: 3584
//If you are trying to hack me I wish you can get it, Good Luck :D.
#include <bits/stdc++.h>
using namespace std;

#define debug(args...) fprintf (stderr,args)
#define pb push_back
#define mp make_pair

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

string s;

int main() {
    cin >> s;
    int n = s.size() - 1;
    ll ans = 0;
    for (int i = 0; i < (1<<n); i++) {
        string cur = string(1, s[0]);
        ll num = 0;
        //cout << "Teste: " << cur << endl;
        for(int k = 1; k < s.size(); k++) {
            if ((1<<(k - 1)) & i) {
                num += stoll(cur);
                cur = "";
            }
            cur += s[k];            
        }        
        num += stoll(cur);
        //cout << "Num: " << num << " Cur: " << cur << '\n';
        ans += num;
    }

    cout << ans << '\n';
}


Measured memory_bytes: 256
import sys
from sys import stdin, stdout

rem = 10 ** 9 + 7
sys.setrecursionlimit(10 ** 6)
take = lambda: map(int, stdin.readline().split())

a,b,c,k=take()
if k%2==1:
    ans=b-a
else:
    ans=a-b
if abs(ans)>10**18:
    print 'Unfair'
else:
    print ans

Measured memory_bytes: 2568
#include<bits/stdc++.h>
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 W,H;
int num_fold,num_hole;
int table[70][70];

void func(){

	for(int row = 0; row < 2*H; row++){
		for(int col = 0; col < 2*W; col++){
			table[row][col] = 0;
		}
	}

	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){
			table[row][col] = 1;
		}
	}

	int work[64][64];

	int command,loc;
	int tmp_H = H,tmp_W = W;
	int left,right,top,bottom;

	for(int loop = 0; loop < num_fold; loop++){

		scanf("%d %d",&command,&loc);

		//workの初期化
		for(int row = 0; row < 2*H; row++){
			for(int col = 0; col < 2*W; col++){
				work[row][col] = 0;
			}
		}

		//tableの状態をworkに転記
		for(int row = 0; row < tmp_H; row++){
			for(int col = 0; col < tmp_W; col++){
				work[row][col] = table[row][col];
			}
		}

		if(command == 1){ //左右に折る

			for(int row = 0; row <= tmp_H-1; row++){

				for(int col = 0; col <= loc-1; col++){
					work[row][loc+((loc-1)-col)] += table[row][col];
				}
			}

			left = loc;
			right = tmp_W-1+max(0,loc-(tmp_W-loc));
			tmp_W = right-left+1;

			//workからテーブルへの転記
			for(int row = 0; row <= tmp_H-1; row++){
				for(int col = left; col <= right; col++){
					table[row][col-left] = work[row][col];
				}
			}


		}else{ //上下に折る

			for(int col = 0; col <= tmp_W-1; col++){
				for(int row = 0; row <= loc-1; row++){
					work[loc+((loc-1)-row)][col] += table[row][col];
				}
			}

			bottom = loc;
			top = tmp_H-1+max(0,loc-(tmp_H-loc));
			tmp_H = top-bottom+1;

			//workからテーブルへの転記
			for(int col = 0; col <= tmp_W-1; col++){
				for(int row = bottom; row <= top; row++){
					table[row-bottom][col] = work[row][col];
				}
			}
		}
	}

	int x,y;

	for(int loop = 0; loop < num_hole; loop++){
		scanf("%d %d",&x,&y);

		printf("%d\n",table[y][x]);
	}
}

int main(){

	while(true){
		scanf("%d %d %d %d",&W,&H,&num_fold,&num_hole);
		if(W == 0 && H == 0 && num_fold == 0 && num_hole == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

int main() {
  int N, Q;
  cin >> N >> Q;
  
  dsu uf(N);
  while (Q--) {
    int t, u, v;
    cin >> t >> u >> v;
    
    if (t) cout << uf.same(u, v) << endl;
    else uf.merge(u, v);
  }
  
  return 0;
}

Measured memory_bytes: 4036
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int N;

    scanf("%d", &N);

    int c[100002];

    for(int i = 0; i <= 100001; i++){
        c[i] = 0;
    }

    int a[N];

    for(int i = 0; i < N; i++){
        scanf("%d", &a[i]);
        c[a[i]]++;
        c[a[i]+1]++;
        c[a[i]+2]++;
    }

    int max = 0;

    for(int i = 0; i <= 100001; i++){
        if(max < c[i]){
            max = c[i];
        }
    }

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

    return 0;
}

Measured memory_bytes: 2456
a, b, h, m = list(map(int,input().split()))
r = min(abs(h*30+m*0.5-m*6), 360-abs(h*30+m*0.5-m*6))
import math
c = (a**2+b**2-2*a*b*math.cos(math.radians(r)))**0.5
print(c)

Measured memory_bytes: 9500
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <numeric>
//#include <bits/stdc++.h>

using namespace std;

typedef long long li;


struct MaxFlow {
    static const long long inf = 1LL << 60;
    struct edge {int to; long long cap; int rev;};
    int V;
    vector<vector<edge> > G;
    vector<int> level;
    vector<int> iter;

    MaxFlow (unsigned int _V): V(_V), G(_V), level(_V), iter(_V) {}

    void add_edge(int from, int to, long long cap) {
        G[from].push_back((edge){to, cap, (int) G[to].size()});
        G[to].push_back((edge){from, 0, (int) G[from].size() - 1});
    }

    void bfs(int s) {
        fill(level.begin(), level.end(), -1);
        queue<int> q;
        level[s] = 0;
        q.push(s);
        while (not q.empty()) {
            int v = q.front(); q.pop();
            for (int i = 0; i < G[v].size(); ++i) {
                edge &e = G[v][i];
                if (e.cap > 0 && level[e.to] < 0) {
                    level[e.to] = level[v] + 1;
                    q.push(e.to);
                }
            }
        }
    }

    long long dfs(int v, int t, long long f) {
        if (v == t) return f;
        for (int &i = iter[v]; i < G[v].size(); ++i) {
            edge &e = G[v][i];
            if (e.cap > 0 && level[v] < level[e.to]) {
                long long d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    long long max_flow(int s, int t) {
        long long flow = 0;
        for (;;) {
            bfs(s);
            if (level[t] < 0) {
                return flow;
            }
            fill(iter.begin(), iter.end(), 0);
            long long f;
            while ((f = dfs(s, t, inf)) > 0) {
                flow += f;
            }
        }
    }
};

int main() {
    li n;
    cin >> n;
    vector<li> a(n);
    li best_performance = 0;
    for (int k = 0; k < n; ++k) {
        cin >> a[k];
        if (a[k] > 0) {
            best_performance += a[k];
        }
    }

    MaxFlow mf(n + 2);
    const int source = n;
    const int sink = source + 1;
    for (int i = 0; i < n; ++i) {
        if (a[i] > 0) {
            mf.add_edge(i, sink, a[i]);
        } else if (a[i] < 0) {
            mf.add_edge(source, i, -a[i]);
        }
        for (int j = i + 1; j < n; ++j) {
            if ((j + 1) % (i + 1) == 0) {
                mf.add_edge(i, j, 1LL << 55);
            }
        }
    }
    cout << best_performance - mf.max_flow(source, sink) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;
struct edge { ll from; ll to; ll cost; };



int main() {
	string s;
	cin >> s;
	int k;
	cin >> k;

	string st = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";

	int cnt = 0;
	while (cnt < s.size()) {
		if (s[cnt] == 'a' && cnt != s.size()-1) { 
			cnt++;
			continue; 
		}

		if (cnt == s.size() - 1) {
			s[cnt] = st[(s[cnt]-'a')+(k%26)];
		}
		else {
			if (26 - (s[cnt] - 'a') <= k) {
				k -= 26 - (s[cnt] - 'a');
				s[cnt] = 'a';
			}
		}
		cnt++;
	}

	cout << s << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

typedef pair<long double, i_i> lii;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
int N;
long double px[300], py[300], pz[300], vx[300], vy[300], vz[300], r[300], vr[300];
long double del[300];
long double ans[300];
bool exist[300];
const long double EPS = 1e-9;
long double f(int i, int j, long double t) {
    long double dx = (px[i] + vx[i]*t) - (px[j]+vx[j]*t);
    long double dy = (py[i] + vy[i]*t) - (py[j]+vy[j]*t);
    long double dz = (pz[i] + vz[i]*t) - (pz[j]+vz[j]*t);
    long double ret = sqrt(dx*dx+dy*dy+dz*dz);
    ret += (vr[i] + vr[j])*t - (r[i] + r[j]);
    return ret;
}
void solve() {
    vector<lii> v;
    for(int i = 0; i < N; i++) {
        exist[i] = true;
        cin >> px[i] >> py[i] >> pz[i] >> vx[i] >> vy[i] >> vz[i] >> r[i] >> vr[i];
        long double t = r[i] / vr[i];
        del[i] = t;
        v.push_back({t, {i, -1}});
    }
    for(int i = 0; i < N; i++) {
        for(int j = i + 1; j < N; j++) {
            long double ub = min(del[i], del[j]);
            long double lb = 0;
            for(int _ = 0; _ <= 200; _++) {
                long double u = (2*ub+lb)/3;
                long double l = (2*lb+ub)/3;
                //cerr << l << " " << u << " " << f(i,j,l) << " " << f(i,j,u) << endl;
                if(f(i, j, u) < f(i, j, l)) lb = l;
                else ub = u;
            }
            //cerr << i << " " << j << " " << ub << " " << f(i, j, ub) << endl;
            if(f(i, j, ub) + EPS >= 0) continue;
            long double ok = lb;
            long double ng = 0;
            for(int _ = 0; _ <= 200; _++) {
                long double mid = (ok + ng) / 2;
                if(f(i, j, mid) + EPS >= 0) ng = mid;
                else ok = mid;
            }
            //cerr << i << " " << j << " " << ok << endl;
            v.push_back({ok, {i, j}});
        }
    }
    sort(v.begin(), v.end());
    for(auto tmp : v) {
        if(!exist[tmp.second.first]) continue;
        if(tmp.second.second != -1 and !exist[tmp.second.second]) continue;
        ans[tmp.second.first] = tmp.first;
        exist[tmp.second.first] = false;
        if(tmp.second.second != -1) {
            ans[tmp.second.second] = tmp.first;
            exist[tmp.second.second] = false;
        }
    }
    for(int i = 0; i < N; i++) {
        cout << fixed << setprecision(40) << ans[i] << endl;
    }
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> N) {
        if(N == 0) break;
        solve();
    }
    return 0;
}


Measured memory_bytes: 3372