akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

//vector<int> G[300];

int main(){
  
  int n,m;
  long long l;
  cin>>n>>m>>l;
  
  int a,b;
  long long c;
  //long long w[n][n];
  vector<vector<long long>> dist(n, vector<long long>(n, INF));
  REP(i,n){
    dist[i][i] = 0;
  }
  REP(i,m){
    cin>>a>>b>>c;
    a--;b--;
    if(c>l)continue;
    //G[a].push_back(b);
    //G[b].push_back(a);
    //w[a][b] = w[b][a] = c;
    dist[a][b] = dist[b][a] = c;
  }
  
  REP(k,n){
    REP(i,n){
      REP(j,n){
        if(dist[i][j] > dist[i][k] + dist[k][j]){
          dist[i][j] = dist[i][k] + dist[k][j];
        }
      }
    }
  }
  /*
  vector<vector<int>> next_(n, vector<int>(n, -1));
  REP(i,n){
    REP(j,n){
      for(int k:G[i]){
        if(dist[i][k] + dist[k][j] == dist[i][j]){
          next_[i][j] = k;
        }
      }
    }
  }
  */
  
  vector<vector<long long>> dist2(n, vector<long long>(n, INF));
  REP(i,n){
    dist2[i][i] = 0;
  }
  REP(i,n){
    REP(j,n){
      if(dist[i][j] <= l){
        dist2[i][j] = 1;
      }
    }
  }
  
  REP(k,n){
    REP(i,n){
      REP(j,n){
        if(dist2[i][j] > dist2[i][k] + dist2[k][j]){
          dist2[i][j] = dist2[i][k] + dist2[k][j];
        }
      }
    }
  }
  
  int q;
  cin>>q;
  int s,t;
  REP(i,q){
    cin>>s>>t;
    s--;t--;
    if(dist[s][t] == INF){
      cout<<-1<<endl;
      continue;
    }

    long long res;
    /*
    int now = s;
    long long cap = l;
    while(now != t){
      int n = next_[now][t];
      if(w[now][n]>=cap){
        res++;
        cap = l;
        cap -= w[now][n];
      }else{
        cap -= w[now][n];
      }
      now = n;
    }
    */
    
    if(dist2[s][t] == INF){
      cout<<-1<<endl;
      continue;
    }
    
    res = dist2[s][t];
    res = max(0LL,res-1);
    cout<<res<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef pair<ll,ll> P;
 
int main(){
    double n;
    cin>>n;
    cout<<std::fixed<<std::setprecision(4)<<(double)n*3.1415926*2<<endl;
 
 
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> c(n);
	vector<int> v(n);
	for(int i=0; i<n; i++){
		cin >> v[i];
	}
	for(int i=0; i<n; i++){
		cin >> c[i];
	}

	int ans = 0;
	for(int i=0; i<n; i++){
		if(v[i] - c[i] > 0) {
			ans += v[i] - c[i];
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
n,m,x=map(int,input().split())
money=[]
skill=[]
for i in range(n):
  a=list(map(int,input().split()))
  money+=[a[0]]
  skill+=[a[1:m+1]]
ans=-1
for i in range(2**n):
  total=0
  learn=[0]*m
  for j in range(n):
    if (i>>j)&1:
      total+=money[j]
      for a in range(m):
        learn[a]+=skill[j][a]
  if len([i for i in learn if i>=x])==m:
    if ans==-1:
      ans=total
    elif ans>total:
      ans=total
print(ans)

Measured memory_bytes: 9168
import java.util.*; 
import java.lang.*; 


public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                String S = scan.next();
                String T = scan.next();
                
                
                
            if(T.equals(S+T.substring(T.length()-1))){
                System.out.println("Yes");
            }
            
            else{
                 System.out.println("No");
            }
        
        }
}

Measured memory_bytes: 39248
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;
int n;
int a[N];
int main(){
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    int r = 0;
    int ans = 0;
    for(int l = 0; l < n; ){
        r = l;
        while(r < n && a[r] == a[l]) r ++;
        r--;
        int len = r - l + 1;
        ans += len / 2;
        l = r + 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz size
#define se second
#define fe first
#define mper make_pair
#define all(x) x.begin(), x.end()
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define vl vector<ll>
#define vi vector<int>
#define vli vector <pair <ll, int> >
#define vll vector <pair <ll, ll> >
#define vii vector <pair <int, int> >
using namespace std;

const ll MAXN = 2e5 + 100;
ll n, a[MAXN];

map <ll, int> mp;

int main(){

cin >> n;

ll ai;

for(int i = 1; i <= n; ++i) {

    cin >> a[i];
    mp[a[i]]++;

}

vector < pair <ll, ll> > g;

ll to = 2147483648ll;
to *= 2ll;

ll ans = 0;

for(int st = 1; st <= 31; ++st) {

    to /= 2ll;

    for(int i = 1; i <= n; ++i) {

        g.pb(mper(a[i], to - a[i]));

    }

}

for(auto key : g) {

    ll l = key.fe;
    ll r = key.se;
    ll to = r + l;

    if(r < 0 || l < 0) {continue;}

    if(r != l && mp[l] && mp[r]) {

            mp[l]--;
            mp[r]--;
            ans++;

    }

    else if(r == l && mp[l] - 2 >= 0) {

        mp[l] -= 2;
        ans++;

    }

}

cout << ans;

return 0;
}


Measured memory_bytes: 151384
N = int(input())
S1 = input()
S2 = input()

lis = []
i = 0
while i < N:
  if i == N-1:
    lis.append(1)
    i += 1
  elif S1[i] == S1[i+1]:
    lis.append(2)
    i += 2
  else:
    lis.append(1)
    i += 1
#print(lis)
ans = 3
if lis[0]==2:
  ans = 6
for i in range(len(lis)-1):
  if lis[i]==2:
    if lis[i+1]==2:
      ans *= 3
  else:
    ans *= 2
  ans %= 10**9+7
print(ans)

#print(*ans, sep='\n')


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

int main() {

	int rooms[4][3][10] = { 0 };

	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int b, f, r, v;
		cin >> b >> f >> r >> v;
		rooms[b - 1][f - 1][r - 1] += v;
	}

	for (int b = 0; b < 4; b++) {
		if (b != 0) {
			cout << "####################" << endl;
		}
		for (int f = 0; f < 3; f++) {
			for (int r = 0; r < 10; r++) {
				cout << " " << rooms[b][f][r];
			}
			cout << endl;
		}
	}

	return 0;
}



Measured memory_bytes: 3112
sdash, t = readlines.map(&:chomp)

x = (sdash.length - t.length + 1).times.reduce([]) do |r, i|
  q = sdash[i..i+t.length-1]
  identical = q.each_char.zip(t.each_char).all? {|c1, c2| c1 == c2 || c1 == '?'}
  if identical
    dup = sdash[0..-1]
    dup[i..i+t.length-1] = t
    r << dup.gsub('?', 'a')
  end
  r
end

puts x.length == 0 ? 'UNRESTORABLE' : x.min

Measured memory_bytes: 2684
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i, n) for (int i = 0; i < int(n); i++)
#define FOR1(i, m, n) for (int i = int(m); i < int(n); i++)
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
#define MIN(a, b) ((a) <= (b) ? (a) : (b))

int main(int argc, char *argv[]) {
  int N, M, Q;
  scanf("%d%d%d", &N, &M, &Q);

  //boost::multi_array<int, 2> mat(boost::extents[N + 1][N + 1]);
  int mat[501][501] = {};

  FOR(i, M) {
    int L, R;
    scanf("%d%d", &L, &R);
    mat[L][R]++;
  }

  FOR(i, N + 1) {
    FOR1(j, i, N) { mat[i][j + 1] += mat[i][j]; }
  }

  for (int i = N; i > 0; i--) {
    FOR1(j, i, N + 1) { mat[i - 1][j] += mat[i][j]; }
  }

  while (Q--) {
    int p, q;
    scanf("%d%d", &p, &q);
    printf("%d\n", mat[p][q]);
  }

  return 0;
}


Measured memory_bytes: 1920
#include<iostream>

using namespace std;

int gcd(int n,int m){
  if(m>n)return gcd(m,n);
  if(m==0)return n;
  return gcd(m,n%m);
}

int A[100+3][1000+2];

int p_gcd[100+3];

int main(){
  int n;
  cin>>n;
  for(int i=0;i<1e2;i++){
    p_gcd[i]=0;
    for(int j=0;j<1e3;j++)A[i][j]=0;
  }
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    A[i/(1000)][i%(1000)]=a;
  }
  for(int i=0;i<1e2;i++){
    int tmp=A[i][0];
    for(int j=1;j<1e3;j++)tmp=gcd(tmp,A[i][j]);
    p_gcd[i]=tmp;
  }
  int ans=1;
  
  for(int k=0;k<n;k++){
    int tmp=0;
    for(int i=0;i<1e2;i++){
      if((k/1000)==i)continue;
      tmp=gcd(tmp,p_gcd[i]);
    }
    for(int i=0;i<1e3;i++){
      if((k%1000)==i)continue;
      tmp=gcd(tmp,A[k/1000][i]);
    }
    ans=max(ans,tmp);
  }
  cout<<ans<<endl;

  
}


Measured memory_bytes: 640
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
       s: String
    }
    let s1 = &s[0..2];
    let s2 = &s[2..4];
    if "01" <= s1 && s1 <= "12" 
    && "01" <= s2 && s2 <= "12" {
        println!("AMBIGUOUS");
    } else if "01" <= s1 && s1 <= "12" {
        println!("MMYY");
    } else if "01" <= s2 && s2 <= "12" {
        println!("YYMM");
    } else {
        println!("NA");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long
#define mp(a, b) make_pair(a, b)
#define newline cout << endl;
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(v) v.begin(),v.end()
using namespace std;

template <typename S, typename T> ostream& operator<<(ostream& out, pair<S, T> const& p)
{
	out << '(' << p.ff << ", " << p.ss << ')';
	return out;
}

template <typename T> ostream& operator<<(ostream& out, vector<T> const& v)
{
	int l = v.size();
	for (int i = 0; i < l - 1; i++)
		out << v[i] << ' ';
	if (l > 0)
		out << v[l - 1];
	return out;
}

template <typename T> void trace(const char* name, T&& arg1) { cout << name << " : " << arg1 << endl; }

template <typename T, typename... Args> void trace(const char* names, T&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	cout.write(names, comma - names) << " : " << arg1 << " | ";
	trace(comma + 1, args...);
}

/*Input*/
/*Input*/

int main()
{
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	//cout.tie(0);
	clock_t tStart = clock();
	int test;
	test = 1;
	// cin >> test;
	while (test--) {
        ll n,r;
        cin >> n >> r;
        if(n>=10){ cout << r << endl;}
        else {
            ll ans = r + 100*(10-n);
            cout << ans << endl;
        }
	}
#ifdef LOCAL_DEFINE
	printf("Time taken: %.2fs\n", (double)(clock() - tStart) / CLOCKS_PER_SEC);
#endif
	return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)

char grid[7][7];
int H,W,K;
bool done[7][7];
int main(){
	fast;
	
	cin>>H>>W>>K;
	int numblack = 0;
	FOR(i,0,H-1) FOR(j,0,W-1){
		cin>>grid[i][j];
		numblack += (grid[i][j] == '#');
	}
	int ans = 0;

	FOR(bm,0,(1<<H) - 1){
		FOR(bm2, 0, (1<<W) - 1){
			mem(done,0);
			int num = 0;
			FOR(i,0,H-1) if (bm & (1<<i)){
				FOR(j,0,W-1){
					done[i][j] = 1;
					num += (grid[i][j] == '#');
				}
			}
			
			FOR(i,0,W-1) if (bm2 & (1<<i)){
				FOR(j,0,H-1) if (done[j][i] == 0) {
					done[j][i] = 1;
					num += (grid[j][i] == '#');
				}
			}
			
			if (numblack - num == K) ans++;
			
		}
	}
	
	
	cout<<ans;
	
	
}


Measured memory_bytes: 3636
h,w,k = map(int, input().split())
sx,sy,gx,gy = map(int, input().split())
sx-=1
sy-=1
gx-=1
gy-=1

grid = ['' for _ in range(h)]

for i in range(h):
    grid[i] = input()
INF = 1001001001  
costgrid = [[INF]*w for _ in range(h)]

import heapq

q = []
q.append((0,sx,sy))

dx = (0,1,0,-1)
dy = (1,0,-1,0)
ans=INF
while q:
    cost,x,y = heapq.heappop(q)
    for i in range(4):
        for j in range(1,k+1):
            nx = x+dx[i]*j
            ny = y+dy[i]*j
            if(not 0<=nx<h):
                break
            if(not 0<=ny<w):
                break
            if(grid[nx][ny]=='@'):
                break
            if(costgrid[nx][ny]<=cost):
                break
            if(costgrid[nx][ny]>cost+1):
                costgrid[nx][ny]=cost+1
                heapq.heappush(q,(cost+1,nx,ny))
                if nx==gx and ny==gy:
                    ans=min(costgrid[nx][ny],ans)
                    q=[]

if ans!=INF:
    print(ans)
else:
    print(-1)



Measured memory_bytes: 160252
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define ll unsigned long long
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    int ans=0;
    REP(i,s.size())ans+=(s[i]==t[i]);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
n=int(input())
t=list(map(int,input().split()))
a=list(map(int,input().split()))
tt=[float("inf") for i in range(n)]
ans=[False for i in range(n)]
tmp=0
mod=10**9+7
for i in range(n):
    if t[i]>tmp:
        
        tt[i]=t[i]
        ans[i]=True
        tmp=t[i]
    else:
        tt[i]=tmp
tmp=0
for i in range(n-1,-1,-1):
    if ans[i]==True and a[i]<t[i]:
        print(0)
        exit()
    if a[i]>tmp:
        if ans[i]==True and a[i]!=t[i]:
            print(0)
            exit()
        tt[i]=a[i]
        ans[i]=True
        tmp=a[i]
    else:
        if ans[i]==False and tmp<tt[i]:
            tt[i]=tmp    
tmp=1
for i in range(n):
    if ans[i]==False:
        tmp*=tt[i]
        tmp%=mod
print(tmp%mod)

Measured memory_bytes: 25192
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
		public static void main(String[] args){
			
			Scanner s = new Scanner(System.in);
			int n = s.nextInt();
			int[] a = new int[n];
						
			for (int i = 0; i < a.length; i++) 
				a[i]=s.nextInt();
			Arrays.sort(a);
			int res = 0;
			int i=1;
			
			for(int j=n-1;j>=0;j--){
				res+=a[j]*i;
				i*=-1;
			}
			
			System.out.println(res);
			
			s.close();
		}		
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll k,x;cin>>k>>x;
  if(500*k>=x) puts("Yes");else puts("No");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);
typedef pair<int, int> pii;

const int maxn = 100100;
int a[maxn][3];
int c[3];
int f[3];
ll res;

set<pii> s[3][3];

void rem(int id, int where) {
    forn (i, 3) {
        if (i == where)
            continue;
        s[where][i].erase(pii{a[id][i] - a[id][where], id});
    }
}

void add(int id, int where) {
    forn (i, 3) {
        if (i == where)
            continue;
        s[where][i].insert(pii{a[id][i] - a[id][where], id});
    }
}

void push(int id) {
    ll best = -infl;
    int type = -1;
    int bi = -1, bj = -1, bk = -1;
    forn (i, 3) {
        if (c[i] > f[i] && a[id][i] > best) {
            best = a[id][i];
            type = 0;
            bi = i;
        }
    }
    forn (i, 3) {
        if (c[i] > f[i])
            continue;
        forn (j, 3) {
            if (i == j || c[j] == f[j])
                continue;
            ll delta = s[i][j].rbegin()->first;
            ll cur = delta + a[id][i];
            if (cur > best) {
                best = cur;
                type = 1;
                bi = i;
                bj = j;
            }
        }
    }
    forn (i, 3) {
        if (c[i] > f[i])
            continue;
        forn (j, 3) {
            if (i == j || c[j] > f[j])
                continue;
            int k = 3 - i - j;
            ll delta = s[i][j].rbegin()->first;
            delta += s[j][k].rbegin()->first;
            ll cur = delta + a[id][i];
            if (cur > best) {
                best = cur;
                type = 2;
                bi = i;
                bj = j;
                bk = k;
            }
        }
    }
    assert(best >= 0);
    res += best;
    if (type == 0) {
        f[bi]++;
        add(id, bi);
    } else if (type == 1) {
        int who = s[bi][bj].rbegin()->second;
        rem(who, bi);
        add(who, bj);

        f[bj]++;
        add(id, bi);
    } else if (type == 2) {
        int who = s[bj][bk].rbegin()->second;
        rem(who, bj);
        add(who, bk);

        who = s[bi][bj].rbegin()->second;
        rem(who, bi);
        add(who, bj);

        f[bk]++;
        add(id, bi);
    }
}

int main() {
    #ifdef LOCAL
    assert(freopen("c.in", "r", stdin));
    #else
    #endif
    int n = 0;
    forn (i, 3) {
        cin >> c[i];
        n += c[i];
    }
    forn (i, n) {
        forn (j, 3)
            cin >> a[i][j];
        push(i);
    }
    forn (i, 3)
        assert(f[i] == c[i]);
    cout << res << '\n';
}


Measured memory_bytes: 10752
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define LINF (1000000000000000000ll)

//typedef pair < int, int> P;
ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b)
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcd(ll a, ll b) {//最小公倍数を求める　b=0のときaを返す
	if (b == 0) return a;
	return (a / gcd(a, b)) * b;
}
vector<int> calc(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p;
}
string S, T;
int A, B;
string U;
int main()
{
	cin >> S >> T;
	cin >> A >> B;
	cin >> U;
	if (U == S) {
		A--;
	}
	else {
		B--;
	}
	cout << A << " " << B << endl;

}

