akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define mp(a,b) make_pair(a,b)
#define vi vector<int>
#define mii map<int,int>
#define mpi map<pair<int,int>,int>
#define vp vector<pair<int,int> >
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define F first
#define S second
#define endl "\n"
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define dom 998244353
#define pi 3.14159265
#define sl(a) (int)a.length()
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define pii pair<int,int> 
#define mini 2000000000000000000
#define time_taken 1.0 * clock() / CLOCKS_PER_SEC
//mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
void shikhar7s(int cas)
{
    int n,k,i;
    cin>>n>>k;
    int a[n];
    fr(i,n)
    {
        cin>>a[i];
    }
    int ans,st=1,end=mod-7,mid,x,y;
    while(st<=end)
    {
        mid=(st+end)/2;
        y=0;
        fr(i,n)
        {
            x=a[i]/mid;
            if(a[i]%mid)
                x++;
            y+=(x-1);
        }
        if(y<=k)
        {
            end=mid-1;
            ans=mid;
        }
        else
        {
            st=mid+1;
        }
    }
    cout<<ans;
}
signed main()
{
    fast;
    int t=1;
    //cin>>t;
    int cas=1;
    while(cas<=t)
    {
    shikhar7s(cas);
    cas++;
    }
    return 0;
}

Measured memory_bytes: 5076
#define DEBUG 0
/**
 * File    : B.cpp
 * Author  : Kazune Takahashi
 * Created : 2019/8/18 21:01:15
 * Powered by Visual Studio Code
 */
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <functional>
#include <random>
#include <chrono>
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
using ll = long long;
class mint
{
public:
  static ll MOD;
  ll x;
  mint() : x(0) {}
  mint(ll x) : x(x % MOD) {}
  mint operator-() const { return x ? MOD - x : 0; }
  mint &operator+=(const mint &a)
  {
    if ((x += a.x) >= MOD)
    {
      x -= MOD;
    }
    return *this;
  }
  mint &operator-=(const mint &a) { return *this += -a; }
  mint &operator*=(const mint &a)
  {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint &operator/=(const mint &a)
  {
    mint b{a};
    return *this *= b.power(MOD - 2);
  }
  mint operator+(const mint &a) const { return mint(*this) += a; }
  mint operator-(const mint &a) const { return mint(*this) -= a; }
  mint operator*(const mint &a) const { return mint(*this) *= a; }
  mint operator/(const mint &a) const { return mint(*this) /= a; }
  bool operator<(const mint &a) const { return x < a.x; }
  bool operator==(const mint &a) const { return x == a.x; }
  const mint power(ll N)
  {
    if (N == 0)
    {
      return 1;
    }
    else if (N % 2 == 1)
    {
      return *this * power(N - 1);
    }
    else
    {
      mint half = power(N / 2);
      return half * half;
    }
  }
};
ll mint::MOD = 1e9 + 7;
istream &operator>>(istream &stream, mint &a) { return stream >> a.x; }
ostream &operator<<(ostream &stream, const mint &a) { return stream << a.x; }
class combination
{
public:
  vector<mint> inv, fact, factinv;
  static int MAX_SIZE;
  combination() : inv(MAX_SIZE), fact(MAX_SIZE), factinv(MAX_SIZE)
  {
    inv[1] = 1;
    for (auto i = 2; i < MAX_SIZE; i++)
    {
      inv[i] = (-inv[mint::MOD % i]) * (mint::MOD / i);
    }
    fact[0] = factinv[0] = 1;
    for (auto i = 1; i < MAX_SIZE; i++)
    {
      fact[i] = mint(i) * fact[i - 1];
      factinv[i] = inv[i] * factinv[i - 1];
    }
  }
  mint operator()(int n, int k)
  {
    if (n >= 0 && k >= 0 && n - k >= 0)
    {
      return fact[n] * factinv[k] * factinv[n - k];
    }
    return 0;
  }
};
int combination::MAX_SIZE = 3000010;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
// constexpr double epsilon = 1e-10;
// constexpr ll infty = 1000000000000000LL;
// constexpr int dx[4] = {1, 0, -1, 0};
// constexpr int dy[4] = {0, 1, 0, -1};
void Yes()
{
  cout << "Yes" << endl;
  exit(0);
}
void No()
{
  cout << "No" << endl;
  exit(0);
}

int main()
{
  int N;
  cin >> N;
  vector<double> A(N);
  for (auto i = 0; i < N; i++)
  {
    cin >> A[i];
  }
  double X{0.0};
  for (auto i = 0; i < N; i++)
  {
    X += 1 / A[i];
  }
  cout << scientific << setprecision(12) << 1 / X << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define N 1000000007
#define ll long long
#define ull unsigned long long
#define mem(a) memset(a,0,sizeof(a))

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    double r;
    cin >> r;
    printf("%lf", 2*r*pi);
    return 0;
}


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

int main() { /* ここに書く */

  long long A,B,N,X,Ans;
  
  cin >> A >> B >> N;
  
  if( B > N ){
    X = N;}
  else{
    X = B-1;}
  
  Ans = (A*X)/B - (X/B)*A;
  
  cout << Ans <<endl;
  
    }

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define il inline
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define rep0(i, n) for(int i = 0; i < (n); i ++)
#define per0(i, n) for(int i = (n) - 1; i >= 0; i --)
#define ept 1e-9
#define INF 0x3f3f3f3f
#define sz(x) (x).size()
#define ALL(x) (x).begin(), (x).end()
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
inline ll read1()
{
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
using namespace std;
int n;
ll a[200010], sum[200010], ans;
map<ll, int> m;
int main()
{
	n = read();
	rep(i, 1, n)
		a[i] = read();
	rep(i, 1, n)
		sum[i] = sum[i - 1] + a[i];
	m[0] ++;
	rep(i, 1, n)
		m[sum[i]] ++;
	rep(i, 1, n)
		if(m[sum[i]] > 1)
		{
			ans += 1ll * m[sum[i]] * (m[sum[i]] - 1);
			m[sum[i]] = 1;
		}
	cout << ans / 2;

	return 0;
}



Measured memory_bytes: 16000
#include <iostream>
#include <string>
#define int long long
using namespace std;

int sum = 0;

void dfs(string s,int tmp,int cnt){
	if(s == ""){
		sum += tmp + cnt;
		return;
	}
	dfs(s.substr(1),tmp * 10 + s[0] - '0',cnt);
	dfs(s.substr(1),0,tmp * 10 + s[0] - '0' + cnt);
}

signed main(){
	string s;
	cin >> s;
	dfs(s,0,0);
	cout << sum / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define SI size()
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PF push_front
#define PB push_back
#define VE vector<int>
#define VP vector<PA>
#define LL long long
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int MOD=1e9+7;
const int INF=1e9+7;
//
int N;
int X[100000],Y[100000];
//
struct edge{int from,to,cost;};
//
bool comp(const edge& e1,const edge& e2){
  return e1.cost<e2.cost;
}
//
vector<edge> es;
int V,E;
//
int par[100000];//親
int runk[100000];//木の深さ
//初期化
void init(int n){
  FOR(i,0,n){
    par[i]=i;
    runk[i]=0;
  }
}
//木の根を求める
int find(int x){
  if(par[x]==x){
    return x;
  }else{
    return par[x]=find(par[x]);
  }
}
//Xの属する集合とYの属する集合を併合
void unite(int x,int y){
  x=find(x);
  y=find(y);
  if(x==y){
    return;
  }
  if(runk[x]<runk[y]){
    par[x]=y;
  }else{
    par[y]=x;
    if(runk[x]==runk[y]){
      runk[x]++;
    }
  }
}
//XとYが同じ集合に属するか否か
bool same(int x,int y){
  return  find(x)==find(y);
}
//
long long kruskal(){
  sort(es.begin(),es.end(),comp);
  init(V);
  long long res=0;
  FOR(i,0,E){
    edge e=es[i];
    if(!same(e.from,e.to)){
      unite(e.from,e.to);
      res+=e.cost;
    }
  }
  return res;
}
//
int main(){
  cin>>N;
  VP x,y;
  FOR(i,0,N){
    cin>>X[i]>>Y[i];
    x.PB(MA(X[i],i));
    y.PB(MA(Y[i],i));
  }
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  V=N;
  E=2*(N-1);
  FOR(i,0,N-1){
    int num1=x[i].SE,num2=x[i+1].SE;
    es.PB({num1,num2,min(abs(X[num1]-X[num2]),abs(Y[num1]-Y[num2]))});
    num1=y[i].SE;num2=y[i+1].SE;
    es.PB({num1,num2,min(abs(X[num1]-X[num2]),abs(Y[num1]-Y[num2]))});
  }
  cout<<kruskal()<<endl;
  return 0;
}


Measured memory_bytes: 7784
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        int a=in.nextInt(),b=in.nextInt();
        double ans=(a+b)/2.0;
        System.out.println(Math.round(ans));
    }
}

Measured memory_bytes: 20820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
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; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

int main() {
  int a,b; cin >> a >> b;
  if (a == b) {
    cout << 0 << endl;
    return 0;
  }
  if (abs(a) == abs(b)) {
    cout << 1 << endl;
    return 0;
  }
  if (abs(a) < abs(b)) {
    int ans = abs(b) - abs(a);
    if (a < 0) ans++;
    if (b < 0) ans++;
    cout << ans << endl;
    return 0;
  } else {
    int ans = abs(a) - abs(b);
    if (a > 0) ans++;
    if (b > 0) ans++;
    cout << ans << endl;
    return 0;
  }
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll inf = 1e18;
ll mod=1e9+7;
//LLONG_MIN

/*
*/

ll a,b,ans=0,a2=0;

ll f(ll s){
	ll sum=0;
	rep(i,40){
		if(i==0){
			if((s+1)/2%2==1)sum+=1;
			continue;
		}
		bool ok=false;
		ll x=(ll)1<<i;
		// cout<<x<<endl;
		if((s/x)%2 == 1 && ((s+1)%x)%2 == 1)ok=true;
		if(ok)sum+=x;
	}
	// cout<<s<<":"<<sum<<endl;
	return sum;
}

int main(void){
	cin>>a>>b;
	cout<<(f(b)^f(a-1))<<endl;
	return 0;
}

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

int main()
{
    ll n, a[300000], ans = 0, count = 1;
    cin >> n;
    rep(i, n) cin >> a[i];
    rep(i, n)
    {
        if (a[i] == count)
        {
            count++;
        }
        else
        {
            ans++;
        }
    }
    if (ans == n)
        cout << -1 << endl;
    else
        cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5156
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int dp[3010][3010];

int main(){ _;
  string s,t;cin>>s>>t;
  int ssize=s.size();
  int tsize=t.size();
  REP(i,ssize+1)dp[i][tsize+1]=0;
  REP(j,tsize+1)dp[ssize+1][j]=0;

  for(int i=ssize-1;i>=0;i--){
    for(int j=tsize-1;j>=0;j--){
      dp[i][j]=max(dp[i+1][j],dp[i][j+1]);
      if(s[i]==t[j])
	dp[i][j]=max(dp[i][j],dp[i+1][j+1]+1);
    }
  }

  if(dp[0][0]==0){
    cout<<endl;
    return 0;
  }

  for(int i=0,j=0;;){
    if(dp[i][j]==dp[i+1][j]){
      i++;
      continue;
    }
    if(dp[i][j]==dp[i][j+1]){
      j++;
      continue;
    }
    cout<<s[i];
    i++;j++;
    if(dp[i][j]==0)break;
  }
  cout<<endl;
}


Measured memory_bytes: 35584
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef double d;
typedef long double ld;
template <typename T>
void ContainerError(T &v){cout<<"{";for(auto &x:v){cout<<x<<',';}cout<<"}"<<endl;return;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,k;
    cin>>n>>k;
    vector<ll> v(n);
    for(auto &x:v)
    {
        cin>>x;
    }
    vector<ll> dp(k+1,0);
    dp[0]=0;
    for(ll i=1;i<=k;i++)
    {
        for(ll j=0;j<n;j++)
        {
            ll val = i-v[j];
            if(val>=0)
            {
                if(dp[val]==0){dp[i]=1;break;}
            }
        }
    }
    if(dp[k]){cout<<"First";}
    else{cout<<"Second";}
    return 0;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

void dfs(int v, vector<vector<int>> &G, vector<bool> &used){
    used[v] = true;
    for(auto nv : G[v]){
        if(used[nv] == false) dfs(nv, G, used);
    }
    return;
}

int main(){
    int n, m; cin >> n >> m;
    vector<vector<int>> G(n);
    rep(i,m){
        int x, y, z; cin >> x >> y >> z;
        x--; y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }

    int ans = 0;
    vector<bool> used(n,false);
    rep(i,n){
        if(used[i] == false){ dfs(i, G, used); ans++; }
    }
    cout << ans << endl;
}

Measured memory_bytes: 13532
use proconio::input;
use proconio::marker::Usize1;
use std::cmp::{max, min};

type QT = (usize, usize, u64, u64);

fn main() {
    input! {
        n: usize,
        m: u64,
        q: usize,
        arr: [(Usize1, Usize1, u64, u64); q],
    }

    let mut solve = Solve {
        n,
        m,
        q,
        arr,
        ans: 0,
    };
    solve.solve();
}

struct Solve {
    n: usize,
    m: u64,
    q: usize,
    arr: Vec<QT>,
    ans: u64,
}

impl Solve {
    fn solve(&mut self) {
        self.dfs(vec![]);
        let ans = self.ans;
        println!("{}", ans);
    }

    fn dfs(&mut self, v: Vec<u64>) {
        if v.len() == self.n {
            let c = self.calc(&v);
            self.ans = max(self.ans, c);
            return;
        }

        let last = match v.last() {
            Some(x) => *x,
            None => 1,
        };

        for next in last..=self.m {
            let mut u = v.clone();
            u.push(next);
            self.dfs(u);
        }
    }

    fn calc(&self, v: &Vec<u64>) -> u64 {
        let mut ret = 0u64;
        for &(a, b, c, d) in &self.arr {
            if v[b] - v[a] == c {
                ret += d;
            }
        }

        ret
    }
}


Measured memory_bytes: 2200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl


int main() {
    int N;  cin >> N;
    vector<int> W(N);  rep(i, N) cin >> W[i];

    vector<int> ans;
    rep(i, N) {
        int s1 = 0, s2 = 0;
        for (int j = 0; j <= i; ++j) {
            s1 += W[j];
        }
        for (int k = i+1; k < N; ++k) {
            s2 += W[k];
        }
        ans.push_back(abs(s1-s2));
    }

    sort(all(ans));
    print(ans[0]);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector <int> dp;
int main(){
	int n;
  	cin>>n;
  	vector <vector<int> >  v(n, vector <int> (3));
  	for(int i=0; i<n;i++){
  		cin>>v[i][0]>>v[i][1]>>v[i][2];
	}
	vector <vector <int> > dp(n+1, vector <int> (3, 0));
	dp[0][0] = v[0][0];
	dp[0][1] = v[0][1];
	dp[0][2] = v[0][2];
	for(int i=1; i<n;i++){
		for(int j=0; j<3;j++){
			for(int k=0; k<3;k++){
				if(j==k) continue;
				dp[i][j] = max(dp[i][j], dp[i-1][k]+v[i][j]);
			}
		}
	}
	cout<< max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]))<<endl;
}

Measured memory_bytes: 11136
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<cmath>
#include<cstdio>
#include<cassert>
using namespace std;

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0)); 
const double INF = 0x3f3f3f3f;
const double INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
const double mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int N, Q;
vi G[200010];
int X[200010];
int C[200010];

