akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

int main() {
  int n;
  ll c;
  cin >> n >> c;
  vector<ll> x(n), v(n);
  REP(i, 0, n) cin >> x[i] >> v[i];
  vector<ll> l(n + 1), r(n + 1);
  REP(i, 0, n) l[i + 1] = l[i] + v[i];
  for (int i = n - 1; i >= 0; --i) r[i] = r[i + 1] + v[i];
  ll mx = 0;
  vector<ll> l_mx(n + 1), r_mx(n + 1);
  REP(i, 0, n) l_mx[i + 1] = max(l_mx[i], l[i + 1] - x[i]);
  for (int i = n - 1; i >= 0; --i)
    r_mx[i] = max(r_mx[i + 1], r[i] - c + x[i]);
  mx = max(mx, max(r_mx[0], l_mx[n]));
  REP(i, 0, n) {
    mx = max(mx, l[i + 1] - 2 * x[i] + r_mx[i + 1]);
    mx = max(mx, r[i] - 2 * (c - x[i]) + l_mx[i]);
  }
  cout << mx << endl;
}


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

int main(){
  long long int n,c,k;
  cin>>n>>c>>k;
  vector<long long int> t(n);
  for(int i=0;i<n;i++) cin>>t[i];
  sort(t.begin(),t.end());
  long long int res=0;
  long long int now_t=-1;
  long long int now_c=c+1;
  for(int i=0;i<n;i++){
    if(now_t<t[i] || now_c>=c){
      res++;
      now_t=t[i]+k;
      now_c=1;
    }
    else{
      now_c++;
    }
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 1024
import re
s=input()
ans=0

s=re.sub('BC', 'D', s)

re_ad=re.compile(r'[AD]+')
ad=re.findall(re_ad,s)
#print(s)
#print(ad)
for adi in ad:
    adi_a=0
    for adij in adi:
        if(adij=='A'):
            adi_a+=1
        else:
            ans+=adi_a

print(ans)

Measured memory_bytes: 5476
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=(a),_ed=(b);i<=_ed;++i)
#define DREP(i,a,b) for(int i=(a),_ed=(b);i>=_ed;--i)
typedef long long ll;
inline int read(){
    register int x=0,f=1;register char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=0;ch=getchar();}
    while(isdigit(ch)){x=x*10+(ch^'0');ch=getchar();}
    return f?x:-x;
}

#define fail return puts("-1"),0;
const int N=1e5+5,inf=1e9;
const char ch[]="BW";
int n,m,d[N],num=1,head[N],w[N<<1],col[N],fa[N];
struct edge{int to,next,vis;} e[N<<2];
inline void add(int u,int v){
    e[++num]=(edge){v,head[u]},head[u]=num;
    e[++num]=(edge){u,head[v]},head[v]=num;
}

inline void dfs(int u){
    for(int i=head[u];i;i=e[i].next){
	int v=e[i].to;if(!e[i].vis||~col[v])continue;
	col[v]=1-col[u];dfs(v);
    }
}

int main(){
    //freopen("in.in","r",stdin);
    n=read(),m=read();
    REP(i,1,n)d[i]=read();
    REP(i,1,m)add(read(),read()),w[i]=inf;
    REP(u,1,n){
	if(!head[u])fail;
	int p=head[u];
	for(int i=e[p].next;i;i=e[i].next){
	    if(d[e[i].to]<d[e[p].to])p=i;
	    else if(d[e[i].to]==d[e[p].to]&&e[i].to<e[p].to)p=i;
	}
	if(d[e[p].to]>d[u])fail;
	e[p^1].vis=1;w[p>>1]=d[u];fa[u]=e[p].to;
    }
    memset(col,-1,sizeof col);
    REP(i,1,n)if(fa[fa[i]]==i&&!~col[i])col[i]=0,dfs(i);
    REP(i,1,n)putchar(ch[col[i]]);
    puts("");
    REP(i,1,m)printf("%d\n",w[i]);
    return 0;
}


Measured memory_bytes: 9472
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <set>
#include <deque>
#include <numeric>
#include<tuple>
#include <utility>
using namespace std;

int main(){
    long long int n,m;
    cin >> n >> m;
    if(n!=1 && m!=1)    cout << n*m - (2*n + 2*m -4);
    else{
        if(n==1 && m==1){
            cout << 1;
        }
        else{
            cout << max(n,m) - 2;
        }
    }

}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b<=a+c && a+c<=b+c){
    cout << a+b << endl;
  }
  else if(a+b<=b+c && b+c<=a+c){
    cout << a+b << endl;
  }
  else if(a+c<=a+b && a+b<=b+c){
    cout << a+c << endl;
  }
  else if(a+c<=b+c && b+c<=a+b){
    cout << a+c << endl;
  }
  else if(b+c<=a+c && a+c<=a+b){
    cout << b+c << endl;
  }
  else if(b+c<=a+b && a+b<=a+c){
    cout << b+c << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <utility>
#include <iomanip>
#include <climits>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
#include <map>
    
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    string s;
    cin >> s;
    int r = 0;
    int ans = 0;
    for(int i = 0; i < s.size(); i++) {
        r = i;
        while(r < s.size() and (s[r] == 'A' or s[r] == 'G' or s[r] == 'C' or s[r] == 'T')) r++;
        ans = max(ans, r - i);
        i = r;
    }
    cout << ans;
    return 0; 
}

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

