akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n;cin>>n;
    string s;cin>>s;
    bool f=0;
    bool b=(s[0]=='o');
    vector<int>w(n+1,0);
    if(!f){
        w[0]=1;w[1]=1;
        REP(i,1,n){
            if(s[i]=='o'){
                if(w[i]==1)w[i+1]=w[i-1];
                else w[i+1]=-w[i-1];
            }else{
                if(w[i]==1)w[i+1]=-w[i-1];
                else w[i+1]=w[i-1];
            }
        }
        if(w[n]!=w[0]);
        else{
            if(b){
                if(w[1]==w[n-1])f=1;
            }else{
                if(w[1]!=w[n-1])f=1;
            }
        }
    }
    if(!f){
        rep(i,n+1)w[i]=0;
        w[0]=1;w[1]=-1;
        REP(i,1,n){
            if(s[i]=='o'){
                if(w[i]==1)w[i+1]=w[i-1];
                else w[i+1]=-w[i-1];
            }else{
                if(w[i]==1)w[i+1]=-w[i-1];
                else w[i+1]=w[i-1];
            }
        }
        if(w[n]!=w[0]);
        else{
            if(b){
                if(w[1]==w[n-1])f=1;
            }else{
                if(w[1]!=w[n-1])f=1;
            }
        }
    }
    if(!f){
        rep(i,n+1)w[i]=0;
        w[0]=-1;w[1]=1;
        REP(i,1,n){
            if(s[i]=='o'){
                if(w[i]==1)w[i+1]=w[i-1];
                else w[i+1]=-w[i-1];
            }else{
                if(w[i]==1)w[i+1]=-w[i-1];
                else w[i+1]=w[i-1];
            }
        }
        if(w[n]!=w[0]);
        else{
            if(b){
                if(w[1]!=w[n-1])f=1;
            }else{
                if(w[1]==w[n-1])f=1;
            }
        }
    }
    if(!f){
        rep(i,n+1)w[i]=0;
        w[0]=-1;w[1]=-1;
        REP(i,1,n){
            if(s[i]=='o'){
                if(w[i]==1)w[i+1]=w[i-1];
                else w[i+1]=-w[i-1];
            }else{
                if(w[i]==1)w[i+1]=-w[i-1];
                else w[i+1]=w[i-1];
            }
        }
        if(w[n]!=w[0]);
        else{
            if(b){
                if(w[1]!=w[n-1])f=1;
            }else{
                if(w[1]==w[n-1])f=1;
            }
        }
    }
    if(f){
        rep(i,n){
            if(w[i]==1)cout<<'S';
            if(w[i]==-1)cout<<'W';
        }
        cout<<endl;
    }else{
        cout<<-1<<endl;;
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#include <iostream>
#include <set>
 
int main(void){
  int n,m;cin >> n >> m;
  vector<int> RoadSum(n,0);
  for(int i=0;i<m;i++){
    int a,b;cin >> a >> b;
    RoadSum[a-1]++;
    RoadSum[b-1]++;
  }
  for(int i=0;i<n;i++){
    cout << RoadSum[i] << endl;
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

void Main() {
  Cin(int, n);

  // 4x + 7y = n
  int ok = 0;
  for (int x = 0; 4 * x <= n; ++x) {
    int y = n - 4 * x;
    y /= 7;
    ok += (4 * x + 7 * y == n);
  }

  puts(ok ? "Yes" : "No");
  return;
}

int main() {
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
k=int(input())
l=[1,2,3,4,5,6,7,8,9]
n=1 #桁数
s=0; e=8 #start&end
p=9
q=9
if k<10:
    print(l[k-1])
else:
    while k>p:
        for m in range(s,e+1):
            I=str(l[m])[n-1] #lの要素の一の位の数
            if I=="0":
                l.append(str(l[m])+"0")
                p+=1
                l.append(str(l[m])+"1")
                p+=1
            elif I != "9":
                l.append(str(l[m])+str(int(I)-1))
                p+=1
                l.append(str(l[m])+str(int(I)))
                p+=1
                l.append(str(l[m])+str(int(I)+1))
                p+=1
            else:
                l.append(str(l[m])+"8")
                p+=1
                l.append(str(l[m])+"9")
                p+=1
        q=p-q
        s=e+1
        e=s+q-1
        q=p
        n+=1

    print(l[k-1])

Measured memory_bytes: 65200
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let (N, X) = (input[0], input[1])
let L = readLine()!.characters.split(" ").map{Int(String($0))!}
var D = 0
print(L.reduce(1){D+=$1;return $0+(D>X ?0:1)})

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

int main(){
    string s;
    cin>>s;
    bool ok=0;
    for(int i=0;i<s.size()-1;i++)for(int j=i+1;j<s.size();j++)if(s[i]=='C'&&s[j]=='F')ok=1;
    cout<<(ok?"Yes":"No")<<endl;
    return 0;
}


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

void swap(int& a, int& b) {
	int tmp = a;
	a = b;
	b = tmp;
}

int main() {
	int a, b, c;

	cin >> a >> b >> c;
	if (a > b) swap(a, b);
	if (b > c) swap(b, c);
	if (a > b) swap(a, b);
	cout << a << " " << b << " " << c << endl;
	return 0;
}

Measured memory_bytes: 3072
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 2147483647;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 2000005;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[SIZE], finv[SIZE], inv[SIZE];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

double len(int a, int b, int c, int d) {
	return (double)sqrt((a - c) * (a - c) + (b - d) * (b - d));
}

ll n,a,b;
int main() {
    ll n;
	cin >> n;
	if(n/100*5>=n%100){ cout << 1 << endl; return 0; } 
	cout << 0 << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        
		int N =sc.nextInt();
		
		String s =sc.next();
		String[] split = new String[N];
		int countR=0;
	
        
        String[] spt = s.split("");
        
        for(int i=0;i<N;i++){
            if(spt[i].equals("R")){
                countR++;
            }
        }
        if((N/2)<countR){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        
        
        
        
    }
}



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

int n, c, s, f;
std::vector<int> C, S, F;

int current_time;

int main() {
    std::cin >> n;
    for (int i = 0; i < n-1; i++) {
        std::cin >> c >> s >> f;
        C.push_back(c);
        S.push_back(s);
        F.push_back(f);
    }
    for (int j = 0; j < n-1; j++) {
        current_time = 0;
        for (int p = j; p < n-1; p++) {
            if (current_time <= S[p]) {
                current_time = S[p] + C[p];
            }
            else if ((current_time - S[p]) % F[p] == 0) {
                current_time += C[p];
            }
            else {
                int m = F[p] - ((current_time - S[p]) % F[p]);
                current_time += (m + C[p]);
            }
        }
        std::cout << current_time << std::endl;
    }
    std::cout << 0 << std::endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#define N 110
int main()
{
	int GMatrices[N][N]={0};
	int n,u,k,v;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d %d",&u,&k);
		for(int j=1;j<=k;j++)
		{
			scanf("%d",&v);
			GMatrices[u][v]=1;
		}
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(j!=n)
				printf("%d ",GMatrices[i][j]);
			else
				printf("%d\n",GMatrices[i][j]);
	return 0;
}


Measured memory_bytes: 2056
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define opr iterator
typedef long long ll;
using namespace std;
int n;
int per[200001];
bool ok[200001];
void get(int standard)
{
	for(int i=1;i<=2*n-1;i++)
	{
		ok[i]=(per[i]>=standard);
//		cout<<ok[i]<<"   ";
	}
	return;
}
bool check()
{
	int i,j;
	for(i=n,j=n;i>1&&j<2*n-1;i--,j++)
	{
		if(ok[i]==ok[i-1])
		{
		 	return ok[i];
		}
		else if(ok[j]==ok[j+1])
		{
			return ok[j];
		}
	}
	return ok[1];
}
int main()
{
	cin>>n;
	for(int i=1;i<=2*n-1;i++)
	{
		cin>>per[i];
	}
	int left=1;
	int right=2*n-1;
	int mid;
	while(left<right)
	{
		mid=(left+right+1)/2;
//		cout<<endl<<endl<<left<<"  LLL   RRR   "<<right<<endl<<endl;
//		cout<<"mid "<<mid<<endl; 
		get(mid);/*
		cout<<"mid= "<<mid<<endl;
		cout<<"left=  "<<left<<"      "<<"right=  "<<right<<endl;
		for(int i=1;i<=2*n-1;i++)
		{
			cout<<ok[i]<<" ";
		}
		cout<<endl;
		cout<<check()<<endl;*/
		if(check())
		{
			left=mid;
		}
		else
		{
			right=mid-1;
		}
//		system("pause");
	}
	cout<<right<<endl;
	return 0;
}

Measured memory_bytes: 1280
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#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 ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int n;
    string s, t;
    cin >> n;
    cin >> s >> t;

    string ans {};
    REP(i,n) {
        ans += s[i];
        ans += t[i];
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define forr(x,n) for(int x = 0; x < n; ++x)
#define pr pair<int,int>
#define ll long long int
const int mod=998244353;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    vector<int> a(n,-1);
    int s,c,ans=1;
    forr(i,m)
    {
        cin>>s>>c;
        s--;
        if(a[s]==-1||a[s]==c)
        a[s]=c;
        else
        ans=-1;
    }
    if(ans==-1||(n>1&&a[0]==0))
    cout<<-1;
    else
    forr(i,n)
    {
        if(a[i]==-1)
        {
            if(i==0)
            {
                if(n==1)
                cout<<0;
                else
                cout<<1;
            }
            else
            cout<<0;
        }
        else
        cout<<a[i];
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define Inf 1000000000
#define nmax_def 110000
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

vl pow_;
void pow_ini(ll n) {
	pow_.push_back(n);
	rep(j, 62) {
		ll nxt = pow_[j] * pow_[j];
		nxt %= mod;
		pow_.push_back(nxt);
	}
	return;
}

ll pow1(ll k) {
	ll ans = 1;
	rep(ntmp, 62) {
		if ((k >> ntmp) % 2 == 1) {
			ans *= pow_[ntmp];
			ans %= mod;
		}
	}
	return ans;
}

vl fact;
vl fact_inv;

void fact_ini(ll n) {
	fact.push_back(1);
	fact.push_back(1);
	for (ll i = 2; i <= n; i++) {
		ll fact_tmp = fact[i - 1] * i;
		fact_tmp %= mod;
		fact.push_back(fact_tmp);
	}
	fact_inv.resize(n + 1);
	pow_ini(fact[n]);
	fact_inv[n] = pow1(mod - 2);
	for (ll i = n - 1; i >= 0; i--) {
		fact_inv[i] = fact_inv[i + 1] * (i + 1);
		fact_inv[i] %= mod;
	}
}

ll nCm(ll n, ll m) {
	ll ans = fact[n] * fact_inv[m];
	ans %= mod;
	ans *= fact_inv[n - m];
	ans %= mod;
	return ans;
}

int main() {
	fact_ini(11000000);
	ll r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	if (r2 - r1 < c2 - c1) {
		swap(r1, c1);
		swap(r2, c2);
	}
	ll anstmp = nCm(r1 + c1, r1);
	ll ans = anstmp;
	rep(i, r2 + c2 - r1 - c1) {
		anstmp *= 2LL;
		anstmp %= mod;
		if (i < c2 - c1) {
			anstmp += nCm(r1 + c1 + i, r1 - 1);
			anstmp += nCm(r1 + c1 + i, c1 - 1);
		}
		else if (i < r2 - r1) {
			anstmp -= nCm(r1 + c1 + i, c2);
			anstmp += nCm(r1 + c1 + i, c1 - 1);
			anstmp += mod;
		}
		else {
			anstmp -= nCm(r1 + c1 + i, c2);
			anstmp -= nCm(r1 + c1 + i, r2);
			anstmp += mod;
			anstmp += mod;
		}
		anstmp %= mod;
		ans += anstmp;
		ans %= mod;
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 174168
/// However long the night,
///     The dawn will break
/// ICPC next year

#include<bits/stdc++.h>
using namespace std ;
const int N = 1e5+5 ,mod = 1e9+7 ;

long long a ,b ,ans = 1 ;
int main(){
    cin >> a >> b ;
    if(a>b) swap(a,b) ;
    for(long long i=2;i*i<=a;++i){
        if(a%i) continue ;
        if(b%i==0) ++ans ;
        while(a%i==0) a/= i ;
    }
    if(a>1 && b%a==0) ++ans ;
    cout << ans ;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int,Int> pii;
typedef pair<Int,double> pid;
typedef pair<double,double> pdd;
typedef pair<Int,pii> pip;
typedef pair<double,Int> pdp;
typedef vector<Int> veci;
typedef vector<double> vecd;
typedef vector<int> veci;
typedef vector<double> vecd;
typedef vector<pii> vecpii;
typedef vector<veci> mati;
typedef vector<vecd> matd;
#define A first
#define B second
#define PB(x) push_back(x)
#define EB(x) emplace_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define REP(i,a,b) for(int i = (a);i <= (b);i++)
#define FORO(i,n) REP(i,0,(int)n-1)
#define FORI(i,n) REP(i,1,(int)n)
#define FORIT(i,t) for(auto i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a,_b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
template<typename T>void getMin(T &a,T b) { if(a > b) a = b; }
template<typename T>void getMax(T &a,T b) { if(a < b) a = b; }
template<typename T> vector<T> getVector(const int n) { return vector<T>(n); }
template<typename T> vector<T> getVector(const int n, const T a) { return vector<T>(n, a); }
template<typename T> vector<T> getEmptyVector() { return vector<T>(); }
template<typename T> void appendAll(vector<T> &a, vector<T> b) { a.insert(a.end(), b.begin(), b.end()); }
// #define X first
// #define Y second
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
const ll MOD = 1000000007;
const int MAXN = 1<<17;
const int inf = 1<<28;
const int NIL = -inf;
int popcount(int x)  { return __builtin_popcount(x); }
#define DUMP(a) \
    do { std::cout << #a " = " << (a) << ", "; } while(false)
#define DUMPLN(a) \
    do { std::cout << #a " = " << (a) << std::endl; } while(false)

ll N, K;
mati G;
ll perm[MAXN];

ll modperm(int k) {
    if(k == 0) return 1;
    if(k < 0) return 0;
    if(k == 1) return K - 2;
    if(perm[k]) return perm[k];
    return perm[k] = ((K - 1 - k) * modperm(k - 1)) % MOD;
}

ll solve(int u, int p) {
    ll ret;
    if(u == 0) {
        ret = 1;
        for(int i = 0;i < SZ(G[u]);i++) {
            ret *= K - 1 - i;
            ret %= MOD;
        }
        ret %= MOD;
    } else ret = modperm(SZ(G[u]) - 1);
    
    FORIT(v, G[u]) {
        if(p == *v) continue;
        ret *= solve(*v, u);
        ret %= MOD;
    }
    
    return ret;
}

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

    cin >> N >> K;
    G.resize(N);
    FORO(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].EB(b); G[b].EB(a);
    }

    cout << (K * solve(0, -1)) % MOD << endl;

    return 0;
}


Measured memory_bytes: 13372
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main(void)
{
    int x, h500, h5;
    cin >> x;
    h500 = x / 500;
    h5 = (x % 500) / 5;
    cout << h500 * 1000 + h5 * 5 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int ans = 0;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            while (true) {
                if (a % 2 == 0) {
                    ans++;
                    a /= 2;
                } else {
                    break;
                }
            }
        }
        System.out.println(ans);

        sc.close();
    }

}


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll sx,sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  ll dy = ty-sy;
  ll dx = tx-sx;
  string ans = "";
  ans += "D";
  rep(i, dx+1){
    ans += "R";
  }
  rep(i, dy+1){
    ans += "U";
  }
  ans += "L";
  rep(i, dy){
    ans +="D";
  }
  rep(i, dx){
    ans += "L";
  }
  ans += "L";
  rep(i, dy+1)ans += "U";
  rep(i, dx+1)ans += "R";
  ans += "D";
  rep(i, dx)ans += "L";
  rep(i, dy)ans += "D";
  cout << ans;
  return 0;
}


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

s_len = len(s)

is_yes = False

rotate_s = s
for i in range(s_len):
	if(rotate_s == t):
		is_yes = True
		break
	rotate_s = rotate_s[-1] + rotate_s[:s_len - 1]
if(is_yes):
	print("Yes")
else:
	print("No")

Measured memory_bytes: 61532
#include<iostream>
#include<string>
using namespace std;
int main()
{
   string s;
   string t;
   cin>>s>>t;
   if(s.length()+1 == t.length()){
      t.erase(t.length()-1 ,1);
      if(s==t){
         {cout<<"Yes";return 0;}
      }
   }
   
   cout<<"No";
}


Measured memory_bytes: 3628
// import chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
  std.range, std.container, std.bigint, std.ascii, std.typecons, std.format, std.bitmanip;

// }}}
// nep.scanner {{{
class Scanner {
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType)) {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0) {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }

  void scan()() {
  }

  void scan(T, S...)(ref T x, ref S args) {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType)) {
    str ~= s.to!(char[]).strip.split;
  }
}
// }}}

void main() {
  auto cin = new Scanner;
  string s;
  cin.scan(s);
  foreach (e; s) {
    if (e == '7') {
      writeln("Yes");
      return;
    }
  }

  writeln("No");
}


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

using I = long long;
const I M = 1e9 + 7;

class Combinatorics {
 public:
  Combinatorics(I N) : fact(N + 1, 1), inv(N + 1, 1), finv(N + 1, 1) {
    for(I i = 2; i <= N; ++i) {
      fact[i] = fact[i - 1] * i % M;
      inv[i]  = inv[M % i] * (M - M / i) % M;
      finv[i] = finv[i - 1] * inv[i] % M;
    }
  }
  I factorial(I n) {return fact[n];}
  I permutation(I n, I r) {return fact[n] * finv[n - r] % M;}
  I combination(I n, I r) {return permutation(n, r) * finv[r] % M;}
 private:
  std::vector<I> fact, inv, finv;
};

using Size = int;
using Vertex = int;
using Weight = long long;
struct Edge {Vertex from, to; Weight weight;};
using Graph = vector<vector<Edge>>;

I centroid(const Graph& G) {
  I N = G.size();
  vector<Vertex> C;
  vector<Size> size(N, 1);
  vector<vector<I>> S(N, vector<I>(N));
  function<Size(Vertex, Vertex)> dfs = [&](Vertex cur, Vertex pre) {
    auto ok = true;
    for(auto e: G[cur]) if(e.to != pre) {
      size[cur] += dfs(e.to, e.from);
      if(N / 2 < size[e.to]) ok = false;
    }
    if(N / 2 < N - size[cur]) ok = false;
    if(ok) C.emplace_back(cur);
    if(ok) {
      S[cur][pre] = N - size[cur];
      for(auto e: G[cur]) if(e.to != pre) S[cur][e.to] = size[e.to];
    }
    return size[cur];
  };
  dfs(0, 0);

  Combinatorics X(N);

  if(C.size() == 2) return X.factorial(S[C[0]][C[1]]) * X.factorial(S[C[1]][C[0]]) % M;

  I res = 0;
  vector<I> T; // sizes of each connected component on the graph removing the centroid
  for(auto e: G[C[0]]) T.emplace_back(S[C[0]][e.to]);

  vector<vector<I>> dp(T.size() + 1, vector<I>(N + 1));
  dp[0][0] = 1;
  for(auto i = 0; i < T.size(); ++i) {
    for(I x = 0; x <= T[i]; ++x) {
      for(I k = 0; k + x <= N; ++k) {
        (dp[i + 1][k + x] += (dp[i][k] * X.combination(T[i], x) % M) * X.permutation(T[i], x) % M) %= M;
      }
    }
  }

  I sign = 1;
  for(I k = 0; k <= N; ++k) {
    (res += sign * X.factorial(N - k) * dp[T.size()][k] % M) %= M;
    (res += M) %= M;
    sign *= -1;
  }
  return res;
}

int main() {
  Size N;
  cin >> N;
  Graph G(N);
  for(auto i = 1; i < N; ++i) {
    Vertex x, y;
    cin >> x >> y; --x; --y;
    G[x].push_back({x, y});
    G[y].push_back({y, x});
  }
  cout << centroid(G) << endl;
}


Measured memory_bytes: 391936
#include<bits/stdc++.h>
using namespace std;
int main()

{

    long long int a,b,c,d,i,j,k,l;
    cin>>a>>b>>c;
    int a1[b];
    int cnt=0;
    for(i=0;i<b;i++)
        cin>>a1[i];
    while(a--)
    {
        int a2[b];
        for(i=0;i<b;i++)
            cin>>a2[i];
            int sum=0;
        for(i=0;i<b;i++)
        {

            sum+=a1[i]*a2[i];

        }
        sum+=c;
        if(sum>0)
            cnt++;
    }

cout<<cnt;
}


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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
// constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

int main(){
  ll M;
  cin >> M;
  ll ans = 0;
  ll keta = 0, sum = 0;
  REP(i, M){
    ll d; ll c;
    cin >> d >> c;
    keta += c;
    sum += d * c;
    if(sum <= 9) continue;
    ans += (sum-1) / 9;
    sum %= 9;
    if(sum == 0) sum=9;
  }
  // assert(sum <= 9);
  ans += keta-1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import itertools
n,m=map(int, input().split())
x=[int(i) for i in input().split()]
x.sort()
if(n>=m):
    print(0)
    exit()
dist = abs(x[-1]-x[0])

diff = []

for i in range(m-1):
    diff.append([abs(x[i]-x[i+1]),i])

diff.sort(key = lambda x:x[0],reverse = True)
for i in range(n-1):
    dist-=diff[i][0]
print(dist)


Measured memory_bytes: 25796
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H,W;
    cin >> H >> W;
    if(H == 1 || W == 1){
        print(1);
        return 0;
    }
    if(H % 2 == 0 || W % 2 == 0){
        print(H*W/2);
    }else{
        ll ans = H * (W-1) / 2 + (H+1) / 2;
        print(ans);
    }

}

Measured memory_bytes: 256
N, K = map(int, input().split())
S = input()
cnt =0
for i in range(N-1):
    p = S[i]+S[i+1] 
    if p =='RL':
        cnt += 1
cnt2 = 0
if S[0] == 'L':
    cnt2 += 1
if S[-1] == 'R':
    cnt2 += 1
n =N- cnt *2-cnt2
if cnt - 1 >= K:
    print(n+2*K)
elif cnt + cnt2 - 2 >= K:
    print(N-2)
else:
    print(N-1)
        

Measured memory_bytes: 39408
#include <bits/stdc++.h>
#include <algorithm>
using namespace std; 
  
typedef long long LL; 
typedef pair<int, int> pii; 
typedef pair<LL, LL> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<string> vs;
typedef vector<vi> vvi; 
typedef vector<pii> vii; 
typedef vector<LL> vl; 
typedef vector<vl> vvl; 
  
double EPS = 1e-9; 
int INF = 100005; 
long long int mod=1000000007;
long long TES=1000007;
long long INFF = 1000000000000000005LL; 
double PI = acos(-1); 
int dirx[8] = { -1, 0, 0, 1, -1, -1, 1, 1 }; 
int diry[8] = { 0, 1, -1, 0, -1, 1, -1, 1 }; 
  
#ifdef TESTING 
#define DEBUG fprintf(stderr, "====TESTING====\n") 
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl 
#define debug(...) fprintf(stderr, __VA_ARGS__) 
#else 
#define DEBUG 
#define VALUE(x) 
#define debug(...) 
#endif 
  
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a)) 
#define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a)) 
#define FORD(a, b, c) for (int(a) = (b); (a) >= (c); --(a)) 
#define FORSQ(a, b, c) for (int(a) = (b); (a) * (a) <= (c); ++(a)) 
#define FORC(a, b, c) for (char(a) = (b); (a) <= (c); ++(a)) 
#define FOREACH(a, b) for (auto&(a) : (b)) 
#define rep(i, n) FOR(i, 0, n) 
#define repn(i, n) FORN(i, 1, n) 
#define MAX(a, b) a = max(a, b) 
#define MIN(a, b) a = min(a, b) 
#define SQR(x) ((LL)(x) * (x)) 
#define RESET(a, b) memset(a, b, sizeof(a)) 
#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back 
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define SIZE(v) (int)v.size() 
#define SORT(v) sort(ALL(v)) 
#define REVERSE(v) reverse(ALL(v)) 
#define SORTA(arr, sz) sort(ALLA(arr, sz)) 
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz)) 
#define PERMUTE next_permutation 
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define TC(t) while (t--)


