akhauriyash/Code-Regression huggingface dataset:
// 射影　正射影ベクトル
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

#include<queue>

using namespace std;

// 浮動小数点のゼロ判定
#define EPS (1e-10)
#define equals(a, b) ( fabs((a) - (b)) < EPS )

// 点を表すクラス
class Point
{
    public:
        double x, y;
        // コンストラクタ
        Point(double x = 0.0, double y = 0.0) : x(x), y(y){ }

        // -----▼▼▼ 演算子のオーバーロード ▼▼▼-----

        Point operator + (Point &p)
        {
            return Point(x + p.x, y + p.y);
        }

        Point operator - (Point &p)
        {
            return Point(x - p.x, y - p.y);
        }

        Point operator * (double a)
        {
            return Point(a * x, a * y);
        }

        Point operator / (double a)
        {
            return Point(x / a, y / a);
        }

        bool operator < ( const Point &p) const
        {
            return x != p.x ? x < p.x : y < p.y;
        }

        bool operator == ( const Point &p) const
        {
            return fabs(x - p.x) < EPS && fabs(y -p.y) < EPS;
        }

        // -----▲▲▲ 演算子のオーバーロード ▲▲▲-----

        // 2点間の距離
        double distance()
        {
            return sqrt( norm() );
        }

        double norm()
        {
            return ( x * x ) + ( y * y );
        }
};

// 線分を表すクラス
class Segment
{
    public:
        Point p1, p2;
        // コンストラクタ
        Segment(Point p1, Point p2) : p1(p1), p2(p2){ }
};

// 点とベクトルの表現は同じ
typedef Point Vector;
// 線分と直線の表現は同じ
typedef Segment Line;

double dot(Vector a, Vector b);
double cross(Vector a, Vector b);

int main(void)
{
    int q;
    Vector p1, p2, p;
    Vector vertical, base, OH;

    // ベクトル要素の格納
    cin >> p1.x >> p1.y >> p2.x >> p2.y;

    cin >> q;

    for(int i = 0; i < q; i++)
    {

        // ベクトル要素の格納
        cin >> p.x >> p.y;

        base = p2 - p1;
        vertical = p - p1;

        // 正射影ベクトルの考え方より
        // OHベクトル = ( ( a, bベクトルの内積 ) / aベクトルの大きさの2乗 ) * aベクトル
        OH = ( base * ( dot(base, vertical) / pow( base.distance(), 2.0 ) ) ) + p1;

         printf("%.10lf %.10lf\n", OH.x, OH.y);
    }

    return 0;
}

// 内積の計算をする関数
double dot(Vector a, Vector b)
{
    return ( ( a.x * b.x ) + ( a.y * b.y ) );
}

// 外積の計算をする関数
double cross(Vector a, Vector b)
{
    return ( ( a.x * b.y ) - ( a.y * b.x ) );
}



Measured memory_bytes: 3300
import sys
n = int(input())
sys.setrecursionlimit(2*n)
graph = [[] for _ in range(n)]
for _ in range(n-1):
    u, v, w = map(int, input().split())
    graph[u-1].append((v-1, w))
    graph[v-1].append((u-1, w))
colors = [None]*n
colors[0] = 0
def DFS(node):
    for c_node, l in graph[node]:
        if colors[c_node] is not None:
            continue
        colors[c_node] = (l+colors[node])%2
        DFS(c_node)
DFS(0)
for i in colors:
    print(i)

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

#define pq priority_queue
#define mp make_pair
#define cauto const auto &

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define clr(ar, val) memset(ar, val, sizeof(ar))

typedef long long int64;
typedef long long lint;
typedef long long lli;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;

typedef pair<int, int> pint;
typedef pair<long, long> plong;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

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 <class T = int> T in() {
  T x;
  cin >> x;
  return (x);
}
template <class T> void print(T &x) {
  cout << x << '\n';
  return;
}

template <class T> ll sized_subset(T &comb) {
  T x = comb & -comb, y = x + comb;
  return ((comb & ~y) / x) >> 1 | y;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  int dont_have[n];
  for (int i = 0; i < n; i++) {
    dont_have[i] = 1;
  }
  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int who;
      cin >> who;
      dont_have[who-1] = 0;
    }
  }
  int res = 0;
  for (int i = 0; i < n; i++) {
    res += dont_have[i];
  }
  cout << res << endl;
  return 0;
}


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

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

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int n;
map<int, int> mm;

