akhauriyash/Code-Regression huggingface dataset:
from functools import reduce
import sys
import numpy as np
MOD = 1000000007

buffer = sys.stdin.buffer
H, W = list(map(int,buffer.readline().split()))
S = np.frombuffer(buffer.read(H*(W+1)), dtype="B") == ord(".")
S = S.reshape((H,W+1))[:,:-1]
L = np.empty((H,W), dtype="i4")
R = np.empty((H,W), dtype="i4")
U = np.empty((H,W), dtype="i4")
D = np.empty((H,W), dtype="i4")
 
L[:,0] = S[:,0]
for i in range(1,W):
    L[:,i] = (L[:,i-1] + 1) * S[:,i]
 
R[:,-1] = S[:,-1]
for i in range(1,W):
    R[:,-1-i] = (R[:,-i] + 1) * S[:,-1-i]
 
U[0] = S[0]
for i in range(1,H):
    U[i] = (U[i-1] + 1) * S[i]
 
D[-1] = S[-1]
for i in range(1,H):
    D[-1-i] = (D[-i] + 1) * S[-1-i]
 
score = L + R + U + D - 3
print(int(score.max()))

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

using namespace std;

//FILE *fi=freopen("1.txt","r",stdin);

int n;
string s;

void nhap()
{
    scanf("%d",&n);
    cin>>s;
    s="1"+s;
}

void process()
{
    int dem=0,vt=1;
    while (vt<=n)
    {
        while (s[vt]==s[vt+1])
            vt++;
        dem++;
        vt++;
    }
    cout<<dem;
}

int main()
{
    nhap();
    process();
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define M (L+R)/2
#define N 500009
#define inf 99999999999
#define ll long long
#define mod 1000000007
#define sz size();
using namespace std;
ll n,m,ans;
int main(){

	ios::sync_with_stdio(0);
	
	cin>>n>>m;
	ans=n*(n-1)/2;
	ans+=m*(m-1)/2;
	cout<<ans<<endl;

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	string S; cin >> S;
	ll ans = 0, count = 0;
	for (int i = S.size() - 1; i >= 0; i--) {
		if (S[i] == 'W')  count++;
		else ans += count;
	}
	cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int N;
  cin >> N;
  vector<ll> a(N);
  cin >> a;
  if (N % 2 == 1) {
    ll sum = accumulate(all(a), 0ll);
    if (sum % 2ll == 0ll)
      cout << "Second" << endl;
    else
      cout << "First" << endl;
    return;
  }
  ll X = accumulate(all(a), 0ll) - *min_element(all(a)) * (ll)(N);
  // dmp(X);
  vector<int> p(N), q(N);
  if (N % 2 == 1) {
    for (int i = 0; i < N - 1; i++) p[i] = i % 2;
    p[N - 1] = 2;
  } else {
    for (int i = 0; i < N; i++) p[i] = i % 2;
  }
  for (int i = 0; i < N; i++) {
    vector<int> to;
    if (i > 0) to.push_back(q[i - 1]);
    to.push_back(p[i]);
    to.push_back(p[(i + N - 1) % N]);
    for (int j = 0;; j++) {
      bool judge = true;
      for (int val : to) {
        if (val == j) {
          judge = false;
          break;
        }
      }
      if (judge) {
        q[i] = j;
        break;
      }
    }
  }
  // dmp(p);
  // dmp(q);
  ll m = *min_element(all(a));
  // dmp(m);
  int ret = -1;
  if (N % 2 == 1) {
    if (m % 2 == 0) {
      ret = p[(X + N - (m / 2) % N) % N];
    } else {
      ret = q[(X + N - (m / 2) % N) % N];
    }
  } else {
    if (m % 2 == 0) {
      ret = p[X % N];
    } else {
      ret = q[X % N];
    }
  }
  // dmp(ret);
  if (ret == 0)
    cout << "Second" << endl;
  else
    cout << "First" << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}



Measured memory_bytes: 6004
#import math

n=int(input())

ans=0
p=2
for p in range(2, int((n+0.5)**0.5)+1):
    if n%p==0:
        cnt=0
        while n%p==0:
            cnt+=1
            n//=p
        k=1
        while cnt>=k:
            cnt-=k
            k+=1
            ans+=1

if n>1:
    ans+=1

print(ans)


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

int main()
{

    int n ; 
    cin>>n; 

    int count =0 ,flag =0 ;
    for(int i=0;i<n; i++ )
    {
        int x ,y; 

        cin>>x>>y; 

        if(flag ==0 )
        if(x == y )
        {
            count++; 
        }
        else 
        {
            count =0 ; 
        }


        if(count == 3)
        {
            flag =1 ; 
        }



    }
    if(flag ==1  )
    {
        cout<<"Yes" ;
    }
    else 
    {
        cout<<"No";
    }

    
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	vector<int> c(n);
	vector<ll> ab(n);
	vector<ll> bc(n);
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	for (int i = 0; i < n; i++){
		cin >> b[i];
	}
	for (int i = 0; i < n; i++){
		cin >> c[i];
	}
	sort(a.begin(), a.end());
	sort(c.begin(), c.end());

	for (int i = 0; i < n; i++){
		//if (b[i] <= a[0]) ab[i] = 0;
		//else if (b[i] > a[n-1]) ab[i] = n;
		ab[i] = lower_bound(a.begin(), a.end(), b[i]) - a.begin();

		//if (b[i] >= c[n-1]) bc[i] = 0;
		//else if (b[i] < c[0]) bc[i] = n;
		bc[i] = c.end() - upper_bound(c.begin(), c.end(), b[i]);
	}
	ll ans = 0;
	for (int i = 0; i < n; i++){
		ans += ab[i]*bc[i];
	}
	cout << ans << endl;
	return 0;
 }



Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  if (S == "Sunny"){
    cout << "Cloudy" << endl;
  }
  else if (S == "Cloudy"){
    cout << "Rainy" << endl;
  }
  else if (S == "Rainy"){
    cout << "Sunny" << endl;
  }
}

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

