akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, M, V, P;
  cin>>N>>M>>V>>P;
  vector<ll> A(N);
  for(int i=0;i<N;++i) cin>>A[i];
  sort(A.begin(), A.end());
  ll l=0, r=N-1, m;
  ll score;
  bool can;
  while(l<r){
    m = (l+r)/2;
    if(m>=N-P){
      r = m;
      continue;
    }
    score = M*V;
    score -= M*(m+1);
    score -= M*(P-1);
    can = true;
    for(int i=m+1;i<=N-P;++i){
      if(A[m]+M<A[i]) can = false;
      score -= A[m]+M-A[i];
    }
    if(can && score<=0){
      r = m;
    }
    else{
      l = m+1;
    }
  }
  cout<<N-l<<endl;
}



Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  ll Q,H,S,D;cin >> Q >> H >> S >> D;
  ll N;cin >> N;
  H = min(H,2*Q);
  S = min(S,2*H);
  D = min(D,2*S);
  cout << D*(N/2) + S*(N%2) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>

using namespace std;

typedef long int lint;
typedef long long int llint;

#define INF 1073741824
#define LINF 4611686018000000000

int n, w;

llint dp[110][110000], we[110], v[110];

int main() {
    cin >> n >> w;
    for (int i = 1; i <= n; i++) {
        cin >> we[i] >> v[i];
    }

    for (int i = 1; i < 110000; i++) {
        dp[0][i] = LINF;
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j < 110000; j++) {
            dp[i][j] = dp[i - 1][j];
            if (j - v[i] >= 0) {
                dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i]] + we[i]);
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < 110000; i++) {
        if (dp[n][i] <= w) {
            ans = max(ans, i);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 88320
import java.util.Scanner;

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

        long a = sc.nextLong();
        long b = sc.nextLong();
        long x = sc.nextLong();

        System.out.println(solve(a, b, x));

        sc.close();
    }

    static long solve(long a, long b, long x) {
        return b / x - (a + x - 1) / x + 1;
    }
}

Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

void solve(ll n, ll m) {
    const ll inf = LONG_LONG_MAX / 2 - 1;
    vector<ll> c(m), x(n);
    rep(i, m) cin >> c[i];
    rep(i, n) cin >> x[i];
    vector<vector<ll>> dp(n + 1, vector<ll>(256, inf));
    dp[0][128] = 0;
    rep(i, n) {
        rep(j, 256) {
            if (dp[i][j] == inf) continue;
            rep(k, m) {
                ll idx = j + c[k];
                idx = max(idx, 0LL);
                idx = min(idx, 255LL);
                ll val = dp[i][j] + (x[i] - idx) * (x[i] - idx);
                dp[i + 1][idx] = min(dp[i + 1][idx], val);
            }
        }
    }
    ll ans = LONG_LONG_MAX;
    rep(i, 256) ans = min(ans, dp[n][i]);
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    while(true) {
        ll n, m;
        cin >> n >> m;
        if ((n == 0) && (m == 0)) break;
        solve(n, m);
    }
    return 0;
}



Measured memory_bytes: 43928
#include<stdio.h>
#define N 25
#define NIL -1

struct Node{
  int p, l, r;
};

struct Node T[N];
int n;

void preParse(int); 
void inParse(int);
void postParse(int);

int main(){
  int i, v, l, r, root;
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) {
    T[i].p = NIL;
  }

  for ( i = 0; i < n; i++ ){
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if ( l != NIL ) T[l].p = v;
    if ( r != NIL ) T[r].p = v;
  }

  for ( i = 0; i < n; i++ ){
    if ( T[i].p == NIL ){
      root = i;
    }
  }
  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}

