akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<55;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

class Lazy_Segment_Tree{
	private:
	int n;
	vp date;
	vi lazy;
	void Set_Lazy(int k,int x){
		date[k].first+=x;
		lazy[k]+=x;
	}
	void Push(int k){
		Set_Lazy(k*2+1,lazy[k]);
		Set_Lazy(k*2+2,lazy[k]);
		lazy[k]=0;
	}
	void Fix(int k){
		date[k]=min(date[k*2+1],date[k*2+2]);
	}
	void Add_func(int a,int b,int k,int l,int r){
		if(r<=a||b<=l) return;
		if(a<=l&&r<=b){
			Set_Lazy(k,-1);
			return;
		}
		Push(k);
		int m=(l+r)/2;
		Add_func(a,b,k*2+1,l,m);
		Add_func(a,b,k*2+2,m,r);
		Fix(k);
	}
	P Query_func(int a,int b,int k,int l,int r){
		if(r<=a||b<=l) return {inf,0};
		if(a<=l&&r<=b) return date[k];
		Push(k);
		int m=(l+r)/2;
		P vl=Query_func(a,b,k*2+1,l,m);
		P vr=Query_func(a,b,k*2+2,m,r);
		return min(vl,vr);
	}
	public:
	Lazy_Segment_Tree(int n_,vi a){
		n=1;
		while(n<n_) n*=2;
		date=vp(2*n-1,{inf,inf});
		lazy=vi(2*n-1);
		for(int i=0;i<n_;i++) date[i+n-1]={a[i],i};
		for(int i=n-2;i>=0;i--) Fix(i);
	}
	void Add(int a,int b){
		Add_func(a,b,0,0,n);
	}
	P Query(int a,int b){
		return Query_func(a,b,0,0,n);
	}
};

class Segment_Tree{
	private:
	int n;
	vi date;
	int Rec(int a,int b,int k,int l,int r){
		if(r<=a||b<=l) return 0;
		if(a<=l&&r<=b) return date[k];
		int m=(l+r)/2;
		return Rec(a,b,k*2+1,l,m)+Rec(a,b,k*2+2,m,r);
	}
	public:
	Segment_Tree(int n_){
		n=1;
		while(n<n_) n*=2;
		date=vi(2*n-1);
	}
	void Update(int k){
		k+=n-1;
		date[k]++;
		while(k>0){
			k=(k-1)/2;
			date[k]=date[k*2+1]+date[k*2+2];
		}
	}
	int Query(int a,int b){
		return Rec(a,b,0,0,n);
	}
	int Open(int k){
		return date[k+n-1];
	}
};

int n,N;
vi a,b;
map<int,int> m;

int main(){
	cin>>n;
	a=vi(n);
	for(int i=0;i<n;i++)cin>>a[i];
	b=a;
	sort(b.begin(),b.end());
	b.erase(unique(b.begin(),b.end()),b.end());
	N=b.size();
	Lazy_Segment_Tree lst(N,b);
	Segment_Tree st(N);
	ll res=0;
	for(int i=0;i<N;i++) m[b[i]]=i;
	for(int i=0;i<n;i++){
		P p=lst.Query(m[a[i]],N);
		int I=p.second;
		res+=b[I]-a[i];
		a[i]=b[I];
		lst.Add(I,N);
		res+=st.Query(I+1,N);
		st.Update(I);
	}
	cout<<res<<endl;
}

Measured memory_bytes: 19440
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
#define debug(x) std::cout << #x << ": " << x << '\n';

const int MOD = 1000 * 1000 * 1000 + 7;


//need define int long long
int mod(int n) {
    n %= MOD;
    if (n < 0) return n + MOD;
    else return n;
}   
int fp(int a, int p) {
    int ans = 1, c = a;
    for (int i = 0; (1ll << i) <= p; ++i) {
        if ((p >> i) & 1) ans = mod(ans * c);
        c = mod(c * c);
    }   
    return ans;
}   
int dv(int a, int b) { return mod(a * fp(b, MOD - 2)); }

struct M {
ll x;
M (int x_) {
    x = mod(x_);
}   
M () {}
M operator + (M y) {
    int ans = x + y.x;
    if (ans >= MOD)
        ans -= MOD;
    return M(ans);
}
M operator - (M y) {
    int ans = x - y.x;
    if (ans < 0)
        ans += MOD;
    return M(ans);            
}   
M operator * (M y) {
    return M(x * y.x % MOD);   
}   
M operator / (M y) {
    return M(x * fp(y.x, MOD - 2) % MOD);
}   
M operator + (int y) {
    return (*this) + M(y);
}
M operator - (int y) {
    return (*this) - M(y);
}   
M operator * (int y) {
    return (*this) * M(y);
}   
M operator / (int y) {
    return (*this) / M(y);
}   
M operator ^ (int p) {
    return M(fp(x, p));
}   
void operator += (M y) {
    *this = *this + y;
}   
void operator -= (M y) {
    *this = *this - y;
}   
void operator *= (M y) {
    *this = *this * y;
}
void operator /= (M y) {
    *this = *this / y;
}   
void operator += (int y) {
    *this = *this + y;
}   
void operator -= (int y) {
    *this = *this - y;
}   
void operator *= (int y) {
    *this = *this * y;
}
void operator /= (int y) {
    *this = *this / y;
}   
void operator ^= (int p) {
    *this = *this ^ p;
}
};  