int main() {
   int N, K;
   cin >> N >> K;
   map<int, int> mp;
   while (N--) {
      int a;
      cin >> a;
      mp[a]++;
   }
   vector<int> v;
   for (auto x : mp) {
      v.push_back(x.second);
   }
   sort(v.begin(), v.end());
   int ans = 0;
   int t = mp.size();
   for (int i = 0; i < t-K; i++) {
      ans += v[i];
   }
   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 10748
sx, sy, tx, ty = map(int, input().split())

dx = tx - sx
dy = ty - sy

route1 = 'R' * dx + 'U' * dy
route2 = 'L' * dx + 'D' * dy
route3 = 'L' + 'U' * (dy + 1) + 'R' * (dx + 1) + 'D'
route4 = 'R' + 'D' * (dy + 1) + 'L' * (dx + 1) + 'U'

ans = route1 + route2 + route3 + route4
print(ans)


Measured memory_bytes: 9096
using System;
using System.Linq;

namespace Aizu {
    public class OnlineJudge {
        static void Main() {
            var input = Console.ReadLine().Split().Select(int.Parse);
            int min = input.Min(), max = input.Max();

            while (min > 0) {
                var mod = max % min;
                max = min;
                min = mod;
            }

            Console.WriteLine(max);
        }
    }
}



Measured memory_bytes: 9400
#include<cstdio>
#include<vector>
#define mod 1000000007
using namespace std;
int n,x,y;
vector<int> g[100001];
long long dp[100001][2];
void dfs(int x,int y){
    dp[x][0]=1;
    dp[x][1]=1;
    for(int i=0;i<g[x].size();i++){
        if(g[x][i]!=y){
            dfs(g[x][i],x);
            dp[x][0]*=(dp[g[x][i]][0]+dp[g[x][i]][1]);
            dp[x][1]*=dp[g[x][i]][0];
            dp[x][0]%=mod;
            dp[x][1]%=mod;
        }
    }
    dp[x][0]%=mod;
    dp[x][1]%=mod;
}
int main(){
    scanf("%d",&n);
    for(int i=0;i<n-1;i++){
        scanf("%d %d",&x,&y);
        g[x].push_back(y);
        g[y].push_back(x);
    }
    dfs(1,0);
    printf("%lld\n",(dp[1][0]+dp[1][1])%mod);
}


Measured memory_bytes: 14208
// C版ダイクストラ
#include <stdio.h>
#define INF 10000000
#define MAX 10000
#define E_MAX 500000

// ====== Implement of Heap ======
int heap[E_MAX]={INF};
int eoh=1;

void swap(int* A, int* B){
    int temp = *A;
    *A = *B;
    *B = temp;
}

void minHeapify(int* A, int i){
  int h = eoh-1;
  int l = 2*i;
  int r = 2*i+1;
  int smallest;
  if ( l <= h && A[l] < A[i] )
    smallest = l;
  else
    smallest = i;

  if ( r<= h && A[r] < A[smallest])
    smallest = r;

  if (smallest != i){
    swap(&A[i], &A[smallest]);
    minHeapify(A, smallest);
  }
}

void insert2Heap(int v, int p){
  if (p == -1){
    p = eoh++;
    heap[p] = v;
    insert2Heap(v, p);
    return;
  }
  if (p == 1)
    return;
  int parent = heap[p/2];
  if (parent < v)
    return;
  swap(&heap[p/2], &heap[p]);
  insert2Heap(v, p/2);
}

int del(void){
  if (eoh == 1)
    return -1;
  int res = heap[1];
  heap[1] = heap[eoh-1];
  eoh--;
  minHeapify(heap, 1);
  return res;
}

int isEmpty(void){
    return eoh==1;
}
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

// ====== Implement of List Structure ======
struct Node {
    int to, cost;
    struct Node * next;
};

typedef struct Node * NodePointer;

NodePointer NIL;

NodePointer makeNode(int to, int cost){
    NodePointer newNode = (NodePointer)malloc(sizeof(struct Node));
    newNode->to = to;
    newNode->cost = cost;
    newNode->next = NIL;
    return newNode;
}

NodePointer insert2List(NodePointer head, int to, int cost){
    NodePointer ite, newNode;
    for (ite=head;ite->next!=NIL;ite=ite->next);
    newNode = makeNode(to, cost);
    ite->next = newNode;
    return newNode;
}


int* dijkstraAlgorithm(NodePointer vertex[], int n){
  int i;
  int* dist = malloc(sizeof(int)*n);

  // Initialize of distance, previous and Push all of vectex to queue 
  dist[0] = 0;
  for (i=0;i<n;i++){
    if (i!=0) dist[i] = INF;
    insert2Heap(i, -1);
  }

  while(!isEmpty()){
    int current = del();
    NodePointer ite;
    
    for (ite=vertex[current]->next;ite!=NIL;ite=ite->next){
      int alt = dist[current]+ite->cost;
      if ( dist[ite->to] > alt ){
        dist[ite->to] = alt;
        insert2Heap(ite->to, -1);
      }
    }
  }
  
  return dist;
}

int main(){
  NodePointer vertex[MAX];
  int i, j, n, *dist;
  scanf("%d", &n);
  NIL = makeNode(0, 0);
  for(i=0;i<n;++i) vertex[i] = makeNode(-1,INF);
  
  for (i=0;i<n;++i){
    int id, k;
    scanf("%d%d", &id, &k);
    for (j=0;j<k;++j){
      int node, cost;
      scanf("%d%d", &node, &cost);
      insert2List(vertex[id], node, cost);
    }
  }

  dist = dijkstraAlgorithm(vertex, n);

  for (i=0;i<n;++i)
    printf("%d %d\n", i, dist[i]);

  free(dist);
  return 0;
}


Measured memory_bytes: 17448
#include <stdio.h>

int main(void){
   
    int i,h,w;
    char a[101][101];
    
    scanf( "%d %d",&h,&w );
    
    for( i = 0; i < h; i++ ){
        scanf( "%s", &a[i][0] );
    }
    
    for( i = 0; i < w + 2; i++ ){
        printf("#");
    }
        printf("\n");
    
    for( i = 0; i < h; i++){
        printf("#%s#\n",a[i]);
    }
    
    for( i = 0; i < w + 2; i++ ){
        printf("#");
    }
    printf("\n");
    
    
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define mp make_pair
#define pi acos(-1)
#define mod 1000000007
#define line cout<<"------------------"<<endl
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
#define inf (ll)1e9+7
using namespace std;
ll n,k;
struct matrix
{
    ll mat[55][55] ;
    matrix()
    {
        memset(mat,0,sizeof mat);
    }
    matrix operator *(matrix a)
    {
        matrix d;
        for(ll i=0;i<n;i++)
        {
            for(ll j=0;j<n;j++)
            {
                for(ll k=0;k<n;k++)
                {
                    d.mat[i][j]+=mat[i][k]*a.mat[k][j];
                    d.mat[i][j]%=mod;
                }
            }
        }
        return d;
    }
    void identity()
    {
        for(ll i=0;i<n;i++) mat[i][i]=true;
    }
};
matrix power(matrix c, ll n1)
{
    matrix d;
    d.identity();
    while(n1)
    {
        if(n1%2) d=d*c;
        n1=n1>>1;
        c=c*c;
    }
    return d;
}
int  main()
{
    cin>>n>>k;
    matrix a,ans;
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<n;j++) cin>>a.mat[i][j];
    }
    ans=power(a,k);
    ll cnt=0;
    for( ll i=0;i<n;i++)
    {
        for(ll j=0;j<n;j++)
        {
            cnt+=ans.mat[i][j];
            cnt%=mod;
        }
    }
    cout<<cnt%mod<<endl;

}


