akhauriyash/Code-Regression huggingface dataset:
n =  int(raw_input())
dic = {}
flag = 0
lis = []
for i in xrange(n):
    s = raw_input()
    lis.append(s)
    if s in dic:
        flag = 1
    else:
        dic[s] = 1
for i in range(1, n):
    #print lis[i][len(lis[i])-1:]
    #print lis[i]
    #print lis[i][0:1]
    #print lis[i-1][len(lis[i-1])-1:]
    if lis[i][0:1] != lis[i-1][len(lis[i-1])-1:]:
        flag = 1
        break
if flag == 1:
    print "No"
else:
    print "Yes"

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

using namespace std;
using ll=long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (n); i < (a); i++)

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int n,m;cin>>n>>m;
  int k,hoge;
  map<int,int> map;
  rep(i,n){
    cin>>k;
    rep(j,k){
      cin>>hoge;
		  auto itr = map.find(hoge);
		  if(itr!=map.end() ) {
		    map[hoge]++;
		  } else {
		    map[hoge]=1;
		  }
    }
  }

  int cnt=0;
  for(auto itr = map.begin(); itr != map.end(); ++itr)if(itr->second==n)cnt++;
  cout<<cnt<<endl;
}


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

//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)

#define All(a) (a).begin(),(a).end()

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

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

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数