int main() {
	cin >> n;
	ll mx1 = 0;
	ll mx2 = 0;
	for (int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		if (mm[x]) {
			mm[x] = 0;
			if (x > mx2)
				mx2 = x;
			if (mx2 > mx1)
				swap(mx2, mx1);
		}
		else {
			mm[x] = 1;
		}
	}
	cout << mx2 * mx1 << "\n";
	return 0;
}




Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(i,e) for(ll i=0;i<e;i++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;
ll i;



int main(){
    ll ans=0;
    string S;
    cin>>S;
    rep(i,4){
        if(S.at(i)=='+')ans++;
        else ans--;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  ll t=1;
  while(t--)
  {
    int n;
    cin>>n;
    int a[n];
    int sum=0;
    REP(i,n)
    {cin>>a[i];sum+=a[i];}
    sort(a,a+n);
    if(sum%10 != 0)
    cout<<sum;
    else
    {
        int j=0;
        while(j<n)
        {
            if((sum - a[j])%10 !=0)
            {
                cout<<sum-a[j];
                return 0;
            }
            j++;
        }
        cout<<0;
    }
    
  }  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
	while (true) {
		int referee;
		std::cin >> referee;
		if (referee == 0) {
			break;
		}

		int max, min;
		std::cin >> max >> min;
		if (max < min) {
			std::swap(min, max);
		}
		int total = 0;
		for (int i = 2; i < referee; ++i) {
			int score;
			std::cin >> score;
			if (max < score) {
				total += max;
				max = score;
			} else if (min > score) {
				total += min;
				min = score;
			} else {
				total += score;
			}
		}
		std::cout << (total / (referee - 2)) << std::endl;
	}
}

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

zisho = "abcdefghijklmnopqrstuvwxyz"

s_list = []
t_list = []

for i in range(len(s)):
  s_list.append(zisho.index(s[i])+1)
s_list.sort()
for i in range(len(t)):
  t_list.append(zisho.index(t[i])+1)
t_list.sort(reverse = True)

if len(s) > len(t):
  for i in range(len(s)-len(t)):
    t_list.append(0)
if len(t) > len(s):
  for i in range(len(t)-len(s)):
    s_list.append(0)

s_int = 0
t_int = 0

dif = 0

length = len(s_list)

#print(s_list)
#print(t_list)

for i in range(length):
#  s_int = s_int + 100 ** (len(s)-i-1) * s_list[i]
#  t_int = t_int + 100 ** (len(s)-i-1) * t_list[i]
  dif = dif + 100 ** (length-i-1) * t_list[i] - 100 ** (length-i-1) * s_list[i]

#if s_int < t_int: print('Yes')
#else: print('No')
#print(dif)
if dif > 0: print('Yes')
else: print('No')


Measured memory_bytes: 3064
import java.util.*;

 
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
      	int K = sc.nextInt();
		int M = sc.nextInt();
		int[] p = new int[M];
        int[] mas = new int[M-1];
		for (int i=0;i<M;i++){
			p[i]=sc.nextInt();
		}
		Arrays.sort(p);
      
      for(int i =0;i<M-1;i++){
        mas[i]=Math.abs(p[i+1]-p[i]);
      }
      Arrays.sort(mas);
      
      int nam = M-K;
      int ans = 0;
      if(M-K>0){
      for(int i=0;i<nam;i++){
        ans = ans+mas[i];
      }
		System.out.print(ans);
      }else{
        System.out.print(ans);
      }
	}
}

Measured memory_bytes: 60336
A = [[]]*3
for T in range(0,3):
    A[T] = [int(x) for x in input().split()]
A   = sum(A,[])
ATF = [False]*9
 
N = int(input())
for TT in range(0,N):
    B = int(input())
    if B in A:
        ATF[A.index(B)] = True

Flag = False
if   (all(ATF[:3])) or (all(ATF[3:6])) or (all(ATF[6:])):
    Flag = True
elif (all(ATF[::3])) or (all(ATF[1::3])) or (all(ATF[2::3])):
    Flag = True
elif (all(ATF[::4])) or (all(ATF[2:7:2])):
    Flag = True
    
if Flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    char c; cin >> c;
    set<char> data = {'a','i','u','e','o'};
    if (data.find(c) != data.end()) cout << "vowel" << endl;
    else cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
int main(){
	int n;
	while(std::cin >> n, n){
		std::vector<int> v;
		for(int i=0;i<n;i++){
			int a;
			std::cin >> a;
			v.push_back(a);
		}

		int max = v[0];
		for(int i=0;i<n;i++){
			int k = 0;
			for(int j=i;j<n;j++){
				k += v[j];
				if(k > max)max = k;
			}
		}

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

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll b[4][4];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a.rbegin(), a.rend());
	ll al = 0;
	ll bob = 0;
	for (int i = 0; i < n; i++)
	{
		if (i % 2 == 0)
			al += a[i];
		else
			bob += a[i];
	}
	cout << al - bob;
	return 0;
}


Measured memory_bytes: 3644
fun main(array: Array<String>) {
    var (n, a, b) = readLine()!!.split(" ").map { it.toLong() }
    var ans = n / (a+b) * a
    val amari = n % (a+b)
    ans += if(amari <= a) {
        amari
    }
    else {
        a
    }
    print(ans)
}

Measured memory_bytes: 37936
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int a, b, c;
    int x, y;
    int sum=0;

    scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);
    
    if(a + b < 2 * c)
        sum = a*x + b*y;
    else
        sum = x>y ? (a>2*c ? 2*c*x : 2*c*y+a*(x-y)) : (b>2*c ? 2*c*y : 2*c*x+b*(y-x));

    printf("%d\n", sum);

    return 0;
}


