akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pii;
typedef pair<pii,ll> piii;
typedef pair<ll,pii> ipii;
#define MOD 1000000007
#define mod(a) ((a)%MOD)
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define dbg(x) cerr<<#x<<" = "<<x<<"\n"
#define dbg2(x,y) cerr<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<"\n"
#define dbg3(x,y,z) cerr<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<" , "<<#z<<" = "<<z<<"\n"
#define INF (1LL<<60)
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;*/
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(v) v.begin(),v.end()
#define endl '\n'
ll gcd(ll a,ll b){if(a==0) return b; return gcd(b%a,a);}
ll powm(ll base,ll exp,ll mod=MOD) {base%=mod;ll ans=1;while(exp){if(exp&1LL) ans=(ans*base)%mod;exp>>=1LL,base=(base*base)%mod;}return ans;}
 
 
 
#define N (1LL<<16)
ll a[16][16];
ll dp[N];
ll dp1[N];
int main(){
      sync;
      int n;
      cin>>n;
      for(int i=0;i<n;i++)
         for(int j=0;j<n;j++) cin>>a[i][j];


      dp[0]=0;
      for(int i=1;i<N;i++){
           for(int j=0;j<16;j++){
           	    if((i&(1<<j))){
           	           dp[i]=dp[i^(1<<j)];
           	           for(int k=j+1;k<16;k++){
           	           	   if((i&(1<<k))) dp[i]+=a[j][k];
           	           }
           	            break;
           	    }
           }
      }

      for(int i=1;i<N;i++){
      	   dp1[i]=dp[i];
      	   for(int j=(i-1)&i;j>0;j=(j-1)&i){
      	   	    int mask=i^j;
      	   	    dp1[i]=max(dp1[i],dp1[j]+dp[mask]);
      	   }
      }
        cout<<dp1[N-1]<<endl;
}

Measured memory_bytes: 1280
#include<stdio.h>
#define N 100001
int A[N];

/*
void QuickSort(int p, int r){
  int q;
  if (p<r){
    q = Partition(p,r);
    QuickSort(p,q-1);
    QuickSort(q+1,r);
  }
}
*/

int Partition(int p, int r){
  int x,i,j,temp;
  x = A[r];
  i = p-1;
  for (j=p;j<=r-1;j++){
    if (A[j]<=x){
      i++;
      temp=A[i];
      A[i]=A[j];
      A[j]=temp;
    }
  }
  temp=A[i+1];
  A[i+1]=A[r];
  A[r]=temp;
  return i+1;
}

int main(){
  int n,i,key;
  scanf("%d",&n);
  for (i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  //QuickSort(0,n-1);

  key=Partition(0,n-1);

  for (i=0;i<n;i++){
    if (i!=0){
      printf(" ");
    }
    if (i==key){
      printf("[");
    }
    printf("%d",A[i]);
    if (i==key){
      printf("]");
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 992
#include<iostream>
#include <cstdio>
#include<cmath>
using namespace std;
int X[100005];
int Y[100005];
long long N,B,C,m,n,a,b,c,x,y,z,i,j,k,h;
double A;
int main ()
{
	cin>>a>>b;
	A=1.0*(double(abs(a*b))/2.0);
	cin>>x>>y;
	cout<<A<<" ";
	if((2*x==a)&&(2*y==b))
	cout<<1;
	else
	cout<<0;
	return 0;
}

Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

 
use proconio::input;

fn main() {
    /*     input! {
        n: usize,
        mut plan: [(i32, i32, i32); n],  // Vec<(i32, i32, i32)>
    }
 */
    input! {
        n: u32,
        m: u32,
        c: i32,
        bs: [i32;m],
        asss: [[i32;m];n],
    }

    let mut ans = 0;
    for ass in asss.iter(){
        let mut result = 0 ;
        for (i,a) in ass.iter().enumerate(){
            result += a * bs[i];
        }
        if result + c > 0 {
            ans += 1;
        }
    }
    println!("{}",ans);
}


Measured memory_bytes: 2144
#include <stdio.h>

#define DATA 1000

int main(void)
{
	int a[DATA], b[DATA];
	char op[DATA];
	int i;

	for(i = 0;i < DATA;i++)
	{
		scanf("%d %c %d", &a[i], &op[i], &b[i]);
		if(op[i] == '?')
			break;
	}
	for(i = 0;op[i] != '?';i++)
	{
		switch(op[i])
		{
			case '+':
				printf("%d\n", a[i] + b[i]);
				break;

			case '-':
				printf("%d\n", a[i] - b[i]);
				break;

			case '*':
				printf("%d\n", a[i] * b[i]);
				break;

			case '/':
				printf("%d\n", a[i] / b[i]);
				break;

			default:
				break;
		}
	}

	return 0;
}

Measured memory_bytes: 608
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int[] a = new int[n];
		boolean d1 = false;
		int[] d = new int[n-1];
		for(int i = 0; i < s.length(); i++)
		{
			a[i] = s.charAt(i)-'0';
			if(i>0)
			{
				d[i-1] = a[i]-a[i-1];
				if(d[i-1]<0)d[i-1]*=-1;
				if(d[i-1] == 1)d1 = true;
			}
		}
		int m = n-1, t1 = 0, t2 = 0;
		
		for(int take = 0; take <= m-1; take++)
		{ //(m-1) C take 0
			int nn = m-1;
			boolean odd = ((nn) & ((nn)-take)) <= 0;
			odd = (take & (nn-take)) <= 0;
			if(d[take] == 1 && odd)t1++;
			if(d[take] == 2 && odd)t2++;
		}
		
		t1 = t1%2;
		t2 = t2%2;
		if(t1<0)t1+=2;if(t2<0)t2+=2;
		if(t1 == 0 && t2 == 0)
			System.out.println(0);
		else if(t2 == 1 && t1 == 0)
			if(!d1) System.out.println(2);
			else System.out.println(0);
		else System.out.println(1);
		
	}

}


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


pair <int,int> mon[200005];


int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n, d, a;
	cin >> n >> d >> a;
	for (int i = 1; i <= n; ++i){
		int x, h;
		cin >> x >> h;
		mon[i] = {x,h};
	}
	sort(mon+1,mon+n+1);
	queue <pair<int,int>> B;
	long long akt_dmg = 0;
	long long wynik = 0;

	for (int i = 1; i <= n; ++i){
		int x = mon[i].first, h = mon[i].second;
		while (!B.empty() && B.front().first + d < x){
			akt_dmg -= B.front().second;
			B.pop();
		}
		h -= akt_dmg;
		if (h > 0){
			int ile = h / a + (h % a != 0);
			B.push({x+d,ile*a});
			akt_dmg += ile*a;
			wynik += ile;
		}
	}
	cout << wynik << "\n";
}

Measured memory_bytes: 2688
N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]