int main()
{
	int n;
	vector<int> h;

	cin >> n;
	REP(i, n) {
		int a;
		cin >> a;
		h.push_back(a);
	}

	REPS(i, n - 1) {
		if (h[i] < h[i - 1]) {
			cout << "No" << endl;
			return 0;
		}
		if (h[i] != h[i - 1])h[i]--;
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 892
lis = [int(input()) for _ in range(5)]
fir = []
sur = []
for i in lis:
    if i % 10 == 0:
        fir.append(i)
        sur.append(0)
    else:
        fir.append(i + (10 - i%10))
        sur.append(10 - i % 10)
print(sum(fir)-max(sur))

Measured memory_bytes: 3064
use std::cmp;
use std::collections::VecDeque;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let first = sc.read::<usize>() - 1;
    let second = sc.read::<usize>() - 1;
    let mut graph = vec![vec![]; n];
    for _ in 1..n {
        let a: usize = sc.read::<usize>() - 1;
        let b: usize = sc.read::<usize>() - 1;
        graph[a].push(b);
        graph[b].push(a);
    }

    let mut second_dist = vec![n; n];
    second_dist[second] = 0;
    let mut q = VecDeque::new();
    q.push_back(second);
    while let Some(v) = q.pop_front() {
        for &next in graph[v].iter() {
            if second_dist[next] > second_dist[v] + 1 {
                second_dist[next] = second_dist[v] + 1;
                q.push_back(next);
            }
        }
    }

    let mut first_dist = vec![None; n];
    first_dist[first] = Some(0);
    let mut q = VecDeque::new();
    q.push_back(first);
    while let Some(v) = q.pop_front() {
        for &next in graph[v].iter() {
            if first_dist[next].is_none() {
                let d = first_dist[v].unwrap() + 1;
                if d <= second_dist[next] {
                    first_dist[next] = Some(d);
                }
                if d < second_dist[next] {
                    q.push_back(next);
                }
            }
        }
    }

    let mut ans = 0;
    for i in 0..n {
        if let Some(d) = first_dist[i] {
            ans = cmp::max(ans, d);
            let second_dist = second_dist[i];
            ans = cmp::max(ans, second_dist - 1);
        }
    }

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

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 14588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N, A;
    cin >> N >> A;
    int x[N];
    rep(i, N) {cin >> x[i]; x[i] -= A;}
    ll dp[N+1][5001];
    fill(dp[0], dp[N+1], 0);
    dp[0][2500] = 1;
    rep(i, N){
        rep(j, 5001){
            if(dp[i][j] == 0) continue;
            dp[i+1][j] += dp[i][j];
            dp[i+1][j+x[i]] += dp[i][j];
        }
    }
    cout << dp[N][2500]-1 << endl;
}

Measured memory_bytes: 5540
#include<bits/stdc++.h>
using namespace std;
#define RI register int
typedef long long LL;
const int mod=1e9+7;
int n,m,a1,a2,b,s;LL K;
char mp[1005][1005];int tmp[3];
int ksm(int x,LL y) {
	int re=1;
	for(;y;y>>=1,x=1LL*x*x%mod) if(y&1) re=1LL*re*x%mod;
	return re;
}
struct matrix{int t[3][3];}X,re;
int qm(int x) {return x>=mod?x-mod:x;}
matrix operator * (matrix A,matrix B) {
	matrix C;
	for(RI i=0;i<3;++i)
		for(RI j=0;j<3;++j) C.t[i][j]=0;
	for(RI k=0;k<3;++k)
		for(RI i=0;i<3;++i)
			for(RI j=0;j<3;++j)
				C.t[i][j]=qm(C.t[i][j]+1LL*A.t[i][k]*B.t[k][j]%mod);
	return C;
}
void work() {
	for(RI i=0;i<3;++i) re.t[i][i]=1;
	X.t[0][0]=X.t[1][1]=s,X.t[1][2]=1,X.t[2][2]=a1;
	for(LL i=K-2;i;i>>=1,X=X*X) if(i&1) re=re*X;
	int V=0,E=0;
	tmp[0]=s,tmp[1]=b,tmp[2]=a1*b;
	for(RI i=0;i<3;++i) V=qm(V+1LL*re.t[0][i]*tmp[i]%mod);
	for(RI i=0;i<3;++i) E=qm(E+1LL*re.t[1][i]*tmp[i]%mod);
	printf("%d\n",qm(V-E+mod));
}
int main()
{
	scanf("%d%d%lld",&n,&m,&K);
	if(K<=1) {puts("1");return 0;}
	for(RI i=1;i<=n;++i) scanf("%s",mp[i]+1);
	for(RI i=1;i<=m;++i) if(mp[1][i]=='#'&&mp[n][i]=='#') ++a1;
	for(RI i=1;i<=n;++i) if(mp[i][1]=='#'&&mp[i][m]=='#') ++a2;
	for(RI i=1;i<=n;++i)
		for(RI j=1;j<=m;++j) if(mp[i][j]=='#') ++s;
	if(a1&&a2) {puts("1");return 0;}
	else if(!a1&&!a2) {printf("%d\n",ksm(s,K-1));return 0;}
	if(a1) {
		for(RI i=1;i<n;++i)
			for(RI j=1;j<=m;++j)
				b+=(mp[i][j]=='#'&&mp[i+1][j]=='#');
	}
	else {
		for(RI i=1;i<=n;++i)
			for(RI j=1;j<m;++j)
				b+=(mp[i][j]=='#'&&mp[i][j+1]=='#');
	}
	a1=a1|a2,work();
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define bp  __builtin_popcount
#define pb push_back
#define sz(s) (int)(s.size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;
const  double EPS = 1e-9;
const int mod = 1e9+7;
/*
ll GCD(ll a,ll b){return (a)?GCD(b%a,a):b;}
ll LCM(ll a, ll b){return a*b/GCD(a,b);}
ll fastpow(ll b, ll p)
{if(!p)return 1;ll ret = fastpow(b, p >> 1);ret *= ret;if(p&1)ret*= b;return ret;}
*/
int dx[] = { -1,-1,-1,0,+1,+1,+1,0 };   // directional array
int dy[] = { -1,0,+1,+1,+1,0,-1,-1 };

ll GCD(ll a,ll b)
{
    return b?GCD(b,a%b):a;
}
ll LCM(ll a, ll b)
{
   return a/GCD(a,b)*b;
}

int main()
{
    ios::sync_with_stdio(0);
    int n,i;
    ll ans,arr[101];
    while(~scanf("%d",&n))
    {
        ans=1LL;
        for(i=0; i<n; i++)
            scanf("%lld",&arr[i]);
        for(i=0; i<n; i++)
            ans=LCM(ans,arr[i]);
        printf("%lld\n",ans);
    }
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
 
public class Program
{
    public static void Main()
    {
        string S = Console.ReadLine();
        if (Search(ref S, 0))
            Console.WriteLine("YES");
        else
            Console.WriteLine("NO");
    }
    static bool Search(ref string s, int begin)
    {
        if (begin == s.Length)
            return true;
        if (begin + 5 > s.Length)
            return false;
        else
        {
            if (s[begin] == 'd')
            {
                if (s.Substring(begin, 5) == "dream")
                {
                    if (begin + 7 <= s.Length && s.Substring(begin, 7) == "dreamer")
                        return Search(ref s, begin + 5) || Search(ref s, begin + 7);
                    else
                        return Search(ref s, begin + 5);
                }
                else
                    return false;
            }
            else if (s.Substring(begin, 5) == "erase")
            {
                if ((begin + 6 <= s.Length && s.Substring(begin, 6) == "eraser"))
                        return Search(ref s, begin + 6);
                else
                    return Search(ref s, begin + 5);
            }
            else
                return false;
        }
    }
}

Measured memory_bytes: 11744
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n); i >= 0; i--)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
const long long MOD = 1000000007;
typedef long long ll;

int main(){
	int N, M;
	cin >> N;
	bool JD = true;
	priority_queue<ll> D;
	priority_queue<ll> T;
	rep(i, N){
		ll A;
		cin >> A;
		D.push(A);
	}
	cin >> M;
	rep(i, M){
		ll A;
		cin >> A;
		T.push(A);
	}
	if(N < M){
		JD = false;
	} else {
		rep(i, N){
			if(!T.empty()){
				ll d = D.top();
				ll t = T.top();
				D.pop();
				if(d == t){
					T.pop();
				} else if(d > t){
					continue;
				} else {
					JD = false;
					break;
				}
			}
		}
	}
	if(!T.empty())JD = false;
	cout << ((JD) ? "YES" : "NO") << endl;
}

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

vector<long> a;
long N,M;
vector<vector<int>> g(100005);
vector<int> d(100005,-1);
void bfs(int s){
  queue<long> q;
  d[0] = 0;
  q.push(0);
  long u;
  int idx=0;
  while (!q.empty()) {
        int v = q.front(); // キューから先頭頂点を取り出す
        q.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : g[v]) {
            if (d[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            d[nv] = d[v] + 1;
            q.push(nv);
        }
    }

return;

}

int main() {


cin>>N>>M;
for(int i=0;i<M;i++){
  int a,b;
  cin>>a>>b;
  a--,b--;
  g[a].push_back(b);
  g[b].push_back(a);
}


//for(int i=0;i<N;i++) cin>>a[i];

bfs(0);

for(int i=0;i<N;i++){
  if(d[i]==-1){
    cout<<"No"<<endl;
    return 0;
  }
}
cout<<"Yes"<<endl;
for(int i=1;i<N;i++){
  int dpth=d[i];
  for(int nv : g[i]){
    if(d[nv]==d[i]-1){
      //cout<<"joint"<<i<<nv<<endl;
      cout<<nv+1<<endl;
      break;
    }
  }
}

}


Measured memory_bytes: 10520
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int N, M;
    cin >> N >> M;

    V(bool) from(N, false), to(N, false);

    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        if(a==0) from[b] = true;
        else if(b==0) from[a] = true;
        else if(a==N-1) to[b] = true;
        else if(b==N-1) to[a] = true;
    }
    
    bool res = false;
    rep(i, N) {
        if(from[i] && to[i]) {
            res = true;
            break;
        }
    }
    
    if(res) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vp = vector<P>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvb = vector<vb>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll  INFL = 1e18;


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    
    ll N, K; cin >> N >> K;
    vvl C(3001, vl(3001));
    for(int i = 0; i <= 3000; i++)
    {
        C[i][0] = C[i][i] = 1;
        for(int j = 1; j < i; j++)
        {
            C[i][j] = (C[i-1][j] + C[i-1][j-1]) % MOD;
        }
    }
    REPS(i, K) cout << (C[N-K+1][i] * C[K-1][i-1]) % MOD << endl;
}

