akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef pair<ll, ll> P;

int main(){
    int n;
    string ans = "No";
        cin >> n;
        for(int i=1; i<10; i++){
            if(n%i==0){
                if(10<=n/i) continue;
                ans = "Yes";
                break;
            }
        }
        cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <iterator>
#include <cmath>
#include <deque>
using namespace std;

int main()
{
    if (fopen("input.txt", "r")) {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int r;
    cin >> r;
    cout << r * r;
    return 0;
}

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

using namespace std;

int n,s[1001];

int main(void){
	
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(int i=0;i<n;i++)scanf("%d",&s[i]);
		sort(s,s+n);
		int res=0;
		for(int i=1;i<n-1;i++)res+=s[i];
		printf("%d\n",res/(n-2));
	}
	
	return 0;
}

Measured memory_bytes: 1208
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;


public class Main {

	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastInput in = new FastInput(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Sample solver = new Sample();
		solver.solve(1, in, out);
		out.close();
	}
	
	static class Sample {
		
		static int mod = 1000000007;
	
		public void solve(int testNum, FastInput in, PrintWriter out) {
			
			int n = in.nextInt();
			int []a = in.nextIntArray(n);
			
			long []sum  = new long [n+1];
			
			sum[0] = 0L;
			
			for(int i = 0 ; i < n  ;i++) {
				sum [i+1] = sum[i] + (long)a[n-i-1];
			}
			
			long ans = 0;
			
			for(int i = 0 ; i < n ;i++) {
				long tmp = (a[i]* (sum[n-i-1] % mod))%mod;
				ans = (ans + tmp)%mod;
			}
			
			out.println(ans);
	
		}
	
	}
	static class FastInput{
		private final BufferedReader in;
		private String[] buff;
		private int index = 0;
		
		public FastInput(InputStream is) {
			in = new BufferedReader(new InputStreamReader(is));
		}
		String nextLine() {
			try {
				return in.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}
		String next() {
			while (buff == null || index >= buff.length) {
				buff = nextLine().split(" ");
				index = 0;
			}
			return buff[index++];
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		Double nextDouble() {
			return Double.parseDouble(next());
		}
		
		BigInteger nextBigInteger() {
			return new BigInteger(next());
		}
		
		BigDecimal nextBigDecimal() {
			return new BigDecimal(next());
		}
		
		public int[] nextIntArray(final int n) {
			final int[] res = new int [n];
			
			for(int i = 0 ; i < n ;i++) {
				res[i] = nextInt();
			}
			return res;
		}
		
		public long[] nextLongArray(final int n) {
			final long[] res= new long [n];
			
			for(int i = 0 ; i < n ;i++) {
				res[i] = nextLong();
			}
			return res;
		}
		
		public double[] nextDoubleArray(final int n ) {
			final double[] res = new double [n];
			
			for(int i = 0 ; i < n ;i++) {
				res[i] = nextDouble();
			}
			return res;
		}
		
		
		public int[][] nextInt2DArray(final int n , final int m){
			int [][]res = new int [n][m];
			
			for(int i = 0 ; i < n ;i++) {
				for(int j = 0 ; j < m ;j++) {
					res[i][j] = nextInt();
				}
			}
			return res;
		}
		public long[][] nextLong2DArray(final int n , final int m){
			long [][]res = new long [n][m];
			
			for(int i = 0 ; i < n ;i++) {
				for(int j = 0 ; j < m ;j++) {
					res[i][j] = nextLong();
				}
			}
			return res;
		}
		
		public char[][] nextChar2DArray(final int n){
			char [][]res = new char [n][];
			
			for(int i = 0 ; i < n ;i++) {
				String s = next();
				res[i] = s.toCharArray();
			}
			
			return res;
		}
	}
}


Measured memory_bytes: 63096
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<fstream>
#include<algorithm>
using namespace std;
using ll = long long;

int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> h(n);
    for(ll i=0;i<n;i++) cin >> h[i];
    sort(h.rbegin(),h.rend());
    ll sum = 0;
    for(ll i=k;i<n;i++){
        sum += h[i];
    }
    cout << sum << endl;
}   

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

int main(){
    bool A=1;
    while(A){
        int n,x;
        cin >> n >> x;
        if (n==0 && x==0) {A=0;}
        else{
            int count=0;
            for (int c=n; 0<c; c--){
                for (int b=c-1; 0<b; b--){
                    int a=x-c-b;
                    if (0<a && a<b) {count++;}
                }
            }
            cout << count << endl;
        }
    }
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	long long l,c;
	cin >> l >> c;
	long long ans = ((c)*(l))/2;
	ans += c%2==l%2 ? c%2 : 0;
	if (l == 1 || c == 1)
		ans = 1;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

const int Mod = 1000000007;

int main()
{
	int D;
	char K[10001];
	scanf("%s", K);
	scanf("%d", &D);
	
	int i, j, k, tmp = 0;
	long long dp[2][101] = {};
	for (i = 0; K[i] != 0; i++) {
		for (j = 0; j < D; j++) dp[i%2][j] = 0;
		for (j = 0; j < D; j++) {
			for (k = 0; k <= 9; k++) dp[i%2][(j+k)%D] += dp[1-i%2][j];
		}
		for (k = 0; k < K[i] - '0'; k++) dp[i%2][(tmp+k)%D]++;
		tmp = (tmp + K[i] - '0') % D;
		for (j = 0; j < D; j++) dp[i%2][j] %= Mod;
	}
	if (tmp == 0) printf("%lld\n", dp[1-i%2][0]);
	else printf("%lld\n", (dp[1-i%2][0] - 1 + Mod) % Mod);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1700
h,w=map(int,input().split())
mod=10**9+7
G=[['#']*(w+1) for _ in range(h+1)]
for i in  range(1,h+1):
    G[i]=['#']+list(input())
A=[[0]*(w+1) for i in range(h+1)]
A[1][1]=1
for i in range(1,h+1):
    for j in range(1,w+1):
        if i==1 and j==1:
            continue
        if G[i][j]=='.':
            A[i][j]=(A[i-1][j]+A[i][j-1])%mod
print(A[-1][-1])

Measured memory_bytes: 50532
#include<iostream>

using namespace std;

int main(){
	int n,m;
	cin>>n;
	int* S=new int[n];
	for(int i=0;i<n;++i)cin>>S[i];
	cin>>m;
	int *T=new int[m];
	for(int i=0;i<m;++i)cin>>T[i];
	int sum=0;
for(int j=0;j<m;++j)
	for(int i=0;i<n;++i)
		{
			if(S[i]==T[j]){sum++;break;}
		}
    cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll keta(ll n){
    int x=0;
    while(n!=0){
        x++;
        n/=10;
    }
    return x;
}

int main() {
    ll x,k,d;
    cin >> x >> k >> d;
    ll ans=1e18;
    ll mi,ma;
    if(keta(k)+keta(d)<=20)mi=max(-ans,x-d*k);
    else mi=-ans;
    if(keta(k)+keta(d)<=20) ma=min(ans,x+d*k);
    else ma=ans;
    if(ma<0){
        ans=-ma;
        cout << ans << endl;
        return 0;
    }
    if(mi>0){
        cout << mi << endl;
        return 0;
    }
    if(x>=0){
        ll xx=x%d;
        ll yy=xx-d;
        if(((x-xx)/d+k)%2==0){
            cout << xx << endl;
            return 0;
        }
        else{
            cout << abs(yy) << endl;
            return 0;
        }
    }
    else{
        ll xx=((x%d)+d)%d;
        ll yy=xx-d;
        if(((x-xx)/d+k)%2==0){
            cout << xx << endl;
            return 0;
        }
        else{
            cout << abs(yy) << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <time.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FFOR(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef double ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<ut,pr> ppr;
typedef priority_queue<pr,Vpr, greater<pr> > PQ;
const int SIZE=5+3*1e+4;
const ut INF=1<<30;
const ld eps=1e-6;
const LL mod=1e+9 + 7;

map<int, int> arr;
map<int, bool> check;

int main() {
	int n, a, d, m, x, y, z, k;
	cin >> n >> a >> d;
	cin >> m;
	REP(i,m){
		cin >> x >> y >> z;
		if(x){
			check[y] = true;
			if(check[z]){
				arr[y] = arr[z];	
			}
			else{
				arr[y] = a + (z - 1) * d;
			}
		}
		else{
			int tmpy, tmpz;
			if(check[y]){
				tmpy = arr[y];
			}
			else{
				tmpy = a + (y - 1) * d;
			}
			if(check[z]){
				tmpz = arr[z];
			}
			else{
				tmpz = a + (z - 1) * d;
			}
			check[y] = check[z] = true;
			arr[z] = tmpy;
			arr[y] = tmpz;
		}
	}
	cin >> k;
	if(check[k]){
		cout << arr[k] << endl;
	}
	else{
		cout << a + (k - 1) * d << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <cmath> 
#include <cctype>

using namespace std;

int main() {
    int N, X;
    int count = 0;
    cin >> N >> X;
    int m[N];
    for (int i = 0; i < N; i++) {
        cin >> m[i];
    }

    sort(m, m + N);

    for (int i = 0; i < N; i++) {
        X -= m[i];
    }

    while (X >= 0) {
        X -= m[0];
        count++;
    }

    cout << count + N - 1 << endl;
    return 0;
}

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

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

    int ans = 0;
    for (int b = 2; b < 32; b++) {
        for (int p = 2; p < 10; p++) {
            int a = pow(b, p);
            if (a <= x) ans = max(ans, a);
        }
    }
    if (ans == 0) ans = x;

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


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 };




void solve() {
    int N, M; cin >> N >> M;
    vector<string> a(N), b(M);
    rep(i, N) cin >> a[i];
    rep(i, M) cin >> b[i];

    bool f=false;
    rep(i, N){
        rep(j, N){
            bool f1 = true;
            if(i+M > N || j+M > N) continue;
            rep(k, M){
                rep(l, M){
                    if(a[i+k][j+l] != b[k][l]) f1 = false;
                }
            }
            if(f1){
                f=true;
            }
        }
    }

    if(f) cout << "Yes" << endl;
    else cout << "No" << 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: 4352
#include <bits/stdc++.h>
using namespace std;

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

const string YES = "Yes";

void solve(long long N, long long M, std::vector<long long> A,
           std::vector<long long> B) {
    vector<vector<int> > E(N);
    rep(i, M) {
        A[i]--;
        B[i]--;
        E[A[i]].push_back(B[i]);
        E[B[i]].push_back(A[i]);
    }

    vector<int> cost(N, -1);
    vector<int> from(N, -1);
    queue<int> Q;
    cost[0] = 0;
    from[0] = 0;
    Q.push(0);
    while (!Q.empty()) {
        int p = Q.front();
        Q.pop();
        for (int to : E[p]) {
            if (cost[to] == -1) {
                cost[to] = cost[p] + 1;
                from[to] = p;
                Q.emplace(to);
            }
        }
    }

    rep(i, N) {
        if (cost[i] == -1) {
            cout << "No" << endl;
            return;
        }
    }

    cout << "Yes" << endl;
    rep(i, N-1) {
        cout << from[i+1] + 1 << endl;
    }

}

int main() {
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for (int i = 0; i < M; i++) {
        scanf("%lld", &A[i]);
        scanf("%lld", &B[i]);
    }
    solve(N, M, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 13716
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main(){
  string S, T;
  cin >> S >> T;
  
  int length = S.length();
  int f = 0;
  
  vector<int> tableST(26,-1);
  vector<int> tableTS(26,-1);
  
  for(int i = 0; i < length; i++){
    if(tableST[S[i] - 'a'] >= 0){
      if(T[i] - 'a' == tableST[S[i] - 'a']) continue;
      else f = 1;
    }else{
      tableST[S[i] - 'a'] = T[i] - 'a';
    }
    
    if(tableTS[T[i] - 'a'] >= 0){
      if(S[i] - 'a' == tableTS[T[i] - 'a']) continue;
      else f = 1;
    }else{
      tableTS[T[i] - 'a'] = S[i] - 'a';
    }
  }
  
  if(f) cout << "No";
  else cout << "Yes";
}


Measured memory_bytes: 776
#include <stdio.h>

int main() {
	int A,B,C,D,P,X=0,Y=0;
	scanf("%d", &A);
	scanf("%d", &B);
	scanf("%d", &C);
	scanf("%d", &D);
	scanf("%d", &P);

	X= P*A;
	if(C > P) {
		Y = B;
	}else if(C < P) {
		Y = B + (P-C)*D;
	}
	printf("%d\n", X<Y?X:Y);
	return 0;
}

Measured memory_bytes: 596
def euq(a, b)
  b, a = a, b if a < b
  loop { (a % b).zero? ? (return b) : (a, b = b, a % b) }
end

while i = gets
  m, n = i.split.map(&:to_i)
  puts "#{e = euq(m, n)} #{m * n / e}"
end

Measured memory_bytes: 8604
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, K, dp[2001];
  vector< int > Book[10];
  cin >> N >> K;
  for(int i = 0; i < N; ++i){
    int C, G;
    cin >> C >> G;
    Book[G - 1].push_back(C);
  }
  fill_n( dp, K + 1, -1);
  dp[0] = 0;
  for(int i = 0; i < 10; ++i){
    sort(Book[i].rbegin(), Book[i].rend());
    for(int j = K - 1; j >= 0; --j){
      if(dp[j] == -1) continue;
      int sum = 0;
      for(int k = 0; k < Book[i].size() && j + k + 1 <= K; k++){
        sum += Book[i][k];
        dp[j + k + 1] = max( dp[j + k + 1], dp[j] + sum + (k + 1) * k);
      }
    }
  }
  cout << dp[K] << endl;
}

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

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

    int ans = 0;
    int size = s.size();
    rep(i, size/2) {
        if (s[i] != s[size-i-1]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <stdlib.h>
#include <stack>

using namespace std;

int main () {

        string str, in;
        while (getline(cin, in)) {
                str += in;
        }

        stack<long> stc;
        for (int i = 0; i < str.size();) {
                switch (str[i]) {
                case '+' : {
                        long a = stc.top();
                        stc.pop();
                        long b = stc.top();
                        stc.pop();
                        stc.push(b + a);
                        i += 2;
                        break;
                }
                case '-' : {
                        long a = stc.top();
                        stc.pop();
                        long b = stc.top();
                        stc.pop();
                        stc.push(b - a);
                        i += 2;
                        break;
                }
                case '*' : {
                        long a = stc.top();
                        stc.pop();
                        long b = stc.top();
                        stc.pop();
                        stc.push(b * a);
                        i += 2;
                        break;
                }
                default :
                        int pos = str.find(" ", i + 1);
                        long psnu = atol((str.substr(i, pos - i)).c_str());
                        stc.push(psnu);
                        i = pos + 1;
                }
        }
        cout << stc.top() << endl;

        return 0;

}

Measured memory_bytes: 1200
s = input()
s = s.replace("BC","X")
ans = []
c = 0

for i in range(1,len(s)+1):
    if s[-1 * i] == "X":
        c += 1
    elif s[-1 * i] == "A":
        ans.append(c)
    else:
        c = 0
print(sum(ans))


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

def needcount(cycoro, K):
    c = 0
    while cycoro * 2 ** c < K:
        c += 1
    return c

ans = 0
for i in range(1, N+1):
    ans += 1/N * (1/2) ** needcount(i, K)
print(ans)


Measured memory_bytes: 2940
import sys
#input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 9)

def main():
    H,W = map(int,input().split())
    s = [list(input()) for _ in range(H)]
    MOD = 10**9+7
    
    memo = [[-1 for _ in range(W)] for _ in range(H)]
    memo[0][0] = 1
    def ch(x,y):
        if memo[x][y] != -1:
            return memo[x][y]
        else:
            ret = 0
            if x == 0:
                if s[x][y-1] == ".":
                    ret += ch(x,y-1)
            elif y == 0:
                if s[x-1][y] == ".":
                    ret += ch(x-1,y)
            else:
                if s[x][y-1] == ".":
                    ret += ch(x,y-1)
                if s[x-1][y] == ".":
                    ret += ch(x-1,y)
            ret %= MOD
            memo[x][y] = ret
            return ret
    
    ch(H-1,W-1)
    print(memo[-1][-1]%MOD)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 53940
#include <iostream>
#include <locale>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	int n;
	int pt{0},ph{0};
	cin >> n;
	for(int i=0; i < n; i++) {
		string taro,hanako;
		
		cin >> taro >> hanako;
		if      (taro > hanako) 
			pt += 3;
		else if (taro == hanako) {
			pt += 1;
			ph += 1;
		}
		else 
			ph += 3;
	}
	
	cout << pt << " " << ph << endl;
	return 0;
}


Measured memory_bytes: 3176
#include<cstdio>
#include<vector>
#include<utility>
using namespace std;
int row,col,__,II;
char s[1111][1111];
void draw_(int x,int y){
	s[x][y] = '<';
	s[x][y+1] = '>';
}
void drawI(int x,int y){
	s[x][y] = '^';
	s[x+1][y] = 'v';
}
void draw31(int x,int y){
	for(int i=0; i<3; i++){
		if(__ > 0){
			__ --;
			draw_(x+i, y);
		}
	}
	if(II > 0){
		II --;
		drawI(x, y+2);
	}
}
void draw13(int x,int y){
	for(int i=0; i<3; i++){
		if(II>0){
			II --;
			drawI(x, y+i);
		}
	}
	if(__ > 0){
		__ --;
		draw_(x+2, y);
	}
}
void draw22(int x,int y){
	for(int i=0; i<2; i++){
		if(__ > 0){
			__ --;
			draw_(x+i*2, y+i);
		}
	}
	for(int i=0; i<2; i++){
		if(II > 0){
			II --;
			drawI(x+1-i, y+2*i);
		}
	}
}

#define vec vector<pair<int,int> > 
vec v22,v_,vI,v33;
bool chk(int __,int II){
	__ = max(__, 0);
	II = max(II, 0);
	return v22.size() >= (__+1)/2 + (II+1)/2;
}
void draw(){
	for(int i=0; i<v22.size(); i++){
		if(__>0){
			__ --;
			draw_(v22[i].first, v22[i].second);
			if(__ > 0){
				__--;
				draw_(v22[i].first+1, v22[i].second);
			}
		}else
		if(II>0){
			II --;
			drawI(v22[i].first, v22[i].second);
			if(II > 0){
				II --;
				drawI(v22[i].first, v22[i].second+1);
			}
		}
	}
}
void cut(int row,int col){
	int R = row;if(R%2==1)R--;
	int C = col;if(C%2==1)C--;
	for(int i=0; i<R/2; i++)for(int j=0; j<C/2; j++)
		v22.push_back(make_pair(i*2,j*2));
	if(row%2==1){
		for(int j=0; j<col/2; j++)
			v_.push_back(make_pair(row-1, j*2));
	}
	if(col%2==1){
		for(int j=0; j<row/2; j++)
			vI.push_back(make_pair(j*2,col-1));
	}
	if(row%2==1 && col%2==1 && row>1 && col>1){
		v33.push_back(v22.back());
		v22.pop_back();
		v_.pop_back();
		vI.pop_back();
	}
}
bool proc(){
	if((__+II) * 2 > row * col)return false;
	cut(row, col);

	int tmp = min(__, (int)v_.size());
	__ -= tmp;
	for(int i=0; i<tmp; i++)
		draw_(v_[i].first, v_[i].second);
	
	tmp = min(II, (int)vI.size());
	II -= tmp;
	for(int i=0; i<tmp; i++)
		drawI(vI[i].first, vI[i].second);

	if(!v33.empty()){
		if(chk(__-3, II-1)){
			draw31(v33[0].first, v33[0].second);
		}else
		if(chk(__-2, II-2)){
			draw22(v33[0].first, v33[0].second);
		}else
		if(chk(__-1, II-3)){
			draw13(v33[0].first, v33[0].second);
		}else
			return false;
	}
	if(chk(__, II)){
		draw();
		return true;
	}else
		return false;
}
int main(){
	scanf("%d%d%d%d",&row,&col,&__,&II);
	for(int i=0; i<row; i++)
		for(int j=0; j<col; j++)
			s[i][j]= '.';
	if(!proc()){
		puts("NO");
	}else{
		puts("YES");
		for(int i=0; i<row; i++)
			puts(s[i]);
	}
	return 0;
}

Measured memory_bytes: 4336
// template {{{
#include <bits/stdc++.h>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define sz(c) (static_cast<int>(c.size()))
#define endl "\n"

using ld = long double;
using ll = long long;

inline ll addm(ll __a, ll __b, ll __m);
inline ll subm(ll __a, ll __b, ll __m);
inline ll mulm(ll __a, ll __b, ll __m);
ll powm(ll __a, ll __b, ll __m);
ll inv(ll __x, ll __m);
// }}}

const ll INFL = numeric_limits<ll>::max() / 2;
const ll INF = numeric_limits<int>::max() / 2;
const ll MOD = 1e9+7;

const int V = 100500;
ll dp[V];
void solve()
{
    int n, W; cin >> n >> W;
    fill(dp+1, dp+V, INFL);
    for (int i = 0; i < n; i++) {
        int w, v; cin >> w >> v;
        for (int j = V-1; j >= v; j--) {
            if (dp[j-v] + w <= W)
                dp[j] = min(dp[j], dp[j-v] + w);
        }
    }
    for (int i = V-1; i >= 0; i--) {
        if (dp[i] <= W) {
            cout << i << endl;
            return;
        }
    }
}

// main {{{
int main()
{
    cin.sync_with_stdio(0); cin.tie(NULL);
    solve();
    return 0;
}

inline ll addm(ll __a, ll __b, ll __m = MOD) {
    return ((__a+__b)%__m);
}
inline ll subm(ll __a, ll __b, ll __m = MOD) {
    return (((__a-__b)%__m+__m)%__m);
}
inline ll mulm(ll __a, ll __b, ll __m = MOD) {
    return ((__a*__b)%__m);
}
ll powm(ll __a, ll __b, ll __m = MOD) {
    ll ret = (!__b) ? 1 : powm(__a, __b/2, __m);
    return (!__b) ? 1 : mulm(mulm(ret, ret, __m), (__b%2) ? __a : 1, __m);
}
ll inv(ll __x, ll __m = MOD) {
    return powm(__x, __m-2, __m);
}
// }}}


Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys


def solve(N: int):
    L = [2, 1]
    for _ in range(100):
        L.append(L[-1]+L[-2])
    return L[N]


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    print(solve(N))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000

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

    ll n;
    cin >> n;
    cout << "Christmas";
    while(n < 25){
        cout << " Eve";
        n++;
    }
    cout << endl;
}

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

int N;
int X[(int)2e5];

int main() {
    cin >> N;
    rep(i, N) cin >> X[i];

    int sorted_X[(int)2e5];
    copy(X, X + N, sorted_X);
    sort(sorted_X, sorted_X + N);

    int middle_left = sorted_X[N / 2 - 1];
    int middle_right = sorted_X[N / 2];
    // printf("l %d r %d\n", middle_left, middle_right);

    rep(i, N) {
        // int idx = find(sorted_X, sorted_X + N, X[i]) - sorted_X;
        if (X[i] <= middle_left) {
            cout << middle_right << endl;
        } else {
            cout << middle_left << endl;
        }
    }
}

Measured memory_bytes: 3712
#include "bits/stdc++.h"
using namespace std;

int main()
{
   long long int N, Case = 0;
   vector <long int> V;
   for(int i = 0; i < 10; i++)
   {
     long int Temp; cin >> Temp; V.push_back(Temp);
   }
   sort(V.rbegin(),V.rend());
   cout << V[0] << endl << V[1] << endl << V[2] << endl;
   return 0;
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  string s; cin>>s;
  bool ans = false;
  for (int i=1; i<4; i++) {
    if (s[i-1] == s[i]) ans=true;
  }
  if (ans) cout << "Bad" << endl;
  else cout << "Good" << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define F first
#define S second
#define ld long double
#define rep(i,a,n) for (ll i= (a) ; i < (n); ++i)
#define vi vector<ll>
#define all(v) (v).begin(),(v).end()
#define M_PI 3.14159265358979323846
const ll MOD = 1e9 + 7;

void solve() {
	ll n; cin >> n;
	vi h(n + 1);
	rep(i, 1, n + 1) cin >> h[i];
	vi dp(n + 1);
	dp[0] = 0;
	dp[1] = 0;
	dp[2] = abs(h[2] - h[1]);
	for ( int i = 3; i <= n; i++)
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));

//    for(auto c:dp) cout<<c<<" ";
//    cout<<endl;
	cout << dp[n] << endl;
}


int main() {

	int t = 1;

	//cin >> t;
	ll k = 1;
	while (t--) {
		//cout << "Case #" << k++ << ": ";
		solve();
	}
	return 0;
}


Measured memory_bytes: 4748
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf

string s;

int main() { 

  getline(cin, s);

  int mn = -1;
  for (int i = 0; i + 2 < sz(s); i++) {
    int cur = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + s[i + 2] - '0';
    int curDiff = abs(753 - cur);
    if (mn == -1 || curDiff < mn) {
      mn = curDiff;
    }
  }

  cout << mn << endl;

  return 0;
}


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

int Gcd(int a,int b){
    int c,d;
    if(b>a){
        d=a;
        a=b;
        b=d;
    }
    while(b!=0){
        c=b;
        b=a%b;
        a=c;
    }
    return(a);
}

int main(){
    int m,n;
    //long p;
    int k;
    while(cin>>m>>n){
        //p=m*n;
        k=Gcd(m,n);
        cout<<k<<" "<<m/k*n<<endl;
    }
}

Measured memory_bytes: 3092
//by Top1
#include <bits/stdc++.h>
          
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define cerr cout
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
      
const int inf = (1e9) + 1;
const int mod = 479001599;
const int maxn = 1e6 + 111;
        
using namespace std;          

int a, b, n;

void solve(){                       
	cin >> a >> b;

	int x = min(a * 25 / 2, b * 10);

	for (int i = x; i <= 1e6; i++){
		int aa = i * 2 / 25;
		int bb = i / 10;
		if (aa == a && bb == b){
			cout << i;
			return;
		}
	}

	cout << -1;
}                              
      
main(){
    boost;
    
    int q = 1;
 
    //cin >> q;
    
    while (q--){
        solve();
    }
}

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

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


Measured memory_bytes: 3100
#include <stdio.h>

main(){
  int n = 100;
  char s[n+1], *p;

  while (fgets(s, n, stdin) != NULL) {
    s[n] = 0;
    for(p = s; *p != 0; p++) {
      if ('a' <= *p && *p <= 'z') {
	printf("%c", 'A' + (*p - 'a'));
      } else {
	printf("%c", *p);
      }
    }
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
const int maxn = 2e6, mod = 1e9 + 7 ;
int fac[maxn + 10], inv[maxn + 10] ;
int X1, X2, X3, X4, X5, X6, Y1, Y2, Y3, Y4, Y5, Y6 ;
int f[4][3], g[4][3] ;
ll ans = 0 ;
ll power (ll x, int y) {
    ll res = 1 ;
    while (y) {
        if (y & 1) res = res * x % mod ;
        x = x * x % mod; y >>= 1 ;
    }
    return res ;
}
void init () {
    fac[0] = inv[0] = 1 ;
    for (int i = 1; i <= maxn; i ++) fac[i] = 1ll * fac[i - 1] * i % mod ;
    inv[maxn] = power (fac[maxn], mod - 2) ;
    for (int i = maxn - 1; i >= 1; i --) inv[i] = 1ll * inv[i + 1] * (i + 1) % mod ;
}
inline ll C (int n, int m) {
    return 1ll * fac[n + m] * inv[n] % mod * inv[m] % mod ;
}
inline void add (ll &x, ll y) {x = (x + y) % mod;}
ll calc (int x1, int y1, int sig1, int x2, int y2, int sig2) {
    ll res = 0 ;
    for (int x = X3; x <= X4; x ++) {
        add (res, mod - 1ll * C (x - x1, Y3 - 1 - y1) * (x + Y3) % mod * C (x2 - x, y2 - Y3) % mod) ;
        add (res, 1ll * C (x2 - x, y2 - Y4 - 1) * (x + Y4 + 1) % mod * C (x - x1, Y4 - y1) % mod) ;
    }
    for (int y = Y3; y <= Y4; y ++) {
        add (res, mod - 1ll * C (y - y1, X3 - 1 - x1) * (y + X3) % mod * C (y2 - y, x2 - X3) % mod) ;
        add (res, 1ll * C (y2 - y, x2 - X4 - 1) * (y + X4 + 1) % mod * C (y - y1, X4 - x1) % mod) ;
    }
    return (res * sig1 * sig2 + mod) % mod ;
}
int main() {
    init () ;
    scanf("%d%d%d%d%d%d%d%d%d%d%d%d", &X1, &X2, &X3, &X4, &X5, &X6, &Y1, &Y2, &Y3, &Y4, &Y5, &Y6) ;
    f[0][0] = 1, f[0][1] = X1 - 1, f[0][2] = Y1 - 1 ;
    f[1][0] = -1, f[1][1] = X1 - 1, f[1][2] = Y2 ;
    f[2][0] = -1, f[2][1] = X2, f[2][2] = Y1 - 1 ;
    f[3][0] = 1, f[3][1] = X2, f[3][2] = Y2 ;
    g[0][0] = 1, g[0][1] = X6 + 1, g[0][2] = Y6 + 1 ;
	g[1][0] = -1, g[1][1] = X6 + 1, g[1][2] = Y5 ;
	g[2][0] = -1, g[2][1] = X5, g[2][2] = Y6 + 1 ;
	g[3][0] = 1, g[3][1] = X5, g[3][2] = Y5 ;
    for (int i = 0; i < 4; i ++)
        for (int j = 0; j < 4; j ++)
            add (ans, calc (f[i][1], f[i][2], f[i][0], g[j][1], g[j][2], g[j][0])) ;
    printf("%lld\n", ans) ;
    return 0 ;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define rep(i,  x,  y) for(int i = x; i <= y; i ++)
#define ll long long
#define X first
#define Y second
#define ls rt << 1
#define rs rt << 1 | 1
#define INF 0x3f3f3f3f
#define mod 1000000007
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int N = 10010;
struct edge
{
	int v, next;
}E[N << 1];
inline ll qpow(ll bas,int pw)
{
	ll ret = 1;
	while(pw)
	{
		if(pw & 1) ret = 1ll * ret * bas % mod;
		bas = 1ll * bas * bas % mod;
		pw >>= 1;
	}
	return ret;
}
ll n,ee,head[N],p1,s1,p2,s2;
ll size[N],jc[N],ny[N],fa[N];
ll bs[N],tot,F[N],G[N];
inline void addedge(int u,int v)
{
	E[++ ee].v = v;
	E[ee].next = head[u];
	head[u] = ee;
}
inline void dfs(int rt)
{
	size[rt] = 1;
	ll mx = 0;
	for(int i = head[rt]; i; i = E[i].next)
	{
		if(E[i].v == fa[rt]) continue;
		fa[E[i].v] = rt;
		dfs(E[i].v);
		size[rt] += size[E[i].v];
		mx = max(mx, size[E[i].v]);
	}
	ll sd = max(mx, n - size[rt]), pd = rt;
	if(sd < s1) swap(sd, s1), swap(pd, p1);
	if(sd < s2) swap(sd, s2), swap(pd, p2);
}
inline void Add(ll &x,ll y)
{
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
inline ll C(int n,int m)
{
	return 1ll * jc[n] * ny[m] % mod * ny[n - m] % mod;
}
int main()
{
	jc[0] = ny[0] = 1;
	rep(i, 1, 5000) jc[i] = 1ll * jc[i - 1] * i % mod;
	ny[5000] = qpow(jc[5000], mod - 2);
	for(int i = 4999; i >= 1; i --) ny[i] = 1ll * ny[i + 1] * (i + 1) % mod;
	n = read();
	s1 = s2 = n + 1;
	rep(i, 1, n - 1)
	{
		int u = read(), v = read();
		addedge(u, v);
		addedge(v, u);
	}
	dfs(1);
	if(!(s1 ^ s2)) {cout << 1ll * jc[n / 2] * jc[n / 2] % mod << endl; return 0;}
	else
	{
		for(int i = head[p1]; i; i = E[i].next)
		{
			if(E[i].v == fa[p1]) continue;
			bs[++ tot] = size[E[i].v];
		}
		bs[++ tot] = n - size[p1];
		F[0] = 1;
		rep(i, 1, tot)
		{
			rep(j, 0, n - 1) G[j] = F[j];
			rep(j, 1, bs[i])
				for(int k = n - 1; k >= j; k --)
					if(F[k - j])
						Add(G[k], 1ll * F[k - j] * jc[bs[i]] % mod * ny[bs[i] - j] % mod * C(bs[i], j) % mod);
			rep(j, 0, n - 1) F[j] = G[j];
		}
		ll Ans = jc[n];
		for(int i = 1, f = -1; i <= n - 1; i ++, f *= -1)
			Add(Ans, f * F[i] * jc[n - i] % mod);
		cout << Ans << endl;
	}
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fr(i, a, b) for(int i=a; i>=b; i--)
#define l long int
using namespace std;
//ll MOD=1000000000000007;
int main()
{
//   
double x,n;
l t;
cin>>n>>x>>t;
l s=ceil(n/x);
l ans=t*s;
cout<<ans;


}






Measured memory_bytes: 3752
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
int main(){
	int n;
	cin>>n;

	vvi in(n,vi(2));
	rep(i,n)rep(j,2)cin>>in[i][j];
	int w=-1;
	rep(i,n){
		int a=(abs(in[i][0]+in[i][1]))%2;
		if(w!=-1&&w!=a){
			cout<<-1<<endl;
			return 0;
		}
		w=a;
	}
	
	int m=35;
	vi g(m);
	rep(i,m)g[i]=1ll<<(m-i-1);
	if(!w){
		g.pb(1);
		m++;
	}
	cout<<g.size()<<endl;
	rep(i,g.size())cout<<g[i]<<" ";cout<<endl;
	
	rep(_,n){
		ll x=in[_][0],y=in[_][1];
		rep(i,m){
			if(x>=0&&abs(y)<=abs(x)){
				cout<<'R';
				x-=g[i];
			}
			else if(y>=0&&abs(y)>=abs(x)){
				cout<<'U';
				y-=g[i];
			}
			else if(x<=0&&abs(y)<=abs(x)){
				cout<<'L';
				x+=g[i];
			}
			else if(y<=0&&abs(y)>=abs(x)){
				cout<<'D';
				y+=g[i];
			}else assert(0);
		}
		cout<<endl;
	}
}









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

int main() {
  int N;
  cin >> N;
  vector<pair<int,int>> loc(N);
  for (auto &p : loc) cin >> p.first >> p.second;
  sort(loc.begin(),loc.end());
  map<pair<int,int>,int> delt;
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      int x = loc[j].first-loc[i].first;
      int y = loc[j].second-loc[i].second;
      delt[make_pair(x,y)] += 1;
    }
  }
  int M = 0;
  for (auto mp : delt) M = max(mp.second,M);
  cout << N-M << endl;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

template <typename T>
T keta(T N){
  T counter = 1;
  while(N/10 > 0){
    N /= 10;
    counter ++;
  }
  return counter;
}

ll ncr(ll n, ll r){
  if(n < r) return 0;
  if(r > n-r) r = n-r;

  ll a = 1, b = 1;
  for(int i = 0; i < r; i++){
    a *= (n - i);
  }
  for(int i = 0; i < r; i++){
    b *= (i + 1);
  }
  return a/b;
}

template <typename T>
T beki(T x, ll n){
  T res = 1;
  while(n > 0){
    if(n & 1) res *= x;
    x = x * x;
    n >>= 1;
  }
  return res;
}

int main(){
  int N;
  cin >> N;
  int ketaN = keta(N);
  vvi num(10, vi(10, 0));
  for(int i = 1; i <= 9; i++){
    for(int j = 1; j <= 9; j++){
      if(i == j && i <= N) num.at(i).at(j)++;
      for(int k = 2; k < ketaN; k++){
        num.at(i).at(j) += beki(10, k-2);
      }
      if(N>=i*beki(10, ketaN-1)+j){
        if(ketaN == 2) num.at(i).at(j)++;
        else if(i < N/beki(10, ketaN-1)) num.at(i).at(j) += beki(10, ketaN-2);
        else{
          int NN = i*beki(10, ketaN-1)+j;
          while(N >= NN){
            num.at(i).at(j)++;
            NN += 10;
          }
        }
      }
      
    }
  }
  ll ans = 0;
  for(int i = 1; i <= 9; i++){
    for(int j = 1; j <= 9; j++){
      ll n = (ll)num.at(i).at(j);
      ll m = (ll)num.at(j).at(i);
      if(i == j) ans += n * m;
      else ans += n * m;
    }
  }
  cout << ans << endl;
}

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

int age(int m, int x) {
  if (x % m == 0) {
    return x / m;
  }
  else {
    return x/ m +1;
  }
}

int main() {
  double N, K;
  cin >> N >> K;
  if (K == 1) {
    cout << 1 <<endl;
  }
  else {
  double n = N;
  double p = 0;
  if (N >= K) {
    double q = (N - K + 1) / N;
    p += q;
    n = K - 1;
  }
  int c = age(n, K);
  int count = 0;
  while (c > 1) {
    c = age(2, c);
    count++;
  }
  int C = count;
  double s = 1.0;
  while (count > 0) {
    s *= 2.0;
    count--;
  }
  for (int i = n; i> 0; i--) {
    if (s * i >= K) {
      double P = 1 / s / N;
      p += P;
    }
    else {
      s *= 2.0;
      double P = 1 / s / N;
      p += P;
    }
  }
  printf("%.10lf\n", p);
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define check(a) if(!(a)){f = false;}
using namespace std;
typedef vector<int> vi;

class UnionFind{
  vi p,r;
public:
  UnionFind(int n):p(n,-1),r(n,0){ }
  int find(int x){ return (p[x]<0)?x:(p[x] = find(p[x])); }
  bool same(int x,int y){return find(x)==find(y);}
  void unite(int x,int y){
    x = find(x); y = find(y);
    if(x==y)return;

    if(r[x] < r[y])p[x] = y;
    else p[y] = x;
    if(r[x] == r[y])r[x]++;
  }
};

int main(){
  int n,m;
  while(scanf("%d%d",&n,&m), n){
    vi deg(n,0);
    UnionFind uf(n);

    bool f = true;
    rep(i,m){
      int a,b;
      scanf("%d%d",&a,&b); a--; b--;
      check(++deg[a]<=2);
      check(++deg[b]<=2);
      check(!uf.same(a,b));
      uf.unite(a,b);
    }

    if(f)puts("yes");
    else puts("no");
  }
}

Measured memory_bytes: 2312
import Data.Bool

main :: IO ()
main = interact solve

solve :: String -> String
solve = putResult . good . read

putResult :: Bool -> String
putResult = bool "No" "Yes"

good :: Int -> Bool
good x
  | x < 1000         = False
  | x > 9999         = False
  | y `mod` 111 == 0 = True
  | z `mod` 111 == 0 = True
  | otherwise        = False
  where
    y = x `mod` 1000
    z = x `div` 10


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
const int MAXN=200200;
const int MOD=998244353;
int N;
int dp[MAXN][3][3][2];
void add(int &x,int y){x+=y;if(x>=MOD)x-=MOD;}
unordered_set<string>vals;
void brute(string S){
	if(vals.count(S))return;
	vals.emplace(S);
	for(int i=0;i+1<N;++i){
		if(S[i]!=S[i+1]){
			char nv='a'+'b'+'c'-S[i]-S[i+1];
			string T=S;
			T[i]=T[i+1]=nv;
			brute(T);
		}
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	string S;
	cin >> S;
	N=S.size();
	if(N <= 3){
		brute(S);
		cout<<int(vals.size())<<"\n";
		return 0;
	}
	for(int i=0;i<3;++i)dp[1][i][i][0]=1;
	for(int i=2;i <= N;++i)
		for(int sum=0;sum<3;++sum)
			for(int last=0;last<3;++last)
				for(int was=0;was<2;++was)
					for(int nxt=0;nxt<3;++nxt)
						add(dp[i][(sum+nxt)%3][nxt][was|(last==nxt)],dp[i-1][sum][last][was]);
	int sum=0;
	bool flagDiff=true,flagSame=true;
	for(int i=0;i<N;++i){
		sum += int(S[i]-'a');
		sum %= 3;
		if(i)flagDiff &=(S[i]!=S[i-1]),flagSame &=(S[i]==S[i-1]);
	}
	int ans=flagDiff;
	for(int i=0;i<3;++i){
		add(ans,dp[N][sum][i][1]);
	}
	if(flagSame)ans=1;
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 14612
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;cin>>N;
  ll sum=0;
  map<ll, ll> MAP;
  MAP[0]++;
  FOR(i,0,N){
    ll A;cin>>A;
    sum += A;
    MAP[sum]++;
  }
  ll ans=0;
  for(auto m : MAP){
    ans += m.second*(m.second-1)/2;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
#include <time.h> 
#define ll long long int
#define F first
#define S second
#define pb push_back
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y);
#define sdl(x) scanf("%lld",&x)
#define sd2l(x,y) scanf("%lld%lld",&x,&y);
#define sz(x) (int)(x.size())
#define nax 100010
#define inf 1001000100
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define mp make_pair
#define pc pair<char ,int>
#define pi pair<int ,int>
#define pii pair <pi,pi>
using namespace std;
double dp[3003][3003];
double prob[3003];
int main(int argc, char const *argv[])
{
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  //fastio;
  int n;
  sd(n);
  for(int i = 1; i <= n; i++)
    cin >> prob[i];

  double fans = 0.0;
  dp[0][0] = 1.0;

  for(int i = 1; i <= n; i++)
  {
      for(int j = 0; j <= i; j++) // itne heads
      {
          dp[i][j] = dp[i][j] + (j > 0 ? dp[i - 1][j - 1] * prob[i] : 0) + dp[i - 1][j] * (1 - prob[i]);
          if(i == n && j > i -j)
            fans += dp[i][j];
      }
  }
  cout << fixed << setprecision(12) << fans;
  return 0;
} 

Measured memory_bytes: 68992
#include <iostream>

int main(){
  int N;
  long long now = 1, buf = 2, buf2 = 2;
  
  std::cin>>N;
  
  if(N == 0)now = 2;
  else if(N == 1)now = 1;
  else {
    for(int i = 0; i < N - 1; i++){
      buf2 = now;
      now = now + buf;
      buf = buf2;
    }
  }
  
  std::cout<<now;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
using namespace std;
typedef long long ll;


int main(int argc, char *args[]) {
	int a, b;
	cin >> a >> b;
	int b_digits;
	b_digits = to_string(b).length();
	int num;
	num = a * pow(10,b_digits) + b;
	bool flag = false;
	for (int i = 1; i <= sqrt(num) + 1; i++) {
		if (num == i*i) {
			flag = true;
			break;
		}
	}
	if (flag == true) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
int main(){
    int n,m,p,ac=0,wa=0;
    string s;
    bool x[100005];
    int wac[100005]={};
    cin>>n>>m;
    REP(i,n) x[i]=false;
    REP(i,m){
        cin>>p>>s;
        if(s.compare("AC")==0){
            if(x[p-1]==false){
                x[p-1]=true;
                ac++;
                wa+=wac[p-1];
            }
        }
        else{
            if(x[p-1]==false) wac[p-1]++;
        }
    }
    cout<<ac<<" "<<wa<<endl;
}

Measured memory_bytes: 768