void dfs(int v, int p, int x){
    C[v] = x + X[v];
    for(int u : G[v]){
        if(u == p) continue;
        dfs(u, v, C[v]);
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");

    cin >> N >> Q;
    rep(i,N-1){
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    rep(i,N) X[i] = 0;
    rep(i,Q){
        int p, x;
        cin >> p >> x;
        X[p] += x;
    }
    dfs(1, -1, 0);
    
    REP(i,1,N+1) cout << C[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 24320
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>pii;
//#define int ll
const int maxn=2e5+10,inf=0x3f3f3f3f,mod=998244353;
//#define DEBUG//#define lowbit(x) ((x) & -(x))//<<setiosflags(ios::fixed)<<setprecision(9)
void read(){}
template<typename T,typename... T2>inline void read(T &x,T2 &... oth) {
	x=0; int ch=getchar(),f=0;
	while(ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	if(f)x=-x;
	read(oth...);
}
ll fac[maxn],a[maxn];
ll quick(ll a,ll b){//快速幂
	ll ans=1;
	while(b){
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ans%mod;
}
ll ccc(ll n,ll m){//求组合数
	return (fac[n] * quick(fac[m], mod - 2) % mod * quick(fac[n - m], mod - 2) % mod)%mod;
}
void initccc()
{
	fac[0] = 1;
	for (int i = 1; i <maxn ;i++){
		fac[i] = fac[i - 1] * i % mod;
	}
}
ll qmod(ll a,ll b,ll mod)  //快速幂
{
	ll ans=1;
	a=a%mod;
	while(b)
	{
		if(b&1)
			ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
ll n,m,k;//n块,m色,k块
ll get(ll x)//有k个和左面颜色相同
{//第一块m个颜色
	ll ret=0,oth=n-x-1;//其他的颜色块
	ret=(m*(ccc(n-1,x)*qmod(m-1,oth,mod)%mod)%mod)%mod;
	return ret;
}
signed main()
{
	std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	#ifdef DEBUG
		freopen("input.in", "r", stdin);
	//	freopen("output.out", "w", stdout);
	#endif
	initccc();
	cin>>n>>m>>k;
	ll ans=0;
	for(ll i=0;i<=k;i++)
		ans=(ans+get(i))%mod;
//	ll ans=qmod(m,n,mod);
//	for(ll i=k+1;i<=n;i++)
//	{
//		ll now=get(i);
//		ans=((ans-now)+mod)%mod;
//	}
	cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 5228
#include <bits/stdc++.h>
#define pb push_back
#define CLR(a) memset(a, 0, sizeof a)
#define SETDP(a) memset(a, -1, sizeof a)
#define SETINF(a) memset(a, 127, sizeof a)
using namespace std;
const int maxn=2e5+100;
typedef long long ll;
typedef pair<int, int>pii;
pii arr[maxn];
int ans[maxn];
int n;
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>arr[i].first;
        arr[i].second=i;
    }
    int f, s;
    sort(arr, arr+n);
    f=arr[n/2-1].first;
    s=arr[n/2].first;
    for(int i=0; i<n; i++)
    {
        if(i<=n/2-1)ans[arr[i].second]=s;
        else ans[arr[i].second]=f;
    }
    for(int i=0; i<n; i++)
        cout<<ans[i]<<"\n";
    return 0;
}


Measured memory_bytes: 4608
import queue

K = int(input())

num_queue = queue.Queue()
for i in range(1, 10):
    num_queue.put(i)

for i in range(K):
    ans = num_queue.get()
    if ans % 10 != 0:
        num_queue.put(10 * ans + ans % 10 - 1)
    num_queue.put(10 * ans + ans % 10)
    if ans % 10 != 9:
        num_queue.put(10 * ans + ans % 10 + 1)
        
print(ans)

Measured memory_bytes: 12452
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define bg(x) (x).begin()
#define ed(x) (x).end()
#define ar array
#define ll long long int
const int sz = 1e6 + 5;
vector<int> cnt(sz, 0);

const ll mod = 1e9 + 7;


int f(vector<int> &a, int greatest) 
{ 
    for (int &x : a)
        cnt[x]++;
    int counter = 0; 
  
    
    for (int i = greatest; i >= 1; i--) {
        int j = i; 
        counter = 0; 
    
        while (j <= greatest) 
        { 
  
            if(cnt[j] >=2) 
               return j; 
  
           else if (cnt[j] == 1)          
                counter++;          

            j += i; 
  
            if (counter == 2)          
                return i; 
        } 
    }
    return 1; 
} 

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
      int n;
      cin >> n;
      vector<int> a(n);
      int maxm = 0;
      for (int i = 0; i < n; ++i) {
        cin >> a[i];
        maxm = max(maxm, a[i]);
      }
      int g = a[0];
      for (int i = 1; i < n; ++i)
        g = __gcd(g, a[i]);
      bool ok = f(a, maxm) == 1;
      if (ok) {
          cout << "pairwise coprime";
      }
      else if (g == 1) {
          cout << "setwise coprime";
      }
      else {
          cout << "not coprime";
      }


    }

    return 0;
}

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

int main()
{
    int n,m,x;
    std::cin >> n >> m >> x;
    std::vector<int> c(200);
    for(int i = 0; i < m; i++){
        int t; std::cin >> t;
        c[t]++;
    }
    int a = 0,b = 0;
    for(int i = x; i <= n; i++)a += c[i];
    for(int i = x; i >= 0; i--)b += c[i];
    std::cout << std::min(a,b) << std::endl;
}

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

#define PI 3.14159265358979323846264338327950L

long long int res;

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

    int N;
    cin >> N;
    int *data = new int[N];
    long long int sum = 0;
    for (int i = 0; i < N + 1; i++)
    {
        cin >> data[i];
        sum += data[i];
    }
    long long int extra = 1;
    long long int number = 1;
    bool flag = true;
    long long int  tmp = 0;
    for (int i = 0; i < N + 1; i++)
    {
        extra -= data[i];
        if (extra < 0)
        {
            res = -1;
            flag = false;
            break;
        }
        if (sum < extra)
        {
            flag = true;
            break;
        }
        extra = extra * 2;
    }

    if (flag == true)
    {

        for (int i = 0; i < N + 1; i++)
        {
            tmp += number;
            if (data[i] != 0)
            {
                sum -= data[i];
                number -= data[i];
            }
            if (number * 2 <= sum)
            {
                number = number * 2;
            }
            else if (number * 2 > sum)
            {
                number = sum;
            }
        }
        res = tmp;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4036
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol abs(lol x,lol y){return(x>y?x-y:y-x);}
lol max(lol x,lol y){if(x>y)return x;return y;}
lol min(lol x,lol y){if(x<y)return x;return y;}
int abc[100];
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >>s;
    bool ans=true;
    for(int i=0;i<s.size();i++){
      abc[s[i]-'a']++;
    }
    for(int i='a';i<='z';i++){
      if(abc[i-'a']%2!=0) ans=false;
    }
    if(ans) cout <<"Yes\n";
    else cout <<"No\n";
    return (0);
}


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

int a,b;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>a>>b;
    if((a+b)%2){
        cout<<"IMPOSSIBLE"<<endl;
    }else{
        cout<<(a+b)/2<<endl;
    }

    return 0;
}

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

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

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

    bool negative_even = true;
    int min_abs = -1;
    long long ans = 0;

    for(int i = 1; i <= N; i++) {
        int A;
        cin >> A;
        ans += abs(A);
        if(A < 0) {
            negative_even ^= true;
        }
        if(min_abs < 0 || abs(A) < min_abs) {
            min_abs = abs(A);
        }
    }
    if(!negative_even) {
        ans -= 2 * min_abs;
    }

    cout << ans << endl;

    return 0;
}


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

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 110

int sum(int n) {
    string s = to_string(n);
    int ret = 0;
    REP(i, s.length()) {
        ret += s[i] - '0';
    }
    return ret;
}

signed main()
{
    int N;
    cin >> N;

    if(N % sum(N) == 0) { printf("Yes\n"); }
    else { printf("No\n"); }

    return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = np.array(list(read().rstrip().decode()))

def f(S, a):
    S = S == a
    if not np.any(S):
        return len(S)
    for n in range(len(S)):
        if np.all(S):
            return n
        S = S[1:] | S[:-1]

x = min(f(S, a) for a in S)
print(x)

Measured memory_bytes: 27196
import java.io.*;
       
public class Main {
    public static void main(String[] args) throws IOException{
        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(is);
        int n = Integer.parseInt(br.readLine());
        String[] A = br.readLine().split(" ", 0);
        int i, j;
        String v;
                
        System.out.println(String.join(" ", A));
  
        for(i=1; i<n; i++){
            v = A[i];
            j = i - 1;
            while(j>=0 && Integer.parseInt(v)<Integer.parseInt(A[j])){
                A[j+1] = A[j];
                j--;
            }
            A[j+1] = v;
            System.out.println(String.join(" ", A));
        }
    }
}

Measured memory_bytes: 26944
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
in p2(in a){
  return 1<<a;
}
in sel(in a, in b){
  if(a<b)
    return 0;
  in c=1;
  for(in i=a;i>a-b;--i)
    c*=i;
  return c;
}
VI bcl;
VVI cl;
VVI cord={{0,5,4,1},{1,4,7,2},{2,7,6,3},{5,0,3,6}};
map<VI,in> hv;
VVI socl;
VI cnn(VI a){
  VI r=a;
  forn(z,4){
    rotate(a.begin(),a.begin()+1,a.end());
    r=min(r,a);
  }
  return r;
}
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n;
  cin>>n;
  cl.resize(n,VI(4));
  forn(z,n){
    forn(i,4)
      cin>>cl[z][i];
  }
  socl=cl;
  forn(z,n){
    socl[z]=cnn(socl[z]);
    ++hv[socl[z]];
  }
  bcl.resize(8);
  in sm=0;
  forn(b,n){
    --hv[socl[b]];
    for(in a=b+1;a<n;++a){
      --hv[socl[a]];
      forn(z,4){
	rotate(cl[a].begin(),cl[a].begin()+1,cl[a].end());
	forn(k,4){
	  bcl[k]=cl[b][k];
	  bcl[k+4]=cl[a][k];
	}
	VVI tr(4,VI(4));
	forn(i,4){
	  forn(j,4){
	    tr[i][j]=bcl[cord[i][j]];
	  }
	  tr[i]=cnn(tr[i]);
	}
	sort(all(tr));
	in cw=1;
	in sf=0;
	forn(i,4){
	  if(i!=0 && tr[i]!=tr[i-1]){
	    cw*=sel(hv[tr[i-1]],sf);
	    sf=1;
	  }
	  else
	    ++sf;
	}
	cw*=sel(hv[tr[3]],sf);
	VI tp;
	forn(i,4){
	  tp=tr[i];
	  in ss=0;
	  forn(j,4){
	    rotate(tp.begin(),tp.begin()+1,tp.end());
	    ss+=(tp==tr[i]);
	  }
	  cw*=ss;
	}
	sm+=cw;
      }
      ++hv[socl[a]];
    }
  }
  cout<<sm<<endl;
  return 0;
}


Measured memory_bytes: 160000
import math
A, B = map(int,input().split())
A_cf = []
B_cf = []
for i in range(1,int(A**0.5)+1):
    if A % i == 0:
        A_cf.append(i)
        if i != A // i:
            A_cf.append(A//i)
for i in range(1,int(B**0.5)+1):
    if B % i == 0:
        B_cf.append(i)
        if i != B // i:
            B_cf.append(B//i)
DA = dict()
for i in range(len(A_cf)):
    DA[A_cf[i]] = False

for i in range(len(B_cf)):
    if B_cf[i] in DA:
        DA[B_cf[i]] = True
cf = []
for i in range(len(A_cf)):
    if DA[A_cf[i]]:
        if A_cf[i] % 2 == 0 and A_cf[i] != 2:
            continue
        cf.append(A_cf[i])
prime_num = []
cf.sort()

def isPrime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
for i in range(len(cf)):
    if isPrime(cf[i]):
        prime_num.append(cf[i])

ans = len(prime_num) + 1
print(ans)

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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int h, w, a, b;
  std::cin >> h >> w >> a >> b;
  int grid[h][w];
  rep(i, h) rep(j, w) grid[i][j] = 0;
  rep(i, b) rep(j, a) grid[i][j] = 1;
  srep(i, b, h) srep(j, a, w) grid[i][j] = 1;
  rep(i, h) {
    rep(j, w) cout << grid[i][j];
    std::cout << "\n";
  }
}


Measured memory_bytes: 5120
N = int(input())
R = [list(map(int, input().split())) for _ in range(N)]
B = [list(map(int, input().split())) for _ in range(N)]
B.sort()
#print(f'B:{B}')
R.sort(key=lambda x: -x[1])
#print(f'R:{R}')
cnt = 0
for b in B:
    #print('----------------------------------------------------')
    bx = b[0]; by = b[1]
    #print(f'bx:{bx} by:{by}')
    for ir, r in enumerate(R):
        rx = r[0]; ry = r[1]
        #print(f'rx:{rx} ry:{ry}')
        if rx < bx and ry < by:
            R.pop(ir)
            cnt += 1
            break
print(cnt)

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

int main(){
    int r, c, n; cin >> r >> c >> n;
    
    int count = 0;
    int big = max(r,c);
    while(n > 0){
        n = n - big;
        count++;
    }
   
    cout << count << endl; 
    return 0;
}

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

int main() {
  long long n, a, nmin = INT_MAX, nmax = INT_MIN, sum = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    nmax = max(a, nmax);
    nmin = min(a, nmin);
    sum += a;
  }
  cout << nmin << " " << nmax << " " << sum << endl;
}

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


int main() {
int K,A,B;
  cin >>K>>A>>B;
  bool judge = 1;
  for(int i=1;i<1001;i++){
   if(K*i>=A && K*i<=B) {
    cout << "OK"<<endl;
     judge = 0;
     break;
   }
  }
  if(judge){
    cout << "NG" <<endl;
  }
}

Measured memory_bytes: 3620
#include <stdio.h>
 
using namespace std;
 
void outPut(int Array[],char mark){
    for(int i = 1; i <= 13; i++){
        if(Array[i] == 0) printf("%c %d\n",mark,i);
    }
}
 
int main(){
    char mark[2];
    int n,S[14],H[14],C[14],D[14],tmp;
    for(int i = 0; i < 14; i++) S[i] = H[i] = C[i] = D[i] = 0;
    scanf("%d",&n);
 
    for(int i = 0; i < n; i++){
        scanf("%s %d",mark,&tmp);
        switch(mark[0]){
        case 'S':
            S[tmp] = 1;
            break;
        case 'H':
            H[tmp] = 1;
            break;
        case 'C':
            C[tmp] = 1;
            break;
        case 'D':
            D[tmp] = 1;
            break;
        }
    }
    outPut(S,'S');
    outPut(H,'H');
    outPut(C,'C');
    outPut(D,'D');
}


Measured memory_bytes: 2620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 987654321;
const ll MOD = 1000000007;



int main(void) {
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL); 
  cout.tie(NULL);
  //freopen("in.txt", "r", stdin);
  int n;
  cin >> n;
  int digitSum = 0;
  while(n) {
    digitSum += n%10;
    n = n/10;
  }
  if(digitSum == 1) {
    cout << 10 << endl;
  } else {
    cout << digitSum << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		long K = scan.nextLong();
		int N = scan.nextInt();
		long [] house = new long[N + 1];
		long l = 0;

		for(int i=0; i < N; i++){
			house[i] = scan.nextLong();
		}
		house[N] = K + house[0];

		for(int i=0; i < N; i++){
			if (l < (house[i+1] - house[i]) )l = (house[i+1] - house[i]);
		}

		System.out.println(K - l);
	}
}

Measured memory_bytes: 88252
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;


int main(void)
{
	//変数の宣言
	int a,b;

	//よく使う変数
	int i,j,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	int dummy;



	//データの読み込み


	scanf("%d %d",&a,&b);
//	scanf_s("%d %d",&a,&b);



/*	for(i=0;i<m;i++){
//		scanf("%d %d",&a,&b);
		scanf_s("%d %d",&a,&b);
	}*/

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	temp1=2*max(a,b)-1;
	temp2=a+b;
	ans=max(temp1,temp2);


	//	printf("計算部分終了\n");

	//出力
	printf("%d",ans);

	//	printf("結果の出力終了\n");

	return 0;
}



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

int main(){
	int w, g[10];
	vector<int> ans;

	for(int i=0,j=1 ; j<=512 ; j*=2, i++){
		g[i] = j;
	}

	while( cin >> w ){
		ans.clear();
		for(int i=9 ; i>=0 ; i--){
			if( w <= 1 ){
				if( w == 1 ) ans.push_back( w ); 
				break;
			}
			else if( g[i] <= w ){
				w -= g[i];
				ans.push_back( g[i] ); 
			}
		}
		for(int i=ans.size()-1 ; i>=0 ; i--){
			cout << ans[i] ;
			(i==0)? cout << endl : cout << " ";
		}
	}
}

Measured memory_bytes: 0
n, a, b = map(int, input().split())
mod = 10 ** 9 + 7
s = pow(2, n, mod) - 1


def comb(n, r):
    p, q = 1, 1
    for i in range(r):
        p = p * (n - i) % mod
        q = q * (i + 1) % mod
    return p * pow(q, mod - 2, mod) % mod


print((s - comb(n, a) - comb(n, b))%mod)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define PI pair<int,int>
#define ff first
#define ss second
#define endl '\n'
#define boost ios_base::sync_with_stdio(0);cin.tie(0)
const int inf=1e18;

int mod(int n,int k)
{
    n%=k;
    n+=k;
    return n%k;
}


int32_t main()
{
    boost;
    
    int n,k,ans=0;
    cin>>n>>k;
    int a[n+1],pre[n+1]={0};
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        a[i]=mod(a[i],k);
        pre[i]=mod(pre[i-1]+a[i],k);
    }

    for(int i=1;i<=n;i++){
        pre[i]=mod(pre[i]-i,k);
        //cout<<pre[i]<<" ";
    }
    //cout<<endl;
    unordered_map<int,int>mp;
    mp[0]=1;
    for(int i=1;i<=n;i++)
    {
        if(i>=k)
            mp[pre[i-k]]--;
        ans+=mp[pre[i]];
        mp[pre[i]]++;
    }
    cout<<ans<<endl;
}


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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	int p[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>p[i];
	}
	int ans=0;
	for (int i = 1; i < n-1; ++i)
	{
		if ((p[i-1]<p[i]&&p[i]<p[i+1])||(p[i-1]>p[i]&&p[i]>p[i+1]))
		{
			++ans;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
while True:
    a,op,b=input().split()
    a=int(a)
    b=int(b)
    if op=="+":
        print(a+b)
    elif op=="-":
        print(a-b)    
    elif op=="*":
        print(a*b)
    elif op=="/":
        print(a//b)    
    else:
        break


Measured memory_bytes: 5592
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 M = sc.nextInt();
		int[] a = new int[A];
		int[] b = new int[B];
		int i,minA,minB,sum,x,y,c;
		for(i = 0;i < A;i++){
			a[i] = sc.nextInt();
		}
		for(i = 0;i < B;i++){
			b[i] = sc.nextInt();
		}
		minA = min(a,A);
		minB = min(b,B);
		sum = minA + minB;
		for(i = 0;i < M;i++){
			x = sc.nextInt();
			y = sc.nextInt();
			c = sc.nextInt();
			if((a[x-1] + b[y-1] - c) < sum){
				sum = (a[x-1] + b[y-1] - c);
			}
		}
		System.out.println(sum);
	}
	public static int min(int[] list,int mini){
		int i;
		int buf = 100000;
		for(i = 0;i < mini;i++){
			if(buf > list[i]){
				buf = list[i];
			}
		}
		return buf;
	}
}

Measured memory_bytes: 132976
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  int n;
  cin >> n;
  int i;
  vector<int> a(n);
  int ans = 0;
  for(i = 0;i < n;++i){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  for(i = 0;i < n;++i){
    if(i % 2 == 0){
      ans += a.at(i);
    }else{
      ans -= a.at(i);
    }
  }
  cout << ans << endl;
  return 0;
}

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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<ll>;
#define EPS (1e-7)
#define INF (1e9)
#define PI  (acos(-1))
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define REP(i,n) for(int i= 0;i<(int)(n);++i)
#define pb push_back

veci enum_div(int n){
	veci ret;
	ret.pb(1);
	for(int i=1;i*i<n;i++){
		if(n%i==0){
			ret.pb(i);
			if(i != n/i){ret.pb(n/i);}
		}
	}
	ret.pb(n);
	return ret;
}
int gcb(int a,int b){return ((b == 0)? a : gcb(b,a%b));}
int gcd(int a,int b){return (a*b) / gcb(a,b);}

int main(){
    string s;
    cin >> s;
    s[5]=s[13]=' ';
    cout << s << endl;
    return 0;
}



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

/*湖の外周: K, 宅数: N, */

int main() {
	int K;
	int N;
	int sum = 0;

	cin >> K >> N;

	vector<int> A(N);
	vector<int> R(N);//隣同士のお宅の距離の行列

	for (int k = 0; k < N; k++) {
		cin >> A.at(k);
	}
	for (int k = 0; k < N-1; k++) {
		R.at(k) = A.at(k + 1) - A.at(k);
	}
	R.at(N-1) = A.at(0) - A.at(N-1) + K;

	sort(R.begin(), R.end());

	for (int k = 0; k < N - 1; k++) {
		sum += R.at(k);
	}

	cout << sum << endl;

	
}

Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

int MOD_BIG = 1000000007;
int MOD_BIG2 = 998244353;
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using std::vector;

#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

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

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

int main() {
    
    int N, M;
    cin >> N >> M;
    using P = std::pair<int, int>;
    using PP = std::pair<ll, P>;
    vector<int> PRE(M);
    std::priority_queue<PP, vector<PP>, std::greater<PP>> pq;
    FOR(i, 0, M) {
        int p;
        ll q;
        cin >> p >> q;
        PRE[i] = p;
        pq.push(std::make_pair(q,std::make_pair(i, p)));
    }
    vector<int> num(N, 0);
    vector<int> ans(M);
    while (!pq.empty()) {
        auto pp = pq.top();
        pq.pop();
        ans[pp.second.first] = ++num[pp.second.second-1];
    }
    REP(i, M) {
        printf("%06d%06d\n", PRE[i], ans[i]);
    }
    
    return 0;
}


Measured memory_bytes: 4208
#include<bits/stdc++.h>
#define N 100010
using namespace std;
int n,K,s[2010][2010],t[2010][2010];
int qrys(int x1,int y1,int x2,int y2)
{
	return s[x2][y2]-s[x1-1][y2]-s[x2][y1-1]+s[x1-1][y1-1];
}
int qryt(int x1,int y1,int x2,int y2)
{
	return t[x2][y2]-t[x1-1][y2]-t[x2][y1-1]+t[x1-1][y1-1];
}
int main()
{
	scanf("%d%d",&n,&K);
	for(int i=1;i<=n;i++)
	{
		int x,y;char c;
		scanf("%d%d %c",&x,&y,&c);
		x%=2*K;y%=2*K;
		x++;y++;
		if(c=='B') s[x][y]++;else t[x][y]++;
	}
	for(int i=1;i<=2*K;i++)
		for(int j=1;j<=2*K;j++)
			s[i][j]+=s[i-1][j]+s[i][j-1]-s[i-1][j-1],t[i][j]+=t[i-1][j]+t[i][j-1]-t[i-1][j-1];
	int ans=0,cal;
	for(int dx=0;dx<K;dx++)
		for(int dy=0;dy<K;dy++)
		{
			cal=qrys(1,1,dx,dy)+qrys(dx+1,dy+1,dx+K,dy+K)+qrys(1,dy+K+1,dx,2*K)+qrys(dx+K+1,1,2*K,dy)+qrys(dx+K+1,dy+K+1,2*K,2*K);
			cal+=qryt(1,dy+1,dx,dy+K)+qryt(dx+1,1,dx+K,dy)+qryt(dx+1,dy+K+1,dx+K,2*K)+qryt(dx+K+1,dy+1,2*K,dy+K);
			ans=max(ans,max(cal,n-cal));
		}
	printf("%d",ans);	
	return 0;
}

Measured memory_bytes: 31744
#include <stdio.h>
#include <string.h>
#define MAX_M 100

char a[MAX_M];
char buf[MAX_M];

int main(int argv, char **args) {
    int N;
    scanf("%d", &N);
    scanf("%s", a);
    int cnt = 0;
    int i = 0;
    next:
    while (i<N) {
        scanf("%s", buf);
        int M = strlen(buf);
        int L = strlen(a);
        for (int j=0; j<M; j++) {
            int flg = 1;
            for (int k=1; j+k*(L-1)<M; k++) {
                flg = 1;
                for (int l=0; l<L; l++) {
                    if (a[l] != buf[j+k*l]) {
                        flg = 0;
                        break;
                    }
                }
                if (flg == 1) {
                    cnt += 1;
                    i += 1;
                    goto next;
                }
            }
        }
        i += 1;
    }
    printf("%d\n", cnt);
}



Measured memory_bytes: 2740