Measured memory_bytes: 256
def check_4(i, j):
    hi = [1, 0, -1, 0]
    wi = [0, -1, 0, 1]
    for p in range(4):
        if 0 <= i+hi[p] < H and 0 <= j+wi[p] < W:
            if cambus[i+hi[p]][j+wi[p]] == '#':
                return True
    return False


H, W = map(int, input().split(' '))
cambus = [input() for i in range(H)]

for i in range(H):
    for j in range(W):
        if cambus[i][j] == '#':
            if not check_4(i, j):
                print('No')
                exit()
print('Yes')


Measured memory_bytes: 3064
#!/usr/bin/env python3
# 105

n = int(input().strip())

def enum(i):
    result = []
    j = 1
    while j**2 <= i:
        if i % j == 0:
            result.append(j)
            #print("j: {}".format(j))
            #if j != 1 and j**2 != i:
            if j**2 != i:
                result.append(n/j)
                #print("n/j: {}".format(n/j))
        j += 1
    return result

num = 0
for i in [i for i in range(1,n+1) if i %2 ==1]:
    result = enum(i)
    if len(result) == 8:
        num += 1
print(num)


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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
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;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    string s;
    cin >> s;
    string s1="";
    string s2="";
    
    int n=s.size()-1;
    for(int i=0;i<s.size()/2;i++){
        if(s[i]!=s[n]){
            cout << "No" << endl;
            return 0;
        }
        s1+=s[i];
        s2+=s[n];
        n--;
    }

    int x = s1.size()-1;
    for(int i=0;i<s1.size()/2;i++){
        if(s1[i]!=s1[x]){
            cout << "No" << endl;
            return 0;
        }
        x--;
    }

    int y = s2.size()-1;
    for(int i=0;i<s2.size()/2;i++){
        if(s2[i]!=s2[y]){
            cout << "No" << endl;
            return 0;
        }
        y--;
    }
    cout << "Yes"<< endl;
    return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n = II()
    as_ = LI()
    ans = 0
    ans = sum([1/a for a in as_])
    print(1/ans)
