akhauriyash/Code-Regression huggingface dataset:
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;

const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf

#define sf scanf

#define ALL(x) x.begin(),x.end()
#define pb push_back

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define for0(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=n-1;i>=0;i--)
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
int ext_gcd(int a, int b, int & x, int & y) {
    //for finding modular inverse
    //if its return 1 ,then a has a mod inverse x mod b.
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    int x1, y1;
    int d = ext_gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}

int main()

{
    IOS;
    //freopen("input.txt", "r", stdin);
     //freopen("output.txt", "w", stdout);
     int n,m;
     while(cin>>n>>m){
        vector<double>vec(n);
        double sum=0;
        for(int i=0;i<n;i++) {cin>>vec[i]; sum+=vec[i];}
        double mm=maxv(vec);
        double lim=(1.0/(4.0*(double)m))*(double)sum;
        sort(ALL(vec));
        reverse(ALL(vec));
        bool b=false;
       // cout<<lim<<endl;
        for(int i=0;i<m;i++){
            if(vec[i]>=lim) continue;
            else {
                b=true;
                break;
            }
        }
        if(!b) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
     }

     return 0;

}
///Alhamdulillah


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

class Main {
    public static void main(final String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        StringBuffer str = new StringBuffer(s);
        String r = str.reverse().toString();
        char[] c = r.toCharArray();
        int size = r.length();
        int ans = 0;
        int[] count = new int[2019];
        int total = 0;
        int mod = 2019;
        int exp = 1;
        for (int i = 0; i < size; i++) {
            count[total]++;
            total += Integer.parseInt(String.valueOf(c[i])) * exp;
            total %= mod;
            ans += count[total];
            exp *= 10;
            exp %= mod;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 50696
#pragma region

#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin); i < (end); i++)
#define IFOR(i, begin, end) for (int i = (end)-1; i >= (begin); i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define MOD 1000000007
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;
typedef long long ll;
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "vec[ ";
  REP(i, vec.size())
  i == 0
      ? os << vec[i]
      : os << ", " << vec[i];
  os << " ]";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const deque<T> &deq) {
  os << "deq[ ";
  REP(i, deq.size())
  i == 0
      ? os << deq[i]
      : os << ", " << deq[i];
  os << " ]";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &set) {
  os << "{ ";
  for (auto &&s : set) &s == &(*set.begin()) ? os << s : os << ", " << s;
  os << " }";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_set<T> &set) {
  os << "{ ";
  for (auto &&s : set) &s == &(*set.begin()) ? os << s : os << ", " << s;
  os << " }";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const multiset<T> &set) {
  os << "{ ";
  for (auto &&s : set) &s == &(*set.begin()) ? os << s : os << ", " << s;
  os << " }";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_multiset<T> &set) {
  os << "{ ";
  for (auto &&s : set) &s == &(*set.begin()) ? os << s : os << ", " << s;
  os << " }";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const map<TK, TV> &m) {
  os << "{ ";
  for (auto &&k : m) &k == &(*m.begin()) ? os << k.first << " => " << k.second : os << ", " << k.first << " => " << k.second;
  os << " }";
  return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const unordered_map<TK, TV> &m) {
  os << "{ ";
  for (auto &&k : m) &k == &(*m.begin()) ? os << k.first << " => " << k.second : os << ", " << k.first << " => " << k.second;
  os << " }";
  return os;
}

#pragma endregion

bool isCollided(vector<vector<bool>> &map, int h, int w, int x, int y) {
  REP(i, w)
  REP(j, h)
  if (map[y + j][x + i]) return true;
  return false;
}

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

  int N;
  cin >> N;
  REP(i, 50000) {
    if ((int)(i * 1.08) == N) {
      cout << i << "\n";
      return 0;
    }
  }

  cout << ":(\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


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

    vbool c(26, false);
    rep(i, s.length()) {
        c[s[i]-'a'] = true;
    }

    vint t, f;
    rep(i, 26) {
        if (c[i]) t.push_back(i);
        else f.push_back(i);
    }

    string ans = "";
    if (t.size() == 26) {
        string tmp = s;
        next_permutation(all(tmp));
        rep(i, 26) {
            ans += tmp[i];
            if (s[i] != tmp[i]) break;
        }
        if (ans == "a") ans = "-1";
    }
    else {
        ans = s;
        ans += (char)(f[0]+'a');
    }

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

Measured memory_bytes: 256
fun main(args:Array<String>?): Unit {
    val (n, _, d) = readLine()!!.trim().split(' ').map(String::toInt)
    val mod = readLine()!!.trim().split(' ').map(String::toLong)
    val suspects = List(d){
        val r = readLine()!!.trim().split(' ').map(String::toLong)
        mod.zip(r).fold(Pair(1L, 0L) as Pair<Long, Long>?) { pair, (a, r) ->
            if (r != -1L) {
                pair?.let { (product, prev) ->
                    newMod(product, prev, a, r)?.let {
                        newR ->
                        Pair(lcm(product, a), newR)
                    }
                }
            }else pair
        }
    }
    println(
            suspects.fold(n.toLong() as Long?){current, pair ->
                if (current != null && pair != null && current >= pair.second) {
                    (current - pair.second) / pair.first * pair.first + pair.second
                }
                else null
            } ?: -1
    )
}
fun lcm(a: Long, b: Long): Long {
    return a * b / gcd(a, b)
}
tailrec fun gcd(a: Long, b: Long): Long {
    return when(b){
        0L -> a
        else -> gcd(b, a % b)
    }
}
fun newMod(x: Long, mx: Long, y: Long, my: Long): Long? {
    tailrec fun sub(x: Long, y: Long, ax: Long, ay: Long, bx: Long, by: Long): Pair<Long, Long> {
        val a = ax * x + ay * y
        val b = bx * x + by * y
        return when (a % b) {
            0L -> if (bx > 0) Pair(bx, by) else Pair(bx + y, by - x)
            else -> {
                val r = a / b
                sub(x, y, bx, by,ax - r * bx, ay - r * by)
            }
        }
    }
    val g = gcd(x, y)
    return when{
        gcd(g, mx) == gcd(g, my) -> {
            val (ax, ay) = sub(x / g, y / g, 1, 0, 0, 1)
            val nx = ax * my % y
            val ny = ((ay % x + x) % x) * mx % x
            val ux = x / g
            val uy = y / g
            val r = ((nx * ux + ny * uy) % (x * y / g) + (x * y / g)) % (x * y / g)
            r
        }
        else -> null
    }
}


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

using namespace std;

using lli = long long int;


const int H_MAX = 80;
const int W_MAX = 80;

const int A_MAX = 80;
const int B_MAX = 80;

int A[H_MAX][W_MAX];
int B[H_MAX][W_MAX];

const int SIZE = (H_MAX + W_MAX) * 2 * (A_MAX + B_MAX);

int dp[W_MAX][SIZE + 1];

int tmp[SIZE + 1];

const int OFFSET = (H_MAX + W_MAX) * (A_MAX + B_MAX);


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int i, j, ii, H, W, h, w, a, b;
    
    cin >> H >> W;
    
    for(i = 0; i < H; ++i)
    {
        for(j = 0; j < W; ++j)
        {
            cin >> A[i][j];
        }
    }
    
    for(i = 0; i < H; ++i)
    {
        for(j = 0; j < W; ++j)
        {
            cin >> B[i][j];
        }
    }
    
    int diff;
    
    diff = A[0][0] - B[0][0];
    
    dp[0][OFFSET + diff] = 1;
    dp[0][OFFSET - diff] = 1;
    
    for(i = 1; i < W; ++i)
    {
        diff = A[0][i] - B[0][i];
        for(j = 0; j < SIZE; ++j)
        {
            if (dp[i - 1][j] == 1)
            {
                dp[i][j + diff] = 1;
                dp[i][j - diff] = 1;
            }
        }
    }
    
    for(i = 1; i < H; ++i)
    {
        for(j = 0; j < W; ++j)
        {
            diff = A[i][j] - B[i][j];
           
            for(ii = 0; ii < SIZE; ++ii)
            {
                if (((j > 0) && (dp[j - 1][ii] == 1)) || (dp[j][ii]) == 1)
                {
                    tmp[ii + diff] = 1;
                    tmp[ii - diff] = 1;
                }
            }
            for(ii = 0; ii < SIZE; ++ii)
            {
                dp[j][ii] = tmp[ii];
                tmp[ii] = 0;
            }
            
        }
    }
    
    int ans;
    
    for(i = OFFSET, j = OFFSET; ; --i, ++j)
    {
        if (dp[W - 1][i] == 1)
        {
            ans = abs(i - OFFSET);
            break;
        }
        if (dp[W - 1][j] == 1)
        {
            ans = abs(j - OFFSET);
            break;
        }
    }
    
    cout << ans;
    
    return 0;
    
}

Measured memory_bytes: 16512
N, M = map(int, input().split())
S = list(map(int, input().split()))
T = list(map(int, input().split()))
MOD = 10**9 + 7

dp = [[0] * (M + 1) for _ in range(N + 1)]  # dp[s][t]

for i, s in enumerate(S, start=1):
    for j, t in enumerate(T, start=1):
        v = dp[i - 1][j] + dp[i][j - 1]
        if s == t:
            v += 1
        else:
            v -= dp[i - 1][j - 1]
        dp[i][j] = v % MOD

print((dp[-1][-1] + 1) % MOD)


Measured memory_bytes: 72668
#include <bits/stdc++.h>
#include <limits>
#include <math.h>
#include <cmath>
#include <cctype>
#include <cstdio>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll> ;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vvll = vector<vector<long long >>;
#define PI  3.1415926535
#define rep(i, k, n) for(ll i = k; i < n; i++)

int main(){
  ll n; cin >> n;
  
  ll ans = 10000000000000000;
  rep(i, 1, pow(n, 0.5)+1){
    ll res;
    if(n % i == 0){res = i + n/i; ans = min(res, ans);}
  }
  
  cout << ans - 2 << endl;
}
      


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

const long long INF = 1e18;

struct edge {
    int to;
    int cost[2];
};

typedef pair<long long, long long> pll;

int n, m, s, t;
vector<vector<edge> > G;
vector<vector<long long> > d(2);  // 0 -> yen, 1 -> snuuk

void dijkstra(int i, int s) {
    priority_queue<pll, vector<pll>, greater<pll> > que;
    d.at(i).at(s) = 0;
    que.push(make_pair(0, s));
    while (!que.empty()) {
        pll p = que.top();
        que.pop();
        int v = p.second;
        if (d.at(i).at(v) < p.first) continue;
        for (auto &e : G.at(v)) {
            if (d.at(i).at(e.to) > d.at(i).at(v) + e.cost[i]) {
                d.at(i).at(e.to) = d.at(i).at(v) + e.cost[i];
                que.push(make_pair(d.at(i).at(e.to), e.to));
            }
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const long long money = 1e15;
    cin >> n >> m >> s >> t;
    --s;
    --t;
    G.resize(n);
    d.at(0).resize(n, INF);
    d.at(1).resize(n, INF);
    for (int i = 0; i < m; ++i) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        --u;
        --v;
        G.at(u).push_back(edge{v, {a, b}});
        G.at(v).push_back(edge{u, {a, b}});
    }
    dijkstra(0, s);
    dijkstra(1, t);
    vector<long long> ans(n, INF);
    ans.at(n - 1) = money - (d.at(0).at(n - 1) + d.at(1).at(n - 1));
    for (int i = n - 2; i >= 0; --i) {
        ans.at(i) = max(ans.at(i + 1), money - (d.at(0).at(i) + d.at(1).at(i)));
    }
    for (auto &x : ans) {
        cout << x << endl;
    }

    return 0;
}

Measured memory_bytes: 10692
/**
 * @author: Mackenzie
**/
#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    int n,k;
    cin>>n>>k;
    int ans=0;
    forn(i,n){
        int h;
        cin>>h;
        if(h>=k)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <cstring>
#include <string>
#include <list>
#include <bitset>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

const LL mod=1e9+7;
const double PI=acos(-1);
const double EPS=1e-6;
const int INF=0x3f3f3f3f;
inline int readint(){int sum=0;char c=getchar();bool f=0;while(c<'0'||c>'9'){if(c=='-') f=1;c=getchar();}while(c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}if(f) return -sum;return sum;}
inline LL readLL(){LL sum=0;char c=getchar();bool f=0;while(c<'0'||c>'9'){if(c=='-') f=1;c=getchar();}while(c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}if(f) return -sum;return sum;}

int ct[10005];
int a[105][105];

int main(){ios_base::sync_with_stdio(0);cin.tie(0);
    int h,w;cin>>h>>w;
    int n;cin>>n;
    for(int i=1;i<=n;i++) cin>>ct[i];
    int pos=1;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(!ct[pos]) pos++;
            if(i%2){
                a[i][j]=pos;
            }else{
                a[i][w+1-j]=pos;
            }
            ct[pos]--;
        }
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cout<<a[i][j];
            if(j<w) cout<<" ";
            else cout<<endl;
        }
    }
    return 0;
}

