akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVETSE(c) reverse((c).begin(),(c).end())
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define ALL(a)  (a).begin(),(a).end()
// int gcd(int a,int b){return b?gcd(b,a%b):a;}
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> T maxt(T x,T y) {
    if (x>y) return x;
    else return y;
}
template<class T> T mint(T x,T y) {
    if (x>y) return y;
    else return x;
}
//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
//cout << fixed << setprecision(10) << ans << defaultfloat << endl;
typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<double> Vd;
typedef vector<string> Vs;

//小数出力
double print_double(double d){printf("%.8f", d);}

long long m = 1e9+7, mod = 1e9+7;
//逆元　a/b の modをとるとき -> a*modinv(b)%mod
long long modinv(long long a, long long m = 1e9+7) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

//約数列挙
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}


int main() {
  ll H,ans=0,p=1;
  cin >> H;
  while(H!=0){
    H/=2;
    ans += p;
    p*=2;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;

using ll = long long;
using p = pair<ll, ll>;

constexpr ll INF = 1LL << 62;
constexpr ll MOD = 1e9 + 7;
constexpr ll MAX_N = 100;
ll dp[MAX_N + 1][MAX_N + 1][MAX_N + 1][MAX_N + 1];

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

    ll N, W;
    cin >> N >> W;

    vector<p> inputs(N);
    vector<ll> V[4];
    ll min_weight = INF;
    for (ll i = 0; i < N; i++) {
        ll w, v;
        cin >> w >> v;
        inputs[i] = p(w, v);
        min_weight = min(min_weight, w);
    }

    for (auto in : inputs) {
        V[in.first - min_weight].push_back(in.second);
    }

    for (ll i = 0; i < 4; i++) {
        sort(V[i].begin(), V[i].end(), greater<ll>());
    }

    for (ll a = 0; a <= V[0].size(); a++) {
        for (ll b = 0; b <= V[1].size(); b++) {
            for (ll c = 0; c <= V[2].size(); c++) {
                for (ll d = 0; d <= V[3].size(); d++) {
                    ll weight = a * min_weight + b * (min_weight + 1) + c * (min_weight + 2) + d * (min_weight + 3);
                    if (weight > W) {
                        dp[a][b][c][d] = -INF;
                    } else {
                        ll ans = dp[a][b][c][d];
                        if (a > 0) {
                            ans = max(ans, dp[a - 1][b][c][d] + V[0][a - 1]);
                        }
                        if (b > 0) {
                            ans = max(ans, dp[a][b - 1][c][d] + V[1][b - 1]);
                        }
                        if (c > 0) {
                            ans = max(ans, dp[a][b][c - 1][d] + V[2][c - 1]);
                        }
                        if (d > 0) {
                            ans = max(ans, dp[a][b][c][d - 1] + V[3][d - 1]);
                        }

                        dp[a][b][c][d] = ans;
                    }
                }
            }
        }
    }

    ll ans = 0;
    for (ll a = 0; a <= V[0].size(); a++) {
        for (ll b = 0; b <= V[1].size(); b++) {
            for (ll c = 0; c <= V[2].size(); c++) {
                for (ll d = 0; d <= V[3].size(); d++) {
                    ans = max(ans, dp[a][b][c][d]);
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 203008
/**
 *    author:  math2do
 *    created: 12.04.2020 22:21:50
**/

#include <bits/stdc++.h>

using namespace std;

template <typename T>
class graph {
 public:
  struct edge {
    int from;
    int to;
    T cost;
  };
 
  vector<edge> edges;
  vector<vector<int>> g;
  int n;
 
  graph(int _n) : n(_n) {
    g.resize(n);
  }
 
  virtual int add(int from, int to, T cost) = 0;
};

template <typename T>
class undigraph : public graph<T> {
 public:
  using graph<T>::edges;
  using graph<T>::g;
  using graph<T>::n;
 
  undigraph(int _n) : graph<T>(_n) {
  }
 
  int add(int from, int to, T cost = 1) {
    assert(0 <= from && from < n && 0 <= to && to < n);
    int id = (int) edges.size();
    g[from].push_back(id);
    g[to].push_back(id);
    edges.push_back({from, to, cost});
    return id;
  }
};

template <typename T>
vector <int> articulation(const undigraph <T> &g) {
  vector <bool> seen(g.n, false);
  vector <int> low(g.n, 0);
  vector <int> dis(g.n, 0);
  vector <int> pv(g.n, -1);
  vector <bool> art(g.n, false);
  int timer = 0;

  function <void(int)> dfs = [&](int u) {
    seen[u] = true;
    dis[u] = low[u] = ++timer;
    int child_cnt = 0;
    for (int id : g.g[u]) {
      int v = g.edges[id].from ^ g.edges[id].to ^ u;
      if (!seen[v]) {
        child_cnt++;
        pv[v] = u;
        dfs(v);
        low[u] = min(low[u], low[v]);
        if (pv[u] == -1 && child_cnt > 1) {
          art[u] = true;
        }
        //...here if check was if (low[v] > dis[u]) then u - v would form a bridge and above child_cnt condition would not be present here
        //...the low[v] > dis[u] for bridge and even == for articulation point  as u still is articulation point
        //...  as  a---u--v--x
        //...           \ | /
        //....            w
        if (pv[u] != -1 && low[v] >= dis[u]) {
          art[u] = true;
        }
      } else if (v != pv[u]) {
        low[u] = min(low[u], dis[v]);
      }
    }
  };
  dfs(0);
  vector <int> ans;
  for (int i = 0; i < g.n; i++) {
    if (art[i]) {
      ans.push_back(i);
    } 
  } 

  return ans;
  //returns list of weak vertices
} 

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  undigraph <int> g(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    g.add(x, y);
  } 
  vector <int> ans = articulation(g);
  for (int v : ans) {
    cout << v << '\n';
  } 
  return 0;
}



Measured memory_bytes: 5384
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		
		int[][][] managementOffice = new int [4][3][10];
		for(int i= 0; i<4;i++){
			
			managementOffice[i] = createOffice();
		}
		
		
		int count  = Integer.parseInt(sc.next());
		for(int i = 0; i< count; i++){
			
			int b = Integer.parseInt(sc.next());
			int f = Integer.parseInt(sc.next());
			int r = Integer.parseInt(sc.next());
			int v = Integer.parseInt(sc.next());
			
			managementOffice[b-1][f-1][r-1] += v;
		}
		
		for(int i = 0; i <4 ;i++){
			for(int j = 0; j<3;j++){
				for(int k = 0; k<10;k++){
					
					System.out.print(" " +managementOffice[i][j][k]);
					
				}
				System.out.println();
				
			}
			if(i != 3){
				
				System.out.println("####################");
			}
			
		}
		
		sc.close();
		
	}
	
	
	private static int[][] createOffice(){
		
		int[][] office = new int[3][10];
		
		for(int i = 0; i < 3;i++){
			
			for(int j = 0; j < 10;j++){
				
				office[i][j] = 0;
			}
			
		}
		
		
		
		
		return office;
	}

}



Measured memory_bytes: 28600
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
sa=set(a)
dic=Counter(a)
hantei=0
for i in dic:
  if (i-1) in dic and (i+1) in dic:
    x=dic[i]+dic[i-1]+dic[i+1]
  elif (i-1) in dic:
    x=dic[i]+dic[i-1]
  elif (i+1) in dic:
    x=dic[i]+dic[i+1]
  else:
    x=dic[i]
  if hantei < x:
    hantei=x
print(hantei)

Measured memory_bytes: 16612
#include<bits/stdc++.h>
#define maxn 100005
using namespace std;

map<int,int>mp;
int n;
int a[maxn],b[maxn],sz;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		mp[x]++;
	}
	for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++){
		int x=it->first,y=it->second;
		sz++;
		a[sz]=x,b[sz]=y;
	}
	if(sz>3){
		printf("No\n");
		return 0;
	}
	if(sz==3){
		if(b[1]==b[2]&&b[2]==b[3]&&(a[1]^a[2]^a[3])==0){
			printf("Yes\n");
			return 0;
		}
	}
	if(sz==2){
		if(b[1]==2*b[2]&&(a[1]^a[1]^a[2])==0||b[2]==2*b[1]&&(a[1]^a[2]^a[2])==0){
			printf("Yes\n");
			return 0;
		}
	}
	if(sz==1){
		if((a[1]^a[1]^a[1])==0){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
}

Measured memory_bytes: 4480
import statistics

n = int(input())
aa = [None] * n
bb = [None] * n
for i in range(n):
    a, b = map(int, input().split())
    aa[i] = a
    bb[i] = b

def median(arr):
    if len(arr) % 2 == 0:
        return (arr[n // 2 - 1] + arr[n // 2]) / 2
    else:
        return arr[n // 2]

m = n
if n % 2 == 0:
    m *= 2
medmin = median(sorted(map(lambda x: x * m, aa)))
medmax = median(sorted(map(lambda x: x * m, bb)))

print(int((medmax - medmin) / n) + 1)

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

int main(){
    vector<vector<int>>a(3,vector<int>(3));
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> a.at(i).at(j);
        }
    }
    int n;
    cin >> n;
    vector<int>b(n);
    for(int i = 0; i < n;i++){
        cin >> b.at(i);
    }
    for(int i = 0; i < n;i++){
        for(int j = 0; j < 3;j++){
            for(int k = 0; k < 3;k++){
                if(b.at(i) == a.at(j).at(k)){
                    a.at(j).at(k) = -1;
                }
            }
        }

        
    }
    //横のビンゴ
    for(int i = 0;i<3;i++){
        
        if(a.at(i).at(0) == -1 && a.at(i).at(1) == -1 && a.at(i).at(2) == -1){
            cout << "Yes" << endl;
            return 0;
        }
    }
    //縦のビンゴ
    for(int i = 0;i<3;i++){
        
        if(a.at(0).at(i) == -1 && a.at(1).at(i) == -1 && a.at(2).at(i) == -1){
            cout << "Yes" << endl;
            return 0;
        }
    }
    //ななめのビンゴ
    if(a.at(0).at(0) == -1 && a.at(1).at(1) == -1 && a.at(2).at(2) == -1){
        cout << "Yes" << endl;
        return 0;
    }
    
    if(a.at(0).at(2) == -1 && a.at(1).at(1) == -1 && a.at(2).at(0) == -1){
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int a, b, c; cin >> a >> b >> c;
    if (a-b >= c) cout << 0 << endl;
    else cout << c-(a-b) << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    a, b = map(int, input().split())

    print(max(0, a - (2 * b)))


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 29164
#include<stdio.h>
 
static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}
 
int main(){
  int n, i, j, v;
  int A[N+1];
  scanf("%d", &n);
 
  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
   
  for(i=1;i<=n;i++){
    v=A[i];
    j=i-1;
    while(j>0&&A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    trace(A,n);
  }
  return 0;
}

Measured memory_bytes: 1768
N, T = map(int, input().split())
min_cost = 1001
for i in range(N):
    c, t = map(int, input().split())
    if t <= T:
        min_cost = min(min_cost, c)
if min_cost == 1001:
    print('TLE')
else:
    print(min_cost)


Measured memory_bytes: 3064
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 puls = A + B;
        int minus = A - B;
        int times = A * B;
        int max1 = Math.max(puls, minus);
        int max2 = Math.max(max1, times);
        System.out.println(max2);
    }
}

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

int main(){
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  int xm=x, ym=y;
  for(int i=0; i<n; i++){
    int tmp;
    cin >> tmp;
    xm = max(xm, tmp);
  }
  for(int i=0; i<m; i++){
    int tmp;
    cin >> tmp;
    ym = min(ym, tmp);
  }
  if(xm < ym)cout << "No War";
  else cout << "War";
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	if (a + b < c + d) {
		cout << "Right" << endl;
	}
	else if (a + b > c + d) {
		cout << "Left" << endl;
	}
	else {
		cout << "Balanced" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll long long 
#define ull long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd long long
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
#define fre freopen("input.txt","r",stdin),freopen("output.txt","w",stdout)
using namespace std;
ll dp[3005][3005][4];
ll memo[3005][3005][4];
ll val[3005][3005];
ll r,c;
ll solve(ll i,ll j,ll k){
	if(i>r or j>c or k>3)return 0;
	if(memo[i][j][k])return dp[i][j][k];
	memo[i][j][k]=1;
	ll res=0;
	res=solve(i,j+1,k);
	res=max(res,solve(i+1,j,0));
	if(k<3)res=max(res,solve(i,j+1,k+1)+val[i][j]);
	if(k<3)res=max(res,solve(i+1,j,0)+val[i][j]);	
	return dp[i][j][k]=res;
	
}
int main(){
   boost;
   ll k;  
   cin>>r>>c>>k;
   while(k--){
   	  ll x,y,v;
   	  cin>>x>>y>>v;
   	  val[x][y]=v;
    }
    cout<<solve(0,0,0)<<endl;
   
   
}
   
	
 
    


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

using namespace std;

const int N = 123;

int p[N];
int was[N];
int st;
vector <int> g[N];

int go(int x) {
  if (x == -1) {
    return 1;
  }
  if (was[x] == st) {
    return 0;
  }
  was[x] = st;
  for (int y : g[x]) {
    if (go(p[y])) {
      p[y] = x;
      return 1;
    }
  }
  return 0;
}

int a[N];
int b[N];

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
    g[i].clear();
  }
  for (int i = 0; i < n; ++i) {
    int c, d;
    cin >> c >> d;
    for (int j = 0; j < n; ++j) {
      if (a[j] < c && b[j] < d) {
        g[j].push_back(i);
      }
    }
  }
  st = 1;
  memset(was, 0, sizeof was);
  memset(p, -1, sizeof p);
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    ans += go(i);
    ++st;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#define rep(i, a, n) for(int i = a;i < n;i++)
using namespace std;


int tile[8][8];


void input(string& s){
	rep(i, 0, 8) tile[0][i] = (s[i] - '0');
	rep(i, 1, 8){
		cin >> s;
		rep(j, 0, 8)
			tile[i][j] = (s[j] - '0');
	}
}


bool A(int x, int y){
	if(x+1 > 7) return false;
	if(!tile[y][x+1]) return false;
	if(y+1 > 7) return false;
	if(!tile[y+1][x]) return false;
	if(!tile[y+1][x+1]) return false;
	return true;
}


bool B(int x, int y){
	if(y+1 > 7) return false;
	if(!tile[y+1][x]) return false;
	if(y+2 > 7) return false;
	if(!tile[y+2][x]) return false;
	if(y+3 > 7) return false;
	if(!tile[y+3][x]) return false;
	return true;
}


bool C(int x, int y){
	if(x+1 > 7) return false;
	if(!tile[y][x+1]) return false;
	if(x+2 > 7) return false;
	if(!tile[y][x+2]) return false;
	if(x+3 > 7) return false;
	if(!tile[y][x+3]) return false;
	return true;
}


bool D(int x, int y){
	if(y+1 > 7) return false;
	if(!tile[y+1][x]) return false;
	if(x-1 < 0) return false;
	if(!tile[y+1][x-1]) return false;
	if(y+2 > 7) return false;
	if(!tile[y+2][x-1]) return false;
	return true;
}


bool E(int x, int y){
	if(x+1 > 7) return false;
	if(!tile[y][x+1]) return false;
	if(y+1 > 7) return false;
	if(!tile[y+1][x+1]) return false;
	if(x+2 > 7) return false;
	if(!tile[y+1][x+2]) return false;
	return true;
}


bool F(int x, int y){
	if(y+1 > 7) return false;
	if(!tile[y+1][x]) return false;
	if(x+1 > 7) return false;
	if(!tile[y+1][x+1]) return false;
	if(y+2 > 7) return false;
	if(!tile[y+2][x+1]) return false;
	return true;
}


void startP(int& x, int& y){
	rep(i, 0, 8){
		rep(j, 0, 8){
			if(tile[i][j]){
				y = i;
				x = j;
				return;
			}
		}
	}
}


char solve(){
	int x, y;
	startP(x, y);
	if(A(x, y)) return 'A';
	if(B(x, y)) return 'B';
	if(C(x, y)) return 'C';
	if(D(x, y)) return 'D';
	if(E(x, y)) return 'E';
	if(F(x, y)) return 'F';
	return 'G';
}


int main(){
	string s;

	while(cin >> s){
		input(s);

		cout << solve() << endl;
	}

	return 0;
}

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

int main(){
	int n;
	scanf("%d",&n);
	if(n==3) printf("2 5 63");
	else printf("2 3 5 ");
	n-=3;
	int sum=2+3+5;
	for(int i=6;n>0;i++){
		if(i%2==0||i%3==0||i%5==0){
			sum+=i;
			while(n==2&&(!(i%2==0||i%3==0||i%5==0)||(sum%2!=0&&sum%3!=0&&sum%5!=0))){
				i++;
				sum++;
			}
			n--;
			if(n==0){
				while(sum%2!=0||sum%3!=0||sum%5!=0){
					i++;
					sum++;
				}
			}
			printf("%d ",i);
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 384
A = []
B = []
n, m = [int(i) for i in input().split(' ')]

for i in range(n):
	A.append([int(j) for j in input().split(' ')])
for j in range(m):
	B.append(int(input()))

c = 0
for i in range(n):
	for j in range(m):
		c += A[i][j] * B[j]
	print(c)
	c = 0

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

int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> a(m);
    rep(i,m) cin>>a[i];
    rep(i,m) n-=a[i];
    if(n>=0) cout<<n<<endl;
    else     cout<<"-1"<<endl;
    return 0;
}

Measured memory_bytes: 3656
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int cnt = 0;
        while(true) {
            cnt++;
            n -= a;
            if (n <= 0) {
                break;
            }
        }
        
        System.out.println(cnt);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define R(a) int a;cin>>a;
#define deb(x) cout<<#x<<" "<<x<<endl;
#define mod 1000000007
#define f_arr(n) for(int i=0;i<n;i++)
#define r_arr(n) for(int i=n-1;i>=0;i--)
#define pb push_back
#define all(x) x.begin(),x.end()
#define inf 1e18
#warning uncomment the #define int line before submitting
#define int long long int
using namespace std;

#ifndef ONLINE_JUDGE
template<typename T>    
void __p(T a) {
  cerr<<a;
}
template<typename T, typename F>
void __p(pair<T, F> a) {
  cerr<<"[";
  __p(a.first);
  cerr<<",";
  __p(a.second);
  cerr<<"]";
}
template<typename T>
void __p(std::vector<T> a) {
  cerr<<"[";
  for(auto it=a.begin(); it<a.end(); it++)
    __p(*it),cerr<<",]"[it+1==a.end()];
}
template<typename T, typename ...Arg>
void __p(T a1, Arg ...a) {
  __p(a1);
  __p(a...);
}
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
  cerr<<name<<" : ";
  __p(arg1);
  cerr<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
  int bracket=0,i=0;
  for(;; i++)
    if(names[i]==','&&bracket==0)
      break;
    else if(names[i]=='(')
      bracket++;
    else if(names[i]==')')
      bracket--;
  const char *comma=names+i;
  cerr.write(names,comma-names)<<" : ";
  __p(arg1);
  cerr<<" | ";
  __f(comma+1,args...);
}
#define trace(...) cerr<<"Line:"<<__LINE__<<" ", __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...)
#endif

void test_case()
{
  R(n);
  cout<<1000-(n%1000==0?1000:n%1000);
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
    int t=1;
    // cin>>t;
    while(t--)
    {
        test_case();
    }

    cerr<<endl<<"Time : "<<1000*((double)clock())/(double)CLOCKS_PER_SEC<<"ms\n";

    return 0;
}


Measured memory_bytes: 3804
#include <iostream>
#include <string>

int main() {
  std::string list;

  std::cin >> list;

  if ((list.c_str()[0] == list.c_str()[1]) && (list.c_str()[1] == list.c_str()[2])) {
    std::cout << "No" << std::endl;
  } else {
    std::cout << "Yes" << std::endl;
  }

  return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  int n = 0;
  for (int i = A; i <= B; i++) {
    if (i/10000 == i%10 && i/1000%10 == i%100/10)
      n = n + 1;
  }
  cout << n << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

#define N (9)

int main()
{
	int i, j;
	
	for (i = 1; i <= N; ++i) {
		for (j = 1; j <= N; ++j) {
			printf("%dx%d=%d\n", i, j, i * j);
		}
	}
	
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int mxsz = 1e5 + 3;
int n, m;
int par[mxsz];
int fpr(int u){return par[u] == u ? u : par[u] = fpr(par[u]);}
void merge(int u, int v){ par[fpr(v)] = fpr(u);}

int main(){
	cin >> n >> m;
	for (int i = 1; i <= n; i++) par[i] = i;
	for (int i = 1, u, v, z; i <= m; i++){
		cin >> u >> v >> z;
		merge(u, v);
	}
	int cnt = 0;
	for (int i = 1; i <= n; i++){
		if (fpr(i) == i) cnt++;
	}
	cout << cnt << '\n';
	return 0;
}


Measured memory_bytes: 768
#include<bits//stdc++.h>
using namespace std;
int N,K;
int A[66],R[66],B[66];
int sA[66],sR[66],sB[66];
int dp[61][61][6001];
const int off=3000;
inline int chmin(int&a,int b)
{
    if(a>b)a=b;
    return a;
}
int main()
{
    cin>>N>>K;
    for(int i=0;i<N;i++)cin>>A[i];
    sort(A,A+N);
    reverse(A,A+N);
    for(int i=0;i<K;i++)cin>>R[i];
    sort(R,R+K);
    reverse(R,R+K);
    for(int i=0;i<K;i++)cin>>B[i];
    sort(B,B+K);
    reverse(B,B+K);
    for(int i=0;i<N;i++)sA[i+1]=sA[i]+A[i];
    for(int i=0;i<K;i++)sR[i+1]=sR[i]+R[i];
    for(int i=0;i<K;i++)sB[i+1]=sB[i]+B[i];
    for(int i=0;i<=N;i++)for(int j=0;j<=K;j++)for(int k=-off;k<=off;k++)
    {
        dp[i][j][k+off]=1e9;
    }
    dp[0][0][off]=0;
    for(int i=0;i<N;i++)
    {
        for(int j=0;j<=K;j++)
        {
            for(int k=-off;k<=off;k++)
            {
                if(dp[i][j][k+off]==1000000000)continue;
                if(j<K)
                {
                    chmin(dp[i+1][j+1][k+off+R[j]-A[i]],dp[i][j][k+off]+(A[i]>R[j]?A[i]-R[j]:0));
                }
                int id=i-j;
                if(0<=id&&id<K)
                {
                    chmin(dp[i+1][j][k+off],dp[i][j][k+off]+(A[i]>B[id]?A[i]-B[id]:0));
                }
            }
        }
    }
    int ans=1e9;
    for(int i=0;i<=K;i++)
    {
        for(int j=-off;j<=off;j++)
        {
            int rrest=j+sR[K]-sR[i];
            int brest=-sA[N]+sR[K]+sB[K]-rrest;
            //if(dp[N][i][j+off]<1e9)cout<<"DBG : "<<rrest<<" "<<brest<<endl;
            if(0<=rrest&&0<=brest)
            {
                ans=min(ans,dp[N][i][j+off]);
            }
        }
    }
    cout<<(ans<1e9?ans:-1)<<endl;
}



Measured memory_bytes: 90380
#!/usr/bin/env python3
import sys

MOD = 2019  # type: int


def solve(L: int, R: int):
    if L // 2019 == R // 2019:
        minL = L % 2019
        maxR = R % 2019
        ans = 2019
        for i in range(minL, maxR):
            for j in range(i + 1, maxR + 1):
                com = (i * j) % 2019
                ans = min(ans, com)
        print(ans)
    else:
        print(0)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    solve(L, R)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int ans = 0;
  rep(i, n) if (~i & 1 && a[i] & 1) ans++;
  cout << ans << '\n';

  




  
  return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#define ll long long
using namespace std;
int main(){
     int N;
     int count = 0;
     int flag = 1;
     vector<int> H;
     cin >> N;
     H.resize(N);
     for(int i = 0; i < N; i++){
          cin >> H[i];
          flag  = 1;
          for(int j = 0; j < i; j++){
               if(H[j] > H[i]){
                    flag = 0;
               }
          }
          if(flag == 1){
               count++;
          }
     }
     cout << count << endl;
     return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

a = [i for i in a if i % 2 == 0]

ans = 0
for i in a:
    if i%3 == 0 or i%5 == 0:
        ans += 1

if ans == len(a):
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 38384
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}


int a, b, k[105], sum, mi = 1005;
int main() {
	cin >> a >> b;
	for (int i = 0; i < a; ++i) {
		cin >> k[i]; sum += k[i]; mi = min(mi, k[i]);
	}
	b -= sum;
	cout << b / mi + a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))

int main(){

	map<string,string> ma;
	string s[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
	string x;
	cin >> x;
	FOR(i,0,7){
		if(s[i]==x)cout << 7-i << endl;
	}


}

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

int main(){
    int n; cin >> n;
    map<string, int> ss;
    rep(i, n){
        string s; cin >> s;
        if(ss.find(s) == ss.end()) ss[s] = 0;
        else ss[s]++;
    }

    int maxl = -1;
    for(auto sp : ss){
        maxl = max(maxl, sp.second);
    }

    for(auto sp : ss){
        if(sp.second == maxl) cout << sp.first << endl;
    }

    return 0;
}

Measured memory_bytes: 25216
#include<stdio.h>

int main(){
	int a[110];
	int tc;
	scanf("%d", &tc);
	for(int i=0; i<tc; i++){
		scanf("%d", &a[i]);
	}
	for(int j=tc; j>0; j--){
		if(j==1) printf("%d\n", a[j-1]);
		else printf("%d ", a[j-1]);
	}
}


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

int main(){
  ll m = 100;
  ll x;
  cin >> x;
  ll ans = 0;
  while( m < x ){
    m += m/100;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;
ll attack(ll h){
	if (h == 1){
		return 1;
	}
	return 2 * attack(h / 2) + 1;
}
int main() {
	ll h;
	cin >> h;
	cout << attack(h) << endl;
	return 0;
}

              
              
              


Measured memory_bytes: 256
N, M = map(int, input().split())

is_solved = [0]*N
penalties = [0] * N
solutions = 0

for i in range(M):
    p_idx, verdict = input().split()
    p_idx = int(p_idx)

    if verdict == "WA" and (not is_solved[p_idx-1]):
        penalties[p_idx - 1] += 1
    elif verdict == "AC" and (not is_solved[p_idx-1]):
        is_solved[p_idx-1] = 1
        solutions += 1
penalty = 0

for i in range(N):
    if is_solved[i]:
        penalty += penalties[i]

print(solutions, penalty)


Measured memory_bytes: 4596
//https://atcoder.jp/contests/abc115/tasks/abc115_b
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
    int N;
    cin >> N;
    int p[11000];
    int tmpMaxNum = 0;
    int tmpArrayNum = 0;
    for(int i = 0; i < N; i++)
    {
        /* code */
        cin >> p[i];
        if(tmpMaxNum < p[i]){
            tmpMaxNum = p[i];
            tmpArrayNum = i;
        }
    }
    
    int price = 0;
    for(int i = 0; i < N; ++i)
    {
        /* code */
        if(i == tmpArrayNum){
            price += (p[i] / 2);
        }else{
            price += p[i];
        }
    }
    cout << price << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
pair<int,int> edge[200]; 
bool vis[200];
int cutid;
void dfs(int u){
	vis[u]=true;
	for(int i=1;i<=m*2;i++){
		if(edge[i].first==u&&i!=cutid){
			int v=edge[i].second;
			if(!vis[v])
				dfs(v);
		}
	}
}
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>edge[i].first>>edge[i].second;
		edge[i+m].first=edge[i].second;
		edge[i+m].second=edge[i].first;
	}
	int res=0;
	for(int i=1;i<=2*m;i++){
		cutid=i;
		memset(vis,false,sizeof(vis));
		dfs(1);
		for(int j=1;j<=n;j++)
			if(vis[j]==false){
				res++;
				break;
			}
	}
	cout<<res<<endl;
	return 0;
}
/*
7 7
1 3
2 7
3 4
4 5
4 6
5 6
6 7
*/

Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#include<limits>
#include<bitset>
#include<ctype.h>
#include<set>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000000;
const int MAX=100001;
const double EPS=1e-10;
vector<int> G[100000];
int main(){
    int n;
    cin>>n;
    ll s=0;
    ll ans=0;
    for(int i=0;i<n;i++){
        ll a;
        cin>>a;
        if(a>0){
            s+=a;
        }else{
            ans+=s/2;
            s=0;
        }
    }
    ans+=s/2;
    cout<<ans<<endl;
    return 0;
}

                           


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=998244353;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



int main(){
    int n;cin >> n;
    cout << "? ";
    for (int i = 1; i <= n; i++) {
        cout << i << (i==n?"\n":" ");
    }
    string s;cin >> s;
    int t = 0;
    if(s=="Red") t = 0;
    else t = 1;
    if(n==1){
        if(t==0) cout << "! RB\n";
        else cout << "! BR\n"; 
        return 0;
    }
    int l = 1,r = n + 1;
    while(r - l > 1){
        int m = (r + l) / 2;
        cout << "? ";
        for (int i = 0; i < n; i++) {
            cout << m + i << (i==n-1?"\n":" ");
        }
        cin >> s;
        int k = 0;
        if(s=="Red") k = 0;
        else k = 1;
        if(t == k) l = m;
        else r = m;
    }
    vector<int> ans(2*n+1,-1);
    vector<int> v(n-1,0);
    for (int i = 0; i < n - 1; i++) {
        v[i] = r + i;
    }
    for (int i = 1; i <= l; i++) {
        cout << "? " << i << " ";
        for (int j = 0; j < v.size(); j++) {
            cout << v[j] << (j==v.size()-1?"\n":" ");
        }
        cin >> s;
        if(s=="Red") ans[i] = 0;
        else ans[i] = 1;
    }
    for (int i = r+n; i <= 2*n; i++) {
        cout << "? " << i << " ";
        for (int j = 0; j < v.size(); j++) {
            cout << v[j] << (j==v.size()-1?"\n":" ");
        }
        cin >> s;
        if(s=="Red") ans[i] = 0;
        else ans[i] = 1;
    }
    vector<int> vv;
    int a = (n - 1) / 2, b = (n - 1) / 2;
    for (int i = 1; i <= 2*n; i++) {
        if(ans[i]==1&&a){
            vv.pb(i);
            a--;
        }
        if(ans[i]==0&&b){
            vv.pb(i);
            b--;
        }
    }
    for (int i = r; i < r+n; i++) {
        cout << "? " << i << " ";
        for (int j = 0; j < vv.size(); j++) {
            cout << vv[j] << (j==vv.size()-1?"\n":" ");
        }
        cin >> s;
        if(s=="Red") ans[i] = 0;
        else ans[i] = 1;
    }
    cout << "! ";
    for (int i = 1; i <= 2*n; i++) {
        cout << (ans[i]==0?"R":"B");
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 724
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    map<string, ll> mp;
    ll n;
    cin >> n;
    for (ll i = 0; i < n;i++){
        string s;
        cin >> s;
        mp[s]++;
    }
    ll m;
    cin >> m;
    for (ll i = 0; i < m;i++){
        string s;
        cin >> s;
        mp[s]--;
    }
    ll ans = 0;
    for (auto i : mp) ans = max(ans, i.second);
    cout << ans << endl;
}


Measured memory_bytes: 256
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
def zeros(n): return [0]*n
# def zeros(n): return np.zeros(n, dtype=np.longlong)
def zeros2(n, m): return [zeros(m) for i in range(n)] # obsoleted zeros((n, m))で代替

INF = 10**18

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                w = cmt + ': ' + str(x)
            else:
                w = str(x)
            print(w)
        return x

def prob():
    d = Debug()
    d.off()
    N = 5
    dish = zeros(N)
    for i in range(N):
        dish[i] = int(input())
    d.dmp((dish),'dish')
    minDigit1 = 10
    idx = N
    time = 0
    for i in range(N):
        if dish[i] % 10 > 0 and minDigit1 > dish[i] % 10:
            idx = i
            minDigit1 = dish[i] % 10
        time += (dish[i]+9)//10*10
        d.dmp((time),'time')
    d.dmp((time),'time')
    d.dmp((idx),'idx')
    if idx < N:
        time -= (dish[idx]+9)//10*10
        time += dish[idx]
    return time
    

ans = prob()
print(ans)


Measured memory_bytes: 3064
import sys

H, W, M = map(int, input().split())
A = [list(map(lambda x: int(x) - 1, input().split())) for i in range(M)]

cnth = [0] * H
cntw = [0] * W
st = set()

for y, x in A:
    cnth[y] += 1
    cntw[x] += 1
    st.add((y, x))

my = max(cnth)
mx = max(cntw)

Y = []
X = []

for i in range(H):
    if cnth[i] == my:
        Y.append(i)

for i in range(W):
    if cntw[i] == mx:
        X.append(i)

for y in Y:
    for x in X:
        if not (y, x) in st:
            print(my + mx)
            exit(0)

print(my + mx - 1)


Measured memory_bytes: 119240
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	int Y,X,a[512][512];cin>>Y>>X;
	for(int y=0;y<Y;y++)
	{
		for(int x=0;x<X;x++)
		{
			cin>>a[x][y];
		}
	}
	int n=0,b[250010][5]={0};
	for(int y=0;y<Y;y++)
	{
		for(int x=0;x<X-1;x++)
		{
			if(a[x][y]%2==1)
			{
				b[n][0]=y;b[n][1]=x;b[n][2]=y;b[n][3]=x+1;
				n++;
				a[x][y]-=1;
				a[x+1][y]+=1;
			}
		}
	}
	for(int y=0;y<Y-1;y++)
	{
		if(a[X-1][y]%2==1)
		{
			b[n][0]=y;b[n][1]=X-1;b[n][2]=y+1;b[n][3]=X-1;
			n++;
			a[X-1][y]-=1;
			a[X-1][y+1]+=1;
		}
	}
	cout<<n<<endl;
	for(int i=0;i<n;i++)
	{
		cout<<b[i][0]+1<<" "<<b[i][1]+1<<" "<<b[i][2]+1<<" "<<b[i][3]+1<<endl;
	}
	return 0;	
}		

Measured memory_bytes: 8064
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>


#ifdef MY_LOCAL
namespace sandbox {
#endif

using namespace std;

int main() {

	int n, m;
	cin >> n >> m;

	vector<vector<int>> passages(n);
	for (int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		passages[a].emplace_back(b);
		passages[b].emplace_back(a);
	}

	vector<int> signposts(n, -2);
	queue<int> q;
	signposts[0] = -1;
	q.push(0);
	while (!q.empty())
	{
		int this_room = q.front();
		q.pop();
		for (auto next_room : passages[this_room])
		{
			if (signposts[next_room] == -2)
			{
				q.push(next_room);
				signposts[next_room] = this_room;
			}
		}
	}

	for (auto this_signpost : signposts)
	{
		if (this_signpost == -2)
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	for (int j = 1; j < n; j++)
	{
		cout << signposts[j] + 1 << "\n";
	}

	return 0;
}

#ifdef MY_LOCAL
}
#endif

Measured memory_bytes: 10128
import java.util.Scanner


object Main {
  def read() = {
    val sc = new Scanner(System.in)
    val a, b, c = sc.nextInt()
    (a,b,c)
  }

  def solve(a: Int, b:Int, c:Int) : String = {
    val isOK :Boolean= a==b && b == c
    if(isOK) "Yes" else "No"
  }

  def main(args: Array[String]): Unit = {
    val (a,b,c) = read()
    println(solve(a,b,c))
  }
}

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

struct state {
    int i, j, k;
    state(int i, int j, int k) : i(i), j(j), k(k) { }
    bool operator<(const state a) const { return state(*this).i < a.i; }
};

int main() {
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X), B(Y), C(Z);
    rep(i, X) cin >> A[i];
    rep(i, Y) cin >> B[i];
    rep(i, Z) cin >> C[i];

    sort(A.rbegin(), A.rend());
    sort(B.rbegin(), B.rend());
    sort(C.rbegin(), C.rend());
    // priority_queue<ll> a, b, c;
    // rep(i, X) a.push(A[i]);
    // rep(i, Y) b.push(B[i]);
    // rep(i, Z) c.push(C[i]);

    // ll res = a.top() + b.top() + c.top();
    // cout << res << endl;
    // if (a.size() > 1) a.pop();
    // if (b.size() > 1) b.pop();
    // if (c.size() > 1) c.pop();
    // rep(i, K) {
    //     ll next;
    //     ll cake;
    //     if (!a.empty()) {
    //         next = a.top();
    //     }
    //     if (!b.empty()) {
    //     }
    // }

    // int ia, ib, ic;
    // ia = ib = ic = 0;
    // ll res = A[0] + B[0] + C[0];
    // priority_queue<ll> ans;
    // ans.push(res);

    // for (int i = 1; i < X; i++) {
    //     ll now = A[i] + B[0] + C[0];
    //     ans.push(now);

    //     ll comp;
    //     rep(j, Y) {
    //         rep(k, Z) {
    //             comp = A[i] + B[j] + C[k];
    //             if (now >= comp) {
    //                 ans.push(comp);
    //             }
    //             else {
    //                 break;
    //             }
    //         }
    //     }

    //     if (ans.size() >= 3000) break;
    // }

    // while (!ans.empty()) {
    //     cout << ans.top() << endl;
    //     ans.pop();
    // }

    vector<vector<vector<bool>>> used(X, vector<vector<bool>>(Y, vector<bool>(Z, false)));
    priority_queue<pair<ll, state>> que;
    que.push({A[0]+B[0]+C[0], state(0, 0, 0)});
    used[0][0][0] = true;
    int num = 0;

    while (num < K) {
        ll ans = que.top().first;
        state s = que.top().second;
        cout << ans << endl;
        que.pop();
        num++;

        int ni = s.i + 1;
        int nj = s.j + 1;
        int nk = s.k + 1;

        if (ni != X && !used[ni][s.j][s.k]) {
            que.push({A[ni] + B[s.j] + C[s.k], state(ni, s.j, s.k)});
            used[ni][s.j][s.k] = true;
        }
        if (nj != Y && !used[s.i][nj][s.k]) {
            que.push({A[s.i] + B[nj] + C[s.k], state(s.i, nj, s.k)});
            used[s.i][nj][s.k] = true;
        }
        if (nk != Z && !used[s.i][s.j][nk]) {
            que.push({A[s.i] + B[s.j] + C[nk], state(s.i, s.j, nk)});
            used[s.i][s.j][nk] = true;
        }
    }
}

Measured memory_bytes: 183408
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

#define ld  long double
#define ll  long long int
#define ull unsigned long long int
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,s,n) for(int i=s;i<n;i++)
#define endl "\n"

const int    INF = 1e11;
const double EPS = 1e-11;

//切り上げ整数除算
int divRoundUp(const int& a, const int& b) { return (a + b - 1) / b; }
//四捨五入
int roundOff(const double& a) { return (int)(a + 0.5); }
// r の(誤差付きの)符号に従って, -1, 0, 1 を返す.
int sgn(const ld& r) { return (r > EPS) - (r < -EPS); }
// a, b の(誤差付きの)大小比較の結果に従って, -1, 0, 1 を返す.
int sgn(const ld& a, const ld& b) { return sgn(a - b); }

using namespace std;

inline void Main() {
	int a, p; cin >> a >> p;
	cout << (a * 3 + p) / 2 << endl;
}

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

	Main();

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define max(A,B) (((A)>(B)) ? (A) : (B))
#define min(A,B) (((A)<(B)) ? (A) : (B))
#define abs(A) (((A)<0) ? (-(A)):(A))
#define celi(A,B) (((A)+(B)-1) / (B))
#define rep(i, n) for(l i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define MAX_N 1510
int dp[MAX_N][MAX_N];

string s;
void solve(int tc) {
	cin >> s;
	int n = 0, pos = 0;
	while (s[pos]) {
		n += (s[pos]-'0');
		pos++;
	}
	if (n % 9 == 0) cout << "Yes\n";
	else cout << "No\n";
	
}
signed main() {
	int T = 1, tc;
//	cin >> T;
	for (tc = 1; tc <= T; tc++) solve(tc);
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

/*
*/

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

signed main() {
  const int inf = 1e15;
  int h, n;
  cin >> h >> n;

  vi a(n), b(n);
  rep(i, 0, n) cin >> a[i] >> b[i];

  vi dp(h+1, inf);
  dp[0] = 0;
  rep(i, 0, n){
    rep(j, 0, h){
      chmin(dp[min(h, j+a[i])], dp[j]+b[i]);
    }
  }

  cout << dp[h] << endl;

  return 0;
}


Measured memory_bytes: 384