void solve()
{
  int n;
  cin>>n;
  int ac=0,tle=0,wa=0,re=0;
  rep(i,n)
  {
      string str;
      cin>>str;
      if(str=="AC")
      ac++;
      else
      if(str=="TLE")
      tle++;
      else
      if(str=="WA")
      wa++;
      else
      if(str=="RE")
      re++;
  }
  cout<<"AC x "<<ac<<endl;
  cout<<"WA x "<<wa<<endl;
  cout<<"TLE x "<<tle<<endl;
  cout<<"RE x "<<re<<endl;
  
  return;
}
int main()
{
    IOS();
  
    solve();
    return 0;
}





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

using namespace std;

bool solve(vector<string> a) {
    int n = a.size();
    vector<pair<int, int>> qPos, qNeg;
    for (int i = 0; i < n; i++) {
        int mn = 0;
        int tot = 0;
        string s = a[i];
        for (char ch: a[i]) {
            tot += ch == '(' ? 1 : -1;
            mn = min(mn, tot);
        }
        if (tot > 0) {
            qPos.push_back({mn, tot});
        } else {
            mn = 0;
            tot = 0;
            reverse(s.begin(), s.end());
            for (char ch: s) {
                tot += ch == ')' ? 1 : -1;
                mn = min(mn, tot);
            }
            qNeg.push_back({mn, tot});
        }
    }
    bool ok = true;
    auto hdl = [&] (vector<pair<int, int>> &vec) {
        int pref = 0;
        sort(vec.begin(), vec.end());
        reverse(vec.begin(), vec.end());
        for (auto pr: vec) {
            if (pref + pr.first >= 0) {
                pref += pr.second;
            } else {
                ok = false;
            }
        }
        return pref;
    };
    int pos = hdl(qPos);
    int neg = hdl(qNeg);
    return ok && pos == neg;
}

