akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;


int main(){
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;
	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <iomanip>
using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	cout << a / b <<" "<< a%b <<" "<< fixed<< setprecision(5)<<(double)a / b << endl;
	return 0;
}

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

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

    int ans = 0;

    rep(i, s.size()/2) if (s[i] != s[s.size()-i-1]) {
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System;

class Program
{
    #region Reader
    static string ReadStr => Console.ReadLine();
    static string[] ReadStrs => Console.ReadLine().Split(' ');
    static int ReadInt => Convert.ToInt32(Console.ReadLine().Trim());
    static int[] ReadInts => Console.ReadLine().Trim().Split(' ').Select(s => Convert.ToInt32(s)).ToArray();
    static long ReadLong => Convert.ToInt64(Console.ReadLine().Trim());
    static long[] ReadLongs => Console.ReadLine().Trim().Split(' ').Select(s => Convert.ToInt64(s)).ToArray();
    #endregion
    #region Method
    const int mod = 1000000007;
    public static int Mod(int a, int mod) { return a % mod >= 0 ? a % mod : a % mod + mod; }
    public static long Mod(long a, long mod = mod) { return a % mod >= 0 ? a % mod : a % mod + mod; }
    #endregion

    static void Main()
    {
        int N = ReadInt;
        long[] As = ReadLongs;

        long sum = Mod(As.Sum());

        long ans = 0;

        for (int i = 0; i < As.Length; i++)
        {
            sum -= As[i];
            sum = Mod(sum);
            ans += Mod(As[i] * sum);
            ans = Mod(ans);
        }

        WriteLine(Mod(ans));
    }
}



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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  string s;
  cin>>N>>s;
  int r=0,b=0;
  for(int i=0;i<N;i++){
    if(s[i]=='R')r++;
    if(s[i]=='B')b++;
  }
  if(r>b)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll gcd(ll a,ll b){
  ll r=a%b;
  while(r>0){
    a=b;b=r;r=a%b;
  }
  return b;
}
vector<bool> prime(1111111,true);
void make_prime(){
  prime[0]=prime[1]=false;
  for(ll i=0;i<1111111;i++){
    if(prime[i]==false)continue;
    for(ll j=2*i;j<1111111;j+=i){
      prime[j]=false;
    }
  }
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b;cin>>a>>b;
  ll num=gcd(a,b);
  make_prime();
  ll ans=0;
  for(int i=2;i<1111111;i++){
    if(num%i==0){
      ans++;
      while(num%i==0)num/=i;
    }
  }
  if(num>1)ans++;
  cout<<ans+1<<endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll k,n;cin >> n >>k;
    vl a(n),b(n);
    rep(i,n)cin >> a[i] >> b[i];
    ll res=0;
    rep(i,30){
        if((1<<i)&k){
            ll t=(1<<i);
            t--;
            ll p=((k-t)|t);
            ll sum=0;
            rep(j,n){
                if(p==(p|a[j]))sum+=b[j];
            }
            chmax(res,sum);
        }
    }
    ll sum=0;
    rep(j,n){
        if(k==(k|a[j]))sum+=b[j];
    }
    chmax(res,sum);
    cout << res <<endl;
}   

Measured memory_bytes: 4824
#include<bits/stdc++.h>
using namespace std;
int main(){
    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])
            or
            (p[i-1] >= p[i] && p[i] >= p[i+1])
        ){
            ans++;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    [H, W] = string_to_int(inputs[0])
    IDEAL_SIZE = H * W / 3

    def separate_first(SH, SW):
        most_closed_size = None
        most_closed_i = None
        for h in range(1, SH):
            tmp_size = h * SW
            if most_closed_size is None:
                most_closed_size = tmp_size
                most_closed_i = h
            else:
                most_closed_diff = abs(IDEAL_SIZE - most_closed_size)
                tmp_diff = abs(IDEAL_SIZE - tmp_size)

                if most_closed_diff > tmp_diff:
                    most_closed_size = tmp_size
                    most_closed_i = h

        return (most_closed_i, most_closed_size)

    def separate_second_row(start_h, SH, SW):
        second_i = (SH - start_h) // 2 + start_h
        second_s = (second_i - start_h) * SW
        third_s = (SH - second_i) * SW
        return (second_i, second_s, third_s)

    def separate_second_column(start_h, SH, SW):
        second_i = SW // 2
        second_s = (SH - start_h) * second_i
        third_s = (SH - start_h) * (SW - second_i)
        return (second_i, second_s, third_s)

    def max_diff(f_s, s_s, t_s):
        diff_s = []
        diff_s.append(abs(f_s - s_s))
        diff_s.append(abs(f_s - t_s))
        diff_s.append(abs(s_s - t_s))

        return max(diff_s)

    diffs = []
    if H == 1:
        f_i, f_s = separate_first(W, H)
        s_i, s_s, t_s = separate_second_row(f_i, W, H)
        diffs.append(max_diff(f_s, s_s, t_s))
    elif W == 1:
        f_i, f_s = separate_first(W, H)
        s_i, s_s, t_s = separate_second_row(f_i, W, H)
        diffs.append(max_diff(f_s, s_s, t_s))
    else:
        f_i, f_s = separate_first(H, W)
        s_i, s_s, t_s = separate_second_row(f_i, H, W)
        diffs.append(max_diff(f_s, s_s, t_s))

        f_i, f_s = separate_first(W, H)
        s_i, s_s, t_s = separate_second_row(f_i, W, H)
        diffs.append(max_diff(f_s, s_s, t_s))

        f_i, f_s = separate_first(H, W)
        s_i, s_s, t_s = separate_second_column(f_i, H, W)
        diffs.append(max_diff(f_s, s_s, t_s))

        f_i, f_s = separate_first(W, H)
        s_i, s_s, t_s = separate_second_column(f_i, W, H)
        diffs.append(max_diff(f_s, s_s, t_s))
    return min(diffs)


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 40428
fun main(args: Array<String>) {
    val (n, a, b, c, d) = readLine()!!.split(" ").map { it.toInt() - 1 }
    val s = readLine()!!

    if (c < d) {
        if ("##" in s.slice(a..d)) println("No")
        else println("Yes")
    } else {
        if ("##" !in s.slice(a..c) && "..." in s.slice(b - 1..d + 1)) println("Yes")
        else println("No")
    }
}

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

using namespace std;

string solve(string s)
{
  for(int i = 0; i < s.size()-1; i++)
    if(s[i] != s[i+1])
      return "Yes";
  return "No";
}


int main()
{
  string s;
  cin >> s;
  cout << solve(s) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long 
using namespace std;
signed main(){
  int n,h[100000],sum[100000]={},a=0,nax=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  for(int i=0;i<n-1;i++){
    if(h[i]>=h[i+1]){
      a++;
    }else{
      nax = max(nax,a);
      a = 0;
    }
  }
  nax = max(nax,a);
  cout<< nax <<"\n";

    return(0);
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>
#include <typeinfo>
#include <set>
#include <bitset>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;



int main(){
  string s,t;
  cin >> s >> t;
  cout << t << s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  ll n, k;
  cin >> n >> k;
  vll h(n);
  rep(i,n) cin >> h[i];
  sort(h.rbegin(), h.rend());
  ll ans = 0;
  for (int i = k; i < n; ++i) {
    ans += h[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
h, w, m = gets.split.map(&:to_i)

r = Array.new(h+1,0)
c = Array.new(w+1,0)
d = Hash.new {|hash,key| hash[key] = {}}
m.times do
    a,b = gets.split.map(&:to_i)
    r[a] += 1
    c[b] += 1
    d[a][b] = 1
end

r_max = r.max
r = (1..h).filter{|a| r[a] == r_max}

c_max = c.max
c = (1..w).filter{|b| c[b] == c_max}

if r.size * c.size > m
    p r_max + c_max
else
    p r_max + c_max - (r.product(c).all?{|a,b| d[a][b]} ? 1 : 0)
end

Measured memory_bytes: 101352
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int main(){
    int a;
    string b;
    cin >> a >> b;

    int num;
    num=atoi(b.c_str())+pow(10,b.length())*a;
    int sqrt=pow(num,0.5);
    if(sqrt*sqrt==num) b="Yes";
    else b="No";

    cout << b << endl;

    return 0;
}

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

using namespace std;

#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define INF 1000000001
#define INFL (1LL << 60)
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main() {
  int n;
  cin >> n;
  string s[n];
  REP(i, n) cin >> s[i];
  int ans = 0;
  REP(i, n){
    bool check = true;
    REP(j, n){
      FOR(k, j, n){
        check &= (s[(j+i)%n][k] == s[(k+i)%n][j]);
      }
    }
    if(check) ans++;
  }
  cout << ans*n << endl;
  return 0;
}


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

using namespace std;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int a,b,c;
    cin>>a>>b;
    if (a>b)
        cout<<"a > b"<<'\n';
    if (a<b)
        cout<<"a < b"<<'\n';
    if (a==b)
        cout<<"a == b"<<'\n';
    return 0;
}



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

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

    int len = s.length();
    int gu = 0;
    int pa = 0;
    int ans = 0;

    for(int i = 0; i < len; i++){
        if(pa < gu){
            if(s[i] == 'g'){
                pa++;
                ans++;
            }else{
                pa++;
            }
        }else{
            if(s[i] == 'g'){
                gu++;
            }else{
                gu++;
                ans--;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,a,b;scanf("%lld%lld%lld",&n,&a,&b);
  if(abs(a-b)%2==0) printf("%lld\n",abs(a-b)/2);
  else{
    long long e = min(min(a,b)-1,n-max(a,b))+1;
    printf("%lld\n",e+abs(a-b)/2);
  }
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int N;
  ll K;
  cin >> N >> K;
  map<int,ll> cnt;
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    cnt[a] += b;
  }
  for(auto a: cnt) {
    K -= a.second;
    if (K <= 0) {
      cout << a.first << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>

#line 1 "lib/modint.hpp"



#include <iostream>

// Modint
struct Mint {
    static const long long mod = (long long)1e9 + 7;
    long long val;

    Mint() { val = 0; }
    Mint(long long a) { val = a; verify_value(); }

    void verify_value() {
        if (val >= mod) val %= mod;
        if (val < 0) val %= mod, val += mod;
    }

    Mint pow(long long p) const {
        Mint cur = Mint(val), ret = 1;
        while (p > 0) {
            if (p & 1) ret *= cur;
            cur *= cur;
            p >>= 1LL;
        }
        return ret;
    }
    Mint inv() const {
        if (val == 0)
            std::cerr << "WARNING: inv() is called with 0." << std::endl;
        return pow(mod - 2);
    }

    Mint operator+() const { return *this; }
    Mint operator-() const { return Mint(mod - val); }

    Mint operator+=(const Mint &a) {
        val += a.val;
        if (val >= mod) val -= mod;
        return Mint(val);
    }
    Mint operator*=(const Mint &a) {
        val *= a.val;
        if (val >= mod) val %= mod;
        return Mint(val);
    }
    Mint operator-=(const Mint &a) { return *this += -a; }
    Mint operator/=(const Mint &a) { return *this *= a.inv(); }

    Mint operator++() { return *this += Mint(1); }
    Mint operator--() { return *this -= Mint(1); }
    Mint operator++(int) {
        Mint ret = *this;
        ++(*this);
        return ret;
    }
    Mint operator--(int) {
        Mint ret = *this;
        --(*this);
        return ret;
    }

    operator long long() const { return val; }
};

Mint operator+(const Mint &a, const Mint &b) {
    long long ret = a.val + b.val;
    if (ret >= Mint::mod) ret -= Mint::mod;
    return Mint(ret);
}
Mint operator*(const Mint &a, const Mint &b) {
    long long ret = a.val * b.val;
    if (ret >= Mint::mod) ret %= Mint::mod;
    return Mint(ret);
}
Mint operator-(const Mint &a, const Mint &b) { return a + (-b); }
Mint operator/(const Mint &a, const Mint &b) { return a * b.inv(); }

std::ostream &operator<<(std::ostream &out, const Mint &a) { return out << a.val; }
std::istream &operator>>(std::istream &in, Mint &a) {
    in >> a.val;
    a.verify_value();
    return in;
}

Mint pow(Mint a, long long b) {
    return a.pow(b);
}         


int main() {
    int n; std::cin >> n;
    std::string s; std::cin >> s;
    Mint ans = 1, cnt = 0;
    for (int i = 0; i < 2*n; i++) {
        if ((i&1)^(s[i] == 'B')) cnt++;
        else ans *= cnt--;
    }
    if (cnt != 0) {
        std::cout << 0 << std::endl;
        return 0;
    }
    for (int i = 1; i <= n; i++) ans *= i;
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

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

int main() {
  int r, g, b, n; cin >> r >> g >> b >> n;

  int ans = 0;
  REP(i, n+1)REP(j, n+1){
    if(r * i + g * j <= n && (n - (r * i + g * j)) % b == 0) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
//file_name:ABC56_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#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 srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int n;
    scanf("%d",&n);


    ll ans = 0;

    rep(i,100000){
        if(i*(i+1)/2>=n){
            ans = i;
            break;
        }
    }

    cout << ans << endl;
    return 0;
}



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

long long INF = (1 << 31) - 1;

class SegmentTree {
private:
	long long Size;
	vector<long long> Node;
public:
	SegmentTree(long long N) {
		Size = 1;
		while (Size < N) Size <<= 1;
		Node.resize(Size * 2, INF);
	}
	void Update(long long K, long long X) {
		K += Size;
		Node[K] = X;
		while (K > 1) {
			K >>= 1;
			Node[K] = min(Node[K * 2], Node[K * 2 + 1]);
		}
	}
	long long Query(long long L, long long R) {
		long long NOWS = Size, ANS = INF;
		while (R > L) {
			if (L & 1) {
				ANS = min(ANS, Node[L + NOWS]);
				L++;
			}
			if (R & 1) {
				ANS = min(ANS, Node[R - 1 + NOWS]);
				R--;
			}
			L >>= 1, R >>= 1, NOWS >>= 1;
		}
		return ANS;
	}
};

int main() {
	long long N, Q;
	cin >> N >> Q;
	SegmentTree Seg(N);
	for (int i = 0; i < Q; i++) {
		long long Mode;
		cin >> Mode;
		if (Mode == 0) {
			long long K, X;
			cin >> K >> X;
			Seg.Update(K, X);
		}
		else {
			long long L, R;
			cin >> L >> R;
			cout << Seg.Query(L, R + 1) << endl;
		}
	}
}


Measured memory_bytes: 4840
#include <stdio.h> 

int main(void){
    int a,b,x,y;
	scanf("%d %d", &a,&b);
	
	if(1<=a,b<=100){
	   x=a*b;
	   y=2*(a+b);
	}
    printf("%d %d\n",x,y);
    return 0;
}


Measured memory_bytes: 2056
#include <iostream>
#include <string>
#include <unordered_map>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
using namespace std;

#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define y1 abcde
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>
#define int long long

const int inf = 2e9;
const int N = 2e5 + 15;
int n, a[N], l[N], r[N];
int st[N], stsz, ans;

inline int st_last() {
    return st[stsz - 1];
}

main() {
    cin >> n;
    for(int i = 1; i <= n; ++i)
        cin >> a[i];
    for(int i = 1; i <= n; ++i) {
        while(stsz && a[st_last()] > a[i])
            stsz--;
        if(stsz)
            l[i] = st_last() + 1;
        else
            l[i] = 1;
        st[stsz++] = i;
    }
    stsz = 0;
    for(int i = n; i; --i) {
        while(stsz && a[st_last()] > a[i])
            stsz--;
        if(stsz)
            r[i] = st_last() - 1;
        else
            r[i] = n;
        st[stsz++] = i;
    }
    for(int i = 1; i <= n; ++i)
        ans += a[i] * ((i - l[i] + 1) * (r[i] - i + 1));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7040
# インプット情報を格納
member_num = int(input())
ans_table = []
for i in range(member_num):
    ans_num = int(input())
    ans = {}
    for k in range(ans_num):
        a,b = input().split()
        # 人を表すIDはインデックスを0オリジンにするために-1する
        ans[int(a) - 1] = b
    ans_table.insert(i,ans)

# 取りうる全パターン(誰が正直/不親切)を作成
# member_numの配列ｘ2^member_num
bin_str = []
for i in range(2**member_num):
    bin_line = format(i,'b').zfill(member_num)
    bin_str.append(bin_line)

#矛盾検索
contradiction = 0
anser_index = []
for i in range(2**member_num):
    for k in range(member_num):
        if bin_str[i][k] == "1":
            # ans_tableのk番目の回答は信用できると仮定
            for idnum, answer in ans_table[k].items():
                if bin_str[i][idnum] != answer:
                    # 矛盾あり
                    contradiction = 1
                    break
        if contradiction == 1:
            break
    # 矛盾がなかった
    if contradiction == 0:
        anser_index.append(i)
    contradiction = 0

honest = 0
for index in anser_index:
    honest_tmp = bin_str[index].count("1")
    if honest < honest_tmp:
        honest = honest_tmp
print(honest)



Measured memory_bytes: 6664
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159265359

//  余弦定理で長針と短針の先端の距離を出力する関数
void cosine(double length_hour, double length_minute, double hour, double minute){
	double angle_hour, angle_minute, difference_angle; // angle_hour(長針の角度), angle_minute(短針の角度), difference_angle(長針と短針の角度の差)をdouble型の変数として宣言
	angle_hour = 360 * hour / 12 + 30 * minute / 60; // 長針の角度を計算
	angle_minute = 360 * minute / 60; // 短針の角度を計算
	difference_angle = angle_hour - angle_minute; // 長針と短針の角度の差を計算
	difference_angle = (difference_angle / 180) * PI ; // 角度の差を弧度法で表す
	double distance; // 長針と短針の先端の距離をdouble型の変数として宣言
	distance = length_hour * length_hour + length_minute * length_minute - 2 * length_hour * length_minute * cos(difference_angle); // 距離の2乗を余弦定理で求める
	distance = sqrt(distance); // 距離をルートに入れて戻す
	printf("%.10lf\n", distance); // 距離を少数第10位まで出力する
}

int main(){
	double length_hour, length_minute, hour, minute; // length_hour(長針の長さ), length_minute(短針の長さ), hour(時間), minute(分数)をdouble型の変数として宣言
	scanf("%lf %lf %lf %lf", &length_hour, &length_minute, &hour, &minute); // length_hour, length_minute, hour, minuteを入力
	
	cosine(length_hour, length_minute, hour, minute); // 余弦定理で長針と短針の先端の距離を出力する関数を実行
	
	return 0;
}

Measured memory_bytes: 2604
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
    int N,K; cin >> N >> K;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
        A[i]--;
    }
    vector<ll> sum(N+1);
    rep(i,N){
        sum[i+1] = sum[i] + A[i];
        sum[i+1] %= K;
    }
    ll ans = 0;
    map<int,int> mp;
    rep(i,N+1){
        mp[sum[i]]++;
        if(i >= K) mp[sum[i-K]]--;
        ans += mp[sum[i]]-1;
    }
    cout << ans << endl;

    

}



Measured memory_bytes: 12800
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include <iomanip>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int digit(int n){
   if(n < 10)  return n;
   return digit(n/10) + n%10;
}
int main(){
  int X;
  cin>>X;
  
  cout<<cei(2000-X,200);
return 0;}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  int a = 0;
  for (int i = 0; i < n; i++) {
    char b;
    cin >> b;
    if (b == 'Y') {
      a = 1;
      cout << "Four" << endl;
      break;
    }
  }
  if (a == 0)
    cout << "Three" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
using namespace std;
int coutDiv(int a){
int res=0;
  for(int i=1;i<=a;i++){
  	if(a%i==0){
    	res++;
    }
  }
  return res;
}
int main(){
  int lis[300];
  int res=0;
  memset(lis,0,sizeof(lis));
  for(int i=105;i<=200;i++){
  	if(coutDiv(i)==8 and i%2 ==1)res++;
  	lis[i]=res;
  }
  int a;
  while(cin>>a){
      cout<<lis[a]<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int v[8][8];
vector<string> arr;

void permute(string a, int l, int r)
{
    // Base case
    if (l == r)
        arr.pb(a);
    else
    {
        // Permutations made
        for (int i = l; i <= r; i++)
        {

            // Swapping done
            swap(a[l], a[i]);

            // Recursion called
            permute(a, l+1, r);

            //backtrack
            swap(a[l], a[i]);
        }
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        v[a][b]=1;
        v[b][a]=1;
    }
    string str="";
    for(int i=2;i<=n;i++){
        char c='0'+i;
        str+=c;
    }
    permute(str,0,n-2);
    ll ans=0;
    for(int i=0;i<arr.size();i++){
        string s="1"+arr[i];
        int count=1;
        for(int i=1;i<=n-1;i++){
            if(v[s[i]-'0'][s[i-1]-'0']==0){
                count=0;
                break;
            }
        }
        if(count==1)
            ans+=1;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
	int H, W, A, B;
	cin >> H >> W >> A >> B;
	vector<vector<bool>> ans(H, vector<bool>(W));
	for (int i = 0; i < A; i++) {
		for (int j = 0; j < B; j++) ans[j][i] = true;
	}
	for (int i = A; i < W; i++) {
		for (int j = B; j < H; j++) ans[j][i] = true;
	}
	for (vector<bool>& i : ans) {
		for (bool j : i) cout << j;
		cout << endl;
	}
}

Measured memory_bytes: 1536
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using namespace std;

const long long MOD = 1000000007;

// Ref. https://qiita.com/ofutonfuton/items/c17dfd33fc542c222396 //
struct UnionFind {
    vector<int> par;
    vector<int> sz;

    // Initialize. All vertices are roots when initial state.
    UnionFind(int N) : par(N),sz(N) {
      REP(n,N){
        par[n] = n;
        sz[n] = 1;
      }
    }

    // Return the root of tree which consists of vertex(x)
    int root(int x) {
      if (par[x] == x) return x;     // If x is the root, return x
      return par[x] = root(par[x]);  // Recursively find the root of tree. 
    }

    // Unite two vertices into one tree. 
    void unite(int x, int y) {
      int rx = root(x);
      int ry = root(y);
      if (rx == ry) return;
      if(sz[rx] > sz[ry]){
        par[ry] = rx;
        sz[rx] += sz[ry];
      }else{
        par[rx] = ry;
        sz[ry] += sz[rx];
      }
    }

    // Return true if two vertices has the same root, else return false.
    bool same(int x, int y) {
      int rx = root(x);
      int ry = root(y);
      return rx == ry;
    }

    // Return the number of vertices which are component of a tree
    int size(int x){
      return sz[root(x)];
    }
};

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


  vector<int> A(M);
  vector<int> B(M);

  REP(m,M){
    int a, b;
    cin >> a >> b;
    A[m] = a-1, B[m] = b-1;
  }

  UnionFind tree(N);

  long long inconv = N*(long long)(N-1)/2;
  vector<long long> res;
  
  RREP(m,M){
    res.push_back(inconv);
    if (tree.same(A[m],B[m])) continue;

    inconv -= tree.size(A[m])*tree.size(B[m]);
    tree.unite(A[m],B[m]);

  }
  reverse(res.begin(),res.end());
  REP(m,M) cout << res.at(m) << endl;
}


Measured memory_bytes: 3828
#pragma region

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;
using vvb = vector<vector<bool>>;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &pair) {
  cin >> pair.first >> pair.second;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

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

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

void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(16);
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int main() {
  init();

  ll K;
  string S;
  cin >> K >> S;

  if (S.length() <= K) {
    out(S);
    return 0;
  }

  rep(i, K) {
    cout << S[i];
  }
  out("...");
}


Measured memory_bytes: 3612
r,c = map(int,input().split())
data = [[0] * (c+1) for i in range(r)]
for row in range(r):
    data[row] = [int(i) for i in input().split()]
    data[row].append(sum(data[row]))
for row in range(r):
    for column in range(c+1):
        if column == (c):
            print(data[row][column])
        else: 
            print("%d " %data[row][column],end = "")
#転置

data_t = []
sumColumn = []
sumSumRow = 0
for column in range(c):
    dataRow = []
    for rowVector in data:
        dataRow.append(rowVector[column])
    data_t.append(dataRow) 

for column in data_t:
    sumColumn.append(sum(column))
for index in range(c):
    print("%d " %sumColumn[index],end = "")
for row in range(r):
    sumSumRow = sumSumRow + sum(data[row][:-1])
print("%d" % sumSumRow)



Measured memory_bytes: 6188
#![allow(dead_code,unused_variables,unused_imports)]
use proconio::{fastout, input};
use proconio::marker::Chars;

#[fastout]
fn main() {
    input!(mut s:Chars, mut t:Chars);
    s.sort();
    t.sort();
    t.reverse();
    match s < t{
        true => println!("Yes"),
        false => println!("No"),
    }


}

Measured memory_bytes: 2184
sumup' [] [] = []
sumup' (x:xs) (y:ys) = (x+y):(sumup' xs ys)

sumup (x:[]) = x
sumup (x0:x1:xs) = sumup ((sumup' x0 x1):xs)

comp [] [] = True
comp (x:xs) (y:ys) =
  if x >= y
  then comp xs ys
  else False

ans' s d =
  let r = sumup d
      c = comp s r
  in
    if c
    then "Yes"
    else "No"

ans ([0,0]:_) = []
ans ([n,k]:s:x) =
  let d = take n x
      r = drop n x
  in
    (ans' s d):(ans r)

main = do
  c <- getContents
  let i = map (map read) $ map words $ lines c
      o = ans i
  mapM_ putStrLn o

Measured memory_bytes: 8052
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
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(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	LL n, m; cin >> n >> m;

	LL ans = 0;

	//1つのｓと2つのcを組合せて、1のSccになる。
	if ((LL)2 * n <= m) {
		ans += n;
		m -= (LL)2 * n;

		ans += m / (LL)4;
	}
	else {
		ans += m / (LL)2;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto l = readln.split.to!(long[]);
    auto A = l[0];
    auto B = l[1];
    auto C = l[2];
    auto D = l[3];

    auto n = B/C + B/D - B/(C*D/gcd(C,D));
    auto m = (A-1)/C + (A-1)/D - (A-1)/(C*D/gcd(C,D));
    writeln((B-A+1) - (n-m));
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;

public class Main{

	public static void main(String[] args) throws IOException{

		long num = 0;
		String strLine ="";
		BufferedReader stdReader =
				new BufferedReader(new InputStreamReader(System.in));

		int maxcnt = 0;
		int cnt = 0;

		ArrayList<String> list = new ArrayList<String>();

		BigInteger max = new BigInteger("100000000000000000000000000000000000000000000000000000000000000000000000000000000");


		while ( ((strLine = stdReader.readLine()) != null)) {

			if(maxcnt == 0){
				maxcnt = 2 * Integer.parseInt(strLine);
			}else{
				list.add(strLine);
				cnt++;
			}

			if(cnt == maxcnt){
				break;
			}if(cnt > 50){
				break;
			}
		}


		for (int i = 0; i < maxcnt; i = i + 2 ) {

			BigInteger t1 = new BigInteger((String)list.get(i));
			BigInteger t2  = new BigInteger((String)list.get(i+1));
			BigInteger result = t1.add(t2);

		if((t1.compareTo(max) >= 0 ) || (t2.compareTo(max) >= 0 ) || (result.compareTo(max) >= 0 )){
			System.out.println("overflow");
		}else{
			System.out.println(result);
		}

	}

	}
}

Measured memory_bytes: 24364
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define x first
#define y second
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define endl '\n'


int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	cout<<max({a+b*10+c,a*10+b+c,a+b+c*10})<<endl;
	return 0;
}

Measured memory_bytes: 256
a = []
a.append(int(input()))

i = 0
while 1:
	if a[i]%2 == 0:
		a.append(a[i]//2)
	else:
		a.append(3*a[i]+1)
	i += 1
	if a[i] in a[:i]:
		print(i+1)
		exit(0)


Measured memory_bytes: 2940
#include <iostream>
#include <math.h>
#include <queue>
using namespace std;
const int INF=100000000;
typedef pair<int,int> P;
char**maze; 
int H,W,N; 
int*y; int *x;
int**d;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int bfs(int sy,int sx,int gy,int gx){
  queue<P> que;
  for(int h=0; h<H; h++)
    for(int w=0; w<W; w++) d[h][w]=INF;
   que.push(P(sy,sx));
   d[sy][sx]=0;
  while(que.size()){
    P p = que.front(); que.pop();
    if(p.first==gy&&p.second==gx) break;
    for(int i=0; i<4; i++){
      int ny=p.first+dy[i],nx=p.second+dx[i];
      if(0<=nx&&nx<W&&0<=ny&&ny<H&&
      maze[ny][nx]!='X'&&d[ny][nx]==INF){
        que.push(P(ny,nx));
        d[ny][nx]=d[p.first][p.second]+1;
        }
    }
  }
  return d[gy][gx];
}
int main() {
    cin>>H>>W>>N;
    y=new int[N+1]; x=new int[N+1];
    maze = new char*[H];
 for (int h = 0; h <H; h++) {
        maze[h] = new char[W];
    }
 for (int h = 0; h < H; h++) {
  for (int w = 0; w < W; w++) {
	  cin >> maze[h][w]; 
    if(maze[h][w]!='.'&&maze[h][w]!='X'&&
    maze[h][w]!='S'){
      int p=(int)maze[h][w]-(int)'0';
      y[p]=h;
      x[p]=w;
    }else if(maze[h][w]=='S'){
      y[0]=h; x[0]=w;
    }
  }
 }
          d = new int*[H];
   for (int h = 0; h <H; h++) {
       d[h] = new int[W];
    }
  int res=0;
  for(int i=0; i<=N-1; i++){
    res+=bfs(y[i],x[i],y[i+1],x[i+1]);
    }
   cout<<res<<endl;
 return 0;
}

Measured memory_bytes: 6132
#include<bits/stdc++.h>
using namespace std;
const int inf=1e9,mod=1e9+7;
typedef long long ll;
int read() {
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();
	while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
main() {
	int n=read(),k=read(),i=1,ans=0;
	while(i<=n) {
		ans++,i+=k*2+1;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

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[i][j];
        }
    }

    int n;
    cin >> n;

    vector<vector<bool>> c(3, vector<bool>(3, false));
    for (int i = 0; i < n; i++) {
        int b;
        cin >> b;

        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (a[j][k] == b) {
                    c[j][k] = true;
                }
            }
        }
    }

    bool res = false;
    for (int i = 0; i < 3; i++) {
        res = res || (c[i][0] && c[i][1] && c[i][2]);
        res = res || (c[0][i] && c[1][i] && c[2][i]);
    }

    res = res || (c[0][0] && c[1][1] && c[2][2]);
    res = res || (c[0][2] && c[1][1] && c[2][0]);

    cout << (res ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		int a = scan.nextInt();

		System.out.println(a + a * a + a * a * a);
	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 26992
#include <stdio.h>
#include <stdlib.h>

int main(){
    int a,b,c,d,d1,d2,d3;

    scanf("%d %d %d %d",&a,&b,&c,&d);

    d1=abs(a-b);
    d2=abs(b-c);
    d3=abs(c-a);

    if(d3<=d){
        printf("Yes\n");
    }else if((d1<=d)&&(d2<=d)){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

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

using namespace std;

int n, cnt[27];
string s;

int main() {
	scanf("%d", &n);
	cin >> s;
	for (int i = 0; i < n; i++) {
		cnt[s[i] - 'a']++;
	}
	
	int ans = 1;
	for (int i = 0; i < 27; i++)
		ans = (ans * 1ll * (cnt[i]+1)) % 1000000007;
	printf("%d\n", (ans-1+1000000007) % 1000000007);
	
	return 0;
}


Measured memory_bytes: 512
from sys import stdin

k, n = [int(x) for x in stdin.readline().rstrip().split()]
a = [int(x) for x in stdin.readline().rstrip().split()]
d = max(max([abs(a[x] - a[x - 1]) for x in range(len(a)) if x > 0]), abs(a[0] + k - a[len(a)-1]))

print(k - d)

Measured memory_bytes: 24948