//cout.setf(ios::fixed);
//cout<<fixed<<setprecision(10)<<s<<endl;


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define mk make_pair


int main()
{
  ll a;
  cin>>a;
  //a--;
  string s="";
  while(a)
  {
    a--;
    ll d=a%26;
    s.pb('a'+d);
    a/=26;
  }
  //s.pb('a'+a);
  reverse(s.begin(),s.end());
  cout<<s;
}


Measured memory_bytes: 3576
S=input()[::-1]
W=("dream"[::-1],"dreamer"[::-1],"erase"[::-1],"eraser"[::-1])
ind=0
while ind<len(S):
  for w in W:
    if S[ind:ind+len(w)]==w:
      ind+=len(w)
      break
  else:
    print("NO")
    break
else:
  print("YES")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INF 1000000000000 //10^12

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

    for(ll i=2;i>=0;i--){
        if(n/(ll)(pow(10,i)) == 7){
            cout <<"Yes"<<endl;
            return 0;
        }
        n%=(ll)(pow(10,i));
    }
    cout << "No" <<endl;
}

Measured memory_bytes: 3776
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


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




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

	vector<ll> num(N + 1, 1);
	vector<ll> r(N + 1, 0);
	r[1] = 1;

	repn(i, M) {
		ll x, y;
		cin >> x >> y;

		if (r[x] == 1) {
			if (num[x] == 1) { r[x] = 0; r[y] = 1; }
			else { r[y] = 1; }
		}

		num[x]--;
		num[y]++;
	}

	ll ans = 0;
	repn(i, N) ans += r[i];

	cout << ans;
	

	system("PAUSE");
}