Measured memory_bytes: 70784
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    char c0, c1;
    scanf("%c %c", &c0, &c1);

    if(c0<c1) {
        printf("<\n");
    }
    else if(c0==c1) {
        printf("=\n");
    }
    else {
        printf(">\n");
    }

 
    return 0;
}


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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

vi A;

long solve_move(int mod, int N){
    vi A_MOD(N);    
    int move = 0;
    long mod_sum = 0;
    REP(i, 0, N) {
        A_MOD[i] = A[i] % mod;
        mod_sum += A_MOD[i];
    }
    
    sort(A_MOD.rbegin(), A_MOD.rend());
    REP(i, 0, mod_sum/mod){
        move += mod - A_MOD[i];
       // cout<<mod<<" "<<A_MOD[i]<<endl;
    }
    return move;
}

int main() {
    int N, K;
    cin>>N>>K;
    long sum = 0;
    A.resize(N);
    REP(i, 0, N){
        cin >> A[i];
        sum += A[i];
    }
    int max_GCD = 0;
    int root_sum = pow(sum, 0.5);
    REP(i, 1, root_sum + 1){
        if(sum % i == 0){
            int move = solve_move(i, N);

            if(move <= K && max_GCD < i) max_GCD = i;
            //cout<<move<<" "<<i<<endl;
            move = solve_move(sum/i, N);
            if(move <= K && max_GCD < sum / i) max_GCD = sum / i;
             //cout<<move<<" "<<i<<endl;
        }
    }
    cout << max_GCD << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
using namespace std;
#define int long long
#define loop(i,a,b) for(i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define vct vector
#define stk stack
#define qu queue
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define br break
#define con continue
#define re return
#define tc(t) int t; cin>>t; while(t--)
#define q(q) int q; cin>>q; while(q--)
#define subs substr
#define er erase
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;
signed main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        /*int te;
        cin>>te;
        while(te--)*/{
                int s,max_sum=0,temp_sum=0,even=0,odd=0,color=1,oka=5,okb=0,inda=-1,indb=-1,n,maxf=INT_MAX,y,index=0,d,z,p=1,i,j,k,x=1,l,sum=0,ans=0,count=LONG_MAX,count2=0,count1=0,count3=0,ans1,ans2,berry=0,straw=0,berry1=0,straw1=0,berry2=0,straw2=0;
                cin>>n>>k;
                vct<int> v(n+1);
                loop(i,1,n+1){
                        cin>>v[i];
                }
                vct<int> t(n+1,INT_MAX);
                t[1]=0;
                t[2]=abs(v[2]-v[1]);
                t[0]=0;
                for(i=3;i<=min(n,k);i++){
                        t[i]=abs(v[i]-v[1]);
                }
                loop(i,k+1,n+1){
                        for(j=i-k;j<i;j++){
                                t[i]=min(t[i],t[j]+abs(v[i]-v[j]));
                        } 
                }
                cout<<t[n];
        }
        return 0;
}


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,t,a;
    cin>>n>>t>>a;
    vi h(n);
    rep(i,n)cin>>h[i];
    double m=1e9;
    int ans;
    rep(i,n){
        double tt=abs(t-(double)h[i]*0.006-a);
        if(m>tt){
            m=tt;
            ans=i+1;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	static int all_day;
	static final int set_data = 10000;
	static long[][] tomato = new long[2][]; 
	static long[][] cream = new long[2][];
	static long[][] basilico = new long[2][];
	
	static void setData(int[][] data, int today) {
		boolean flag = false;
		for(int r = 0; r < data.length; r++) {
			if((data[r][0] - 1) == today) {
				Type_accumulate(data[r][1], today);
				flag = true;
			}
			if(flag == false && r == data.length - 1) {
				Not_Only_accumulate(today);
			}
		}
	}
	
	static void Not_Only_accumulate(int today) {
		//トマト
		tomato[0][today] = tomato[1][today - 1] % set_data;
		tomato[1][today] = cream[0][today - 1] + cream[1][today - 1] + basilico[0][today - 1] + basilico[1][today - 1] % set_data;
		//クリーム
		cream[0][today] = cream[1][today - 1] % set_data;
		cream[1][today] = tomato[0][today - 1] + tomato[1][today - 1] + basilico[0][today - 1] + basilico[1][today - 1] % set_data;
		//バジル
		basilico[0][today] = basilico[1][today - 1] % set_data;
		basilico[1][today] = tomato[0][today - 1] + tomato[1][today - 1] + cream[0][today - 1] + cream[1][today - 1] % set_data;
	}
	
	static void Type_accumulate(int kind, int today) {
		switch(kind) {
		case 1: //トマトの場合
			tomato[0][today] = tomato[1][today - 1] % set_data; 
			tomato[1][today] = cream[0][today - 1] + cream[1][today - 1] + basilico[0][today - 1] + basilico[1][today - 1] % set_data;
			break;
		case 2: //クリームの場合
			cream[0][today] = cream[1][today - 1] % set_data;
			cream[1][today] = tomato[0][today - 1] + tomato[1][today - 1] + basilico[0][today - 1] + basilico[1][today - 1] % set_data;
			break;
		case 3: //バジルの場合
			basilico[0][today] = basilico[1][today - 1] % set_data;
			basilico[1][today] = tomato[0][today - 1] + tomato[1][today - 1] + cream[0][today - 1] + cream[1][today - 1] % set_data;
			break;
		}
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner stdIn = new Scanner(System.in);
		
		all_day = stdIn.nextInt();
		for(int r = 0; r < tomato.length; r++) {
			tomato[r] = new long[all_day];
			cream[r] = new long[all_day];
			basilico[r] = new long[all_day];
		}
		int decided_day = stdIn.nextInt();
		int[][] data = new int[decided_day][2];
		boolean flag = true;
		
		for(int r = 0; r < decided_day; r++) { //読み込み
			data[r][0] = stdIn.nextInt(); //day
			data[r][1] = stdIn.nextInt(); //kind
	
			if(flag == true && data[r][0] == 1) {
				switch(data[r][1]) {
				case 1: tomato[1][0] = 1; break;
				case 2: cream[1][0] = 1; break;
				default: basilico[1][0] = 1; break;
				}
				flag = false;
			} else if(flag == true && (r == decided_day - 1 || decided_day == 0)){
				tomato[1][0] = 1;
				cream[1][0] = 1;
				basilico[1][0] = 1;
				flag = false;
			}
		}	
		for(int r = 1; r < all_day; r++) { //r + 1 = 日にち
			setData(data, r);
		}
		
		System.out.println((tomato[0][all_day - 1] + tomato[1][all_day - 1] + cream[0][all_day - 1] + cream[1][all_day - 1] + basilico[0][all_day - 1] + basilico[1][all_day - 1]) % set_data);		
	}
}

Measured memory_bytes: 19744
s,a,b=[set(map(int,input().split()))for j in[0]*3];c=1;N=M=0;k=x=max(a)
while k:A=k in a;B=k in b;N+=A;M+=B;c*=[M*N-x+k,N,M,1][A*2+B];c%=10**9+7;k-=1
print(c)

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

int main() {
    long long n,m;
    cin >> n >> m;
    long long h[n];
    long long c[n];
    long long d[n];
    for(int i=0;i<n;i++){
        cin >> h[i];
        c[i]=0;
        d[i]=0;
    }
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        c[a-1]++;
        c[b-1]++;
        if(h[a-1]>h[b-1]) d[a-1]++;
        else if(h[b-1]>h[a-1]) d[b-1]++;
    }
    long long ans=0;
    for(int i=0;i<n;i++){
        if(c[i]==d[i]&&c[i]>0) ans++;
        if(c[i]==0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5952
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

const double PI = 3.1415926535;

int main() {
	// 小数点以下12ケタを表示させるためのおまじない
	cout << fixed << setprecision(12);

	while (1) {
		int n;
		cin >> n;
		if (n == 0) return 0;
		double s[1000];
		double sum = 0;
		for (int i = 0; i < n; i++) {
			cin >> s[i];
			sum += s[i];
		}
		double avg = (double)sum / n;
		double v = 0.0;
		for (int i = 0; i < n; i++) {
			v += (s[i] - avg) * (s[i] - avg);
		}
		v /= (double)n;
		cout << sqrt(v) << endl;
	}
	return 0;
}



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

namespace AC
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();

            Console.WriteLine(input[0] == input[1] ? "Yes" : "No");
            Console.ReadKey();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int len = S.length();
    int cnt[3] = {};
    REP(i,len){
        cnt[S[i]-'a']++;
    }
    int dif[3] = {};
    dif[0] = abs(cnt[0]-cnt[1]);
    dif[1] = abs(cnt[1]-cnt[2]);
    dif[2] = abs(cnt[2]-cnt[0]);

    int maxdif = *max_element(dif, dif+3);

    if(maxdif <= 1) cout << "YES" << endl;
    else cout << "NO" << endl;

}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main() {

	int n, debt=100000;

	cin >> n;
	for(int i=0; i<n; i++) {
		debt*=1.05;
		if(debt%1000!=0)
			debt+=1000-(debt%1000);
	}
	cout << debt << endl;

	return 0;

}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<vector<pair<int, int> > > vvp;
typedef vector<pair<int, int> > vp;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<vector<ll> > vvl;
typedef vector<ll> vl;
typedef vector<vector<bool> > vvb;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<string, int> psi;
typedef pair<int, int> pii;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define yn(f) (f?"yes":"no")
#define YN(f) (f?"YES":"NO")
#define Yn(f) (f?"Yes":"No")
#define mod (1e9+7)
#define inf (1e9+7)
#define nil -1
int main() {
	int N;
	cin >> N;
	vi H(N);

	for (int i = 0; i < N; i++)cin >> H[i];
	string ans = "Yes";
	for (int i = N-1; i >=1; i--)
	{
		if (H[i-1] - H[i] ==1) {
			H[i - 1]--;
		}
		else if (H[i-1] - H[i] >= 2) {
			ans = "No";
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int n, k;
int ans = 1;
/**********************************************/

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

    REP(i, n){
        ans = min(ans * 2, ans + k);
    }

    cout << ans << endl;
}


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

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> a(n,0);
	int sum=0;
	for(int i=0;i<n;i++){
		cin >> a[i];
		sum+=a[i];
	}
	int border=(sum+4*m-1)/(4*m);
	int cnt=0;
	for(int i=0;i<n;i++){
		if(border<=a[i]){
			cnt++;
		}
	}
	if(cnt>=m){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,st,sr;
    int a=0,i;
    cin>>s>>st;
    sr=s+st;
    for (i=0;i<sr.length();i++)
    a=a*10+sr[i]-49+1;
    if (sqrt(a)==float(sqrt(a))) cout<<"Yes";
    else cout<<"No";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
b = list(input())
t = list(input())
kouho = []
if len(b) < len(t):
  print("UNRESTORABLE")
else:
  for i in range(len(b)-len(t)+1):
    a = b[:]
    ok = True
    for j in range(len(t)):
      if a[i+j] == "?" or a[i+j] == t[j]:
        a[i+j] = t[j]
      else:
        ok = False
    if ok:
      for j in range(len(a)):
        if a[j] == "?":
          a[j] = "a"
      kouho.append("".join(a))
  if kouho:
    kouho.sort()
    print(kouho[0])
  else:
    print("UNRESTORABLE")

Measured memory_bytes: 3064
H, W, d = map(int, input().split())
for i in range(H):
	ans = ""
	for j in range(W):
		if (i+j) % (2*d) < d and (i-j) % (2*d) < d:
			ans += "R"
		elif (i+j) % (2*d) >= d and (i-j) % (2*d) < d:
			ans += "Y"
		elif (i+j) % (2*d) < d and (i-j) % (2*d) >= d:
			ans += "G"
		else:
			ans += "B"
	print(ans)

Measured memory_bytes: 3316
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    String s;
    char[] c;
    int l, i, a, count;
    double w, h;

    count = 0; a = 0; w = 0; h = 0;
    for(;sc.hasNext();){
      s = sc.next(); c = new char[s.length()];
      for(i = 0;i < s.length();i++)c[i] = s.charAt(i);
      l = 0;
      for(i = l;i < s.length();i++)if(c[i] == ',')break;
      a = readint(c, l, i); l = ++i;
      for(i = l;i < s.length();i++)if(c[i] == ',')break;
      w = readdouble(c, l, i);
      l = ++i;
      h = readdouble(c, l, s.length());

      if(w / h / h >= 25.0){
        out.println(a); count++;
      }
    }
    if(count == 0)out.println("????????????");

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
  private static int readint(char[] ch, int l, int r){
    int i, d, res, s;
    d = 1; res = 0; s = 1;
    if(ch[l] == '-'){ s = -1; l++; }
    for(i = r - 1;i >= l;i--){
      res += d * (int)(ch[i] - '0');
      d *= 10;
    }
    return res * s;
  }

  private static double readdouble(char[] ch, int l, int r){
    int i;
    double res, d, s = 1;
    if(ch[l] == '-'){ s = -1; l++; }
    d = 1.0; res = 0.0;
    for(i = l;i < r;i++){
      if(ch[i] == '.')break;
      d *= 10;
    }
    d /= 10;
    for(i = l;i < r;i++)if(ch[i] != '.'){
      res += d * (double)(ch[i] - '0');
      d /= 10;
    }
    return res * s;
  }
}

Measured memory_bytes: 15296
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }




int main() {
	int n;
	cin >> n;
	if (n % 2 == 1) {
		cout << n * (n - 1) / 2 - (n - 1) / 2 << endl;
		FOR(i, 1, n + 1) {
			FOR(j, i + 1, n + 1) {
				if (i + j != n) {
					printf("%d %d\n", i, j);
				}
			}
		}
	}
	else {
		cout << n * (n - 1) / 2 - (n) / 2 << endl;
		FOR(i, 1, n + 1) {
			FOR(j, i + 1, n + 1) {
				if (i + j != n+1) {
					printf("%d %d\n", i, j);
				}
			}
		}
	}
	return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
    int n, k;
    cin >> n >> k;
    
    double p[n];
    
    rep(i, n){
        cin >> p[i];
        p[i]++;
    }
    
    double sum = 0;
    double s[n+1];
    s[0] = 0;
    rep(i, n){
        sum += p[i];
        s[i+1] = sum;
    }
    
    double res = 0;
    rep(i, n - k + 1){
        double s_k = s[k + i] - s[i];
        res = max(res, s_k);
    }
    
    cout << setprecision(7) << res/2 << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return (t * t) % mod;
    } else {
        return (modpow(m, n - 1) * m) % mod;
    }
}
bool bitcheck(ll x, ll y) { return (x >> y) & 1; }

template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;
long long power(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}

long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }

const ll INF = 1LL << 60;

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

ll nCkmod(ll n, ll k) {
    ll denomi = 1;
    for (int i = n; i > n - k; i--) {
        denomi *= i;
        denomi %= mod;
    }
    ll numera = 1;
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}
map<ll, ll> cnt;
void primeFactors(long long n) {
    while (n % 2 == 0) {
        cnt[2]++;
        n = n / 2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2) {
        while (n % i == 0) {
            cnt[i]++;
            n = n / i;
        }
    }
    if (n > 2) {
        cnt[n]++;
    }
}
int main() {
    ll q;
    cin >> q;
    map<string, ll> cnt;
    REP(i, q) {
        ll a, x;
        string key;
        cin >> a;
        if (a == 0) {
            cin >> key >> x;
            cnt[key] = x;
        } else if (a == 1) {
            cin >> key;
            cout << cnt[key] << endl;
        } else {
            cin >> key;
            cnt.erase(key);
        }
    }
}


Measured memory_bytes: 25872
N, K = map(int, input().split())
ps = list(map(int, input().split()))

cursum = sum(ps[:K])
l = 0
h = K
i = 0
best = cursum
while h != N:
    cursum += ps[h] - ps[l]
    h += 1
    l += 1
    if (cursum > best):
        best = cursum
        i = l

ans = 0
for j in range(K):
    ans += (ps[i+j] + 1) / 2 
print(ans)


Measured memory_bytes: 71792
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=2e3+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
   }

   void solve() {
	        string s,p="";
	        cin>>s;
	        int q,ct=0;
	        cin>>q;
	          
	        deque<char> dq;
	        for(auto to:s)
	         dq.pb(to);
	        
	        int f=0;
	        rep(i,0,q) {
				   int x,y;
				   char c;
				   cin>>x;
				   if(x==1)				      
					      ct^=1;				   
					   
				   else {
					      cin>>y>>c;
					      --y;
					      if(ct^y) dq.pb(c);
					      else dq.push_front(c);				        
			           }			           
				   }
				   for(auto to:dq)
				    p+=to;
				     
				     
				     if(ct) reverse(all(p));
				     
				     cout<<p<<endl;				   		   
	   }

    
