akhauriyash/Code-Regression huggingface dataset:
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-11;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
long long dp[5100][5100];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	init_C(210000);
	dp[0][b]=1;
	for(int i=0;i<a;i++){
		long long tmp=0;
		for(int j=b;j>=1;j--){
			// printf("%d %d: %lld\n",i,j,dp[i][j]);
			dp[i+1][j]=(tmp*j+dp[i][j]*(j+1))%mod;
			tmp=tmp*2%mod;
			tmp=(tmp+dp[i][j])%mod;
			
		}
	}
	long long ret=0;
	for(int i=1;i<=b;i++){
		// printf("%d: %lld\n",i,dp[a][i]);
		ret+=dp[a][i];
	}
	ret%=mod;
	printf("%lld\n",ret);
}

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

using namespace std;
 
vector<int> ans;
int arr[13];
int cnt[10];
 
bool check(int a[])
{
    int sum = 0;
    for (int i = 1; i <= 9; i++) {
	sum += a[i];
    }
    if(sum == 0) return 1;
    for (int i = 3; i <= 9; i++) {
	if (a[i-2] > 0 && a[i-1] > 0 && a[i] > 0) {
	    a[i-2]--; a[i-1]--; a[i]--;
	    if (check(a)) return 1;
	    a[i-2]++; a[i-1]++; a[i]++;
	}
    }
 
    for (int i = 1; i <= 9; i++) {
	if(a[i] >= 3){
	    a[i] -= 3;
	    if(check(a)) return 1;
	    a[i] += 3;
	}
    }
    return 0;
}
 
void solve()
{
    int tmp[10];
    for (int i = 0; i < 9; i++) {
	for (int j = 0; j < 10; j++) {
	    tmp[j] = cnt[j];
	}
	if (cnt[i+1] > 3) continue;
	cnt[i+1]++;
	for (int j = 1; j <= 9; j++) {
	    if (cnt[j] >= 2) cnt[j] -= 2;
	    else {
                continue;
            }
	    if (check(cnt)) {
		ans.push_back(i+1);
		break;
	    }
	    cnt[j] += 2;
	}
	for(int j = 0 ; j < 10 ; j++){
	    cnt[j] = tmp[j];
	}
    }
}
 
int main()
{
    string str;
    while (cin >> str) {
	memset(cnt, 0, sizeof(cnt));
	for (int i = 0; i < 13; i++) {
	    arr[i] = str[i]-'0';
	    cnt[arr[i]]++;
	}
	sort(arr, arr+13);
	ans.clear();
	solve();
	int size = ans.size();
	if (!size) {
	    cout << 0 << endl;
	} else {
	    for (int i = 0; i < size; i++) {
                if (i > 0) cout << " ";
                cout << ans[i];
	    }
	    cout << endl;
	}
    } 
    return 0;
}

Measured memory_bytes: 3056
#include <cstdlib>
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 100005
#define pb push_back
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const double PI  =3.141592653589793238463;
long long MOD = 1000000007;

int stringToInteger(string x){
    int gg=0;
    //stringstream geek(x);
    //geek >> gg;
    return gg;
}

ll powmod(ll a,ll b,ll m)
{
    ll ans=1;
    while(b>0){ if(b%2)
        {ans*=a; ans%=m;}
         b/=2; a=a*a; a=a%m;
        }
        return ans%m;
}
ll gcd(ll a,ll b)
{

    return __gcd(a,b);
}
ll mulmod(ll a,ll b,ll m)
{  ll ans=0;
    a %=m;
    while (b>0)
    {       if(b&1) ans = (ans + a) % m;
        a = (a * 2)%m;
        b /= 2;
    }
    return ans % m;
}

ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a;
 while(b > 0)
 	{
 		if(b%2 == 1)
 	{
 		x=(x*y);
 		if(x>MOD) x%=MOD;
 	}
 	y = (y*y);
 	if(y>MOD) y%=MOD;
 	b /= 2;
 	}
 return x;
}
ll modInverse(ll a, ll m)
{
    a = a%m;
    for (int x=1; x<m; x++)
       if ((a*x) % m == 1)
          return x;
}
ll maxDivide(ll a, ll b)
{
  while (a%b == 0)
   a = a/b;
  return a;
}
  set<ll>ans;
