akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using Int = int64_t;
const Int INF = 1<<30;
const Int MOD = (Int)1e9 + 7;
const Int MAX_N = (Int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }


bool dfs(vector<int> v, int k)
{
    if(k < 0) return false;
    bool ok = true;
    for(int i = 0; i < 2; i++)
    {
        if(v[i] >= v[i + 1]) ok = false;
    }
    if(ok) return true;
    bool res = false;
    for(int i = 0; i < v.size(); i++)
    {
        vector<int> tmp = v;
        tmp[i] *= 2;
        res |= dfs(tmp, k - 1);
    }
    return res;
}

void solve()
{
    vector<int> v(3);
    for(int i = 0; i < 3; i++) cin >> v[i];
    int k; cin >> k;
    cout << (dfs(v, k) ? "Yes" : "No") << endl;
}

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

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<map>
#include<queue>
#define sqr(x) (x)*(x)
#define fz1(i,n) for (i=1;i<=n;i++)
#define fd1(i,n) for (i=n;i>=1;i--)
#define fz0g(i,n) for (i=0;i<=n;i++)
#define fd0g(i,n) for (i=n;i>=0;i--)
#define fz0k(i,n) for (i=0;i<n;i++)
#define fd0k(i,n) for (i=(long long)(n-1);i>=0;i--)
#define fz(i,x,y) for (i=x;i<=y;i++)
#define fd(i,y,x) for (i=y;i>=x;i--)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len) {char ss[len];scanf("%s",ss);(st)=ss;}
using namespace std;
int n,m,i,j,cnt,dis[1100005],vis[100005],x,y,z;
map<int,vector<int> > bi[100005];
vector<int> all[1000005],bi2[1100005];
queue<int> qx;
void dfs(int x,int col)
{
	if (vis[x]==col) return;
	vis[x]=col;
	bi2[x].push_back(cnt);
	bi2[cnt].push_back(x);
	ff(bi[x][col],it) dfs(*it,col);
}
int main()
{
	cin>>n>>m;
	cnt=n;
	for (i=1;i<=m;i++)
	{
		cin>>x>>y>>z;
		bi[x][z].push_back(y);
		bi[y][z].push_back(x);
		all[z].push_back(y);
		all[z].push_back(x);
	}
	fz1(i,1000000)
	{
		sort(all[i].begin(),all[i].end());
		all[i].resize(unique(all[i].begin(),all[i].end())-all[i].begin());
		ff(all[i],it)
		{
			if (vis[*it]==i) continue;
			cnt++;
			dfs(*it,i);
		}
	}
/*	fz1(i,cnt)
	{
		cerr<<i<<':';
		ff(bi2[i],it) cerr<<*it<<' ';
		cerr<<endl;
	}*/
	memset(dis,22,sizeof(dis));
	qx.push(1);
	dis[1]=0;
	while (!qx.empty())
	{
		int x=qx.front();qx.pop();
		ff(bi2[x],it)
		{
			if (dis[*it]>dis[x]+1)
			{
				dis[*it]=dis[x]+1;
				qx.push(*it);
			}
		}
	}
	if (dis[n]>=0x16161616) cout<<-1<<endl; else cout<<dis[n]/2<<endl;
	return 0;
}

Measured memory_bytes: 118656
def solve(n, nums):
    sorted_nums = sorted(nums)
    low = sorted_nums[n/2 - 1]
    high = sorted_nums[n/2]

    for i in xrange(n):
        if nums[i] <= low:
            print high
        else:
            print low
    return


n = int(raw_input())
nums = map(int, raw_input().split())
solve(n, nums)


Measured memory_bytes: 20060
#include<bits/stdc++.h>
using namespace std;
#define NIL -1
int n,D[1000001];
struct node {int p,l,r;};
node tree[1000001];

void print(int u){
  int i,c;
  cout<<"node "<<u<<": ";
  cout<<"parent = "<<tree[u].p<<", ";
  cout<<"depth = "<<D[u]<<", ";
  if(tree[u].p==NIL) cout<<"root, ";
  else if(tree[u].l==NIL) cout<<"leaf, ";
  else cout<<"internal node, ";
  cout<<"[";
  for(int i=0,c=tree[u].l;c!=NIL;i++,c=tree[c].r){
    if(i) cout<<", ";
    cout<<c;
  }
  cout<<"]"<<endl;
}

int setdepth(int u,int p){
  D[u]=p;
  if(tree[u].r!=NIL)
    setdepth(tree[u].r,p);
  if(tree[u].l!=NIL)
    setdepth(tree[u].l,p+1);
}
  int main(){
    int d,v,c,l,r;
    cin>>n;
    for(int i=0;i<n;i++) tree[i].p=tree[i].l=tree[i].r=NIL;

    for(int i=0;i<n;i++){
      cin>>v>>d;
      for(int j=0;j<d;j++){
	cin>>c;
	if(j==0) tree[v].l=c;
	else tree[l].r=c;
	l=c;
	tree[c].p=v;
      }
    }
    for(int i=0;i<n;i++){
      if(tree[i].p==NIL) r=i;
    }
    setdepth(r,0);
    for(int i=0;i<n;i++){
      print(i);
    }
    return 0;
  }

Measured memory_bytes: 7744
// Ala be zekrellah tatmaenolgholoob ...
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define F first
#define S second
#define MP make_pair
const int maxn = 1e5+9;
const ll mod = 1e9+7;

vector <int> g[maxn];
int grundy[maxn];