bool naive(vector<string> a) {
    int n = a.size();
    vector<int> perm(n);
    for (int i = 0; i < n; i++) {
        perm[i] = i;
    }
    do {
        string s;
        for (int i: perm) {
            s += a[i];
        }
        bool ok = true;
        int tot = 0;
        for (char ch: s) {
            tot += ch == '(' ? 1 : -1;
            if (tot < 0) {
                ok = false;
            }
        }
        if (ok && tot == 0) {
            return true;
        }
    } while (next_permutation(perm.begin(), perm.end()));
    return false;
}

void test() {
    int n = 5;
    int sz = 5;
    while (true) {
        vector<string> a(n);
        for (int i = 0; i < n; i++) {
            int m = rand() % sz + 1;
            string cur;
            for (int j = 0; j < m; j++) {
                cur += rand()%2 == 0 ? ')' : '(';
            }
            a[i] = cur;
        }
        auto expected = naive(a);
        auto actual = solve(a);
        if (expected != actual) {
            for (auto s: a) {
                cout << s << endl;
            }
            cout << "expected " << expected << endl;
            cout << "actual " << actual << endl;
            return;
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    //test();
    int n;
    cin >> n;
    vector<string> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    auto ok = solve(a);
    cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 73808
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <string>
#define rep(i, n) for (int i = 0; i < n; i++) 

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    int d;
    int cnt = 0;
    int A;
    map<int, bool> mp;
    rep(i, k) {
        cin >> d;
        rep(j, d) {
            cin >> A;
            mp.insert(make_pair(A-1, true)); 
        }
    }
    rep(i, n) {
        if (mp.count(i) == 0) {
            cnt++;
        }
    }
    cout << cnt;
    return 0;
}

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

using namespace std;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int a,b,c,x,y,ans;
cin>>a>>b>>c>>x>>y;
int com=min(x,y);
int price1=min(com*(2*c),com*(a+b));
int price2=min(2*c*(x+y-2*com),a*(x-com)+b*(y-com));

cout<<price1+price2<<endl;

//system("pause");
return 0;
}

Measured memory_bytes: 256
n = int(input())

c =[]
s =[]
f =[]

for i in range(n-1):
    x,y,z = map(int,input().split())
    c.append(x)
    s.append(y)
    f.append(z)

for i in range(n-1):
    t = 0
    for j in range(i,n-1):
        if t <= s[j]:
            w = s[j]-t 
        else:
            w = (f[j] - (t-s[j])%f[j])%f[j]
        t+=w
        t+=c[j]
    print(t)

print(0)


Measured memory_bytes: 3064
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)






