akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

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

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  vl num(4);
  
  rep(i,6){
    ll x; cin >> x; x--;
    num[x]++;
  }
  
  rep(i,4){
    if(num[i] == 3){
      cout << "NO" << endl;
      return 0;
    }
  }
  
  cout << "YES" << endl;
  
  
}

Measured memory_bytes: 3620
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    ll A[200010];
    rep(i,0,N) cin >> A[i];
    rep(i,0,N) A[i]--;
    ll sum[200010] = {};
    rep(i,0,N) sum[i+1] = sum[i] + A[i];
    ll ans = 0;
    map<ll,ll> mp;
    rep(i,0,N+1) sum[i] %= K;
    // printa(sum, N+1);
    rep(i,0,N+1){
        ll amari = sum[i] % K;
        ans += mp[amari];
        mp[amari]++;
        ll j = i - (K-1);
        if(j >= 0) mp[sum[j] % K]--;
    }
    print(ans);
    // rep(i,0,N+1){
    //     mp[sum[i] % K]++;
    // }
    // for(auto &e: mp){
    //     ans += e.second * (e.second - 1) / 2;
    // }
    // print(ans);


    

}

Measured memory_bytes: 15872
MOD = int(1e+9 + 7)
N, K = map(int, input().split())

cnt = [0] * (K + 1) # 要素が全てXの倍数となるような数列の個数をXごとに求める
for x in range(1, K + 1):
    cnt[x] = pow(K // x, N, MOD)
for x in range(K, 0, -1): # 2X, 3Xの個数を求めてひく
    for i in range(2, K // x + 1):
        cnt[x] -= cnt[x * i]
ans = 0
for k in range(K+1):
    ans += cnt[k] * k
ans = ans % MOD
print(ans)

Measured memory_bytes: 11288
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
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() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll A, B; cin >> A >> B;
    ll ans = 0;
    ll out = 1;
    if (B==1) {
        cout << 0 << '\n';
        return 0;
    }
    REP (i, 20) {
        ++ans;
        out += A-1;
        if (out>=B) break;
    }
    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
n, m = map(int, input().split())
ary = [tuple(map(int, line.strip().split())) for line in sys.stdin.readlines()]

demands = sorted(ary, key=lambda x: x[1])[::-1]
compressed = []
while demands:
    a, b = demands.pop()

    for i, (ai, bi) in enumerate(compressed):
        if bi <= a:
            continue

        else:
            if ai < a:
                compressed[i] = (a, min(b, bi))
            break

    else:
        compressed.append((a, b))

print(len(compressed))


Measured memory_bytes: 23736
// ARC085
// E - MUL

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 100;
const int MAX_V = MAX_N + 2;
const ll INF = 1e18;

template <typename T>
struct edge {
    int to;
    T cap;
    int rev;
};

template <typename T>
class Graph {
public:
    void add_edge(int from, int to, T cap);
    T max_flow(int s, int t);

private:
    void bfs(int s);
    T dfs(int v, int t, T f);
    vector<edge<T>> g[MAX_V];
    int level[MAX_V];
    int iter[MAX_V];
};

template <typename T>
void Graph<T>::add_edge(int from, int to, T cap) {
    g[from].push_back((edge<T>){to, cap, (int)g[to].size()});
    g[to].push_back((edge<T>){from, 0, (int)g[from].size() - 1});
    return;
}

template <typename T>
T Graph<T>::max_flow(int s, int t) {
    T f;
    T flow = 0;

    while (true) {
        bfs(s);
        if (level[t] < 0) {
            break;
        }
        memset(iter, 0, sizeof(iter));
        while ((f = dfs(s, t, INF)) > 0) {
            flow += f;
        }
    }
    return flow;
}

template <typename T>
void Graph<T>::bfs(int s) {
    queue<int> que;
    int v;
    int i;

    memset(level, -1, sizeof(level));
    level[s] = 0;
    que.push(s);
    while (!que.empty()) {
        v = que.front();
        que.pop();
        for (i = 0; i < (int)g[v].size(); i++) {
            if (g[v][i].cap > 0 && level[g[v][i].to] < 0) {
                level[g[v][i].to] = level[v] + 1;
                que.push(g[v][i].to);
            }
        }
    }
    return;
}

template <typename T>
T Graph<T>::dfs(int v, int t, T f) {
    T d;

    if (v == t) {
        return f;
    }
    for (; iter[v] < (int)g[v].size(); iter[v]++) {
        edge<T> &e = g[v][iter[v]];
        if (e.cap > 0 && level[v] < level[e.to]) {
            d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                g[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int N;
Graph<ll> g;

int main() {
    cin >> N;

    int S = 0;
    int T = N + 1;
    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        ll a;
        cin >> a;
        if (a < 0) {
            g.add_edge(S, i, -a);
        } else {
            ans += a;
            g.add_edge(i, T, a);
        }
        for (int j = 2 * i; j <= N; j += i) {
            g.add_edge(i, j, INF);
        }
    }

    ans -= g.max_flow(S, T);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS {ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
#define endl "\n"
#define float long double
#define int long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fb(i, a, b) for(int i=a; i>=b; i--)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define LB lower_bound
#define UB upper_bound
#define g(t, n) get<n>(t)
#define fp(x, y) fixed<<setprecision(y)<<x
#define PI 3.141592653589793238462643383279502884
using namespace std;

const int M = (int)2e5+5;
const int mod = (int)1e9+7;

void solve()
{
    int n;
    cin>>n;
    int x[n], y[n], mxsum = -1e18, mnsum = 1e18, mxdiff = -1e18, mndiff = 1e18;
    f(i, 0, n) cin>>x[i]>>y[i];
    f(i, 0, n)
    {
    	mxsum = max(mxsum, x[i]+y[i]);
    	mnsum = min(mnsum, x[i]+y[i]);
    	mxdiff = max(mxdiff, x[i]-y[i]);
    	mndiff = min(mndiff, x[i]-y[i]);
    }
    cout<<max(mxsum-mnsum, mxdiff-mndiff)<<endl;
}

int32_t main()
{
    IOS
    int t = 1;
    // cin>>t;
    f(tno, 1, t+1)
    {
        // cout<<"Case #"<<tno<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 6756
import sys

text = [line.lower().split() for line in sys.stdin.readlines()]
new_text = "".join([line for inner in text for line in inner])
keys = [chr(ord("a") + i) for i in range(26)]
values = [0] * 26
alpha = dict(zip(keys, values))

for c in alpha:
    alpha[c] = new_text.count(c)

for key, value in alpha.items():
    print("{0} : {1}".format(key, value))



Measured memory_bytes: 5572
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
const ll maxn = 1e5 + 500;
ll a[maxn],dp[maxn];
int main(int argc, char const *argv[])
{
	memset(dp,0x3f3f3f3f,sizeof(dp));
	ll n,k;
	cin>>n>>k;
	for(ll i = 1;i <= n; ++i)
	{
		scanf("%lld",&a[i]);
	}
	dp[1] = 0;
	for(ll i = 1;i <= n; ++i)
	{
		for(ll j = 1;j <= k; ++j)
		{
			dp[i + j] = min(dp[i + j],dp[i] + abs(a[i + j] - a[i]));
		}
	}
	// for(ll i = 1;i <= n; ++i)
	// {
	// 	debug("dp[%d] = %d\n",i,dp[i]);
	// }
	printf("%lld\n",dp[n]);
	return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>

#define ll long long int
#define all(x) x.begin(), x.end()
#define MOD 998244353

using namespace std;


void solve()
{
    string s, t;
    cin >> s >> t;

    int n = s.size();
    for (int i = 0; i < n; i++)
    {
        if (s[i] != t[i])
        {
            cout << "No\n";
            return;
        }
    }

    if (n == t.size() - 1) {
        cout << "Yes\n";
        return;
    }
    cout << "No\n";
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int T = 1;
    // cin >> T;
    while (T--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
int main(){
  int n,m;
  cin>>n>>m;
  dsu x(n);
  int c=n;
  for(int _=0;_<m;_++){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    if(x.same(a,b))
      continue;
    x.merge(a,b);
    c--;
  }
  cout<<c-1<<endl;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
#define hyperspeed ios::sync_with_stdio(false);cin.tie(NULL);
#define ll long long  
#define ull unsigned long long
#define ui unsigned int
#define li long int
#define uli unsigned long int
#define pb push_back
#define ld long double
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
const int MOD = 1e9+7;

void solve() {
    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5]) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
}

int32_t main()
{
    hyperspeed
    int test=1;
    // cin >> test;
    while(test--) {
        solve();
    }
    return 0;
}

//--n1m5


Measured memory_bytes: 3624
function main()
    data = readlines()
    N = parse(Int, data[1])
    A = parse.(Int, split(data[2]))
    B = zeros(Int, N)
    now = A[1]
    for n in 1:N
        B[n] = max(0, now-A[n])
        now = max(A[n], now)
    end
    println(sum(B))
end
main()

Measured memory_bytes: 206120
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
ll bin_pow(ll a,ll b,ll m)
{
    ll res=1;
    a%=m;
    while(b>0)
    {
        if(b&1)
            res=res*a%m;
        b>>=1;
        a=a*a%m;
    }
    return res;
}
bool miller_rabin(ll d,ll n)
{
    ll a=2+rand()%(n-4);
    ll x=bin_pow(a,d,n);
    if(x==1 || x==n-1)
        return true;
    while(d!=n-1)
    {
        x=(x*x)%n;
        d*=2;
        if(x==1)
            return false;
        if(x==n-1)
            return true;
    }
    return false;
}
bool prime(ll n,ll k)
{
    if(n==1 || n==4)
        return false;
    if(n<=3)
        return true;
    ll d=n-1;
    while(d%2==0)
        d/=2;
    for(int i=0; i<k; i++)
    {
        if(!miller_rabin(d,n))
            return false;
    }
    return true;
}
int n;
string s;
ll ans = 0;

void solve(ll x,ll y){
    if(x==n+1){
        ans += y;
        return;
    }
    ll cur = 0;
    for(ll i=x;i<=n;i++){
        cur = (10*cur) + (s[i]-'0');
        solve(i+1,y+cur);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    vector<ll>v[n+2];
    for(int i=0;i<m;i++){
        ll x,y;
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    for(int i=1;i<=n;i++){
        cout<<v[i].size()<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include <iomanip>
using namespace std;
int main()
{
  int a,b,c;
  cin >>a>>b>>c;

  if(a <= b && b <= c){ cout<<a<<" "<<b<<" "<<c<<endl;}
  else if(a <= c && c <= b){ cout<<a<<" "<<c<<" "<<b<<endl;}
  else if(b <= a && a <= c){ cout<<b<<" "<<a<<" "<<c<<endl;}
  else if(b <= c && c <= a){ cout<<b<<" "<<c<<" "<<a<<endl;}
  else if(c <= b && b <= a){ cout<<c<<" "<<b<<" "<<a<<endl;}
  else{ cout<<c<<" "<<a<<" "<<b<<endl;}

}



Measured memory_bytes: 3088
open System
open System.Collections.Generic

module InputUtility =
    let InputTokens = new Queue<string>()

    let EnsureInput () =
        if InputTokens.Count = 0 then
            let input = Console.ReadLine ()
            let s = input.Split ([|' '|], StringSplitOptions.RemoveEmptyEntries)
            if s.Length > 0 then
                for x in s do InputTokens.Enqueue(x)
                true
            else false
        else true

    let rec ReadNext () =
        if EnsureInput () then InputTokens.Dequeue ()
        else ReadNext ()

    let ReadNextInt () = ReadNext () |> int

    let Read2Int () = ReadNextInt (), ReadNextInt ()

    let ReadListOf f n =
        let rec loop acc = function
            | 0 -> List.rev acc
            | c -> loop ((ReadNext () |> f) :: acc) (c-1)
        loop [] n

    let MultipleCaseWithId f =
        let caseNum = ReadNextInt ()
        let rec loop index =
            if index = caseNum then ()
            else
                f index
                loop (index + 1)
        loop 0

    let MultipleCase f = MultipleCaseWithId (fun _ -> f ())

    let ReadList n =
        let rec loop acc = function
            | 0 -> List.rev acc
            | c -> loop (ReadNext () :: acc) (c-1)
        loop [] n

open InputUtility

module ARC075 =
    let rec binarySearchInt64 f s t =
        if s+1L=t then s
        else
            let d = (s+t)/2L
            if f d then binarySearchInt64 f d t
            else binarySearchInt64 f s d

    let private Widespread () =
        let g64 = ReadNext >> int64
        let ubDiv a b = (a - 1L) / b + 1L
        let n = ReadNextInt ()
        let inA, b = g64 (), g64 ()
        let a = inA - b
        let h = ReadListOf int64 n
        let f inD =
            let d = inD - 1L
            let bd = d * b
            let rec inner c = function
                | [] -> c >= 0L
                | h :: t ->
                    if h <= bd then inner c t
                    elif c < 0L then false
                    else
                        let r = ubDiv (h - bd) a
                        inner (c - r) t
            inner d h |> not
        binarySearchInt64 f 1L 1000000000L
        |> printfn "%d"

    let Entry = Widespread

ARC075.Entry ()

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

int a[1000000];
int main(){
	int n,l;scanf("%d%d",&n,&l);
	rep(i,n)scanf("%d",&a[i]);
	multiset<int>se;
	rep(i,l)se.insert(a[i]);
	printf("%d",*se.begin());
	for(int i=l;i<n;i++){
		se.insert(a[i]);
		se.erase(se.find(a[i-l]));
		printf(" %d",*se.begin());
	}
	puts("");
}

Measured memory_bytes: 11808
use io::*;
use proconio::{fastout, input};
use std::*;

#[fastout]
fn main() {
    input! {
        N: i64
    }
    let change = if (N % 1000 != 0) {
        1000 - (N % 1000)
    } else {
        0
    };
    println!("{}", change);
}


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

typedef long long ll;
typedef vector<ll> vl;

vl n_layers(51), n_buns(51);

ll solve(int N, ll X){
  if (N==0){ return X;}
  else if (X<=1){ return 0;}
  else if (X<=n_layers[N-1]+1){ return solve(N-1, X-1);}
  else if (X==n_layers[N-1]+2){ return n_buns[N-1]+1;}
  else if (X<=n_layers[N]-1){
    return n_buns[N-1]+1+solve(N-1, X-n_layers[N-1]-2);
  }
  else {return n_buns[N];}
}

int main(){
  int N;ll X;cin >>N>>X;
  n_layers[0]=1;
  n_buns[0]=1;
  for (int i=0;i<50;i++){
    n_layers[i+1]=2*n_layers[i]+3;
    n_buns[i+1]=2*n_buns[i]+1;
  }

  cout << solve(N, X)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int _par[1000005], _rank[1000005];

void init() {
  for(int i = 0; i < 1000005; i++) {
    _par[i] = i;
    _rank[i] = 0;
  }
}

int find(int x) {
  if(_par[x] == x) return x;
  else return _par[x] = find(_par[x]);
}

void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if(x == y) return ;

  if(_rank[x] < _rank[y]) _par[x] = _par[y];
  else {
    _par[y] = _par[x];
    if(_rank[_par[y]] == _rank[_par[x]]) _rank[_par[x]]++;
  }
}

bool same(int x, int y) {
  return find(x) == find(y);
}

int main() {
  init();
  int n, q, com, x, y;
  cin >> n >> q;
  for(int i = 0; i < q; i++) {
    cin >> com >> x >> y;
    if(com) cout << same(x, y) << endl;
    else unite(x, y);
  }
}



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

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


Measured memory_bytes: 3628
a,b=list(map(int,input().split()))

s=[['.' if i<50 else '#' for j in range(100)] for i in range(100)]

a-=1
b-=1

for i in range(1,50,2):
    for j in range(0,100,2):
        if b>0:
            s[i][j]='#'
            b-=1
        if a>0:
            s[i+50][j]='.'
            a-=1
print('100 100')
for i in range(100):
    print(''.join(s[i]))


Measured memory_bytes: 64884
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

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

    VI cnt(n, 0);
    FOR(i, 0, m) {
        int a, b; cin >> a >> b;
        a--, b--;
        cnt[a]++, cnt[b]++;
    }

    bool ng = false;
    FOR(i, 0, n)ng |= cnt[i] % 2;

    cout << (ng ? "NO\n" : "YES\n");
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
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;}

void solve() {
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i,n) cin >> v[i];
	int ans = v[0];
	rep(i,n) {
		ans = gcd(ans, v[i]);
	}
	cout << ans << endl;
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3792
#include<string>
#include<queue>
#include<stack>
#include<iostream>
#include<algorithm>
using namespace std;

int block[100][100];
bool maze = false;
int w, h;

void Lnitialization(int w,int h){
	for (int i = 1; i <= h; i++){
		for (int j = 1; j <= w; j++){
			block[i][j] = 0;
		}
	}
}
void Side(int c,int x,int y){
	for (int i = y; i < y + 2; i++){
		for (int j = x; j < x + 4; j++){
			block[i][j] = c;
		}
	}
}
void Longitudinal(int c,int x,int y){
	for (int i = y; i < y + 4; i++){
		for (int j = x; j < x + 2; j++){
			block[i][j] = c;
		}
	}
}
void solve(int xs, int ys, int xg, int yg,int c){

	if (xs<0 || xs>w || ys<0 || ys>h || block[ys][xs] != c) return;
	if (ys == yg && xs == xg) {
		maze = true;
		return;
	}
	block[ys][xs] = -1;

	solve(xs+1, ys, xg, yg, c);
	solve(xs-1, ys, xg, yg, c);
	solve(xs, ys+1, xg, yg, c);
	solve(xs, ys-1, xg, yg, c);

	return;
}

// block[xx][xx]???-1?????£?????´??? return;
// block[xx][xx]??????????????§????????´??? return;
// block[xx][xx]?????´???????????£?????´??????true AND re:start

int main(){
	int xs, ys;
	int xg, yg;
	int n;
	int c, d, x, y;
	while (cin >> w >> h, w, h){
		Lnitialization(w, h);
		cin >> xs >> ys;
		cin >> xg >> yg;
		cin >> n;
		for (int i = 0; i < n; i++){
			cin >> c >> d >> x >> y;
			if (d == 0) Side(c, x, y);
			else if (d == 1) Longitudinal(c, x, y);
		}
		c = block[ys][xs];
		solve(xs, ys, xg, yg, c);
		if (maze) cout << "OK" << endl;
		else cout << "NG" << endl;
		maze = false;
 	}
	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define rep(i, n) rep2(i, 0, n)
using ll = long long;
using V = vector<int>;
using Vll = vector<ll>;
using VV = vector<V>;
using VVll = vector<Vll>;

char s[1000000];

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

  VVll t(3, Vll(n+1));
  VV pos(3, V());
  string dmc = "DMC";

  rep(i, n) rep(j, 3) {
    t[j][i+1] = t[j][i];
    if (s[i] == dmc[j]) {
      ++t[j][i+1];
      pos[j].push_back(i);
    }
  }

  rep(_, q) {
    int k; 
    scanf("%d", &k);
    ll ans = 0;
    for (auto c : pos[2]) ans += t[1][c] * (t[0][c] - t[0][max(c-k+1, 0)]);
    for (auto a : pos[0]) ans -= t[1][a+1] * (t[2][min(a+k, n)] - t[2][a+1]);
    printf("%lld\n", ans);
  }
  return 0;
}


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

#define EB emplace_back
#define int long long
#define F first
#define S second
#define N 100005
#define ALL(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)


using namespace std;


int32_t main()
{
    IOS;

    int tt=1;
    //cin>>tt;
    while(tt--)
    {
		int n; cin>>n;
		map<int,int> mp;
		for (int i = 0; i < n; i++)
		{
			int temp; cin>>temp;
			mp[temp] = i + 1;
		}
		for(auto x : mp) cout<<x.S<<" ";
		cout<<endl;
    }
    return 0;

}


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

int main(){
  char b;
  cin >> b;
  if(b=='A') cout << 'T' << endl;
  if(b=='C') cout << 'G' << endl;
  if(b=='G') cout << 'C' << endl;
  if(b=='T') cout << 'A' << endl;
}

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

using namespace std;

#define ll long long
#define ar array
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))

int n, k, tmp;
string s;


bool compare(const pair<int, bool> &p1, const pair<int, bool> &p2){
    return p1.first > p2.first;
}


void solve(){
    cin >> s;
   
    int cur  = 0;
    int max = 0;
    for (char c : s)
    {
        if(c == 'R'){
            cur++;
        } 
        else
        {
            if(cur > max) max = cur;
            cur = 0;

        }
        
    }
    if(cur > max) max = cur;
    cout << max;
}





int main(){

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

    solve();

}

Measured memory_bytes: 3648
#include <stdio.h>
int main(void)
{
    int max,min,j,i,*p,n;
    long long sum=0;
    scanf("%d",&n);
    int a[n];
    p=a;

    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        sum=sum+a[i];
    }
    i=0;
        max=i; min=i;
        for(j=i+1;j<n;j++)
            {if(*(p+j)>*(p+max))
                max=j;
            if(*(p+j)<*(p+min))
                min=j;
            }
    printf("%d %d %lld\n",a[min],a[max],sum);
    return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rrep(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
typedef long long ll;

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll a,b; cin >> a >> b;
  cout << (a*b)/__gcd(a,b) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int a,i,t;
int main(void){
  scanf("%d",&a);
  int s[a];
  for(i=0;i<a;i++){
    s[i]=i+1;
  }
  for(i=0;i<a;i++){
    s[i]=log10(s[i]);
  }
  for(i=0;i<a;i++){
    if(s[i]%2==0){
      t=t+1;
    }
  }
  printf("%d",t);
  return 0;
}

Measured memory_bytes: 2860
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) puts("error")
    #define rep(i,l,r) for(int i=(l);i<=(r);i++)
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    inline int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> inline void add(T &x,const T y){x=mm(x+y);}
    inline ll qpower(ll x,ll e)
    {
        ll ans=1;GG(e<0);
        while(e){if(e&1)ans=ans*x%MOD;x=x*x%MOD;e>>=1;}return ans;
    }
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e6+10;

    bool nop[N];int mu[N],pp=0,prn[N];
    void pre()
    {
        mu[1]=1;
        for(int i=2;i<N;i++)
        {
            if(!nop[i]) mu[i]=MOD-1,prn[++pp]=i;
            for(int j=1;j<=pp and (ll)prn[j]*i<N;j++)
            {
                int t=prn[j]*i;nop[t]=1;mu[t]=MOD-mu[i];
                if(i%prn[j]==0){mu[t]=0;break;}
            }
        }
    }
    ll sm[N];int a[N];
    void main()
    {
        pre();
        int n=qread();for(int i=1;i<=n;i++) a[i]=qread(),(sm[a[i]]+=a[i])%=MOD;
        for(int i=1;i<N;i++) for(int j=i+i;j<N;j+=i) add(sm[i],sm[j]);
        ll ans=0;
        for(int D=1;D<N;D++) {ll sum=0;for(int d=1;d*D<N;d++) add(sum, mu[d]*sm[D*d]%MOD*sm[D*d]%MOD );add(ans,sum*invm(D)%MOD);}
        for(int i=1;i<=n;i++) add(ans,1ll*MOD-a[i]);
        write(ans*invm(2)%MOD);
    }
};//(ans+MOD)%MOD
int main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define LL long long

int n;
int A[200005];
int C[200005];

int main(){
	
	scanf("%d",&n);
	for ( int i = 1; i <= n; i++ ){
		scanf("%d",&A[i]);
		C[A[i]]++;
	}
	
	LL ans = 0;
	for ( int i = 1; i <= n; i++ ){
		ans += C[i] * 1LL * (C[i]-1) / 2;
	}
	
	for ( int i = 1; i <= n; i++ ){
		LL tmp = ans - C[A[i]] * 1LL * (C[A[i]]-1) / 2;
		tmp += (C[A[i]]-1) * 1LL * (C[A[i]]-2) / 2;
		printf("%lld\n",tmp);
	}
	return 0;
}


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

 using namespace std;
 int main() {
   int A1, A2, A3;
   cin >> A1 >> A2 >> A3;
   cout << abs(A1 - A2) + abs(A2 - A3) + abs(A3 - A1) - max(abs(A1 - A2), max(abs(A2 - A3), abs(A3 - A1))) << endl;
 }


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

int main()
{
	int nA, nB;
	int nRo = 0, nArea = 0;
	
	while (cin >> nA >> nB)
	{
		nRo = (nA + nB) * 2;
		nArea = nA*nB;
		cout << nArea << " " << nRo << endl;
	}

	/*system("pause");*/
	return 0;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) { cin >> v[i]; }

  map<ll, ll> mp;
  for (int i = 0; i < v.size(); i++) {
    mp[v[i]]++;
  }

  ll sowa = 0;
  for (auto x : mp) {
    sowa += x.second * (x.second - 1) / 2;
  }

  for (int i = 0; i < n; i++) {
    cout << sowa - (mp[v[i]] - 1) << endl;
  }
}


Measured memory_bytes: 10240
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll a[114514], b[114514], c[114514], d[114514];
int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n);
	for (int i = 0; i < n; i++) cin >> b[i]; sort(b, b + n);
	for (int i = 0; i < n; i++) cin >> c[i]; sort(c, c + n);
	int f = 0;
	for (int i = 0; i < n; i++) {
		while (f < n&&c[f] <= b[i])f++;
		d[i] = n - f;
	}
	for (int i = n - 1; i >= 0; i--) 
		d[i] += d[i + 1];
	ll ans = 0; f = 0;
	for (int i = 0; i < n; i++) {
		while (f < n&&b[f] <= a[i])f++;
		ans += d[f];
	}
	cout << ans << endl;
	return 0;
}

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

using ll = long long ;

int main()
{
    string s;
    cin>>s;
    map<ll,ll>mp;
    mp[0]=1;
    reverse(s.begin(),s.end());
    ll now=0,ten=1;
    for(int i=0;i<s.size();i++)
    {
        now=(now+(s[i]-'0')*ten)%2019;
        ten*=10;
        ten%=2019;
        mp[now]++;
    }
    ll ans=0;
    for(auto &e:mp)
    {
        ans+=(e.second*(e.second-1))/2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3756
N = int(input())
H = list(map(int, input().split()))

ans = 0
temp = 0
for i in range(N - 1):
    if H[i] >= H[i + 1]:
        temp += 1
    else:
        ans = max(ans, temp)
        temp = 0

ans = max(ans, temp)

print(ans)

Measured memory_bytes: 14252
#coding:utf-8
import bisect,sys
A,B,Q=map(int,raw_input().split())
s=[0]*A
t=[0]*B
for i in range(A):    
    s[i]=int(sys.stdin.readline())
for i in range(B):
    t[i]=int(sys.stdin.readline())
buf=[]
def f(x):
    sl=bisect.bisect_left(s,x)-1
    sr=sl+1
    tl=bisect.bisect_left(t,x)-1
    tr=tl+1
    ans=float("inf")
    if sl!=-1 and tl!=-1:
        A=max(s[sl],t[tl])
        B=min(s[sl],t[tl])
        L=abs(x-A)+abs(A-B)
        ans=min(ans,L)
    if sl!=-1 and tr!=len(t):
        L=abs(x-s[sl])*2 + abs(t[tr]-x)        
        ans=min(ans,L)
        ans=min(ans,abs(x-s[sl])+abs(t[tr]-x)*2)
    if tl!=-1 and sr!=len(s):
        ans=min(ans,abs(x-t[tl])*2+abs(s[sr]-x))
        ans=min(ans,abs(x-t[tl])+abs(s[sr]-x)*2)
    if tr!=len(t) and sr!=len(s):
        A=min(s[sr],t[tr])
        B=max(s[sr],t[tr])
        L=abs(A-x)+abs(B-A)
        ans=min(ans,L)
    return str(ans)

I=[0]*Q
for i in xrange(Q):
    I[i]=int(sys.stdin.readline())
r=map(f,I)
print("\n".join(r))
    
    




Measured memory_bytes: 19824
#include <cstdio>
#include <algorithm>
using namespace std;
#define inf (1<<27)
#define rep(i,n)for(int i=0;i<n;i++)
#define min(a,b) ((a)<=(b)?(a):(b))
int n,k,a,b,c,d,e;
int cost[100][100];
int main() {
	while(scanf("%d %d",&n,&k),n) {
		fill(cost[0],cost[0]+100*100,inf);
		rep(i,k) {
			scanf("%d",&a);
			if(a==1) {
				scanf("%d %d %d",&c,&d,&e);
				c--;d--;
				if(cost[c][d]<e)continue;
				cost[c][d]=cost[d][c]=e;
				rep(k,n)rep(i,n)rep(j,n) {
					cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
				}
			}else {
				scanf("%d %d",&a,&b);
				a--;b--;
				if(cost[a][b]<inf)printf("%d\n",cost[a][b]);
				else printf("-1\n");
			}
		}
	}
}

Measured memory_bytes: 1076
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
const int N=1e6+3;
vector<bool> isp(N);
vector<int> p;
int pp[N];
constexpr int mod=1e9+7;
int modp(int a,int b)
{
	if(b==0)return 1;
	int u=modp(a,b/2);
	u=(u*u)%mod;
	if(b&1)return (a*u)%mod;
	return u;
}
void sie()
{
	fill(all(isp),1);
	isp[0]=isp[1]=0;
	for(int i=2;i<N;i++)
	{
		if(isp[i])
		{
			for(int j=i*i;j<N;j+=i)isp[j]=0;
		}
	}
	for(int i=2;i<N;i++)
	{
		if(isp[i])p.push_back(i);
	}
}
int32_t main()
{
	int n=in();
	int x;sie();
	vector<int> a(n);
	for(int i=0;i<n;i++)
	{
		
		a[i]=in();x=a[i];
		int cur=0;
		while(x%2==0){x/=2;cur++;}
		pp[2]=max(pp[2],cur);
		
		for(int i=3;i<=sqrt(x);i+=2)
		{
			cur=0;
			while(x%i==0){x/=i;cur++;}
			pp[i]=max(pp[i],cur);
		}
		if(x>2){pp[x]=max(pp[x],1LL);}
	}
	
	int lc=1;
	for(auto i:p)
	{
		lc=(lc*modp(i,pp[i]))%mod;
	}
	
	
	int ans=0;
	for(int i=0;i<n;i++)
	{
		ans+=(modp(a[i],mod-2)*lc)%mod;
		ans%=mod;
	}
	cout<<ans;
	
	
	
	
	
	
	
	
	
}

Measured memory_bytes: 7820
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	string s;
	cin >> n >> s;

	int res = 0;
	for (int i = 0; i < n - 1; i++)
	{
		int cnt = 0;
		for (int j = 0; j < 26; j++)
		{
			char ch = 'a' + j;
			bool x = false, y = false;
			for (int k = 0; k < n; k++)
			{
				if(s[k] == ch) {
					if(k <= i) x = true;
					else y = true;
				}
			}
			if(x && y) cnt++;
		}
		res = max(res, cnt);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll ar1[2000000];
int main()
{
    ll test,n,k,i;
    cin>>n;
    if(n==22)cout<<"Christmas Eve Eve Eve"<<endl;
    else if(n==23)cout<<"Christmas Eve Eve"<<endl;
    else if(n==24)cout<<"Christmas Eve"<<endl;
    else if(n==25)cout<<"Christmas"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <iomanip>
#include <cstdlib>
#include <climits>
using namespace std;

//関数getinputdata宣言
vector<vector<string>> getinputdata();
vector<vector<int>> getinputdata2();
vector<vector<double>> getinputdata3();

void yahoo_procon2019_qual_a(vector<vector<int>> v) {

    int n = v[0][0];
    int k = v[0][1];

    int cnt=n % 2==0 ? n /2 : (n/2)+1;
    
    cout << (cnt>=k ? "YES" : "NO") << endl;
    


}

int main() {

    //    vector<vector < string>> vec_arr_result;
    vector<vector<int>> vec_arr_result;
    vec_arr_result = getinputdata2();

    yahoo_procon2019_qual_a(vec_arr_result);

    return 0;
}

//関数getinputdata実装

vector<vector<double>> getinputdata3() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector<double>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<double> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(atof(ret.c_str()));
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;
}

//関数getinputdata実装

vector<vector<int>> getinputdata2() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector<int>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<int> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(atoi(ret.c_str()));
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;


}

//関数getinputdata実装

vector<vector < string >> getinputdata() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector < string>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<string> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(ret);
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;

}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 順列のループは https://maku77.github.io/java/numstr/permutation.html を参考
 */
public class Main {

	/** 数字の数 */
	private static final int N = 3;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int[] a = IntStream.range(0, N).map(i -> scanner.nextInt()).toArray();
			System.out.println(permutation(a));
		}
	}

	/**
	 * 与えられた配列で順列のループを実施する
	 * 
	 * @param seed 順列のもととなる配列
	 */
	private static int permutation(int[] seed) {
		int[] perm = new int[seed.length];
		boolean[] used = new boolean[seed.length];
		return buildPerm(seed, perm, used, 0);
	}

	/**
	 * 与えられた配列で順列のループを実施し、最小値を計算する
	 * 
	 * @param seed  順列のもととなる配列
	 * @param perm  作成された順列
	 * @param used  個々の要素が使用したかどうかを記録用配列
	 * @param index 現在処理しているインデックス
	 */
	private static int buildPerm(int[] seed, int[] perm, boolean[] used, int index) {
		if (seed.length == index) {
			return procPerm(perm);
		}

		int min = Integer.MAX_VALUE;
		for (int i = 0; i < seed.length; ++i) {
			if (!used[i]) {
				perm[index] = seed[i];
				used[i] = true;
				min = Math.min(min, buildPerm(seed, perm, used, index + 1));
				used[i] = false;
			}
		}
		return min;
	}

	/**
	 * できた順列に対して、コストを計算する
	 * 
	 * @param perm 順列
	 * @return コスト
	 */
	private static int procPerm(int[] perm) {
		return IntStream.range(1, perm.length).map(i -> Math.abs(perm[i] - perm[i - 1])).sum();
	}
}


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

int A[110];

int main(void)
{
    int N;
    int idx = 0;
    int ab, abmax=0;

    cin >> N;
    
    for(int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    for(int i = 0; i < N; i++)
    {
        for(int j = i + 1; j < N; j++)
        {
            ab = abs(A[j] - A[i]);        
            if(ab > abmax) abmax = ab;
        }
    }

    cout << abmax << endl;
    return 0;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int,input().split())
P = list(map(int,input().split()))
uf = UnionFind(N+1)
for i in range(M):
    a, b = map(int,input().split())
    uf.union(a,b)
ans = 0
for i in range(1,N+1):
    if uf.same(i,P[i-1]):
        ans += 1
print(ans)

Measured memory_bytes: 13940
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
template<typename T> T ctmax(T &x, const T &y){ return x = max(x, y); }
template<typename T> T ctmin(T &x, const T &y){ return x = min(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int k, n;
	cin >> k >> n;
	vector<int> a(n);
	copy_n(istream_iterator<int>(cin), n, a.begin());
	sort(a.begin(), a.end());
	int res = a[0] - a.back() + k;
	for(int i = 1; i < n; ++ i){
		ctmax(res, a[i] - a[i - 1]);
	}
	cout << k - res;
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n-1; i >= 0; --i)

const int MAX = 2e5;

int parent[MAX];
int rankb[MAX];
 
void init(int x) {
    for(int i = 0; i <= x; i++)
    parent[i] = i,rankb[i] = 0;
}
 
int root(int x) {
    return (parent[x]==x) ? x : parent[x]=root(parent[x]);
}
 
bool same(int x, int y) {
    return root(x) == root(y);
}
 
void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;

    if (rankb[x] < rankb[y])
        parent[x] = y;
    else {
        parent[y] = x;
        if (rankb[x] == rankb[y]) rankb[x]++;
    }
}

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

    init(N);
    REP (i, M) {
        int x, y, z;
        cin >> x >> y >> z; x--; y--;
        unite(x, y);
    }

    int ans = 0;
    REP (i, N) if (root(i) == i) {
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {

		try {
			InputStreamReader isr = new InputStreamReader(System.in);
			BufferedReader br = new BufferedReader(isr);
			String buf = br.readLine();
			int n = Integer.parseInt(buf);
			buf = br.readLine();
			StringTokenizer st = new StringTokenizer(buf, " ");
			int[] a = new int[n];

			for(int i=0;i<n;i++){

				a[i]=Integer.parseInt(st.nextToken());
			}

			for(int i=n-1;i>=0;i--){
				System.out.print(a[i]);
				if(i!=0)	System.out.print(" ");
				else	System.out.println();
			}
		} catch (IOException e) {
			System.err.println(e);
		}
	}

}

Measured memory_bytes: 16944
# d = list(map(int, input().split()))
n = int(input())
a = input().split()
even = []
even_counter = 0
div = 0
 
for i in a:
  int_a = int(i)
  if int_a % 2 == 0:
    even.append(int_a)
    even_counter += 1
 
for i in range(even_counter):
  if int(even[i]) % 3 == 0 or int(even[i]) % 5 == 0:
    div += 1
 
if div == even_counter:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
#include<set>
#include<vector>
#define int long long int
#define inf 1000000000000000
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int h,w,k;
    cin>>h>>w>>k;
    char mat[h][w];
    int i,j;
    for(i=0;i<h;i++)
    {
		for(j=0;j<w;j++)
		{
			cin>>mat[i][j];
		}
	}
	int count[h]={0};
	for(i=0;i<h;i++)
    {
		int val=0;
		for(j=0;j<w;j++)
		{
			if(mat[i][j]=='#')
			   val++;
		}
		count[i]=val;
	}
	int answer[h][w];
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			answer[i][j]=-1;
		}
	}
	int curr=1;
	int first,last;
	for(i=0;i<h;i++)
	{
		if(count[i]!=0)
		{
			first=i;
			break;
		}
	}
	for(i=0;i<h;i++)
	{
		if(count[i]!=0)
		{
			last=i;
		}
	}
	i=first;
	for(j=0;j<w;j++)
	{
		if(mat[i][j]=='#')
		  break;
		else
		{
			answer[i][j]=curr;
		}
	}
	answer[i][j]=curr;
	j++;
	while(j<w)
	{
		if(mat[i][j]=='#')
		{
			curr++;
		}
		answer[i][j]=curr;
		j++;
	}
	curr++;
	i=first;
	if(first==last)
	{
		for(i=first-1;i>=0;i--)
		{
			for(j=0;j<w;j++)
			{
				answer[i][j]=answer[i+1][j];
			}
		}
		for(i=first+1;i<h;i++)
		{
			for(j=0;j<w;j++)
			{
				answer[i][j]=answer[i-1][j];
			}
		}
	}
	else
	{
	    for(i=first-1;i>=0;i--)
		{
			for(j=0;j<w;j++)
			{
				answer[i][j]=answer[i+1][j];
			}
		}
		for(i=first+1;i<h;i++)
		{
			if(count[i]==0)
			{
				for(j=0;j<w;j++)
				   answer[i][j]=answer[i-1][j];
			}
			else
			{
				for(j=0;j<w;j++)
			    {
					if(mat[i][j]=='#')
					   break;
					else
					  answer[i][j]=curr;
				}
				answer[i][j]=curr;
				j++;
				while(j<w)
				{
					if(mat[i][j]=='#')
					   curr++;
					 answer[i][j]=curr;
					 j++;
				}
				curr++;
			}
		}
	}
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			cout<<answer[i][j]<<" ";
		}
		cout<<endl;
	}
}



Measured memory_bytes: 1536