void dfs (int v, int parent = -1) {
	int num = 0;
	for (auto u : g[v]) {
		if (u == parent)
			continue;
		dfs(u, v);
		grundy[v] ^= grundy[u] + 1;
	}
}

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int v, u;
		cin >> v >> u;
		--v; --u;
		g[v].push_back(u);
		g[u].push_back(v);
		}
	dfs(0);
	if (grundy[0])
		cout << "Alice\n";
	else
		cout << "Bob\n";
}



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

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

    int n, k;
    cin >> n >> k;
    vector<int> as(n);
    for (int i = 0; i < n; i++) cin >> as[i];

    double l = 1e-9, r = 1e9;
    for (int i = 0; i < 200; i++) {
        double m = sqrt(l * r);
        double cnt = 0;
        for (int j = 0; j < n; j++) {
            cnt += floor(as[j] / m);
        }
        if (cnt <= k) {
            r = m;
        } else {
            l = m;
        }
    }
    // cout << setprecision(20) << l << endl;
    cout << (int)(ceil(l)) << endl;
}


Measured memory_bytes: 3984
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,S[100000],q,T[50000],c=0,i,i2,toread,cnt;
	cin>>n;
	for(i=0;i<n;i++)cin>>S[i];
	cin>>q;
	for(i=0;i<q;i++)cin>>T[i];
	/*for(i=0;i<n;i++){
		for(i2=0;i2<n;i2++){
			if(S[i]<S[i2]){
				toread=S[i];
				S[i]=S[i2];
				S[i2]=toread;
			}
		}
	}*/
	sort(S,S+n);
	for(i=0;i<q;i++){
		cnt=0;
		toread=n;
		while(toread>1){
			if(toread%2==0)toread/=2;
			else toread=(toread+1)/2;
			if(S[(toread-1)+cnt]<T[i])cnt+=toread;
			else if(S[(toread-1)+cnt]==T[i]){
				c++;
				break;
			}
		}
	}
	cout<<c<<endl;
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned int ui;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
#define All(v) (v).begin(),(v).end()
#define Rep(i,n) for(int i = 0; i < (int)n; i++)
#define Reps(i,n) for(int i = 1; i <= (int)n; i++)
#define For(i,m,n) for(int i = m; i < n; i++)
#define Fors(i,m,n) for(int i = m; i <= n; i++)
#define inf 2e9
#define f first
#define s second
#define pb push_back
#define mp make_pair
struct speed{speed(){cin.tie(); ios::sync_with_stdio(false); cout << fixed << setprecision(18);}}speed;

int dy[] = {0,0,1,-1};
int dx[] = {1,-1,0,0};

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

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


int main (){
    ll n,m;
    cin >> n >> m;
    if(n >= 2 && m >= 2){
        cout << (n-2)*(m-2) << endl;
    }else if(max(n,m) >= 2){
        cout << max(n,m)-2 << endl;
    }else{
        cout << 1 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main(void) {

    long long x;
    cin >> x;

    long long total = x / 11 * 2, r = x % 11;

    if (r > 6)
        total += 2;
    else if (r > 0)
        total += 1;

    cout << total << endl;

    return 0;
}

Measured memory_bytes: 256
from fractions import gcd
N, *A, = map(int, open(0).read().split())
l = [0]*N
r = [0]*N

# [0,i]のgcd
l[0] = A[0]
for i in range(1, N):
    l[i] = gcd(l[i-1],A[i])

# [i,N-1]のgcd
r[N-1] = A[N-1]
for i in range(N-1)[::-1]:
    r[i] = gcd(r[i+1],A[i])

m = [0]*N
for i in range(1, N-1):
    m[i] = gcd(l[i-1], r[i+1])
m[0] = r[1]
m[N-1] = l[N-2]
print(max(m))

Measured memory_bytes: 16144
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
const int INF = (int)1e9;
int e_num = 1, S, T;
int hed[maxn], dep[maxn];

struct Edge {
  int from, to, nxt, c;
} edge[maxn * 4];

void addedge(int from, int to, int c) {
  edge[++e_num] = (Edge){from, to, hed[from], c};
  hed[from] = e_num;
}

void adde(int from, int to, int c) {
  addedge(from, to, c);
  addedge(to, from, 0);
}

int que[maxn + 5], head = 0, tail = 0;
bool bfs() {
  head = tail = 0;
  que[tail++] = S;
  memset(dep, 0, sizeof(dep));
  dep[S] = 1;
  while (head != tail) {
    int cur = que[head++]; head %= maxn;
    for (int i = hed[cur]; i; i = edge[i].nxt) {
      int to = edge[i].to;
      if (!dep[to] && edge[i].c) {
        dep[to] = dep[cur] + 1;
        que[tail++] = to; tail %= maxn;
      }
    }
  }
  return dep[T];
}

int dfs(int x, int flow) {
  if (x == T) return flow;
  int ret = 0;
  for (int i = hed[x]; i; i = edge[i].nxt) {
    int to = edge[i].to;
    if (dep[to] == dep[x] + 1 && edge[i].c) {
      int tmp = dfs(to, std::min(flow, edge[i].c));
      edge[i].c -= tmp;
      edge[i ^ 1].c += tmp;
      flow -= tmp;
      ret += tmp;
      if (!flow) {
        break;
      }
    }
  }
  if (!ret) dep[x] = 0;
  return ret;
}

int dinic() {
  int ret = 0;
  while (bfs()) {
    ret += dfs(S, INF);
  }
  return ret;
}

const int N = 103;
int n, m, a[N][N], x[N][N], y[N][N], row1[N * N], row2[N * N], ban[N * N], id[N * N];

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%d", &a[i][j]);
      row1[a[i][j]] = i;
      row2[m * (i - 1) + j] = i;
    }
  }
  S = 0, T = n * 2 + 1;
  for (int c = 1; c <= m; c++) {
    for (int i = 0; i <= T; i++) hed[i] = 0;
    e_num = 1;
    for (int i = 1; i <= n; i++) {
      adde(S, i, 1);
      adde(i + n, T, 1);
    }
    for (int i = 1; i <= n * m; i++) {
      if (!ban[i]) {
        adde(row1[i], row2[i] + n, 1);
        id[i] = e_num - 1;
      }
    }
    dinic();
    for (int i = 1; i <= n * m; i++) {
      if (!ban[i] && !edge[id[i]].c) {
        ban[i] = 1;
        x[row1[i]][c] = i;
        y[row2[i]][c] = i;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      printf("%d ", x[i][j]);
    }
    puts("");
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      printf("%d ", y[i][j]);
    }
    puts("");
  }
  return 0;
}