int main()
{
    char ch[12];
scanf("%s",ch);
int ans=0,count=0;
for(int i=0;i<strlen(ch);i++)
{
if(ch[i]=='A' || ch[i]=='T' || ch[i]=='G' || ch[i]=='C')
{
count++;
}
else
{
    if(ans<count)
    ans=count;
    count=0;
}
}
if(ans<count)
    ans=count;
    count=0;
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
k = int(input())
a,b = map(int,(input().split()))
flag = False

for i in range(1,b+1):
    if((k * i >= a) and (k * i <= b)):
        flag = True
        break

if(flag):
    print("OK")
else:
    print("NG")

Measured memory_bytes: 9128
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>


using namespace std;

int main(void) {

        int N;
        cin>>N;
        int A=1;
        vector<int >H(N);
        for(int i=0;i<N;i++){
            cin>>H[i];
        }
        int B=H[0];
        for(int i=1;i<N;i++){
            if(H[i]>=B){
                A++;
                B=H[i];
            }
        }

        cout<<A<<endl;

}


Measured memory_bytes: 256
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<iostream>

#define D(x) cout << #x " is " << (x) << endl
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(c) (c).begin(),(c).end()
#define foreach(it, c) for(__typeof__((c).begin()) it=(c).begin();it!=(c).end();it++)

using namespace std;

int main(void){

  int a,ans=0;

  for(int i=0;i<5;i++){
    cin >> a;
    ans+=max(40,a);
  }

  cout << ans/5 << endl;

  return 0;
}

Measured memory_bytes: 1160
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int main(void){
    char a; cin >> a;
    if ((int)(a - 'a') < 0) cout << "A" << endl;
    else cout << "a" << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
	string s;
	cin >> s;
	int a = 0;
	int b = 0;
	for(int i = 0; i < (int)s.size(); i++){
		if(i%2){
			if(s[i] == '0')a++;
			else b++;
		}
		else{
			if(s[i] == '1')a++;
			else b++;
		}
	}
	cout << min(a, b) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
 
 
int main()
{
   int n,t;
  cin>>n;
  int p=0;
  while(n>0)
  {
    t=n%10;
    n=n/10;
    if(t==7)
     p=1;
  }
  
  
  if(p==1)
    cout<<"Yes"<<endl;
  else
   cout<<"No"<<endl;
  
return 0;
}
    

Measured memory_bytes: 3636
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define vpush(v,x) v.push_back(x);
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,w,h;
    cin>>a>>b>>w;
    cout<<(w/a)*b;
    return(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
#define vecout(V) for(int i=0;i<V.size();i++) {cout<<V[i]<<endl;}
typedef long long ll;


vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main(void){
    ll n, m;
    cin>>n>>m;
    vector<ll> v=divisor(m);
    if(n==1){
        cout<<m<<endl;
        return 0;
    }
    int left=0;
    int right=v.size();
    while(right-left>1){
        int mid=(left+right)/2;
        if(v[mid]>=n) right=mid;
        else left=mid;
    }
    cout<<m/v[right]<<endl;
}

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

int main() {
  long long A,B,K;
  cin>>A>>B>>K;
   if(A>=K){
     cout<<A-K<<' '<<B<<endl;
   }
   else if(((A+B)-K)>0){
       cout<<0<<' '<<B-(K-A)<<endl;
     }
   else { 
       cout<<0<<' '<<0<<endl;
     }
}


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

typedef long long ll;

int main() {
    int N, Q;
    string S;
    cin >> N >> S >> Q;
    vector<int> k(Q);
    rep(i, Q) cin >> k[i];
    vector<ll> Dsum(N + 1, 0), Msum(N + 1, 0), DM(N + 1, 0);
    rep(i, N) {
        Dsum[i + 1] = Dsum[i];
        if (S[i] == 'D') Dsum[i + 1]++;
        Msum[i + 1] = Msum[i];
        if (S[i] == 'M') Msum[i + 1]++;
    }
    rep(i, Q) {
        ll ans = 0, DM = 0;
        rep(j, N) {
            int j0 = j - k[i];
            if (j0 >= 0 && S[j0] == 'D') DM -= Msum[j + 1] - Msum[j0];
            if (S[j] == 'M') DM += Dsum[j] - Dsum[max(0, j0)];
            if (S[j] == 'C') ans += DM;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 24836
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;

bool is_prime(ll x){
  for (int i = 2; i * i <= x; i++) {
    if(x % i == 0){
      // cout << x << endl;
      return true;
    }
  }
  return false;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x;
  cin >> x;
  for (int i = x; ; i++) {
    if(!is_prime(i)){
      cout << i << endl;
      break;
    }
  }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

  public static void main(String args[]) throws IOException {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    List<String> list = new ArrayList<>();
    String data;
    while ((data = br.readLine()) != null) {
      list.add(data);
    }
    br.close();

    int n = Integer.parseInt(list.get(0)); // 大きさ
    String p = list.get(1).replaceAll(" ", ""); // 比較１
    String q = list.get(2).replaceAll(" ", ""); // 比較２

    List<String> li = new ArrayList<>();
    List<String> result = new ArrayList<>();

    String target = "";
    int tmp = 1;
    for (int i = 0; i < n; i++) {
      target += String.valueOf(tmp++);
    }

    String ans = "";
    result = permutation(li, target, ans);

    // 結果
    int pn = result.indexOf(p);
    int qn = result.indexOf(q);
    if (pn > qn) {
      System.out.println(pn - qn);
    } else {
      System.out.println(qn - pn);
    }

  }

  public static List<String> permutation(List<String> list, String target, String ans) {
    if (target.length() <= 1) {
      list.add(ans + target);
    } else {
      for (int i = 0; i < target.length(); i++) {
        permutation(list, target.substring(0, i) + target.substring(i + 1), ans + target.charAt(i));
      }
    }
    return list;
  }

}



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

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef std::pair<int,int> pii;

using namespace std;

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

    int ans = n * n;
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define pi 3.14159265358979323846264338327950L
using namespace std;

int main() {
  int64_t N, M, ans;
  cin >> N >> M;
  if (N>=M/2) {
    ans=M/2;
  }
  else {
    ans=N+(M-2*N)/4;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
# nCk 前処理メモ化
MOD = 10 ** 9 + 7
N = 2000
@fac = [1, 1]
@inv = [1, 1]
@finv = [1, 1]

(2..N).each do |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
end

def nCk(n, k)
  return 0 if n < k || n < 0 || k < 0
  @fac[n] * (@finv[k] * @finv[n - k] % MOD) % MOD
end

n, k = gets.split.map(&:to_i)
blue = k
red = n - k

1.upto(k) do |i|
  blue_places_combi = nCk(red + 1, i)
  blue_splits_combi = nCk(blue - 1, i - 1)
  puts blue_places_combi * blue_splits_combi % MOD
end


Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int a, b, h;
  cin >> a >> b >> h;
  cout << (a + b) * h / 2.0 << endl;
  return 0;
}



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

int main()
{
	int N {};
	std::string S;
	std::cin >> N >> S;

	int dp[N] {};
	dp[0] = 1;
	for (int i {1}; i < N; i++)
	{
		if (S[i] != S[i - 1])
			dp[i] = dp[i - 1] + 1;
		else 
			dp[i] = dp[i - 1];
	} 

	std::cout << dp[N - 1];
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define off  exit( 0 )
#define cn   continue
#define rt   return
#define sc   scanf
#define pr   printf
#define pb   push_back
#define pf   push_front
#define p_f  pop_front
#define p_b  pop_back
#define ff   first
#define ss   second
#define ll   long long
#define ld   long double
#define N    200256
#define M    998244353
#define I    1000000000000000000
#define pdd  pair < ld, ld >
#define pll  pair < ll, ll >
#define pii  pair < int, int >
#define sqr( a )           a * a
#define all( c )           c.begin(), c.end()
#define srt( c )           sort( all( c ) )
#define rev( c )           reverse( all( c ) )
#define srtr( c )          sort( c.rbegin(), c.rend() );

using namespace std;
ll a, b, c, ans;
void solve()
{
    sc( "%I64d%I64d%I64d", &a, &b, &c );
    if( c <= b )
    {
        pr( "%I64d", c + b );
        rt;
    }
    ans = b * 2;
    c -= b;
    ans += min( a + 1, c );
    pr( "%I64d", ans );
}

int main()
{
    int tt = 1;
    //sc( "%d", &tt );
    for( int i = 1; i <= tt; i ++ )
        solve();
}












Measured memory_bytes: 256
n, k = 3, gets.to_i
m = 10**9 + 7

a = Array.new(k, 1)

(n - 1).times do
  b = Array.new(k + 1, 0)
  a.each.with_index(1) do |cnt, j|
    next if cnt == 0
    1.upto(k) do |i|
      b[i.gcd(j)] += cnt
    end
  end
  a = b.drop(1)
end

puts a.each.with_index(1).inject(0) { |s, (cnt, i)| (s + cnt * i) % m }

load __FILE__ unless $stdin.eof?


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

int main(){
    lint h; cin>>h;
    lint ans = 0; lint c = 1;
    while(h > 0){
        h /= 2;
        ans += c;
        c *= 2;
    }
    out(ans);
}

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

int main() {
    int na;
    cin >> na;
    string sa;
    vector<char> ea = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','A','B','C','D','E'};
    cin >> sa;
    for (int i=0; i<sa.size(); i++) {
        for (int j=0; j<26; j++) {
            if (sa.at(i) == ea.at(j)) {
                sa.at(i) = ea.at(j+na);
            break;
            }
        }
    }
    cout << sa << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MS(a) memset(a,0,sizeof(a))
#define MP make_pair
#define PB push_back
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3fLL;
inline ll read(){
    ll 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;
}
//////////////////////////////////////////////////////////////////////////
const int maxn = 1e5+10;

int a[maxn];

int main(){
	int n,k;
	cin >> n >> k;
	MS(a);
	for(int i=0; i<k; i++){
		int u,v; scanf("%d%d",&u,&v);
		a[u]++,a[v]++;
	}
	for(int i=1; i<=n; i++){
		if(a[i]%2) {
			puts("NO");
			return 0;
		}
	}
	puts("YES");

    return 0;
}

Measured memory_bytes: 640
n = int(input())
s = list(map(int,input().split()))
min = max = sum = s[0]
for i in range(1,n):
    sum += s[i]
    if s[i] > max:
        max = s[i]
    elif s[i] < min:
        min = s[i]
        
print(min,max,sum)
    


Measured memory_bytes: 6592
sx,sy,tx,ty = map(int,input().split())
for i in range(tx-sx):
    print("R",end = "")
for i in range(ty-sy):
    print("U",end = "")
for i in range(tx-sx):
    print("L",end = "")
for i in range(ty-sy):
    print("D",end = "")
print("D",end = "")
for i in range(tx-sx+1):
    print("R",end = "")
for i in range(ty-sy+1):
    print("U",end = "")
print("L",end = "")
print("U",end = "")
for i in range(tx-sx+1):
    print("L",end = "")
for i in range(ty-sy+1):
    print("D",end = "")
print("R")

Measured memory_bytes: 9324
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

typedef long long i64;

int64_t gcd(int64_t a, int64_t b) {
    while (b) {
        int64_t c = a % b;
        a = b;
        b = c;
    }
    return a;
}

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

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    int64_t a = 1, b = 1;
    while (n-- > 0) {
        int64_t x, y;
        cin >> x >> y;

        int64_t g = gcd(x, y);
        x /= g;
        y /= g;
        
        int64_t mul = max((a + x - 1) / x, (b + y - 1) / y);
        a = x * mul;
        b = y * mul;
    }
    cout << a + b << '\n';
}

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

using namespace std;

string str1,str2;

int m[1000][1000];

int LCS(int i,int j){
  
  
  if(i==-1||j==-1){
    return 0;
  }else if(m[i][j]!=0){
    return m[i][j];
  }else if(str1[i]==str2[j]){
    m[i][j]=LCS(i-1,j-1)+1;
    return m[i][j];
  }else{
    m[i][j]=max(LCS(i-1,j),LCS(i,j-1));
    return m[i][j];
  }
  
}

int main(){
  int N;
  
  cin >> N;
  
  
  for(int i=0;i<N;i++){
    cin >> str1 >> str2;
    for(int j=0;j<1000;j++){
      for(int k=0;k<1000;k++){
        m[j][k]=0;
      }
    }
    cout << LCS(str1.size()-1,str2.size()-1) << endl;
  }
  return 0;
}

Measured memory_bytes: 7136
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define pb push_back
#define r1 rt<<1
#define r2 rt<<1|1
#define fi first
#define se second
#define db double
#define ld long db
#define ri register int
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define rep2(i,a,b,c) for(ri i=(a);i<=(b);i+=(c))
#define REP(i,a,b) for(ri i=(a);i>=(b);--i)
#define REP2(i,a,b,c) for(ri i=(a);i>=(b);i-=(c))
using namespace std;
inline int read(){
	ri x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^'0'),c=getchar();
	return x*f;
}
const int inf=0x3f3f3f3f,N=2005;
char a[N];
int n,f[N],s[N];
vector<int>g[N];
inline void dfs(ri u,ri fa){
	s[u]=a[u]=='1';f[u]=0;
	for(ri v:g[u])if(v!=fa)dfs(v,u),s[u]+=s[v],f[u]+=f[v]+s[v];
}
inline int dfs2(ri u,ri fa){
	ri x=0;
	for(ri v:g[u])if(v!=fa)if(!x||f[v]>f[x])x=v;
	if(!x)return 0;
	ri y=dfs2(x,u)+s[x];
	if(f[u]-f[x]-s[x]>=y)return f[u]&1;
	return y-(f[u]-f[x]-s[x]);
}
int main()
{
	n=read();scanf("%s",a+1);
	rep(i,2,n){ri u=read(),v=read();g[u].pb(v);g[v].pb(u);}
	ri ans=inf;
	rep(i,1,n){
		dfs(i,0);
		if(!dfs2(i,0))ans=min(ans,f[i]>>1);
	}
	printf("%d\n",ans<inf?ans:-1);
	return 0; 
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main(void)
{
    int n, m; cin >> n >> m;
    vector<int> a(n);
    int sum = 0;
    for (int i = 0; i < n; i++) 
    {
        cin >> a[i];
        sum += a[i];
    }
    sort(a.begin(), a.end());
    if (4 * a[n - m] * m < sum) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int K,X;
	scan(K>>X);
	int st=X-K+1,en=X+K-1;
	for(int i=st;i<=en;i++) printf("%d ",i);
	kaigyo;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i=0,n=0,a[20000],b[20000],sign[20000];
    while(1)
    {
        scanf("%d %c %d",&a[i],&sign[i],&b[i]);
        if(sign[i]=='?'){
            break;
        }
        i++;
        n++;
    }
    for(i=0;i<n;i++){
        if(sign[i]=='+'){
           printf("%d\n",a[i]+b[i]);
        }
        else if(sign[i]=='-'){
            printf("%d\n",a[i]-b[i]);
        }
        else if(sign[i]=='*'){
            printf("%d\n",a[i]*b[i]);
        }
        else{
            printf("%d\n",a[i]/b[i]);
        }
    }

    return 0;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
#define P pair<int, int>
using namespace std;

const int M = 1000005;

int main() {
  int n;
  cin >> n;
  map<string, int> mp;
  set<string> ans;
  int c = 0;
  rep(i, n){
    string s;
    cin >> s;
    if(mp.count(s)) mp[s]++;
    else mp[s] = 1;
    if(c < mp[s]) ans.clear();
    
    c = max(c, mp[s]);

    if(c == mp[s]){
      ans.insert(s);
    }
  }

  for(auto x : ans){
    cout << x << endl;
  }

  return 0;
}

Measured memory_bytes: 34860
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(), v.end()
#define fori(i, j, k) for (int i = (j); i < (int)(k); i++)
#define forb(i, j, k) for (int i = (j); i >= (int)k; i--)
#define lchild(ind) 2 * ind + 1
#define rchild(ind) 2 * ind + 2
#define bug(val) cout << "# " << val << endl;
#define bugs(val) cout << '_' << val;
#define bugl(val) cout << "## " << val << endl;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
typedef pair<ll, pll> plp;
typedef pair<pll, int> ppi;
typedef pair<pll, ll> ppl;
typedef pair<pll, pll> ppp;
typedef vector<int> vi;
typedef vector<ll> vll;

const int maxn = 1e5 + 1;
const ll inf = 2e18, mod = 1e9 + 7;

int ind = 1;

deque<int> solve(ll n)
{
	deque<int> res;
	if (!n)
		return res;
	if (n == 1)
	{
		res.pb(ind), res.pb(ind);
		ind++;
		return res;
	}
	if (n == 2)
	{
		res.pf(ind), res.pb(ind);
		ind++;
		res.pf(ind), res.pb(ind);
		ind++;
		return res;
	}
	if (n & 1)
	{
		deque<int> tmp = solve((n - 1) / 2);
		fori (i, 0, tmp.size())
		{
			if (i == (int)tmp.size() / 2)
				res.pb(ind);
			res.pb(tmp[i]);
		}
		res.pb(ind++);
		return res;
	}
	else
	{
		deque<int> tmp = solve((n - 2) / 2);
		fori (i, 0, tmp.size())
		{
			if (i == (int)tmp.size() / 2)
				res.pb(ind);
			res.pb(tmp[i]);
		}
		res.pb(ind++);
		res.pf(ind), res.pb(ind), ind++;
		return res;
	}
}

int get(deque<int> a)
{
	int n = a.size(), res = 0;
	vi A, B;
	fori (mask, 1, (1 << n))
	{
		int cnt = __builtin_popcount(mask), now = 0;
		if (cnt & 1)
			continue;
		A.clear(), B.clear();
		fori (i, 0, n)
			if ((mask >> i) & 1)
			{
				cerr << a[i] << ' ';
				if (now < cnt / 2)
					A.pb(a[i]);
				else
					B.pb(a[i]);
				now++;
			}
		cerr << ':' << (A == B) << endl;
		res += (A == B);
	}
	return res;
}

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

	ll n;
	cin >> n;
	deque<int> ans = solve(n);
	cout << ans.size() << endl;
	for (int i : ans)
		cout << i << ' ';
	cout << endl;
}























Measured memory_bytes: 256
#include <bits/stdc++.h>
#define M 1000000000
typedef long long ll;

using namespace std;

int main(){
    ll N;
    cin >> N;

    ll res=1;
    for (int i=1;i<=N;i++){
	res*=i;
	res=res%(M+7);
    }

    cout << res << endl;

    return 0;
}

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

using namespace std;

#define inf (long long)1e18
#define mod (long long)1e9 + 7
#define int long long
#define eps 1e-9
#define _ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int32_t main(void) { _
    // int t; cin >> t;
    // while (t--) {
    //     int n, k1, k2, k3; cin >> n >> k1 >> k2 >> k3;
    //     for (int i = 0; i < n; i++) {
            
    //     }
    // }
    int n; cin >> n;
    int sx = 0, sy = 0;
    int prevt = 0;
    for (int i = 1; i <= n; i++) {
        int t, x, y; cin >> t >> x >> y;
        if (abs(sx - x) + abs(sy - y) > t || (abs(sx - x) + abs(sy - y)) % 2 != (t - prevt) % 2) return cout << "No" << endl, 0;
        sx = x; sy = y;
        prevt = t;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
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; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int h[100010];

int main() {
  int n;
  while(cin>>n) {
    inputs(h,n);
    bool ng = 0;
    h[0]--;
    REP(i,n-1) {
      if (h[i+1] > h[i]) h[i+1]--;
      if (h[i+1] < h[i]) ng = 1;
    }
    cout << (ng?"No":"Yes") << endl;
  }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

template<class T>
struct BIT{
	vector<T> dat;

	BIT(int sz) : dat(sz,0){}

	void add(int i,T x){
		for(;i < dat.size();i += i & -i) dat[i] += x;
	}

	T sum(T i){
		T ret = 0;
		for(;i;i -= i & -i) ret += dat[i];
		return ret;
	}
};

signed main(){
	int n;
	cin >> n;
	const int lim = 500010;
	BIT<int> bit(lim + 10);
	bool isCompleted = false,out = false;
	for(int i = 0;i < n;i++){
		int x;
		cin >> x;
		if(isCompleted){
			No();
			continue;
		}
		if(x >= lim){
			out = true;
			Yes();
			continue;
		}
		if(bit.sum(x) == x){
			if(bit.sum(lim) == x && !out){
				Yes();
				isCompleted = true;
			}else No();
		}else{
			Yes();
			bit.add(x,1);
			while(bit.sum(x) - bit.sum(x - 1) == 2){
				bit.add(x--,-2);
				bit.add(x,1);
			}
		}
	}
}


Measured memory_bytes: 6796
using System;
using System.Collections.Generic;
using System.Linq;

namespace KPCA
{
    static class MainClass
    {

        public static void Main(string[] args)
        {

            string[] N = Console.ReadLine().Split(' ').ToArray();
            string ans = "YES";
            string str = "";

            foreach(string n in N)
            {

                if (n != "1" && n != "9" && n != "7" && n != "4")
                {
                    ans = "NO";
                }
                str += n;
            }

            if(str.IndexOf("1", StringComparison.Ordinal) < 0 || str.IndexOf("9", StringComparison.Ordinal) < 0|| str.IndexOf("7", StringComparison.Ordinal) < 0|| str.IndexOf("4", StringComparison.Ordinal) < 0)
            {
                ans = "NO";
            }



            Console.WriteLine(ans);

            return;


        }



        public static long Gcd(long a, long b)
        {
            long tmp;
            // a<bにする
            if (a >= b)
            {
                tmp = a;
                a = b;
                b = tmp;
            }

            if (a == 0)
            {
                return b;
            }

            tmp = a;
            a = b % a;
            b = tmp;
            return Gcd(a, b);

        }


        public static IEnumerable<long> PF(long n)
        {
            long i = 2;
            long tmp = n;

            while (i * i <= n) //※1
            {
                if (tmp % i == 0)
                {
                    tmp /= i;
                    yield return i;
                }
                else
                {
                    i++;
                }
            }
            if (tmp != 1) yield return tmp;//最後の素数も返す
        }




    }

}






Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	ll r, d, x;
	cin >> r >> d >> x;
	for(int i = 1; i <= 10; i ++){
		x = r * x - d;
		cout << x << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

int x;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> x;
	int g = __gcd(x, 360);
	cout << 360 / g << endl;

	return 0;
}


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

int N,K;
int data[100001];
int taba[100001];	//最初から連続して並んでいる数字の数

int main(){
	int i,num;
	int max[1000];
	int mcor = 0;
	while(1){
		cin >> N >> K;
		if(N == 0 && K == 0)
			break;
		for(i = 0;i < K;i++){
			cin >> num;
			data[num] = 1;
		}
		int tcor,count;
		tcor = 0;
		count = 0;
		for(i = 1;i <= N;i++){
			if(data[i] == 1){
				count++;
			}
			else{
				taba[tcor] = count;
				tcor++;
				if(count > 0){
					taba[tcor] = 0;
					tcor++;
				}
				count = 0;
			}
		}
		taba[tcor] = count;
		max[mcor] = 0;
		if(data[0] == 0){
			for(i = 0;i <= tcor;i++){
				if(max[mcor] < taba[i])
					max[mcor] = taba[i];
			}
		}
		else{
			for(i = 0;i <= tcor;i++){
				if(taba[i] != 0)
					continue;
				if(i == 0){
					if(1+taba[i+1] > max[mcor])
						max[mcor] = 1+taba[i+1];
				}
				else if(i == tcor){
					if(1+taba[i-1] > max[mcor])
						max[mcor] = 1+taba[i-1];
				}
				else{
					if(taba[i-1]+1+taba[i+1] > max[mcor])
						max[mcor] = taba[i-1]+1+taba[i+1];
				}
			}
		}
		for(i = 0;i <= N;i++){
			data[i] = 0;
		}
		mcor++;
	}
	for(i = 0;i < mcor;i++){
		cout << max[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1700
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <algorithm> 
#include <set>
#include <sstream>
#include <bit>
#include <time.h>
#include <bitset>
#include <iomanip>
#include <queue>
typedef long long int ll;
using namespace std;

int main()
{
	ll MOD = pow(10, 9) + 7;
	int N; cin >> N;
	vector<ll>data(2009);
	data[0] = data[1] = data[2] = 0;
	data[3] = data[4] = data[5] = 1;
	
	for (int i = 6; i <= 2000; i++) {
		data[i] = 1;
		for (int j = 3; j < i; j++) {
			data[i] += data[i - j];
		}
		data[i] = data[i] % MOD;
	}
	cout << data[N] << endl;
}

Measured memory_bytes: 3164
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	TreeSet<Integer> valSet;
	HashMap<Integer, Integer> emergeNumMap;

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		
		int n = fs.nextInt();
		int m = fs.nextInt();
		
		emergeNumMap = new HashMap<>();
		valSet = new TreeSet<>();
		
		for(int i = 0; i < n; i++) {
			int a = fs.nextInt();
			update(a,1);
		}
		
		for(int i = 0; i < m; i++) {
			int b = fs.nextInt();
			int c = fs.nextInt();
			
			update(c,b);
		}
		
		Iterator<Integer> iterator = valSet.descendingIterator();
		int addedNum = 0;
		long ans = 0;
		while(iterator.hasNext()) {
			int val = iterator.next();
			int emergeNum = emergeNumMap.get(val);
			
			if(addedNum + emergeNum < n) {
				ans += ((long)val) * emergeNum;
				addedNum += emergeNum;
			}else {
				int diff = n - addedNum;
				ans += ((long)val) * diff;
				break;
			}
		}
		
		System.out.println(ans);
		
	}
	
	void update(int val, int num) {
		if(!valSet.contains(val)) {
			valSet.add(val);
			emergeNumMap.put(val, num);
		}else {
			int emergeNum = emergeNumMap.get(val);
			emergeNumMap.put(val, emergeNum+num);
		}
	}

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


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

using namespace std;

int N, Q;
vector<int> graph[200001];
long long ans[200001];


int dfs(int curNode, int parentNode) {
    for (int childNode : graph[curNode]) {
        if (childNode == parentNode) {
            continue;
        }
        ans[childNode] += ans[curNode];
        dfs(childNode, curNode);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> N >> Q;
    
    for (int i = 1; i <= N-1; i++) {
        int a_i, b_i;
        cin >> a_i >> b_i;
        graph[a_i].push_back(b_i);
        graph[b_i].push_back(a_i);
    }
        
    for (int i = 1; i <= Q; i++) {
        int p_i, x_i;
        cin >> p_i >> x_i;
        ans[p_i] += x_i;
    }
    
    dfs(1, -1);
    
    for (int i = 1; i <= N; i++) {
        cout << ans[i] << " ";
    }
        
    
    return 0;
}



Measured memory_bytes: 24320
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#include<bitset>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
/*string st(int bina,int n){
  string out;
  for (int i = 0; bina>0 ; i++){
    out = (char)((bina%2)+'0')+out;
    bina = bina/2;
  }
  while(out.size()!=n)out='0'+out;
  return out;
}  */
int main(){
  int n;
  while(cin>>n,n){
    int ans=9999999;
    vector<int>in(n);
    int sum2=0;
    rep(i,n){cin>>in[i];sum2+=in[i];}
    rep(i,1<<n){
      int sum=0;
      rep(j,n)if((i>>j)&1)sum+=in[j];
      if(ans>abs(2*sum-sum2))ans=abs(sum2-2*sum);
      //cout<<i<<" "<<sum<<endl;
    }
    cout<<ans<<endl;
  }

}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector<long long> h(n);
	for(int i=0; i<n; i++) cin >> h[i];

	long long cnt = 0;
	sort(h.begin(), h.end());
	int size = n-k;

	if(!(size <= 0)) {
		for(int i=0; i<size; i++) {
			cnt += h[i];
		}
	}
	cout << cnt;
  
	return 0;
}


Measured memory_bytes: 1792
def judge_kaibun(text):
    if len(text) % 2 == 0:
        if text[:len(text)//2] == text[len(text)//2:][::-1]:
            return True
        else:
            return False
    else:
        if text[:len(text)//2] == text[len(text)//2+1:][::-1]:
            return True
        else:
            return False


S = input()
if judge_kaibun(S) and judge_kaibun(S[:len(S)//2]) and judge_kaibun(S[len(S)//2+1:]):
    print('Yes')
else:
    print('No')

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

using namespace std;

int dp[1000000], arr[100], n;

int helper(int stones){

    if(dp[stones] != -1)
        return dp[stones];

    for(int i = 0; i < n; ++i){
        if(stones >= arr[i] && helper(stones - arr[i]) == 0){
            dp[stones] = 1;
            return 1;
        }
    }

    dp[stones] = 0;
    return 0;

}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int s; cin >> n >> s;
    
    for(int i = 0; i < n; ++i)
        cin >> arr[i];

    for(int i = 0; i <= s; ++i)
        dp[i] = -1;

    cout << (helper(s) == 0 ? "Second\n" : "First\n");

    return 0;
}

Measured memory_bytes: 3712
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define repc(i, s, t) for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(ios_base::fixed);
    cout.precision(12);

    var(string, s);

    print(s == "ABC" ? "ARC" : "ABC");

    return 0;
}


Measured memory_bytes: 3608
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));

  $H="MARCH";

  $cnt = array_fill(0,5,0);
  for ($i=0; $i<$n; $i++) {
    list($s) = explode(" ", trim(fgets(STDIN)));
    for ($j=0;$j<5; $j++){
      if($s[0] == $H[$j]){
        $cnt[$j]++;
        break;
      }
    }
  }

  $ans=0;
  $all=1<<5;
  for($i=0;$i<$all;$i++){
    $x=$i;
    $a=[];
    for($j=0;$j<5;$j++){
      if($x >> $j & 1 == 1){
        $a[]=$cnt[$j];
      }
    }
    if(count($a)==3){
      $p=1;
      for($j=0;$j<3;$j++){
        $p*=$a[$j];
      }
      $ans+=$p;
    }
  }
  echo $ans;

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

int main() {
char N;
cin>>N;
  if(N=='a'){
   cout<<"vowel"<<endl; 
  }
  else if(N=='i'){
   cout<<"vowel"<<endl; 
  }
 else if(N=='u'){
   cout<<"vowel"<<endl;   
  }
   else if(N=='e'){
   cout<<"vowel"<<endl;   
  }
   else if(N=='o'){
   cout<<"vowel"<<endl;   
  }
   else {
   cout<<"consonant"<<endl;   
  }
}


Measured memory_bytes: 256
n, m, x = list(map(int, input().split()))
books = []
for _ in range(n):
    books.append(list(map(int, input().split())))

# 参考書の組み合わせ
price_min = pow(10, 6) * n
found = False
for bits in range(2 ** n):
    level = [0] * m
    price = 0
    # ビットが立っている参考書の理解度と値段を加算
    for book in range(n):
        if (bits >> book) & 1:
            price += books[book][0]
            for alg in range(m):
                level[alg] += books[book][alg + 1]
    # 理解度がXに満たないアルゴリズムを抽出
    level = list(filter(lambda lv: lv < x, level))
    # 理解度の条件を満たし、かつ合計額が最低値を下回るときに最低値を更新
    if len(level) == 0 and price < price_min:
        found = True
        price_min = price
print(price_min if found else "-1")

Measured memory_bytes: 74128
import sys
input=sys.stdin.readline

def gcd(a,b):
  if b==0:
    return a
  else:
    return gcd(b,a%b)
def calc():
  n=int(input())
  arr=list(map(int,input().split()))
  g=arr[0]
  cnt=[0]*(10**6+1)
  for val in arr:
    g=gcd(g,val)
    cnt[val]+=1
  for i in range(2,10**6+1):
    tmp=0
    for j in range(i,10**6+1,i):
      tmp+=cnt[j]
    if tmp>=2:
      break
  if i==10**6:
    print('pairwise coprime')
  elif g==1:
    print('setwise coprime')
  else:
    print('not coprime')
calc()

Measured memory_bytes: 127360