const int N = 2e5+7;
M f[N], inv[N];
void prec() {
    f[0] = M(1);
    for (int i = 1; i < N; ++i)
        f[i] = f[i - 1] * M(i);
    inv[N - 1] = f[N - 1] ^ (MOD - 2);
    for (int i = N - 2; i >= 0; --i)
        inv[i] = inv[i + 1] * M(i + 1);
}
M C(int n, int k) {
    return f[n] * inv[k] * inv[n - k];
}   

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int n, A, B;
    cin >> n >> A >> B;

    prec();    

    vector <M> ex(2 * n);
    for (int i = 0; i < 2 * n; ++i) {
        ex[i] = M(i) / ( M(A + B) / M(100) );
    }   

    M ans(0);           
    M pa = M(A) / M(A + B);
    M pb = M(B) / M(A + B);
    for (int i = 0; i < n; ++i) {
        // A * n + B * i
        M en = C(n + i - 1, i) * ((pa ^ n) * (pb ^ i));
        ans += en * ex[n + i];                    
    }   
    for (int i = 0; i < n; ++i) {
        // B * n + A * i
        M en = C(n + i - 1, i) * ((pa ^ i) * (pb ^ n));
        ans += en * ex[n + i];
    }   
    cout << ans.x << endl;
}


Measured memory_bytes: 7928
n,m,q=map(int,input().split())
cs=[]
for _ in range(q):
    cs.append(list(map(int,input().split())))

A=[1]*(n+1)
mx=0
while A[0]==1:
    s=0
    for i in range(0,q):
        if A[cs[i][1]]-A[cs[i][0]]==cs[i][2]:s+=cs[i][3]
    mx=max(mx,s)
    k=n
    while A[k]==m and k>=1:
        k-=1
    A[k]+=1
    for i in range(k+1,n+1):
        A[i]=A[i-1]
print(mx)





Measured memory_bytes: 68392
#include<stdio.h>
int main(void){
	int i,t,m=100000;
	scanf("%d",&t);
	for(i=1;i<=t;i++){
		m=m+m*5/100;
		if(m%1000!=0){
			m=m+(1000-m%1000);
		}
	}
	printf("%d\n",m);
	return 0;
}


Measured memory_bytes: 1980
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    ll a, b;

    vector<ll> ans(41, 0);

    cin >> a >> b;

    a--;

    for (int i = 1; i <= ceil(log2(b)) + 1; i++)
    {
        ans[i] += (b / (ll)pow(2, i)) * (ll)pow(2, i) / 2 + max(b % (ll)pow(2, i) - ((ll)pow(2, i - 1) - 1), 0ll);
    }

    for (int i = 1; i <= ceil(log2(a)) + 1; i++)
    {
        ans[i] -= (a / (ll)pow(2, i)) * (ll)pow(2, i) / 2 + max(a % (ll)pow(2, i) - ((ll)pow(2, i - 1) - 1), 0ll);
    }

    ll res = 0;

    for (int i = 1; i < 41; i++)
    {
        res += (ans[i] % 2) * pow(2, i - 1);
    }

    cout << res << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
using namespace std;
long long MOD = 1e9 + 7;

int N, L;
vector<string> S;

int main() {
	cin >> N >> L;
	S.resize(N);
	for (int n = 0; n < N; n++) {
		cin >> S[n];
	}
	sort(S.begin(), S.end());
	for (int n = 0; n < N; n++) {
		cout << S[n];
	}
	cout << endl;
	return 0;
}

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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

ll x;

ll f(ll n){
  if(n == -1) return 0;
  else return n/x + 1;
}