Measured memory_bytes: 512
#include <algorithm>
#include <cstdio>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_reverse(i, n) for (int i = (n)-1; (i) >= 0; --(i))
#define whole(x) begin(x), end(x)
using namespace std;

int main() {
    while (true) {
        // input
        int n; scanf("%d", &n);
        if (n == 0) break;
        vector<pair<int, int> > books(n);
        repeat (i, n) {
            int r, w; scanf("%d%d", &r, &w);
            books[i] = { r, w };
        }
        // solve
        sort(whole(books));
        int max_r = books[n - 1].first;
        int sum_r = 0, sum_w = 0;
        for (auto book : books) {
            sum_r += book.first;
            sum_w += book.second;
        }
        int result;
        if (2 * max_r > sum_r) {
            int capacity = max_r - (sum_r - max_r);
            vector<char> dp(capacity + 1);
            dp[0] = true;
            repeat (i, n - 1) {
                int w = books[i].second;
                repeat_reverse (j, capacity + 1 - w) if (dp[j]) {
                    dp[j + w] = true;
                }
            }
            int knapsack = 0;
            repeat (j, capacity + 1) if (dp[j]) {
                knapsack = j;
            }
            result = 2 * max_r + sum_w - knapsack;
        } else {
            result = sum_r + sum_w;
        }
        // output
        printf("%d\n", result);
    }
    return 0;
}

Measured memory_bytes: 2664
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    char    buf[8];
    char    *pbuf;
    char    suit;
    unsigned int    n, rank, ii;
    unsigned short  s = 0, h = 0, c = 0, d = 0;
    
    fgets(buf, sizeof(buf), stdin);
    n = atoi(buf);
    
    for(ii = 0; ii < n; ii++){
        fgets(buf, sizeof(buf), stdin);
        suit = buf[0];
        pbuf = &buf[2];
        rank = atoi(pbuf);
        switch(suit){
            case 'S':
                s |= 1 << (rank - 1);
                break;
            case 'H':
                h |= 1 << (rank - 1);
                break;
            case 'C':
                c |= 1 << (rank - 1);
                break;
            case 'D':
                d |= 1 << (rank - 1);
                break;
            default:
                break;
        }
    }
    
    for(ii = 0; ii < 13; ii++){
        if((s >> ii) % 2 == 0){
            printf("S %d\n", ii + 1);
        }
    }
    for(ii = 0; ii < 13; ii++){
        if((h >> ii) % 2 == 0){
            printf("H %d\n", ii + 1);
        }
    }
    for(ii = 0; ii < 13; ii++){
        if((c >> ii) % 2 == 0){
            printf("C %d\n", ii + 1);
        }
    }
    for(ii = 0; ii < 13; ii++){
        if((d >> ii) % 2 == 0){
            printf("D %d\n", ii + 1);
        }
    }

    return 0;
}


Measured memory_bytes: 2108
/*********************
*  Author: xuziyuan  * 
*********************/
 
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <LL,LL>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair
 
using namespace std;
 
LL n,m,x,y,re[60],ans=0,pw[60];
vector <pii> g[60];
map <pii,LL> mp;
bool vis[60];
 
bool dfs(LL pos,LL to,LL k)
{
  if(vis[pos]) return false;
  vis[pos]=true;
  bool flg=0;
  rep(i,g[pos].size())
  {
    if(g[pos][i].fi==to)
    {
      re[k]|=(LL)pow(2,mp[mpr(pos,g[pos][i].fi)]);
      return true;
    }
    flg|=dfs(g[pos][i].fi,to,k);
    if(flg)
    {
      re[k]|=(LL)pow(2,mp[mpr(pos,g[pos][i].fi)]);
      return true;
    }
  }
  return false;
}
 
