akhauriyash/Code-Regression huggingface dataset:
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int m, n;
  cin >> m >> n;
  int maxi = 0;
  while (m--) {
    vi a(n);
    rep(i, n) cin >> a[i];
    cmax(maxi, accumulate(all(a), 0));
  }
  cout << maxi << endl;
}

Measured memory_bytes: 3080
#include <iostream>
#include <string>
using namespace std;
int main(int argc, const char * argv[]) {
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    if (s.size()!=6) {
        
    }else{
        if (s[2]==s[3]&&s[4]==s[5]) {
            cout<<"Yes";
        }else{
            cout<<"No";
        }
    }
    
    return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const int mod=1e9+7;
const ll inf = 1LL << 60;
const ld pi = (acos(-1));
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
   
  ll x; cin >> x;
  ll q=0,r=0;
  rep(i,-1000,1000){
  	rep(j,-1000,1000){
  		if(((ll)pow(i,5)-(ll)pow(j,5))==x){ q=i,r=j; break;}
  	}
  }
  cout << q << " " << r << endl;
}

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

int main()
{
    int n,k;
    cin>>n>>k;
    double mx,m;
    vector <int> p(n);
    vector <double> exp(n);

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

    for(int i=0;i<n;i++)
    {
        exp[i]=(double)(p[i]+1)/2;
    }

    queue <double> q;

    for(int i=0;i<n;i++)
    {
        m+=exp[i];
        q.push(exp[i]);
        if(q.size()>k)
        {
            m-=q.front();
            q.pop();
        }
        if(q.size()==k)
        {
            mx = max(mx,m);
        }
    }

    printf("%.8f",mx);

    return 0;
}

Measured memory_bytes: 4224
import numpy as np


def calc(ell: int, r: int) -> int:
    if ell % 2019 > r % 2019:  # 間に2019の倍数があるパターン1
        return 0
    if r >= ell + 2019:  # 間に2019の倍数があるパターン2
        return 0

    start = ell
    # stop = min(ell + 2019, r)
    stop = r

    searching_array = np.arange(start, stop, 1)
    searching_mat = np.tile(searching_array, (searching_array.shape[0], 1))
    searching_mat2 = searching_mat.T + 1
    seki = searching_mat * searching_mat2
    results = np.mod(seki, 2019)
    results_masked = results[searching_mat < searching_mat2]
    return results_masked.min()


def load_input_as_int_array():
    return [int(v) for v in input().split(" ")]


ell, r = load_input_as_int_array()
print(calc(ell, r))


Measured memory_bytes: 159492
#include<iostream>
#include<cstdio>
#define MN 3000
#define MX 32000
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,mod,p[MN+5],inv[MN+5],S[MN+5][MN+5],pw[MX+5],PW[MX+5],ans,ppw[MX+5],PPW[MX+5];
inline int C(int n,int m){return 1LL*p[n]*inv[m]%mod*inv[n-m]%mod;}
inline int pw2(int n){return 1LL*PW[n/MX]*pw[n%MX]%mod;}
inline int ppw2(int n){return 1LL*PPW[n/MX]*ppw[n%MX]%(mod-1);}
int main()
{
	n=read();mod=read();p[0]=inv[0]=p[1]=inv[1]=S[0][0]=pw[0]=PW[0]=ppw[0]=PPW[0]=1;
	for(int i=2;i<=n+1;++i) p[i]=1LL*p[i-1]*i%mod,inv[i]=1LL*(mod-mod/i)*inv[mod%i]%mod;
	for(int i=2;i<=n+1;++i) inv[i]=1LL*inv[i-1]*inv[i]%mod;
	for(int i=1;i<=n+1;++i) for(int j=1;j<=i;++j)
		S[i][j]=(S[i-1][j-1]+1LL*S[i-1][j]*j)%mod;
	for(int i=1;i<=MX;++i) pw[i]=2*pw[i-1]%mod,ppw[i]=2*ppw[i-1]%(mod-1);
	for(int i=1;i<=MX;++i) PW[i]=1LL*PW[i-1]*pw[MX]%mod,PPW[i]=1LL*PPW[i-1]*ppw[MX]%(mod-1);
	for(int i=0;i<=n;++i)
	{
		int res=0;
		for(int k=0;k<=i;++k)
			res=(res+1LL*S[i+1][k+1]*pw2(k*(n-i)))%mod;
		ans=(ans+1LL*res*C(n,i)%mod*((i&1)?mod-1:1)%mod*pw2(ppw2(n-i)))%mod;
	}
	cout<<ans;
	return 0;
}