if __name__ == '__main__':
    main()

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

int main() {
    int N,K;cin>>N>>K;
    vector<int> p(N);
    for (int i = 0; i < N; i++){
        cin>>p[i];
    }
    int ans=0;
    for (int i = 0; i < K; i++){
        ans+=p[i]+1;
    }
    int sum=ans;
    for (int i = 0; i < N-K; i++){
        sum=sum-p[i]+p[i+K];
        ans=max(ans,sum);
    }
    cout<<ans/2;
    if(ans%2!=0)cout<<".5"<<endl;
}

Measured memory_bytes: 4000
N, K = map(int, input().split())
A = list(map(int, input().split()))
a = 0
b = 0
for i in range(N):
  for j in range(i+1,N):
    if A[i] < A[j]:
      b += 1
    elif A[i] > A[j]:
      a += 1
ans = a*(K*(K+1))//2 + b * (K*(K-1))//2
ans = ans % (10**9 + 7)
print(ans)

Measured memory_bytes: 3188
//package Contest088;

import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
            int n  = sc.nextInt();
            int arr[] = new int[n];
            for(int i=0;i<n;i++)
                arr[i] = sc.nextInt();
            Arrays.sort(arr);
            int alice=0,bob =0;
            for(int i=arr.length-1;i>=0;i--)
            {
                if(i%2==0)
                    alice+=arr[i];
                else
                    bob+=arr[i];
            }
            if(alice>bob)
                out.println(alice-bob);
            else
                out.println(bob-alice);
        out.flush();
    }
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define ll long long