int main()
{
  pw[0]=1;
  repn(i,52) pw[i]=pw[i-1]*2;
  cin>>n;
  rep(i,n-1)
  {
    cin>>x>>y;
    g[x].pb(mpr(y,i+1));
    g[y].pb(mpr(x,i+1));
    mp[mpr(x,y)]=mp[mpr(y,x)]=i+1;
  }
  cin>>m;
  rep(i,m)
  {
    cin>>x>>y;
    memset(vis,0,sizeof(vis));
    dfs(x,y,i);
  }
  rep(i,(1<<m))
  {
    LL cnt=0,now=0;
    rep(j,m)
    {
      if((i&(1<<j))==0) continue;
      now|=re[j];
      cnt++;
    }
    LL c=0;
    while(now>0)
    {
      c+=now%2;
      now/=2;
    }
    if(cnt&1) ans-=pw[n-1-c];
    else ans+=pw[n-1-c];
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
use proconio::input;
use std::cmp::max;

fn main() {
    input! {
        a: i64,
        b: i64,
        n: i64,
    }

    let f = F { a, b };

    let ans = if n >= b - 1 {
        f.f(b - 1)
    } else {
        f.f(n)
    };

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

struct F {
    a: i64,
    b: i64,
}

impl F {
    fn f(&self, x: i64) -> i64 {
        let a = self.a;
        let b = self.b;
        (a * x) / b - a * (x / b)
    }
}


Measured memory_bytes: 2064
#include<bits/stdc++.h>
using namespace std;
#define T top()
#define E end()
#define PS push
#define Q queue
#define PP pop()
#define L0 (LL)0
#define V vector
#define ST stack
#define FI first
#define MAX 4e18
#define MIN -MAX
#define DQ deque
#define RE rend()
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define SE second
#define DL double
#define G getline
#define IN insert
#define endl "\n"
#define EM empty()
#define RB rbegin()
#define PSB push_back
#define PI acos(-1.00)
#define PPB pop_back()
#define PSF push_front
#define ub upper_bound
#define lb lower_bound
#define MD 1000000007
#define PPF pop_front()
#define LL long long int
#define PQ priority_queue
#define N cout<<"NO"<<endl
#define Y cout<<"YES"<<endl
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define UOSMOY v.C;w.C;ww.C;u.C;uu.C;uo.C;vo.C;vu.C;ab.C;bc.C;cc.C;uuu.C;a.C;b.C;c.C
V<LL>v;
V<LL>w,ab,bc;
set<LL>uo;
map<LL,LL>u,uc;
map<LL,LL>ww,cc;
LL ar[120005];
LL br[500005];
LL cr[500][500];
V<pair<LL,LL> >uu;
map<LL,V<LL> >uuu;
map<pair<LL,LL>,LL> vo;
map<pair<LL,LL>,LL> vu;
int main()
{
//  BRR;
//  file;
    FAST;
    char ch;
    string a,b,c,str;
    DL x,y,d,e,f,g,h;
    LL n,m,i,j,k,p,q,o,l,s,tt=1,t,z,aa,r=0;
    while(tt--)
    {
//        UOSMOY;
        cin>>n;
        k=0;
       for(i=0;i<n;i++)
       {
           cin>>o;
           v.PSB(o);
           k^=o;
           w.PSB(k);
       }
       for(i=0;i<n;i++)
       {
           l=v[i]^k;
           cout<<l<<" ";
       }
       cout<<endl;
    }
    return 0;
    //IN
    //AL
}


Measured memory_bytes: 6688
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = Math.max(a,b);
		System.out.println(Math.max(2*c-1,a+b));
  }
}


Measured memory_bytes: 21844
import java.util.*;
import java.util.Map.Entry;
 
 
 class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
	 static long[] ans;
	 static boolean[] visit;
    public static void main(String[] args) {
    	
        Scanner sc = new Scanner(System.in);
        int N= sc.nextInt();
        int Q= sc.nextInt();
        for(long i=0;i<N;i++)list.add(new ArrayList<Integer>());
		int[] a = new int[N];
		int[] b = new int[N];
		for(int i=0;i<N-1;i++){
			a[i]=sc.nextInt()-1;
			b[i]=sc.nextInt()-1;
        	list.get(a[i]).add(b[i]);
        	list.get(b[i]).add(a[i]);
		}
        ans=new long[N];
        visit = new boolean[N];
		for(int i=0;i<Q;i++) {
			ans[sc.nextInt()-1]+=sc.nextInt();
//	        System.out.println("aa");			
		}
		dfs(0);
			
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < ans.length; i++) {
			if (i == ans.length - 1) {
				sb.append(ans[i]);
			} else {
				sb.append(ans[i]);
				sb.append(" ");
			}
		}
        System.out.println(sb);			
    }
    
	static void dfs(int now) {
		visit[now]=true;
		int next =0;
		for(int i=0;i<list.get(now).size();i++) {
			next = list.get(now).get(i);
			if(visit[next] == true)continue;
			ans[next] = ans[next]+ ans[now];
			dfs(next);
		}
	}
 
}

Measured memory_bytes: 226380
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
int MOD = 1e9+7;

ll fact(int n) {
    if (n==1) return 1;
    return n*fact(n-1)%MOD;
}

int main(){
    int n;
    cin >> n;
    cout << fact(n) << endl; 
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main (void){
    int a,i,t,n,s,f,kei;
    for(;;){
        scanf("%d",&t);
        if(t==0)break;
        scanf("%d",&n);
        kei=0;
        for(i=0;i<n;i++){
            scanf("%d%d",&s,&f);
            kei=kei+(f-s);
        }
        if(t<=kei)printf("OK\n");
        else printf("%d\n",t=t-kei);
    }
return 0;
}

Measured memory_bytes: 612
#include <stdio.h>
#include <string>
#include <iostream>

#define LEN 1000000

using namespace std;

typedef struct Node{
	unsigned int key;
	struct Node *nPrev;
	struct Node *nNext;
} Node;

Node dummy;
unsigned int sum = 0;
void insert(unsigned int n);
void deleteNode(unsigned int n);
void deleteFisrt();
void deleteLast();
void display();

int main() {
	string command;
	int n;
	unsigned input;
	dummy.nPrev = NULL;
	dummy.nNext = NULL;

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		cin >> command;
		if (command == "insert") {
			scanf("%u", &input);
			insert(input);
		}
		else if (command == "delete") {
			scanf("%u", &input);
			deleteNode(input);
		}
		else if (command == "deleteFirst") {
			deleteFisrt();
		}
		else if (command == "deleteLast") {
			deleteLast();
		}
		else {
			return -1;
		}
	}
	display();
	return 0;
}