Measured memory_bytes: 35072
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 2050;
const int K = 1e18;
const int M = 1e9;
const int mod = 1e9 + 7;
int n;
pair <int, int> a[N];
int dp[N][N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i].F;
        a[i].S = i;
    }
    sort(a + 1, a + n + 1);
    reverse(a + 1, a + n + 1);
    for (int i = 1; i <= n; i++){
        for (int j = 0; j <= i; j++){
            int x = a[i].F;
            int p = a[i].S;
            int l = j;
            int r = n - (i - j) + 1;
            if (l != 0) dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + x * abs(p - l));
            if (r != n + 1) dp[i][j] = max(dp[i][j], dp[i - 1][j] + x * abs(r - p));
        }
    }
    int ans = 0;
    for (int i = 0; i <= n; i++){
        ans = max(ans, dp[n][i]);
    }
    cout << ans;
}


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

//Recurring Decimals
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int[] a = new int[21];
			a[0] = sc.nextInt();
			int L = sc.nextInt();
			if((a[0]|L)==0)break;
			for(int i=1;i<=20;i++){
				String s = a[i-1]+"";
				while(s.length()<L)s+="0";
				char[] c = s.toCharArray();
				Arrays.sort(c);
				int min = 0, max = 0;
				for(int j=0;j<L;j++)min=min*10+(c[j]-'0');
				for(int j=L-1;j>=0;j--)max=max*10+(c[j]-'0');
				a[i] = max-min;
				boolean f = false;
				for(int j=i-1;j>=0;j--)if(a[i]==a[j]){
					f = true;
					System.out.println(j+" "+a[i]+" "+(i-j));
					break;
				}
				if(f)break;
			}
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

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

Node T[MAX];
int n, D[MAX];

void rec(int a, int d){
  D[a] = d;
  if (T[a].l != NIL) rec(T[a].l, d+1);
  if (T[a].r != NIL) rec(T[a].r, d);
}

void print(int a){
  int i, c;
  cout << "node " << a << ": ";
  cout << "parent = " << T[a].p << ", ";
  cout << "depth = " << D[a] << ", ";
  if (T[a].p == NIL) cout << "root, ";
  else if (T[a].l == NIL) cout << "leaf, ";
  else cout << "internal node, ";

  cout << "[";
  for (i=0, c = T[a].l; c != NIL; i++, c = T[c].r){
    if (i) cout << ", ";
    cout << c;
  }
  cout << "]" << endl;
}

int main(){
  int v, d, c, l, r;

  cin >> n;
  for (int i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;

  for (int i=0; i<n; i++){
    cin >> v >> d;
    for (int j=0; j<d; j++){
      cin >> c;
      if (j == 0) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[l].p = v;
    }
  }

  for (int i=0; i<n; i++) if (T[i].p == NIL) r = i;

  rec(r, 0);

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

  return 0;
}



Measured memory_bytes: 4624
#include<bits/stdc++.h>
#define INF (1e9)
#define N 305
#define L 16
using namespace std;

int main(){

  while(1){
    
    int n,m,l,s,t;
    cin>>n>>m>>l>>s>>t;
    
    if(!n&&!m&&!l&&!s&&!t)break;
    
    s--;

    int d[N][N];
    
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++) d[i][j]=INF;

    for(int i=0;i<n;i++) d[i][i]=0;
  
    for(int i=0;i<m;i++){
      
      int a,b,c;
      cin>>a>>b>>c;
      a--,b--;
      
      d[a][b]=d[b][a]=c;
    }

    for(int k=0;k<n;k++)
      for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
	  d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    
    int r[L],tim[L];
    
    for(int i=0;i<l;i++) cin>>r[i]>>tim[i],r[i]--;
    
    int dp[(1<<L)][L];

    for(int i=0;i<(1<<l);i++)
      for(int j=0;j<l;j++) dp[i][j]=INF;

    for(int i=0;i<l;i++)
      dp[(1<<i)][i]=min(dp[(1<<i)][i],d[s][r[i]]+tim[i]);
    
    int ans=0;
    
    for(int i=0;i<(1<<l);i++){
      for(int j=0;j<l;j++){
	
	if(dp[i][j]==INF) continue;
	
	if(dp[i][j]+d[r[j]][s]<=t)
	  ans=max(ans,__builtin_popcount(i));
	
	for(int k=0;k<l;k++){
	  
	  if(i&(1<<k))continue;
	  
	  dp[i|(1<<k)][k]=min(dp[i|(1<<k)][k],dp[i][j]+d[r[j]][r[k]]+tim[k]);
	
	}
      
      }
    }

    cout<<ans<<endl;

  }
  
  return 0;
}

Measured memory_bytes: 7460
#include<stdio.h>

int pt(int *,int ,int);