Measured memory_bytes: 1280
$n=<>;
@s=glob<>;@t=glob<>;
$S[$_]=$s[$_-1]+$S[$_-1] for(1..$n);
$T[$n-$_]=$t[$n-$_]+$T[$n-$_+1] for(1..$n);
$m=$m>($a=$S[$_+1]+$T[$_])?$m:$a for(0..$n);
print$m

Measured memory_bytes: 768
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

using ll = long long;
using P = pair<int, int>;

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; }

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

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

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

int main() {
    int n;
    cin >> n;
    vector<double> p(n);
    cin >> p;
    
    vector<vector<double>> dp(n + 1, vector<double>(n + 1));
    dp[0][0] = 1;
    rep(i, n) rep(x, n) {
        dp[i + 1][x + 1] += dp[i][x] * p[i];
        dp[i + 1][x] += dp[i][x] * (1 - p[i]);
    }
    
    double ans = 0;
    repr(x, (n + 1) / 2, n + 1) ans += dp[n][x];
    printf("%.15lf\n", ans);
}

Measured memory_bytes: 70656
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
int n,m;
int x[100010];
queue<pair<int,int> >Q[100010];
queue<int> T;
int main(){
  cin>>n>>m;
  lol(i,m){
    int a,b,c;cin>>a>>b>>c;
    a--,b--;
    Q[a].push(make_pair(b,c));
    Q[b].push(make_pair(a,-c));
  }
  lol(i,n)x[i]=-mod;
  bool ans=true;
  lol(i,n){
    if(x[i]==-mod)T.push(i);
    else continue;
    x[i]=0;
    while(!T.empty()){
      int a=T.front();
      T.pop();
      while(!Q[a].empty()){
	int to=Q[a].front().first;
	int cost=Q[a].front().second;
	Q[a].pop();
	if(x[to]==-mod){
	  x[to]=x[a]+cost;
	  T.push(to);
	}
	else{
	  if(x[to]!=x[a]+cost)ans=false;
	}
      }
    }
  }
  cout<<(ans?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 69888
use proconio::input;

const MODULO: usize = 1_000_000_007;

fn mod_pow(a: usize, p: usize, modulo: usize) -> usize {
    if p == 0 {
        1
    } else if p % 2 == 0 {
        let x = mod_pow(a, p / 2, modulo);
        x * x % modulo
    } else {
        let x = mod_pow(a, p / 2, modulo);
        a * ((x * x) % modulo) % modulo
    }
}

fn main() {
    input! {
        n: usize,
        k: usize,
    }
    let mut result = 0;
    let mut dp = vec![0; k + 1];
    for i in (1..=k).rev() {
        dp[i] = mod_pow(k / i, n, MODULO);
        for j in 2.. {
            if j * i > k {
                break;
            }
            dp[i] = (MODULO + dp[i] - dp[j * i]) % MODULO;
        }
        result = (result + dp[i] * i) % MODULO;
    }

    println!("{}", result);
}


Measured memory_bytes: 2792
#include<stdio.h>

int main(){

int n,i,j,k,l,sum;

 while(scanf("%d",&n) != EOF)
 {
   sum = 0;
 for(i=0;i<=9;i++)
    {for(j=0;j<=9;j++)
	{for(k=0;k<=9;k++)
	    {for(l=0;l<=9;l++)
		{if(i+j+k+l == n)
		    {sum++;
		    }
		}
	    }
	}
    }
 printf("%d\n",sum);
 }

  return 0;
}

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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define VEC vector

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				Vint;
typedef vector<Vint>			VV;

template<typename T>string join(const v(T)&v)
{stringstream s;REP(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		400010

const ll LINF = (ll)9e18+7;		//
const int INF = 100100100;			//2,147,483,647 (Max int)
const ll MOD = 1e9+7;
// テンプレ終了
//====================================================================//

// int DP[MAX];


//
int main(){
	int m,n;cin >> n >> m;
	v(int) A(n);
	int suml = 0;
	REP(i,n){
		cin>>A[i];
		suml += A[i];
	}

	int cnt=0;
	REP(i,n){
		if(4*m*A[i] >= suml)cnt++;
	}
	
	puts((cnt>=m) ? "Yes" : "No");

	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0 ,sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int prime[N]; 
unordered_map<int, int> max_map;
int power(int x, int y)
{
    if(y==0) return 1;
    else if(y%2==0)
        return power(x*x%MOD,y/2)%MOD;
    else return (x%MOD*power(x*x%MOD,y/2))%MOD;
}
void sieve() 
{ 
    prime[0] = prime[1] = 1; 
    for (int i = 2; i < N; i++) { 
        if (prime[i] == 0) { 
            for (int j = i * 2; j < N; j += i) { 
                if (prime[j] == 0) { 
                    prime[j] = i; 
                } 
            } 
            prime[i] = i; 
        } 
    } 
} 
// Function to return the LCM modulo M 
int lcmModuloM(const int* ar, int n) 
{ 
  
    for (int i = 0; i < n; i++) { 
        int num = ar[i]; 
        unordered_map<int, int> temp; 
  
        // Temp stores mapping of prime factor to 
        // its power for the current element 
        while (num > 1) { 
  
            // Factor is the smallest prime factor of num 
            int factor = prime[num]; 
  
            // Increase count of factor in temp 
            temp[factor]++; 
  
            // Reduce num by its prime factor 
            num /= factor; 
        } 
  
        for (auto it : temp) { 
  
            // Store the highest power of every prime 
            // found till now in a new map max_map 
            max_map[it.first] = max(max_map[it.first], it.second); 
        } 
    } 
  
    int ans = 1; 
  
    for (auto it : max_map) { 
  
        // LCM is product of primes to their highest powers modulo M 
        ans = (ans * power(it.ff, it.ss)) % MOD; 
    } 
  
    return ans; 
} 
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n;
        cin >> n;
        int a[n];
        for(int i = 0; i < n; i++){
            cin >> a[i];
        }
        sieve();
        int ans = lcmModuloM(a, n);
        int sum = 0;
        for(int i = 0; i < n; i++){
            sum = (sum + (ans * power(a[i], MOD - 2)) % MOD) % MOD;
        }
        cout << sum % MOD << '\n';
    } 
}
/*
   a0 * b0 = a1 * b1 = a2 * b2 = a3 * b3 = ....

 */

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

using str = string;
using ss = stringstream;

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

    int a,b;
    cin>>a>>b;

    ss s;
    s<<a<<b;

    int n;
    s>>n;

    int nn=sqrt(n);

    puts(nn*nn==n?"Yes":"No");

    return 0;
}


Measured memory_bytes: 3664
c=input()
r=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
n=0
for i in r:
    if c==i:
        print(r[n+1])
    n+=1

Measured memory_bytes: 2940
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    ArrayList<Integer> ar = new ArrayList<Integer>();
    int A = sc.nextInt();
    int B = sc.nextInt();
    int K = sc.nextInt();
    int diff = B - A;
    if(diff + 1 > K){
      for(int i=0;i<K;i++){
        ar.add(A + i);
        ar.add(B - i);
      }
      Collections.sort(ar);
      ArrayList<Integer> li = new ArrayList<Integer>(new LinkedHashSet<>(ar));
      for(int i=0;i<li.size();i++){
        System.out.println(li.get(i));
      }
    }else{
      for(int i=A;i<=B;i++){
        System.out.println(i);
      }
    }
  }
}