// 先頭に挿入する
void insert(unsigned int n) {
	if (NULL == dummy.nPrev || NULL == dummy.nNext) {
		Node *node = new Node;
		node->key = n;
		node->nPrev = &dummy;
		node->nNext = &dummy;
		dummy.nPrev = node;
		dummy.nNext = node;
		sum++;
	}
	else {
		Node *node = new Node;
		node->key = n;
		node->nPrev = &dummy;
		node->nNext = dummy.nNext;
		node->nNext->nPrev = node;
		dummy.nNext = node;
		sum++;
	}
}

// 任意のキー値を持つノードを削除する
void deleteNode(unsigned int n) {
	if (NULL == dummy.nPrev || NULL == dummy.nNext) {
		return;
	}
	// 確認用に宣言
	Node *pNode;
	pNode = &dummy;

	if (sum == 1) {
		if (dummy.nNext->key == n) {
			delete(dummy.nNext);
			dummy.nNext = NULL;
			dummy.nPrev = NULL;
			sum--;
		}
	}
	else {
		for (int i = 0; i < sum; i++) {
			if (pNode->nNext->key == n) {
				// Nodeの削除
				pNode->nNext = pNode->nNext->nNext;
				delete(pNode->nNext->nPrev);			// 前の部分は残っているからそこを使ってdelete()
				pNode->nNext->nPrev = pNode;
				sum--;
				break;
			}
			else {
				// pNodeのnextを次のNodeにする
				pNode = pNode->nNext;
			}
		}
	}
}

// 先頭を削除する
void deleteFisrt() {
	if (NULL == dummy.nPrev || NULL == dummy.nNext) {
		return;
	}
	Node *ptmpN = dummy.nNext->nNext;
	delete(dummy.nNext);				// 先頭の削除

	// ノードが1つの時と2つ以上の時の条件分岐
	if (&dummy == ptmpN) {
		dummy.nPrev = NULL;
		dummy.nNext = NULL;
	}
	else {
		dummy.nNext = ptmpN;
		ptmpN->nPrev = &dummy;
	}
}

// 末尾を削除する
void deleteLast() {
	if (NULL == dummy.nPrev || NULL == dummy.nNext) {
		return;
	}
	Node *ptmpN = dummy.nPrev->nPrev;
	delete(dummy.nPrev);

	// ノードが1つ以上の時と2つ以上の時の条件分岐
	if (&dummy == ptmpN) {
		dummy.nPrev = NULL;
		dummy.nNext = NULL;
	}
	else {
		dummy.nPrev = ptmpN;
		ptmpN->nNext = &dummy;
	}
}

// 出力
void display() {

	Node *node = dummy.nNext;
	while (&dummy != node) {
		printf("%d", node->key);
		node = node->nNext;
		delete(node->nPrev);
		if (node != &dummy) {
			printf(" ");
		}
	}
	printf("\n");
}



Measured memory_bytes: 34548
//============================================================================
// Name        : HairetuTest.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int a,x;
	a=1;
	while(a>0){
		cin>>x;
		if(x==0)break;
		cout<<"Case "<<a<<": "<<x<<endl;
		a++;
	}
return 0;
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
#include <iostream>
typedef long long ll;
#define rep(i,a,b) for(ll i =a ;i <= b;i++)
#define per(i,a,b) for(ll i =a ;i >= b;i--)
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;


int main(int argc, char const *argv[])
{
	//ifstream cin("input.txt");
	int n,k,d,a;
	cin>>n>>k;

	vector<bool> mapper(n, false);
	rep(i, 0 , k-1)
	{
		cin>>d;
		rep(j, 0 , d-1){
			cin>>a;
			mapper[a - 1] = true;
		}
	}
	cout<<count(mapper.begin(), mapper.end(), false);
}

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