int main() {
	int A, B;
	cin >> A >> B ;
	string s = "Odd";
	if ((A*B)%2==0) {
		s = "Even";
	}
	cout <<s<< endl;
}


Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
col = [0 for i in range(n)]
cnt = 0
for i in range(n):
    if 1 <= a[i] <=399:
        col[i] = "b"
    elif 400<= a[i]<=799:
        col[i] = "c"
    elif 800<= a[i]<=1199:
        col[i] = "d"
    elif 1200<= a[i]<=1599:
        col[i] = "e"
    elif 1600<= a[i]<=1999:
        col[i] = "f"
    elif 2000<= a[i]<=2399:
        col[i] = "g"
    elif 2400<= a[i]<=2799:
        col[i] = "h"
    elif 2800<= a[i]<=3199:
        col[i] = "j"
    else:
        col[i] = "k"
        cnt += 1
colv = list(set(col))
mn =mx = len(colv)
if "k" in colv:
        mn -=1
        mx += cnt-1
        if mn == 0:
            mn =1
        
print(str(mn)+" "+str(mx))

Measured memory_bytes: 3064
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n;
  int mx=0;
  cin >> n;
  string s;
  map<string,int>m;
  
  rep(i,n){
    cin >> s;
    m[s]++;
    if(m[s]>mx){
      mx = m[s];
    }
  }
  for(auto p:m){
    if(p.second == mx){
      cout << p.first << endl;
    }
  }
}

Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define mp make_pair
 
