akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {
	FastScanner in = new FastScanner(System.in);
	PrintWriter out = new PrintWriter(System.out);

	String right = "yuiophjklnm";
	String left = "qwertasdfgzxcvb";
	
	public void run() {
		while (true) {
			String s = in.next();
			if (s.matches("#")) break;
			
			int res = 0;
			int nowHand = -1;
			for (int i = 0; i < s.length(); i++) {
				int next = 0;
				char c = s.charAt(i);
				boolean flag = false;
				for (int j = 0; j < left.length(); j++) {
					if (left.charAt(j) == c) {
						flag = true;
						break;
					}
				}
				next = (flag) ? 1 : 0;
				if (next != nowHand && nowHand != -1) res++;
				nowHand = next;
			}
			
			System.out.println(res);
		}
		out.close();
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");

		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}

		System.out.println("----------------------------");
		System.out.println();
	}

	public void debug(Object... obj) {
		System.out.println(Arrays.deepToString(obj));
	}

	class FastScanner {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public FastScanner(InputStream stream) {
			this.stream = stream;
			//stream = new FileInputStream(new File("dec.in"));

		}

		int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    vector<pair<ll,ll>> b;
    for(i = 0;i < n;++i){
        b.emplace_back(a.at(i), i);
    }
    sort(all(b));
    reverse(all(b));
    vector<vector<ll>> dp(n,vector<ll>(n+1,0));
    dp.at(0).at(0) = b.front().first*b.front().second;
    dp.at(0).at(1) = b.front().first*(n-1-b.front().second);
    for(i = 1;i < n;++i){
        auto x = b.at(i);
        ll val = x.first;
        ll ind = x.second;
        rep(j,i+2){
            if(j == 0){
                dp.at(i).at(j) = dp.at(i-1).at(j) + val*abs(ind - i);
            }else{
                dp.at(i).at(j) = max(dp.at(i-1).at(j) + val*abs(ind - i + j), dp.at(i-1).at(j-1) + val*abs(n - j - ind));
            }
        }
    }
    ll ans = 0;
    for(i = 0;i <= n;++i){
        ans = max(ans, dp.at(n-1).at(i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 34676
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <string.h>
using namespace std;
int sx, sy, tx, ty;
int main()
{
    cin >> sx >> sy >> tx >> ty;
    int x = tx - sx;
    int y = ty - sy;
    for (int i = 0; i < y; i++)
        cout << "U";
    for (int i = 0; i < x; i++)
        cout << "R";

    for (int i = 0; i < y; i++)
        cout << "D";
    for (int i = 0; i < x; i++)
        cout << "L";

    cout << "L";
    for (int i = 0; i < y + 1; i++)
        cout << "U";
    for (int i = 0; i < x + 1; i++)
        cout << "R";

    cout << "DR";
    for (int i = 0; i < y + 1; i++)
        cout << "D";
    for (int i = 0; i < x + 1; i++)
        cout << "L";
    cout << "U" << endl;
    return 0;
}

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

int main() {
    string S;
    cin >> S;
    int er=1000;
    for (int i=0;i<S.size()-2;i++){
        int x=abs(stoi(S.substr(i,3)) -753);
        if (er > x){
            er=x;
        }
    }

    cout << er << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
typedef pair<int,int> PII;
const int mod = 1e9+7,INF = 1e9;
const int mx = 1e6+5;
//int a[101];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x,n;
    cin>>x>>n;
    int p;
    map<int,int>mp;
    for(int i=0;i<n;i++)
        {
            cin>>p;
            mp[p] =1;
        }
    for(int i=0;i<=101;i++)
    {
      if(!mp.count(x-i))
      {
          cout<<x-i<<endl;
          return 0;
      }
      if(!mp.count(x+i))
      {
          cout<<x+i<<endl;
          return 0;
      }
    }
    return 0;
}



Measured memory_bytes: 3628
#include"stdio.h"
int main(){
    long a,b,x,res=0;
    scanf("%ld%ld%ld",&a,&b,&x);
    if (a!=0) res=b/x-(a-1)/x;
    else res=b/x+1;
    printf("%ld",res);
    return 0;
}

Measured memory_bytes: 1716
#include<bits/stdc++.h>
using namespace std;
int main()
{  
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	int a ,b,c;
	cin>> a >> b>> c;

	if((b-a)==(c-b))
	{
		cout<<"YES"<<"\n";

	}
	else
	{
		cout<<"NO"<<"\n";
	}
}

Measured memory_bytes: 3648
#ifdef DEBUG
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <cassert>
#include <sstream>
#include <fstream>
#include <functional>
#include <set>
#include <bitset>
#include <string>
#include <utility>
#include <queue>
#include <deque>
#include <vector>
#include <map>
#else
#include <bits/stdc++.h>
#endif

#ifdef DEBUG
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

#define rep(i, n) for (int i = 0, i##_end_ = (n); i < i##_end_; ++i)
#define per(i, n) for (int i = (n) - 1; i >= 0; --i)
#define forn(i, l, r) for (int i = (l), i##_end_ = (r); i <= i##_end_; ++i)
#define nrof(i, r, l) for (int i = (r), i##_end_ = (l); i >= i##_end_; --i)
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define SZ(x) (int)((x).size())
#define ALL(x) (x).begin(), (x).end()

using namespace std;

typedef vector<int> vi;

typedef pair<int, int> pii;

typedef long long LL;

template<typename T> inline bool chkmax(T &x, const T &y) {
	return x < y ? x = y, 1 : 0;
}

template<typename T> inline bool chkmin(T &x, const T &y) {
	return x > y ? x = y, 1 : 0;
}

int n, k;
string s;

void transfer(vector< vector<int> > &dp) {
	auto pd = dp;
	for (int i = 0; i < n; ++i) {
		for (int j = n - 1; ~j; --j) {
			dp[i + 1][j + 1] = max(dp[i + 1][j + 2], dp[i][j + 1]);
			if(s[i] == s[j]) {
				chkmax(dp[i + 1][j + 1], dp[i][j + 2] + 1);
			}
			else {
				chkmax(dp[i + 1][j + 1], pd[i][j + 2] + 1);
			}
		}
	}
	return;
}

int main() {
	cin >> s;
	n = s.size(), k;
	cin >> k;
	vector< vector<int> > dp(n + 2, vector<int>(n + 2, 0));
	for (int i = 0; i < n; ++i) {
		for (int j = n - 1; ~j; --j) {
			dp[i + 1][j + 1] = max(dp[i + 1][j + 2], dp[i][j + 1]);
			if(s[i] == s[j]) {
				chkmax(dp[i + 1][j + 1], dp[i][j + 2] + 1);
			}
		}
	}
	for (int _k = 1; _k <= k; ++_k) {
		transfer(dp);
	}
	int ans = 0;
	for (int i = 0; i <= n + 1; ++i) {
		for (int j = i + 1; j <= n + 1; ++j) {
			chkmax(ans, dp[i][j] * 2);
		}
		if(i >= 1 && i <= n) {
			chkmax(ans, dp[i - 1][i + 1] * 2 + 1);
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

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

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

//#define int long long

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
int N,K;
VI a;

int dp[112345][2];

int rec(int r, int pl){ // 1ならplが勝つ
    if(dp[r][pl] != -1) return dp[r][pl];
    bool win = false;
    for(int i : a){
        if(r-i < 0) continue;
        if(rec(r-i,pl^1) == 0) win = true;
    }
    if(win) return dp[r][pl] = 1;
    else return dp[r][pl] = 0;
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    cin >> N >> K;
    a.resize(N);
    REP(i,N) cin >> a[i];
    memset(dp,-1,sizeof(dp));

    if(rec(K,0)){
        cout << "First" << endl;
    }else{
        cout << "Second" << endl;
    }



}


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

int main() {
    int n;
    int l[10];
    int sum = 0;
    
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }
    
    sort(l, l + n, greater<int>());
    
    for (int i = 1; i < n; i++) {
        sum += l[i];
    }
    
    cout << ((l[0] >= sum) ? "No" : "Yes") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

typedef tree<
        int,
        null_type,
        less<int>,
        rb_tree_tag,
        tree_order_statistics_node_update>
        ordered_set;



int main() {
//    cout << fixed << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    int n;
    cin >> n;
    while (n--) {
        int e;
        cin >> e;
        if (e % 2 == 0 && e % 5 && e % 3) {
            cout << "DENIED";
            return 0;
        }
    }

    cout << "APPROVED";


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define reps(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define rep(i, n) reps(i, 0, n - 1)
#define sper(i, s, n) for (int i = (s); i >= (int)(n); i--)
#define per(i, n) sper(i, n - 1, 0)
using namespace std;
using ll = long long;
using P = pair<int, int>;

void solve()
{
    int n, k;
    cin >> n >> k;
    int ans = n - k + 1;
    cout << ans << endl;
}

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

Measured memory_bytes: 3600
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let r: usize = iterator.next().unwrap().parse().unwrap();
    let g: usize = iterator.next().unwrap().parse().unwrap();
    let b: usize = iterator.next().unwrap().parse().unwrap();

    if (r * 100 + g * 10 + b) % 4 == 0 {
        "YES".to_string()
    } else {
        "NO".to_string()
    }
}


Measured memory_bytes: 2140
A, B = map(int, input().split())
fu, fd = [['#' for _ in range(100)] for _ in range(50)], [['.' for _ in range(100)] for _ in range(50)]
dx, dy = [1, 0, -1, 0], [0, 1, 0, -1]
for _ in range(A - 1):
    FLAG = BREAK = False
    for y in range(1, 49):
        for x in range(1, 49):
            for i in range(4):
                for j in range(4):
                    if fu[y + dy[i]][x + dx[j]] == '.':
                        BREAK = True
            if BREAK:
                BREAK = False
                continue
            FLAG, fu[y][x] = True, '.'
            break
        if FLAG:
            break
for _ in range(B - 1):
    FLAG = BREAK = False
    for y in range(1, 49):
        for x in range(1, 49):
            for i in range(4):
                for j in range(4):
                    if fd[y + dy[i]][x + dx[j]] == '#':
                        BREAK = True
            if BREAK:
                BREAK = False
                continue
            FLAG, fd[y][x] = True, '#'
            break
        if FLAG:
            break
print(100, 100)
for f in [fu, fd]:
    for y in range(50):
        s = ""
        for x in range(100):
            s += f[y][x]
        print(s)

Measured memory_bytes: 46940
#include <cstdio>
#include <vector>
#define N 300005
using namespace std;
typedef long long ll;
ll n, q, k, c[N];
vector<ll> a[N], b[N];

void f(ll p, ll q, ll r) {
	c[p] = r;
	for(ll i=0; i<a[p].size(); i++)
		if(a[p][i]!=q) f(a[p][i], p, r+b[p][i]);
}

int main() {
	ll u, v, w;
	scanf("%lld", &n);
	while(--n) {
		scanf("%lld%lld%lld", &u, &v, &w);
		a[u].push_back(v);
		b[u].push_back(w);
		a[v].push_back(u);
		b[v].push_back(w);
	}
	scanf("%lld%lld", &q, &k);
	f(k, 0, 0);
	while(q--) {
		scanf("%lld%lld", &u, &v);
		printf("%lld\n", c[u]+c[v]);
	}
	return 0;
}

Measured memory_bytes: 32256
n,k = map(int,input().split())
h = list(map(int,input().split()))
dp = [float("inf") for i in range(n)]
dp[0] = 0
for i in range(1,n):
    if(i<k):
        for j in range(1,i+1):
            if(dp[i] > dp[i-j]+abs(h[i]-h[i-j])):
                dp[i] = dp[i-j]+abs(h[i]-h[i-j])
    else:
        for j in range(1,k+1):
            if(dp[i] > dp[i-j]+abs(h[i]-h[i-j])):
                dp[i] = dp[i-j]+abs(h[i]-h[i-j])
print(dp[-1])

Measured memory_bytes: 57056
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,k;
signed main(){
    cin>>n>>k;
    init_fact();
    int ans=0;
    for(int i=0;i<=min(n,k);i++){
        int res=comb(n,i);
        res*=comb(n-1,n-i-1);
        res%=mod;
        ans+=res;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}

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

bool IsSquare(int N)
{
    int i;
    for(i=1; N>0; i+=2)  //变化步长为2， 初值为1，一直减到N大于0
    {
        N-=i;
    }
    if(N==0)
        return true;  //如果N减到最后，恰好等于0，就是平方数
    else
        return false;  //否则，就不是平方数
}

int main()
{
    int n;
    cin>>n;
    
    while(n){
        if(IsSquare(n)){
           cout << n;
            break;
        }
       else n--;
        
    }
    
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll X, Y, Z;
    cin >> X >> Y >> Z;
    cout << (X - Z) / (Y + Z) << endl;
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  int n,a,b;
  string s;
  cin>>n>>a>>b>>s;
  int in=0,out=0;
  for(int i=0;i<n;i++){
    if(s[i]=='c'){
      cout<<"No"<<endl;
      continue;
    }
    if(s[i]=='a'){
      if(in+out<a+b){
        cout<<"Yes"<<endl;
        in++;
      }
      else cout<<"No"<<endl;
    }
    else{
      if(in+out<a+b and out<b){
        cout<<"Yes"<<endl;
        out++;
      }
      else cout<<"No"<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 896
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

int main(void) {
    cout << std::fixed << std::setprecision(10);
    cin.tie(0);
    std::ios::sync_with_stdio(false);

    int h, w, n;
    cin >> h >> w >> n;
    std::vector<int> vec(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        cin >> vec[i];
    }

    int result[h][w];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            result[i][j] = 0;
        }
    }

    int target = 1;
    int x = 0, y = 0;
    bool lefttoright = true;
    while (target <= n) {
        int count = 0;
        while (count < vec[target]) {
            result[x][y] = target;
            if (lefttoright) {
                if (y + 1 < w) {
                    y++;
                } else {
                    x++;
                    lefttoright = false;
                }
            } else {
                if (y - 1 >= 0) {
                    y--;
                } else {
                    x++;
                    lefttoright = true;
                }
            }
            count++;
        }
        target++;
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << result[i][j] << " ";
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 384
def main ():
  input()
  result = 1
  for i in map(int, input().split()):
    if i == 0:
      result = 0
      break
    
    if result == -1:
      continue
      
    result = result * i
    if result > 10 ** 18:
      result = -1
  
  return result

print(main())


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

vector < int > adj[5];

int main() {
	int cnt1 = 0, cnt = 0;
	for ( int i = 0; i < 3; i++ ) {
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for ( int i = 1; i <= 4; i++ ) {
		if ( (int)adj[i].size() == 1 ) cnt1++;
		else if ( (int)adj[i].size() == 2 ) cnt++;
		else {
			cout << "NO";
			return 0;
		}
	}
	if ( cnt1 == 2 && cnt == 2 ) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);
const ld EPS = 1e-6;
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
const char nl = '\n';

template <typename T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T> inline T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> void ckmin(T& a, T b) { a = min(a, b); }
template <class T> void ckmax(T& a, T b) { a = max(a, b); }

// (Integer/Long).bitCount(x)
int pct(int x) { return __builtin_popcount(x); }
int pctll(ll x) { return __builtin_popcountll(x); }

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
void setIO(string s = "") {
	unsyncIO();
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); }
}

// Binary Exponentiation
ll pow(ll b, ll e, ll m = 0LL, ll ans = 1LL) { while (e) { if (e & 1LL) { ans *= b; if (m) ans %= m; } b *= b, e >>= 1LL; if (m) b %= m; } return ans; }



void solve(int tcn) {
	int k;
	cin >> k;
	F0R(i, k) cout << "ACL";
	cout << nl;
}

int main() {
    setIO();

    int t = 1; //cin >> t;
	for (int i = 1; i <= t; ++i) {
		//cout << "Case #" << i << ": ";
		solve(i);
	}
	return 0;
}

Measured memory_bytes: 3588
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>


#define MAX_E 10000
#define MAX_V 100
#define INF 100000000

typedef struct edge{
    int from;
    int to;
    int cost;
}edge;


edge es[MAX_E];

int distance[MAX_V];

void bellman_ford(int n, int s, int e) {
    int i, update;
    
    for (i = 0; i < MAX_V; i++) distance[i] = INF;
    distance[s] = 0;
    while (1) {
        update = 0;
        for (i = 0; i < e; i++) {
            edge e = es[i];
            if (distance[e.from] != INF && distance[e.to] > distance[e.from] + e.cost) {
                distance[e.to] = distance[e.from] + e.cost;
                update = 1;
            }
        }
        if (!update) break;
    }
}


int main( ){
    
    int n, i, j, l, u, v, k, c;
    scanf("%d", &n);
    
    
    l = 0;
    for (i = 0; i < n; i++) {
        scanf("%d %d", &u, &k);
        
        for (j =0 ; j < k; j++) {
            scanf("%d %d", &v, &c);
            es[l].from = u;
            es[l].to = v;
            es[l].cost = c;
            l++;
        }
    }
    
    bellman_ford(n, 0, l);
    
    for (i=0; i<n; i++) {
        printf("%d %d\n", i, distance[i]);
    }
    
    return 0;
}

Measured memory_bytes: 656
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 10000

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

const int INF = 1<<30;
const ll MOD = ll(1e9+7);

int main(){
  int n, k;cin>>n>>k;
  ll ans = 0LL;
  repb(b, 1, n+1){
    int p, r;
    p = n/b;r = n%b;
    ans += p * max(0, b-k);
    ans += max(0, r-k+1);
  }
  if(k==0)ans -= n;
  cout<<ans<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


Measured memory_bytes: 256
a,b=map(int,input().split())
c,d=map(int,input().split())
e,f=map(int,input().split())
g,h=map(int,input().split())

if a==1:
    print(b*6000)
elif a==2:
    print(b*4000)
elif a==3:
    print(b*3000)
elif a==4:
    print(b*2000)
if c==1:
    print(d*6000)
elif c==2:
    print(d*4000)
elif c==3:
    print(d*3000)
elif c==4:
    print(d*2000)
if e==1:
    print(f*6000)
elif e==2:
    print(f*4000)
elif e==3:
    print(f*3000)
elif e==4:
    print(f*2000)
if g==1:
    print(h*6000)
elif g==2:
    print(h*4000)
elif g==3:
    print(h*3000)
elif g==4:
    print(h*2000)


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

ans = 0
i = 0
while n > i:
    ans += 1
    while n > i + 1 and a[i] == a[i+1]:
        i += 1
    if n == i + 1:
        break
    if a[i] < a[i+1]:
        while n > i + 1 and a[i] <= a[i+1]:
            i += 1
    else:
        while n > i + 1 and a[i] >= a[i+1]:
            i += 1
    i += 1
print(ans)


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

int main(){
  int i,j,cnt;
  int n;
  cin>>n;
  string s;
  cin>>s;
  cnt=1;
  for(i=0;i<n-1;i++){
    if(s[i]!=s[i+1])cnt++;
  }
  cout<<cnt;
}

Measured memory_bytes: 512
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;

using namespace std;



void solve()
{
    ll n;
    scanf("%lld", &n);
    vector<int> a(n);
    int i;
    int s = 0;
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        s = (s^a[i]);
    }
    for (i = 0; i < n; i++) {
        printf("%d", s^a[i]);
        if (i < n - 1) printf(" ");
        else printf("\n");
    }

    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 3552
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // min, max, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define rep(i,n) rep1(i,0,n)
#define rep1(i,m,n) for(int i=m;i<(n);i++)
#define All(v) (v).begin(),(v).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
const double PI = acos(-1);
int main(){
    ll n, m=1000000000000000;
    cin >> n;
    rep(i, 5) {
        ll a;
        cin >> a;
        m =min(a,m);
    }
    cout << 4 + (n + m - 1) / m << endl;
}

Measured memory_bytes: 256
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=900000+10;

const int mod=1e9+7;
inline int qpow(int a,int b) { int c=1;
    for (;b;b>>=1,a=1ll*a*a%mod) if (b&1) c=1ll*c*a%mod;
    return c;
}

int fac[N],ifac[N],pw[N];
inline void init(int n) {
    fac[0]=1;
    for (re int i=1;i<=n;++i) fac[i]=1ll*fac[i-1]*i%mod;
    ifac[n]=qpow(fac[n],mod-2);
    for (re int i=n;i;--i) ifac[i-1]=1ll*ifac[i]*i%mod;
    for (re int i=pw[0]=1;i<=n;++i) pw[i]=3ll*pw[i-1]%mod;
}

inline int C(int n,int m) {
    return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}

int main() { init(900000);
    int n=read(),m=read(),k=read(); if (m<k) swap(m,k);
    int ans=0,lst=1;
    for (re int i=0;i<=m+k;++i) {
        ans=(ans+1ll*C(n+i-1,n-1)*pw[m+k-i]%mod*lst)%mod;
        if (i<k) lst=2ll*lst%mod;
        else if (i<m) lst=(2ll*lst+mod-C(i,k))%mod;
        else lst=(2ll*lst+mod-C(i,k)+mod-C(i,i-m))%mod;
    }
    printf("%d\n",ans);
    return 0;
}
//qwq

Measured memory_bytes: 10880
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void angshuGod()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int N = 1e5+1;
const double pi = acos(-1);

bool check(string s){
	int n = len(s);

	fo(i,n/2){
		if(s[i] != s[n-1-i])
			return false;
	}
	return true;
}

void solve(){    

    
    string s;
    cin>>s;

    if(check(s)){
    	string x,y;
    	int n = len(s);
    	for(int i = 0;i<(n-1)/2;i++)
    		x += s[i];
    	for(int i = (n+3)/2-1;i<n;i++)
    		y += s[i];
    	if(check(x) && check(y)){
    		cout<<"Yes";
    	}
    	else cout<<"No";
    }
    else cout<<"No";
    
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

int ks[110];

int toIndex(char c){
    if('a' <= c && c <= 'z'){
        return c - 'a';
    }
    return c - 'A' + 26;
}

char toChar(int idx){
    if(0 <= idx && idx < 26){
        return (char)('a' + idx);
    }
    return (char)('A' + (idx - 26));
}

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

    while(true){
        int N;
        std::cin >> N;
        if(!N){break;}

        for(int i=0;i<N;++i){
            std::cin >> ks[i];
        }

        string S;
        std::cin >> S;

        int L = S.size();
        for(int i=0;i<L;++i){
            char d = toChar((toIndex(S[i]) + 52 - ks[i % N]) % 52);
            std::cout << d;
        }

        std::cout << std::endl;
    }
}



Measured memory_bytes: 3156
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int x = sc.nextInt();
		
		ArrayList<Integer> children = new ArrayList<>();
		
		for(int i = 0; i < n; i++) {
			
			children.add(sc.nextInt());
			
		}
		
		children.sort(null);
		
		int count =  0;
		
		for(int i = 0; i < n; i++) {
			
			int child = children.get(i);
			
			if(child < x) {
				if(i == n - 1) {
					break;
				}else {
					x = x - child;
					count++;
				}
			}else if(child == x){
				count++;
				break;
			}else {
				break;
			}
			
			
		}
		
		System.out.println(count);
		
	}

}


Measured memory_bytes: 22612
/* 
 * Project: AtCoder Beginners Contest 162 C - Sum of gcd of Tuples (Easy)
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/04/12
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <iostream>
#include <algorithm>
#include <numeric>
using namespace std;

int k;

void solve() {

    long sum = 0;
    int gcd_ab;

    for (int a=1;a<=k;a++) {
        for (int b=1;b<=k;b++) {
            for (int c=1;c<=k;c++) {
                gcd_ab = gcd(a,b);
                sum += gcd(gcd_ab,c);
            }
        }
    }

        cout << sum << endl;
}

int main() {

    cin >> k;

    solve();

}


Measured memory_bytes: 3192
#include<iostream>
#include<string>
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)

using namespace std;

int main(){
  string str;
  cin >> str;
  cout << str.substr(0, 5) << ' ' << str.substr(6, 7) << ' ' << str.substr(14) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define v(T) vector<T>
#define yn {puts("Yes");}else{puts("No");}
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const double eps = 1e-10;

void foreach_permutation(int n, function<void(int)> f) {
  int indexes[n];
  rep(i, n) {
    indexes[i] = i + 1;
  }
  do
  {
    int num = 0;
    for (int i = 0; i < n; i++) {
      num *= 10;
      num += indexes[i];
    }
    f(num);
  } while (next_permutation(indexes, indexes + n));
}

void solve() {
  int n, p = 0, q = 0;
  cin >> n;

  int l;
  rep(i, n) {
    cin >> l;
    p *= 10;
    p += l;
  }
  rep(i, n) {
    cin >> l;
    q *= 10;
    q += l;
  }

  int a = 0;
  int b = 0;
  int count = 0;
  foreach_permutation(n, [&](int num) {
    count++;
    if (num == p)
    {
      a = count;
    }

    if (num == q)
    {
      b = count;
    }
  });

  cout << abs(a - b) << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed << setprecision(15);
  solve();
  return 0;
}


Measured memory_bytes: 3656
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
using ll = long long;
int main()
{
    int n;
    cin >> n;
    map<string,ll> mp;
    for(int i = 0;i < n;i++)
    {
        string s;
        cin >> s;
        sort(s.begin(),s.end());
        mp[s]++;
    }
    ll ans = 0;
    auto itr = mp.begin();
    while(itr != mp.end())
    {
        ans += itr -> second * ((itr -> second) - 1) / 2;
        itr++;
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 11136
function Main(input){
  var arr = input.split(" ");
  var a = parseInt(arr[0],10);
  var b = parseInt(arr[1],10)
  if(a % b == 0){
    console.log(0);
  }else{
    console.log(1);
  }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int32 N;
	cin >> N;
	vector<int64> A(N), B(N);
	using T = tuple<int64, int64, int64>;
	priority_queue<T> pq[2];
	REP(i, N) cin >> A[i] >> B[i];
	REP(i, N){
		pq[0].push(T(abs(A[i]+B[i]), A[i], i));
		pq[1].push(T(abs(A[i]+B[i]), B[i], i));
	}

	int64 res = 0;
	bool used[112345] = {};
	REP(i, N){
		while(1){
			int64 a, b, c;
			tie(a, b, c) = pq[i%2].top(); pq[i%2].pop();
			if (used[c]) continue;
			used[c] = 1;
			res += b * (i%2 ? -1 : 1);
			break;
		}
	}
	cout << res << endl;
	
}


Measured memory_bytes: 8744
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;}
const long long mod = 1000000007;
typedef long long ll;

int n;
string s,t;
int a[100005],L[100005],R[100005];

int main() {
  cin >> n;
  rep(i,n) cin >> a[i];
  rep(i,n) L[i+1]=__gcd(L[i],a[i]);
  for(int i=n-1;i>=0;i--) R[i]=__gcd(R[i+1],a[i]);
  int ans=0;
  rep(i,n) chmax(ans,__gcd(L[i],R[i+1]));
  cout << ans << endl;
}

Measured memory_bytes: 1408
def main():
    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
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    a,b = map(int, input().split())
    if a>b:
        print(a*2-1)
    elif a<b:
        print(b*2-1)
    else:
        print(a*2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <map>
#include <iomanip>

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

using namespace std;
using lli = long long int;
using ll = long long;

lli calc(lli H) {
    if (H == 1) {
        return 1;
    }
    return 2 * calc(H / 2) + 1;
}

int main() {
    lli H;
    cin >> H;
    cout << calc(H) << endl;
}




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

int main(){
    string S;
    cin>>S;
    rep(i,0,S.size()){
        if(i%2==0){
            if(S[i]!='R'&&S[i]!='U'&&S[i]!='D') {
                cout<<"No"<<endl;
                return 0;
            }
        }
        if(i%2!=0){
            if(S[i]!='L'&&S[i]!='U'&&S[i]!='D'){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BCutAndCount solver = new BCutAndCount();
        solver.solve(1, in, out);
        out.close();
    }

    static class BCutAndCount {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            String s = in.next();
            int max = 0;
            for (int i = 0; i < s.length(); i++) {
                String a = s.substring(0, i);
                String b = s.substring(i, s.length());
                int count = 0;
                boolean[] used = new boolean[26];
                outer:
                for (char c : a.toCharArray()) {
                    if (used[c - 97]) {
                        continue outer;
                    }
                    for (char d : b.toCharArray()) {
                        if (c == d) {
                            count++;
                            used[c - 97] = true;
                            continue outer;
                        }
                    }
                }
                if (count > max) {
                    max = count;
                }
            }
            System.out.println(max);
        }

    }
}



Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <tuple>
#include <iterator>
using namespace std;
using ll = long long;
const int INF = 1000001;

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &e : a)
    cin >> e;
  int nmax = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      nmax = max(abs(a[i] - a[j]), nmax);
  cout << nmax << endl;
  return 0;
}


Measured memory_bytes: 256
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cmath>
#include <ios>
#include <iomanip>

using namespace std;

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

    switch (s)
    {
        case 'A':
            cout <<'T'<<endl;
            break;
        case 'T':
            cout <<'A'<<endl;
            break;
        case 'G':
            cout <<'C'<<endl;
            break;
        case 'C':
            cout <<'G'<<endl;
            break;
    
        default:
            break;
    }
    
    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
 
 
#define mod(cans) cans%10**9+7
#define debug(x) cout << "Debug" << x << "\n"
#define rep(i,n) for(unsigned i=0;i<n;i++)
#define repr(i,n) for(unsigned i=n-1;i>=0;i--)
#define rep1(i,n) for(unsigned i=1;i<=n;i++)
#define cin_pl(n,x) rep(i,n){cin>>x[i];}
#define cins(s,n) rep(i,n)cin>>s.at[i];
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define prians(Answer) cout<<Answer<<"\n"
#define TF(X) X==1?cout<<"Yes\n":cout<<"No\n"
#define elcon else{continue;}
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vector<int> > matrix;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef greater<int> gi;
typedef vector<unsigned> vu;


ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
bool is_prime(const unsigned n){
    switch(n){
        case 0:
        case 1: return false;
        case 2: return true;
    }
 
 
    for(unsigned i=2;i<n;++i){
        if(n%i == 0) return false;
    }
 
    return true;
}
int Digits(unsigned x)
{
    int ans=0;
    while(x!=0)
    {
        x/=10;
        ans++;
    }
    return ans;
}
unsigned GetDigit(unsigned num){
    return to_string(num).length();
}


int main()
{
    int n,m;
    cin>>n>>m;
    vpi p,q;
    rep(i,n)
    {
        int a,b;cin>>a>>b;p.push_back(make_pair(a,b));
    }
    rep(i,m)
    {
        int a,b;cin>>a>>b;q.push_back(make_pair(a,b));
    }
    rep(i,n)
    {
        int distance=INT_MAX,num,tmp;
        rep(j,m)
        {
            tmp=min(distance,abs(p[i].first-q[j].first)+abs(p[i].second-q[j].second));
            if(distance>tmp)
            {
                num=j+1;
                distance=tmp;
            }
            if(distance==0)break;
        }
        cout<<num<<"\n";
    }
}

Measured memory_bytes: 256
from operator import itemgetter

N, M, Q = map(int, input().split())

que = []

for _ in range(M):
    l, r = list(map(int, input().split()))
    que.append((-1, l, r))
for i in range(Q):
    l, r = list(map(int, input().split()))
    que.append((i, l, r))

ans = [0 for _ in range(Q)]
que = sorted(que, key=itemgetter(2, 0))
before = -1
ans_data = [0 for _ in range(N)]
for i, l, r in que:
    if i == -1:
        ans_data[l-1] += 1
    else:
        ans[i] = sum(ans_data[l-1:r])

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


Measured memory_bytes: 127448
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solveA();
    }

    private void solveA() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        int a = (A * N);

        if(a>B){
        	System.out.println(B);
        }else if(a == B){
        	System.out.println(a);
        }else{
        	System.out.println(a);
        }

    }

    private void solveB() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveC() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveD() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveE() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

    private void solveF() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N);
    }

}

Measured memory_bytes: 21716