int main(){
    string s;
    cin >> s;
    int k = (int)s.size();
    if (k < 26) {
        vector<bool> abc(26, false);
        for (int i = 0; i < k; i++) abc[s[i] - 'a'] = true;

        for (int i = 0; i < k; i++) cout << s[i];
        for (int i = 0; i < 26; i++){
            if (abc[i] == false) {
                cout << (char)('a' + i) << endl;
                exit(0);
            }
        }
    }
    else {
        vector<bool> abc(26, false);
        for (int i = k - 1; i > 0; i--) {
            abc[s[i] - 'a'] = true;
            if (s[i] > s[i-1]) {
                for (int j = 0; j < i - 1; j++) cout << s[j];
                for (int j = s[i-1] - 'a'; j < 26; j++) {
                    if (abc[j]) {
                        cout << (char)(j + 'a') << endl;
                        exit(0);
                    }
                }
            }
        }
        cout << - 1 << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
const int N = 300032;
typedef long long ll;
const ll MOD = 998244353;

ll factor(int n) {
	ll s = 1;
	while (n > 1) s = s * n-- %MOD;
	return s;
}

struct range {
	int l, r;
	range() {}
	range(int l, int r): l(l), r(r) {}
	int len();
	void ins();
} rg[N];

int a[N], n, k, fre = 0;
ll ans = 1;

inline int nxt(int i) {if (++i >= n) i -= n; return i;}
inline int pre(int i) {if (--i <  0) i += n; return i;}
inline int range::len() {int d = r-l+1; if (d < 0) d += n; return d;}

inline void range::ins() {
	int flag = (a[pre(l)] < a[l]) + (a[nxt(r)] < a[r]), d = len();
	if (flag ? d > k : d != k) puts("0"), exit(0);
	if (flag == 1) fre += d - 1;
	else if (flag == 2) {
		fre += k + d - 2;
		ans = ans * (k + 1 - d) %MOD;
	}
}

int main() {
	memset(rg, -1, sizeof rg);
	scanf("%d",&n);
	int l = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d",a+i);
		if (i && a[i] != a[i-1]) {
			auto &t = rg[a[i-1]];
			if (~t.r) {puts("0"); return 0;}
			t = range(l, i-1), l = i;
		}
	}
	if (!l) {
		if (*a != 1) puts("0");
		else printf("%lld\n",factor(n));
		return 0;
	}
	a[n] = a[0];
	if (a[n-1] == a[0]) rg[a[0]].l = l;
	else {
		auto &t = rg[a[n-1]];
		if (~t.r) {puts("0"); return 0;}
		else t = range(l, n-1);
	}

	if (rg[1].r == -1) {puts("0"); return 0;}
	k = rg[1].len();

	for (int i = 1; i <= n; i++)
		if (~rg[i].r) rg[i].ins();
		else ans = ans * fre-- %MOD;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 3712
import Data.List
main = do
    (n:m:x:y:_)<-map read.words<$>getLine::IO [Int]
    xz<-maximum.map read.words<$>getLine::IO Int
    yz<-minimum.map read.words<$>getLine::IO Int
    --
    putStrLn $ if xz > yz then "War" else
               if any (`elem` [x+1..y]) [xz+1..yz] then "No War" else "War"


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

const int MOD = 1e9 + 7;
const int MAX = 2 * 1e5; // 適宜


ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
	COMinit();
	
	int n,m,k;
	cin >> n >> m >> k;
	
	
	// calc x
	ll x = 0;
	for(int i = 1; i < m; i++){
		x = (x + (((ll)(m-i)*i) % MOD) ) % MOD;
	}
	x = (x * (((ll)n*n) % MOD)) % MOD;
	
	// calc y
	ll y = 0;
	for(int i = 1; i < n; i++){
		y = (y + (((ll)(n-i)*i) % MOD) ) % MOD;
	}
	y = (y * (((ll)m*m) % MOD)) % MOD;
	
	ll res = (x+y)%MOD;
	
	cout << (res * COM(n*m-2,k-2)) % MOD << endl;
	return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    if(a>0) cout << "Positive" << endl;
    else if(b<0) {
        if((b-a)%2==0) cout << "Negative" << endl;
        else cout << "Positive" << endl;
    } else cout << "Zero" << endl;

    return 0;
}


Measured memory_bytes: 256
"""
https://atcoder.jp/contests/abc131/submissions/6086380
"""
import os
import sys

import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import connected_components

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N = int(sys.stdin.readline())
X, Y = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(N)]))
PAD = 10 ** 5 + 1
X = np.array(X)
Y = np.array(Y) + PAD

graph = csr_matrix(([True] * N, (X, Y)), shape=(PAD * 2, PAD * 2))
# i から j までのパスがあれば components[i] と components[j] が同じ値
_, components = connected_components(graph)

# 同じ連結成分に含まれる X の数
# x_cnt[i]: 連結成分 i に含まれる x の数
x_cnt = np.bincount(components[:PAD], minlength=PAD * 2)
y_cnt = np.bincount(components[PAD:], minlength=PAD * 2)
# 同じ連結成分である x の数と y の数をかけた数だけその間に辺を張れる
# すでにある分は引く
print((x_cnt * y_cnt).sum() - N)


Measured memory_bytes: 68952
#include <iostream>

using namespace std;

int main()
{
    int A, B;
    cin >> A >> B;

    int sum = A + B;
    int subtract = A - B;
    int multi = A * B;

    if (sum>=subtract && sum>=multi) {cout << sum << endl;}
    else if (subtract>=sum && subtract>=multi) {cout << subtract << endl;}
    else {cout << multi << endl;}
    return 0;
}

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

int main(){

    unsigned int N;
    cin>>N;
    string str;
    cin>>str;

    if(str.size() > N){
        string subs = str.substr(0,N);
        subs += "...";
        cout<<subs;
    }
    else{
        cout<<str;
    }
    return 0;
}

Measured memory_bytes: 3612
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iterator>
#include <deque>
#include <string>
#include <queue>
#include <omp.h>
#include <fstream>   // ifstream, ofstream
typedef int64_t ll;
using namespace std;
const ll INF=1e10;



int main(){
	ll n,x;
	cin>>n>>x;
	vector<ll> diff;
	for(ll i1=0;i1<n;i1++){
		ll temp;
		cin>>temp;
		diff.push_back(temp);
	}
	ll pos=0;
	ll index=0;
	for(index=0;index<n;index++){
		pos = pos + diff[index];//次の値
		if(pos > x){
			cout<<index+1<<endl;
			return 0;
		}
	}
	cout<<n+1<<endl;

}


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

int a,b,c,d,gede;
int main(){
cin>>a>>b;
d=0;
for(int i=1;i<=a;i++){
	cin>>c;
	if(c>=b){
		d++;
	}
}
cout<<d;
}

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

using namespace std;

map<string, int> mp;

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	for(int bin=0; bin<(1<<n); bin++)
	{
		string left="", right="";
		for(int i=0; i<n; i++)
		{
			if((bin & (1<<i))>>i) left=left+s[i];
			else right=s[i]+right;
		}
		string t=left+"0"+right;
		mp[t]++;
	}
	long long ans=0;
	for(int bin=0; bin<(1<<n); bin++)
	{
		string left="", right="";
		for(int i=0; i<n; i++)
		{
			if((bin & (1<<i))>>i) left=left+s[2*n-1-i];
			else right=s[2*n-1-i]+right;
		}
		string t=left+"0"+right;
		ans+=(long long)mp[t];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 67200
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it;}cout<<endl;}