cand = [-1] * N
flag = False
for s, c in X:
    s -= 1
    if cand[s] == -1:
        cand[s] = c
    elif cand[s] != c:
        flag = True

if flag or (N > 1 and cand[0] == 0):
    print(-1)
else:
    ans = 0
    for i in range(N):
        if cand[i] == -1:
            if i == 0 and N > 1:
                cand[i] = 1
            else:
                cand[i] = 0
        ans += cand[i] * 10 ** (N - i - 1)
    print(ans)


Measured memory_bytes: 61972
#include <cstdio>
#include <algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int N;

int digS( int x )
{
  int ret = 0;

  while( x > 0 )
    ret += x%10, x /= 10;

  return ret;
}

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

  int ans = 10000000;

  repi( A, 1, N )
  {
    int B = N-A;

    ans = std::min( ans, digS(A)+digS(B) );
  }

  printf( "%d\n", ans );
  
  return 0;
}

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

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

template<ll mod>
struct modint {
private:
  ll x;

public:
  modint(): x((ll)0) {}
  modint(ll y): x(y >= 0? y % mod: (mod - (-y) % mod) % mod) {}

  ll get() {
    return x;
  }

  modint &operator+=(const modint &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }

  modint &operator-=(const modint &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  modint &operator*=(const modint &p) {
    x = x * p.x % mod;
    return *this;
  }

  modint &operator/=(const modint &p) {
    *this *= p.inverse();
    return *this;
  }

  modint operator-() const { return modint(-x); }
  modint operator+(const modint &p) const {return modint(*this) += p; }
  modint operator-(const modint &p) const {return modint(*this) -= p; }
  modint operator*(const modint &p) const {return modint(*this) *= p; }
  modint operator/(const modint &p) const {return modint(*this) /= p; }

  bool operator==(const modint &p) const { return x == p.x; }
  bool operator!=(const modint &p) const { return x != p.x; }

  modint inverse() const {
    ll a = x, b = mod, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      a -= t * b;
      swap(a, b);
      u -= t * v;
      swap(u, v);
    }
    return modint(u);
  }

  modint pow(int e) const {
    ll a = 1, p = x;
    while(e > 0) {
      if (e % 2 == 0) {
	p = (p * p) % mod;
	e /= 2;
      } else {
	a = (a * p) % mod;
	e--;
      }
    }
    return modint(a);
  }
};


using mi = modint<MOD>;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  mi ans = 2;
  ans = ans.pow(n) - 1;

  mi adiff = 1;
  for (int i = 0; i < a; ++i) {
    adiff *= (n - i);
    adiff /= (i + 1);
  }

  mi bdiff = 1;
  for (int i = 0; i < b; ++i) {
    bdiff *= (n - i);
    bdiff /= (i + 1);
  }

  ans -= adiff;
  ans -= bdiff;
  
  cout << ans.get() << endl;
  return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math

low = 1
high = 100

#t = int(input())
tmp = input().split()
x,n = list(map(lambda a: int(a), tmp))

if(n==0):
	print(x)
	sys.exit()

tmp = input().split()
p = list(map(lambda a: int(a), tmp))

ans=[]
for i in range(102):
	ans.append(0)

#print(ans)

for i in range(n):
	ans[p[i]]+=1

tmp=0
if(ans[x]==0):
	print(x)
	sys.exit()

for i in range(102):
	if(ans[x-tmp]==0):
		print(x-tmp)
		sys.exit()
	if(ans[x+tmp]==0):
		print(x+tmp)
		sys.exit()
	tmp+=1


Measured memory_bytes: 9232
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PI 				acos(-1)
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define sz(a)			a.size()
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define MOD1			998244353
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)
int in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
using namespace __gnu_pbds;