main(){
  ll a,b; cin >> a >> b >> x;
  cout << f(b) - f(a-1) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main (void)
{
  char str[4],box;
  int len=0;

  scanf ("%s",str);

  while (str[len])
    len++;

  if (len==3)
  {
    box=str[2];
    str[2]=str[0];
    str[0]=box;
  }

  printf ("%s\n",str);

  return 0;

}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
typedef long long  ll;

#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
int main()
{
	ll A, B, C, D; cin >> A >> B >> C >> D;
	ll cnt = 0;
	repe(i, 1, 100) {
		if (i > A && i <= B && i > C && i <= D) cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
using namespace std;
int main() {
  int x,a,b;
  cin >> x >> a >> b;
  if (a>=b) cout << "delicious" << endl;
  else if (a<=b && b-a<=x) cout << "safe" << endl;
  else if (a<=b && b-a>=x) cout << "dangerous" << endl;
} 

Measured memory_bytes: 256
s=input()
t=input()


dp=[[0]*(len(t)+1) for _ in range(len(s)+1)]
#dp[s][t]はs文字とt文字までのやつ

for sx in range(len(s)):
    for ty in range(len(t)):
        #sx+1文字目とty+1文字目が同じなら
        if s[sx]==t[ty]:dp[sx+1][ty+1]=dp[sx][ty]+1
        #違うならどっちか一つ削ったのと同じ
        else:dp[sx+1][ty+1]=max(dp[sx+1][ty],dp[sx][ty+1])


ans=''
i=len(s)
j=len(t)
while(i>0):
    if dp[i][j]==dp[i-1][j]:i-=1
    elif dp[i][j]==dp[i][j-1]:j-=1
    else:
        ans=t[j-1]+ans
        i-=1
        j-=1
print(ans)



Measured memory_bytes: 112220
#include <stdio.h>
#define N 100
int main(){
  
  int i,j,k,n,key,a[N];
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++) scanf("%d",&a[i]);
  for(i=0;i<n;i++){
    if(i!=n-1) printf("%d ",a[i]);
  else printf("%d",a[i]);
  }
   printf("\n");
  for(i=1;i<n;i++){
    key=a[i];
    j=i-1;
    
    while(j>=0 && a[j]>key){
      a[j+1]=a[j];
      j--;
      a[j+1]=key;
    }
      for(k=0;k<n;k++){
	if(k!=n-1)printf("%d ",a[k]);
	else printf("%d",a[k]);
      }
    printf("\n");
  }
  
  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a,b;
  cin >> a >> b;
  if((a+b) % 2 == 0){
    cout << (a + b) / 2;
  }
  else if ((a+b) % 2 != 0){
      cout << "IMPOSSIBLE" << endl;
  }
}

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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int a, b;
	cin >> a >> b;
	if ((a*b) % 2 == 1) {
		cout << "Odd\n";
	}
	else {
		cout << "Even\n";
	}
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    char ch;
    scanf("%c", &ch);

    if (ch >= 'a' && ch <= 'z'){
        printf("a\n");
    }
    else if (ch >= 'A' && ch <= 'Z')
    {
        printf("A\n");
    }
    return 0;
}

Measured memory_bytes: 1592
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define INF 1e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
  int N, ans;
  string S; 
  cin>>N>>S;
  for(int i=0; i<=999; i++){
    int c[3]={i/100, (i/10)%10, i%10};
    int f=0;
    for(int j=0; j<N; j++){
      if(S[j]==('0'+c[f])){
        f++;
      }
      if(f==3){
        break;
      }
    }
    if(f==3){
      ans++;
    }
  }
  cout<<ans<<endl; 
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
    private static FastScanner sc = new FastScanner();
    private static boolean DEBUG_FLG = false;

    public static void main(String[] args) {
    	int A = sc.nextInt();
    	int B = sc.nextInt();
    	if(A >= 13) {
    		System.out.println(B);
    	} else if(A >= 6) {
    		System.out.println(B / 2);
    	} else {
    		System.out.println(0);
    	}
    }

    static void debug(long... args) {
    	if(!DEBUG_FLG) return;
    	boolean flg = false;
    	for(long s : args) {
    		if(flg) System.out.print(" ");
    		flg = true;
    		System.out.print(s);
    	}
    	System.out.println();
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 20564
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
const ll mod=1e+9;

int main(){
    int n;
    cin>>n;
    vector<ll>a(n),b(n);
    for(int i=0;i<n;i++)cin>>a.at(i);
    for(int i=0;i<n;i++)cin>>b.at(i);
    ll ans=0;
    for(int i=0;i<n;i++){
        ll ad=0,bd=0;
        if(a.at(i)==b.at(i))continue;
        if(a.at(i)<b.at(i)){
            ad=b.at(i)-a.at(i);
        ad/=2;
        }
        else  bd=a.at(i)-b.at(i);
        ans+=ad-bd;
    }
    if(ans>=0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef pair<int, int>P;

int main(){

    for(int n;cin>>n,n;){
        vector<P>books(n);
        int rSum = 0, wSum = 0;
        for(int i=0;i<n;i++){
            cin >> books[i].first;
            cin >> books[i].second;
            rSum += books[i].first;
            wSum += books[i].second;
        }
        sort(books.begin(), books.end(), greater<P>());
        if(books[0].first >= (rSum - books[0].first)){
            int w = books[0].first - (rSum - books[0].first);
            vector<int>dp(w+1, 0);
            dp[0]=1;
            int mx = 0;
            for(int i=1;i<n;i++){
                int v = books[i].second;
                for(int j=w;j>=0;j--){
                    if(dp[j]==0)continue;
                    if(v+j>w)continue;
                    dp[v+j]=1;
                    mx = max(mx, v+j);
                }
            }
            cout<<books[0].first*2+wSum-mx<<endl;
        }
        else{
            cout<<rSum+wSum<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3148
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
vector<pair<int,int> > v1;
vector<int> v2;
bool exist[100005];
int check(int a,int b,int r,int c){
	if(b==0)return a;
	if(a==r)return r+b;
	if(b==c)return r+c+(r-a);
	if(a==0)return r*2+c+(c-b);
	return -1;
}
	
int main(){
	int r,c,n;
	int i,j,k;
	int a,b,d,e;
	cin>>r>>c>>n;
	for(i=0;i<n;i++){
		cin>>a>>b>>d>>e;
		a=check(a,b,r,c),b=check(d,e,r,c);
		if(a!=-1 && b!=-1){
			v1.push_back(make_pair(a,i));
			v1.push_back(make_pair(b,i));
		}
	}
	if(v1.size()==0){
		cout<<"YES"<<endl;
		return 0;
	}
	sort(v1.begin(),v1.end());
	for(i=0;i<v1.size();i++){
		a=v1[i].second;
		if(exist[a]){
			b=v2.back();
			v2.pop_back();
			if(a!=b){
				cout<<"NO"<<endl;
				return 0;
			}
		}else{
			exist[a]=true;
			v2.push_back(a);
		}
	}
	cout<<"YES"<<endl;
	return 0;
}


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

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(ll i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    ll tmp = a[0], count = 0, ans = 0;
    for(ll i = 0; i < n; i++){
        if(tmp != a[i]){
            if(count%2 != 0) ans++;
            count = 0;
            tmp = a[i];
        }
        count++;
    }
    if(count%2 != 0) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 4004
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

using namespace std;
 
int main()
{

 int a,b,c,d,i,p;
 
 cin>>a>>b>>c>>d;
 
 if(c>b || a>d)
 cout<<0;
 else
 {
 	int ans;
 	
 	if(a>=c && b<=d)
 	ans=b-a;
 	else if(c>=a && d<=b)
 	ans=d-c;
 	else if(a>=c && b>d)
 	ans=d-a;
 	else if(b>=c && a<c)
 	ans=b-c;
 	else if(c>=a && d>b)
 	ans=c-a;
 	else if(d>=a && c<a)
 	ans=d-a;
 	
 	cout<<ans;
 }
  
 
 
	return 0;
 
} 

Measured memory_bytes: 256
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
dic = {}

for i in range(n):
    dic[i] = abs(a - (t - h[i] * 0.006))

ans = [val for val in dic.items() if val[1] == min(dic.values())]

print(ans[0][0] + 1)

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {

    int n;
    cin >> n;

    vector<int> x(n), y(n);
    REP(i, n) {
        cin >> x[i];
        y[i] = x[i];
    }
    sort(x.begin(), x.end());

    int mid1 = x[n / 2 - 1];
    int mid2 = x[n / 2];
    REP(i, n){
        if (y[i] < mid2) cout << mid2 << endl;
        else cout << mid1 << endl;
    }


    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for(int i = (int)(n); i>=0; --i)
struct fast_ios { fast_ios(){cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast_ios_;

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

    int sum = 0;
    rep(i, M)
    {
        int a;
        cin >> a;
        sum+=a;
    }

    int play = N-sum;
    if(play>=0)
    {
        cout << play << endl;
    }
    else
    {
        cout << -1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3644
N = int(input())-1
timeLine = [[0 for x in range(3)] for y in range(N)]
for i in range(N):
    tmp = input().split()
    timeLine[i][0],timeLine[i][1],timeLine[i][2] = int(tmp[0]),int(tmp[1]),int(tmp[2])
for j in range(N):
    total = timeLine[j][0] + timeLine[j][1]
    now = j+1
    while now <= (N-1):
        if timeLine[now][1] >= total:
            total = timeLine[now][1] + timeLine[now][0]
        else:
            if timeLine[now][1] + timeLine[now][2] >= total:
                total = timeLine[now][0] + timeLine[now][1] + timeLine[now][2]
            else:
                n = int((total-timeLine[now][1])/timeLine[now][2])
                if (total-timeLine[now][1]) % timeLine[now][2] > 0:
                    n += 1
                total = timeLine[now][0] + timeLine[now][1] + timeLine[now][2] * n
        now +=1
    print(total)
print(0)

Measured memory_bytes: 3188
#include<stdio.h>
#include <iostream>
#include <math.h>
using namespace std;

int main(){
	
	double n, s[1000], data, x = 0, m, y = 0;
	
	while(1){
		
		x = 0;
		y = 0;
		
		cin >> n;
		if(n == 0) break;
		
		for(int i = 0; i < n; ++i){
			cin >> s[i];
			x += s[i];
		}
		
		m = x/n;
		
		for(int i = 0; i < n; ++i){
			y += (s[i] - m) * (s[i] - m);
		}
		
		printf("%f\n",sqrt(y/n));
	}
		
		return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
    int a;
    cin >> a;
    cout << (a + a * a + a * a * a) << endl;
}

Measured memory_bytes: 3628
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
ll A[int(2e3+5)], DP[int(2e3+5)][int(2e3+5)];
Pll P[int(2e3+5)];

int main(){
  cin >> N;
  for (int i = 1; i <= N; i++){
    cin >> A[i];
    P[i] = mp(A[i], i);
  }
  sort(P + 1, P + N + 1, greater<Pll>());

  ll ans = 0;
  for (ll i = 1; i <= N; i++){
    for (ll j = 0; j <= i; j++){
      ll now = 0;

      if (j >= 1){
        now = max(now, DP[j-1][i-j] + P[i].fi * abs(P[i].se - j));
      }
      if (i - j - 1 >= 0){
        now = max(now, DP[j][i-j-1] + P[i].fi * abs(P[i].se - (N - (i - j) + 1)));
      }
      DP[j][i-j] = now;
      ans = max(ans, DP[j][i - j]);
    }
  }
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 26448
# 2020/05/03
# AtCoder Beginner Contest 166 - D

# Input
x = int(input())

# Calc
eflg = False
for a in range(200):
    wk_a = a ** 5
    for b in range(200):
        if wk_a - (b ** 5) == x:
            ans1 = a
            ans2 = b
            eflg = True
            break

        if wk_a - (-b ** 5) == x:
            ans1 = a
            ans2 = -b
            eflg = True
            break

    if eflg == True:
        break

# Output
print(ans1, ans2)


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

int main() {
	int N, T, t[225202], oyu = 0;
	cin >> N >> T;
	cin >> t[0];
	for (int i = 0; i < N - 1; i++) {
	    cin >> t[i + 1];
	    if (t[i + 1] - t[i] < T) oyu = oyu + t[i + 1] - t[i];
	    else oyu = oyu + T;
	}
  	oyu = oyu + T;
	cout << oyu;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
main(){
  int N,M,X,Y;
  cin>>N>>M>>X>>Y;
  vector<int> x(N+1),y(M+1);
  for(int i=0;i<N;++i)cin>>x[i];
  for(int i=0;i<M;++i)cin>>y[i];
  x[N]=X, y[M]=Y;
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  cout<<(x[N]<y[0]?"No ":"")<<"War";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007;
int dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
int n;
long long ma, mb;
vector<long long> a, b, c;
long long dp[51][510][510];
int main() {
    cin >> n >> ma >> mb;
    a.resize(n),b.resize(n),c.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i] >> c[i];
    }
    for (int i = 0; i < 50; ++i) {
        for (int j = 0; j < 500; ++j) {
            for (int k = 0; k < 500; ++k) {
                dp[i][j][k] = INF;
            }
        }
    }
    dp[0][0][0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int wa = 0; wa < 500; ++wa) {
            for (int wb = 0; wb < 500; ++wb) {
                if(dp[i][wa][wb] >= INF) continue;
                chmin(dp[i+1][wa][wb],dp[i][wa][wb]);
                chmin(dp[i+1][wa+a[i]][wb+b[i]],dp[i][wa][wb]+c[i]);
            }
        }
    }
    ll ans = INF;
    for (int wa = 1; wa < 500; ++wa) {
        for (int wb = 1; wb < 500; ++wb) {
            if(wa*mb != wb*ma) continue;
            chmin(ans,dp[n][wa][wb]);
        }
    }
    if(ans < INF) cout << ans << endl;
    else cout << -1 << endl;
    return 0;
}

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


#define ll long long int 
#define all(v) v.begin(),v.end()
#define MOD 1000000007
#define PB push_back
#define F first
#define S second

ll cost(vector< ll >&v,ll n,ll index,vector< ll > &dp ){

     if(index == n-1) return 0;

     if(dp[index]>-1) return dp[index];

     ll one=INT_MAX,two= INT_MAX;
     if(index+1<n) {
     	one = abs(v[index+1]-v[index])+ cost(v,n,index+1,dp);
     }
     if(index+2<n){
     	two = abs(v[index+2]-v[index]) + cost(v,n,index+2,dp);
     }
     dp[index] = min(one,two);
     return dp[index];

}

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

	 vector< ll > v(n); for(auto &i:v) cin>>i;

	 vector< ll > dp(n,-1);

	 ll ans = cost(v,n,0,dp);

	 cout<<ans<<endl;

	return 0;
}

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

#define space ' '
#define enter "\n"
#define fi first
#define se second
#define INF 2000000007
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef set <int> si;
typedef map <int, int> mii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <pii> vii;

template <typename T>
T sqr (T x)
{
    return x * x;
}

template <typename T>
T gcd (T a, T b)
{
    return b ? gcd(b, a % b) : a;
}

template <class T>
bool chmin (T &x, const T &y)
{
    if (y < x)
    {
        x = y;
        return true;
    }
    return false;
}

template <class T>
bool chmax (T &x, const T &y)
{
    if (x < y)
    {
        x = y;
        return true;
    }
    return false;
}


template <class P, class Q>
ostream & operator << (ostream &os, const pair <P, Q> &p)
{
    return os << '(' << p.fi << ", " << p.se << ')';
}


template <class T>
ostream & operator << (ostream &os, const vector <T> &v)
{
    os << '{';
    bool was = false;
    for (const T & x : v)
    {
        if (was)
            os << ", ";
        was = true;
        os << x;
    }
    os << '}';
    return os;
}

template <class T>
ostream & operator << (ostream &os, const set <T> &v)
{
    os << '[';
    bool was = false;
    for (const T & x : v)
    {
        if (was)
            os << ", ";
        was = true;
        os << x;
    }
    os << ']';
    return os;
}

template <class P, class Q>
ostream & operator << (ostream &os, const map <P, Q> &m)
{
    os << '<';
    bool was = false;
    for (const auto &x : m)
    {
        if (was)
            os << ", ";
        was = true;
        os << x;
    }
    os << '>';
    return os;
}

int n, m;
bool clr[(int)1e5 + 10];
int cnt[(int)1e5 + 10];
int ans;

int main ()
{
    //freopen("", "r", stdin); freopen("", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin >> n >> m;
    clr[1] = true;
    for (int i = 1; i <= n; i++)
    {
        cnt[i] = 1;
    }
    for (int i = 1; i <= m; i++)
    {
        int x, y;
        cin >> x >> y;
        if (clr[x])
        {
            if (cnt[x] == 1)
                clr[y] = true, clr[x] = false;
            else
                clr[y] = true;
        }
        cnt[x]--, cnt[y]++;
    }
    for (int i = 1; i <= n; i++)
        ans += clr[i];
    cout << ans;
}


Measured memory_bytes: 768
def main():
	N, K = map(int,input().split())
	A = list(map(int,input().split()))
	A.sort(reverse=True)
	no_need = 0
	sub = 0
	for ai in A:
		if sub+ai < K:
			sub += ai
			no_need += 1
		else:
			no_need = 0

	print(no_need)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3572
#include <stdio.h>

int main(){
   int W, H, x, y, r;
   scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
   if((x>=r)&&(x<=(W-r))){
     if((y>=r)&&(y<=(H-r))){
       printf("Yes\n");
       } else{printf("No\n");}
   } else{printf("No\n");}
   return 0;


}

Measured memory_bytes: 584
#include <iostream>
using namespace std;
const int aa=100001;
int main(){

    int N,Q,B,C,A;
    cin>>N;
    int ct[aa];
    for(int i=0;i<aa;i++){
        ct[i]=0;
    }
    long long int total=0;
    for(int i=0;i<N;i++){
        cin>>A;
        total+=A;
        ct[A]++;
    }
    cin >>Q;
    for(int i=0;i<Q ;i++){
        cin>>B>>C;
        int temp=C-B;
        total+=temp*ct[B];
        cout<<total<<endl;
        ct[C]+=ct[B];
        ct[B]=0;
    }
}

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

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

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

ll N, A, B, C, D;
string S;

// [s, t] に 2 連があるならfalse
bool check(int s, int t) {
    for(int i = s; i < t - 1; ++i) {
        if(S[i] == '#' && S[i+1] == '#') { return false; }
    }
    return true;
}

signed main()
{
    cin >> N >> A >> B >> C >> D >> S;
    A--; B--; C--; D--;

    if(C < B) {
        // 3 AC と BD をチェック
        if(check(A, C) && check(B, D)) {
            printf("Yes\n");
        }
        else {
            printf("No\n");
        }
    }
    else if(C < D) {
        // 1 B -> D 、 A -> C の順でチェック
        if(check(A, C) && check(B, D)) {
            printf("Yes\n");
        }
        else {
            printf("No\n");
        }
    }
    else if(D < C) {
        // 2 A が B を抜く
        bool isFind = false;
        for(int i = B; i <= D; ++i) {
            if(S[i] == '#') { continue; }
            if(S[i-1] == '.' && S[i+1] == '.') {
                isFind = true;
                break;
            }
        }
        if(!isFind) {
            printf("No\n");
            return 0;
        }
        // 1 B -> D 、 A -> C の順でチェック
        if(check(A, C) && check(B, D)) {
            printf("Yes\n");
        }
        else {
            printf("No\n");
        }
    }
    else {
        assert(false);
    }
    return 0;
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int a, b;
  cin >> a >> b;
  cout << a + b/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  string s;
  cin >> s;
  int count = 0;
  int size = s.size();
  
  rep(i, size) {
    if (s.at(i) == 'o') {
      count++;
    }
  }
  cout << count*100 + 700 << endl;
}
  

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back
#define pf push_front
#define FOR(i, m, n) for(int i=n;i<(n);i++)
#define rep(i,n) FOR(i, 0, n)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;

int main(){
    int x;
    cin >> x;
    if(x == 3 || x == 5 || x == 7){
        YES
    }else{
        NO
    }
    return 0;
}

Measured memory_bytes: 256
/*
ID: duttonl1
TASK: Knapsack_1.cpp 
LANG: C++
*/
#include <bits/stdc++.h>

#define pb push_back
#define fst first
#define snd second
#define DEBUGA(a, b) cout << "[ "; for (auto _x = (a); _x != (b); _x++) cout << *_x << " "; cout << "]"<< endl
#define DEBUG(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string>_it(_ss); err(_it, args); };cout << endl
#define fr(i,x) for (int i = 0; i < int(x); i++)
#define frab(i,a,b) for (int i = int(a); i < int(b); i++)
#define sz(x) ((int) (x).size())
void run();
int main() {
    std::ios::sync_with_stdio(false);
    run();
    return 0;
}

using namespace std;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << "; ";
    err(++it, args...);
}


typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;

int weight[105], val[105];
int N, W;
ll dp[105][100005];

const int mxSize = 1000000000;
const int mxVal = 100001;
void solve() {
    memset(dp, mxSize+7, 105*mxVal);
    dp[0][val[0]] = weight[0];
    frab(i,1,N) {
        fr(j,mxVal) dp[i][j] = dp[i-1][j];
        dp[i][val[i]] = min(dp[i][val[i]], (ll)weight[i]);
        fr(j,mxVal - val[i]) {
            dp[i][j+val[i]] = 
                min(dp[i][j+val[i]], dp[i-1][j] + weight[i]);
        }
    }
}

void run() {
    cin >> N >> W;
    fr(i,N) cin >> weight[i] >> val[i];
    solve();
    for (int i = mxVal-1; i >= 0; i--)
        if (dp[N-1][i] <= W) {
            cout << i << endl;
            return;
        }
}




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


int main()
{
    int i,n;
    int arr[100001];cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>arr[i];
    }
    
    int cnt=0;
    for(i=1;i<=n;i++)
    {
        if(i==arr[arr[i]])cnt++;
    }
    cout<<cnt/2<<endl;
    return 0;
}


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

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

    if (n == 1 && m == 1) {
        cout << 1 << endl;
        return 0;
    }

    if (n == 1 || m == 1) {
        cout << 1L * max(0L, max(n, m) - 2) << endl;
        return 0;
    }

    n = max(0L, n - 2);
    m = max(0L, m - 2);

    cout << n * m << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <sstream>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define clr(a) memset(a, 0, sizeof(a))
#define set(a) memset(a, -1, sizeof(a))
#define pb push_back
#define sz(a) ((ll)a.size())
#define all(a) a.begin(), a.end()
#define mp make_pair
#define rep(i, a, y) for (ll i = a; i <= y; i++)
#define rep2(i, b) for (ll i = 0; i < b; i++)
#define repl(i, a, b) for (ll i = a; i <= b; i++)
#define ppi pair<int, int>
#define scl(x) scanf("%d", &x)
#define pcl(x) printf("%d", x)
#define FastRead                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0)
/*
 
     ██╗██╗   ██╗██╗  ██╗ █████╗ ███╗   ██╗
     ██║██║   ██║██║  ██║██╔══██╗████╗  ██║
     ██║██║   ██║███████║███████║██╔██╗ ██║
██   ██║██║   ██║██╔══██║██╔══██║██║╚██╗██║
╚█████╔╝╚██████╔╝██║  ██║██║  ██║██║ ╚████║
 ╚════╝  ╚═════╝ ╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═══╝
 
*/
int main()
{
    ll n,m,mx=0;
    cin>>n>>m;
    rep2(i,m) 
    {
        ll x;
        cin>>x;
        mx+=x;
    }
    if(mx>n) cout<<"-1"<<endl;
    else cout<<n-mx<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

#define newline cout<<"\n"
#define deb(x) cout<<#x<<" "<<x<<endl;

template<typename... T>
void read(T&... args){
    ((cin>>args), ...);
}

template<typename... T>
void write(T... args){
    ((cout<<args<<" "), ...);
}

void printarr(vector<ll> &v){
    for(ll x: v){
        cout<<x<<" ";
    }
    newline;
}

const ll MOD = 1e9+7;
const ll nax = 1e7+7;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    
    ll n,a,b,c,d,e; read(n,a,b,c,d,e);

    ll ans = 5;

    ll x = min({a,b,c,d,e});

    n-=x;

    ll q = n/x;
    ll r = n%x;

    if(r>0){
        q++;
    }

    ans += q;

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

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

#define ll long long

signed main() {
  string A,x,B;
  cin >> A >> x >> B;
  int ans=0;
  if(x=="+")
  {ans = stoi(A) + stoi(B);}
  else{ans = stoi(A) - stoi(B);}
  cout << ans << endl;
}

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

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

int main() {
    int n,m;cin>>n>>m;
    
    vector<vector<int>> vec(m);
    
    rep(i,m){
        int k;cin>>k;
        vec[i].resize(k);
        rep(j,k){
            cin>>vec[i][j];
            --vec[i][j];
        }
    }
    vector<int>p(m);
    rep(i,m)cin>>p[i];
    
    int ans=0;
    rep(i,(1<<n)){
        bool ok = true;
        rep(j,m){
            int c=0;
            for(int id : vec[j]){
                if((i>>id) & 1) ++c;
            }
        c %= 2;
        if(c != p[j]) ok = false;
        }
        if(ok) ++ans;
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename X, typename Y> istream& operator>>(istream& is, pair<X, Y>& p) { return is >> p.first >> p.second; }
void solve(long long N, long long K, std::vector<long long> p) {
    for(ll& pp : p) {
        pp++;
    }
    ll s = 0, ans = 0;
    for(int i = 0; i < p.size(); i++) {
        s += p[i];
        if(i >= K) {
            s -= p[i - K];
        }
        ans = max(ans, s);
    }
    cout << fixed << setprecision(6) << ans / 2.0 << endl;
}
int main() {
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    solve(N, K, std::move(p));
    return 0;
}


Measured memory_bytes: 1792
N = int(input())
W = [int(x) for x in input().split()]
acc = [0]
for w in W:
    acc.append(acc[-1] + w)
ans = acc[-1]
for i in range(N-1):
    a = acc[-1] - acc[i+1]
    b = acc[i+1]
    ans = min(ans, abs(a-b))
print(ans)


Measured memory_bytes: 3060
sx,sy,tx,ty=map(int,input().split())
w=tx-sx
h=ty-sy
ans=''
ans+='U'*h
ans+='R'*w
ans+='D'*h
ans+='L'*w
ans+='L'
ans+='U'*(h+1)
ans+='R'*(w+1)
ans+='D'
ans+='R'
ans+='D'*(h+1)
ans+='L'*(w+1)
ans+='U'
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000007;
long long n,ans1=1,ans2=1,ans3=1;
int main()
{
    cin>>n;
    for (int i=1;i<=n;i++) {ans1*=10;if (ans1>mod) ans1%=mod;}
    for (int i=1;i<=n;i++) {ans2*=9;if (ans2>mod) ans2%=mod;}
    for (int i=1;i<=n;i++) {ans3*=8;if (ans3>mod) ans3%=mod;}
    cout<<(ans1+mod*5-ans2*2+ans3)%mod<<endl;
	return 0;
}

Measured memory_bytes: 3632
import scala.io.StdIn

object Main extends App {
  val n  = StdIn.readLine().toInt
  val p :Array[Int] = StdIn.readLine().split(" ").map(_.toInt)

  def solve(n: Int, p: Array[Int]): Int = {
    var v = 0
      (0 to (n - 3)).foreach {i =>

        if (p(i) < p(i + 1) && p(i + 1) < p(i + 2)) v = v + 1
        else if (p(i) > p(i + 1) && p(i + 1) > p(i + 2)) v = v + 1
      }

    v
  }

  println(solve(n, p))
}
  



Measured memory_bytes: 25288
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

auto solve(immutable int n)
{
    auto a = iota(n).map!(_=>readln().chomp()).array();
    auto dp = new int[][](n+1,n+1);
    foreach(i;0..n)
        foreach(j;0..n)
            dp[i+1][j+1]=dp[i][j+1]+dp[i+1][j]-dp[i][j]+(a[i][j]!='.'?1:0);
    int m = 0;
    foreach(i;0..n)
        foreach(j;0..n)
        {
            int lo=0, hi=min(n-i,n-j)+1;
            while(lo+1<hi)
            {
                immutable k = (lo+hi)/2;
                if(0==dp[i+k][j+k]-dp[i][j+k]-dp[i+k][j]+dp[i][j])
                    lo=k;
                else
                    hi=k;
            }
            m=max(m,lo);
        }
    return m;
}

void main()
{
    for(int n; 0!=(n=readln().chomp().to!int()); )
        writeln(solve(n));
}

Measured memory_bytes: 8036
#include <stdio.h>  /*入出力*/
#include <stdlib.h> /*標準ライブラリ*/
#include <string.h> /*文字列*/
#include <math.h>   /*計算*/
#include <assert.h> /*確認*/
#include <ctype.h>  /*文字操作*/
#include <stdbool.h>/*bool型*/
#include <limits.h>/*限界*/
//---------------------------------------------------
#define rep(i, n) for(int  i = 0; i < (n); i++)
#define max(a,b) ((a>b)?a:b)
#define ABS(a) (((a)>(0))?a:-(a))
#define LL long long
#define MOD 1000000007//10^9+7(素数)
//---------------------------------------------------
void swap(int *a, int *b)
{
  int temp;
  temp = *a;*a = *b;*b = temp;
}
//---------------------------------------------------

int main(void)
{
  int n;
  scanf("%d",&n);
  printf("%lf\n",2 * M_PI * (double)n );
  return 0;
}


Measured memory_bytes: 1736
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, a, b) for (int i = a; i < (b); i++)
#define FOR(i, n) for (int i = n; i >= 0; i--)
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <vector>
#define ll long long
#define INF 1000000001;
using namespace std;
struct Edge{int from, to, cost;};
typedef pair<int,int> P;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    P a[100001];
    
    REP(i, n){ 
        cin >> a[i].second >> a[i].first;
    }

    sort(a, a+ n);

    cout << a[0].first + a[0].second << endl;

    return 0;
}


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

const int ramen=700;
const int toping=100;

int main(){
    char S[3];
    for(int i=0;i<3;i++){
        cin >> S[i];
    }
    int counter=0;

    for(int j=0;j<3;j++){
        if(S[j]=='o'){
            ++counter;
            //cout << "toping add\n" <<endl;
        }
    }

    cout << ramen+counter*toping <<endl;


}

Measured memory_bytes: 256
#include <stdio.h>
#define max(a, b) (((a) > (b)) ? (a) : (b))
int main()
{
    int N, A[2][101] = {};
    scanf("%d", &N);
    for (int j = 0; j < 2; j++) {
        for (int i = 0; i < N; i++) {
            scanf("%d", &A[j][i]);
        }
    }
    
    int s[2][101] = {};
    for (int j = 0; j < 2; j++) {
        for (int i = 0; i < N; i++) {
            s[j][i] += ((i > 0) ? s[j][i-1] : 0) + A[j][i];
        }
    }
    
    int m = -1e9;
    for (int i = 0; i < N; i++) {
        m = max(m, s[0][i] + s[1][N-1] - s[1][i-1]);
    }
    
    printf("%d", m);
    
    return 0;
}


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

using namespace std;

int c[5][5];
int a[5];
int b[5];

int main() {        
	for (int i = 1; i <= 3; i++) {
		for (int j = 1; j <= 3; j++) {
			scanf("%d", &c[i][j]);	
		}
	}
	for (int i = 1; i <= 3; i++) {
		int mn = 12345;
		for (int j = 1; j <= 3; j++) {
			mn = min(mn, c[i][j]);
		}	
		a[i] = mn;
	}	
	memset(b, -1, sizeof(b));
	for (int i = 1; i <= 3; i++) {
		for (int j = 1; j <= 3; j++) {
			if (b[j] == -1) {
				b[j] = c[i][j] - a[i];	
			}
			if (b[j] != c[i][j] - a[i]) {
				puts("No");
				return 0;
			}
		}        
	}
	/*
	for (int i = 1; i <= 3; i++) {
		cout << a[i] << ' ';
	}
	cout << endl;
	for (int i = 1; i <= 3; i++) {
		cout << b[i] << ' ';
	}
	cout << endl;*/
	puts("Yes");
}

Measured memory_bytes: 256
s=input()
t=input()
ans=[]
for i in range(len(s)-len(t)+1):
  for j in range(len(t)):
    if s[i+j]!=t[j] and s[i+j]!='?':break
  else:
    a=''
    for k in s[0:i]+t+s[i+len(t):]:
      if k=='?':a+='a'
      else:a+=k
    ans+=[a]
ans=sorted(ans)
if ans:print(ans[0])
else:print('UNRESTORABLE')

Measured memory_bytes: 63688
fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val n = sc.nextInt()
    val k = sc.nextInt()

    var r = 0.0
    for (i in 1..n) {
        // 分母
        var bb = n
        var sc = i
        while (sc < k) {
            sc *= 2
            bb *= 2
        }
        r += 1.0 / bb
    }
    println(r)
}

Measured memory_bytes: 29476
#include<bits/stdc++.h>
using namespace std;
#define int long long
vector<int> xx={0,-1,0,1},yy={1,0,-1,0};
int H,W;
void a(vector<string> &A,vector<vector<bool>> &B,vector<vector<bool>> &C,int x,int y,int &b,int &w){
  if(A[x][y]=='#')
    b++;
  else
    w++;
  C[x][y]=false;
  for(int i=0;i<4;i++){
    int xxx=x+xx[i],yyy=y+yy[i];
    if(0<=xxx && xxx<H && 0<=yyy && yyy<=W && B[x][y]==B[xxx][yyy] && C[xxx][yyy]){
      a(A,B,C,x+xx[i],y+yy[i],b,w);
    }
  }
}
signed main(){
  cin>>H>>W;
  vector<string> A(H);
  for(string &S:A)
    cin>>S;
  vector<vector<bool>> B(H,vector<bool>(W,true)),C(H,vector<bool>(W,true));
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      if((A[i][j]=='.' && (i+j)%2==0) || (A[i][j]=='#' && (i+j)%2==1))
        B[i][j]=false;
  int k=0;
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      if(C[i][j]){
        int b=0,w=0;
        a(A,B,C,i,j,b,w);
        k+=b*w;
      }
  cout<<k<<endl;
}

Measured memory_bytes: 23832
fun main(){
    var num = readLine()!!.toInt()

    if(num < 10){
        judge(num)
    }
    else if(num < 100){
        val onesPlace = num%10
        judge(onesPlace)
    }
    else{
        num = num%100
        val onesPlace = num%10
        judge(onesPlace)
    }

}

fun judge(onesPlace: Int){
    when(onesPlace){
        2, 4, 5, 7, 9 -> println("hon")
        0, 1, 6, 8 -> println("pon")
        3 -> println("bon")
    }
}

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


int main()
{
	int N, W;
	int v[100];
	int w[100];
	int memo1[10005] = {};
	int memo2[10005] = {};

	cin >> N >> W;

	for (int i = 0; i < N; i++) cin >> v[i] >> w[i];

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j <= W; j++)
		{
			if (j - w[i] >= 0)
				memo2[j] = max(memo1[j], memo2[j - w[i]] + v[i]);
			else
				memo2[j] = memo1[j];
		}
		swap(memo1, memo2);
	}

	cout << *max_element(memo1, memo1 + W + 1) << endl;

	return 0;
}

Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
int a,b,ans;
int main(){
    cin>>a>>b;
    for(int i=0;i<2;i++){
        if(a>=b){ans+=a;a--;}
        else{ans+=b;b--;}
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
from math import *

N = int(input())
all_input_list = [list(map(int, input().split())) for i in range(N)]
x_y_h = [all_input_list[i] for i in range(N) if all_input_list[i][2] > 0][0]
for cx in range(101):
    for cy in range(101):
        flag = 1
        H = x_y_h[2] + abs(cx - x_y_h[0]) + abs(cy - x_y_h[1])
        for input_list in all_input_list:
            if (input_list[2] != max(H - abs(cx - input_list[0]) - abs(cy - input_list[1]), 0)):
                flag = 0
                break
        if (flag == 1):
            print("%s %s %s" % (cx, cy, H))
            break
    if (flag == 1):
        break

Measured memory_bytes: 3064
def main
  x = gets.to_i

  return 1 if x == 1

  b = 2
  answers = []
  loop do
    ans_b = b * b
    break if ans_b > x

    while ans_b <= x do
      ans_b *= b
    end
    answers << ans_b / b

    b += 1
  end

  answers.max
end

puts main()

Measured memory_bytes: 1788