int main() {
    ll a,b;
    bool flag = true;
    cin>>a>>b;
    pr("100 100");
    if (b<a) {
        swap(a, b);
        flag=false;
    }// a <= b
    
    ll sa=1,sb=0;
    char m[100][100];
    rep(i, 100) rep(j,100) m[i][j]='.';
    
    bool kisu = false;
    ll  endline=0;
    rep(i, 100) {
        kisu = !kisu;
        if (kisu) {
            rep(j,50){
                if (a==sa || b==sb) {
                    endline=i;
                    break;
                }
                m[i][2*j+1]='#';
                if (i!=0) {
                    sa++;
                    sb++;
                }else{
                    sb++;
                }
            }
        }else{
            rep(j,50){
                if (a==sa || b==sb) {
                    endline=i;
                    break;
                }
                m[i][2*j]='#';
                sa++;
                sb++;
            }
        }
        if (a==sa || b==sb) {
            endline=i;
            break;
        }
    }
    
    if (a==sa) {
        fr(i,endline+2,100){
            if(b==sb) break;
            rep(j,50){
                if(b==sb) break;
                m[i][2*j]='#';
                sb++;
            }
            i++;
        }
    }else{ // b==sb
        rep(j,100){
            if(a==sa) break;
            if(j!=0 && j!=99 && m[endline][j]=='#'){
                if(a==sa) break;
                fr(i, endline, 100){
                    m[i][j]='#';
                }
                sa++;
                if(a==sa) break;
            }
            if(j!=0 && j!=99 && m[endline-1][j]=='#' && m[endline][j+1]!='#'&& m[endline][j-1]!='#'){
                if(a==sa) break;
                fr(i, endline-1, 100){
                    m[i][j]='#';
                }
                sa++;
                if(a==sa) break;
            }
            if(a==sa) break;
        }
    }
    
    if(!(a==sa&&b==sb)) {m[98][0] = '#';m[98][1] = '#';sa++;}
    if(!(a==sa&&b==sb)) {m[98][99] = '#';m[98][98] = '#';sa++;}
    rep(i, 100) {
        rep(j,100) {
            if (flag) {
                cout<<m[i][j];
            }else{
                cout<<(m[i][j] == '#' ? '.':'#');
            }
        }
        cout<<endl;
    }
//        cout<<(a==sa&&b==sb)<<endl;
}



Measured memory_bytes: 888
mtx = [[0] * 2019 for _ in range(2019)]

for i in range(len(mtx)):
    for j in range(len(mtx)):
        mtx[i][j] = (i * j) % 2019

l, r = map(int, input().split())

min_val = 10000000

l_mod = l % 2019
r_mod = r % 2019

if r_mod < l_mod:
    r_mod += 2019

for i in range(l, r):
    for j in range(i+1 , r + 1):
        a = i % 2019
        b = j % 2019
        ret = mtx[a][b]
        min_val = min(min_val, ret)
        if min_val == 0:
            print(0)
            exit()

print(min_val)



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

using namespace std;

int main() {

    long int N, W; cin >> N >> W;

    long int v[N], w[N];
    for (int i=0; i<N; i++) cin >> v[i] >> w[i];

    long int dp[N+10][W+10];
    for (int i=0; i<=W; i++) dp[0][i] = 0;

    // 商品番号 i までの商品のうち幾つかを選び
    // 重さjを超えないようにナプサクに詰めたときの値が dp[i+1][j]
    for (int i=0; i<N; i++) {
        for (int j=0; j<=W; j++) {
            // dp[i+1][j] = dp[i][j-w[i]]+v[i]
            // 商品 i をナプサクに加えてもナプサク容量が j を超えないような
            // dp[i][] を選んでいる
            if (j>=w[i]) dp[i+1][j] = max(dp[i][j-w[i]]+v[i], dp[i][j]);
            else dp[i+1][j] = dp[i][j];
        }
    }

    cout << dp[N][W] << endl;

    return 0;
}


Measured memory_bytes: 10996
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>

#define ll long long
#define rr register

#define inf 1e9
#define MAXN 100010

using namespace std;

inline int read() {
	int s = 0, f = 0;
	char ch = getchar();
	while (!isdigit(ch)) f |= ch == '-', ch = getchar();
	while (isdigit(ch)) s = s * 10 + (ch ^ 48), ch = getchar();
	return f ? -s : s;
}

void print(int x) {
	if (x < 0) putchar('-'), x = -x;
	if (x > 9) print(x / 10);
	putchar(x % 10 + 48);
}

int x;