Measured memory_bytes: 128
A,B,K=map(int,input().split())
for i in range(1,K+1):
    if i%2==1:
        if A%2==0:
            B=B+(A//2)
            A=A//2
        else:
            C=A-1
            B=B+(C//2)
            A=C//2
    elif i%2==0:
        if B%2==0:
            A=A+(B//2)
            B=B//2
        else:
            D=B-1
            A=A+(D//2)
            B=D//2
print(' '.join([str(A),str(B)]))

Measured memory_bytes: 61948
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var s = Console.ReadLine().Trim().ToCharArray();
        getAns(n, s);
    }
    static void getAns(int n, char[] s)
    {
        var sL = s.Length;
        var t = new char[sL];
        for (int i = 0; i < sL; i++)
        {
            t[i] = (char)(s[i] + n);
            if (t[i] > 'Z') t[i] -= (char)26;
        }
        Console.WriteLine(new string(t));
    }
}


Measured memory_bytes: 13168
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,r=0,a=0; cin>>n;
  char c[n];
  for(int i=0;i<n;i++){
    cin>>c[i];
    if(c[i]=='R') r++;
  }
  for(int i=0;i<r;i++){
    if(c[i]=='W') a++;
  }
  cout<<a;
}

Measured memory_bytes: 3828
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <locale>
#include <list>
using namespace std;
#define FORN(i,m,n) for(ll i=m; i<ll(n); i++)
#define PRINTVEC(v) FORN(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define PRINTMAT(m) FORN(j,0,m.size()) {PRINTVEC(m[j]);}
#define p_b(x) push_back(x)
#define m_p(a,b) make_pair(a,b)
typedef long long ll;
typedef long double ld;

const ll mod = 1e9 + 7;
vector<ll> f(1e6);

ll exp(ll a, ll b){
  ll ans = 1;
  a = a % mod;
  while (b > 0){
    if ((b & 1) == 1){
      ans *= a;
      ans = ans % mod;
    }
    a *= a;
    a = a % mod;
    b >>= 1;
  }
  return ans;
}

ll C(int k, int n){
  return f[n] * exp(f[k],mod-2) % mod * exp(f[n - k],mod-2) % mod;
}

int main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  ll x, y;
  cin>>x>>y;
  if((x + y) % 3 != 0) cout<<0<<endl;
  else{
    int lvl = (x + y) / 3;
    if(x < lvl || y < (lvl - 1)) cout<<0<<endl;
    else{
      f[0] = 1;
      for (int i = 1; i <= 1e6; i++) {
	f[i] = f[i - 1] * i % mod;
      }
      cout<<C(x - lvl, lvl)<<endl;
    }
  }
}

Measured memory_bytes: 8192
inp = raw_input().split()
H = int(inp[0])
N = int(inp[1])
A = raw_input().split()
A = list(map(int, A))

def attack_sum():
	sum_damage = 0
	for i in A:
		sum_damage += i
	return sum_damage

ans = ""
if H <= attack_sum():
	ans = "Yes"
else:
	ans = "No"
print(ans)

Measured memory_bytes: 12084
import std.algorithm;
import std.stdio;
import std.typecons;

immutable int maxL = 401;
immutable int inf = int.max / 2;

void main ()
{
	int n;
	int ma, mb;
	while (readf (" %s %s %s", &n, &ma, &mb) > 0)
	{
		alias Substance = Tuple !(int, q{a}, int, q{b}, int, q{c});
		int [maxL] [maxL] f;
		foreach (ref line; f)
		{
			line[] = inf;
		}
		f[0][0] = 0;
		foreach (i; 0..n)
		{
			Substance cur;
			readf (" %s %s %s", &cur.a, &cur.b, &cur.c);
			foreach_reverse (p; cur.a..maxL)
			{
				foreach_reverse (q; cur.b..maxL)
				{
					f[p][q] = min (f[p][q],
					    f[p - cur.a][q - cur.b] + cur.c);
				}
			}
		}

		int res = inf;
		foreach (p; 1..maxL)
		{
			foreach (q; 1..maxL)
			{
				if (p * mb == q * ma)
				{
					res = min (res, f[p][q]);
				}
			}
		}
		if (res >= inf)
		{
			res = -1;
		}
		writeln (res);
	}
}


Measured memory_bytes: 892
A, B = map(int, input().split())

if A == B:
    print(A)
    exit()

ans = 0
if A % 2 == 1:
    ans ^= A
    A += 1

if (B - A + 1) % 2 == 1:
    ans ^= B
    B -= 1

if ((B - A + 1) // 2) % 2 == 1 and A <= B:
    ans ^= 1

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char *argv[]){
    int length,flag,i,j;
    char *S=malloc(100);
    char *T=malloc(100);
    char *U=malloc(100);
    scanf("%s", S);
    scanf("%s", T);
    length = strlen(S);
    while(i<length&&strcmp(U,T)!=0){
        for (j = 0; j < length; j++) {
            U[j]=S[(i+j)%length];
        }
        i++;
    }
    if(strcmp(U,T)==0){
        printf("Yes");
    }
    else{
        printf("No");
    }
}

Measured memory_bytes: 128
n , m = list(map(int, input().split()))
x = list(map(int, input().split()))
if n >= m:
    print(0)
    exit()
x.sort()
L = []
for i in range(m - 1):
    L.append(x[i + 1] - x[i])
L.sort()
L.reverse()
total = 0
for i in range(n - 1):
    total += L[i]
print(x[-1] - x[0] - total)

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

using namespace std;

int n, a[20], x[20][20], y[20][20], f[20], ans = 0;