Measured memory_bytes: 2040
#include<stdio.h>
typedef long long LL;
const int mod=1000000007;
inline int Mod2(int x){return x<0?x+mod:x;}
int Qpow(int a,int b){
	int c=1;
	for(;b;b>>=1,a=(LL)a*a%mod) if(b&1) c=(LL)c*a%mod;
	return c;
}
int flag[100010];
int A[100010],n;
int main(){
	scanf("%d",&n);
	int s,t;
	for(int i=1;i<=n+1;++i){
		scanf("%d",&A[i]);
		if(flag[A[i]]) s=flag[A[i]],t=i;
		flag[A[i]]=i;
	}
	int p1=n+1,p2=1;
	for(int k=0;k<=n;++k){
		printf("%d\n",Mod2(p1-p2));
		p1=(LL)p1*Qpow(k+2,mod-2)%mod*(n-k)%mod;
		p2=(LL)p2*Qpow(k+1,mod-2)%mod*(n-t+s-k)%mod;
	}
//	while(1);
	return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <limits>
#include <ios>
#include <iomanip>
#include <stdio.h>
#include <iomanip>
#include <queue>
using namespace std;

#define rep(i,N) for(int (i)=0; (i)<(N); (i)++)
#define revrep(i,N) for(int (i)=(N)-1; (i)>=0; (i)--)
#define coutline cout<<"------------ ("<<__LINE__<<")"<<endl;

typedef long long ll;

int main(void)
{
    int N,M;
    cin >> N >> M;
    vector<int> list(M, 0);
    vector<int> P(M);

    rep(i,M){
        int k;
        cin >> k;

        rep(j,k) {
            int s;
            cin >> s;
            s--;
            list.at(i) += ((int)(1) << s);
        }
    }

    rep(i,M){
        int p;
        cin >> p;
        P.at(i) = p;
    }


    ll ret = 0;
    rep(i,pow(2,N)) {
        bool flg = true;
        rep(j,M){
            int s = list.at(j);
            int t = i & s;
            int count = 0;
            rep(k,N) {
                if ((t >> k) & 1 == 1){
                    count ++;
                }
            }
            int p = P.at(j);
            if (count%2 != p){
                flg = false;
                break;
            }
        }

        if(flg) ret++;
    }

    
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 512
var pairs = [];

process.stdin.resume();
process.stdin.setEncoding('utf8');

process.stdin.on('data', function(input){
    input.trim().split('\n').forEach(function(line){
        pairs.push(line.split(' '));
    });
});

process.stdin.on('end', function(){
    for (var i in pairs){
        var a = parseInt(pairs[i][0]);
        var b = parseInt(pairs[i][1]);
        console.log((Math.LOG10E * Math.log(a + b) | 0) + 1);
    };
});

Measured memory_bytes: 8676
#include <bits/stdc++.h>
using namespace std;
#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 bit(k) (1LL<<(k))
typedef long long ll;

// m桁の短歌数の総数
ll total(int m){
    return 81*(bit(m-1)-1);
}

string rec(ll n,int m,int f){
    rep(x,10){
        ll block = (f != x ? bit(m-1) : (bit(m-1)-1)*9);
        if(n >= block){
            n -= block;
        }else{
            string str = to_string(x);
            if(f == x){
                str += rec(n,m-1,f);
            }else{
                if(f < x) swap(f,x);
                for(int k = m-2; k >= 0; k--){
                    str += to_string(n&bit(k) ? f : x);
                }
            }
            return str;
        }
    }
    assert(false);
}

int main(){
    ll n;
    while(cin>>n, n){
        n--;
        int m = 2;
        while(n >= total(m)){
            n -= total(m);
            m++;
        }
        ll block = total(m)/9;
        int f = 1 + n/block;
        n %= block;
        cout<<to_string(f)<<rec(n,m-1,f)<<endl;
    }
    return 0;
}



Measured memory_bytes: 3228
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    S = rl().rstrip()
    if 'RRR' == S:
        print(3)
    elif 'RR' in S:
        print(2)
    elif 'R' in S:
        print(1)
    else:
        print(0)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 61804
N = int(input())
A = [str(bin(a)).lstrip('0b').zfill(60) for a in map(int,input().split())]
A_rev = list(zip(*A))

ans = 0
for i, a in enumerate(A_rev):
	k = a.count('1')
	ans+=(k*(N-k)*2**(59-i))
print(ans%(10**9+7))

Measured memory_bytes: 203864
#include<stdio.h>
#define Double double
#define Int int
#define For for
#define Scanf scanf
#define If if
#define Printf printf
#define Roop(i,n) for(i=0;i<n;i++)
#define Roop2(i,n) for(i=1;i<=n;i++)
#define Roop3(i,n) for(i=2;i<=n;i++)

Double dp[101][101],x[101][101];

int main(){
 Int i,j,k,n,m;
 Double max=0.0;
while( scanf("%d%d",&n,&m),n+m){
Roop(i,n)
 Roop(j,n)
  Scanf("%lf",&x[i][j]);

 Roop2(i,m)
  Roop(j,n)
   dp[i][j]=(double)(i==1);

 Roop3(i,m)
  Roop(j,n)
   Roop(k,n)
    If(dp[i][j]<dp[i-1][k]*x[k][j])
     dp[i][j]=dp[i-1][k]*x[k][j];

 max=0.0;
 Roop(i,n)if(max<dp[m][i])max=dp[m][i];

 Printf("%.2lf\n",max);}
return 0;
}

Measured memory_bytes: 820
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N;
    while (cin >> N, N) {

        auto cost = make_v(INF, 15, 15);

        for (size_t i = 0; i < 15; ++i) {
            cost[i][i] = 0;
        }

        size_t maxnode = 0;
        for (size_t i = 0; i < N; ++i) {
            size_t a, b, c; cin >> a >> b >> c;
            cost[a][b] = cost[b][a] = c;
            chmax(maxnode, max(a, b));
        }

        for (size_t node = 0; node <= maxnode; ++node) {
            for (size_t s = 0; s <= maxnode; ++s) {
                for (size_t g = 0; g <= maxnode; ++g) {
                    chmin(cost[s][g], cost[s][node] + cost[node][g]);
                }
            }
        }

        pair<size_t, size_t> minv = {INF, INF};
        for (size_t s = 0; s <= maxnode; ++s) {
            size_t sum = 0;
            for (size_t node = 0; node <= maxnode; ++node) {
                if (s == node) continue;
                if (cost[s][node] != INF) {
                    sum += cost[s][node];
                }
            }
            chmin(minv, make_pair(sum, s));
        }

        cout << minv.second << " " << minv.first << "\n";
    }

    return 0;
}



Measured memory_bytes: 3184
#include <stdio.h>
int main(){
	int H,W,i,k;
	for(;;){
		scanf("%d %d",&H,&W);
		if(H==0 && W==0)break;
		for(i=1;i<=H;i++){
			if(i%2!=0){
				for(k=1;k<=W;k++){
					if(k%2!=0){
						printf("#");
					}else{
						printf(".");
					}
				}
			}else{
				for(k=1;k<=W;k++){
					if(k%2==0){
						printf("#");
					}else{
						printf(".");
					}
				}
			}
			printf("\n");
		}
		printf("\n");	
	}
	return 0;
}	

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

ll mod = 1e9+7;

int main()
{
	int n;cin>>n;
	string s;
	cin>>s;
	int x = 0;
	int ans =0;
	for(auto ch :s){
		if(ch == 'I')
			x++;
		else x--;

		ans = max(ans,x);
	}

	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }



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

  string s;
  cin >> s;

  cout << s.substr(0, 3) << endl;

  return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>

#define INITIALIZE_INT 0//整数型の初期値
#define END 0//入力の終了値
#define START_NUMBER 1//魔法陣に入る最初の数値
#define HALF 2 //魔法陣のマスのセンター座標を求めるとき使う値
#define NO_CONTENTS 0//空のマスの値

/*すべてのパネルが埋まっているかどうかのフラグ*/
enum
{
	OFF,
	ON
};

void out_magic_square(short *x, short *y, unsigned short *input_n);

int main(void)
{
	
	while(1)
	{
		short x = INITIALIZE_INT;//魔法陣のx座標
		short y = INITIALIZE_INT;//魔法陣のy座標
	
		unsigned short input_n = INITIALIZE_INT;//入力値n
		scanf("%hd", &input_n);
		if(END == input_n)
		{
			break;
		}
		
		
		unsigned short ix = INITIALIZE_INT;
		unsigned short iy = INITIALIZE_INT;
		unsigned short loop_flag = OFF;
		unsigned short center = INITIALIZE_INT;
		unsigned short number = START_NUMBER;
		
		short magic_square[input_n][input_n];
		
		for(iy = 0; iy < input_n; iy++)
		{
			for(ix = 0; ix < input_n; ix++)
			{
				magic_square[iy][ix] = INITIALIZE_INT;
			}
		}
		
		center = input_n / HALF;
		magic_square[center + 1][center] = number;
		number++;
		x = center;
		y = center + 1;
		
		while(1)
		{
			x++;
			y++;
			
			out_magic_square(&x, &y, &input_n);
			
			if(NO_CONTENTS == magic_square[y][x])
			{
				magic_square[y][x] = number;
				number++;
			}
			else if(NO_CONTENTS != magic_square[y][x])
			{
				
				/*マスに数字が入るまで*/
				while(1)
				{
					y++;
					x--;
					out_magic_square(&x, &y, &input_n);
					
					if(NO_CONTENTS == magic_square[y][x])
					{
						magic_square[y][x] = number;
						number++;
						break;
					}
				}
			}
			
			/*魔法陣がすべての埋まっているか埋まっていないかの判定*/
			loop_flag = OFF;
			for(iy = 0; iy < input_n; iy++)
			{
				for(ix = 0; ix < input_n; ix++)
				{
					if(0 == magic_square[iy][ix])
					{
						loop_flag = ON;
					}
				}
			}
			if(OFF == loop_flag )
			{
				break;
			}
			
		}
		
		/*結果の出力*/
		for(iy = 0; iy < input_n; iy++)
		{
			for(ix = 0; ix < input_n; ix++)
			{
				printf("%4d",magic_square[iy][ix]);
			}
			printf("\n");
		}
	}
	return 0;
}

void out_magic_square(short *x, short *y, unsigned short *input_n)
{
	
	if(*x >= *input_n )
	{
		*x = 0;
	}
	if(*y >= *input_n)
	{
		*y = 0;
	}
	if( *x < 0)
	{
		*x = *input_n - 1;
	}
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

vector<int> G[200200];
vector<int> rG[200200];
vector<int> loop;
int used[200200];
bool isloop[200200];
int N;

vector<int> grundyP[200200];

bool dfs_findloop(int v){
    used[v]=1;
    bool res=false;
    for(int u:G[v]){
        if(used[u]==0){
            if(dfs_findloop(u))res=true;
        }else if(used[u]==1)res=true;
    }
    if(res)loop.push_back(v);
    used[v]=2;
    return res;
}

void add_G(int from,int to){
    G[from].push_back(to);
    rG[to].push_back(from);
}

int dfs_grundy(int v){
    set<int> used_g;
    for(int u:G[v])used_g.insert(dfs_grundy(u));
    int res=-1;
    while(true)if(used_g.count(++res)==0)return res;

}

int dfs_solve(int v,int k){
    used[v]=1;
    int rec =(k==grundyP[v][0] ? grundyP[v][1] : grundyP[v][0]);
    for(int u:rG[v])if((isloop[u])&&(used[u]==0))return dfs_solve(u,rec);
    return rec;
}


int main(){
    cin>>N;
    REP(i,N){
        int p;cin>>p;p--;
        add_G(p,i);
    }
    set<int> grundy[N];

    fill_n(used,N,0);
    fill_n(isloop,N,false);
    REP(i,N)if(used[i]==0)dfs_findloop(i);
    for(int v:loop)isloop[v]=true;
    for(int v:loop)
        for(int u:G[v])
            if(!isloop[u])
                grundy[v].insert(dfs_grundy(u));

    for(int v:loop){
        int res=-1;
        while(grundyP[v].size()<2){
            if(grundy[v].count(++res)==0)
                grundyP[v].push_back(res);
        }
    }

    int root=loop[0];
    fill_n(used,N,0);
    if(dfs_solve(root,-1)!=grundyP[root][0]){
        cout<<"POSSIBLE"<<endl;
    }else{
        fill_n(used,N,0);
        if(dfs_solve(root,grundyP[root][0])==grundyP[root][0]) {
            cout << "POSSIBLE" << endl;
        }else{
            cout<<"IMPOSSIBLE"<<endl;
        }
    }
    return 0;
}

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

int main()
{
  int i, j, N, minj;
  char store[36][3], Bubble[36][3], Select[36][3], temp[3];

  
  scanf("%d", &N);

  for( i=0; i<N; i++ )
    {
      scanf("%s", store[i]);
      strcpy(Bubble[i],store[i]);
      strcpy(Select[i],store[i]);
    }

  
  for( i=0; i<N; i++ )
    {
      for( j=N-1; j>=i+1; j-- )
	{
	  
	  if( Bubble[j][1] < Bubble[j-1][1] )
	    {
	      strcpy(temp,Bubble[j]);
	      strcpy(Bubble[j],Bubble[j-1]);
	      strcpy(Bubble[j-1],temp);
	    }
	}
      

      minj = i;
      
      for( j=i; j<N; j++ )
	{
	  if( Select[j][1] < Select[minj][1] ) minj = j;    
	}

      if( minj != i);
      {
	strcpy(temp, Select[i]);
	strcpy(Select[i],Select[minj]);
	strcpy(Select[minj],temp);
      }


      printf("%s", Bubble[i]);
      
      if( i == N-1 )
	{
	  printf("\n");
	  break;
	}
      printf(" ");
      
    }
  
  printf("Stable\n");
  

  for( i=0; i<N; i++ )
    {
      printf("%s", Select[i]);
      if( i == N-1 )
	{
	  printf("\n");
	  break;
	}
      printf(" ");
    }

  for( i=0; i<N; i++ )
    {
      if( Bubble[i][0] != Select[i][0] && Bubble[i][1] != Select[i][0] )
	{
	  printf("Not stable\n");
	  return 0;
	}
    }
  
  printf("Stable\n");
  
  return 0;
}

  

	  
	      



Measured memory_bytes: 2104
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;*/
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define S second
#define F first
#define f(i,n) for(ll i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
int main()
{
fast;

    ll r;
    cin>>r;
    double ans=2*3.141592653589793238*r;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3796
#include "bits/stdc++.h"

using namespace std;
using ll = long long;

const ll MOD = 998244353;
ll dp[3005][3005] = {};

int main() {
    int N, S;
    cin >> N >> S;
    vector<int> A(N);
    for (int i = 0; i < N; ++i)
        cin >> A[i];

    dp[0][0] = 1LL;
    for (int i = 0; i < N; ++i) {
        for (int k = 0; k <= S; ++k) {
            if (A[i] <= k)
                dp[i + 1][k] = (2 * dp[i][k] + dp[i][k - A[i]]) % MOD;
            else
                dp[i + 1][k] = 2 * dp[i][k] % MOD;
        }
    }

    cout << dp[N][S] << endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	string S;
	cin>>S;
	S[0]='2';
	S[1]='0';
	S[2]='1';
	S[3]='8';
	cout<<S<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
    	FastScanner fs = new FastScanner();
    	String s = "ACL";
    	int k = fs.nextInt();
    	s = s.repeat(k);
    	System.out.println(s);
    }
    
    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        String next() {
            while (!st.hasMoreTokens())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }

}


Measured memory_bytes: 32604
from fractions import gcd
from functools import reduce

N, X   = map(int, input().split())
x = list(map(int, input().split()))
assert len(x) == N

x.sort()

# distance between each two cities
dist = [x[i] - x[i-1] for i in range(1, len(x))]

# distance between the first city and the start point
dist.append(abs(x[0] - X))

print(reduce(gcd, dist))


Measured memory_bytes: 16280
from queue import deque

h, w = map(int, input().split())
state = [input() for _ in range(h)]

q = deque()
q.append((0,0))
distance = [[-1]*w for _ in range(h)]
distance[0][0] = 0
neighbors = [[0,1],[0,-1],[1,0],[-1,0]]

while q:
    pos_i, pos_j = q.popleft()
    cur_d = distance[pos_i][pos_j]
    for di, dj in neighbors:
        ni, nj = pos_i+di, pos_j+dj
        if not(0<=ni<h and 0<=nj<w):
            continue
        elif state[ni][nj]=='.' and distance[ni][nj]<0:
            distance[ni][nj] = cur_d+1
            q.append((ni,nj))

if distance[h-1][w-1] == -1:
    print(-1)
    exit()

n_white = sum(state[i].count('.') for i in range(h))
print(n_white-distance[h-1][w-1]-1)

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

typedef long long LL;

int main() {
    int N, K;
    cin >> N >> K;
    int a[N];
    LL sum = 0;
    vector<int> check_point;
    for (int i=0;i<N;i++)
    {
        cin >> a[i];
        sum += a[i];
    }

    if (sum < K) {
        cout << N;
        return 0;
    }

    sort(a, a+N);

    sum = 0;

    for (int i=N-1;i>=0;i--)
    {
        if (sum < K and i >= 0)
        {
            sum += a[i];
        } else if (i >= 0)
        {
            check_point.push_back(i + 1);
            sum = sum + a[i] - a[i + 1];
        } else{
            break;
        }
    }
    if (!check_point.empty() & sum < K)
        cout << check_point.back();
    else
        cout << 0;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <map>
#include <math.h>
#include <complex>
#include <string>

#define _GLIBCXX_DEBUG
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
/* 基本要素 */


int main()
{
	 string s;
    cin >> s;
    if(s=="SUN") cout << 7 << endl;
    else if (s=="MON") cout << 6 << endl;
    else if (s=="TUE") cout << 5 << endl;
    else if (s=="WED") cout << 4 << endl;
    else if (s=="THU") cout << 3 << endl;
    else if (s=="FRI") cout << 2 << endl;
    else if (s=="SAT") cout << 1 << endl;
}

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

int main(){
	int N;
	int AC = 0;
	int WA = 0;
	int TLE = 0;
	int RE = 0;
	cin >> N;
		
	while(N--){
		string s;
		cin >> s;
		if(s == "AC"){
			AC++;
		}else if(s == "WA"){
			WA++;
		}else if(s == "TLE"){
			TLE++;
		}else if(s == "RE"){
			RE++;
		}
	}
	
	cout << "AC x " << AC << "\n";
	cout << "WA x " << WA << "\n";
	cout << "TLE x " << TLE << "\n";
	cout << "RE x " << RE ;
	
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  ll X, ans = 0, count = 1;
  cin >> X;
  while (ans < X) {
    ans = ans + count;
    count++;
  }
  cout << count - 1 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  static String str;
  static int N,zeroC,oneC;
  static int[] A;
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    str = sc.next();
    N = str.length();
    A = new int[N];
    for(int i=0;i<N;i++){
      A[i]=Character.getNumericValue(str.charAt(i));
      if(A[i]==0){
        zeroC++;
      }
      else{
        oneC++;
      }
    }
    System.out.println(N-(Math.abs(zeroC-oneC)));



  }


}


Measured memory_bytes: 26048
#include <stdio.h>

int main(void){
    int A[6];
    int k;
    for (int i=0; i<5; i++) {
        scanf("%d",&A[i]);
    }
    scanf("%d",&k);
    if(A[4]-A[0]>k){
        printf(":(\n");
    }
    else{
        printf("Yay!\n");
    }
    return 0;
}


Measured memory_bytes: 128
import sys
from collections import deque


def main():
    n, m = map(int, sys.stdin.readline().split())

    to = [[] for _ in range(n + 1)]
    for _ in range(m):
        a, b = map(int, sys.stdin.readline().split())
        to[a].append(b)
        to[b].append(a)
    INF = float("inf")

    dist = [INF] * (n + 1)
    dist[1] = 0
    pre = [0] * (n + 1)
    que = deque([])
    que.append(1)

    while que:
        p = que.popleft()
        for i in to[p]:
            if dist[i] == INF:
                dist[i] = dist[p] + 1
                pre[i] = p
                que.append(i)

    print("Yes")
    for i in range(2, n + 1):
        print(pre[i])


if __name__ == "__main__":
    main()

Measured memory_bytes: 35120
#include <bits/stdc++.h>
    #define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
    using ll = long long;
    using namespace std;
    ll n , k , s = 0 , a[550] , b[550] , ans = 0;
    ll f(ll w) {
        ll s2 = 0 , s3 = 0;
        rep(i , 0 , n) {
    	    b[i] = a[i] % w;
    	    s2 += b[i];
    	} 
        sort(b , b + n);
        rep(i , 0 , n - s2 / w) s3 += b[i];
        if(s3 <= k) return w;
        else return 0;
    }
    int main(){
        cin >> n >> k;
        rep(i , 0 , n) {
    	    cin >> a[i];
    		s += a[i];
    	}
        for(ll p = 1 ;(p * p) <= s ; p++) if(s % p == 0) {
            ans = max(ans , f(p));
            if(s % p == 0)ans = max(ans , f (s / p));
        }
        cout << ans;
    	return 0;
    }

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
    int n;
    cin>>n;
    pair<ll,ll> a[n];
    rep(i,n){
        cin>>a[i].first>>a[i].second;
    }

    sort(a,a+n,[](pair<ll,ll> s, pair<ll,ll> t){
        complex<double> x,y;
        x=complex<double>{(double)s.first, (double)s.second};
        y=complex<double>{(double)t.first, (double)t.second};
        return arg(x)<arg(y);
    });

    ll ans = 0;
    rep(i,n){
        ll x = 0, y = 0;
        rep(j,n){
            x+=a[(i+j)%n].first;
            y+=a[(i+j)%n].second;
            ans = max(ans,x*x+y*y);
        }
    }
    cout<<fixed<<setprecision(12)<<sqrt((long double)ans)<<endl;
    return 0;
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n+2, -100);
    rep(i, n) cin >> a[i];
    int ans=0;
    rep(i, n) {
        if (a[i+1] == -1) continue;
        if (a[i] == a[i+1]) {
            a[i+1] = -1;
            ans++;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

#define FOR(i,a,b)  for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n)    FOR(i,0,n)
#define ALL(a)      a.begin(),a.end()
#define vi          vector<int>
#define vvi         vector<vi>
#define P           pair<int,int>
#define vP          vector<P>
#define vvP         vector<vP>
#define ll          long long

int main(){
    ll multiple=0;
    {
        ll x,y;cin>>x>>y;
        multiple=y/x;
    }
    int res=1;
    while(true){
        if(multiple<2)break;
        multiple/=2;
        res++;
    }
    cout<<res<<"\n";
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
answers = [input().split() for _ in range(m)]

num_ac = 0
num_wa = 0
q_d = dict()
done = set()

for q_num, result in answers:
    q_num = int(q_num)
    if q_num in done:
        continue

    if result == "AC":
        num_ac += 1
        num_wa += q_d.get(q_num, 0)
        done.add(q_num)
    elif result == "WA":
        q_d[q_num] = q_d.get(q_num, 0) + 1

print(num_ac, num_wa)



Measured memory_bytes: 41104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=998244353;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<'\n';}}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll n;cin>>n;
    ll ans=n/500*1000;
    n%=500;
    out(ans+n/5*5);
}

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

using namespace std;

int main(){
    int x,n;
    cin>>x>>n;
    
    vector<int> p(n);
    for(int i=0;i<n;i++)
        cin>>p[i];
    
    int c=0;
    for(int i=0;i<n;i++){
        if(x!=p[i]){
            c++;
        }
    }
    
    if(c==n)
        cout<<x<<endl;
    else{
        int j=1;
        int c1=0;
        int c2=0;
    
        while(c!=n){
            for(int i=0;i<n;i++){
                if(x-j!=p[i])
                    c1++;
                if(x+j!=p[i])
                    c2++; 
            }
            if(c1==n){
                cout<<x-j<<endl;
                break;
            }else if(c2==n){
                cout<<x+j<<endl;
                break;
            }
            j++;
            c1=0;
            c2=0;
        }
    }
}

Measured memory_bytes: 3604