typedef long long 		ll;
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//find_by_order kth largest  order_of_key <
const int tam = 100010;
const int MOD = 1e9+7;
const double EPS = 1e-9;
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	//freopen("qwe.txt", "r", stdin);
	//freopen("asd.txt", "w", stdout);
	ll n;
	ll podo[50];
	podo[0] = 1;
	fore(i, 1, 50) podo[i] = podo[i-1] * (-2);
	cin>>n;
	if(n == 0)
	{
		cout<<0<<'\n';
		return 0;
	}
	bool be[100];
	mem(be, 0);
	while(n != 0)
	{
		ll proto = abs(n);
		for(int i = 0; (1ll<<i) <= proto; i++)
		{
			if(proto & (1ll<<i))
			{
				n -= podo[i];
				podo[i] = -podo[i];
				be[i] = !be[i];
			}
		}
	}
	string res = "";
	bool bo = false;
	for(int i = 99; i > -1; i--)
	{
		if(be[i])
			bo = true;
		if(bo)
			res += be[i] ? '1' : '0';
	}
	cout<<res<<'\n';
	return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2

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

using namespace std;

#define int long long

signed main() {
  int n, d;
  cin >> n >> d;
  int m = n-d-1;
  if(d == 1) cout << n*(n-1)/2 << endl;
  else if(d == 2) cout << n*(n-1)/2-1 << endl;
  else cout << d+m*(m+1)/2+2*m << endl;
  return 0;
}



Measured memory_bytes: 3100
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  char a[n];
  cin >> a;
  int count = 0;
  for(int i = 0; i < n; i++){
    if(a[i] == 'A'){
      if(a[i+1] =='B'){
        if(a[i+2] == 'C')count++;
      }
    }
  }
  cout  << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const int vx[]={1,0,-1,0}, vy[]={0,1,0,-1};
const ll LINF=1e18;
const ld PI=abs(acos(-1));

int main(){
	ll x,y; cin >> x >> y;
	
	if(abs(x - y) > 1) cout << "Alice" << endl;
	else cout << "Brown" << endl;
	return 0;
}


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

int main(){
  int X,Y,Z;
  cin >>X>>Y>>Z;
  int tmp=1;
  while(Y*(tmp+1)+Z*(tmp+2)<=X){
    tmp+=1;
  }
  cout <<tmp<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int n,l,i,max=0,s=0;
  scanf("%d",&n);
  for (i=0;i<n;i++){
    scanf("%d",&l);
    if (l>max) max=l;
    s+=l;
  }
  s-=max;
  printf("%s\n",(max<s)? "Yes":"No");
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;

vector<int> to[100005];
int n;

vector<int> dist;
void dfs(int v,int d=0,int p=-1){
  dist[v]=d;
  for(int u : to[v]){
    if(u==p) continue;
    dfs(u,d+1,v);//無向グラフで一点dpsの時は一つ前に戻るパターンを削除
  }
}
vector<int> calcDist(int s){
  dist=vector<int>(n);
  dfs(s);
  return dist;
}

int main(){
  cin>>n;
  int s,t;cin>>s>>t;
  s--;t--;
  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  
  vector<int> distS=calcDist(s);
  vector<int> distT=calcDist(t);
  
  int mx=0;
  rep(i,n){
    if(distS[i]<distT[i]){
      mx=max(mx,distT[i]);
    }
  }
  int ans=mx-1;
  cout<<ans<<endl;
  
}

Measured memory_bytes: 10744
#include <stdio.h>

int main (void)


{


int n;


int x;


int num;


int min=1000001;


int max=-1000001;


long total=0;


scanf("%d",&n);


for(x=0;x<n;x++){


scanf("%d",&num);


if(min>num) min=num;


if(max<num) max=num;


total+=num;


}


printf("%d %d %ld\n",min,max,total);


return 0;


}

Measured memory_bytes: 2752
s = input()

def calc_str(st):
  lst = st.split('+')
  lst = map(int, lst)
  return sum(lst)
  
prev = []
for c in s:
  if prev != []:
    new_prev = []
    for elem in prev:
      new_prev.append(elem + c)
      new_prev.append(elem + "+" + c)
    prev = new_prev
  else:
    prev.append(c)

sums = 0
for elem in prev:
  sums += calc_str(elem)
print(sums)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/math/common_factor_rt.hpp>
using namespace std;
using namespace boost::range;
using boost::irange;
using boost::math::gcd;
using boost::math::lcm;

using ll = int64_t;
constexpr char LN = '\n';
template<class T> bool chmax(T& a, const T& b) {if(a<b){a=b;return true;}else{return false;}}
template<class T> bool chmin(T& a, const T& b) {if(b<a){a=b;return true;}else{return false;}}

#ifdef LOCAL
template<class H> void dump_(const char* s, H h) {cout<<s<<"="<<h<<LN; }
template<class H, class... T> void dump_(const char* s, H h, T... t) {for(;*s!=',';++s){cout<<*s;}cout<<"="<<h<<",";dump_(++s,t...);}
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__)
#else
#define dump(...)
#endif

struct init_ {init_(){cin.tie(nullptr);ios::sync_with_stdio(false);}} init_;