using namespace std;

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

    int a, b, c;
    cin >> a >> b >> c;
    map<int, int> map;
    map[1] = a;
    map[2] = b;
    map[3] = c;

    int res = 10e5;
    int cost;
    vector<int> v(3);
    iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
    do {
        cost = abs(map[v[2-1]]-map[v[1-1]]) + abs(map[v[3-1]]-map[v[2-1]]);
        res = min(res, cost);
    } while( next_permutation(v.begin(), v.end()) );     // 次の順列を生成

    cout << res << '\n';

}


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

using namespace std;

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;


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

    int ans=0;
    bool jdg=true;
    
    if(s.size()==1){
         cout<<0<<endl;
         return 0;
     }

    while(jdg){
        jdg=false;
        rep(i,s.size()-1){
            if(s[i]!=s[i+1]){
                s.erase(s.begin()+i,s.begin()+(i+2));
                ans+=2;                
                jdg=true;
                break;
            }
        }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 512
#include<stdio.h>
int  linear(int , int [], int );
#define N 10000
int main() {
  int n,q,A[N+1],key,sum = 0,i;

  scanf("%d",&n);
for(i=0;i<n;i++)  scanf("%d", &A[i]);

  scanf("%d", &q);
for(i=0;i<q;i++) {
    scanf("%d", &key);
    if(linear(key,A,n)) sum++;
}
  printf("%d\n",sum);

  return 0;
}

/*int  linear(int key, int A[],int n) {
  int i = 0;
   A[n] = key;
   while(A[i] != key) i++;
  return i != n;
}*/

int  linear(int key, int A[],int n) {
  int i = 0;
   A[n] = key;
   while(A[i] != key) i++;
  return i != n;
}

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

typedef long long ll;

int main()
{
   ll l , r;
   cin>>l>>r;
   if( r -l >= 2019 )
   {
       cout<<0;
       return 0;
   }
   ll ans = INT_MAX;
   for(int i=l;(i<=l + 2019 && i<=r) ;i++   )
   {
       for(int j = i+1; (j<= l+2019 && j<= r) ; j++ )
       {
           ll temp =( (i%2019 )*( j%2019) )%2019;
           ans = min( ans , temp );
       }
   }
   cout<<ans;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
vector<long long> a[100010];

int main(){
	long long n,m,x,y,sum = 0;
	cin >> n >> m;
	for(int i = 0;i < n;i++){
		cin >> x >> y;
		a[x].push_back(y);
	}
	priority_queue<long long> p;
	for(long long i = 1;i <= m;i++){  //看作步数 ,以m为上限 
		for(long long j = 0;j < a[i].size();j++){
			p.push(a[i][j]);
		}
		if(!p.empty()){
			sum += p.top();
			p.pop();
		}
	}
	cout << sum << endl;
	return 0;
} 

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

int main() {
    ll A, B, V, W, T;
    cin >> A >> V;
    cin >> B >> W;
    cin >> T;
    if (A < B) {
        if (A+T*V >= B+T*W) cout << "YES" << endl;
        else cout << "NO" << endl;
    }else {
        if (B-T*W >= A-T*V) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
n,k,q=map(int,input().split())
#print(n,k,q)
a=[k-q]*n
for i in range(q):
    c=int(input())
    c-=1
    a[c]+=1
for i in range(n):
    if(a[i]>0):
        print("Yes")
    else :
        print("No")

Measured memory_bytes: 6572
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#define PI 3.14159265359
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pai;
typedef pair<ll, ll> pal;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

ll fact[2000002];

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

ll modinv(ll a){
	return modpow(a, MOD-2);
}

ll nCr(ll n, ll r){
	if (n < r) return 0;
	return ((fact[n]*modinv(fact[n-r]))%MOD*modinv(fact[r]))%MOD;
}

int main(){
	int r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	fact[0] = 1;
	for (int i = 1; i <= 2000001; i++){
		fact[i] = (fact[i-1]*i)%MOD;
	}

	ll ans = 0;
	for (int i = c1; i <= c2; i++){
		ans += nCr(r2+i+1, i+1) - nCr(r1+i, i+1);
		ans %= MOD;
		if (ans < 0) ans += MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 19272
using System;
using System.Collections;
class Program
{
    public static void Main()
    {
        string s = Console.ReadLine();
        ArrayList str = new ArrayList();
        int count = 0;
        for (int i = 0; i < s.Length; i++)
        {
            if (s[i] != 'B')
            {
                str.Add(s[i]);
                count++;
            }
            else if (count != 0)
            {
                count--;
                str.RemoveAt(count);
            }
        }
        for (int i = 0; i < str.Count; i++)
            Console.Write((char)str[i]);
        Console.WriteLine();
    }
}

Measured memory_bytes: 11092
#include<stdio.h>
int main()
{
    int a,b,c,r;
    scanf("%d%d%d",&a,&b,&c);
    r=c-(a-b);
    if(a-b>=c){
        printf("0");
    }
    else if(a-b<c){
        printf("%d",r);
    }
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(){
  int A,B;
  scanf("%d %d",&A,&B);
  
  if(9<A){
    printf("-1\n");
  }else if(9<B){
   printf("-1\n");
  }else{
   printf("%d\n",A*B);
  }
  return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef pair <ll, ll> pll;
 
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const ll Inf = 1LL << 62;
 
int main() {
#ifdef Mr_Emrul
	freopen("inputf.in", "r", stdin);
#endif /// Mr_Emrul
 
	long double a, b;
	cin >> a >> b;
	ll l = 0, r = 1e18;
	ll ans = 0;
	while(l <= r) {
		ll mid = (l + r) >> 1;
		if((long double) mid / b >= a) {
			ans = mid;
			r = mid - 1;
		}
		else {
			l = mid + 1;
		}
	}
	long double here = a * b;
	if(abs(here - (long double) ans) > 1e-15) {
		ans--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3732
#include <vector>
#include <cstdio>
#include <typeinfo>
#include <string>
#include <iostream>
using namespace std;

string input;
int a,b,c,d;
int main()
{
  cin >> input;
  a = input[0] - '0';
  b = input[1] - '0';
  c = input[2] - '0';
  d = input[3] - '0';

  if(a-b+c+d == 7) printf("%d-%d+%d+%d=7\n", a,b,c,d);
  else if(a-b+c-d == 7) printf("%d-%d+%d-%d=7\n", a,b,c,d);
  else if(a-b-c+d == 7) printf("%d-%d-%d+%d=7\n", a,b,c,d);
  else if(a-b-c-d == 7) printf("%d-%d-%d-%d=7\n", a,b,c,d);
  else if(a+b-c+d == 7) printf("%d+%d-%d+%d=7\n", a,b,c,d);
  else if(a+b-c-d == 7) printf("%d+%d-%d-%d=7\n", a,b,c,d);
  else if(a+b+c-d == 7) printf("%d+%d+%d-%d=7\n", a,b,c,d);
  else if(a+b+c+d == 7) printf("%d+%d+%d+%d=7\n", a,b,c,d);

  return 0;
}


Measured memory_bytes: 256
import re
import sys
INF=10000000000000
sys.setrecursionlimit(10**6)

def merge(A,left,mid,right):
    count=0
    L=A[left:mid]
    R=A[mid:right]
    L.append(INF)
    R.append(INF)
    i=0
    j=0
    for k in range(left,right):
        if(L[i] <= R[j]):
            A[k] = L[i]
            i+=1
            count+=1
        else:
            A[k] = R[j]
            j+=1
            count+=1
    return count

def mergeSort(A,left,right):
    count=0
    if(left+1<right):
        mid=(left+right)//2
        count+=mergeSort(A, left, mid)
        count+=mergeSort(A, mid, right)
        count+=merge(A, left, mid, right)
    return count

count=0
n=int(input())
s=list(map(int,input().split()))
count=mergeSort(s, 0, n)

print(re.sub("[\[\]\,]","",str(s)))
print(count)


Measured memory_bytes: 78064
#!/usr/bin/env python3
def main():
    N, K = map(int, input().split())
    P = [int(x) - 1 for x in input().split()]
    C = [int(x) for x in input().split()]

    ans = -10 ** 9
    # 全ての点を始点とした場合を考える(N通り)
    for start in range(N):
        # ループを探索．スコアの累積和も勘定しておく
        now = start
        loop = []
        total = 0
        for _ in [0] * N:  # while Trueでもおｋ
            now = P[now]
            loop.append(C[now])
            total += C[now]
            if now == start:
                break
        # 最大スコアを探索
        length = len(loop)
        score = 0
        for i in range(length):
            score += loop[i]
            # 操作回数 >= Kなら，ループ途中でも探索終了
            if i >= K:
                break
            # ループを周回するので，それを利用して探索を省略
            res = score
            if total > 0:
                laps = (K - (i + 1)) // length
                res += total * laps
            ans = max(ans, res)
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

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

int N, M, P;

int F[10][10][10];
int Fsize[10][10];

int ansf;

#define ck(x) (0<=(x)&&(x)<N)
#define ck3(x,y,z) (ck(x)&&ck(y)&&ck(z))

void dfs(int x, int y, int z,
         int dx, int dy, int dz, int col, int cnt) {
  
  if(col != F[z][y][x]) { return; }
  if(cnt == M-1) {
    ansf += col; return;
  }
  int nx = x+dx, ny = y+dy, nz = z+dz;
  if(!ck3(nx, ny, nz)) return;
  dfs(nx, ny, nz,
      dx, dy, dz, col, cnt+1);
}

int main() {
  
  while(cin >> N >> M >> P && (N|M|P)) {
    rep(i, 10) rep(j, 10) {
      Fsize[i][j] = 0;
      rep(k, 10) F[i][j][k] = 0;
    }
    
    ansf = 0;
    int xs[P], ys[P];
    rep(i, P) {
      cin >> xs[i] >> ys[i]; xs[i]--, ys[i]--;
    }
    rep(turn, P) {
      int x = xs[turn], y = ys[turn];
      F[Fsize[y][x]++][y][x] = turn%2 ? 1 : -1;
      
      rep(i, N) rep(j, N) rep(k, N)
        REP(dx, -1, 2) REP(dy, -1, 2) REP(dz, -1, 2) {
        if(dx == 0 && dy == 0 && dz == 0) continue;
        rep(ci, 2) {
          dfs(i, j, k, dx, dy, dz, ci%2 ? 1:-1, 0);
        }
        if(ansf) {
          if(ansf == -1) { cout << "Black " << turn+1 << endl; }
          if(ansf == 1) { cout << "White " << turn+1 << endl; }
          goto exit;
        }
      }
    }
    
  exit:;
    if(!ansf) { cout << "Draw\n"; }
  }
  
  return 0;
}

Measured memory_bytes: 1168
#include<iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main(){
  int n, a, b;
  cin >> n >> a >> b;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
	int c = 0, t = i;
  for (int j = 0; j < 5; j++) {
    c += t % 10; t /= 10; 
  }
    if  (a <= c && c <= b ) ans += i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	s := readLineInt()[0]
	a := make([]int, 0, 1e6)
	a = append(a, s)
	Loop(1, 1e7, func(i int) {
		Current := f(a[i-1])
		for _, v := range a {
			if v == Current {
				fmt.Println(i + 1)
				os.Exit(0)
			}
		}
		a = append(a, Current)
	})
}

func f(n int) int {
	if (n % 2) == 0 {
		return n / 2
	} else {
		return (3 * n) + 1
	}
}

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

func readLineInt() []int {
	result := make([]int, 0)
	for _, v := range strings.Split(readLine(), " ") {
		i, _ := strconv.Atoi(v)
		result = append(result, i)
	}
	return result
}

var reader = bufio.NewReaderSize(os.Stdin, 1e6)

func readLine() string {
	result := make([]byte, 0, 1e6)
	for {
		line, remains, e := reader.ReadLine()
		if e != nil {
			panic(e)
		}
		result = append(result, line...)
		if !remains {
			break
		}
	}
	return string(result)
}

func Loop(start, end int, f func(i int)) {
	for i := start; i < end; i++ {
		f(i)
	}
}

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

int main(){
    char ch;
    int cnt[26]={};
    
    while(cin>>ch){
        ch=tolower(ch);
        if (isalpha(ch)){
            cnt[ch-'a']++;
        }
    }
    
    for (int i=0;i<26;i++){
        printf("%C : %d\n", i+'a',cnt[i]);
        
    }
    
    return 0;
}


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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

#define INF 1e9
#define MOD 1000000007
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (a); i > (b); i--)
#define each(x, v) for (auto& x: (v))
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl

void solve();
void in(){} template<class T, class... U> void in(T &t, U &...u){ cin >> t; in(u...); }
int main() { cin.tie(0); ios::sync_with_stdio(0); solve(); }

void solve() {
  int N;
  in(N);
  vi H(N);
  each(x, H) in(x);
  int ans = 0;
  int tmp = 0;
  rep(i, 0, N - 1) {
    if (H[i + 1] > H[i]) {
      tmp = 0;
    } else {
      ans = max(ans, ++tmp);
    }
  }
  print(ans);
}


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

int main() {
  string s;cin >> s;
  bool flg = true;
  for(int i = 0; i < s.size(); i++){
    if((i+1) % 2 == 0){
      if(s[i] == 'R'){
        flg = false;
      }
    }else{
      if(s[i] == 'L'){
        flg = false;
      }
    }
  }
  if(flg){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double


// ABC072C - Together
int main(){
  int n; // 1 <= n <= 1e5
  cin >> n;
  vector<int> a(n, 0);
  vector<int> nums(1e5+10, 0);
  rep(i, n) {
    cin >> a[i];
    nums[a[i]]++;
  }

  int maxNum = 0;
  for (int i = 0; i < 1e5; ++i) {
    int tmp = nums[i];
    if (i >= 1) {
      tmp += nums[i-1];
    }
    tmp += nums[i+1];
    if (maxNum < tmp) {
      maxNum = tmp;
    }
  }

  cout << maxNum << endl;
  return 0;
}



Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int MAX_N = 2000000;

ll inv[MAX_N], fac[MAX_N], fiv[MAX_N];

void COMinit() {
    inv[1] = fac[1] = fiv[1] = inv[0] = fac[0] = fiv[0] = 1;
    for (ll i = 2; i < MAX_N; i++) {
        fac[i] = fac[i - 1] * i % MOD; // n!
        inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD; // n^-1
        fiv[i] = fiv[i - 1] * inv[i] % MOD; // (n!)^-1
    }
}

ll com(ll n, ll k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * fiv[k] % MOD * fiv[n-k] % MOD;
}

ll pow_mod(ll num, ll pow, ll mod) {
    ll prod = 1;
    num %= mod;
    while (pow > 0) {
        if (pow & 1) prod = prod * num % mod;
        num = num * num % mod;
        pow >>= 1;
    }
    return prod;
}

int main() {
    ll n, a, b, c;
    cin >> n >> a >> b >> c;

    COMinit();

    ll A = a * inv[a + b] % MOD;
    ll B = b * inv[a + b] % MOD;

    ll ret = 0;
    ll An = pow_mod(A, n, MOD);
    ll Bn = pow_mod(B, n, MOD);

    for (ll i = 0; i < n; i++) {
        ll tmp = An * pow_mod(B, i, MOD) % MOD + Bn * pow_mod(A, i, MOD) % MOD;
        tmp = tmp % MOD * com(n + i - 1, i) % MOD * (n + i) % MOD;
        ret = (ret + tmp) % MOD;
    }

    cout << ret * 100 % MOD * inv[a + b] % MOD << "\n";
    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


class BIT{
  public:
  vector<ll> s;
  const ll n;
  BIT (ll n_):s(n_+1,0),n(n_){}
  //[0,i],1-index
  ll sum(ll i){
    ll k = 0;
    while(i > 0){
      k += s[i];
      i -= i & (-i);
    }
    return k;
  }
  //[l,r],1-index
  ll sum(ll l,ll r){
    return sum(r)-sum(l-1);
  }
  // 1-index
  void add(ll pos,ll val){
    while(pos <= n){
      s[pos] += val;
      pos += pos & (-pos);
    }
  }
};

int main(){
  
  ll n,k;
  cin >> n >> k;
  vector<ll> v(n+10);
  rep(i,n)cin >> v[i+1];
  BIT bit(n+10);
  rep(i,n){
    bit.add(max(1ll,i+1-v[i+1]),1);
    bit.add(min(n,i+1+v[i+1])+1,-1);
  }
  k--;
  while(k--){
    BIT nbit(n+10);
    rep(i,n){
      ll l = bit.sum(i+1);
      nbit.add(max(i+1-l,1ll),1);
      nbit.add(min(n,i+1+l)+1,-1);
    }
    bit.s = nbit.s;
    if(bit.sum(1) == n && bit.sum(n) == n)break;
  }
  rep(i,n)cout << bit.sum(i+1) << " ";
  cout << endl;



  




  return 0;
}

Measured memory_bytes: 8016
#include<bits/stdc++.h>
#define mod 998244353
#define ll long long
using namespace std;
int main()
{
	ll n,a[1000000],flag=0;
	while(cin>>n)
	{
	for(int i=1;i<=n;i++)
		cin>>a[i];
		if(a[1]!=0)
		{
			cout<<"0";
			continue;
		}
		sort(a+1,a+n+1);
		for(int i=2;i<=n;i++)
		{
			if(abs(a[i]-a[i-1]>1))
			{
				flag=1;
				break;
			}
		}
		if(flag==1)
		{
			cout<<"0";
			continue;
		}
		ll i=2,ans=1,t=0;
		for(;a[i]==1;i++)
			t++;
		for(;i<=n;)
		{
			ll d=a[i],s=1,num=0;
			for(;a[i]==d&&i<=n;i++)
			{
				num++;
				s = (s*t)%mod;
			}
			ans=(ans*s)%mod;
			t=num;
		}
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 2944
from heapq import heappush, heappop
N,C=list(map(int,input().split()))

arr=[]
for _ in range(N):
    arr.append(list(map(int,input().split())))

arr=sorted(arr, key=lambda x:x[0])

ans=0
cnt=0
tmp=0
recorder = [(10**10,31)]

for x in arr:
    s, t, c= x
    while recorder[0][0]<s:
        heappop(recorder)
        cnt-=1
        cnt+=tmp
        tmp=0
    
    for i in range(len(recorder)):
        if recorder[i][0] == s and recorder[i][1] ==c:
            cnt-=1
            tmp+=1
            break
    heappush(recorder,(t,c))
    cnt+=1
    if ans < cnt:
        ans=cnt            
print(ans)

Measured memory_bytes: 29960
/*
由于最后的结果是三个值相加 当所有数全为正数时 只需把每一个蛋糕的
三个值相加 计算出贡献 贪心地取最大就可以了
而数中有负数 则枚举一下每个值的正负性 再计算贡献
*/

#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define MAXN 1005
#define LL long long
int N,M;
LL ans;
LL x[MAXN],y[MAXN],z[MAXN],r[MAXN];
bool cmp(LL p,LL q)
{
	return p>q;
}
void Solve(int m,int n,int k)
{
	memset(r,0,sizeof(r));
	LL res=0;
	for(int i=1;i<=N;i++)
		r[i]=x[i]*m+y[i]*n+z[i]*k;
	sort(r+1,r+N+1,cmp);
	for(int i=1;i<=M;i++)
		res+=r[i];
	if(res>ans) ans=res;
}
int main()
{
	scanf("%d %d",&N,&M);
	for(int i=1;i<=N;i++)
		scanf("%lld %lld %lld",&x[i],&y[i],&z[i]);
	for(int i=-1;i<=1;i+=2)
		for(int j=-1;j<=1;j+=2)
			for(int k=-1;k<=1;k+=2)
				Solve(i,j,k);
	printf("%lld\n",ans);
}

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

template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

int main() {
    int N; cin >> N;
    int Q; cin >> Q;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    
    vector<int> lefts(Q), rights(Q), ids(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> lefts[i] >> rights[i];
        --lefts[i];
        ids[i] = i;
    }
    sort(ids.begin(), ids.end(), [&](int i, int j) {
            return rights[i] < rights[j];});

    BIT<int> bit(N+5);
    vector<int> prev(1100000, -1);
    vector<int> res(Q, 0);
    int r = 0;
    for (auto i : ids) {
        for (; r < rights[i]; ++r) {
            bit.add(prev[a[r]]+2, r+2, 1);
            prev[a[r]] = r;
        }
        int tmp = bit.sum(lefts[i]+1, lefts[i]+2);
        res[i] = max(res[i], tmp);
    }
    for (int i = 0; i < Q; ++i) cout << res[i] << endl;
}

Measured memory_bytes: 21728
#include<cstdio>
using namespace std;
char s[110][110];
int n,m;
int main()
{
	scanf("%d%d",&n, &m);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
			scanf(" %c", &s[i][j]);
		
	}
	for(int i=0;i<n;i++)
	{
		bool flag=false;
		for(int j=0;j<m;j++)
			if(s[i][j]=='#')
				flag=true;
		if(flag==true)
			continue;
		for(int j=0;j<m;j++)
			s[i][j]='/';
	}
	for(int i=0;i<m;i++)
	{
		bool flag=false;
		for(int j=0;j<n;j++)
			if(s[j][i]=='#')
				flag=true;
		if(flag==true)
			continue;
		for(int j=0;j<n;j++)
			s[j][i]='/'; 
	}
	for(int i=0;i<n;i++)
	{
		bool flag=false;
		for(int j=0;j<m;j++)
			if(s[i][j]!='/')
			{
				printf("%c", s[i][j]);
				flag=true;
			}
		if(flag==true)
			printf("\n");
	}	
	return 0;
 } 

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

using namespace std;

const int maxn = 1e5 + 10;

int n, d;
int a[maxn], cnt[maxn];

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", a + i);
		cnt[a[i]]++;
		d = max(d, a[i]);
	}
	int lim = (d + 1) / 2;
	int sum = 0;
	for (int i = lim + 1; i <= d; ++i) {
		sum += (cnt[i] >= 2) ? cnt[i] : -sum;
	}
	sum += (cnt[lim] == 1 + d % 2) ? cnt[lim] : -sum;
	cout << (sum == n ? "Possible" : "Impossible") << endl;
	return 0;
}


Measured memory_bytes: 256