void primeFactors(ll n)
{

    while (n % 2 == 0)
    {
       ans.insert(2);
        n = n/2;
    }

    for (ll i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (n % i == 0)
        {
            ans.insert(i);
            n = n/i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (n > 2)
        ans.insert(n);
}
ll is(ll no)
{   if(no==1) return 0;
    set<ll>::iterator it;
for(it=ans.begin();it!=ans.end();it++){
  no = maxDivide(no, *it);
  if(no==1) return 1;
//  if()
 // no = maxDivide(no, 3);
 // no = maxDivide(no, 5);
}
//if(no==1) return 1;
//for(it=ans.begin();it!=ans.end();it++){
//if(no==*it) return 1;
//}
  return 0;
}

int comp(string a,string b)
{
    string aa = a.append(b);
    string bb = b.append(a);

    return aa.compare(bb) > 0 ? 1: 0;

}
vector<pair<int,int> >adj[100005];
int colors[100005]={0};
void dfs(int i,int color,int prev1=-1)
{
 for(int j=0;j<adj[i].size();j++)
 {
     if(adj[i][j].first==prev1) continue;
//cout<<adj[i][j].second<<endl;
     if(adj[i][j].second&1)
     {

         colors[adj[i][j].first]=1-color;
     }
     else
         colors[adj[i][j].first]=color;
     dfs(adj[i][j].first,colors[adj[i][j].first],i);

 }
}
bool com(const pair<string,pair<int,int> >&a, const pair<string,pair<int,int> >&b )
{
    if(a.first!=b.first) return a.first<b.first;
    else return a.second.first>b.second.first;

}
int main()
{
   int n;
   cin>>n;
   vector<pair<string,pair<int,int> > >v(n);
   for(int i=0;i<n;i++)
   {

       string a; int b; cin>>a>>b;
       pair<int,int>p = make_pair(b,i+1);
       pair<string,pair<int,int> >q = make_pair(a,p);
       v[i]=q;

   }
   sort(v.begin(),v.end(),com);
   for(int i=0;i<n;i++) cout<<v[i].second.second<<endl;
}


Measured memory_bytes: 2560
import sys
readline = sys.stdin.readline
N = int(readline())
S = list(map(int, readline().strip()))

dp1 = [False]*10
dp2 = [False]*100
dp3 = [False]*1000

for s in S:
    
    for i in range(100):
        if dp2[i]:
            dp3[i*10+s] = True
    
    for i in range(10):
        if dp1[i]:
            dp2[i*10+s] = True
    
    dp1[s] = True
    
print(sum(dp3))

Measured memory_bytes: 43116
# coding: utf-8
# Your code here!

import sys
readline = sys.stdin.readline
read = sys.stdin.read


n,k,*p = [int(i) for i in read().split()]


p = [(1+i) for i in p]


m = a = sum(p[:k])
for i in range(k,n):
    a += p[i]
    a -= p[i-k]
    m = max(m,a)

print(m/2)




Measured memory_bytes: 78876
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}


int main(){
	FIO
	
	int x, y;
	for(int _ = 1;; _++){
		cin >> x >> y;
		if(x == 0 && y == 0)break;
		if(x < y)cout << x << " " << y << "\n";
		else cout << y << " " << x << "\n";
	}
	return 0;
}



Measured memory_bytes: 3136
N = int(input())
src = list(map(int, input().split()))
MAX = 10**5
 
counts = [0 for i in range(MAX+2)]
for a in src:
	a += 1
	
	counts[a-1] += 1
	counts[a] += 1
	counts[a+1] += 1
 
print(max(counts[1:-2]))

Measured memory_bytes: 13964
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <tuple>
#include <queue>
#include <string>
#include <map>
#include <utility>
const int maxn = 1e5+1;
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    int w;
    cin>>w;
    string ans;
    for(int i=0; i<s.size(); i+=w)
        ans+=s[i];
    cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N;
int main(){
  cin>>N;
if(N<10)cout<<"Yes";
else if(N<100){
  if(N%10==N/10)cout<<"Yes";
  else cout<<"No";
}
else{
  if(N%10==N/100)cout<<"Yes";
  else cout<<"No";
}
  return 0;
}

Measured memory_bytes: 256
#pragma region noncode
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#pragma endregion

int main() {
    ll n;
    cin >> n;
    n++;
    vector<ll> t(n), x(n), y(n);
    t[0] = 0;
    x[0] = 0;
    y[0] = 0;

    for(size_t i = 1; i < n; i++) {
        cin >> t[i] >> x[i] >> y[i];
    }

    bool ans = true;
    rep(i, n - 1) {
        if(t[i + 1] - t[i] < (abs(x[i] - x[i + 1]) + abs(y[i] - y[i + 1])))
            ans = false;
        if((t[i + 1] - t[i]) % 2 !=
           (abs(x[i] - x[i + 1]) + abs(y[i] - y[i + 1])) % 2)
            ans = false;
    }
    if(ans)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int n,k;
int p[200005];
int pre[1005];
int main(){
    scanf("%d %d",&n,&k);
    for(int i=0;i<n;i++) scanf("%d",&p[i]);
    for(int i=1;i<=1000;i++) pre[i]=i+1;
    ll nowsum=0;
    for(int i=0;i<k;i++) nowsum+=pre[p[i]];
    ll ans=nowsum;
    for(int i=k;i<n;i++){
        nowsum-=pre[p[i-k]];
        nowsum+=pre[p[i]];
        ans=max(ans,nowsum);
    }
    printf("%lf\n",ans/2.0);
    return 0;
}

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

typedef long long lli;
typedef vector<vector<int> > Graph;

const int MAXN = 50;

int N;
map<string,int> id;
Graph g;
int B[MAXN];

lli adj[MAXN];
int sum[MAXN];
int ans;

inline int getId(const string &s) {
  if(!id.count(s)) id[s] = id.size()-1;
  return id[s];
}

inline void addEdge(int src, int dst, Graph &g) {
  g[src].push_back(dst);
}

void rec(int k, lli bit, int now) {
  ans = max(ans, now);
  if(now + sum[k] <= ans) return;
  if(k == N) return;
  if(!(bit & (1LL<<k))) rec(k+1, bit|adj[k], now+B[k]);
  rec(k+1, bit, now);
}

int main() {
  while(cin >> N && N) {
    id.clear();
    g = Graph(N);
    for(int i = 0; i < N; ++i) {
      string src;
      int C;
      cin >> src;
      cin >> B[getId(src)] >> C;
      while(C--) {
        string dst;
        cin >> dst;
        addEdge(getId(src), getId(dst), g);
      }
    }

    for(int v = 0; v < N; ++v) {
      adj[v] = 0;//1LL<<v;
      for(int i = 0; i < g[v].size(); ++i) {
        int nv = g[v][i];
        adj[v] |= 1LL<<nv;
      }
    }

    sum[N] = 0;
    for(int v = N-1; v >= 0; --v) sum[v] = sum[v+1] + B[v];

    ans = 0;
    rec(1, adj[0], B[0]);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1260
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		int L = str.length();
		int cnt = 0;

		boolean check = true;
		
		for (int i = 0; i < L; i++) {
			if ( i == 0) {
				if(str.charAt(i) != 'A') {
					check = false;
				}
			}
			else if( 2 <= i && i <= L - 2) {
				if (str.charAt(i) == 'C') {
					cnt++;
				}
				else if( 'A'<= str.charAt(i) && str.charAt(i) <= 'Z' ) {
					check = false;
				}
			}
			else {
				if('A'<= str.charAt(i) && str.charAt(i) <= 'Z')
					check = false;
			}
	}
		if (cnt != 1) {
			check = false;
		}
		
		if(check) {
			System.out.println("AC");
		}
		else {
			System.out.println("WA");
		}
}
}


Measured memory_bytes: 22740
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, char> plc;

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

	int cnt = 0;
	rep(i, s.size()) {
		if (cnt % 2 == 0)
			cout << s[i];
		cnt++;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
 
template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
	ll a,b,x;
	cin>>a>>b>>x;

	if(a==b) 
		cout<<(a%x==0)<<endl;
	else if(a==0)
		cout<<(b/x)+1<<endl;
	else 
		cout<<(b/x)-(max(a-1,0LL)/x)<<endl;
	return 0; 
}


Measured memory_bytes: 256
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    S = input()
    h = len(S) // 2
    s1 = S[:h]
    s2 = S[h:][::-1]
    # print(s1,s2)
    ans = 0
    for i in range(h):
        if s1[i] != s2[i]:
            ans += 1
    print(ans)




if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    string S;
    ll K;
    cin >> S >> K;
    vector<pair<char, ll>> v;
    S.push_back('.');
    ll cnt = 0;
    char cur = S[0];
    for (int i = 0; i < S.size(); i++) {
        if (cur == S[i]) cnt++;
        else {
            v.push_back(make_pair(cur, cnt));
            cur = S[i];
            cnt = 1;
        }
    }

    if (v.size() == 1) { cout << (v[0].second * K) / 2 << '\n'; }
    else {
        ll ans = 0;
        for (auto p : v) ans += (p.second / 2) * K;
        pair<char, int> pl = *v.begin(), pr = *v.rbegin();
        if (pl.first == pr.first) {
            ans -= (K - 1) * (pl.second / 2 + pr.second / 2);
            ans += (K - 1) * ((pl.second + pr.second) / 2);
        }
        cout << ans << '\n';
    }
}


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

int N,a,b,u = 1;
ll A[100010],C[100010],visited[100010] = {0};
bool judge = true;
vector<vector<int>> v(100010);

void dfs(int n){
	visited[n] = 1;
	ll T = 2*A[n],ma = 0,sum = 0;
	for(int i=0;i<v[n].size();i++){
		if(visited[v[n][i]]==0){
			dfs(v[n][i]);
			T -= C[v[n][i]];
			sum += C[v[n][i]];
			ma = max(C[v[n][i]],ma);
		}
	}
	if(v[n].size()==1) C[n] = A[n];
	else C[n] = T;
	if(v[n].size()>=2){
		ll L = sum - A[n];
		if(T<0 || L<0) judge = false;
		if(2*ma>sum){
			if(L>sum-ma) judge = false;
		}else{
			if(L>sum/2) judge = false;
		}
	}
	if(n==u && T!=0) judge = false;
}

int main(){
	cin >> N;
	for(int i=1;i<=N;i++){
		cin >> A[i];
		C[i] = INT_MAX;
	}
	for(int i=0;i<N-1;i++){
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	for(int i=1;i<=N;i++){
		if(v[i].size()>=2) u = i;
	}
	dfs(u);
	if(N==2 && A[1]==A[2]) judge = true;
	else if(N==2) judge = false;
	cout << (judge? "YES" : "NO") << endl;
}

Measured memory_bytes: 15232
def f(n) n>0?1<<n.to_s(2).size: 1 end
a,b=$<.map &:to_i
x=a^b
c=f(x)
a&=c-1
b&=c-1
i=c>>1
b=f(b-i)-1
p c-a-[a-1-b,0].max

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	ll n,a,b; cin>>n>>a>>b;
	ll c=a+b;
	ll m=n/c;
	ll k=min(a,n%c);
	cout<<(m*a)+k;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int i,j,k,n,m,l,a[100][100],b[100][100];
    long sum;
    scanf("%d%d%d",&n,&m,&l);
    for(j=0;j<n;j++){
        for(i=0;i<m;i++){
            scanf("%d",&a[j][i]);
        }
    }
    for(i=0;i<m;i++){
        for(k=0;k<l;k++){
            scanf("%d",&b[k][i]);
        }
    }
    for(j=0;j<n;j++){
        for(k=0;k<l;k++){
            sum=0;
            for(i=0;i<m;i++){
                sum+=a[j][i]*b[k][i];
            }
            if(k!=0){
                printf(" ");
            }
            printf("%ld",sum);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2112
m1, d1 = map(int, input().split())
m2, d2 = map(int, input().split())
if m1 != 12:
  if m2 == m1+1:
    print(1)
  else:
    print(0)
else:
  if m2 == 1:
    print(1)
  else:
    print(0)

Measured memory_bytes: 38384
import scala.collection.mutable

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N, M = sc.nextInt()
  val (acs, was) = List
    .fill(M)(sc.nextInt() -> sc.next())
    .foldLeft((mutable.HashMap.empty[Int, Int], mutable.HashMap.empty[Int, Int])) {
      case ((acs, was), (p, result)) =>
        if (!acs.contains(p)) result match {
          case "AC" => acs.update(p, 0)
          case "WA" => was.update(p, was.getOrElse(p, 0) + 1)
        }
        acs -> was
    }
  println(s"${acs.size} ${was.filter { case (i, _) => acs.contains(i) }.values.sum}")
}


Measured memory_bytes: 74864
a, b, c = gets.chomp.split.map(&:to_i)

if (!([a, b, c].uniq.count == 1)) then
  if (([a, b].uniq.count == 1) || ([b, c].uniq.count == 1)  || ([a, c].uniq.count == 1)) then
    puts "Yes"
  else
    puts "No"    
  end
else
  puts "No"
end


Measured memory_bytes: 1916
#!/usr/bin/env python3
s = input()
t = input()
# 10日前にACした問題を解く
# 文字列s,tが与えられ、s内にある異なる文字a,bをひっくり返すことでtにできるか判定
# s,tの文字が全単射であるかどうか判定する
# s,t内に出てくる文字全ての位置をリストで保管して、それが一致しているかを判定すれば良い
s_idx = []
t_idx = []
s_visit = []
t_visit = []
for i in range(len(s)):# 全ての位置を探索する
  if s[i] not in s_visit:#初出のやつならその文字を記録する
    s_idx.append([i])
    s_visit.append(s[i])
  else:# 既出ならそれが出てきた時の位置に場所を追加する
    pos = s_visit.index(s[i])
    s_idx[pos].append(i)
for i in range(len(t)):# 全ての位置を探索する
  if t[i] not in t_visit:#初出のやつならその文字を記録する
    t_idx.append([i])
    t_visit.append(t[i])
  else:# 既出ならそれが出てきた時の位置に場所を追加する
    pos = t_visit.index(t[i])
    t_idx[pos].append(i)
#print(s_idx,t_idx,s_visit,t_visit)
if s_idx == t_idx:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 51772
n,m=map(int,input().split())
lm,mr=0,n
for i in range(m):
  l,r=map(int,input().split())
  lm=max(lm,l)
  mr=min(mr,r)
  x=mr-lm+1

if x>=0:
  print(x)
else:
  print(0)


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


int main(){
  long long int N;
  cin >> N;
  vector<long long int> A(N);
  for(auto& a : A){
    cin >> a;
  }

  // ii < jj
  // jj - ii = A[ii] + A[jj]
  // ii + A[ii] = jj - A[jj]
  // x = ii + A[ii]
  // y = jj - A[jj]
  long long int ans = 0;
  vector<map<long long int, long long int>> B(N);
  for(long long int ii=0; ii<N; ii++){
    long long int x = ii + A[ii];
    long long int y = ii - A[ii];
    if(x < N){
      B[x][x]++;
    }
    if(y>=0){
      if(B[y].find(y)!=B[y].end()) ans+=B[y][y];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 22052
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007;
#define pi 3.14159265358979323846
#define Endl endl
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int l;
	cin>>l;
	double hab = ( 1.0 * l ) / 3.0;
	cout<<setprecision(15)<<hab*hab*hab<<endl;
	return 0;
}

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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int H,W;
int dx[2] = {0,1};
int dy[2] = {1,0};

int dfs(vector<vector<char>> &C, vector<vector<int>> &seen, int h, int w, int step, int flag) {
    int tmp;
    if (h+dy[flag]<H && w+dx[flag]<W) {
        if (C[h+dy[flag]][w+dx[flag]]=='.' && seen[h+dy[flag]][w+dx[flag]]==-1) {
            tmp = dfs(C,seen,h+dy[flag],w+dx[flag],step+1,flag)+1;
        }
        else tmp = 1;
    }
    else tmp = 1;
    seen[h][w] = step + tmp;
    //cout << tmp << endl;
    return tmp;
}

int main(){
    cin >> H >> W;
    vector<vector<char>> C(H,vector<char>(W));
    rep(i,H) {
        string tmp;
        cin >> tmp;
        rep(j,W) {
            C[i][j] = tmp[j];
        }
    }
    vector<vector<int>> seenh(H,vector<int> (W,-1));
    vector<vector<int>> seenw(H,vector<int> (W,-1));

    rep(h,H) {
        rep(w,W) {
            if (C[h][w]=='#') continue;
            else {
                if (seenh[h][w]==-1) {
                    seenh[h][w] = dfs(C,seenh,h,w,0,0);
                }
                if (seenw[h][w]==-1) {
                    seenw[h][w] = dfs(C,seenw,h,w,0,1);
                }
            }
        }
    }

    int ans = 0;
    rep(h,H) { 
        rep(w,W) {
            ans = max(ans,seenh[h][w]+seenw[h][w]-1);
        }
    }
    cout << ans << endl;
}


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

using namespace std;
using ll = long long;
#define int ll

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a
#define lcoutln(a) cout << a << endl
#define lcerr(a) cerr << a
#define lcerrln(a) cerr << a << endl
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007
#define PI 3.141592653589793238462643383

signed main()
{
	init();
	solve();
}

int N;
vector<int> l;

void init()
{
	cin >> N;
	l.resize(2*N);
	rep(i, 2*N) cin >> l[i];
}

void solve()
{
	sort(all(l));
	int res = 0;
	rep(i, N*2) {
		res += l[i];
		i++;
	}
	cout << res << endl;
}


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<double>;
using vvi = vector<vector<int>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main() {
	string s; cin >> s;
	vi memo(26);

	rep(i, s.size()) {
		memo[s[i] - 'a']++;
	}

	rep(i, 26) {
		if (memo[i] == 0) {
			cout << char(i + 97) << endl;
			return 0;
		}
	}

	cout << "None" << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <string>
#include <cmath>
using namespace std;

int main() {
    string str;
    cin >> str;
    if (str[2] == str[3] && str[4] == str[5]) cout << "Yes" << endl;
    else cout << "No" << endl;


    
}



Measured memory_bytes: 256
def add(a,b):
    return a+b
def sub(a,b):
    return a-b
def mul(a,b):
    return a*b

ls=input().split()

stack=[]

i = 0
while i < len(ls):
    if ls[i] == '+':
        stack.append(add(stack[-2],stack[-1]))
        stack.pop(-3)
        stack.pop(-2)
    elif ls[i] == '-':
        stack.append(sub(stack[-2],stack[-1]))
        stack.pop(-3)
        stack.pop(-2)
    elif ls[i] == '*':
        stack.append(mul(stack[-2],stack[-1]))
        stack.pop(-3)
        stack.pop(-2)
    else:
        stack.append(int(ls[i]))
    i+=1
print(stack[-1])


Measured memory_bytes: 5608
i = gets.chomp.split.map(&:to_i)
i[2] = i[0] - 1
i[3] = i[1] - 1
max = 0
max2 = 0
4.times do |hoge|
    if max < i[hoge] then
        if max != 0 and 1 <= hoge then
            max2 = max
        end
        max = i[hoge]
    elsif max2 < i[hoge] then
        max2 = i[hoge]
    end
end
puts max + max2

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

using namespace std;

int main() {
  int64_t A, B, N;
  cin >> A >> B >> N;
  //vector<vector<int>> input(q, vector<int>(4));

  int64_t loop = N / B +1;
  int64_t x, ans, tmp;
  ans = 0;

  if(B==1){
    ans =0;
  }
  else{
    for (int i = 1; i <= loop; i++){
      if ((i * B -1) < N) x = i * B -1; 
      else x = N;
      tmp = floor(A*x/B) - A * floor(x/B);
      if (tmp > ans) ans = tmp;
    }
  }  

  cout << ans << endl;

}


Measured memory_bytes: 3620
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

int main(){
    // input
    string s;
    cin >> s;

    // calc
    if(s.size() == 2){
        cout << s << endl; 
    }else{
        reverse(s.begin(), s.end());
        cout << s << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+5;
int a[N],m[N];
int main(){
	//freopen("in.txt","r",stdin);
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		m[a[i]]++;
	}
	int res = 0;
	for(int i=1;i<N;i++){
		int tm = m[i-1]+m[i]+m[i+1];
		res=max(res,tm);
	}
cout<<res;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define bit(x,j) ((x>>j)&1)
using namespace std;
// bitset<8>set1(p);
// __builtin_popcountll(x);
// bitset<100> b("1010");
ll int mod=1e9+7;//998244353;
int mul(ll int x, ll int y)
{
    return (x * 1ll * y) % mod;
}

int add(int x, int y)
{
    x += y;
    while(x >= mod) x -= mod;
    while(x < 0) x += mod;
    return x;
}

long long power(long long a, long long b,ll m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = mul(res,a);
        a = mul(a,a);
        b >>= 1;
    }
    return res%m;
    }


  ll int binomial(ll int n, ll int k) 
{ 
    ll int C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll int i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (int j = min(i, k); j > 0; j--) 
            C[j] = C[j]+C[j-1]; 
    } 
    return C[k]; 
} 
  vector<int> pr;
  bool prime[10000000];
void Sieve(ll int n) 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            pr.push_back(p);
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
}
 


//It reurns Fn,Fn+1
pair<int, int> fib (int n) {
    if (n == 0)
        return {0, 1};

    auto p = fib(n >> 1);
    int c = p.first * (2 * p.second - p.first);
    int d = p.first * p.first + p.second * p.second;
    if (n & 1)
        return {d, c + d};
    else
        return {c, d};
}
int sum(int n)  
{  
    if (n == 0)  
    return 0;  
    return (n % 10 + sum(n / 10));  
}  
ll int factorial(ll int n,ll int m) 
{ 
    ll int fact = 1; 
    for(int i=2;i<=n;i++) { 
        fact = (fact * i)%m; 
    } 
    return fact%m; 
} 

int reduce(int x, int y) 
{ 
    int d; 
    d = __gcd(x, y); 
  
    x = x / d; 
    y = y / d; 
    return x; 
} 


int main() {
  ios;
  ll int n;
  cin>>n;
  ll int x,t;
  cin>>x>>t;
  int l=n/x;
  if(n%x!=0)
  l++;
  cout<<l*t<<endl;
}


Measured memory_bytes: 3656
from collections import deque
import math

def dig(K):
    k = str(K)
    ans = 0

    for i in k:
        ans += int(i)
    return ans

K = int(input())
m = 0
ans = []

q = deque([[1,1],[2,1]])
now = 1
i = 2

while True:

        i += now   
        
        num = i / dig(i)

        while q[-1][1] > num:
            q.pop()

        q.append([i , num])

        if len(q) > 2 * K:
            break

        if math.log10(q[-1][0] - q[-2][0]) == math.log10(q[-1][0] - q[-2][0]) // 1:
            now = 10 ** (int(math.log10(q[-1][0] - q[-2][0])))

for i in range(K):
    print (q[i][0])

Measured memory_bytes: 40940
#include <iostream> //cin,cout
#include <fstream> //input.txtの入力
#include <vector> //vector
using namespace std;

int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());

  int N;
  cin>>N;

  vector<int> P(N);
  for(int i=0;i<N;i++) cin>>P.at(i);

  int ans=1;
  int minNum=P.at(0);

  for(int i=1;i<N;i++){
    //cout<<minNum<<','<<P.at(i)<<endl;
    if(minNum>=P.at(i)){
      ans++;
      minNum=P.at(i);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
# coding: utf-8
# Your code here!
x,n = map(int,input().split())
if n == 0:
    print(x)
    exit()
s = sorted(list(map(int,input().split())))


i = x
while True:
    if i not in s:
        res_high = i
        break
    else:
        i += 1


j = x
while True:
    if j not in s:
        res_low = j
        break
    else:
        j -= 1


if abs(res_low - x) <= abs(res_high - x):
    print(res_low)
else:
    print(res_high)

    

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int L[5050],R[5050];
pair<ll,int> P[5050];

ll dp[3030][3030][2];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		cin>>L[i]>>R[i];
		P[i]={R[i]+L[i],i};
	}
	if(N%2==0) {
		P[N]={0,N};
		N++;
	}
	
	FOR(x,3000) FOR(y,3000) dp[x][y][0]=dp[x][y][1]=1LL<<60;
	dp[0][0][0]=0;
	
	sort(P,P+N);
	FOR(i,N) {
		j=P[i].second;
		for(l=0;l<=N/2;l++) {
			for(k=0;k<=1;k++) {
				r=i-l-k;
				if(r<0 || r>N/2) continue;
				
				if(l+1<=N/2) dp[l+1][r][k]=min(dp[l+1][r][k],dp[l][r][k]+R[j]+(N/2-(l+1))*P[i].first);
				if(r+1<=N/2) dp[l][r+1][k]=min(dp[l][r+1][k],dp[l][r][k]+L[j]+(N/2-(r+1))*P[i].first);
				if(k==0)     dp[l][r][k+1]=min(dp[l][r][k+1],dp[l][r][k]+(N-1)/2*P[i].first);
			}
		}
	}
	
	cout<<dp[N/2][N/2][1]<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 143744
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int cmp(const void *a, const void *b)
{
	return *(int*)a - *(int*)b;//昇順
							   //降順ならreturn *(int*)b - *(int*)a;
}
int main()
{
	int p[3];

	scanf("%d%d%d", &p[0], &p[1], &p[2]);
	qsort(p, 3, sizeof(int), cmp);
	printf("%d\n",p[0]+p[1] );
	return 0;
}

Measured memory_bytes: 128
from itertools import combinations

N, X, Y = map(int, input().split())


def length(i, j):
  return min(j - i, abs(X - i) + abs(Y - j) + 1, abs(X - j) + abs(Y - i) + 1)


counter = [0] * (N - 1)

for i, j in combinations(range(1, N + 1), 2):
  l = length(i, j)
  counter[l - 1] += 1

for c in counter:
  print(c)


Measured memory_bytes: 3572
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

int main()
{
	int a, p;

	scanf("%d %d", &a, &p);

	a *= 3;

	a += p;

	printf("%d\n", a / 2);

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
int main()
{
    vector<ll>sz;
    ll a,b;
    ll sc=0;
    scanf("%lld%lld",&a,&b);
    if(a==1||b==1)
        sc=0;
    else
    {
        for(ll i=2; i*i<=a&&i<=1000009; i++)
        {
            if(a%i==0)
            {
                while(a%i==0)
                    a=a/i;
                sz.push_back(i);
            }
        }
        if(a>1)
            sz.push_back(a);
        ll len=sz.size();
        for(ll i=0; i<len; i++)
        {
            if(b%sz[i]==0)
                sc++;
        }
    }
    printf("%lld\n",sc+1);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

priority_queue<int> pq;

int main() {
    rep(i, 2000010) {
        string query; cin >> query;
        if (query == "insert") {
            int k; cin >> k;
            pq.push(k);
        } else if (query == "extract") {
            int k = pq.top();
            cout << k << endl;
            pq.pop();
        } else {
            return 0;
        }
    }
}



Measured memory_bytes: 6960
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		float a,b,c,d,e,f;
		try {
			while(scan.hasNext()){
				a=scan.nextFloat();
				b=scan.nextFloat();
				c=scan.nextFloat();
				d=scan.nextFloat();
				e=scan.nextFloat();
				f=scan.nextFloat();
				float y=((a*f)-(c*d))/(float)((a*e)-(b*d));
				float x=(c-(b*y))/(float)a;
				System.out.printf("%.3f %.3f\n",x,y);
			}
		} catch (Exception e2) {
		}
	}

}

Measured memory_bytes: 20512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/arc082_a.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  vector<int> c(N);
  rep(i, N) { cin >> c[i]; }

  map<int, int> m;
  rep(i, N) {
    m[c[i] - 1]++;
    m[c[i]]++;
    m[c[i] + 1]++;
  }
  int cnt = 0;
  for (auto kv : m) {
    cnt = max(kv.second, cnt);
  }

  cout << cnt << endl;
}

Measured memory_bytes: 5120
function Main(input) {
    var input = input.split("\n");
    const num = input[0];
    const arr = input[1].split(" ");
    var a = 1;
    var b = 0;
    arr.forEach(i => a *= i);
    for(var i=0; i<arr.length; i++){
        b += a / arr[i];
    }
    console.log(a/b);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 23100
use proconio::input;
use std::collections::BTreeMap;

const M: u64 = 1_000_000_007;

fn main() {
    input! {
        n: usize,
        d: [(i64, i64); n],
    }

    let mut z = 0;
    let mut t = BTreeMap::new();
    for e in d {
        if e.0 == 0 && e.1 == 0 {
            z += 1;
        } else if e.0 == 0 {
            *t.entry((0, 1)).or_insert(0) += 1;
        } else if e.1 == 0 {
            *t.entry((1, 0)).or_insert(0) += 1;
        } else {
            let g = num::integer::gcd(e.0.abs(), e.1.abs());
            let e = if e.0 < 0 {
                (-e.0, -e.1)
            } else {
                e
            };
            let e = (e.0 / g, e.1 / g);
            *t.entry((e.0, e.1)).or_insert(0) += 1;
        }
    }
    z %= M;

    let mut ans = 1;
    while let Some((&k, &c)) = t.iter().next() {
        t.remove(&k);
        let inv = if k.1 < 0 {
            (-k.1, k.0)
        } else {
            (k.1, -k.0)
        };

        let c2 = modpow(2, c);
        if let Some(invc) = t.remove(&inv) {
            let i2 = modpow(2, invc);
            ans *= c2 + i2 - 1;
        } else {
            ans *= c2;
        }
        ans %= M;
    }
    ans = (ans + z + M - 1) % M;
    println!("{}", ans);
}

fn modpow(x: u64, y: u64) -> u64 {
    let mut result = 1;
    let mut a = x;
    let mut b = y;
    while b > 0 {
        if b % 2 == 1 {
            result = result * a % M;
        }
        a = a * a % M;
        b /= 2;
    }
    result
}


Measured memory_bytes: 20588
#include<iostream>

using namespace std;

int main(){
  int a, b, k;
  cin >> a >> b >> k;
  for(int i=0;i<k;i++){
    if(i%2==0){
      if(a%2) a--;
      a /= 2;
      b += a;
    }else {
      if(b%2) b--;
      b /= 2;
      a += b;
    }
  }
  cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<list>
#include<set>
using namespace std;
int main() {
  int a, b;
  while (cin >> a >> b) {
    if (a + b < 10){
      cout << 1 << endl;
    }
    else if (a + b < 100){
      cout << 2 << endl;
    }
    else if (a + b < 1000) {
      cout << 3 << endl;
    }
    else if (a + b < 10000) {
      cout << 4 << endl;
    }
    else if (a + b < 100000) {
      cout << 5 << endl;
    }
    else if (a + b < 1000000) {
      cout << 6 << endl;
    }
    else if (a + b < 10000000) {
      cout << 7 << endl;
    }
  }

  return 0;
}




Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <list>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>

using namespace std;


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

	K = K - 1;
	int chara = S[K];
	S[K] = S[K] + 32;

	std::cout << S; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N;cin >> N;
    int ans = -1;
    rep(i,N+1){
        if(floor(i*1.08) == N){
            ans = i;
            break;
        }
    }
    if(ans == -1)cout << ":(" << endl;
    else cout << ans << endl;

}



Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

struct modint{
    using i64=int_fast64_t;
    i64 a;
    const i64 MOD=1000000007;
    modint(i64 a_=0){
        a=a_%MOD;
        if(a<0) a+=MOD;
    }
    modint inv()const{
        i64 n=1,m=MOD-2,A=a;
        while(m){
            if(m&1)(n*=A)%=MOD;
            (A*=A)%=MOD;
            m>>=1;
        }
        modint y(n);
        return y;
    }
    bool operator==(const modint& x){
        return a==x.a;
    }
    bool operator!=(const modint& x){
        return a!=x.a;
    }
    modint& operator=(const modint& x){
        a=x.a;
        return *this;
    }
    modint operator+(const modint& x){
        modint y;
        y.a=a+x.a;
        if(y.a>MOD) y.a-=MOD;
        return y;
    }
    modint operator-(const modint& x){
        modint y;
        y.a=a-x.a;
        if(y.a<0) y.a+=MOD;
        return y;
    }
    modint operator*(const modint& x){
        modint y;
        y.a=(a*x.a)%MOD;
        return y;
    }
    modint operator/(const modint& x){
        modint y;
        y.a=(a*x.inv().a)%MOD;
        return y;
    }
    modint& operator+=(const modint& x){
        a+=x.a;
        if(a>=MOD) a-=MOD;
        return *this;
    }
    modint& operator-=(const modint& x){
        a-=x.a;
        if(a<0) a+=MOD;
        return *this;
    }
    modint& operator*=(const modint& x){
        (a*=x.a)%=MOD;
        return *this;
    }
    modint& operator/=(const modint& x){
        (a*=x.inv().a)%=MOD;
        return *this;
    }
};
istream& operator>>(istream &in,modint& x){
    int_fast64_t a_;
    in>>a_;
    modint y(a_);
    x=y;
    return in;
}
ostream& operator<<(ostream &out,const modint& x){
    out<<x.a;
    return out;
}
modint pwr(int_fast64_t a,int_fast64_t b){
    modint _;
    int_fast64_t n=1,A=a,MOD=_.MOD;
    while(b){
        if(b&1) (n*=A)%=MOD;
        (A*=A)%=MOD;
        b>>=1;
    }
    _.a=n;
    return _;
}

class ENChildrenAndCandies {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int n,c;
        in>>n>>c;
        vector<int> a(n),b(n);
        for(auto&i:a) in>>i;
        for(auto&i:b) in>>i;
        vector<vector<modint>> e(c+1,vector<modint>(401)),dp(n+1,vector<modint>(c+1));
        fr(i,c+1) Fr(j,400) e[i][j]=e[i][j-1]+pwr(j,i);
        dp[0][0]=1;
        fr(i,n) fr(j,c+1) fr(k,j+1) dp[i+1][j]+=dp[i][j-k]*(e[k][b[i]]-e[k][a[i]-1]);
        out<<dp[n][c]<<endl;
    }
};

int main() {
    ENChildrenAndCandies solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 7424
#include<cstdio>
#include<vector>
#include<algorithm>

#define	pb	push_back

using namespace std;

typedef	vector<int>	vi;

bool check(vi v){
	int n=v.size();
	if(n==0)	return true;
	if(n==3){
		sort(v.begin(),v.end());
		if(v[0]==v[1] && v[1]==v[2])		return true;
		if(v[0]+1==v[1] && v[1]+1==v[2])	return true;
		return false;
	}
	if(n>=6){
		vector<bool> b(n);
		for(int i=n-3;i<n;i++)	b[i]=true;
		do{
			vi vv[2];
			for(int i=0;i<n;i++)	vv[b[i]].pb(v[i]);
			if(check(vv[0]) && check(vv[1]))	return true;
		}while(next_permutation(b.begin(),b.end()));
		return false;
	}
}

int main(){
	int t;	scanf("%d",&t);
	while(t--){
		pair<int,char> card[9];
		for(int i=0;i<9;i++)	scanf("%d ",&card[i].first);
		for(int i=0;i<9;i++)	scanf("%c ",&card[i].second);

		vi v[3];
		for(int i=0;i<9;i++){
			if(card[i].second=='R')	v[0].pb(card[i].first);
			if(card[i].second=='G')	v[1].pb(card[i].first);
			if(card[i].second=='B')	v[2].pb(card[i].first);
		}

		bool ok;
		if(v[0].size()%3==0 && v[1].size()%3==0 && v[2].size()%3==0){
			ok=true;
			for(int i=0;i<3;i++){
				if(!check(v[i])){ ok=false; break; }
			}
		}
		else	ok=false;

		printf("%d\n",ok);
	}

	return 0;
}

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

#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
//typedef vector<ll> vec;
//typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

const ll MAX_N=100010;

ll N,a[MAX_N];

int main(){
  cin>>N;
  for(ll i=0;i<N;i++){
    cin>>a[i];
  }
  sort(a,a+N);
  ll amax=a[N-1];
  ll tmp=a[0];
  for(ll i=0;i<N-1;i++){
    if(abs(amax-tmp*2)>abs(amax-2*a[i]))tmp=a[i];
  }
  cout<<amax<<" "<<tmp<<endl;


  return 0;
}


Measured memory_bytes: 1024