int main(){
  int a[100000],i,x,j;
  scanf("%d",&x);
  for(i=0;i<x;i++)
    scanf("%d",&a[i]);
  j=pt(a,0,x-1);
  for(i=0;i<x;i++){
    if(i==x-1)
      printf("%d\n",a[i]);
    else{
      if(i==j)
	printf("[%d] ",a[i]);
      else
	printf("%d ",a[i]);
    }
  }
  return 0;
}
int pt(int *a,int p,int r){
  int x,y,i,c;
  x=a[r];
  y=p-1;
  for(i=p;i<r;i++){
    if(a[i]<=x){
      y++;
      c=a[i];
      a[i]=a[y];
      a[y]=c;
    }
  }
  c=a[y+1];
  a[y+1]=a[r];
  a[r]=c;
  return ++y;
}
  



Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ll N;
    cin >> N;
    if ( N == 1 ) {
        cout << "Hello World" << "\n";
    } else {
        ll A, B;
        cin >> A >> B;
        cout << A + B << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int mod=1e9+7;  ///A simpler way to write 1,000,000,007
 
int main()
{
    int n,k;
    cin >> n >> k;
    int a[n+1];
    for(int i=1;i<=n;i++)
    {
        cin >> a[i];
    }
    int dp[n+1][k+1];
    dp[0][0]=1;
    for(int i=1;i<=k;i++)  /// Set the initial values
    {
        dp[0][i]=0;
    }
    for(int i=1;i<=n;i++)
    {
        int sums[k+1];
        sums[0]=dp[i-1][0];
        for(int j=1;j<=k;j++)
        {
            sums[j]=(sums[j-1]+dp[i-1][j])%mod;  ///Calculate the prefix sums for i-1
        }
        for(int j=0;j<=k;j++)
        {
            int tr=sums[j];  ///Sum of dp[i-1][0...j]
            int unreachable=j-a[i]-1;  ///We need to subtract the sum of the first "unreachable" elements (dp[i-1][0...unreachable])
            if(unreachable>=0)
            {
                tr=(tr-sums[unreachable]+mod)%mod;  ///Add mod to make sure that "tr-sums[unreachable]" is not negative.
            }
            dp[i][j]=tr;
        }
    }
  	cout << dp[n][k];
    return 0;
}

Measured memory_bytes: 40064
#include <bits/stdc++.h>
#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++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
	int x, a, b;
	cin >> x >> a >> b;
	x -= a;

	while(1){
		if (x < b) break;
		x -= b;
	}

	cout << x << endl;

}


Measured memory_bytes: 256
parseInt(x) = parse(Int,x)

function main()
	n,m = map(parseInt, split(readline()))
	a = Array{String}(n)
	for i in 1:n
		a[i] = chomp(readline())
	end
	b = Array{String}(m)
	for i in 1:m
		b[i] = chomp(readline())
	end
	flg = 0
	for i in 1:n-m+1
		for j in 1:n-m+1
			lflg = 0
			for k in 0:m-1
				if a[i+k][j:j+m-1] != b[k+1]
					lflg = 1
				end
			end
			if lflg == 0
				flg = 1
    		end
    	end
	end
	if flg == 1
		println("Yes")
	else
		println("No")
	end
end

main()

Measured memory_bytes: 115084
<?php
fscanf(STDIN,'%d',$n);
fscanf(STDIN,'%d',$k);
fscanf(STDIN,'%d',$x);
fscanf(STDIN,'%d',$y);
if($n<$k){
  echo $x * $n;
}else{
  echo $x * $k + $y * ($n - $k);
}
 ?>

Measured memory_bytes: 3576
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<functional>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define INF 1000000007
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define CLR(a) memset((a), 0, sizeof(a))

using ll = long long;
using ull = unsigned long long;
using namespace std;

inline int toInt(string s){
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}

ll gcd(ll a, ll b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }

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

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

template<class T> inline string toString(T x){
    ostringstream sout;
    sout << x;
    return sout.str();
}

int main(void){

    ull a, b, d, c;
    cin >> a >> b >> c >> d;

    ull ans = b/c;
    ans -= (a-1)/c;

    ull ans2 = b/d;
    ans2 -= (a-1)/d;

    ull g = lcm(d,c);

    ull ans3 = b/g;
    ans3 -= (a-1)/g;

    ans = ans+ans2-ans3;
    ans = b-a-ans+1;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

double dist(int x1, int y1, int x2, int y2)
{
    int dif1 = (x2-x1);
    int dif2 = (y2-y1);
    return 1.0 * sqrt((dif1*dif1) + (dif2*dif2));
}

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

    int n;
    cin >> n;
    vector<pair<int,int> > v(n);
    for(int i = 0; i< n; ++i)
    {
        cin >> v[i].first >> v[i].second;
    }
    sort(v.begin(),v.end());

    double avg = 0.0;

    double curr =0;
    int k = 0;
    do
    {
        k++;
        curr = 0;
        for(int i =0; i < n-1; ++i)
        {
            curr+= 1.0 * dist(v[i].first,v[i].second, v[i+1].first, v[i+1].second);
        }
        avg+=curr;

    } while (next_permutation(v.begin(),v.end()));

    cout << fixed << setprecision(8) << 1.0 * avg / k;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int x[10000] = {};
  for(int i=0;i<10000;i++){
    cin >> x[i];
    if(x[i] == 0){
      break;
    }
  }
  for(int i=0;i<10000;i++){
    if(x[i] == 0){
      break;
    }
    cout << "Case " << i+1 << ": " << x[i] << endl;
  }
  return 0;
}

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N;
    ll P;
    ll mini = LONG_LONG_MAX;
    vector<ll> X;
    cin >> N;
    X.resize(N);
    for(ll i = 0;i < N;i++) cin >> X[i];
    for(ll i = 1;i <= 100;i++) {
        ll c = 0;
        for(auto &j: X) {
            c += (j - i) * (j - i);
        }
        mini = min(mini, c);
    }
    cout << mini << endl;
    return 0;
}


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