typedef long long ll;
typedef unsigned long long int ull;
typedef long double ld;
 
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef pair<string, string> ss;
typedef pair<int, ss> iss;
 
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<ld> vld;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pair<int, pii>> vpiii;
 
typedef map<string, string> mss;
typedef map<string, int> msi;
typedef map<int, int> mii;
typedef map<int, bool> mib;
typedef map<int, ll> mill;
typedef map<int, vpii> mivpii;

const int MAXN = 1e5;
const int MOD = 1e9 + 7;
const int COLORS = 2;
const int B = 0;
const int W = 1;

ll dp[MAXN + 1][COLORS];
vi g[MAXN + 1];

void fast_io() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

void add(ll &a, ll b) {
	a += b;
	if(a >= MOD) a-= MOD;
}

void dfs(int u, int p) {
	dp[u][B] = dp[u][W] = 1;
	for(int v : g[u]) {
		if(v != p) {
			dfs(v, u);
			dp[u][B] *= dp[v][W];
			dp[u][B] %= MOD;
			dp[u][W] *= dp[v][W] + dp[v][B];
			dp[u][W] %= MOD;
		}
	}
}

int main() {
	fast_io();
//	freopen("input/DP_P.txt", "r", stdin);
	
	int n, u, v;
	cin >> n;
	for(int i = 1; i < n; i++) {
		cin >> u >> v;
		g[u].pb(v);
		g[v].pb(u);
	}
	dfs(1, 1);

	ll ans = dp[1][B] + dp[1][W];
	if(ans >= MOD) ans -= MOD;
	cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 14208
n=int(input())
xy=[list(map(int,input().split())) for _ in range(n)]
if n==1:
    print(1)
    exit()
pq={}
for i in range(n):
    x,y=xy[i]
    for j in range(n):
        if j==i:continue
        xx,yy=xy[j]
        p=xx-x
        q=yy-y
        pq.setdefault((p,q),0)
        pq[(p,q)]+=1
print(n-max(pq.values()))


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 3e5+5;
const ll mod = 1e9 + 7;
const ll INF = 1e9 + 7;

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

	int t=-1,s=0;

	for (int q=0;q<n;q++)
	{
		int x;
		cin>>x;
		t=max(t,x);
		s+=x;
	}

	s-=t;
	if (s>t)
	{
		printf("Yes\n");
	}
	else printf("No\n");

	

	return 0;
}