void dfs(int x, int ho)
{
	if (x > n)
	{
		for (int i = 1; i <= n; i++)
			if (f[i])
				for (int j = 1; j <= a[i]; j++)
					if (f[::x[i][j]] != y[i][j])
						return;
		ans = max(ans, ho);
		return;
	}
	f[x] = 0;
	dfs(x + 1, ho);
	f[x] = 1;
	dfs(x + 1, ho + 1);
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		for (int j = 1; j <= a[i]; j++)
			cin >> x[i][j] >> y[i][j];
	}
	dfs(1, 0);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
Module _20190525

    Sub Main()

        Dim sRead As String = Console.ReadLine()

        Dim r As Integer = sRead.Split(" ")(0)
        Dim D As Integer = sRead.Split(" ")(1)
        Dim X2000 As Integer = sRead.Split(" ")(2)

        Dim XNext As Integer = r * X2000 - D

        Console.WriteLine(XNext)

        For i As Integer = 2 To 10

            XNext = r * XNext - D

            Console.WriteLine(XNext)

        Next

    End Sub

End Module

Measured memory_bytes: 11220
n = int(input())
a = list(map(int, input().split()))
a.sort()
furui = [False] * (10**6+1)
ans = 0
for i in range(n):
    if i-1 >= 0 and a[i] == a[i-1]:
        continue
    if furui[a[i]] == False:
        if (i + 1 < n and a[i] != a[i + 1]) or i==n-1:
            ans += 1
        now = a[i]
        while now <= 10**6:
            furui[now] = True
            now += a[i]
print(ans)

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

int main(){
  int n;
  cin >> n;
  int max=0,max_second=0;
  vector<int> data(n);
  vector<int> dp(200001);
  for(int i=0; i<n; i++){
    cin >> data.at(i);
    dp.at(data.at(i))++;
    if(max < data.at(i)) max = data.at(i);
  }
  
  for(int i=max-1; i >= 0; i--){
    if(dp.at(i) > 0){
      max_second = i;
      break;
    }
  }
 
  if(dp.at(max) > 1){
    for(int i=0; i<n; i++){
      cout << max << endl;
    }
    return 0;
  }
  
  for(int i=0; i<n; i++){
    if(data.at(i) == max){
      cout << max_second << endl;
    }else{
      cout << max << endl;
    }
  }   
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	long long i,j,k;   
    string s;
    cin>>s;
    for (i=0;i<s.length();i++)
    {
    	if (s[i]=='?')
    	{
    		s[i]='D';
		}
	}
	cout<<s<<endl;
}

Measured memory_bytes: 3740
#! /usr/bin/env python3

n = int(input())

res = 0
min_v = 1000000

for _ in range(n):
    v = int(input())
    res += v
    if v % 10 != 0 and v < min_v: min_v = v

if res % 10 == 0:
    if min_v == 1000000: 
        res = 0
    else:
        res -= min_v

print(res)


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

int main(){
	int n;
	cin >> n;
	for(int i=0; i < n; i++){
		int cost;
		int x, y, b, p;
		cin >> x >> y >> b >> p;

		cost = x*b + y*p;
		if(5 <=  b && 2 <= p) cost *= 0.8;

		int b2=0, p2=0;
		if(b < 5 || p < 2){
			if(b < 5) b2 = 5-b;
			if(p < 2) p2 = 2-p;
			if((cost+b2*x + p2*y)*0.8 < cost) cost = (cost + b2*x + p2*y)*0.8;
		}
		cout << cost << endl;
	}
}

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

int main( void )
{
	vector <bool> isPrime( 51000 + 1, false );
	isPrime[2] = true;
	for ( int i = 3; i < 51000; i += 2 )
	{
		isPrime[i] = true;
	}

	for ( int i = 3; i < 51000; i += 2 )
	{
		for ( int j = i + i; j < 51000; j += i )
		{
			isPrime[j] = false;
		}
	}

	vector <int> primes;
	primes.push_back( 2 );
	for ( int i = 3; i < 51000; i += 2 )
	{
		if ( isPrime[i] )
			primes.push_back( i );
	}

	int n;
	while ( cin >> n && n != 0 )
	{
		int kotae = 0;
		for ( int i = 0; i < primes.size(); i++ )
		{
			if ( primes[i] <= n / 2 )
			{
				if ( isPrime.at( n-primes[i] ) )
					kotae++;
			}
		}
		cout << kotae << endl;
	}

	return 0;
}