int32_t main() {
	cool;
	int t=1;
	//cin>>t;
	while(t--)
	solve();


return 0;	   
}


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

using namespace std;

int n,k;
long long a[100005],b[100005],x[100005];

int main()
{
    long long s1=0,s2=0,cnt=0,sum=0;
    cin>>n;

    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        s1+=a[i];
    }

    for(int i=1;i<=n;i++)
    {
        cin>>b[i];
        s2+=b[i];
        if(b[i]>a[i])
        {
            sum+=b[i]-a[i];
            cnt++;
        }
        else if(b[i]<a[i])x[++k]=a[i]-b[i];
    }

    if(s2>s1)
    {
        cout<<"-1";
        return 0;
    }

    sort(x+1,x+k+1,greater<int>());

    x[k+1]=0;
    for(int i=1;i<=k+1;i++)
        if(sum<=0)
        {
            cout<<cnt+i-1;
            return 0;
        }
        else sum-=x[i];


    return 0;
}


Measured memory_bytes: 2176
import scala.annotation.tailrec

object Main extends App{
  import scala.io.StdIn._
  solve()
  @tailrec def solve(): Unit = {
    val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
    if (n == 0) return
    val scores = Array.fill(n){0}
    for (_ ← 0 until m){
      val s = readLine.trim.split(' ').map(_.toInt)
      for (i ← s.indices) {
        scores(i) += s(i)
      }
    }
    println(scores.max)
    solve()
  }
}