Measured memory_bytes: 256
n = int(input())
honest = []
unkind = []
for _ in range(n):
    a = int(input())
    ho = []
    un = []
    for _ in range(a):
        x, y = map(int, input().split())
        if y == 1:
            ho.append(x-1)
        else:
            un.append(x-1)
    honest.append(ho)
    unkind.append(un)

# 全探索
ans = []
for i in range(2 ** n):
    person = []
    for j in range(n):
        person.append(i % 2)
        i //= 2

    flag = False

    # honestを判定
    for j in range(n):
        if person[j] == 1:
            for k in honest[j]:
                if person[k] == 0:
                    flag = True
                    break
            if flag:
                break
    if flag:
        continue
    
    # unkindを判定
    for j in range(n):
        if person[j] == 1:
            for k in unkind[j]:
                if person[k] == 1:
                    flag = True
                    break
            if flag:
                break
    if flag:
        continue

    ans.append(sum(person))
print(max(ans))

Measured memory_bytes: 3480
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 1000000000000000005
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
char in[100005];
stack<int> s;
int main(){
	while(~scanf("%s",in)){
		int l=strlen(in),ans1=0,ans2=0;
		F(i,0,l){
			if(in[i]=='0') ans1++;
			else ans2++;
		}
		printf("%d\n",min(ans1,ans2)*2);
	}
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

int find_substring(char str[], char sub[]){
    char *p1, *p2, *p3;
    int i,j;
    int flag = 0;

    p1 = str; p2 = sub;

    for(i=0; i<strlen(str); i++){
        if(flag == 1) break;
        if(*p1 == *p2){
            p3 = p1;
            for(j=0; j<strlen(sub); j++){
                if(*p3 == *p2){
                    p3++;
                    p2++;
                }
                else
                    break;
            }
            p2 = sub;/*Important!!*/
            if(j == strlen(sub))
                flag = 1;
        }
        p1++;
    }
    return flag;
}

int main(){
    
    char str[201];
    char s[301];
    char sub[201];
    int i, j;

    /*get input*/
    fgets(str, sizeof(str), stdin);
    fgets(sub, sizeof(sub), stdin);
    /*replace '\n' of input to '\0'*/
    str[strlen(str)-1] = '\0';
    sub[strlen(sub)-1] = '\0';
    /*copy the first line twice to s*/    
    strcpy(s, str);
    strcat(s, str);
    //printf("%s\n", s);

    if(find_substring(s, sub) == 1)
        printf("Yes\n");
    else
        printf("No\n");
}



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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  string s;
  cin>>s;
  int a[100005];
  int d=s.length();
  for(int i=0;i<s.length();i++){
    a[i]=(int)s[i];
  }
  sort(a,a+d);
  int f=1;
  if(a[0]==97){
  for(int i=0;i<d-1;i++){
    if(a[i]+1<a[i+1]){
      cout<<(char)(a[i]+1);
      f=0;
      return 0;

    }
  }
}else {
   cout<<'a';
   return 0;
}
if(f && a[d-1]!=122){
    cout<<'z';
}else{
  cout<<"None";
}


}



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