Measured memory_bytes: 968
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
/*メモ 
*/
int main(){
    int n,qq;
    std::cin >> n>>qq;
    Graph g(n);
    rep(i,n-1){
        int a,b;
        std::cin >> a>>b;
        a--;b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    std::vector<int> w(n);
    rep(i,qq){
        int p,x;
        std::cin >> p>>x;
        p--;
        w[p]+=x;
    }
    std::vector<int> ro(n,-1);
    ro[0]=0;
    std::queue<int> q;
    q.push(0);
    while(!q.empty()){
        int p=q.front();
        erep(i,g[p]){
            if(ro[i]==-1){
                ro[i]=p;
                w[i]+=w[p];
                q.push(i);
            }
        }
        q.pop();
    }
    rep(i,n){
        std::cout << w[i] << std::endl;
        
    }
}

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

public class Main {

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

	private void solve() throws IOException {
		try {
			//			solveA();
			solveB();
			//			 solveC();
			//			 solveD();
			//			 solveE();
			//			 solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		int numA = nextInt();
		int numB = nextInt();
		int numC = nextInt();

		if (numA == numB && numB == numC) {
			out.println("Yes");
		} else {
			out.println("No");
		}

	}

	private void solveB() {
		int numN = nextInt();
		char[] wk = next().toCharArray();

		int rCnt = 0;
		int bCnt = 0;
		for (int i = 0; i < numN; i++) {
			if (wk[i] == 'R') {
				rCnt++;
			} else if (wk[i] == 'B') {
				bCnt++;
			}
		}

		out.println(rCnt > bCnt ? "Yes" : "No");
	}

	private void solveC() {
		int numN = nextInt();

		out.println("");
	}

	private void solveD() {
		int numN = nextInt();

		out.println("");
	}

	private void solveE() {
		int numN = nextInt();

		out.println("");
	}

	private void solveF() {
		int numN = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

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

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 20820
#include<stdio.h>

int main(void){
	
	int N,V[N],C[N],count=0;
	
	scanf("%d",&N);
	
	for(int i=0;i<N;i++)
		scanf("%d",&V[i]);
	
	for(int i=0;i<N;i++)
		scanf("%d",&C[i]);
	
	for(int i=0;i<N;i++){
		if(V[i]>C[i])
			count+=(V[i]-C[i]);
	}
	
	printf("%d",count);
	
	return 0;
}

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

typedef long long ll;
const ll INF = 1LL << 60;

inline bool chmin(ll& a, ll b) { if (a > b) { a = b; return true; } return false; }
inline bool chmax(ll& a, ll b) { if (a < b) { a = b; return true; } return false; }

int N, W;
vector<ll> wi, vi;
vector<vector<ll>> sum;

int main() {

  cin >> N >> W;
  wi = vector<ll>(N+10);
  vi = vector<ll>(N+10);
  sum = vector<vector<ll>>(N+10,vector<ll>(W+100,0));

  for (ll i=0; i<N; i++){
    cin >> wi.at(i) >> vi.at(i);
  }

  for (ll i=0;i<N;i++){
    for (ll j=0;j<=W;j++){
      if (j-wi.at(i)>=0) {
        chmax(sum.at(i+1).at(j),sum.at(i).at(j-wi.at(i)) + vi.at(i));
      }
      chmax(sum.at(i+1).at(j),sum.at(i).at(j));
    }
  }

  cout << sum.at(N).at(W) << endl;
}

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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;


int main(){
  int H, W, Sx, Sy, Gx, Gy;
  cin >> H >> W >> Sx >> Sy >> Gx >> Gy;
  vector<vector<int>> num(1010,vector<int>(1010, 10000000));//そのマスにワープ何回で辿り着けるか記録する
  
  
  char s;
  rep(i,H){
    rep(j,W){
      cin >> s;
      if(s == '.'){
        num[i+1][j+1] = -1;
      }
    }
  }
  
  //BFSの準備
  queue<pair<int,int>> que0;
  
  queue<pair<int,int>> que;
  
  que.push(make_pair(Sx,Sy));
  que0.push(make_pair(Sx,Sy));
  num[Sx][Sy] = 0;
  int p = 0;
  
  while(!que.empty()){
  
  while(!que.empty()){
    pair<int,int> v = que.front();
    que.pop();
    
    int x,y;
    tie(x,y) = v;
    
    if(num[x+1][y]==-1){
      num[x+1][y]=p;
      que0.push(make_pair(x+1,y));
      que.push(make_pair(x+1,y));
    }
    if(num[x-1][y]==-1){
      num[x-1][y]=p;
      que0.push(make_pair(x-1,y));
      que.push(make_pair(x-1,y));
    }
    if(num[x][y+1]==-1){
      num[x][y+1]=p;
      que0.push(make_pair(x,y+1));
      que.push(make_pair(x,y+1));
    }
    if(num[x][y-1]==-1){
      num[x][y-1]=p;
      que0.push(make_pair(x,y-1));
      que.push(make_pair(x,y-1));
    } 
  }
    
  p++;
  int t = que0.size();
  for(int i = 0; i<t;i++){
    pair<int,int> v = que0.front();
    que0.pop();
    int x,y;
    tie(x,y) = v;
    for(int i = max(0,x-2); i<=min(1010, x+2); i++){
      for(int j = max(0,y-2); j<=min(1010, y+2); j++){
        if(num[i][j]==-1){
          num[i][j]=p;
          que.push(make_pair(i,j));
          que0.push(make_pair(i,j));
        }
      }
    }
  }
    
  }
 
  cout << num[Gx][Gy] << endl;
}

      
      
       






Measured memory_bytes: 7620
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    int w,h,sharp = 0;
    cin >> w >> h;
    
    for(int i = 0; i < w*h; i++){
        char c;
        cin >> c;
        if( c == '#') sharp++;
    }
    
    if(w + h -1 == sharp){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
    
}


Measured memory_bytes: 384
fn main(){
	loop{
		let v = read_vec::<usize>();
		let (h, w) = (v[0], v[1]);
		if h == 0 && w == 0 { break; }
		
		let row = repeat_string("#.", w / 2 + 1);
		for i in 0..h {
			println!("{}", if i % 2 == 0 { &row[0..w] } else { &row[1..w + 1] });
		}
		println!("");
	}
}

fn repeat_string(s: &str, n: usize) -> String{
	let mut str = String::new();
	for _ in 0..n {
		str.push_str(s);
	}
	str
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


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

int main(){

  int p = 1, num = 0, c;
  for(int i=0;i<6;i++){
    cin >> c;
    num += p * c;
    if(i&1) p *= 2;
    else p *= 5;
  }

  if(num < 1000) puts("0");
  else puts("1");

}

Measured memory_bytes: 1120
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INF 100000000000000000

int N, K, X, x[100100] = {};

signed main(){
	int temp=0, ans = INF;
	
	cin>>N>>K;
	
	for(int i = 1; i <= N; i++){
		cin>>X;
		if(X<0){
			X *= -1;
			temp = i;
		}
		x[i] = X;
	}

	
	for(int i = 1; i <= N-K+1; i++){
		int m=0, p=0;
		if(i <= temp) m = x[i];
		if(i+K-1 > temp)p = x[i+K-1];
		ans = min(ans, min(m * 2 + p, p * 2 + m));
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#define min(X, Y) ((X) < (Y) ? (X) : (Y))
typedef long long ll;

ll n;
ll a[2 * 100000 + 5];

int main()
{
	ll ans = (1ll << 60ll);

	scanf("%lld", &n);
	for (ll i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);

		a[i] += a[i - 1];
	}

	for (ll i = 1; i < n; i++) {
		ans = min(ans, 
				llabs(a[n] - a[i] - a[i]));
	}

	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 1792
import java.util.*;

class Pair {
	public Pair(int f, int s) {
		this.f = f;
		this.s = s;
	}
	public int f, s;
}

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int w = scanner.nextInt();
		int n = scanner.nextInt();
		Pair[] pairs = new Pair[n];
		for (int i = 0; i < n; i++) {
			String[] s = scanner.next().split(",");
			pairs[i] = new Pair(Integer.parseInt(s[0]) - 1, Integer.parseInt(s[1]) - 1);
		}
		int[] result = new int[w];
		for (int i = 0; i < w; i++) {
			int finger = i;
			for (int j = 0; j < n; j++) {
				if (finger == pairs[j].f) finger = pairs[j].s;
				else if (finger == pairs[j].s) finger = pairs[j].f;
			}
			result[finger] = i + 1;
		}
		for (int i = 0; i < w; i++) System.out.println(result[i]);
	}
}

Measured memory_bytes: 25608
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int W, H, N;
	bool w[100] = {}, h[100] = {};
	int x, y, a;
	cin >> W >> H >> N;
	
	for (int i = 0; i < N; i++) {
		cin >> x >> y >> a;
		if (a == 1) {
			for (int i = 0; i < x; i++) {
				w[i] = true;
			}
		}
		else if (a == 2) {
			for (int i = x; i < W; i++) {
				w[i] = true;
			}
		}
		else if (a == 3) {
			for (int i = 0; i < y; i++) {
				h[i] = true;
			}
		}
		else if (a == 4) {
			for (int i = y; i < H; i++) {
				h[i] = true;
			}
		}
	}
	x = 0; y = 0;
	for (int i = 0; i < W; i++) {
		if (w[i] == false) x++;
	}
	for (int i = 0; i < H; i++) {
		if (h[i] == false) y++;
	}
	cout << x*y << endl;

	return 0;
	
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from collections import Counter
def inpl(): return tuple(map(int, input().split()))

N = int(input())
C = Counter()
for _ in range(N):
    C[input()] += 1
M = int(input())
for _ in range(M):
    C[input()] -= 1
print(max(max(C.values()), 0))

Measured memory_bytes: 3316
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
ll ans[2005]={0};
int main(){
  ll k,n;
  cin>>k>>n;
  vector<ll> vec;
  for(int i=1;i<=n;i++){
    ll a;
    cin>>a;
    vec.push_back(a);
  }
  sort(vec.begin(),vec.end());
  ll ans=1744174417441744;
  for(int i=0;i<n;i++){
    vec.push_back(vec[i]+k);
  }
  for(int i=0;i<n;i++) ans=min(ans,vec[i+n-1]-vec[i]);
  cout<<ans<<endl;
}


Measured memory_bytes: 6256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n;
int32_t main(){_

   cin>>n;

   vector<int> a(n);

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

   if (is_sorted(a.begin(), a.end())){
      cout<<"YES";
      exit(0);
   }

   vector<int> v = a;
   for (int i = 0; i < n; ++i)
   {
      for (int j = i+1; j < n; ++j)
      {
         swap(v[i], v[j]);
         if (is_sorted(v.begin(), v.end())){
            cout<<"YES";
            exit(0);
         }
         swap(v[i], v[j]);
      }
   }

   cout<<"NO";

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, x[102];
  cin >> n >> k;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
    if (x[i] * 2 <= (k - x[i]) * 2) {
      ans += x[i] * 2;
    }
    else {
      ans += (k - x[i]) * 2;
    }
  }
  cout << ans << endl;
}


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

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

int main()
{
    string a, b;
    cin >> a >> b;
    if (a.size() > b.size())
        cout << "GREATER" << endl;
    else if (a.size() < b.size())
        cout << "LESS" << endl;
    else
    {
        int cmp = strcmp(a.c_str(), b.c_str());
        if (cmp > 0)
            cout << "GREATER" << endl;
        else if (cmp < 0)
            cout << "LESS" << endl;
        else
            cout << "EQUAL" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		char[][] a = new char[n][n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.next().toCharArray();
		}
		char[][] b = new char[m][m];
		for (int i = 0; i < m; i++) {
			b[i] = sc.next().toCharArray();
		}
		sc.close();

		for (int i = 0; i <= n - m; i++) {
			for (int j = 0; j <= n - m; j++) {
				boolean flg = true;
				for (int x = 0; x < m; x++) {
					for (int y = 0; y < m; y++) {
						if (a[i + x][j + y] != b[x][y]) {
							flg = false;
							break;
						}
					}
				}
				if (flg) {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");
	}
}


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


int main(){
    int N;
    cin >> N;
    vector<int> data;

    for ( int i = 0; i< N; ++i ){
        int x;
        cin >> x;
        data.push_back(x);
    }

    int result = 0;

    // for(int i = 0; i < data.size(); ++i ){
    //     cout << data.at(i); 
    // } 

    // cout << endl;

    int n = 1;
    int i = 0;
    int count = 0;
    while( i != N ){
        if( n == data.at(i) ){
            count++;
            ++n;
        }
        ++i;
    }

    // cout << "result:" << count << endl;

    if( count <= N && count != 0 ){
        cout << N - count << endl;
    }else{
        cout << -1 << endl;
    }

}

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

#define rep(i,s,t) for(int i = s; i <= t; ++ i)
const int MaxN = 100050;

int n, m, x, ans;
int cnt[MaxN], hs[MaxN], pa[MaxN];

int main()
{
    scanf("%d%d",&n,&m);
    rep(i,1,n) scanf("%d",&x), cnt[x%m] ++, hs[x] ++;
    ans += cnt[0]/2, cnt[0] = 0;
    if(m%2==0) ans += cnt[m/2]/2, cnt[m/2] = 0;
    rep(i,1,m/2-(m%2==0))
        if(cnt[i] && cnt[m-i])
        {
            if(cnt[i] < cnt[m-i])
            {
                ans += cnt[i];
                cnt[m-i] -= cnt[i]; cnt[i] = 0;
            }
            else
            {
                ans += cnt[m-i];
                cnt[i] -= cnt[m-i]; cnt[m-i] = 0;
            }
        }
    rep(i,0,m-1) for(int j = i; j <= MaxN-50; j += m)
        if(cnt[i] < 2) break;
        else {ans += min(cnt[i],hs[j])/2; cnt[i] -= min(cnt[i],hs[j])/2*2;}
    cout << ans;
    return 0;
}


Measured memory_bytes: 1024
using System;

class A
{
    static void Main()
    {
        int X = int.Parse(Console.ReadLine());
        if (X <= 599) Console.WriteLine("8");
        else if (X <= 799) Console.WriteLine("7");
        else if (X <= 999) Console.WriteLine("6");
        else if (X <= 1199) Console.WriteLine("5");
        else if (X <= 1399) Console.WriteLine("4");
        else if (X <= 1599) Console.WriteLine("3");
        else if (X <= 1799) Console.WriteLine("2");
        else if (X <= 1999) Console.WriteLine("1");
    }
}


Measured memory_bytes: 27532
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace AtCoder
{

    class Program
    {
        static void Main()
        {
            //ここから
            List<int> vs = new List<int>();
            for(int i = 0; i < 5; i++)
            {
                vs.Add(IO.ReadLineToInt());
            }

            int ans = 0;

            foreach(var item in vs)
            {
                if (item % 10 == 0)
                {
                    ans += item;
                }
            }
            vs.RemoveAll(v => v % 10 == 0);
            vs = vs.OrderByDescending(v => v % 10).ToList();
            if (vs.Count > 0)
            {
                foreach (var item in vs)
                {
                    ans += ((item / 10) + 1) * 10;
                }
                ans += -10 + (vs.Last() % 10);
            }


            Console.WriteLine(ans);
            Console.ReadKey();
        }
    }

    class Func
    {
        long mod = 1000000007;
        static public void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; }
        static public long GCD(int a, int b) { return b != 0 ? GCD(b, a % b) : a; }
        static public long LCM(int a, int b) { return (long)a * b / GCD(a, b); }
        static public int Factorial(int a) { return a == 1 ? a : a * Factorial(a - 1); }
        static public int Conbin(int n, int m) { return Factorial(n) / (Factorial(n - m) * Factorial(m)); }
        static public void Factoring(long num, ref long[] vs)
        {
            if (num == 1)
            {
                vs[1]++;
            }
            for (long i = 2; i < (long)Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    vs[i]++;
                    Factoring(num / i, ref vs);
                }
            }
            vs[1]++;
        }
    }

    class IO
    {
        static public string ReadLineToString() { return Console.ReadLine(); }
        static public int ReadLineToInt() { return int.Parse(Console.ReadLine()); }
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public string[] ReadLineToStringArray() { return Console.ReadLine().Split(' ').ToArray(); }
        static public int[] ReadLineToIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] ReadLineToLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<string> ReadLineToStringList() { return Console.ReadLine().Split(' ').ToList(); }
        static public List<int> ReadLineToIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

// KMP?????? O(N)
vector<int> build_kmp(const string &s){
  int n = s.size();
  vector<int> a(n+1, -1);
  int j = -1;
  rep(i,n){
    while(j>=0 && s[i]!=s[j]) j = a[j];
    j++;
    if(s[i+1]==s[j]) a[i+1] = a[j];
    else a[i+1]=j;
  }
  return a;
}

vector<int> kmp_match(const string &txt, const string &pat, const vector<int> &skip){
  int n = txt.size();
  int m = pat.size();
  vector<int> ret;
  int j = 0;
  rep(i,n){
    while(j>-1 && txt[i] != pat[j]) j = skip[j];
    j++;
    if(j==m){
      ret.pb(i-m+1);
      j = skip[m];
    }
  }
  return ret;
}

int main(){
  string t,p;
  cin>>t>>p;

  auto skip = build_kmp(p);
  auto ans = kmp_match(t, p, skip);

  for(auto i : ans) cout << i << endl;

  return 0;
}

Measured memory_bytes: 8488
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String args[]){

		Scanner cin = new Scanner(System.in);

		int N = cin.nextInt();
		int M = cin.nextInt();
		int list[] = new int[2*M];
		int tmp = 0;
		int count=1;
		String result = "YES";

		for(int i=0;i<2*M;i++){
			list[i] = cin.nextInt();
		}
		cin.close();
		Arrays.sort(list);
		tmp = list[0];
		for(int j=0;j<2*M;j++){
			if(j<2*M-1&&tmp==list[j+1]){
				count++;
			}else{
				if(count%2==0){
					count=1;
					if(j<2*M-1){
						tmp = list[j+1];
					}
				}else{
					result = "NO";
					break;
				}
			}
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 65232
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<algorithm>

using namespace std;

typedef long long ll;

int main()
{
	int N, M;
	scanf("%d%d", &N, &M);
	if (N > M) swap(N, M);
	if (N == 1 && M == 1) printf("1\n");
	else if (N == 1) printf("%d\n", max(0, M - 2));
	else printf("%lld\n", (ll)(N - 2) * (M - 2));
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define ll long long
#define str_to_int(s) atoi(s.c_str())
#define print(x) cout << x << endl

int big_reminder(int a, int b, int p){
    b %= p;
    int r = 1;
    rep(i, b){
        r = (r*a)%p;
    }
    return r;
}

vector<int> big_reminders(int a, int p){
    vector<int> rs;
    int r = 1;
    rep(i, p){
        r = (r*a)%p;
        rs.push_back(r);
    }
    return rs;
}

ll powi(ll x, ll y){
    ll z = 1;
    rep(i,y) z*=x;
    return z;
}

int main(){
    int n, p;
    string s;
    cin >> n >> p >> s;
    ll nf = 0;
    map<int, int> rs;
    map<int, int> m;
    vector<int> reminders = big_reminders(10,p);
    rs[-1] = 0;
    rep(i,n){
        if(p==2 || p==5){
            int ui = stoll(s.substr(i,1));
            if(ui%p == 0){
                nf += i+1;
            }
        } else {
            int si = s[n-1-i]-'0';
            //cout << "si: " << si << endl;;
            //cout << "reminder of 10^i%p: " << reminders[i%(p-1)] << endl;
            int r;
            if (i == 0) r = (si+rs[i-1])%p;
            else r = ((si*reminders[(i-1)%(p-1)]) + rs[i-1])%p;
            rs[i] = r;
            m[r] += 1;
            //cout << "r: " << r << endl;
            if(r == 0) nf += m[r];
            else nf += m[r] - 1;
            //print(" ");
        }
    }
    print(nf);
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

using namespace std;

typedef long long ll;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n; cin>>n;
  int min = 1000000010;
  int max = 1;
  
  
  rep(i,n) {
    int a; cin>>a;
    
    chmax(max, a);
    chmin(min, a);
  }
  
  cout<<max-min;
  
  return 0;
}

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

using namespace std;
typedef long long ll;
const int inf = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;
const ll mod = (int)1e9 + 7;

int gets(int n) {
    int s = 0;
    while (n > 0) {
        s += n % 10;
        n /= 10;
    }
    return s;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n;
    cin >> n;
    int res = inf;
    for (int i = 1; i < n; ++i) {
        res = min(res, gets(i) + gets(n - i));
    }

    cout << res;
    return 0;
}


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

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

	cin >> a >> b >> c >> x;
	for (int i = 0; i <= a; i++) {
		for(int j = 0; j <= b; j++){
			for (int k = 0; k <= c; k++) {
				if (i*500+j*100+k*50 == x) {
					count++;

				}

			}
		}
	}


	cout << count << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
  string weathers[4] = {"Sunny", "Cloudy", "Rainy", "Sunny"};
  string today;
  
  cin >> today;
  for (int i = 0; i < 3; i++) {
    if (weathers[i] == today) {
     	cout << weathers[i+1]; 
    }
  }
}

Measured memory_bytes: 256
s = gets.chomp
Q = gets.to_i

ts = ""
Q.times do |q|
  query = gets.split
  
  if query[0].to_i == 1
    tmp = s
    s = ts
    ts = tmp
  else
    f = query[1].to_i
    if f == 1
      ts << query[2]
    else
      s << query[2]
    end
  end
end
puts ts.reverse + s


Measured memory_bytes: 2940