Measured memory_bytes: 60700
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <string>
#include <random>
#include <map>
#pragma warning(disable : 4996)


char s[4096];
char t[16384];

int main(void) {
	int sx, sy, tx, ty;
	scanf("%d %d %d %d", &sx, &sy, &tx, &ty);

	char *p = &s[0];
	for (int y = sy; y < ty; ++y) {
		if (ty > sy) {
			*(p++) = 'U';
		}
		else {
			*(p++) = 'D';
		}
	}
	for (int x = sx; x < tx; ++x) {
		if (tx > sx) {
			*(p++) = 'R';
		}
		else {
			*(p++) = 'L';
		}
	}
	*(p++) = '\0';
	strcpy(t, s);
	int len = strlen(s);
	p = t + len;
	for (int i = 0; i < len; ++i) {
		if (s[i] == 'U') *(p++) = 'D';
		if (s[i] == 'D') *(p++) = 'U';
		if (s[i] == 'R') *(p++) = 'L';
		if (s[i] == 'L') *(p++) = 'R';
	}
	char *r = p;
	if (tx > sx) {
		*(p++) = 'L';
	}
	else {
		*(p++) = 'R';
	}
	char c = s[0];
	for (int i = 0; i < len; ++i) {
		*(p++) = s[i];
		if((i+1 < len) && (s[i] != s[i+1])) {
			*(p++) = s[i];
			*(p++) = s[i+1];
		}
		if (!(i+1 < len)) {
			if (ty > sy) {
				*(p++) = 'D';
			}
			else {
				*(p++) = 'U';
			}
		}
	}
	*p  = '\0';
	len = strlen(r);
	for (int i = 0; i < len; ++i) {
		if (*(r + i) == 'U') *(p++) = 'D';
		if (*(r + i) == 'D') *(p++) = 'U';
		if (*(r + i) == 'R') *(p++) = 'L';
		if (*(r + i) == 'L') *(p++) = 'R';
	}
	*(p++) = '\0';
	printf("%s", t);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const int M=1e9+7;// M=1e9+7;//M=300000;//
const int N=1e5+5;
typedef long long int ll;
using namespace std;
 
ll cnt(0),n,m,x,y,i,j,temp,t,k,ans(0),sum(0),mn(M),mx(-9e9);

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s,ss;
	cin>>s>>ss;
	cout<<ss<<s;
	
}