void preParse(int u){
  if ( u == NIL ) return;
  printf(" %d", u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if ( u == NIL ) return;
  inParse(T[u].l);
  printf(" %d", u);
  inParse(T[u].r);
}

void postParse(int u){
  if ( u == NIL ) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d", u);
}

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

using namespace std;
using ll = long long;
#define int ll

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define PB push_back

const double EPS = 1e-10;

using R = long double;
using P = complex<R>;
using L = pair<P,P>;
struct S : public L {
  S() {}
  S(const P &a, const P &b) : L(a,b) {}
};

inline int sgn(const R& r) { return (r>EPS) - (r<-EPS); }
inline R det(const P& a, const P& b) {
  return real(a)*imag(b) - imag(a)*real(b);
}
inline P vec(const L& l) {return l.second - l.first;}
namespace std {
	bool operator < (const P& a, const P& b) {
		return sgn(real(a-b)) ? real(a-b) < 0 : sgn(imag(a-b)) < 0;
	}
	bool operator == (const P& a, const P& b) {
		return sgn(real(a-b)) == 0 && sgn(imag(a-b)) == 0;
	}
}

// P,L,Sについて入力
inline istream& operator>>(istream& is, P& p) {
  R x, y;
  is >> x >> y;
  p = P(x, y);
  return is;
}
inline istream& operator>>(istream& is, L& l) {
  P a, b;
  is >> a >> b;
  l = L(a, b);
  return is;
}
inline istream& operator>>(istream& is, S& s) {
  P a, b;
  is >> a >> b;
  s = S(a, b);
  return is;
}

enum CCW{LEFT=1, RIGHT=2, BACK=4, FRONT=8, ON_SEG=16};
int ccw(P a, P b, P c) {
	P p = (c-a)/(b-a);
	if(sgn(imag(p)) > 0) return LEFT;
	if(sgn(imag(p)) < 0) return RIGHT;
	if(sgn(real(p)) < 0) return BACK;
	if(sgn(real(p)-1) > 0) return FRONT;
	return ON_SEG;
}

template<bool strict=false> inline bool intersect(const S&s1, const S&s2) {
  int ccw1 = ccw(s1.first, s1.second, s2.first) | ccw(s1.first, s1.second, s2.second);
  int ccw2 = ccw(s2.first, s2.second, s1.first) | ccw(s2.first, s2.second, s1.second);
  if(strict) return (ccw1 & ccw2) == (LEFT | RIGHT);
  return (ccw1 & ccw2) == (LEFT | RIGHT) || ((ccw1 | ccw2) & ON_SEG);
}

inline P crosspoint(const L& l1, const L& l2) {
  R ratio = det(vec(l2), l2.first-l1.first)/det(vec(l2),vec(l1));
  return l1.first + vec(l1)*ratio;
}

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

  while(true) {
    int n;
    cin >> n;
    if(!n) break;
    S s[105];
    REP(i, n) cin >> s[i];

    int ret = 2;
    FOR(i, 1, n) {
      vector<P> v;
      int tmp = 0;
      REP(j, i) {
        if(!intersect<true>(s[i], s[j])) continue;
        P c = crosspoint(s[i], s[j]);
        bool flag = true;
        for(auto k: v) {
          if(k == c) {
            flag = false;
            break;
          }
        }
        if(flag) {
          v.PB(c);
          tmp++;
        }
      }
      ret += tmp + 1;
    }

    cout << ret << endl;
  }

  return 0;
}



Measured memory_bytes: 3108
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
#include<cstdlib>
#include<typeinfo>
#define int long long int

using namespace std;
#define INF 1000000005

signed main()
{

std::string str;
std::cin >> str;
int l = str.length();
int num[4];
for(int i = 0; i < 4; i++){
    num[i] = (int)(str[i] - '0');
}
int flag = 0;
int count = 0;
while(count < 8){
    int temp = num[0];
    for(int i = 0; i < 3; i++){
        if(count & (1 << i)){
            temp += num[i + 1];
        } else {
            temp -= num[i + 1];
        }
    }
    if(temp == 7){
        flag = 1;
        break;
    }
    count++;
}
std::cout << num[0];
for(int i = 0; i < 3; i++){
    if(count & (1 << i)){
        std::cout << '+';
    } else {
        std::cout << '-';
    }
    std::cout << num[i + 1];
}
std::cout << "=7" << std::endl;

return 0;
}

Measured memory_bytes: 384
import math
X = int(input())
def prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

p = X
while True:
    Bool = prime(p)
    if Bool:
        break
    p += 1
    
print(p)