template<class C> C scan(size_t n) {C c(n);for(auto& v:c){cin>>v;}return c;}
template<class C> C scan(size_t n, size_t m) {C vss(n);for(auto& vs:vss){vs.resize(m);for(auto& v:vs){cin>>v;}}return vss;}

template<class R> struct Joined { const R& r; const char* s; };
template<class R> Joined<R> joined(const R& r, const char* s = " ") {return{r,s};}
template<class R> ostream& operator<<(ostream& out, Joined<R> j) {bool f=true;for(const auto& v:j.r){if(f){f=false;}else{out<<j.s;}out<<v;}return out;}

template<class T> using matrix = vector<vector<T>>;
template<class T> matrix<T> make_matrix(size_t n, size_t m, const T& init = T()) {matrix<T> vss(n);for(auto& vs:vss){vs.resize(m,init);}return vss;}
template<class T> ostream& operator<<(ostream& out, Joined<matrix<T>> j) {bool a=true;for(const auto& vs:j.r){if(a){a=false;}else{out<<LN;}bool f=true;for(const auto& v:vs){if(f){f=false;}else{out<<j.s;}out << v;}}return out;}

template<class T> void show_(const T& t) {cout<<t;}
template<class T> void show_(const vector<T>& v) {cout<<joined(v);}
void show_(bool b) {cout<<(b?"Yes":"No");}
void show_(double d) {cout<<fixed<<setprecision(12)<<d;}
template<class T, class... TS> void show_(const T& t, TS... ts) {show_(t);cout<<' ';show_(ts...);}
template<class T> void show(const T& t) {show_(t);cout<<LN;}
template<class T, class... TS> void show(const T& t, TS... ts) {show_(t, ts...);cout<<LN;}

int main() {
    int N, M;
    cin >> N >> M;
    auto A = scan<vector<int>>(N);
    int count = 0;
    int sum = accumulate(A.begin(), A.end(), 0);
    for (int a : A) {
        if (a * 4 * M >= sum) {
            count++;
        }
    }
    show(count >= M);
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;


public class Main {
	public static int INF = 1 << 24;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		ArrayList<Data> list = new ArrayList<Data>();
		
		int N = stdIn.nextInt();
		for(int i = 0; i < N; i++) {
			int h = stdIn.nextInt();
			int m = stdIn.nextInt();
			list.add(new Data(h,m));
		}
		int M = stdIn.nextInt();
		for(int i = 0; i < M; i++) {
			int h = stdIn.nextInt();
			int m = stdIn.nextInt();
			list.add(new Data(h,m));
		}
		Collections.sort(list,new MyComparator());
		Data tmp = list.get(0);
		System.out.printf("%1d:%02d", tmp.h, tmp.m);
		int lastsm = tmp.sm;
		
		for(int i = 1; i < list.size(); i++) {
			if(list.get(i).sm == lastsm) {
				continue;
			}
			tmp = list.get(i);
			System.out.printf(" %1d:%02d", tmp.h, tmp.m);
			lastsm = tmp.sm;
		}
		System.out.println();
	}
	
}
class MyComparator implements Comparator<Data> {
	
	public int compare(Data o1, Data o2) {
		if(o1.sm < o2.sm) {
			return -1;
		}
		else if(o1.sm > o2.sm) {
			return 1;
		}
		return 0;
	}
}
class Data {
	int h;
	int m;
	int sm;
	
	Data(int h, int m) {
		this.h = h;
		this.m = m;
		sm = h*60+m;
	}
}

  

Measured memory_bytes: 20984
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
  
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
using namespace std;
      
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int n;
  cin>>n;

  int x,sum=0;
  reps(i,n){
    cin>>x;
    if(i!=x){
      sum++;
    }
  }

  if(sum==0 || sum==2){
    cout<<"YES"<<'\n';
  }
  else{
    cout<<"NO"<<'\n';
  }
  return 0;
}


Measured memory_bytes: 256
#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);i>=0;i--)
#define FOR (i,m,n) for(int (i)=m;(i)<(n);(i)++)

int main(){
  int target, elem;
  bool flag=0;
  cin >>target >>elem;
  int kazu[elem];
  REP(i,elem)cin >>kazu[i];

 
  REP(i,100){
    if(elem==0){
      cout <<target;
      break;
    }
    
    REP(j,elem){
      flag=0;
      if(target-i==kazu[j]){
	flag=1;
	break;
      }
    }
    if(flag==0){
      cout <<target-i;
      break;
    }

    REP(j,elem){
      flag=0;
      if(target+i==kazu[j]){
	flag=1;
	break;
      }
    }
    if(flag==0){
      cout <<target+i;
      break;
      }
    }
}


Measured memory_bytes: 3632
n,m = map(int,input().split())
ps = [list(input().split()) for _ in range(m)]
aw = ["WA"] * n
wacnt = [0] * n
ac = 0
wa = 0
for i in ps:
    if aw[int(i[0])-1] == "WA":
        if i[1] == "AC":
            ac += 1
            wa += wacnt[int(i[0])-1]
            aw[int(i[0])-1] = "AC"
        else:
            wacnt[int(i[0])-1] += 1
    else:
        pass
print(ac,wa)

Measured memory_bytes: 27472
n, m = map(int, raw_input().split())
a, b = [], []
c = [0 for _ in range (n)]
for _ in range(n):
	a.append(map(int, raw_input().split()))