int main()
{
    int h,w,n;
    std::cin>>h>>w>>n;
    std::queue<int> q;
    std::vector<std::vector<int>> ans(h,std::vector<int>(w));
    for(int i=0;i<n;i++){
        int tmp;
        std::cin>>tmp;
        for(int j=0;j<tmp;j++){
            q.push(i);
        }
    }

    for(int i=0;i<h;i++){
        if(i%2==0){
            for(int j=0;j<w;j++){
                ans[i][j] = q.front();
                q.pop();
            }
        }else{
            for(int j=w-1;j>=0;j--){
                ans[i][j] = q.front();
                q.pop();
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(j!=w-1)std::cout<<ans[i][j]+1<<" ";
            else std::cout<<ans[i][j]+1<<std::endl;
        }
    }
    return 0;
}

Measured memory_bytes: 384
import numpy as np


def main():
    S = np.array(list(input()))
    LS = len(S)
    T = np.array(list(input()))
    LT = len(T)
    # LCS
    dp = np.zeros((LS + 1, LT + 1))
    match = S.reshape(-1, 1) == T.reshape(1, -1)
    for s in range(LS):
        dp[s + 1, 1:] = np.fmax(dp[s, :(-1)] + match[s], dp[s, 1:])
        dp[s + 1] = np.maximum.accumulate(dp[s + 1])
    # recover
    s, t = LS, LT
    ans = ''
    while s > 0 and t > 0:
        if dp[s, t] == dp[s - 1, t]:
            s -= 1
        elif dp[s, t] == dp[s, t - 1]:
            t -= 1
        else:
            ans = S[s - 1] + ans
            s -= 1
            t -= 1
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 91588
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int A  = sc.nextInt();
		int B  = sc.nextInt();
		int Q  = sc.nextInt();

		Long[] AA = new Long[A+2];
		Long[] BB = new Long[B+2];
		Long[] QQ = new Long[Q+2];

		for(int i = 1 ; i <= A ; i++){
			AA[i] = sc.nextLong();
		}
		for(int i = 1 ; i <= B ; i++){
			BB[i] = sc.nextLong();
		}
		for(int i = 1 ; i <= Q ; i++){
			QQ[i] = sc.nextLong();
		}

		AA[A+1] = 100000000001L;
		BB[B+1] = 100000000001L;

		AA[0] = (long) -1l;
		BB[0] = (long) -1l;
		sc.close();

		int s1 = 0;
		int t1 = 0;



		for(int i = 1 ; i <= Q ; i++){
			int L = 0;
			int R = A+1;
			while(L<R){
				int M = (L+R)/2;
				if(AA[M]<QQ[i] && AA[M+1]>QQ[i]){
					s1 = M;
					break;
				}
				else if(AA[M+1] < QQ[i]){
					L = M+1;
				}
				else if(AA[M] > QQ[i]){
					R = M;
				}
			}

			int L1 = 0;
			int R1 = B+1;
			while(L1<R1){
				int M = (L1+R1)/2;

				if(BB[M]<QQ[i] && BB[M+1]>QQ[i]){
					t1 = M;
					break;
				}
				else if(BB[M+1] < QQ[i]){
					L1 = M+1;
				}
				else if(BB[M] > QQ[i]){
					R1 = M;
				}
			}
			//System.out.println(i + " " + AA[s1] + " " + AA[s1+1] + " " + BB[t1] + " " + BB[t1+1]);
			long[] SS = {AA[s1],AA[s1+1]};
			long[] TT = {BB[t1],BB[t1+1]};
			long ans = 90000000001l;
				for(int ii = 0 ; ii < 2 ; ii++){
					for(int jj = 0 ; jj < 2 ; jj++){
						//System.out.println(QQ[i] + " " + SS[ii] + " " + TT[jj]);
						if(SS[ii] > 0 && TT[jj] > 0 && SS[ii] <  100000000001L && TT[jj]<  100000000001L){
							ans = Math.min(ans, Math.abs(QQ[i]-SS[ii])+Math.abs(SS[ii]-TT[jj]));
							ans = Math.min(ans, Math.abs(QQ[i]-TT[jj])+Math.abs(TT[jj]-SS[ii]));
							//System.out.println(ans);
						}
					}
				}
				System.out.println(+ans);
		}

	}
}