Measured memory_bytes: 38384
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static final int INF = Integer.MAX_VALUE;
	static int N = Integer.parseInt(sc.next());
	static int W = Integer.parseInt(sc.next());
	static int V = N*1000;
	static int[] w = new int[N];
	static int[] v = new int[N];
	static long[][] dp = new long[N+1][V+1];
	static {
		Arrays.stream(dp).parallel().forEach(i -> Arrays.fill(i, INF));
		dp[0][0] = 0;
	}
	public static void main(String[] args) {
		for (int i = 0; i < N; i++) {
			w[i] = Integer.parseInt(sc.next());
			v[i] = Integer.parseInt(sc.next());
		}
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < V+1; j++) {
				if (j-v[i]>=0) {
					dp[i+1][j] = Math.min(dp[i][j], dp[i][j-v[i]]+w[i]);
				} else {
					dp[i+1][j] = dp[i][j];
				}
			}
		}
		int ans = -1;
		for (int j = 0; j < V+1; j++) {
			if (dp[N][j] <= W) {
				ans = j;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 132436
#include<iostream>
using namespace std;
int main(){
  int m[100],a[100],b[100],c[200];
  int i,j,s,n,f;  
  while(1){ 
 cin>>n;
 if(n==0)break;
 f=0;
  for(i=0;i<n;i++){
   cin>>m[i]>>a[i]>>b[i];
   c[2*i]=a[i];
   c[2*i+1]=b[i];
  }
  for(i=0;i<2*n;i++){
    s=0;
    for(j=0;j<n;j++){
      if(a[j]<=c[i]&&c[i]<b[j])s+=m[j];
      if(s>150){
	f=1;
	break;
      }
    }
    if(f==1)break;
  }
  if(f==1)cout<<"NG"<<endl;
  else cout<<"OK"<<endl;
  } 
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<int, int>;

#define INF 1001001001

struct Edge {
  int to;
  int cost;
};

int main() {
  int n, m, r;
  cin >> n >> m >> r;
  vector< vector<Edge> > G(n);
  rep(i,m) {
    int s, t, d;
    cin >> s >> t >> d;
    G[s].push_back(Edge({t,d}));
  }

  vector<int> d(n,INF);
  d[r] = 0;
  priority_queue<P, vector<P>, greater<P> > q;

  q.push({0,r});
  while (!q.empty()) {
    int c, v;
    tie(c,v) = q.top(); q.pop();
    if (d[v] < c) continue;
    for (auto e : G[v]) {
      if (d[e.to] <= c + e.cost) continue;
      d[e.to] = min(d[e.to], c+e.cost);
      q.push({d[e.to],e.to});
    }
  }
  rep(i,n) {
    if (d[i]==INF) cout << "INF" << endl;
    else cout << d[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 13068
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define max(x,y)(x>y?x:y)
#define min(x,y)(x>y?y:x)
#define MOD (int)1e9+7
int dx4[]={1,0,-1,0};
int dy4[]={0,-1,0,1};
typedef long long int ll;
typedef unsigned long long int ull;
ll gcd(ll x,ll y){if(!y)return x;return gcd(y,x%y);}
ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
void swap(ll *x,ll *y){ll tmp=*x;*x=*y;*y=tmp;}
int asc_cmp(const void* X,const void* Y){ll x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp(const void* X,const void* Y){ll x=*(int*)X,y=*(int*)Y;if(x<y)return 1;else if(x==y)return 0;else return -1;}
typedef struct pair_{
    int x;
    int y;
}pair_t;

int main(){
    ll a,b,c;scanf("%lld %lld %lld",&a,&b,&c);
    ll tmp=(c-a-b);
    if(a+b>=c){
        printf("No\n");
        return 0;
    }
    tmp*=tmp; 
    ll tmp1=4*a*b;
    //printf("%lld %lld\n",tmp,tmp1);
    printf("%s\n",tmp1<tmp?"Yes":"No");
    
}


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

void Main() {
    int N, M;
    cin >> N >> M;
    vector<int> c(N);
    int a, b;
    for (int i = 0; i < M; i++) {
        cin >> a >> b;
        c.at(a - 1) += 1;
        c.at(b - 1) += 1;
    }
    for (auto &&i : c) {
        cout << i << endl;
    }
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}

Measured memory_bytes: 256
import collections

n = int(input())
V = list(map(int, input().split()))

V_odd = [V[i] for i in range(0, n, 2)]
V_even = [V[i] for i in range(1, n, 2)]

c_odd = collections.Counter(V_odd)
c_even = collections.Counter(V_even)

list_odd = []
list_even = []

for k, v in c_odd.items():
    list_odd.append([v, k])
list_odd = sorted(list_odd, reverse=True)

for k, v in c_even.items():
    list_even.append([v, k])
list_even = sorted(list_even, reverse=True)

if list_odd[0][1] == list_even[0][1]:
    if len(list_odd) == 1:
        print(n - list_even[0][0])
    elif len(list_even) == 1:
        print(n - list_odd[0][0])
    else:
        print(min(n - list_odd[0][0] - list_even[1][0],
                  n - list_odd[1][0] - list_even[0][0]))
else:
    print(n - list_odd[0][0] - list_even[0][0])


Measured memory_bytes: 24888
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> P;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<62;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<ll,ll,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll poc(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    string s;cin>>s;
    string t;cin>>t;
    t=t.substr(0,s.size());
    if(s==t)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> a(3*N);
  for(int i = 0; i < 3*N; ++i) cin >> a[i];
  sort(a.begin(),a.end());
  int id = 3*N-2;
  long long int ans = 0;
  for(int i = 0; i < N; ++i){
    ans += a[id];
    id -= 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>

int main()
{
    int A, B, C;
    std::cin >> A >> B >> C;

    int ans = B / A;
    if (ans >= C)
    {
        std::cout << C << std::endl;
    }
    else
    {
        std::cout << ans << std::endl;
    }

    return 0;
}


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

int main() {
  int N, D, X;
  cin >> N >> D >> X;
  int answer = 0;
  rep(i,N) {
    int A;
    cin >> A;
    answer += 1 + (D-1)/A;
  }
  answer += X;
  
  cout << answer << endl;
}

Measured memory_bytes: 256
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

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

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string& S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
int n;
int bit[100010];
void add(int v, int x) {

	while (v <= n)
	{
		bit[v] += x;
		v += v & -v;
	}
}

ll sum(int v) {
	ll r = 0;
	while (v > 0)
	{
		r += bit[v];
		v -= v & -v;
	}
	return r;
}

void solv() {
	int a,b;
	cin >> a >> b;
	cout << (a * b) << " " << (2 * a + 2 * b) << endl;

}


int main() {
	//	COMinit();
	solv();

	return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}

constexpr ll LNF = 1LL<<50;

constexpr int INF = 1e9+7;

const long double PI=3.14159265358979323846;


vector<int> dx = {1,0,-1,1,-1,0};
vector<int> dy = {1,1,1,0,0,-1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a,v;
    ll b,w;
    cin >> a >> v >>b >> w;
    ll t; cin >> t;
    ll p = v-w;
    ll x = abs(b-a);
    if(p<=0){
        cout << "NO" << endl;
    }
    else if((x+p-1)/p <=t){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 3652
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
#include <numeric>
using namespace std;

#define REP(i,b,n) for(int (i)=b; (i)<(int)(n); ++(i))
#define rep(i,n) REP(i,0,n)
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define all(a) (a).begin(),(a).end()
#define print(var) cout<<#var":"<<(var)<<endl;
#define printkv(key,var) cout<<#key":"<<(var)<<endl;
#define updatemax(dst,src) dst=max(dst,src);
#define updatemin(dst,src) dst=min(dst,src);

typedef long long ll;

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
  if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}

int N;
string s[52];

string solve() {
  int mincnt[30];
  int cnt[30];

  rep(i,30) mincnt[i] = 100;

  rep(i,N) {
    memset(cnt, 0, sizeof cnt);
    int M = s[i].size();
    rep(j,M) {
      cnt[ s[i][j] - 'a' ]++;
    }
    rep(j,30) {
      mincnt[j] = min(mincnt[j], cnt[j]);
    }
  }

  string ret;
  rep(i,30) {
    rep(j,mincnt[i]) {
      ret += ('a' + i);
    }
  }

  return ret;
}

int main() {
  while (cin>>N) {
    rep(i,N) cin>>s[i];
    cout<<solve()<<endl;
  }
  return 0;
}


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

using namespace std;

int main() {
  int N;
  cin >> N;
  if (N < 10) {
    cout << N << endl;
    return 0;
  }
  int64_t res = 0;
  vector<vector<int64_t>> cnt(10, vector<int64_t>(10));
  for (int i = 1; i <= N; ++i) {
    string str = to_string(i);
    int head = str.front() - '0';
    int tail = str.back() - '0';
    ++cnt[head][tail];
  }
  for (int i = 1; i <= 9; ++i) {
    for (int j = 1; j <= 9; ++j) {
      res += cnt[i][j] * cnt[j][i];
    }
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 3668
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int n, q;
ll s, t;
ll a[200005] = { 0 };
ll sa[200005] = { 0 };
ll cdeg = 0;
int main() {
	cin >> n >> q >> s >> t;
	for (int i = 0; i <= n; i++) cin >> a[i];
	cdeg = 0;
	for (int i = 1; i <= n; i++) {
		sa[i] = a[i] - a[i - 1];
		//cout << sa[i] << endl;
		if (sa[i]>0) {
			cdeg -= s * sa[i];
			//cout << " " << s * sa[i] << endl;
		}
		if(sa[i]<0) {
			cdeg += t * abs(sa[i]);
			//cout << " " << t * abs(sa[i]) << endl;
		}
		//cout <<" "<< cdeg << endl;
	}
	for (int i = 0; i < q; i++) {
		int l, r;
		ll x;
		cin >> l >> r >> x;
		ll nl = sa[l] + x;
		ll a, b;
		if (sa[l]>0) a = -1 * s*sa[l];
		else a = abs(sa[l])*t;
		if (nl>0) b = -1 * s*nl;
		else b = abs(nl)*t;
		cdeg += (b - a);
		sa[l] = nl;
		if (r != n) {
			ll nr = sa[r + 1] - x;
			if (sa[r + 1]>0) a = -1 * s*sa[r + 1];
			else a = abs(sa[r + 1])*t;
			if (nr>0) b = -1 * s*nr;
			else b = abs(nr)*t;
			cdeg += (b - a);
			sa[r + 1] = nr;
		}
		cout << cdeg << endl;
	}
}



Measured memory_bytes: 6260
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w,k,sum=0,sum1=0,sum2=0,ans=0,flg;
    char masu[10][10];
    int tate[10]={};
    int yoko[10]={};
    queue <int>que;
    cin>>h>>w>>k;

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin>>masu[i][j];
            if(masu[i][j]=='#'){
                yoko[i]++;
                tate[j]++;
                sum++;
            }
        }
    }

    for(int i=0; i< 1<<h; i++){
        
        sum1=0;
        for(int k=0; k<h; k++){
            if(i & (1<<k)){
                sum1+=yoko[k];
            }
        }

        for(int j=0; j< 1<<w; j++){
            
            sum2=0;
            for(int l=0; l<w; l++){
                    if(j & (1<<l)){
                        sum2+=tate[l];
                    }
            }

            for(int k=0; k<h; k++){
                if(i & (1<<k)){
                    for(int l=0; l<w; l++){
                        if(j & (1<<l)){
                            if(masu[k][l]=='#')sum2--;
                        }
                    }    
                }
            }

            if((sum-(sum1+sum2))==k){
                ans++;
            }
        
        }
    }

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

Measured memory_bytes: 3636
var n,i,j,t,k,re,sum:integer;
begin
    readln(n,k);
    t:=(n-1)*(n-2) div 2;
    if t>=k then
      begin
        sum:=n - 1 + t - k;
        i:=1; re:=0;
        writeln(sum);
        while (i<n) and (sum<>re) do
          begin
            j:=i+1;
            while (j<=n) and (sum<>re) do 
              begin
                writeln(i,' ',j);
                inc(j);
                inc(re);
              end;
            inc(i);
          end;
      end
    else write(-1);
end.

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(500000)

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    A, B, C = mi()
    for i in range(B):
        if (A*i)%B == C:
            print('YES')
            return
    print('NO')

if __name__ == '__main__':
    main()


Measured memory_bytes: 61852
#include<bits/stdc++.h>
#define ll long long
#define loop(n) for(ll i = 0; i<n; i++)
#define sort(a) sort(a.begin(), a.end())
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    ll n,x ; cin>>n;
    set<ll> s;
    bool ok = 1;
    loop(n){
        cin>>x;
        if(s.count(x)) ok = false;
        else s.insert(x);
    }

    if(ok) cout<<"YES\n";
    else cout<<"NO\n";
    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
 using namespace std;
 #define rep(i,N) for(int i=0;i<int(N);++i)
 using ll = long long;
 const int MOD = 1e9 + 7;
 const int INF = 2147000000;
 // const ll INF = 1000000000000000000LL;
 
 struct UnionFind {
     //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
     //そうでなければ親のid
     vector<int> r;
  
     UnionFind(int N) {
         r = vector<int>(N, -1);
     }
  
     int root(int x) {
         if (r[x] < 0) return x;
         return r[x] = root(r[x]);
     }
  
     bool unite(int x, int y) {
         x = root(x);
         y = root(y);
         if (x == y) return false;
         if (r[x] > r[y]) swap(x, y);
         r[x] += r[y];
         r[y] = x;
         return true;
     }
  
     int size(int x) {
         return -r[root(x)];
     }
 };


 int main(){
     ll n,m;
     cin >> n >> m;
     vector<ll> a(m);
     vector<ll> b(m);
     rep(i,m){
         cin >> a[i] >> b[i];
     }
     UnionFind tree(n);
     for(int i=0;i<m;i++){
         int A,B;
         A = a[i];
         A-=1;
         B = b[i];
         B-=1;
         tree.unite(A,B);
     }
     int ans = 0;
     for(int i=0;i<n;i++){
         if(tree.r[i]<0)
            ans++;
     }
     cout << ans-1 << endl;
     return 0;
 }

Measured memory_bytes: 5108
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
using namespace std;

const double pi = acos(-1);
#define nyan cout<<"(=^•ω•^=)"<<endl;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)

int gcd(int i, int j){
    while(true){
        if(i<j)swap(i,j);
        if(!j)break;
        i%=j;
    }
    return i;
}

signed main(){
    int x,y;
    cin>>x>>y;
    cout<<gcd(x,y)<<endl;
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define PP pair<P,P>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	random_device rnd;
	mt19937_64 mt64(rnd());
	uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/

int n, ans;
signed main() {
	cin >> n;
	rep(i, n) {
		int a; cin >> a; ans += a - 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
h = w = 0
slist =[]
list1=[]
def dfs(f):
    while True:
        if len(slist) == 0:
            return 1
        coordinate= slist.pop()
        #print(coordinate)
        x = coordinate[0]
        y = coordinate[1]

        list1[y] = list1[y][:x] + '1' + list1[y][x + 1:]
        if x + 1 < w:
            if list1[y][x + 1] == f:
                slist.append([x + 1,y])
        if x - 1 >= 0:
            if list1[y][x-1] == f:
                slist.append([x - 1, y])
        if y + 1 < h:
            if list1[y + 1][x] == f:
                slist.append([x, y + 1])
        if y -1 >= 0:
            if list1[y -1][x] == f:
                slist.append([x, y - 1])

while True:
    h, w = list(map(lambda x: int(x),input().split(" ")))
    if 0 in (h, w):
        break
    n = 0
    for i in range(0, h):
        list1.append(input())
    for i in range(0, h):
        for j in range(0, w):
            if list1[i][j] != '1':
                slist.append([j,i])
                n += dfs(list1[i][j])
            #print(list1)
    print(n)
    list1=[]

Measured memory_bytes: 8776
#include <stdio.h>
int main(void){
    int H,W,N;
    scanf("%d %d %d",&H,&W,&N);
    int iro[H][W];
    int x=0;
    int y=0;
    for(int i=0;i<N;i++){
        int kari;
        scanf("%d",&kari);
        for(int j=0;j<kari;j++){
            iro[x][y]=i+1;
            if(y%2==0&&x!=H-1)x++;
            else if(y%2==0&&x==H-1)y++;
            else if(y%2==1&&x!=0)x--;
            else if(y%2==1&&x==0)y++;
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++)printf("%d ",iro[i][j]);
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 256
n,*a=map(int,open(0))
c=0
for i in range(n-1,0,-1):
  if a[i]-a[i-1]>1:
    print(-1)
    exit()
  if a[i]<=a[i-1]:
    c+=a[i]
  else:
    c+=1
print(-(a[0]>0)or c)

Measured memory_bytes: 57436
import sys
readline = sys.stdin.readline

N = int(readline())

ans = 0
dp = [2] * (N + 1)
dp[0] = 0
dp[1] = 1
ans = 1
for i in range(2,len(dp)):
  ans += dp[i] * i
  for j in range(i * 2,len(dp),i):
    dp[j] += 1

print(ans)

Measured memory_bytes: 146232
#include <stdio.h>

int main(void){
  int N;
  int M;
  int X;
  int A[100];
  int i, j, k;
  int count1 = 0;
  int count2 = 0;
  scanf("%d %d %d", &N, &M, &X);
  for(i = 0; i < M; i++){
    scanf("%d", &A[i]);
  }
  for(i = 0; i < M; i++){
    if(A[i] < X){
      count1++;
    }
    if(A[i] > X){
      count2++;
    }
  }
  if(count1 < count2){
    printf("%d\n", count1);
  }else{
    printf("%d\n", count2);
  }
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

#define REP(i, N) for (int i = 0; i < N; i++)
#define REP1(i, N) for (int i = 1; i < N; i++)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ANS(a) cout << a << endl;
#define SORT(V) sort(V.begin(), V.end())
#define RSORT(V) sort(V.rbegin(), V.rend())

#define DBG(V) for (auto v : V) cout << v << " "; cout << endl

int
main()
{
  int N; cin >> N;
  vector<int> A, B;
  vector<int> cntA(100001, 0);
  vector<int> cntB(100001, 0);

  for (int i = 0; i < N; i += 2) {
    int tmp0, tmp1;
    cin >> tmp0 >> tmp1;
    ++cntA[tmp0];
    ++cntB[tmp1];
  }

  int ans, maxA, maxB;
  auto i_maxA = max_element(cntA.begin(), cntA.end());
  maxA = *i_maxA;
  auto i_maxB = max_element(cntB.begin(), cntB.end());
  maxB = *i_maxB;
  if (distance(cntA.begin(), i_maxA) == distance(cntB.begin(), i_maxB)) {
    *i_maxA = 0;
    *i_maxB = 0;
    i_maxA = max_element(cntA.begin(), cntA.end());
    i_maxB = max_element(cntB.begin(), cntB.end());
    
    if (maxA == maxB) {
      if (*i_maxA > *i_maxB) {
	maxA = *i_maxA;
      } else {
	maxB = *i_maxB;
      }
    } else if (maxA < maxB) {
      maxA = *i_maxA;
    } else {
      maxB = *i_maxB;
    }
  }
  ans = N - maxA - maxB;

  ANS(ans);

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a+b==c+d){
        printf("Balanced");
    }else if(a+b>c+d){
        printf("Left");
   }else{
       printf("Right");
   }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
ll f(ll n){
    return (n*n + 4) / 8;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    rep(i,0,s.size()){
        if(i % 2 == 0) cout << s[i];
    }
    cout << endl;

}

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

int main()
{
  int N,K;
  long ans=0;
  long HP[200010]={0};
  cin>>N>>K;
  for(int i=0;i<N;i++)cin>>HP[i];
  sort(HP,HP+N,greater<long>());
  for(int i=K;i<N;i++)ans+=HP[i];
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.Scanner;

//The First Acceptance
public class Main{

	class R implements Comparable<R>{
		int a, b;
		public R(int a, int b) {
			this.a = a;
			this.b = b;
		}
		public int compareTo(R o) {
			return b-o.b;
		}
	}
	
	int n;
	
	void run(){
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		R[] r = new R[n];
		for(int i=0;i<n;i++)r[i]=new R(sc.nextInt(), sc.nextInt());
		Arrays.sort(r);
		int[][] dp = new int[n][n+1];
		for(int[] a:dp)Arrays.fill(a, 1<<30);
		dp[0][1] = r[0].a<=r[0].b?r[0].a:(1<<30);
		for(int i=0;i<n;i++)dp[i][0] = 0;
		for(int i=1;i<n;i++){
			for(int j=1;j<=i+1;j++){
				if(dp[i-1][j-1]+r[i].a<=r[i].b)dp[i][j]=Math.min(Math.min(dp[i][j], dp[i-1][j]), dp[i-1][j-1]+r[i].a);
				else dp[i][j] = dp[i-1][j];
				
			}
		}
//		for(int i=0;i<n;i++)for(int j=1;j<=n;j++)System.out.println("I: " + i + " J:" + j + " MIN:" + dp[i][j]);
		for(int j=n;j>=0;j--){
			if(dp[n-1][j]!=1<<30){
				System.out.println(j);
				break;
			}
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
#include <bitset>
#include <string>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#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 REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define all(x) (x).begin(),(x).end()
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)


ll modpow(ll x, ll n) {
    if (n == 0) {
        return 1;
    } else if (n % 2 == 0) {
        ll h = modpow(x, n / 2);
        return h * h % MOD;
    } else {
        return x * modpow(x, n - 1) % MOD;
    }
}

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

int vector_finder(vector<int> vec, int number) {
  auto itr = find(vec.begin(), vec.end(), number);
  size_t index = distance(vec.begin(), itr);
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
    int H, W; cin >> H >> W;
    vector<string> s(H);
    rep(i, H) cin >> s[i];
    int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
    reps(i, H-2){
      reps(j, W-2){
        int cnt = 0;
        if (s[i][j] != '#') continue;
        rep(k, 4){
          if (s[i+dy[k]][j+dx[k]] == '#')  cnt++;
        }
        if (cnt == 0){
          cout << "No" << endl;
          return 0;
        }
      }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

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

	ll a,b,c,k;
	cin >> a >> b >> c >> k;
	if(k%2 == 0) cout << a-b << endl;
	else         cout << b-a << endl;
}

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

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

int main(){
  string s;
  int a;
  cin >> s;
  a = s.size();
  for (int i = 0; i < a; i++){
    for (int j = 0; j < i; j++){
      if (s[i] == s[j]){
        cout << "no\n";
        return 0;
      }
    }
  }
  cout << "yes\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int f(int n)
{
    return n == 1 ? 14 : n;
}

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int a, b;
    cin >> a >> b;
    if (f(a) > f(b))
        cout << "Alice";
    else if (f(a) < f(b))
        cout << "Bob";
    else
        cout << "Draw";
    cout << endl;
    return 0;
};


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

int maxtime(int x){
  return (x+9)/10*10;
}

int remtime(int x){
  return maxtime(x)-x;
}

int main(){
  int a[5],sum=0,ans;
  for(int i=0; i<5; i++){
    cin >> a[i];
  }
  for(int i=0; i<5; i++){
    sum += maxtime(a[i]);
  }
  ans = sum-max({remtime(a[0]),remtime(a[1]),remtime(a[2]),remtime(a[3]),remtime(a[4])});
                cout << ans << endl;
                }
  
  
  

Measured memory_bytes: 256
/* ex 7_3
   nnasy */

#include <stdio.h>
#include <stdlib.h>

int main(void){
    //宣言と入力
    int row, col;
    char **grid;
    int *judge_row, *judge_col;
    scanf("%d %d", &row, &col);

    //二次元配列領域および一次元配列領域の動的確保
    grid = (char**)calloc(row, sizeof(char*));
    if (grid == NULL){
        exit(1);
    }
    for (int i=0; i<row; i++){
        grid[i] = (char*)calloc(col, sizeof(char));
        if (grid[i] == NULL){
            exit(1);
        }
    }
    judge_row = (int*)calloc(row, sizeof(int));
    judge_col = (int*)calloc(col, sizeof(int));
    if ((judge_row == NULL) || (judge_col == NULL)){
        exit(1);
    }


    //マス目の記号を入力
    for (int i=0; i<row; i++){
        for (int j=0; j<col; j++){
            scanf(" %c", &grid[i][j]);
        }
    }

    //取り除く行および列を調べる
    for (int i=0; i<row; i++){
        for (int j=0; j<col; j++){
            if (grid[i][j] == '#'){
                judge_row[i]=1;
                judge_col[j]=1;
            }
        }
    }

    //各Judgeを用いて出力
    for (int i=0; i<row; i++){
        if (judge_row[i] == 1){
            for (int j=0; j<col; j++){
                if (judge_col[j] == 1){
                    printf("%c", grid[i][j]);
                }
            }
            printf("\n");
        }
    }

    //確保した配列の解放
    for (int i=0; i<row; i++){
        free(grid[i]);
    }
    free(grid);

    return 0;
}

Measured memory_bytes: 1660
import sys
sys.setrecursionlimit(10**7)
 
n=int(input())
l=[list(input()) for i in range(n)]
connection=[[] for i in range(n)]
for i in range(n):
  for j in range(n):
    if l[i][j]=='1':
      connection[i].append(j)
 
colors = [0]*n
def dfs(v,color):
    colors[v] = color
    for to in connection[v]:
        if colors[to] == color:
            return False
        if colors[to] == 0 and not dfs(to, -color):
            return False
    return True
 
def is_bipartite():
    return dfs(0,1)
if is_bipartite()==0:
  print(-1)
  sys.exit()
 

def bfs(v):
  distance=[-1]*n
  distance[v]=0
  next=connection[v]
  next2=set()
  visited=[-1]*n
  visited[v]=1
  visitct=1
  ct=0
  while visitct!=n:
    ct+=1
    for i in range(len(next)):
      distance[next[i]]=ct
      visited[next[i]]=1
      visitct+=1
      for j in range(len(connection[next[i]])):
        if visited[connection[next[i]][j]]==-1:
          next2.add(connection[next[i]][j])
    next=list(next2)
    next2=set()
    
  return distance

ans=[]
for i in range(n):
  ans.append(max(bfs(i)))
print(max(ans)+1)

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

using namespace std;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main()
{
	int X;
	cin >> X;

    while (!IsPrime(X))
    {
        X++;
    }

    cout << X << endl;

	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 REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();


int main() {
  int X, A, B;
  cin >> X >> A >> B;
  if (B - A <= 0) cout << "delicious";
  else if (B - A > X) cout << "dangerous";
  else cout << "safe";
  cout << endl;
}

Measured memory_bytes: 256
# import sys
# fin = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush


def initialize(adj, s):
    MAX_NUM = float('inf')
    parent = {s: None}
    d = {vertex: MAX_NUM for vertex in adj.keys()}
    d[s] = 0
    return d, parent


# Dijkstra can work using a minheap which does not have decrease_key.
# and also we do not have to implement Vertex class.
# Instead, we can use (distance, vertex).
# in this case, the time it takes is O(ElgE).
# E is at most O(V^2), thus O(ElgE) = O(ElgV).
def dijkstra_simple(adj, w, s):
    d, parent = initialize(adj, s)
    priority_queue = []
    heappush(priority_queue, (d[s], s))
    while priority_queue:
        distance, source = heappop(priority_queue) 
        for neighbor in adj[source]:
            new_distance = distance + w[(source, neighbor)]
            if new_distance < d[neighbor]:
                d[neighbor] = new_distance
                parent[neighbor] = source
                heappush(priority_queue, (new_distance, neighbor))
    return d


n, m, s, t = map(int, input().split())
adj = defaultdict(list)
yen_weights = dict()
snuuk_weights = dict()
for _ in range(m):
    u, v, a, b = map(int, input().split())
    for v1, v2 in [(u, v), (v, u)]:
        adj[v1].append(v2)
        yen_weights[(v1, v2)] = a
        snuuk_weights[(v1, v2)] = b

d_yen = dijkstra_simple(adj, yen_weights, s)
d_snuuk = dijkstra_simple(adj, snuuk_weights, t)
min_cost = float('inf')
min_cost_after_each_year_reversed = []
for vertex in range(n, 0, -1):
    min_cost = min(min_cost, d_yen[vertex] + d_snuuk[vertex])
    min_cost_after_each_year_reversed.append(min_cost)

initial_money = 10**15
print(*(initial_money - cost for cost in reversed(min_cost_after_each_year_reversed)), sep='\n')



Measured memory_bytes: 124568