for _ in range(m):
	b.append(int(raw_input()))
for i in range(n):
	c[i] = 0
	for j in range(m):
		c[i] += a[i][j]*b[j]
	print c[i]

Measured memory_bytes: 4820
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;
pair<ll, ll> ps[1 << 20];

int main(void) {

  int n;
  cin >> n;
  n--;
  int d = 0;
  while (n >= 1 << d) d++;
  d--;

  string s, t;
  cout << 0 << endl;
  cin >> s;
  if (s == "Vacant") return 0;

  int l = 0, r = n + 1;
  while (true) {
    int med = (l + r) >> 1;
    cout << med << endl;
    cin >> t;
    if (t == "Vacant") return 0;
    if ((med % 2 == 0 && t == s) || (med % 2 == 1 && t != s)) l = med;
    else r = med;
  }
  return 0;
}


Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}

const int MAX = 15001000;//適宜変更
bool IsPrime[MAX];
int MinFactor[MAX];
//前処理
vector<int> preprocess(int n = MAX) {
    vector<int> res;
    //初期化
    for (int i = 0; i < n; ++i) IsPrime[i] = true, MinFactor[i] = -1;
    IsPrime[0] = false; IsPrime[1] = false; 
    //最小の素因数を求める。
    MinFactor[0] = 0; MinFactor[1] = 1;
    for (int i = 2; i < n; ++i) {
        if (IsPrime[i]) {
            MinFactor[i] = i;
            res.push_back(i);
            for (int j = i*2; j < n; j += i) {
                IsPrime[j] = false;
                if (MinFactor[j] == -1) MinFactor[j] = i;
            }
        }
    }
    return res;
}

/*素因数がそれぞれ何個あるか調べる。*
 *      ex)18→{2,1}{3,2}      */
vector<pair<int,int> > prime_factor(int n) {
    vector<pair<int,int> > res;
    while (n != 1) {
        int prime = MinFactor[n];
        int exp = 0;
        while (MinFactor[n] == prime) {
            ++exp;
            n /= prime;
        }
        res.push_back(make_pair(prime, exp));
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    ll ans_tmp = 1;
    ll cnt = 1;
    bool flag = false;
    preprocess();
    for (int i = 1; i <= n; ++i) {
        auto pf = prime_factor(i);
        for (auto p : pf) {
            if(p.second != 1) {
                ans_tmp *= p.second+1;
                flag = true;
                //cout << p.second << " ";
            }
            else {
                cnt++;
            }
        }
        //cout << i << " " << ans_tmp << " " << cnt << " ";
        //if(cnt == 0) cnt++;
        ans_tmp *= pow(2, cnt-1);
        //ans_tmp--;
        ans += ans_tmp*i;
        //cout << ans_tmp << " " << i << endl;;
        ans_tmp = 1;
        cnt = 1;
        flag = false;
    }
    cout << ans << endl;
    return 0;
}

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

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

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

    vector<ll> x(n);
    for (int i = 0; i < n; ++i) {
        ll in;
        cin >> in;
        x[i] = abs(m - in);
    }

    ll d = x[0];
    for (int i = 1; i < n; ++i) {
        d = gcd(d, x[i]);
    }

    cout << d << endl;

    return 0;
}