void solve() {
    int N;
    string S;
    cin >> N >> S;
    for (char c : S) {
        cout << (char)(((c - 65) + N) % 26 + 65);
    }
    cout << endl;
}

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


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        Map<Integer,Deque<Long>> queue = new HashMap<>();
        StringBuilder sb = new StringBuilder();
        for(int i=0;i<n;i++){
            Deque<Long> L = new ArrayDeque<>();
            queue.put(i,L);
        }
        for(int i=0;i<q;i++){
            int cmd = sc.nextInt();
            int t = sc.nextInt();
            if(cmd==0)queue.get(t).add(sc.nextLong());
            else if(cmd==1 && queue.get(t).size()!=0) sb.append(queue.get(t).peek()+"\n");
            else if(cmd==2 && queue.get(t).size()!=0) queue.get(t).poll();
        }
        System.out.print(sb);
    }
}


Measured memory_bytes: 170336
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 n = sc.nextLong();
		
		long x = Long.min(b - 1, n);
		
		long ans = a * x / b;
		
		System.out.println(ans);
	}
	
}


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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << max({a * c, b * d, a * d, b * c}) << endl;
}

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

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
#include<math.h>
using namespace std;
long ex(long n){
    return n*(n-1)/2;
  }
int main() {
  int N;
  cin>>N;
  vector<string>data(N);
  for(int i=0; i<N;i++){
      cin>>data.at(i);
  }
  for(int i=0;i<N;i++){
    sort(data.at(i).begin(),data.at(i).end());
  }
  sort(data.begin(),data.end());
  long a=0;
  int j=0;
  string b=data.at(0);
  vector<int> c(N);

  for(int i=0; i<N;i++){
    if(b==data.at(i)){
       c.at(j)++;
    }
    else{
      c.at(j+1)=1;
      b=data.at(i);
      j++;
    }
  }
 
      
 for(int i=0; i<N;i++){
    a+=ex(c.at(i));
 }
    cout<<a<<endl; 
}


Measured memory_bytes: 7680
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> opset;
#define SZ(X) ((int)X.size())
#define ALL(I) I.begin(), I.end()
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define eps 1e-12
#define INF 1000000007
#define MXN 200005
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

int main(){
	LL a, b, c;
	cin >> a >> b >> c;
	cout << b + min(a + b + 1, c) << '\n';
}



Measured memory_bytes: 256
#include <iostream>

int main()
{
        int a,b;

        while(true)
        {
                std::cin >> a >> b;

                if(a==0 && b==0)
                        break;

                if(a < b)
                        std::cout << a << " " << b << std::endl;
                else
                        std::cout << b << " " << a << std::endl;
        }
}


Measured memory_bytes: 3056
/*
   AUTHOR :- Gaurang_Kothiya
   
   Quote:-" Great things never come from comfort zones."                                                                                                                
*/
 
#include<bits/stdc++.h>
using namespace std;
 
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long  
#define ld long double
#define f(i,x,n) for(ll i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(ll i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define b_s(a,b)   binary_search( all(a),b)
#define lb(v,n)  lower_bound(all(v) ,n )
#define ub(v,n)  upper_bound( all(v) , n)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846
#define MOD 1000000007
 




void solve()
{
	ll n;
	cin>>n;
	
	ll a[n];
	f(i,0,n-1) cin>>a[i];
	
	bool okay=true;
	
	f(i,0,n-1)
	{
		if(a[i]%2 ==0)
		{
			if(a[i]%3 !=0  && a[i]%5!=0)
			{
				okay=false;
				break;
			}
		}
	}
	
	if(okay) cout<<"APPROVED";
	else cout<<"DENIED";
	
}

signed main() 
{
	speed;
	
	int q=1;
	//cin>>q;
	
	while(q--)
		solve();
		
 	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}