Measured memory_bytes: 3616
n = int(input())
a = list(map(int, input().split()))

b = set(a)

hoge = {}

for x in b:
    hoge[x] = 0

for x in a:
    hoge[x] += 1

ans = n
for x in b:
    if hoge[x] >= x:
        ans -= x

print(ans)

Measured memory_bytes: 23412
# include<iostream>

using namespace std;
int main(){
	int a=0;
	int b=0;
	cin >> a >> b;
	if (a < b){
		cout << "a < b" << endl;
	}
	if (a > b){
		cout << "a > b" << endl;
	}
	if (a == b){
		cout << "a == b" << endl;
	}
	return 0;
}

Measured memory_bytes: 3088
// subtle.cpp : C vWFNg t@CÅ·B

#include <iostream>
#include <bitset>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <numeric>
#include <list>
#include <sstream>
using namespace std;
//#define P pair<int,int>
//#define max 999999
typedef unsigned int uint;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(ull i = 0;i<n;i++)
#define pb(n) push_back(n)
#define mp(n,k) (make_pair(n,k))
#define clear(n) memset(n,0,sizeof(n))
uint dp[20][20];

int main() {
	int n;
	cin >> n;
	for(int k = 0;k<n;k++){
	memset(dp,0,sizeof(dp));
	int gx,gy,p;
	set<pair<pair<int,int>,pair<int,int> > > R;
	cin >> gx >> gy;
	cin >> p;
	for(int i = 0;i<p;i++){
		int x1,y1,x2,y2;
		cin >> x1 >> y1 >> x2 >> y2;
		R.insert(make_pair(make_pair(x1+1,y1+1),make_pair(x2+1,y2+1)));
		R.insert(make_pair(make_pair(x2+1,y2+1),make_pair(x1+1,y1+1)));
	}
	dp[1][1] = 1;
	for(int i = 1;i<=gx+1;i++)for(int j = 1;j<=gy+1;j++){
		if(!R.count(mp(mp(i,j),mp(i-1,j)))){
			dp[i][j] += dp[i-1][j];
		}
		if(!R.count(mp(mp(i,j),mp(i,j-1)))){
			dp[i][j] += dp[i][j-1];
		}
	}
	if(dp[gx+1][gy+1])
		cout << dp[gx+1][gy+1] << endl;
	else
		cout << "Miserable Hokusai!" << endl;
	}
	//cin >> n;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x;
	cin>>x;
	cout<<(x==3 || x==5 || x==7 ? "YES" : "NO")<<'\n';
	return 0;
}


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

  int K,N;

  cin >> K >> N ;

  vector<int> A(N);

  rep(i,N) cin >> A.at(i);//入力終了

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

  int M=0;

  for(int i=0;i<N-1;i++){
    int d=A.at(i+1)-A.at(i);
    M=max(M,d);    
  }
  int last=(K-A.at(N-1))+A.at(0);

  M=max(last,M);

  cout<<K-M<<endl;

  

  return 0;
}