Measured memory_bytes: 1024
using System;
class Program
{
	static void Main(string[] args)
	{
		 string[] line = System.Console.ReadLine().Trim().Split(' ');
		 var a = ulong.Parse(line[0]);
		 var b = ulong.Parse(line[1]);
		 Console.WriteLine(Math.Min(a%b,(a+b)/b*b-a));
	}
}

Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());

        int[] arr = new int[N];

        long sum=0;

        for(int j=0; j<N; j++){
            arr[j]=j+1;
        }

        for(int i = 0; i<N; i++){
            if ( (arr[i] % 3 ==0) || (arr[i] % 5 ==0)){
                arr[i]=0;
            }else{
                sum= sum + arr[i];
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 39584
#include<math.h>
#include<iostream>

using namespace std;

int main() {

	unsigned long H;
	cin >> H;

	for (int i = 0; i < 40; ++i)
	{
		if (powl(2, i) <= H && H < powl(2, (unsigned long)(i + 1))) {
			cout << (unsigned long)powl(2, (unsigned long)(i + 1)) - 1;
		}
	}

	return 0;
}

Measured memory_bytes: 640
import sys

INF = 1001001001

def resolve():
  n = int(input())
  a = list(map(int, input().split()))
  a.sort()
  prev = 0
  for v in a:
    if (v == prev):
      print("NO")
      return
    prev = v
  print("YES")

  return

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 25172
#include <bits/stdc++.h>
#define ll long long int
#define r(a, b) for(ll i = a; i < b; i++)
#define pb push_back
using namespace std;
#define mod 998244353
const long long int INF = 1e10;
vector<ll>v;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,n;
    cin>>a>>n;
    ll sum=0;
    for(ll x=0; x<n; x++){
        ll y;
        cin>>y;
        sum+=y;
    }
    if(sum>=a){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
    return 0;
}



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

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    public static void Main()
    {
        int N = NextInt();
        SieveOfEratosthenes sieve = new SieveOfEratosthenes(55555);
        sieve.Run();
        foreach (var v in sieve.list)
        {
            if (v % 5 == 2)
            {
                Console.Write(v + " ");
                N--;
            }
            if (N == 0) break;
        }
        Console.WriteLine();
    }
}
public class SieveOfEratosthenes
{
    public HashSet<int> list { get; private set; } = new HashSet<int>();
    private static bool[] memo;
    private int M, root;
    public SieveOfEratosthenes(int N)
    {
        M = (int)Math.Ceiling((double)N / 2);
        root = (int)Math.Ceiling((Math.Sqrt(N) + .1)) / 2;
        memo = new bool[M];
    }
    public void Run()
    {
        memo[0] = false;
        for (int i = 1; i < M; i++) memo[i] = true;
        list.Add(2);
        for (int i = 1; i < root; i++)
        {
            if (!memo[i]) continue;
            for (int j = 2 * i * (i + 1); j < M; j += (2 * i + 1)) memo[j] = false;
        }
        for (int i = 0; i < M; i++) if (memo[i]) list.Add(i * 2 + 1);
    }
    public bool IsPrime(int N)
    {
        return list.Contains(N);
    }
}
public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

Measured memory_bytes: 13780
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pii  = pair<int,int>;
#define rep(i,n) for(auto i=0; i<(n); i++)
#define rep2(i,x,n) for(auto i=x; i<(n); i++)
#define MOD 1000000007
#define INF 1e+9
#define MAX_V 10

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; }
const double PI = 3.141593;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}    //最大公約数
ll lcm(ll a,ll b) {return a * b / gcd(a, b);}   //最小公倍数
ll combination(ll n, ll r) {
  if ( r * 2 > n ) r = n - r;
  ll dividend = 1;
  ll divisor  = 1;
  for ( ll i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

ll n;
ll ans = 0;

int main() {
    cin >> n;
    ll a[n+10];
    rep(i,n)cin >> a[i];
    ll p = 1;
    rep(i, 61)
    {
        ll cnt = 0;
        rep(j,n){
            if((a[j]>>i)&1)
                cnt++;
        }
        if(i<25)
        ans += p*cnt*(n-cnt);
        else
        ans += ((((p%1000000007)*cnt)%1000000007)*(n-cnt))%1000000007;
        p *= 2;
    }
    cout << ans%1000000007 << endl;

    return 0;
}

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

int main() {
    int k, s;
    cin >> k >> s;

    int ans = 0;
    rep(x, k + 1) {
        rep(y, k + 1) {
            int z = s - x - y;
            ans += (0 <= z && z <= k);
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        int a,b,c,d,v1=0,v2=0;
        Scanner sc = new Scanner(System.in);
        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();
        d = sc.nextInt();
        v1= a*b;
        v2= c*d;
        if(v1>v2)
            System.out.println(v1);
        else if(v1<v2)
            System.out.println(v2);
        else if(v1==v2)
            System.out.println(v1);
    }  
}

Measured memory_bytes: 10316
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  if(n%1000!=0){
  int val = n/1000;
  val++;
  int ans = val*1000;
  cout<<(ans-n)<<endl;
  }
  else
    cout<<"0"<<endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)

int main(){
    int N;
    cin >> N;
    vector<int> L(N);
    int m = 0, sum =0;
    rep(i,0,N){
        cin >> L[i];
        m = max(m, L[i]);
        sum += L[i];
    }
    if(m >= sum - m) cout << "No" << endl;
    else cout << "Yes" << endl;
}

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

#define pb push_back
#define mp make_pair
#define F(i, a, n, b) for(int i=a;i<n;i+=b)
#define REVF(i, a, b, c) for(int i=a;i>=b;i-=c)
#define REP(i, n) F(i, 0, n, 1)
#define REP1(i, n) F(i, 1, n+1, 1)
#define REV(i, n) REVF(i, n, 0, 1)
#define PTR(it, x) for(auto it=x.begin();it!=x.end();++it)
#define REVPTR(it, x) for(auto it=x.rbegin();it!=x.rend();++it)
#define MOD 1000000007

typedef unsigned long long ll;

const int MAX = 2e6 + 5;

int n;
string s;
set<string> lst;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n;
	REP(i,n){
		cin>>s;
		lst.insert(s);
	}
	cout<<lst.size();
	return 0;
}

Measured memory_bytes: 19216
#include<iostream>
using namespace std;
int main(){
int a,b,c,d;
cin>>a>>b>>c;
if(a>b){d=a;a=b;b=d;}
if(b>c){d=b;b=c;c=d;}
if(a>b){d=a;a=b;b=d;}
cout<<a<<" "<<b<<" "<<c<<endl;
return 0;
}




















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Measured memory_bytes: 3092
def main():
    buf = input()
    N = int(buf)
    buf = input()
    buflist = buf.split()
    A = list(map(int, buflist))
    buf = input()
    buflist = buf.split()
    B = list(map(int, buflist))
    if sum(A) < sum(B):
        print(-1) # impossible
        return
    diff = []
    for i in range(N):
        diff.append(A[i] - B[i])
    diff = list(sorted(diff))
    insufficient_value = 0
    insufficient_count = 0
    for i in range(N):
        if diff[i] < 0:
            insufficient_value += -diff[i]
            insufficient_count += 1
    deduction_count = 0
    pointer = -1
    while insufficient_value > 0:
        insufficient_value -= diff[pointer]
        deduction_count += 1
        pointer -= 1
    print(insufficient_count + deduction_count)


if __name__ == '__main__':
    main()


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

typedef pair<int,int> pint; // (w, d)
bool cmp(pint a, pint b) { return a.first * a.second < b.first * b.second; }

int main() {
  int N, W, D;
  while (cin >> N >> W >> D, W) {
    vector<pint> res; res.push_back(pint(W, D));
    for (int xxx = 0; xxx < N; ++xxx) {
      int p, s; cin >> p >> s; --p;
      pint cur = res[p]; res.erase(res.begin() + p);
      pint ne[2];
      for (int i = 0; i < 2; ++i) ne[i].first = cur.first, ne[i].second = cur.second;
      s %= (cur.first + cur.second) * 2;
      if (s <= cur.first) ne[0].first = s, ne[1].first = cur.first - ne[0].first;
      else if (s - cur.first <= cur.second) ne[0].second = s-cur.first, ne[1].second = cur.second - ne[0].second;
      else if (s-cur.first-cur.second <= cur.first) ne[0].first = cur.first - (s-cur.first-cur.second), ne[1].first = cur.first - ne[0].first;
      else ne[0].second = (cur.first+cur.second)*2 - s, ne[1].second = cur.second - ne[0].second;
      if (ne[0] < ne[1]) res.push_back(ne[0]), res.push_back(ne[1]);
      else res.push_back(ne[1]), res.push_back(ne[0]);
    }
    sort(res.begin(), res.end(), cmp);
    for (int i = 0; i < res.size(); ++i) {
      cout << res[i].first * res[i].second;
      if (i != (int)res.size()-1) cout << " ";
    }
    cout << endl;
  }
}


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

int main(void)
{
    int k;
    string s;
    cin >> k >> s;
    if (s.size() > k)  {
        rep(i, k) cout << s[i];
        cout << "..." << endl;
        cout << endl;
    } else cout << s << endl;
}


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


int main() {
	
	int64_t x;
	cin >> x;
	int64_t y = x/11;
	if(x==y*11) cout << 2*y << endl;
	else if(x - y*11<=6) cout << 2*y+1 << endl;
	else cout << 2*y+2 << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt(), b = scanner.nextInt();
		String s = scanner.next();
		if(s.charAt(a) != '-' || s.length() != (a + b + 1)){
			System.out.println("No");
			return;
		}
		String left = s.substring(0, a);
		String right = s.substring(a+1, a+b+1);
		String regex = "[0-9]*";
		if(left.matches(regex) && right.matches(regex)){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 21844
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: ty),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn ulog2(u: u32) -> u32 {
    return (u as f64).log2().floor() as u32;
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, l: u32);
    let r = (l as f64).log2().floor() as u32;
    let mut ret = vec![];
    for i in 0..r {
        ret.push(format!("{} {} {}", i + 1, i + 2, 0));
        ret.push(format!("{} {} {}", i + 1, i + 2, 2usize.pow(i as u32)));
    }
    let mut cur = 2u32.pow(r);
    while cur < l {
        let t = ulog2(l - cur);
        ret.push(format!("{} {} {}", t + 1, r + 1, cur));
        cur += 2u32.pow(t);
    }
    println!("{} {}", r + 1, ret.len());
    for line in ret {
        println!("{}", line);
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 4476
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)

int main()
{
  string s;
  int size;
  cin >> s;
  size=s.length()-1;
  if(s[size]=='s')
    cout << s << "es\n";
  else
    cout << s << "s\n";
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
typedef long long ll;
#define INF 1e9
typedef vector<int> VI;
typedef vector<string> VS;
int main()
{
int a,b,c;
cin>>a>>b>>c;
if (a==5&&b==5&&c==7||a==5&&b==7&&c==5||a==7&&b==5&&c==5)
{
    cout<<"YES"<<endl;
}
else
{
    cout<<"NO"<<endl;
}


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;

struct edge { int to; int cost;
edge(int a, int b) {
	to = a; cost = b;
			}
};
typedef pair<int, int> P;//firstは最短距離、secondは頂点の番号

int V = 100001;//頂点の数
vector<edge> G[200001];//辺の情報！
int d[100001]; //sからnまでの最短コスト
int m[100001];//道しるべ

void dijkstra(int s) {//sがゴール
	priority_queue<P, vector<P>, greater<P>> que;
	fill(d, d + V, INF);//最短距離の初期化
	d[s] = 0;//開始位置
	que.push(P(0, s));//始点は距離０と考える

	while (!que.empty()) {
		P p = que.top(); que.pop();//キューの視点からの最短距離の頂点を取り出す
		int v = p.second;
		if (d[v] < p.first)continue;//既に最短距離がd[v]に記録されていたら飛ばす
		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];//頂点vを始点とした辺の構造体

			if (d[e.to] > d[v] + e.cost) {//辺の終点にある現時点での最短距離が今回追加するやつより大きいなら
				d[e.to] = d[v] + e.cost; //更新する
				m[e.to] = v;
				que.push(P(d[e.to], e.to));
			}
		}

	}

}

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

	int N, M; cin >> N >> M;
	FOR(i, 0, M) {
		int a, b; cin >> a >> b;
		edge c1(a, 1);
		edge c2(b, 1);
		G[a].emplace_back(b, 1);
		G[b].emplace_back(a, 1);
	}
	dijkstra(1);

	cout << "Yes" << endl;
	FOR(i, 2, N+1) {
		cout << m[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 15972
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
#include <climits>
#include <set>
#include <map>
using namespace std;

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

typedef long long ll;



int main()
{
    int n;
    string s, t;
    cin >> n >> s >> t;

    for(int i = 0; i < n; i++)
    {
        cout << s.at(i) << t.at(i);
    }

    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

int gcd(int a, int b)
{
    if (a < b)
        int c = a, a = b, b = c;
    return a % b == 0 ? b : gcd(b, a % b);
}

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

    int n, a[112345];

    cin >> n;
    REP(i, n)
    cin >> a[i];

    int res = a[0];

    REP(i, n)
    res = gcd(res, a[i]);

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
int (*rd)()=read<int>;
const u32 P=1e9+7;
inline u32 &inc(u32 &a, u32 b) {return (a+=b)<P?a:(a-=P);}
inline u32 &dec(u32 &a, u32 b) {return (a-=b)&0x80000000?(a+=P):a;}
inline u32 sum(u32 a, u32 b) {return (a+=b)<P?a:a-P;}
inline u32 dif(u32 a, u32 b) {return (a-=b)&0x80000000?a+P:a;}
u64 power(u64 a, int b) {
	u64 ans=1;
	for(; b; a=a*a%P, b/=2) if(b&1) ans=ans*a%P;
	return ans;
}

const int N=5005;

int p[N], pa[N], size[N];
u32 f[N], pwr[N], fac[N];
int find(int x) {
	return x==pa[x]?x:(pa[x]=find(pa[x]));
}
int main() {
	int n=rd(), k=0;
	u32 ans=n;
	for(int i=1; i<=n; ++i) {
		pa[i]=i;
		size[i]=1;
	}
	for(int i=1; i<=n; ++i) {
		p[i]=rd();
		if(p[i]!=-1) {
			if(find(p[i])!=i) {
				pa[i]=pa[p[i]];
				size[pa[i]]+=size[i];
			} else
				--ans;
		} else
			++k;
	}
	fac[0]=1;
	for(int i=1; i<=n; ++i) fac[i]=1llu*fac[i-1]*i%P;
	pwr[0]=1;
	for(int i=1; i<=k; ++i) pwr[i]=pwr[i-1]*(n-1llu)%P;
	f[0]=1;
	for(int i=1; i<=n; ++i) {
		if(p[i]==-1) {
			for(int j=i; j--; )
				f[j+1]=(f[j+1]+1llu*size[i]*f[j])%P;
		}
	}
	f[1]-=k;
	ans=1llu*ans*pwr[k]%P;
	for(int i=1; i<=n; ++i) {
		ans=(ans+1llu*(P-fac[i-1])*f[i]%P*pwr[k-i])%P;
	}
	printf("%u\n", ans);
	return 0;
}


Measured memory_bytes: 3880
def main():
    N = int(input())
    P = list(map(int, input().split()))
    diff = 0
    for p_org, p_sort in zip(P, sorted(P)):
        if p_org != p_sort:
            diff += 1
    if diff == 0 or diff == 2:
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> llVEC;
typedef vector<P> PVEC;
typedef priority_queue<P,PVEC,greater<P> > PPQ;
typedef priority_queue<ll, llVEC, greater<ll> > llPQ;

#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n-1; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue;
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> vec){ return (ll)vec.size(); }
ll sz(string s){ return (ll)s.size(); }

ll gcd(ll a,ll b){ return ((!b) ?a :gcd(b, a%b)); }

int main(){
    ll n,m,r;
    cin >> n >> m >> r;
    
    ll d[n][n] = {};
    rep(i,0,n) rep(j,0,n) if(i != j) d[i][j] = LINF;

    ll memo[r] = {};
    rep(i,0,r){
        cin >> memo[i];
        memo[i]--;
    }

    rep(i,0,m){
        ll a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        d[a][b] = c;
        d[b][a] = c;
    }
    rep(k,0,n) rep(i,0,n) rep(j,0,n) d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
    
    ll dp[(ll)pow(2,r)][r] = {};
    rep(i,1,(ll)pow(2,r)) rep(j,0,r) dp[i][j] = LINF;

    rep(i,0,r) dp[(1 << i)][i] = 0;
    
    rep(i,0,pow(2,r)){
        rep(j,0,r){
            rep(k,0,r){
                if((i >> k) & 1) continue;
                dp[i | (1 << k)][k] = min(dp[i | (1 << k)][k],dp[i][j] + d[memo[j]][memo[k]]);
            }
        }
    }
    
    ll ans = LINF;
    rep(i,0,r) ans = min(ans,dp[(ll)pow(2,r)-1][i]);

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


Measured memory_bytes: 4284
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll a,b;
int32_t main(){
CODE_START;
cin>>a>>b;
if(b>=a){
    cout<<"unsafe"<<endl;
}else cout<<"safe"<<endl;
}


Measured memory_bytes: 3644