signed main() {
	x = read();
	if (x >= 30) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll& a, ll b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
bool chmax(ll& a, ll b) {
    if (b > a) {
        a = b;
        return 1;
    }
    return 0;
}
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans, s;
ll histgram(vl B) {
    ll n = B.size(), ans = 0;
    vl A;
    A.push_back(0);
    rep(i, n) A.push_back(B[i]);
    A.push_back(0);
    n += 2;
    vl X(n, 0), Y(n, 0);

    deque<PP> DQ;

    rep(i, n) {
        while (!DQ.empty() && DQ.back().second > A[i]) {
            X[DQ.back().first] += i - DQ.back().first;
            DQ.pop_back();
        }
        DQ.push_back({i, A[i]});
    }

    reverse(all(A));

    DQ.clear();

    rep(i, n) {
        while (!DQ.empty() && DQ.back().second > A[i]) {
            Y[DQ.back().first] += i - DQ.back().first;
            DQ.pop_back();
        }
        DQ.push_back({i, A[i]});
    }

    reverse(all(Y));
    reverse(all(A));

    rep(i, n) {
        ans = max(ans, (X[i]+Y[i]-1) * A[i]);
    }
    
    return ans;
}
int main() {
    cin >> h >> w;
    vector<vl> dp(h, vl(w, 1));
    rep(i, h) {
        rep(j, w) {
            cin >> x;
            if (i > 0) dp[i][j] = dp[i - 1][j] + 1;
            if (x) dp[i][j] = 0;
        }
    }

    rep(i, h){
    	chmax(t, histgram(dp[i]));
    }

    cout << t << endl;
}



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

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

using vc = vector<vector<char>>;

void dfs(vc &c, int y, int x, char oldc, char newc) {
  if(y < 0 || y >= c.size() || x < 0 || x >= c[0].size()) return;
  if(c[y][x] != oldc) return;
  c[y][x] = newc;

  for(int i = 0; i < 4; ++i) {
    int ny = y + dy[i], nx = x + dx[i];  
    dfs(c, ny, nx, oldc, newc);
  }
}

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

  char tmp[] = {'R', 'G', 'B'};

  int x, y;
  while(cin >> x >> y, y != 0) {
    vc c(y, vector<char>(x));
    for(int i = 0; i < y; ++i) {
      for(int j = 0; j < x; ++j) {
        cin >> c[i][j];
      }
    }

    int ans = 1e9;
    queue<vc> que;
    que.push(c);
    map<vc, int> mp;
    mp[c] = 0;

    while(!que.empty()) {
      vc s = que.front();
      que.pop();

      {
        bool ok = true;
        for(int i = 0; i < y; ++i) {
          for(int j = 0; j < x; ++j) {
            if(s[0][0] != s[i][j]) ok = false;
          }
        }

        if(ok) {
          ans = mp[s];
          break;
        }
      }

      for(int i = 0; i < 3; ++i) {
        if(s[0][0] == tmp[i]) continue;

        vc nc = s;

        dfs(nc, 0, 0, s[0][0], tmp[i]);
        if(!mp.count(nc)) {
          mp[nc] = mp[s] + 1;
          que.push(nc);
        }
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 7872
#include<iostream>
using namespace std;
using ll = long long;

ll mod_pow(ll a, ll n, ll mod) {
	if (n == 0)return 1;
	if (n % 2 == 0)
		return mod_pow(a, n / 2, mod) * mod_pow(a, n / 2, mod) % mod;
	else
		return mod_pow(a, n - 1, mod) * a % mod;
}

ll mod_inv(ll a, ll mod) {
	return mod_pow(a, mod - 2, mod);
}

ll cmb(ll n, ll m, ll mod) {
	ll rtn = 1;
	for (ll i = 1; i <= m; i++, n--) {
		rtn = rtn * n % mod;
		rtn = rtn * mod_inv(i, mod) % mod;
	}
	return rtn;
}

int main() {
	ll x, y, n, m, mod = 1000000007;
	cin >> x >> y;
	n = (2 * y - x) / 3;
	m = (2 * x - y) / 3;
	if ((x + y) % 3 != 0)
		cout << 0 << endl;
	else if (n < 0)
		cout << 0 << endl;
	else if (m < 0)
		cout << 0 << endl;
	else {
		cout << cmb(n + m, n, mod) << endl;;
	}
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
inf = 10**17
mod = 10**9+7

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

ac = [0] * n
wa = [0] * n

acn = 0
wan = 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    p -= 1
    if ac[p] > 0: continue
    if s == 'AC':
        ac[p] = 1
        acn += 1
        wan += wa[p]
    else:
        wa[p] += 1

print(acn, wan)


Measured memory_bytes: 10428
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long r;

int main(){
    scanf("%ld", &r);
    if(r < 1200){
        printf("ABC\n");
    }else if(r < 2800){
        printf("ARC\n");
    }else{
        printf("AGC\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <unordered_map>

using namespace std;
using LL = long long;

#define MOD 1000000007

class RollingHash {
private:
	LL mod(LL x) { return (x % MOD + MOD) % MOD; }
	LL h = 0, w = 0;
public:
	template <class I>
	RollingHash(I first, I last) {
		for (auto it = first; it != last; ++it)
			h = mod(h * 256 + *it), w = w ? mod(w * 256) : 1;
	}
	void roll(char L, char R) { h = mod((h - w * L) * 256 + R); }
	operator int() const { return h; }
};

class Solution {
private:
	template <class F>
	int lowestTrue(int low, int high, F cond) {
		while (low < high) {
			const int mid = low + (high - low) / 2;
			if (cond(mid))
				high = mid;
			else
				low = mid + 1;
		}
		return low;
	}
public:
	/* time: O(n*log(n)), space: O(n), where n = |S| */
	int whoSaysAPun(const string& S) {
		const int n = S.size();
		auto cond = [&](int len) {
			unordered_map<int, int> h;
			RollingHash curr(S.begin(), S.begin() + len);
			for (int L = 0, R = len - 1; R < n; ++L, ++R) {
				const auto it = h.find(curr);
				if (it == h.end())
					h[curr] = L;
				else if (L - it->second >= len && !S.compare(it->second, len, S, L, len))
					return false; /* found */
				if (R != n - 1)
					curr.roll(S[L], S[R + 1]);
			}
			return true; /* not found */
		};
		return lowestTrue(1, n, cond) - 1;
	}
};

int main() {
	int n;
	cin >> n;

	string S;
	cin >> S;

	Solution sol;
	int ans = sol.whoSaysAPun(S);
	cout << ans << endl;
	return 0;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

pll A[200005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, D;
    cin >> N >> D;
    REP(i, N) {
        cin >> A[i].first >> A[i].second;
    }

    ll ans = 0;
    REP(i, N) {
        ll d = A[i].first * A[i].first + A[i].second * A[i].second;
        if (d <= D * D)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6736
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound, __gcd, count, find, next_permutation
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   // setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cassert> // assert
#include <cctype>  // isupper, islower, isdigit, toupper, tolower
#include <cmath>   // abs, sin, cos, tan
#include <ctime>   // clock

// __builtin_popcountll

using namespace std;
using Graph = vector<vector<int>>;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

void Main()
{
  ll n; cin >> n;
  ll dp = 0;
  vll a1(n), a2(n);
  rep(i, n)
  {
    cin >> a1[i];
    dp += a1[i];
  }
  rep(i, n)
  {
    cin >> a2[i];
    if(i == n - 1) dp += a2[i];
  }
  ll ans = dp;
  for(ll i = 1;i < n;i++)
  {
    dp -= a1[n - i];
    dp += a2[n - i - 1];
    ans = max(ans, dp);
  }
  cout << ans << endl;
  return;
}

//前処理
int main()
{
  int ti = clock();
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  //printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<list>
#include<vector>
#include<string>
#include<cmath>

using namespace std;

int main(){
  	int a, b, c;
    cin >> a;
    cin >> b;
    cin >> c;
	if ( a == b + c || b == c + a || c == a + b){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
}


Measured memory_bytes: 256