akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,w; cin >> n >> w;
  vector<ll> v[4];
  ll w1;cin >> w1;
  {
      ll tmp;
      cin >>tmp;
      v[0].push_back(tmp);
  }
  REP(i,n-1){
      ll ww,vv;
      cin >> ww >> vv;
      v[ww-w1].push_back(vv);
  }
  REP(i,4){
      sort(all(v[i]), greater<ll>());
      v[i].insert(v[i].begin(), 0);
      FOR(j,1,v[i].size()){
          v[i][j] += v[i][j-1];
      }
  }
  ll ans = 0;
  REP(a,v[0].size()){
      REP(b,v[1].size()){
          REP(c,v[2].size()){
              REP(d,v[3].size()){
                  if((a+b+c+d) * w1 + b + 2*c + 3*d>w)continue;
                  ans = max(ans, v[0][a] + v[1][b] + v[2][c] + v[3][d]);
              }
          }
      }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, X, Y;
	cin >> N >> X >> Y;
	cout << min(X, Y) << " " << max((int)0, (X + Y - N)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << " = " << x << ".\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define print(xx) cout << (xx) << endl
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
const int INF = ((1LL << 30) + (1LL << 29));
const ll MOD = 1000000007;

/* 
*/
//================== INPUT ========================
int N,K;
vector<pii> v;
vector<int> x,y;
//=================================================
void input()
{
    cin>>N>>K;
    v.resize(N);
    x.resize(N);
    y.resize(N);
    rep(i,N){
        cin>>v[i].first>>v[i].second;
        x[i] = v[i].first;
        y[i] = v[i].second;
    }

}
//=================================================
void solve()
{
    // K, N <= 50.
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());

    int ans = (x[N-1]-x[0])*(y[N-1]-y[0]);

    for(int lx = 0; lx < N; ++lx){
        for (int rx=N-1; rx > lx; --rx){
            for (int ly = 0; ly < N; ++ly){
                for (int ry = N-1; ry>ly; --ry){
                    int cnt = 0;
                    for (auto a: v){
                        if (a.first >=x[lx] && a.first <= x[rx]
                            && a.second >= y[ly] && a.second <= y[ry]){
                                cnt++;
                            }
                    }
                    if (cnt >= K){
                        ans = min(ans, ((x[rx]-x[lx])*(y[ry]-y[ly])));
                    }
                }
            }

            
        }
    }
    cout<<ans<<endl;

}

//=================================================
signed main()
{
    input();
    solve();
    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;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
using P = pair<ll,ll>;
#define int ll
template <typename T>
vector<pair<T, T>> prime_factor(T n) {
    vector<pair<T, T>> ret;
    for (T i = 2; i * i <= n; i++) {
        T tmp = 0;
        while (n % i == 0) {
            tmp++;
            n /= i;
        }
        if(tmp != 0) ret.push_back(make_pair(i, tmp));
    }
    if (n != 1) ret.push_back(make_pair(n, 1));
    return ret;
}
signed main(){
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<pair<ll,ll>> pf = prime_factor(n);
    ll ans = 0;
    for(auto i : pf) {
        int e = 1;
        while(true) {
            if(i.second >= e) {
                i.second -= e;
                ans++;
            } else break;
            e++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i, n, sum, avg, count;
	    while(true) {
	    	sum = 0;
	    	avg = 0;
	    	count = 0;
	    	n = sc.nextInt();
	    	if(n == 0)break;
	    	int a[] = new int[n];
	    	for( i = 0; i < n; i++) {
	    		a[i] = sc.nextInt();
		    	sum += a[i];
		    }
	    	avg = sum / n;
	    	for( i = 0; i < n; i++) {
		    	if( a[i] <= avg) {
		    		count++;
		    	}
		    }
	    	System.out.println(count);
	    }
        sc.close();
    }
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int n,a,b;
  cin>>n>>a>>b;
  if((b-a)%2==0) cout<<"Alice"<<endl;
  else cout<<"Borys"<<endl;
}
  



Measured memory_bytes: 256
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

h,w=MI()
lis=[list(SI()) for i in range(h)]
al=[[-1]*w for i in range(h)]
dp=[[inf]*w for i in range(h)]
'''for i in range(h):
    for j in range(w):
        if lis[i][j]=="#":
            dp[i][j]=-1'''
dp[0][0]= 0 if lis[0][0]=="." else 1
q=deque([[0,0]])
step=[[0,1],[1,0]]
#print(lis)
while q:
    x,y=q.popleft()
    if lis[x][y]==".":
        state=1
    else:
        state=-1
    for i,j in step:
        if x+i>h-1 or y+j>w-1:
            continue
        elif state==1:
            if al[x+i][y+j]<0:
                al[x+i][y+j]=0
                q.append([x+i,y+j])
            if lis[x+i][y+j]=="#":
                dp[x+i][y+j]=min(dp[x+i][y+j],dp[x][y]+1)
            else:
                dp[x+i][y+j]=min(dp[x+i][y+j],dp[x][y])
        elif state==-1:
            if al[x+i][y+j]<0:
                al[x+i][y+j]=0
                q.append([x+i,y+j])
            dp[x+i][y+j]=min(dp[x+i][y+j],dp[x][y])
print(dp[-1][-1])

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#include<string>
#define FIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define ll long long
#define mod (ll)(1e9+7)
#define nax (ll)(1e5 +1)
#define INFL LLONG_MAX
#define INF INT_MAX
#define disp(a,n,arr) for(int i=a;i<(ll)n;i++) cout << arr[i] << " "; cout << "\n";
#define check cout << "Working\n";
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vpl vector<pl>
#define vpi vector<pi>
#define vb vector<bool>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;

ll binpow(ll a, ll b) {
	ll x = 1;
	while (b) {
		if (b & 1) x = x * a;
		a = a * a;
		b >>= 1;
	}
	return x;
}

ll mult(ll a, ll b) {
	ll x = 0;
	while (b) {
		if (b & 1) x = (x + a);
		a = (a + a);
		b >>= 1;
	}
	return x;
}



int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	FIO;

	// Write your code here

	int t = 1;
	//cin >> t;
	while (t--) {
		ll n;
		cin >> n;
		vector<char> v;
		while (n) {
			n--;
			v.pb((char)(n % 26 + 'a'));
			n /= 26;
			//if (n <= 26 && n >= 0) n--;
		}
		for (int i = (int)v.size() - 1; i >= 0; i--) {
			cout << v[i] ;
		}
		cout << "\n";
	}


	return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <list>
#include <utility>
#include <iterator>

using namespace std;

typedef long long LL;

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ALL(a)  (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define dump(x)  cerr << #x << " = " << (x) << endl;

int main() {
  string s;
  int K;
  cin >> s;
  cin >> K;

  list<string> l;
  REP(i, s.length()) {
    REP(j, min(K, (int)s.length() - i)) {
      l.push_back(s.substr(i, j+1));
    }
  }

  l.sort();
  l.unique();

  cout << *next(l.begin(), K-1)<< endl;

  return 0;
}

Measured memory_bytes: 1408
s = input().split()
n, m = map(int, s)
if n >= m:
    print(0)
    exit(0)
x = input().split()
x = [int(i) for i in x]
x.sort()
#print(x)
dist = []
for i in range(1, len(x)):
    dist.append(x[i] - x[i-1])
dist.sort()
#print(dist)
dist = dist[:m-n]
print(sum(dist))

Measured memory_bytes: 13840
S = list(map(str,input()))

S_pre = S[:int(len(S)/2)]
if len(S) % 2  == 0 : # 偶数
	S_aft = S[int(len(S)/2):]
else: # 奇数
	S_aft = S[int(len(S)/2)+1:]
S_aft.reverse() # 逆順
count = 0
for i in range(len(S_pre)):
	if S_pre[i] != S_aft[i]:
		count += 1

print(count)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 20000000000;
struct edge {int to,cost;};
#define VMAX 51
//typedef std::pair<int,int> P;

    ll ans;
    string s;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>s;
    cout<<((s[0]==s[s.size()-1])^(s.size()%2)?"First":"Second");

    return 0;
}


Measured memory_bytes: 764
import sys
import math

N = int(sys.stdin.readline().rstrip())

def sieve_of_erastosthenes(num):
    input_list = [
        False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True
        for i in range(num)
    ]
    input_list[0] = input_list[1] = False
    input_list[2] = input_list[3] = input_list[5] = True
    sqrt = math.sqrt(num)

    for serial in range(3, num, 2):
        if serial >= sqrt:
            return [i for i, b in enumerate(input_list) if b == True]
        for s in range(serial**2, num, serial):
            input_list[s] = False

primes = sieve_of_erastosthenes(55555)

ans = []

for p in primes:
    if p % 5 == 1:
        ans.append(p)
    if len(ans) == N:
        break

print(" ".join(map(str, ans)))

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

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

using namespace std;
using graph=vector<vector<int>>;

int main(){
	int n,m; scanf("%d%d",&n,&m);
	vector<int> h(n);
	rep(u,n) scanf("%d",&h[u]);
	graph G(n);
	rep(i,m){
		int u,v; scanf("%d%d",&u,&v); u--; v--;
		G[u].emplace_back(v);
		G[v].emplace_back(u);
	}

	int ans=0;
	rep(u,n){
		bool ok=true;
		for(int v:G[u]) if(h[u]<=h[v]) ok=false;
		if(ok) ans++;
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 8796
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
using namespace std;

int main(void){
	int n;
	cin>>n;
	int ans;
	ans=n/2;
	if(n%2==1)ans++;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int X=scan.nextInt();
		int A=scan.nextInt();
		if(X<A){
			System.out.println("0");
		}else{
			System.out.println("10");
		}}}


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

using namespace std;

int main() {
    int A,B,C,D,E; cin>>A>>B>>C>>D>>E;

    vector<pair<int,int>> pn;
    pn.push_back(make_pair(A%10==0?0:10-A%10,A));
    pn.push_back(make_pair(B%10==0?0:10-B%10,B));
    pn.push_back(make_pair(C%10==0?0:10-C%10,C));
    pn.push_back(make_pair(D%10==0?0:10-D%10,D));
    pn.push_back(make_pair(E%10==0?0:10-E%10,E));

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

    int time=0;
    for (int i=0;i<pn.size()-1;i++) {
        // cout << pn[i].first << "/" << pn[i].second << endl;
        time += pn[i].first+pn[i].second;
    }
    time += pn[pn.size()-1].second;

    cout << time << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

C = Counter(A)
A.sort(reverse=True)
ans = 0
for i in range(N):
    x = A[i]
    if C[x] > 0:
        y = 2**x.bit_length() - x
        C[x] -= 1
        if C[y] > 0:
            C[y] -= 1
            ans += 1

print(ans)



Measured memory_bytes: 36172
#include<iostream>
#include<string>
#include<algorithm>
#define ll long long
using namespace std;
void get(ll arr[],ll n)
{
for(ll i=0;i<n;i++)
cin>>arr[i];
}
int main()
{
	char s[6];
	cin>>s;
	ll flag=1;
	if(s[2]==s[3]&&s[4]==s[5])
	cout<<"Yes";
	else
	cout<<"No";
}


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

int main(){
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  for(int i = 0; i < N; i++){
    cin >> L[i];
  }
  
  int counter = 1;
  int Lsum = 0;
  for(int i = 0; i < N; i++){
    Lsum += L[i];
    if(Lsum > X){
      break;
    }
    counter++;
  }
  
  cout << counter << endl;
}

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

int table[33][101010];

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N,C; cin >> N >> C;
    int s,t,c, E = 0;

    for(int i=0; i < N; ++i) {
        cin >> s >> t >> c;
        table[c][s]++; table[c][t+1]--;
        E = max(E, t);
    }

    for(int i=1; i <= C; ++i){
        for(int j=0; j <= E; ++j) {
            table[i][j+1] += table[i][j];
        }
    }

    int ans = 0;
    for(int i=0; i <= E; ++i) {
        int cnt = 0;
        for(int j = 1; j <= C; ++j) {
            if(table[j][i] > 0) ++cnt;
        }
        ans = max(ans, cnt);
    }

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

Measured memory_bytes: 12160
#include <stdio.h>
int main(){
    double b;
    int i,n,c,fl0=0,fl1=0,fl2=0,fl3=0,fl4=0,fl5=0;
    scanf("%d",&n);
    for(c=0;c<n;c++){
        scanf("%lf",&b);
        if(b < 165.0){
            fl0++;
        }
        else if(b < 170.0){
            fl1++;
        }
        else if(b < 175.0){
            fl2++;
        }
        else if(b < 180.0){
            fl3++;
        }
        else if(b < 185.0){
            fl4++;
        }
        else if(b >= 185.0){
            fl5++;
        }
    }
    printf("1:");
    for(i=0;i<fl0;i++){
        printf("*");
    }
    printf("\n2:");
    for(i=0;i<fl1;i++){
        printf("*");
    }
    printf("\n3:");
    for(i=0;i<fl2;i++){
        printf("*");
    }
    printf("\n4:");
    for(i=0;i<fl3;i++){
        printf("*");
    }
    printf("\n5:");
    for(i=0;i<fl4;i++){
        printf("*");
    }
    printf("\n6:");
    for(i=0;i<fl5;i++){
        printf("*");
    }
    printf("\n");
    return(0);
}

Measured memory_bytes: 624
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

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

long mod = 1000000007L;

signed main() {
	string s;
	cin >> s;
	int n = s.size();
	ll sum = 1;
	map<char, long> mp = {};
	for (int i = 0; i < n; ++i) {
		sum += i - mp[s[i]];
		mp[s[i]]++;
	}
	cout << sum << endl;
}


Measured memory_bytes: 640
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: usize, l: [usize; n]};
    let mut l: Vec<usize> = l;

    let mut l_c = l.clone();
    let mut max = l_c.iter().max().unwrap();

    l.sort();
    l.pop();
    l.reverse();

    let mut sum = 0;
    let mut b = false;

    for l_i in l.iter() {
        sum += l_i;
        if sum > *max {
            b = true;
            break;
        }
    }

    if b {
        println!("Yes")
    } else {
        println!("No")
    }
}


Measured memory_bytes: 2176
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	int cnt[200010] = { 0 };
	REP(i, N - 1) {
		int a; cin >> a;
		a--; cnt[a]++;
	}
	REP(i, N)cout << cnt[i] << endl;
	return 0;
}



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

int main() {
    int a, b, c;
    int counter = 0;

    cin >> a >> b >> c;

    for (int i=a; i <= b; ++i) {
        if ((c % i) == 0) {
            ++counter;
        }
    }

    cout << counter << endl;

    return 0;
}


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

using namespace std;

int main(){
    int N, Q;
    string S;
    cin>>N>>Q;
    cin>>S;

    vector<int> v;
    int len = S.length();
    for(int i=0; i<len-1; ++i){
        if(S[i]=='A' && S[i+1]=='C'){
            v.push_back(i);
        }
    }

    int l, r;
    for(int i=0; i<Q; ++i){
        cin>>l>>r;
        auto a = lower_bound(v.begin(), v.end(), l-1);
        auto b = lower_bound(v.begin(), v.end(), r-1);

        cout<<b-a<<endl;
    }

    return 0;
}



Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
int n, m;
char a[10];
string dp[11000];
int num[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

bool is_bigger(string s, string t)
{
    if (s.length() > t.length())
    {
        return true;
    }
    else if (s.length() < t.length())
    {
        return false;
    }
    else if (s > t)
    {
        return true;
    }
    return false;
}

int main()
{
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        cin >> a[i];
    }
    dp[0] = "0";
    for (int i = 0; i < n; i++)
    {
        if (dp[i] != "")
        {
            for (int j = 0; j < m; j++)
            {
                string tmp = dp[i];
                tmp.push_back(a[j]);
                if (is_bigger(tmp, dp[i + num[a[j] - '0']]))
                {
                    dp[i + num[a[j] - '0']] = tmp;
                }
            }
        }
    }
    dp[n].erase(0, 1);
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 43776
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL n,a[200010],cnt[200010],pos[200010];
int main(){
	LL i,j,k;
	cin>>n;
	for(i=0,cnt[n]=1;i<n;i++){
		cin>>a[i];
		pos[a[i]]=i;
		cnt[i]=1;
	}
	for(i=0;i<n;i++){
		j=a[i]-1;
		if(j!=0&&pos[j]<i)cnt[i]=max(cnt[i],cnt[pos[j]]+1);
	}
	for(i=0,k=0;i<n;i++)k=max(k,cnt[i]);
	cout<<n-k<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <climits>
#include <unordered_map>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstring>
#define int long long 
#define lli unsigned long long int
#define pb push_back
#define ins emplace
#define mod 1e9+7
#define fi(i,n) for(int i=1; i<=n;i++)
#define INF 10000000000
#define unm  unordered_map<int , int>
#define vvi  vector<vector<int>>
#define sortall(v) sort(v.begin(),v.end())
#define deb(x)     cout << #x << "=" << x << endl
#define deb2(x,y)  cout << #x << "=" << x << "," << #y << "=" << y << endl
#define mp make_pair
#define F  first
#define S second
#define itr(it,a) for(auto it = a.begin(); it!=a.end();it++)
#define vi  vector<int>
#define pii pair<int ,int>
#define vii vector<vi>
#define in1(x) int x; cin >> x
#define in2(x,y) int x,y; cin >> x >> y;
#define in3(x,y,z) int x,y,z; cin >> x >> y >> z

using namespace std;

int32_t main(){
	in3(n,m,t);
	if( n <= m) cout << t << endl;
	else {
		if(n%m == 0) cout << t*(n/m) << endl;
		else cout << t*(n/m+1) << endl;
	}

}



Measured memory_bytes: 3156
#include <iostream>

using namespace std;

class B {
	int K, S, ans{ 0 };
public:
	void solve()
	{
		cin >> K >> S;

		int x, y, z, rem;

		for (x = 0; x <= S / 3 && x <= K; x++)
		{
			rem = S - x;
			for (y = x; y <= rem / 2 && y <= K; y++)
			{
				z = rem - y;
				if (z > K) continue;

				if (x != y)
				{
					if (y != z) ans += 6;
					else ans += 3;
				}
				else
				{
					if (y != z) ans += 3;
					else ans += 1;
				}
			}
		}
		cout << ans << endl;
	}
};


int main()
{
	B solution;
	solution.solve();

	return 0;
}

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

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	int sum = 0;
	for (int i =1; i <= n; i ++) {
		int cnt = 0, tmp = i;
		while (tmp) {
			cnt += tmp % 10;
			tmp /= 10;
		}
		if (a <= cnt && cnt <= b) sum += i;
	}
	cout << sum << endl;
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  if(s == "Sunny"){
    cout << "Cloudy" << endl;
  }
  else if(s == "Cloudy"){
    cout << "Rainy" <<endl;
  }
  else if(s == "Rainy"){
    cout << "Sunny" <<endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
#include<complex>
#include<cstdlib>
#include<cctype>

#define REP(i,n) for(int i = 0;i < (n);i++)
#define PB push_back
#define MP make_pair
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cout << v[i] << ' ';cout << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cout << v[a][b] << ' ';cout << endl;}cout << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> ivv;

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

int main()
{
	int n,k;
	
	cin >> n >> k;
	
	iv v;
	
	REP(i,n)
	{
		int qqq;
		cin >> qqq;
		v.PB(qqq);
	}
	
	sort(ALL(v));
	
	int mingcd = gcd(v[0],v[1]);
	
	for(int i = 2;i < n;i++)mingcd = gcd(mingcd,v[i]);
	
	if(mingcd == 1)
	{
		cout << "POSSIBLE" << endl;
		return 0;
	}
	
	for(int i = v[n-1];i > 0;i -= mingcd)
	{
		if(i == k)
		{
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
		
	cout << "IMPOSSIBLE" << endl;

	return 0;
}

Measured memory_bytes: 892
#include <iostream>
#define llint long long
#define mod 1000000007

using namespace  std;

llint n, C;
llint dif[35][100005], sum[35][100005];
llint all[100005];

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

  cin >> n >> C;
  llint s, t, c;
  for(int i = 1; i <= n; i++){
    cin >> s >> t >> c;
    dif[c][s-1]++, dif[c][t]--;
  }
  for(int i = 1; i <= C; i++){
    sum[i][0] = dif[i][0];
    for(int j = 1; j <= 100000; j++){
      sum[i][j] = sum[i][j-1] + dif[i][j];
      if(sum[i][j] > 0) all[j]++;
    }
  }

  /*for(int i = 1; i <= C; i++){
    for(int j = 1; j <= 10; j++){
      cout << sum[i][j];
    }
    cout << endl;
  }*/

  llint ans = 0;
  for(int i = 1; i <= 100000; i++){
    ans = max(ans, all[i]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 50688
#include<iostream>
#include<string>
#include<queue>
using namespace std;



int main(){
  int field[14][14];
  int xx[4]={1,0,-1,0};
  int yy[4]={0,1,0,-1};
  queue<int> search;
  string line;
  int x,y;
  while(true){
    for(y=0;y<14;y++){
      for(x=0;x<14;x++){
	field[x][y] = 0;
      }
    }
    for(y=0;y<12;y++){
      if (!(cin>>line))break;
      for(x=0;x<12;x++){
	if (line[x]=='1')
	  field[x+1][y+1] = 1;
      }
    }
    if(y<12)break;
    int count = 0;
    for(int y=1;y<13;y++){
      for(int x=1;x<13;x++){
	if (field[x][y]==1){
	  count++;
	  field[x][y]=0;
	  search.push(y*14+x);
	  while(!(search.empty())){
	    for(int i=0;i<4;i++){
	      if(field[search.front()%14+xx[i]][search.front()/14+yy[i]]){
		field[search.front()%14+xx[i]][search.front()/14+yy[i]]=0;
		search.push(search.front()+yy[i]*14+xx[i]);
	      }
	    }
	    search.pop();
	  }
	}
      }
    }
    cout<<count<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
Imports System

Module Module1

    Sub Main()

        Dim ABHM() As Integer = Console.ReadLine().Split(" ").Select(Function(x) Integer.Parse(x)).ToArray()

        Dim jkaku As Double = ABHM(2) * 30 + ABHM(3) * 0.5
        Dim fkaku As Double = ABHM(3) * 6
        Dim kaku As Double

        If jkaku - fkaku <= 180 Then
            kaku = Math.Abs(jkaku - fkaku)
        Else
            kaku = 360 - Math.Abs(jkaku - fkaku)
        End If

        Dim yogen As Double = Math.Sqrt(ABHM(0) ^ 2 + ABHM(1) ^ 2 - 2 * ABHM(0) * ABHM(1) * Math.Cos(kaku * Math.PI / 180))

        Console.WriteLine(yogen)

    End Sub

End Module

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

using ul = unsigned long long;

bool is_product_overflow(ul a, ul b) {

	ul prod = a * b;

	return (prod / b != a);
}

int main()
{
	int n; cin >> n;
	vector<ul> a(n);
	vector<int> d(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if (a[i] == 0)
		{
			cout << 0 << endl;
			return 0;
		}
	}

	ul tot = 1;
	for (int i = 0; i < n; i++)
	{
		if (is_product_overflow(tot, a[i]))
		{
			cout << -1 << endl;
			return 0;
		}

		tot *= a[i];
		if (tot > 1'000'000'000'000'000'000UL)
		{
			cout << -1 << endl;
			return 0;
		}
	}

	cout << tot << endl;

	return 0;
}


Measured memory_bytes: 4548
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

ll mod = 1e9 + 7;
ll modpow(ll A, ll B) {
	if (B == 0) return 1;
	if (B % 2) return A * modpow(A, B - 1) % mod;
	ll half = modpow(A, B / 2);
	return half * half % mod;
}

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


	int N, K;
	cin >> N >> K;

	ll F[2001] = {};
	F[0] = 1;
	rep1(i, 2000) F[i] = F[i - 1] * i % mod;

	rep1(i, K) {
		if (N - K + 1 < i) co(0);
		else {
			ll kotae = 1;
			ll kakeru = F[K - 1];
			ll waru = F[i - 1] * F[K - i] % mod;
			kotae = kakeru * modpow(waru, mod - 2) % mod;
			//ce(kotae);
			kakeru = F[N - K + 1];
			waru = F[i] * F[N - K + 1 - i] % mod;
			kotae *= kakeru * modpow(waru, mod - 2) % mod;
			kotae %= mod;
			co(kotae);
		}
	}



	Would you please return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n+2);
    a[0] = 0;
    rep1(i, n) cin >> a[i];
    a[n+1] = 0;
    ll sum = 0;
    rep(i, n+1) sum += abs(a[i] - a[i+1]);
    rep1(i, n) {
        ll tmp = sum;
        tmp -= abs(a[i-1]-a[i]);
        tmp -= abs(a[i]-a[i+1]);
        tmp += abs(a[i-1]-a[i+1]);
        cout << tmp << endl;
    }
    return 0;
}

Measured memory_bytes: 1664
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = int(1e09) + 7
INF = int(1e15)


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def main():
    # sys.stdin = open("sample.txt")
    N = Scanner.int()
    P = Scanner.map_int()
    ans = 0
    m = INF
    for i in range(N):
        if m > P[i]:
            ans += 1
        m = min(m, P[i])
    print(ans)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 71660
h,w=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(h)]

C=[]
for i in range(h):
    flag=1 if i%2==0 else -1
    for j in range(w)[::flag]:
        if A[i][j]%2==1:
            if 0<=j+flag<w:
                C.append([i+1,j+1,i+1,j+flag+1])
                A[i][j+flag] +=1
            elif 0<=i+1<h:
                C.append([i+1,j+1,i+2,j+1])
                A[i+1][j] +=1

print(len(C))
for i in C:print(*i)

Measured memory_bytes: 71900
var
    a,b,c,i,ans:longint;
    a1:array[1..100000]of longint;//定义数组变量
begin
    read(a,b,c);
    for i:=1 to a do
    begin
        read(a1[i]);
        if(a1[i]<b)or(a1[i]>=c)then inc(ans);//暴力判断
    end;
    writeln(ans);
end.

Measured memory_bytes: 128
#include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    char buf[1<<10];
    size_t q;
    scanf("%s %zu", buf, &q);
    string str(buf);

    for (size_t i=0; i<q; ++i) {
        size_t a, b;
        scanf("%s %zu %zu", buf, &a, &b);
        string instr(buf);

        if (instr == "print") {
            printf("%s\n", str.substr(a, b-a+1).c_str());
        } else if (instr == "reverse") {
            reverse(&str[a], &str[b+1]);
        } else if (instr == "replace") {
            scanf("%s", buf);
            string p(buf);
            str.replace(a, b-a+1, p);
        }
    }

    return 0;
}

Measured memory_bytes: 2780
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

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

  int n;
  cin >> n;
  int cnt = n / 100;
  if(100 * cnt <= n && n <= 105 * cnt) cout << 1 << endl;
  else cout << 0 << endl;
}


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

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

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

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

    vector<vector<double>> dp(n+1,vector<double>(n+1,0));
    dp[0][0] = 1.0;

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(i + j >= n){
                break;
            }
            dp[i+1][j] += dp[i][j] * in[i+j];
            dp[i][j+1] += dp[i][j] * (1.0 - in[i+j]);
        }
    }

    double ans = 0;

    for(int i = 0; i <= n; i++){
        if(i > (n - i)){
            ans += dp[i][n-i];
        }
    }

    cout << setprecision(17) << fixed;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 70784
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define N 444
#define ll long long
using namespace std;

int n, A[N];
ll f[N][N], s[N];

inline int read() {
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') {if (ch == '-')f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	return x * f;
}
#define cmin(a,b) ((a>b)?a=b:1)
int main() {
	n = read();
	memset(f, 127, sizeof(f));
	for (int i = 1; i <= n; ++i)A[i] = read(), f[i][i] = 0, s[i] = s[i - 1] + A[i];
	for (int len = 2; len <= n; ++len)
		for (int l = 1; l + len - 1 <= n; ++l) {
			int r = l + len - 1;
			for (int i = l; i < r; ++i)cmin(f[l][r], f[l][i] + f[i + 1][r] + s[r] - s[l - 1]);
		}
	printf("%lld\n", f[1][n]);
	return 0;
}


Measured memory_bytes: 1664
from collections import defaultdict
n = int(input())

factors = defaultdict(int)
for i in range(2, n + 1):
    for j in range(2, i+1):
        while i % j == 0:
            factors[j] += 1
            i //= j
if n == 1:
    print(1)
else:
    a = '*'.join(str(value+1) for value in factors.values())
    print(eval(a)%(10**9+7))


Measured memory_bytes: 3436
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		int dx[]={1,1,0,-1,};
		int dy[]={0,1,1,1};
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int n=in.nextInt();
			if(n==0)
				return;
			int a[][]=new int[n][n];
			int ans=0;
			for(int i=0;i<n;i++)
			{
				String s=in.next();
				for(int j=0;j<n;j++)
					a[i][j]=Integer.valueOf(s.charAt(j)-'0');
			}
			for(int i=0;i<n;i++)
				for(int j=0;j<n;j++)
				{
					
					for(int k=0;k<4;k++)
					{
						int cnt=0;
						int sy=i;
						int sx=j;
						while(0<=sx&&sx<n&&sy<n&&a[sy][sx]==1)
						{
							cnt++;
							sx+=dx[k];
							sy+=dy[k];
						}
						ans=Math.max(ans, cnt);
					}
				}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 13000
import itertools

def print_elements(a):
    print(' '.join(list(map(str, a))))

n = int(input())
a = tuple(map(int, input().split(' ')))

permutations = list(itertools.permutations([i+1 for i in range(n)]))
for i, per in enumerate(permutations):
    if per == a:
        if i != 0: print_elements(permutations[i-1])
        print_elements(a)
        if i != len(permutations)-1: print_elements(permutations[i+1])


Measured memory_bytes: 52368
///
// File:  alds1_3_a.cpp
// Author: ymiyamoto
//
// Created on Fri Oct  6 00:43:19 2017
//

#include <cstdint>
#include <iostream>
#include <string>

using namespace std;

#define SIZE 200

static int64_t array[SIZE];
static uint32_t index;

static int64_t pop()
{
  index--;
  int64_t val = array[index];
  return val;
}

static void push(int64_t val)
{
  array[index] = val;
  index++;
}

int32_t main()
{
  while (true) {
    string str;
    cin >> str;
    if (cin.eof()) break;
    if (str[0] == '+') {
      int64_t operand2 = pop();
      int64_t operand1 = pop();
      push(operand1 + operand2);
    } else if (str[0] == '-') {
      int64_t operand2 = pop();
      int64_t operand1 = pop();
      push(operand1 - operand2);
    } else if (str[0] == '*') {
      int64_t operand2 = pop();
      int64_t operand1 = pop();
      push(operand1 * operand2);
    } else {
      push(stoi(str));
    }
  }

  int64_t val = pop();
  cout << val << endl;

  return 0;
}

Measured memory_bytes: 3176
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

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

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

vector<pair<int, int>> G[55];

int main() {

  rep(i, 5) {
    char x;
    rep(j, 4) {
      cin >> x;
      if(x-'0') {
        G[i * 5 + j].emplace_back(i * 5 + j + 1, 2);
        G[i * 5 + j + 1].emplace_back(i * 5 + j, 0);
      }
    }

    if(i == 4) break;

    rep(j, 5) {
      cin >> x;
      if(x-'0') {
        G[i * 5 + j].emplace_back((i + 1) * 5 + j, 3);
        G[(i + 1) * 5 + j].emplace_back(i * 5 + j, 1);
      }
    }
  }

  string const OP = "LURD";

  int y = 0, x = 0, d = 2;

  while(y != 0 || x != 0 || d != 0) {
    int le = -1, st = -1, ri = -1, dw = -1;
    for(auto && e: G[y * 5 + x]) {
      if(e.second == (d + 3) % 4) le = e.second;
      if(e.second == (d + 1) % 4) ri = e.second;
      if(e.second == d) st = e.second;
      if(e.second == (d + 2) % 4) dw = e.second;
    }
    if(le != -1) d = le;
    else if(st != -1) ;
    else if(ri != -1) d = ri;
    else d = dw;
    y += dy[d], x += dx[d];
    cout << OP[d];
  }
  cout << endl;
    
  return 0;
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
#pragma GCC optimize ("-O3")
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define int long long
#define double long double
#define pb push_back
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define diff(a,b) (a>b?a-b:b-a)
#define F first
#define S second
const int N=1e6+5;
int mod = 1e9+7;
void pairsort(int a[], int b[], int n){
    pair<int, int> pairt[n];
    for (int i = 0; i < n; i++) 
    {
        pairt[i].first = a[i];
        pairt[i].second = b[i];
    }
    sort(pairt, pairt + n);
    for (int i = 0; i < n; i++) 
    {
        a[i] = pairt[i].first;
        b[i] = pairt[i].second;
    }
}
ll pow1(ll n,ll p)
{
    if(p==0)    return 1;
    ll x=pow1(n, p/2);
    x=(x*x)%mod;
    if(p%2==0)
        return x;
    else
        return (x*n)%mod;
}
ll binarySearch(ll arr[], ll l, ll r,ll x) 
{ 
    if (r >= l) 
    { 
        ll mid = l + (r - l) / 2;  
        if (arr[mid] == x) 
        return mid; 
        if (arr[mid] > x) 
        return binarySearch(arr, l, mid - 1, x); 
        return binarySearch(arr, mid + 1, r, x); 
    }
    return -1; 
}
bool compare(const pair<ll, ll>&p1, const pair<ll,ll>&p2)
{
    if(p1.F < p2.F) return true;
        if(p1.F == p2.F) return p1.S < p2.S;
        return false;
}
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b); 
}
int isPrime(int n){
    if(n < 2)
        return 0;
    if(n < 4)
        return 1;
    if(n % 2 == 0 or n % 3 == 0)
        return 0;
    for(int i = 5; i*i <= n; i += 6)
        if(n % i == 0 or n % (i+2) == 0)
            return 0;
    return 1;
}
long long C(int n, int r) {
    if(r>n-r) 
        r=n-r;
    long long ans=1;
    for(int i=1;i<=r;i++){
        ans*=n-r+i;
        ans/=i;
    }
    return ans;
}
int modexpo(int x,int p){
    int res = 1;
    x = x%mod;
    while(p){
        if(p%2)
            res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}

vector<double>v;
int m;
vector<vector<double>>dp;
double prob_heads(int n, int tails){

    if(tails>m/2)return 1;
    if(n==0)return 1;
    if(dp[n][tails]!=-1)return dp[n][tails];

	double ans = 0;
    ans = v[n]*(prob_heads(n-1, tails));
    if(tails<m/2)
	ans += (1-v[n])*(prob_heads(n-1, tails+1));
    return dp[n][tails] = ans;
}
int32_t main()
{
    IOS;
    
    int n;
    cin>>n;
    m=n;
    dp.clear();
    dp.resize(n+1, vector<double>(n+1));
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++)dp[i][j] = -1;
    }
    v.clear();
    v.resize(n+1);
    for(int i=1;i<=n;i++)cin>>v[i];
    int tails = 0, heads = 0;
    double ans = prob_heads(n,tails);
    cout<<fixed<<setprecision(12)<<ans<<endl;

    return 0;
}


Measured memory_bytes: 141312
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < int(n); i++)
#define rep1(i,n) for (int i = 1; i <= int(n); i++)
#define repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define all(x) (x).begin(), (x).end()
#define show(x) #x " = " << x

int main() {
    int a,b; cin >> a >> b;
    int n = (b-1)/(a-1);
    if (b-1 != (a-1)*n) n++;
    cout << n << endl;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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


int N, W;
const int MAX_N = 105;
const int MAX_W = 100005;
ll dp[MAX_N][MAX_W];
ll w[MAX_N];
ll v[MAX_N];

void solve() {
    cin >> N >> W;
    rep(i, N) cin >> w[i] >> v[i];

    memset(dp, 0, sizeof(dp));

    rep(i, N){
        Rep1(j, 0, W){
            if(j < w[i]){
                dp[i+1][j] = dp[i][j];
            }else{
                dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i]);
            }
        }
    }

    cout << dp[N][W] << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 86400
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  string a, b, c;
  cin >> a >> b >> c;
  char A = a[0] - 32;
  char B = b[0] - 32;
  char C = c[0] - 32;
  cout << A << B << C << endl;
}

Measured memory_bytes: 256