Measured memory_bytes: 256
#include<map>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> E;
const LL MOD = 1000000007LL;
LL f(LL b, LL n)
{
	LL ret = 0;
	while (n > 0)
	{
		ret += n%b;
		n /= b;
	}
	return ret;
}
int main()
{
	LL n, s;
	cin >> n >> s;
	if (n == s)
	{
		cout << n + 1 << endl;
		return 0;
	}
	for (LL i = 2; i*i <= n; i++)
	{
		if (f(i, n) == s)
		{
			cout << i << endl;
			return 0;
		}
	}
	if (n < s)
	{
		cout << -1 << endl;
		return 0;
	}
	LL ans = 1LL << 60;
	for (LL i = 1; i*i <= n - s; i++)
	{
		if ((n - s) % i) continue;
		LL b = (n - s) / i + 1;
		if (f(b, n) == s) ans = min(ans, b);
	}
	if (ans == 1LL << 60)
	{
		cout << -1 << endl;
		return 0;
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, K, Q = map(int, input().split())
    score = [K] * N
    num = [0] * N
    ans = ["Yes"] * N
    for i in range(Q):
        i = int(input())
        num[i-1] += 1
    for i in range(N):
        score[i] -= Q - num[i]
        if score[i] <= 0:
            ans[i] = "No"

    for i in range(N):
        print(ans[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 48988
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

int main(void){
  int N;
  cin >> N;
  vector<int> a(N);
  int s = 0;
  for(int i = 0; i < N; i++){
    cin >> a[i];
    s += a[i];
  }
  int m = (int)round((double)s / N);
  int ans = 0;
  for(int i = 0; i < N; i++) ans += (a[i] - m) * (a[i] - m);
  cout << ans << endl;
  return 0;
}
  


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

using ll = long long;
using p = pair<ll, ll>;
constexpr ll INF = 1LL << 62;

int main(void) {
  char c;
  cin >> c;
  cout << static_cast<char>(c + 1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  int a[N], b[N];
  FOR(i,0,N) cin >> a[i];
  FOR(i,0,N) cin >> b[i];
  ll x = 0, y = 0;
  FOR(i,0,N) {
    if(a[i] < b[i]) {
      x += (b[i] - a[i]) / 2;
    } else if(a[i] > b[i]) {
      x -= a[i] - b[i];
    }
  }
  cout << (x >= 0 ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long int
#define mod_ceil(a, b) (a % b) ? a / b + 1 : a / b
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, a, b, ans = 0;
    cin >> n;
    vector<pair<ll, ll>> P;
    map<pair<ll, ll>, char> M;
    for (int i = 0; i < n; i++)
    {
        cin >> a >> b;
        P.push_back({a, b});
        M[{a, b}] = 'R';
    }
    for (int i = 0; i < n; i++)
    {
        cin >> a >> b;
        P.push_back({a, b});
        M[{a, b}] = 'B';
    }

    sort(P.begin(), P.end());

    vector<pair<ll, ll>> X;

    for (int i = 0; i < n * 2; i++)
    {
        if (M[P[i]] == 'R')
        {
            X.push_back(P[i]);
        }
        else if (M[P[i]] == 'B')
        {
            // choose greatest y
            ll choice = -1, tmp_y = -1;
            for (int j = X.size() - 1; j >= 0; j--)
            {
                if (M[X[j]] != 'P' and X[j].second < P[i].second and tmp_y < X[j].second)
                {
                    choice = j;
                    tmp_y = X[j].second;
                }
            }
            if (choice != -1)
            {
                M[X[choice]] = 'P';
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

x, y = map(int, input().split())

xs = [x, -x, x, -x]
ys = [y, y, -y, -y]
init = [0, 1, 1, 2]
ans = float('inf')
for i in range(4):
    if xs[i] <= ys[i]:
        ans = min(ans, init[i] + ys[i] - xs[i])

print(ans)


Measured memory_bytes: 3316
from heapq import heappush, heappop
from collections import defaultdict
N, M = map(int, input().split())
d = defaultdict(list)  # {deadline: [rewards]}
for _ in range(N):
    A, B = map(int, input().split())
    deadline = M - A
    d[deadline].append(B)

ans = list()
for day in range(M + 1):
    rewards = d.get(day)
    if rewards is None or len(rewards) == 0:
        continue
    # rewards.sort(reverse=True)
    for reward in rewards:
        if len(ans) <= day:
            heappush(ans, reward)
        else:
            min_reward = heappop(ans)
            if reward > min_reward:
                heappush(ans, reward)
            else:
                heappush(ans, min_reward)

print(sum(ans))

Measured memory_bytes: 27588
nm = lambda:map(int,input().split())
h,w,n = nm()
l=[tuple(nm()) for _ in range(n)]
l.sort()
c = 0
for x,y in l:
    if x>y+c:
        print(x-1)
        break
    if x==y+c:
      c+=1
else:
  print(h)

Measured memory_bytes: 30860
#include <bits/stdc++.h>
using namespace std;
//*******************
// Mahmoud Magdy    *
//*******************
#define ll long long
#define endl "\n"

void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m ;
    cin>>m;
    return m ;
}
string s1[55],s2[55];
int main()
{
  fast();
  ll n=lD(),m=lD();
  ll x = m/2;
  if(n>=x){
    cout<<x<<endl;
    return 0;
  }
  if(n<x){
    ll y= x-n;
    cout<<n+(y/2)<<endl;
  }
}



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

int main() {
  int N;
  cin >> N;
  
  int a = (N % 10);
  int b = (N-a)/10%10;
  int c = (N-10*b-a)/(10*10)%10;
  int d = (N-10*10*c-10*b-a)/(10*10*10)%10;
  int e = (N-10*10*10*d-10*10*c-10*b-a)/(10*10*10*10)%10;
  int f = (N-10*10*10*10*e-10*10*10*d-10*10*c-10*b-a)/(10*10*10*10*10)%10;
  int g = (N-10*10*10*10*10*f-10*10*10*10*e-10*10*10*d-10*10*c-10*b-a)/(10*10*10*10*10*10)%10;
  int h = (N-10*10*10*10*10*10*g-10*10*10*10*10*f-10*10*10*10*e-10*10*10*d-10*10*c-10*b-a)/(10*10*10*10*10*10*10)%10;
  int i = (N-10*10*10*10*10*10*10*h-10*10*10*10*10*10*g-10*10*10*10*10*f-10*10*10*10*e-10*10*10*d-10*10*c-10*b-a)/(10*10*10*10*10*10*10*10)%10;
  
  if (N % (a+b+c+d+e+f+g+h+i) == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

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

vector<pair<ll,int>> factorize(ll n) {
    vector<pair<ll,int>> res;
    for(ll i = 2; i * i <= n; ++i) {
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n, 1);
    return res;
}

int main()
{
    ll a, b;
    cin >> a >> b;
    ll g = gcd(a, b);
    auto f = factorize(g);
    int ans = f.size() + 1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repeq(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define rep1eq(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

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

    int n,k,q;
    cin >> n >> k >> q;
    map<int,int> mp;

    rep(i,q){
        int a;
        cin >> a;
        if(mp.find(a) == mp.end()){
            mp[a] = 1;
        }else{
            mp[a]++;
        }
    }

    rep1eq(i,1,n){
        if(mp.find(i) == mp.end()){
            if(k-q<=0){
                cout << "No" << endl;
            }else{
                cout << "Yes" << endl;
            }
        }else{
            if(k-q+mp[i]<=0){
                cout << "No" << endl;
            }else{
                cout << "Yes" << endl;
            }
        }
            
    }

    return 0;

}

Measured memory_bytes: 3584
N, M = map(int, input().split())

AC = [0 for i in range(N)]
WA = [0 for i in range(N)]

for i in range(M):
    p, s = input().split()
    if s == 'AC' and AC[int(p)-1] == 0:
        AC[int(p)-1] += 1
    elif s == 'WA' and AC[int(p)-1] == 0:
        WA[int(p)-1] += 1

for i in range(N):
    if AC[i] == 0:
        WA[i] = 0

print(sum(AC), sum(WA))

Measured memory_bytes: 4760
from functools import reduce
n,a,b = map(int,input().split())
mod = 10 ** 9 + 7

def f(a):
    num = reduce(lambda x,y:x * y % mod,range(n,n-a,-1))
    den = reduce(lambda x,y:x * y % mod,range(1,a+1))
    return num * pow(den,mod-2,mod)%mod

ans = pow(2,n,mod)-f(a)-f(b)-1
ans %= mod
print(ans)

Measured memory_bytes: 3572
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace ConsoleApp6
{
	class Program
	{
		static void Main(string[] args)
		{
			var w = Console.ReadLine();
			int c = 0, i = 0;

			while (true)
			{
				var t = Console.ReadLine();
				if (t == "END_OF_TEXT")
					break;

				string[] T = t.Split(' ');

				for(i = 0; i < T.Length; i++)
				{
					int result = String.Compare(T[i], w, true);
					if(result == 0)
					{
						c++;
					}
				}
			}

			Console.WriteLine(c);
		}
	}
}



Measured memory_bytes: 18700
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<random>
using namespace std;


int main(){


  long long int a, b, x;
  cin >> a >> b >> x;

  long long int ans = 0;
  ans += b/x;
  ans -= a/x;
  if( a%x == 0 ) ans ++;
  cout << ans << endl;


  return 0;
}














// EOF


Measured memory_bytes: 256
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
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 int dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;



int main() {
	int N, T;
	cin >> N >> T;
	vector<int>c(N), t(N);
	int ans = INT_MAX;
	for (int i = 0; i < N; i++) {
		cin >> c[i] >> t[i];
		if (T >= t[i]) {
			chmin(ans, c[i]);
		}
	}
	if (ans == INT_MAX) {
		cout << "TLE" << endl;
	}
	else {
		cout << ans << endl;
	}
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int d = Integer.parseInt(sc.next());
        int t = Math.min(b,d) - Math.max(a,c);
        if(t < 0) t = 0;
        System.out.println(t);
    }
}

Measured memory_bytes: 21716
module Main where

import Debug.Trace

main :: IO ()
main = do
  s <- getLine
  putStrLn $ ans $ all p $ zip s $ map odd [1..]
  where
    ans True = "Yes"
    ans False = "No"
    p ('L', True) = False
    p (_, True) = True
    p ('R', False) = False
    p (_, False) = True


Measured memory_bytes: 508
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

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

template <class T> inline T chmax(T &a, T &b) {a = max(a, b);}
template <class T> inline T chmin(T &a, T &b) {a = min(a, b);}

constexpr int MOD = 1e9 + 7;
constexpr ll INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

ll modpow(ll a, ll b){
    if(b == 0) return 1;
    else if(b % 2 == 0){
        ll d = modpow(a, b/2) % MOD;
        return (d * d) % MOD;
    }
    else{
        return (a * modpow(a, b-1)) % MOD;
    }
}

const int MAX_N = 2010;

ll fact[MAX_N], finv[MAX_N];
ll comb(int n, int r){
    if(n < r || r < 0) return 0;
    return fact[n] * finv[n-r] % MOD * finv[r] % MOD;
}

void calc(int n){
    fact[0] = finv[0] = 1;
    for(int i=1; i<=n; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        finv[i] = modpow(fact[i], MOD-2);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k; cin>>n>>k;

    calc(2000);

    for(int i=1; i<=k; i++){
        ll ans = comb(n - k + 1, i) * comb(k - 1, i - 1);
        cout << ans % MOD << endl;
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
  int64_t A,V,B,W,T;
  cin>>A>>V>>B>>W>>T;
  if(V<=W){cout<<"NO"<<endl;}
  else{
    if((V-W)*T>=abs(B-A)){cout<<"YES"<<endl;}
    else{cout<<"NO"<<endl;}
  }
  return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

	static double min_dst_p ( int[] x, int[] y, int n, int p ) {
		double min_dst = 0.0;
		double max_xy = 0.0;

		for ( int i = 0 ; i < n ; i++ ) {
			
			if( i == 0 ) {
				max_xy = Math.abs( x[i] - y[i] );
			} else  if ( Math.abs( x[i] - y[i] ) > max_xy ) {
				max_xy = Math.abs( x[i] - y[i] );
			}

			min_dst += Math.pow( Math.abs( x[i] - y[i] ), p );

		}

		if ( p == 2 ) {
			min_dst = Math.sqrt( min_dst );
		} else if ( p == 3 ) {
			min_dst = Math.cbrt( min_dst );
		} else if  (p == 4){
			min_dst = max_xy;
		}

		return min_dst;
	}

	public static void main(String[] args) {

		int[] vector_x;
		int[] vector_y;
		int vector_num = 0;
		double[] min_dst_p = new double[4];

		Scanner sc= new Scanner( System.in );

		vector_num = sc.nextInt();
		vector_x = new int[vector_num];
		vector_y = new int[vector_num];

		for ( int i = 0; i < vector_num ; i++ ) {
			vector_x[i] = sc.nextInt();
		}

		for ( int i = 0; i < vector_num ; i++ ) {
			vector_y[i] = sc.nextInt();
		}

		for  ( int i = 0; i < 4 ; i++ ) {
			min_dst_p[i] = min_dst_p( vector_x, vector_y, vector_num ,i+1 );
			System.out.println( min_dst_p[i] );
		}

		sc.close();
	}
}



Measured memory_bytes: 26436
#include<bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define mer make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pair<int,int>,int> piii;
typedef pair<int,pair<int,int> > ipii;
typedef pair<pii,pii> pi4;
const int vbi=999999999;

int main(){
	//my new name is Veex
	//clock_t start1=clock();
	long n,m;
	cin>>n>>m;
	for(int i=int(m/n);i>=1;i--)
		if(m%i==0){
			cout<<i;
			return 0;
		}
	//cout<<endl<<((double)(clock()-start1)/CLOCKS_PER_SEC);
	return 0;
}


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

for i in range(M):
    a,b=map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

from itertools import permutations

P=permutations(range(1,N),N-1)

cnt=0
for r in P:
    now=0
    F=True
    for x in r:
        if x in G[now]:
            now=x
        else:
            F=False
    if F:
        cnt+=1
print(cnt)


Measured memory_bytes: 9144
import sys
mod = 10**9 +7
N = int(input())
S1 = input()
S2 = input()

H = ''
for i in range(N):
    if S1[i] == S2[i]:
        H += 't'
    else:
        H += 'Y'
H = H.replace('YY','y')
K = len(H)
if K == 1 :
    print(3*N)
    sys.exit()
if H[0] == 'y':
    ans = 6
    prev = 'y'
else:
    ans = 3
    prev = 't'
for i in H[1:]:
    if prev == 'y':
        if i == 'y':
            ans = ans*3 %mod
    else:
        ans = ans*2 %mod
    prev = i
print(ans%mod)
    




Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int n, m;
    cin >> n >> m;
    vector<int> G[n];
    int a, b;
    rep(i, m) {
        cin >> a >> b;
        a--;
        b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    int q;
    cin >> q;
    int v[q], d[q], c[q];
    rep(i, q) {
        cin >> v[i] >> d[i] >> c[i];
        v[i]--;
    }
    reverse(v, v + q);
    reverse(d, d + q);
    reverse(c, c + q);
    int ans[n] = {};
    int dp[n];
    fill(dp, dp + n, -1);
    rep(i, q) {
        if (d[i] <= dp[v[i]]) continue;
        queue<P> que;
        que.emplace(v[i], d[i] - 1);
        if (ans[v[i]] == 0) ans[v[i]] = c[i];
        dp[v[i]] = d[i];
        while (!que.empty()) {
            P p = que.front();
            que.pop();
            for (int to : G[p.first]) {
                if (p.second <= dp[to]) continue;
                que.emplace(to, p.second - 1);
                if (ans[to] == 0) ans[to] = c[i];
                dp[to] = p.second;
            }
        }
    }
    rep(v, n) {
        cout << ans[v] << endl;
    }
    return 0;
}

Measured memory_bytes: 8912
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#define ll long long
#define il inline
using namespace std;
const int N = 200000 + 5;
int a[ N ],p[N],b[N];
bool cmp(int x,int y){
	return a[x]<a[y];
}
int main()
{
    int n;
    cin >> n;
    for(int i=1;i<=n;i++)scanf("%d",&a[i]),p[i]=i;
    sort(p+1,p+n+1,cmp);
    sort(a+1,a+n+1);
    int k=n/2;
	for(int i=1;i<=n;i++){
    	if(i<=k)b[p[i]]=a[k+1];
    	else b[p[i]]=a[k];
//    	cout<<b[p[i]]<<endl;
    }
    for(int i=1;i<=n;i++){
    	printf("%d\n",b[i]);
    }
    return 0;
}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    int i = 1;
    while( i * i <= n ) {
        ++i;
    }

    cout << (i - 1) * (i - 1) << endl;
    return 0;
}


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

#define MAX_N (1e8)+1

int main(void){
    //?????????????????????
    vector<bool> eratos(MAX_N, true);
    eratos[0] = eratos[1] = false;
    for(int i = 2; i*i < MAX_N; i++)
        if(eratos[i])
            for(int j = 2; i*j < MAX_N; j++)
                eratos[i*j] = false;
    
    //?????¨?????????
    int n, input, ans = 0;
    cin >> n;
    for(int i=0; i < n; i++){
        cin >> input;
        if(eratos[input])
            ++ans;
    }
    
    //??????
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14748
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup cin.tie(0);ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int kazu(int n){
    if (n == 1) {return 2;}
    else if (n == 2 || n == 3 || n == 5) {return 5;}
    else if (n == 4) {return 4;}
    else if (n == 6 || n == 9) {return 6;}
    else if (n == 7) {return 3;}
    else if (n == 8) {return 7;}
}

int main()
{
    ciosup;
    int n, m;
    cin >> n >> m;
    vint a(m);
    REP(i,m) cin >> a[i];
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    ll dp[n + 10];
    REP(i, n + 10) { dp[i] = -INF; }
    dp[0] = 0;

    REP(i,n){
        REP(k,m)
        {
            dp[i + kazu(a[k])] = max(dp[i + kazu(a[k])], dp[i] + 1);
        }
    }
    int now = n;
    while (now > 0)
    {
        REP(k,m){
            if (now - kazu(a[k]) >= 0)
            {
                if (dp[now] == dp[now - kazu(a[k])] + 1)
                {
                    cout << a[k];
                    now -= kazu(a[k]);
                    break;
                }
            }
        }
    }
    cout << endl;
}

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

int main()
{
  string S;
  cin >> S;
  int counter = 0;
  bool loopfrag = true;
  for(int i = 0;i < 3;i++){
    if(S.at(i) == 'R' && loopfrag == true) counter++;
    else if(S.at(i) == 'R'){
      loopfrag = true;
      counter = 1;
    }
    else loopfrag = false;
  }
  cout << counter << endl;
}


Measured memory_bytes: 3588
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n);
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end());
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end());
#define reverse(a)      reverse((a).begin(), (a).end());
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d);
#define outl(d)         std::cout<<(d)<<"\n";
#define Yes()           printf("Yes\n");
#define No()            printf("No\n");
#define YES()           printf("YES\n");
#define NO()            printf("NO\n");
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  string s1, s2, s3; cin >> s1 >> s2 >> s3;
  outl(ctos(char(toupper(s1[0]))) + ctos(char(toupper(s2[0]))) + ctos(char(toupper(s3[0]))))
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12)

  solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];

// DP テーブル
long long dp[100100];

int main() {
    int N, K; cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> h[i];

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100100; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 0; i < N; ++i) {
        for (int j = 1; j <= K; ++j) {
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }

    // 答え
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1792
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n,m; cin>>n>>m;
    int gotyuumonnha_usagi_desuka;
    rep(i,m)cin>>gotyuumonnha_usagi_desuka;
    cout<<n-m-1<<endl;
}

Measured memory_bytes: 3084