Measured memory_bytes: 1024
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE BangPatterns #-}

-- Default Imports

import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Class

import qualified Control.Monad.Reader as Reader
import Control.Monad.Reader (Reader, ReaderT, runReader, runReaderT)

import qualified Data.Array.MArray as MArray
import qualified Data.Array.ST as STArray
import Data.Array.ST (STArray, STUArray, runSTArray, runSTUArray)
import Data.Ix (Ix)

import qualified Data.Bits as Bits
import Data.Bits ((.&.), (.|.))

import qualified Data.ByteString.Char8 as BS
import Data.ByteString.Char8 (ByteString)

import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Map as Map
import Data.Map (Map)
import qualified Data.Maybe as Maybe

import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Unboxed as UVector

import Numeric

import Debug.Trace
-- ----------

-- Custom Import Here


-- ----------

-- Default Definitions

type Vector = Vector.Vector
-- type GVector = GVector.Vector
type UVector = UVector.Vector

readIntToList :: ByteString -> [Int]
readIntToList = List.unfoldr (fmap (second $ BS.dropWhile Char.isSpace) . BS.readInt)

readToList :: Read a => ByteString -> [a]
readToList = List.unfoldr $ fmap (mapTaken . mapRemain) . span' (not . Char.isSpace)
	where
		mapTaken  = first $ read . BS.unpack
		mapRemain = second $ BS.dropWhile Char.isSpace
		span' pred s
			| BS.null taken = Nothing
			| otherwise     = Just (taken, remain')
			where
				(taken, remain) = BS.span pred s
				remain' = BS.dropWhile Char.isSpace remain

readToListN :: Read a => Int -> ByteString -> [a]
readToListN n = take n . readToList

readIntToUVector :: ByteString -> UVector.Vector Int
readIntToUVector = UVector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVectorN :: Int -> ByteString -> UVector.Vector Int
readIntToUVectorN n = UVector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

first :: (a -> a') -> (a, b) -> (a', b)
first f (a, b) = (f a, b)

second :: (b -> b') -> (a, b) -> (a, b')
second f (a, b) = (a, f b)

average :: Fractional a => [a] -> a
average xs = sum xs / (fromIntegral . length) xs

-- ----------

ans :: String -> String -> String
ans "" _ = ""
ans (a:as) (b:bs) = [a, b] ++ ans as bs

main :: IO ()
main = do
	n <- readLn
	[s, t] <- (map $ take n) . words <$> getLine
	putStrLn $ ans s t


Measured memory_bytes: 508
unittest
{
	assert( [ "2 700", "3 500", "5 800" ].solve == 3 );
	assert( [ "2 2000", "3 500", "5 800" ].solve == 7 );
	assert( [ "2 400", "3 500", "5 800" ].solve == 2 );
	assert( [ "5 25000", "20 1000", "40 1000", "50 1000", "30 1000", "1 1000" ].solve == 66 );
}



import std.algorithm;
import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto d = 0L;
	auto g = 0L;
	input.front.formattedRead!"%s %s"( d, g );
	auto pcs = new long[ 2 ][ d ];
	foreach( ref pc; pcs )
	{
		input.popFront;
		pc = input.front.split.to!( long[] );
	}
	
	auto as = new long[ d ];
	foreach( i, ref a, pc; lockstep( as, pcs ) )
	{
		a = 100L * ( 1 + i.signed ) * pc[ 0 ] + pc[ 1 ];
	}
	
	auto ans = long.max;
	foreach( b; 0L .. 1L << d )
	{
		auto pt = 0L;
		auto ct = 0L;
		auto m = 0L;
		foreach( i, a; as )
		{
			if( b & ( 1L << i ) )
			{
				pt += pcs[ i ][ 0 ];
				ct += a;
			}
			else
			{
				m = i;
			}
		}
		
		if( ct < g )
		{
			auto u = 100L * ( 1 + m );
			auto p = ( g - ct + u - 1 ) / u;
			if( pcs[ m ][ 0 ] < p ) continue;
			pt += p;
			ct += u * p;
		}
		
		ans = min( ans, pt );
	}
	return ans;
}


Measured memory_bytes: 3000