Measured memory_bytes: 22864
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s1,s2;
    long long n,i,j,k,l,flag;
    vector<long long>vc(30,0);
    cin>>s1;
    flag=0;

    for(i=0;i<s1.size();i++)
    {
        k=s1[i]-'a'+1;
        if(vc[k]==0)
        {
            vc[k]++;
            flag=0;
        }
        else if(vc[k]==1)
        {
            flag=1;
            break;
        }
    }
    if(flag==0)
    {
        cout<<"yes"<<endl;
    }
    else if(flag==1)
    {
        cout<<"no"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int bit[200001], n;
 
int sum(int i){
	int s=0;
	while(i>0){
		s+=bit[i];
		i-=(i&(-i));
	}
	return s;
}
 
void add(int i, int x){
	while(i<=n){
		bit[i]+=x;
		i+=(i&(-i));
	}
}

int main()
{
	string s;
	cin>>s;
	n=s.size();
	vector<int> v[26];
	for(int i=1; i<=n; i++){
		v[s[i-1]-'a'].push_back(i);
	}
	int odd=-1;
	for(int i=0; i<26; i++){
		if(odd>=0 && (v[i].size())%2==1){
			printf("%d\n", -1);
			return 0;
		}
		if((v[i].size())%2==1) odd=i;
	}
	vector<int> a;
	for(int i=0; i<26; i++){
		int m=v[i].size();
		if(m==0) continue;
		for(int j=0; j<m/2; j++){
			a.push_back(v[i][j]);
		}
		reverse(v[i].begin()+(m+1)/2, v[i].end());
	}
	sort(a.begin(), a.end());
	string s2;
	for(auto x:a){
		s2+=s[x-1];
	}
	reverse(s2.begin(), s2.end());
	if(odd>=0){
		int m=v[odd].size();
		a.push_back(v[odd][m/2]);
	}
	for(auto c:s2){
		int x=v[c-'a'].back();
		v[c-'a'].pop_back();
		a.push_back(x);
	}

	ll ans=0;
	for(int i=1; i<=n; i++){
		ans+=(ll)(i-1-sum(a[i-1]));
		add(a[i-1], 1);
	}
	printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3832
#include <stdio.h>

int main(void)
{
    int h1, h2;
    int k1, k2;
    int a, b, c, d;
    int hiroshi, kenjiro;

    scanf("%d%d%d%d%d%d%d%d", &h1, &h2, &k1, &k2, &a, &b, &c, &d);
    
    hiroshi = h1 * a + (h1 / 10) * c + h2 * b + (h2 / 20) * d;
    kenjiro = k1 * a + (k1 / 10) * c + k2 * b + (k2 / 20) * d;
    
    if (hiroshi > kenjiro){
        printf("hiroshi\n");
    }
    else if (hiroshi < kenjiro){
        printf("kenjiro\n");
    }
    else {
        printf("even\n");
    }
    
    return (0);
}



Measured memory_bytes: 2104
houses = [[[0]*10 for f in range(3)] for b in range(4)]

n = int(input())
for _ in range(n):
  b, f, r, v = [int(i) for i in input().split()]
  houses[b-1][f-1][r-1] += v

for b in range(4):
  for f in range(3):
    print(" " + " ".join([str(v) for v in houses[b][f]]))
  if b<3:
    print("#"*20)


Measured memory_bytes: 5608
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace contest11
{
    class Program
    {
        static void Main(string[] args)
        {
            string read = Console.ReadLine();

            int vertical_num = int.Parse(read);

            //縦線
            int[] vert_array = new int[vertical_num];
            for (int i = 0; i < vertical_num; i++)
            {
                vert_array[i] = i + 1;
            }

            //横線の数
            read = Console.ReadLine();
            int hori_num = int.Parse(read);

            for (int i = 0; i < hori_num; i++)
            {
                string read_line = Console.ReadLine();
                char[] text_split = ",".ToCharArray();
                string[] chang = read_line.Split(text_split);

                //入れ替える
                int tmp = vert_array[int.Parse(chang[0])-1];
                vert_array[int.Parse(chang[0]) - 1] = vert_array[int.Parse(chang[1]) - 1];
                vert_array[int.Parse(chang[1]) - 1] = tmp;

            }

            foreach (int num in vert_array)
            {
                Console.WriteLine(num);
            }
        }
    }
}

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

class Main {
    public static void main(String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] strArray = new String[n];
        for (int i = 0; i < n; i++) {
            char[] ca = sc.next().toCharArray();
            Arrays.sort(ca);
            strArray[i] = String.valueOf(ca);
        }
        sc.close();
        Arrays.sort(strArray);

        long count = 1;
        long res = 0;
        String before = "";
        String current = "";
        for (String str : strArray) {
            before = current;
            current = str;
            if (before.equals(current)) {
                count++;
            } else {
                res += (count * (count - 1)) / 2;
                count = 1;
            }
        }
        res += (count * (count - 1)) / 2;

        System.out.print(res);
    }
}


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

int main()
{
    string s;
    int x=0;
    cin>>s;
    REP(i,s.size())
    {
        if(s[i]=='x')x++;
    }
    if(x>=8)cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
string s;
main()
{
	cin>>s;
	int c=0;
	if(s[0]!='A')
	{
		cout<<"WA"<<endl;
		return 0;
	}
	for(int i=2;i+1<s.size();i++)
	{
		c+=s[i]=='C';
	}
	if(c!=1)
	{
		cout<<"WA"<<endl;
		return 0;
	}
	c=0;
	for(int i=0;i<s.size();i++)
	{
		c+=s[i]<='Z';
	}
	cout<<(c==2?"AC":"WA")<<endl;
}


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

#define F first
#define S second
#define PB push_back
#define all(x) x.begin(), x.end()

typedef long long ll; 
typedef long double ld;

const int N = 1000 * 1000 + 10, mod = 998244353; 

ll get(ll x)
{
	ll y = 1;
	while(y<=x) y *= 2;
	return y;
}

int32_t main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	multiset<ll> s;
	int n, x;
	cin>> n;
	while(n--) cin>> x, s.insert(x);
	int ans = 0;
	while(s.size() > 1)
	{
		x = *s.rbegin();
		s.erase(s.find(x));
		ll y = get(x) - x;
		if(s.find(y)!=s.end())
		{
			ans ++;
			s.erase(s.find(y));
		}
	}
	cout<< ans << endl;
}


Measured memory_bytes: 11008
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> a(M), b(M);
	set<int> x;
	for (int i = 0; i < M; ++i) {
		cin >> a[i] >> b[i];
		if (a[i] == 1) {
			x.insert(b[i]);
		}
	}
	for (int i = 0; i < M; ++i) {
		if (b[i] == N && x.count(a[i])) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
}


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

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


Measured memory_bytes: 3596
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;

int main(){
    int n, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        ans += i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {

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

  string s, t;

  int ans = 0;

  cin >> s >> t;

  for(int i = 0; i < s.size(); i++)
    ans += (s[i] != t[i]);

  cout << ans;

  return 0;
}
/*

*/


Measured memory_bytes: 3888
import           Data.List

renzoku :: Eq a => [a] -> [(a,Int)]
renzoku [] = []
renzoku (x1:xs1) =
    inner x1 1 xs1 []
    where
        inner s c [] result = ((s,c)  : result)
        inner s c (x2:xs2) result =
            if x2 == s
            then
                inner s (1 + c) xs2 result
            else 
                inner x2 1 xs2 ((s,c)  : result)

bunkatsu :: Int -> [a] -> [[a]]
bunkatsu c [] = []
bunkatsu c arr =
    inner 0 arr [] []
    where
        inner i [] result1 result2 = result1 : result2
        inner i (x2:xs2) result1 result2 = 
            if i < c 
            then 
                inner (1+i) xs2 (x2 : result1) result2
            else
                inner 1 xs2 [x2] (result1:result2)

main = do 
    str <- getLine
    putStrLn $ intercalate " "  $ map show $ concat $ map func $ bunkatsu 2 $ renzoku str
    where 
        func [x,y] = 
            (replicate (cx - 1) 0 ) ++ [ix+ax+iy] ++ [iy+ay+ix] ++ (replicate (cy - 1) 0)
            where 
                (sx,cx) = x
                (sy,cy) = y
                (ix,ax) = divMod cx 2
                (iy,ay) = divMod cy 2





Measured memory_bytes: 12796
#include <stdio.h>
#include <math.h>
#define _USE_MATH_DEFINES
double A,B,H,M;
int main()
{
    scanf("%lf %lf %lf %lf",&A,&B,&H,&M);
    double len=0,degA=0,degB=0,def_A=0.5,def_B=6.0,deg=0;
    degA=def_A*(H*60.0+M)*M_PI/180.0;
    degB=def_B*M*M_PI/180.0;
    deg=fabs(degA-degB);
//    printf("degA=%lf degB=%lf def=%lf\n",degA,degB,deg);
    len=sqrt(A*A+B*B-2.0*A*B*cos(deg));
    printf("%15.10lf\n",len);
    return 0;
}



Measured memory_bytes: 2596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var HW = ReadLongs();
            if (HW[0] == 1 || HW[1] == 1)
            {
                WriteLine("1");
            }
            else if (HW[0] * HW[1] % 2 == 0)
            {
                WriteLine(HW[0] * HW[1] / 2);
            }
            else
            {
                WriteLine(HW[0] * HW[1] / 2 + 1);
            }
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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; }

const long long INF = 1LL << 60;

int main(){
  int n, m;
  cin >> n >> m;

  vector<int> a(n, -1);
  rep(i, m){
    int s, c;
    cin >> s >> c;
    s--;
    if(n != 1 && s == 0 && c == 0){
      cout << -1 << endl;
      return 0;
    }
    if(a[s] != c && a[s] != -1){
      cout << -1 << endl;
      return 0;
    }
    a[s] = c;
  }
  rep(i, n){
    if(a[i] == -1){
      if(n != 1 && i == 0) a[i] = 1;
      else a[i] = 0;
    }
  }
  
  int ans = 0;
  rep(i, n){
    ans += a[i] * pow(10, n-1-i);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE BangPatterns#-}
{-# OPTIONS_GHC -O2 #-}

import GHC.TypeLits

import Data.Int
import Data.Proxy
import qualified Data.Map.Lazy as Map
import Data.List
import Data.Bits
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Array.IArray as Array
import Data.Array.MArray
import Data.Array.ST
--import Data.Monoid
--import Data.Semigroup

import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Control.Monad.Primitive
import Control.Monad.State

import Debug.Trace




getInts :: IO [Int]
getInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

main :: IO ()
main = do
  [n, m] <- getInts
  a <- replicateM m $ head <$> getInts

  let
    check = runST $ do
      ret <- VUM.replicate (n+1) True
      forM_ a $ \i -> do
        VUM.write ret i False
      VU.freeze ret

    dp :: V.Vector M
    dp = V.generate (n+1) f
    f i
      | i == 0 = 1
      | i == 1 = if check VU.! 0 then 1 else 0
      | otherwise = a + b
        where
          a = if check VU.! (i - 1) then dp V.! (i - 1) else 0
          b = if check VU.! (i - 2) then dp V.! (i - 2) else 0
          

  print $ getMintValue . V.last $ dp


type M = Mint 1000000007


{-- Mod Int --}
data Mint (m :: Nat) = Mint {getMintValue :: Integer} deriving (Eq, Show)

getMintMod :: forall p. KnownNat p => Mint p -> Integer
getMintMod = natVal

makeMint :: forall p. KnownNat p => Integer -> Mint p
makeMint a
  | 0 <= a && a < p = Mint $ fromInteger $ a
  | otherwise = Mint $ fromInteger $ a `mod` p
  where p = natVal $ (Proxy :: Proxy p)

instance KnownNat p => Num (Mint p) where
  (Mint a) + (Mint b) = makeMint $ a + b
  (Mint a) - (Mint b) = makeMint $ a - b
  (Mint a) * (Mint b) = makeMint $ a * b
  negate (Mint a) = makeMint $ negate a
  abs = id
  signum (Mint a) = if a == 0 then 0 else 1
  fromInteger = makeMint

invMint :: forall p. KnownNat p => Mint p -> Mint p
invMint m = let p = getMintMod m in m ^ (p - 2)

powerMint :: forall p. KnownNat p => Integer -> Integer -> Mint p
powerMint n p
  | p >= 0 = (fromInteger n :: Mint p) ^ p
  | otherwise = invMint $ powerMint n (-p)


Measured memory_bytes: 49532
N = int(input())
A = list(map(int,input().split()))
ans = 0
xor = 0
sumA = 0
l = 0
for r in range(N):
    sumA += A[r]
    xor ^= A[r]
    while sumA != xor :
        sumA -= A[l]
        xor = xor^A[l]
        l += 1
    ans += r-l+1
print(ans)

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

using namespace std;

int main()
{
  int K, S; cin >> K >> S;

  int ans = 0;
  for (int i = 0; i<= K; ++i) {
    for (int j = 0; j <= K; ++j) {
      int k = S-i-j;
      if (k < 0 or k > K) continue;
      ans++;
    }
  }

  cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cstdlib>
#include <unordered_map>
#include <numeric>

using namespace std;

#define fs first
#define sc second

typedef long long ll;
typedef pair<int, int> P;

const ll mod = 1e9+7;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return pow(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}


ll dp[101000][110][2];

int main(){
    string K;
    cin >> K;
    int D;
    cin >> D;

    for(int i = 0; i < 101000; i++){
        for(int k = 0; k < 110; k++){
            for(int j = 0; j < 2; j++){
                dp[i][k][j] = 0;
            }
        }
    }

    dp[0][0][1] = 1;
    for(int i = 0; i < K.length(); i++){
        int d = K[i] - '0';

        for(int j = 0; j <= D; j++){
//            cout << dp[i][j][0] << " " << dp[i][j][1] << " " << i << " " << j << endl;
            // Kに縛られていない
            for(int k = 0; k <= 9; k++){
                dp[i+1][(j+k) % D][0] = add(dp[i+1][(j+k) % D][0], dp[i][j][0]);
            }

            for(int k = 0; k < d; k++){
                dp[i+1][(j+k) % D][0] = add(dp[i+1][(j+k) % D][0], dp[i][j][1]);
            }

            dp[i+1][(j+d) % D][1] = add(dp[i+1][(j+d) % D][1], dp[i][j][1]);
        }
//        cout << endl;
    }

    cout << sub(add(dp[K.length()][0][0], dp[K.length()][0][1]), 1) << endl;

    return 0;
}

Measured memory_bytes: 174336
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int MOD = 998244353;

long long GCD(long long x, long long y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

int main() {
    int N;
    cin >> N;
    vector<long long> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];
    sort(a.begin(), a.end());

    long long res = 1;
    for (int i = 0; i < N; ++i) {
        res = (res * GCD(a[i], i)) % MOD;
    }
    cout << res << endl;
}


Measured memory_bytes: 1024
import math
A=[]
N,M=[int(i) for i in input().split()]
sqrt=math.sqrt(M)
for i in range(1,int(sqrt)+1):
    if M%i==0:
        A.append(i)
        A.append(M//i)
ans=[1]
for i in A:
    if i*N<=M:
        ans.append(i)
    else:
        continue
print(max(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define FOR(i, begin, end) for(ll i = (begin); i < (end); i++)
#define rep(i, n) FOR(i, 0, n)
using ll = long long;
using namespace std;
#define all(x) (x).begin(),(x).end()
using pii = pair<int, int>; using vi = vector<int>; using vl = vector<ll>;

int lunlun(int a) {
    int before = a % 10;
    a /= 10;
    int i = 0;
    while(a > 0) {
        if(before - a%10 > 1) {
            return 0;
        } else if(a%10 - before > 1) {
            return i;
        }
        before = a % 10;
        a /= 10;
        i++;
    }
    return -1;
}
signed main() {
    int k;
    cin>>k;
    int a = 1;
    int n = 0;
    while (true)
    {
        int i = lunlun(a);
        // cerr << i << ' '<< a << endl;
        if(i == -1) {
            // cerr << a << endl;
            n++;
            if(n==k) {
                cout << a;
                return 0;
            }
            a++;
        } else
            if(i>1)
                a += pow(10, i) - pow(10, i-1);
            else a ++;
        // if(a > 10) return 0;
    }
    

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef pair<ul, ul> P;

const int INF = 1e9;
const int MOD =1e9+7;
const ll LINF = 1e18;

int main(){
    int N, A;

    cin >> N;
    cin >> A;

    int mod = N % 500;
    cout << ((mod <= A) ? "Yes" : "No" ) << endl;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ans;
string a,b;
int main(){
	a="CODEFESTIVAL2016";
	cin>>b;
	for(int i=0;i<b.size();i++)
		if(a[i]!=b[i]) ++ans;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<iostream>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	while(1){
		string s,tmp;
		while(1){
			getline(cin,tmp);
			if(tmp=="") break;
			s+=tmp;
		}
		string a; getline(cin,a);
		getline(cin,tmp);
		if(a=="") break;

		int m=a.length();
		bool b[128]={};
		rep(i,m) b[a[i]]=true;

		int n=s.length();
		int j_ans,w_ans=2*n,c_ans=0;
		int cnt[128]={},cnt2=0;
		for(int i=0,j=0;i<n;i++){
			if(cnt[s[i]]==0 && b[s[i]]) cnt2++;
			cnt[s[i]]++;

// printf("i=%2d, j=%2d\n",i,j);
			if(cnt2==m){
				while(j<i && cnt[s[j]]>1 || cnt[s[j]]==1 && !b[s[j]]){
					cnt[s[j]]--;
					j++;
				}
				if(i-j+1<w_ans){
					j_ans=j;
					w_ans=i-j+1;
					c_ans=1;
				}
				else if(i-j+1==w_ans){
					c_ans++;
				}
			}
		}

		cout<<c_ans<<endl<<endl;
		if(c_ans>0){
			string ans=s.substr(j_ans,w_ans);
			for(int i=0;i<w_ans;i+=72){
				for(int j=i;j<min(i+72,w_ans);j++) cout<<ans[j];
				cout<<endl;
			}
			cout<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1696
// Chekpoints
#include <iostream>
#include <math.h>
using namespace std;

int n,m;
int a[50],b[50],c[50],d[50];

int main(){
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }for(int i=0;i<m;i++){
        cin>>c[i]>>d[i];
    }
    for(int i=0;i<n;i++){
        int Min=0;
        for(int j=0;j<m;j++){
            if(abs(a[i]-c[Min])+abs(b[i]-d[Min])>abs(a[i]-c[j])+abs(b[i]-d[j]))
                Min=j;
        }
        cout<<Min+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vpii = vector<pair<int, int>>;

int main()
{
  int n;
  cin >> n;
  ll data[n + 1];
  data[0] = 0;
  ll sum = 0;
  for (int i = 1; i <= n;i++){
    cin >> data[i];
    
  }
  for (int i = 1; i < n;i++){
    if(data[i]>data[i+1]){
      sum = sum + (data[i ] - data[i+1]);
      data[i + 1] = data[i];
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 5184
#include <bits/stdc++.h>
#define MOD 1000000007
//for(int i=0; i<n; ++i)
using namespace std;
#define all(c) c.begin(), c.end()
#define watch(x) cout << (#x) << " is " << (x) << endl
#define ll long long

void dfs(int node, vector<int> &lpfrom, vector<int> &visited, vector<vector<int>> &adj)
{
    if (visited[node] == 1)
        return;
    int sol = 0;
    for (auto nxt : adj[node])
    {
        dfs(nxt, lpfrom, visited, adj);
        sol = max(sol, lpfrom[nxt] + 1);
    }
    lpfrom[node] = sol;
    visited[node] = 1;
    return;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m, x, y;
    cin >> n >> m;

    vector<int> lpfrom(n + 1, 0), visited(n + 1, 0);
    vector<vector<int>> adj(n + 1);
    while (m--)
    {
        cin >> x >> y;
        adj[x].push_back(y);
    }
    int sol = 0;
    for (int i = 1; i <= n; ++i)
    {
        dfs(i, lpfrom, visited, adj);
        sol = max(sol, lpfrom[i]);
    }
    cout << sol << endl;
    return 0;
}

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

using int64 = long long;

int main() {
  string S;
  cin >> S;
  int64 n = S.size() + 1;

  int64 sum = 0;
  int64 pre = 0;
  for (int64 s = 0; s < n - 1;) {
    int64 i = 0;
    for (i = 0; s + i < n - 1 && S[s + i] == '>'; ++i) {}
    int64 dec = i;
    for (i = 0; s + dec + i < n - 1 && S[s + dec + i] == '<'; ++i) {}
    int64 inc = i;
    s += dec + inc;
    sum += dec * (dec + 1) / 2;
    sum += inc * (inc + 1) / 2;
    sum -= min(dec, pre);
    pre = inc;
  }
  cout << sum << "\n";


  return 0;
}


Measured memory_bytes: 900
#include <stdio.h>


void swap(int *x,int *y) {
    
    int tmp;
    
    tmp = *x;
    *x = *y;
    *y = tmp;
    
}

int main(int argc, const char * argv[]) {
    
    int a,b,c;
    
    scanf("%d %d %d",&a,&b,&c);
    
    if (c < b) {
        swap(&c, &b);
    }
    
    if (b < a) {
        swap(&b, &a);
    }
    
    if (c < b) {
        swap(&c, &b);
    }
    
    
    printf("%d %d %d\n",a,b,c);
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
using namespace std;

int main() {
	int row, column;
	scanf("%d %d", &row, &column);
	char** board = new char*[row + 1];
	for (int i = 0; i < row + 1; i++) {
		board[i] = new char[column + 1];
	}
	char c;
	scanf("%c", &c);
	for (int i = 0; i < row + 1; i++) {
		for (int j = 0; j < column + 1; j++) {
			scanf("%c", &(board[i][j]));
		}
	}

	bool flag = true;
	for (int i = 1; i < row; i++) {
		for (int j = 1; j < column; j++) {
			if (board[i - 1][j] == '#' && board[i][j - 1] == '#') {
				flag = false;
				break;
			}
		}
	}
	if (flag  == true) {
		printf("Possible\n");
	}
	else {
		printf("Impossible\n");
	}
}

Measured memory_bytes: 256
import sys
n = int(input())
a = list(map(int, input().split()))
if a.count(0) > 0:
  print(0)
  sys.exit()
ans = 1
for i in a:
  ans *= i
  if ans > 10 ** 18:
    print(-1)
    break
else:
  print(ans)


Measured memory_bytes: 21776
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
  int k,x;
  cin >> k >> x;
  for(int i = x - k +1; i <= x + k -1; i++)cout << i << endl;
}

Measured memory_bytes: 3536
import math
from functools import reduce
k = int(input())
ans = 0
def gcd(*numbers):
    return reduce(math.gcd, numbers)
for a in range(1, k + 1):
  for b in range(1, k + 1):
    for c in range(1, k + 1):
      ans = ans + gcd(a,b,c)
print(ans)

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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;



signed main(){

	int N, a[5];
	cin >> N >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
	int ans;
	int*i = min_element(a, a + 5);

	ans = ceil((double)N / (*i));

//	ans += a + 4 - i;

	ans += 4;

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

Measured memory_bytes: 256
from collections import deque

def main():
    N, M = list(map(int, input().split()))
    R = [set() for _ in range(N+1)]
    for _ in range(M):
        x = list(map(int, input().split()))
        R[x[0]].add(x[1])
        R[x[1]].add(x[0])
    
    q = deque()
    #s = set()
    r = [0] * (N+1)
    q.append(1)
    while any(q):
        x = q.popleft()
        #s.add(x)
        ro = R[x]
        for i in ro:
            #if r[i] == 0 and i not in s and i not in q:
            if r[i] == 0: 
                r[i] = x
                q.append(i)
    #if len(s) == N:
    print("Yes")
    print("\n".join(map(str, r[2:])))
    #else:
    #    print("No")

if __name__ == '__main__':
    main()

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

using namespace std;

typedef long long ll;
const ll modl = 1e9 + 7;

void fast() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

#ifndef tmr
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int main() {

	ll n , m;
	cin >> n >> m;

	char grid[n][m];
	for (long i = 0; i < n; i++) {
		for (long j = 0; j < m; j++) {
			cin >> grid[i][j];
		}
	}

	ll ans[n][m];
	memset(ans, 0, sizeof ans);


	for (int i = 1; i < m; i++) {
		if (grid[0][i] == '#') break;
		ans[0][i] = 1ll;
	}

	for (int i = 1; i < n; i++) {
		if (grid[i][0] == '#') break;
		ans[i][0] = 1ll;
	}

	for (int i = 1; i < n; i++) {
		for (int j = 1; j < m; j++) {
			if (grid[i][j] == '#') continue;

			if (j - 1 >= 0) ans[i][j] = ((ans[i][j] + ans[i][j - 1]) % modl);
			if (i - 1 >= 0) ans[i][j] = ((ans[i][j] + ans[i - 1][j]) % modl);
		}
	}

	cout << (ans[n - 1][m - 1] % modl) << endl;
	return 0;

}

Measured memory_bytes: 12324
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,c[3];
    cin>>a>>b;
    c[0]=a+b;
    c[1]=a-b;
    c[2]=a*b;
    sort(c,c+3);
    cout<<c[2]<<endl;
    return 0;
}

Measured memory_bytes: 256