Measured memory_bytes: 117636
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define y second

using namespace std;

typedef long long ll;

int a[200005], summa[200005];

int main()
{
 	//freopen("input.txt", "r", stdin);
 	//freopen("output.txt", "w", stdout);
 	ios_base::sync_with_stdio(0); cin.tie(0);
 	int n, k;
 	cin >> n >> k;
 	for (int i = 1; i <= n; i++) cin >> a[i];

 	while (k > 0)
 	{
     	k--;
     	bool fl = false;
     	for (int i = 1; i <= n; i++) if (a[i] != n) fl = true;
     	if (!fl) break;

     	for (int i = 0; i <= n + 1; i++) summa[i] = 0;
     	for (int i = 1; i <= n; i++)
     	{
     	 	int lef = max(i - a[i], 0), rig = min(n, i + a[i]);
     	 	summa[lef]++, summa[rig + 1]--; 
     	}
     	for (int i = 1; i <= n; i++) summa[i] += summa[i - 1];
     	for (int i = 1; i <= n; i++) a[i] = summa[i];
    }
    for (int i = 1; i <= n; i++) cout << a[i] << ' ';
    cout << '\n';
 	return 0;
}

Measured memory_bytes: 5192
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main() {
  int n;
  cin>>n;
  vector<ll> a(n);
  ll sum=0;
  rep(i,n){
    cin>>a[i];
    sum+=a[i];
  }
  ll ans=1000000000000;
  ll cnt=0;
  rep(i,n){
    cnt+=a[i];
    ans=min(ans,abs(cnt-(sum-cnt)));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4856
#include <iostream>

using namespace std;

int fi(int f[], int x) {
    return f[x] == x ? x : (f[x] = fi(f, f[x]));
}

int main() {
    int n, m;
    cin >> n >> m;
    int a[m], b[m];
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
    }

    int f[n], c[n];
    for (int i = 0; i < n; i++) {
        f[i] = i;
        c[i] = 1;
    }

    long long p = 1ll * n * (n - 1) / 2;
    long long ans[m];
    for (int i = m - 1; i >= 0; i--) {
        ans[i] = p;
        int fa = fi(f, a[i]), fb = fi(f, b[i]);
        if (fa != fb) {
            p -= 1ll * c[fa] * c[fb];
            c[fa] += c[fb];
            f[fb] = fa;
        }
    }

    for (int i = 0; i < m; i++) {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3712
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <bitset>
#include <set>
#include <iomanip>
#include <functional>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'a' = 97

int main()
{
    int n, x;
    cin >> n >> x;
    int a[n];
    rep(i, 0, n) cin >> a[i];

    ll ans = 0;
    if (x < a[0]) {
        ans += a[0] - x;
        a[0] = x;
    }
    rep(i, 1, n) {
        if (x < a[i - 1] + a[i]) {
            ans += a[i - 1] + a[i] - x;
            a[i] = a[i] - (a[i - 1] + a[i] - x);
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 640