akhauriyash/Code-Regression huggingface dataset:
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    
    for h in range(1, 3501):
        for n in range(1, 3501):
            denom = 4 * h * n - N * n - N * h
            if denom == 0:
                continue
            w = (N * h * n) / denom
            if w.is_integer() and 0 < w:
                print(h, n, int(w))
                return


if __name__ == '__main__':
    solve()


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

int tax(int r, int pr){
    return pr*(r + 100)/100 - pr;
}

int main(){
    int a, b; cin >> a >> b;
    bool no = true;
    for(int i = 0; i < 1600; i++){
        if(tax(8, i) == a && tax(10, i) == b){
            cout << i << endl;
            no = false;
            break;
        }
    }
    if(no) cout << -1 << endl;
}

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

bool allsame(const string &S) {
    for(int i = 0; i < (int)S.size(); ++i) {
        if(S[i] != S[0]) return false;
    }
    return true;
}

int num(const string &S) {
    int res = 0;
    for(int i = 0; i < (int)S.size(); ++i) {
        if(S[i] == S[i + 1]) res++, i++;
    }
    return res;
}

long long solve() {
    string S;
    long long K;
    cin >> S >> K;
    if(allsame(S)) return K * S.size() / 2;
    return num(S) + (num(S + S) - num(S)) * (K - 1);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
int c[500000];
int sqrtN = 710;
struct SqrtDecomposition{
    int N, K;
    vector <long long> data;
    vector <long long> bucketSum;
    
    SqrtDecomposition(int n){
        N = n;
        K = (N + sqrtN - 1) / sqrtN;
        data.assign(N, 0);
        bucketSum.assign(K, 0);
    }

    void add(int x, int y){
        data[x] += y;
        bucketSum[x / sqrtN] += y;
    }

    long long getSum(int x, int y){
        long long ans = 0;
        if(y - x < sqrtN){
            for(int i = x; i < y; i++){
                ans += data[i];
            }
            return ans;
        }
        for(int i = x / sqrtN + 1; i < y / sqrtN; i++){
            ans += bucketSum[i];
        }

        for(int i = x; i < (x / sqrtN + 1) * sqrtN; i++){
            ans += data[i];
        }
        for(int i = y / sqrtN * sqrtN; i < y; i++){
            ans += data[i];
        }
        return ans;
    }
    
};

int ans[500000];
int last_appeared[500001];
pair <pair <int, int>, int> RL_ind[500000];
int main(){
  int N;
  int Q;
  cin >> N >> Q;

  int max_c = 0;
  for(int i = 0; i < N; i++){
    cin >> c[i];
    max_c = max(max_c, c[i]);
  }

  for(int i = 0; i < Q; i++){
    int l;
    int r;
    cin >> l >> r;
    RL_ind[i] = make_pair(make_pair(r, l), i);
  }
  for(int i = 0; i <= max_c; i++){
    last_appeared[i] = -1;
  }

  sort(RL_ind, RL_ind + Q);

  SqrtDecomposition sq(N);
  int last_R = 0;
  for(int i = 0; i < Q; i++){
    int cur_L = RL_ind[i].first.second;
    int cur_R = RL_ind[i].first.first;
    int ans_ind = RL_ind[i].second;
    for(int j = last_R; j < cur_R; j++){
      if(last_appeared[c[j]] >= 0){
        sq.add(last_appeared[c[j]], -1);
      }
      last_appeared[c[j]] = j;
      sq.add(j, 1);
    }
    ans[ans_ind] = sq.getSum(cur_L - 1, cur_R);
    last_R = cur_R;
  }

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

  return 0;
}


Measured memory_bytes: 19348
N = int(input())
edges = [list(map(int, input().split())) for _ in range(N - 1)]

graph = [[] for _ in range(N + 1)]
for u, v, w in edges:
    graph[u].append((v, w))
    graph[v].append((u, w))

edges.sort()
color = [-1] * (N + 1)
color[1] = 0
que = [1]

while que:
    u = que.pop()
    
    for v, w in graph[u]:
        if color[v] != -1:
            continue

        if w % 2 == 0:
            color[v] = color[u]
        else:
            color[v] = color[u] ^ 1
            
        que.append(v)
        
print(*color[1:], sep='\n')




Measured memory_bytes: 85208
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String input = scan.next();

    int gc = 0; // '<'
    int lc = 0; // '>'
    long sum = 0;
    int pc = 0;
    for (int i = 0; i < input.length(); i++) {
      if (input.charAt(i) == '<') {
        gc++;
        sum+=gc;
        lc = 0;
      } else {
        if (gc != 0) {
          pc = gc;
          gc = 0;
        }
        if (pc <= lc) {
            sum++;
        }
        sum += lc;
        lc++;
      }
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 28860
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, m;
  cin>>n>>m;
  int a[n];
  for(int i=0; i<n; ++i) cin>>a[i];
  
  int x = 1, sum = 0;
  while(n*x%m!=0) x++;
  for(int i=0, cnt=0; i<n*x/m; ++i){
    int ma = 0, mi = 1e9;
    for(int j=0; j<m; ++j, ++cnt){
      if(cnt == n) cnt=0;
      ma = max(ma, a[cnt]);
      mi = min(mi, a[cnt]);
    }
    sum += ma - mi;
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 3104
using System;

namespace ABC110A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            string[] s = Console.ReadLine().Split(' ');
            a = int.Parse(s[0]);
            b = int.Parse(s[1]);
            if (a > 8 || b > 8)
                Console.WriteLine(":(");
            else
                Console.WriteLine("Yay!");
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<map>
#include<set>
using namespace std;
int n,a[200005];
map <int,int> mp;
long long pow(int x)
{
	long long k=1;
	while(k<=x)
	    k*=2;
    return k;
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		mp[a[i]]++;
	}
	sort(a,a+n);
	reverse(a,a+n);
	int cnt=0;
	for(int i=0;i<n;i++)   
	{
		int f=pow(a[i])-a[i];
		if((mp[f]>=1&&f!=a[i]&&mp[a[i]]>=1)||(mp[f]>=2&&f==a[i]))
		{
			mp[f]--;
			mp[a[i]]--;
			cnt++;
		}
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 19712
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template <class T> inline T gcd(T a, T b) {if(a==0) return b; return gcd(b%a,a);}
template <class T> inline T lcm(T a, T b) {return a * b / gcd(a,b);}
template <class T> inline T sum(vector<T> &vec) {T res=0; for (int i = 0; i < vec.size(); i++) res += vec[i]; return res;}
template <class T> inline T mpow(T a, T b) {if(b==0)return 1; T c = mpow(a,b/2);if(b%2==1)return c*c*a; return c*c;}
const int INF = 1 << 30;
const long long INFLL = 1LL << 60;
typedef pair<int, int> P;

#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define FOR(i,n) for (int (i)=0;(i)<(n);(i)++)
#define REPB(i,n) for (int (i)=((n)-1);(i)>=0;(i)--)
#define FORB(i,n) for (int (i)=((n)-1);(i)>=0;(i)--)
#define SORT(A) sort((A).begin(),(A).end())

int main() {
    
    int K, X;
    cin >> K >> X;
    if (500 * K >= X) {
        cout << "Yes\n";
    } else {
        cout <<  "No\n";
    }
}


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

using ll = long long;
using P = pair<int, int>;

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

    bool isExists = false;
    for (int i = 1; i <= 9; i++)
    {
        for (int j = 1; j <= 9; j++)
        {
            if (i * j == N)
            {
                isExists = true;
                break;
            }
        }
    }
    if (isExists)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}

Measured memory_bytes: 3604
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cmath>     // pow
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   // setprecision
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a; }
// cout << fixed << setprecision(10);
// vector<vector<int>> vec(H, vector<int>(W))    // int H*W

int main() {
    int N;
    cin >> N;
    int ans = 0;

    int prev, cur;
    cin >> prev;
    int ret = 0;
    for(size_t i = 0; i < N - 1; i++) {
        cin >> cur;
        if(prev >= cur) {
            ans++;
            ret = max(ret, ans);
        } else {
            ret = max(ret, ans);
            ans = 0;
        }
        prev = cur;
    }

    cout << ret << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int linerSearch(int[],int,int);

  int main(){

    int i,h,H[10000+1], q, key, sum = 0;
    
    scanf("%d",&h);
  
  for( i = 0 ; i < h ; i++ ){
    scanf("%d",&H[i]);
  }

  scanf("%d",&q);
  
  for( i = 0 ; i < q ; i++ ){
    
    scanf("%d",&key);
    
    if( linerSearch(H, h , key))sum++;
  }
  printf("%d\n",sum);

  return 0;
}
 
    
int linerSearch(int H[],int h,int key){
  int i = 0;
  H[h] = key;
  while( H[i] != key )i++;
  return i != h;
}



Measured memory_bytes: 2108
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>


#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define Yes_RTN s_cout("Yes");return 0
#define No_RTN  s_cout("No");return 0
#define YES_RTN s_cout("YES");return 0
#define NO_RTN  s_cout("NO");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);


int main(void) {

	int    N,i,s1=0,s2=0,tmp=0,m=10001;
	int    w[101];
	
	i_cin(N);
	i_cins(N, w);

	for (i = 1; i < N; i++) s2 += w[i];
	for (i = 0; i < N-1; i++) {
		s1 += w[i];
		tmp = abs(s2-s1);
		if (tmp < m) m= tmp;
		s2 -= w[i + 1];
	}

	i_cout(m);

	return 0;	
}
	

int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a -*(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}

int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}



Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#define r(i,n) for(int i=0;i<n;i++)
#define R(i,c,n) for(int i=c;i<n;i++)
#define debug(x) cerr << #x << ": " << x << endl;
using namespace std;

int main(){
  int x,y;
  cin >> x >> y;
  cout << x + (y/2) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <cctype>
#define pb push_back
#define endl '\n'
#define ll long long
#define PI acos(-1)
#define RUN_FAST ios::sync_with_stdio(false);
#define sz 8000000
using namespace std;

int main()
{
    RUN_FAST; cin.tie(nullptr);
    int x;
    cin >> x;
    if (x>=400 && x<=599) cout << 8 << endl;
    else if (x>=600 && x<=799) cout << 7 << endl;
    else if (x>=800 && x<=999) cout << 6 << endl;
    else if (x>=1000 && x<=1199) cout << 5 << endl;
    else if (x>=1200 && x<=1399) cout << 4 << endl;
    else if (x>=1400 && x<=1599) cout << 3 << endl;
    else if (x>=1600 && x<=1799) cout << 2 << endl;
    else if (x>=1800 && x<=1999) cout << 1 << endl;
    return 0;
}


Measured memory_bytes: 3648
def resolve():
    a,b,c=map(int, input().split())
    if a==c==b and a%2==0:
        print(-1)
    elif a==c==b and a%2==1:
        print(0)
    else:
        cnt=0
        while a%2==b%2==c%2==0:
            a_new=(b+c)//2
            b_new=(a+c)//2
            c_new=(a+b)//2
            a=a_new
            b=b_new
            c=c_new
            cnt+=1
        print(cnt)

resolve()

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

typedef long long ll;

const long long MOD = 1000000007;
long long modpow(long long a, long long n, long long m)
{
    long long ans = 1;
    while (n)
    {
        if (n & 1)
        {
            ans = (ans * a) % m;
        }
        a = (a * a) % m;
        n >>= 1;
    }
    return ans;
}
long long combi(long long n, long long a)
{
    long long ans = 1, ans1 = 1;
    for (long long i = n - a + 1; i <= n; i++)
    {
        ans *= i % MOD;
        ans %= MOD;
    }

    for (long long i = 2; i <= a; i++)
        ans1 = (ans1 * i) % MOD;
    ans1 = modpow(ans1, MOD - 2, MOD);
    return ((ans % MOD) * ans1) % MOD;
}

void dfs(string s, char mx, ll N)
{
    if (s.length() == N)
    {
        cout << s.c_str() << endl;
    }
    else
    {
        for (char c = 'a'; c <= mx; c++)
        {
            dfs(s + c, ((c == mx) ? (char)(mx + 1) : mx), N);
        }
    }
}

int bfs(int a, int b, int h, int w, char tmp[][101])
{
    int ans[101][101] = {0};
    char c[101][101] = {0};
    queue<pair<int, int>> s;

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

    s.push(make_pair(a, b));

    while (s.size() > 0)
    {

        pair<int, int> tmp = s.front();
        s.pop();
        c[tmp.first][tmp.second] = '#';
        for (int i = -1; i <= 1; i++)
        {
            for (int j = -1; j <= 1; j++)
            {
                if (tmp.first + i < 1 || tmp.first + i > h)
                {
                    continue;
                }
                if (tmp.second + j < 1 || tmp.second + j > w)
                {
                    continue;
                }
                if (i != 0 && j != 0)
                {
                    continue;
                }
                if (i == 0 && j == 0)
                {
                    continue;
                }
                if (c[tmp.first + i][tmp.second + j] == '#')
                {
                    continue;
                }
                c[tmp.first + i][tmp.second + j] = '#';
                if (ans[tmp.first + i][tmp.second + j] == 0)
                {
                    ans[tmp.first + i][tmp.second + j] = ans[tmp.first][tmp.second] + 1;
                }
                else
                {
                    ans[tmp.first + i][tmp.second + j] = min(ans[tmp.first + i][tmp.second + j], ans[tmp.first][tmp.second] + 1);
                }
                s.push(make_pair(tmp.first + i, tmp.second + j));
            }
        }
    }

    int asd = 0;

    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            asd = max(a, ans[i][j]);
        }
    }

    return asd;
}

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

    ll a = (n / 500);
    ll b = (n % 500) / 5;

    cout << a*1000 + b*5 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;
typedef unsigned long long ull;
const int mo =1e+9+7;

ull f[110];
LL n,m;

LL calc(LL x,LL y){
	LL cnt=0;
	if (x<=n&&y<=m)cnt=(m-y)/x+1;
	if (x<=m&&y<=n)cnt=cnt+(n-y)/x+1;
	return cnt;
}

int main(){
	f[0]=f[1]=1;
	fo(i,2,90)f[i]=f[i-1]+f[i-2];
	int T;
	scanf("%d",&T);
	for(;T;T--){
		scanf("%lld%lld",&n,&m);
		if (n>m)swap(n,m);
		if (n==1&&m==1){printf("1 1\n");continue;}
		int k=0;
		fo(i,1,90)
		if (n>=f[i]&&m>=f[i+1])k=i;else break;
		if (k==1){
			if (n==2)printf("1 4\n");
			else printf("1 %lld\n",m%mo);
			continue;
		}
		printf("%d ",k);
		LL ans=0;
		ans=calc(f[k],f[k+1]);
		fo(i,1,k-1)ans=(ans+calc(f[k]+f[i]*f[k-1-i],f[k+1]+f[i]*f[k-i]))%mo;
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll h,w,cb=0,cw=0,ans=0;
char s[410][410];
bool b[410][410];

void search_area(int i,int j){
    b[i][j]=true;
    if(s[i][j]=='#') cb ++;
    if(s[i][j]=='.') cw ++;
    if(j<w-1&&s[i][j]!=s[i][j+1]&&!b[i][j+1]) search_area(i,j+1);
    if(j>0&&s[i][j]!=s[i][j-1]&&!b[i][j-1]) search_area(i,j-1);
    if(i<h-1&&s[i][j]!=s[i+1][j]&&!b[i+1][j]) search_area(i+1,j);
    if(i>0&&s[i][j]!=s[i-1][j]&&!b[i-1][j]) search_area(i-1,j);
    return;
}

int main(){
    cin >> h >> w;
    for(int i = 0;i < h;i ++){
        for(int j = 0;j < w;j ++){
            cin >> s[i][j];
        }
    }
    for(int i = 0;i < h;i ++){
        for(int j = 0;j < w;j ++){
            cb=0;
            cw=0;
            if(!b[i][j]){
                search_area(i,j);
                ans += cb*cw;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15616
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    String s = next();
    String[] ss = splitString(s);

    if(ss[0].equals(ss[1]) && ss[0].equals(ss[2])){
      System.out.println("No");
    }
    else{
      System.out.println("Yes");
    }



    //System.out.println();

  }
  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

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

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

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

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


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

int main(void){
	int num;
	char str[256];
	scanf("%d",&num);
	scanf("%s",str);
	int i=0;
	int count_r=0;
	for(i=0;str[i]!='\0';i++){
		if(str[i] == 'R')count_r++;
		else count_r--;
	}
	if(count_r>0)printf("Yes\n");
	else printf("No\n");

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  ll n,k;
  cin >> n >> k;

  map<ll, ll> mp;

  vector<ll> a(n), b(n);
  rep(i,n) {
    cin >> a[i] >> b[i];
    mp[a[i]] += b[i];
  }
  ll t;
  for (auto itr : mp) {
    t = itr.first;
    if (k - itr.second <= 0) {
      cout << itr.first << endl;
      return 0;
    } else {
      k -= itr.second;
    }
  }

  if (k > 0) {
    cout << t << endl;
  }
}


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

int main() {
    string S = "";
    cin >> S;
    deque<char> deq(S.size());
    rep(i, S.size()) { deq[i] = S[i]; }
    ll Q;
    int rev = 0;
    cin >> Q;
    rep(i, Q) {
        int T;
        cin >> T;
        if(T == 1) {
            rev = 1 - rev;
        } else {
            int F;
            char C;
            cin >> F >> C, --F;
            if(rev)
                F = 1 - F;
            if(F == 0) {
                deq.push_front(C);
            } else {
                deq.push_back(C);
            }
        }
    }
    if(rev) {
        reverse(deq.begin(), deq.end());
    }
    for(auto c : deq) {
        cout << c;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 4040
"use strict"
// input
function main(input) {
    let args = Number(input.split('\n')[0]);
    let total = 0;
    if (args === 0) {
        console.log(total);
    } else {
        total += Math.floor(args / 500) * 1000;
        args = Math.floor(args % 500);
        if (args !== 0) {
            total += Math.floor(args / 5) * 5;            
        }
        console.log(total);
    }
}

// output
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a, n) \
    REP(i, n) { cout << (a[i]) << (i == n - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll n, a, b;

class mint
{
public:
    ll a;

    mint(const ll x = 0) : a(x % MOD) {}
    ll &value() { return a; }
    mint pow(ll rhs)
    {
        ll exp = rhs;
        mint res = mint(1);
        mint p = mint(a);
        while (exp)
        {
            if (exp & 1)
            {
                res *= p;
            }
            exp >>= 1;
            p *= p;
        }
        return res;
    }
    mint pow(mint rhs)
    {
        return pow(rhs.a);
    }
    mint &operator+=(ll rhs)
    {
        a += rhs;
        if (a >= MOD)
        {
            a -= MOD;
        }
        return *this;
    }
    mint &operator+=(mint rhs)
    {
        *this += rhs.a;
        return *this;
    }
    mint &operator-=(ll rhs)
    {
        if (a < rhs)
        {
            a += MOD;
        }
        a -= rhs;
        return *this;
    }
    mint &operator-=(mint rhs)
    {
        *this -= rhs.a;
        return *this;
    }
    mint &operator*=(ll rhs)
    {
        a = a * rhs % MOD;
        return *this;
    }
    mint &operator*=(mint rhs)
    {
        *this *= rhs.a;
        return *this;
    }
    mint &operator/=(ll rhs)
    {
        *this *= mint(rhs).pow(MOD - 2);
        return *this;
    }
    mint &operator/=(mint rhs)
    {
        *this /= rhs.a;
        return *this;
    }
};

mint operator+(const mint &lhs, const mint &rhs)
{
    return mint(lhs.a) += rhs;
}
mint operator+(const mint &lhs, const ll &rhs)
{
    return mint(lhs.a) += rhs;
}
mint operator+(const ll &lhs, const mint &rhs)
{
    return mint(lhs) += rhs;
}
mint operator-(const mint &lhs, const mint &rhs)
{
    return mint(lhs.a) -= rhs;
}
mint operator-(const mint &lhs, const ll &rhs)
{
    return mint(lhs.a) -= rhs;
}
mint operator-(const ll &lhs, const mint &rhs)
{
    return mint(lhs) -= rhs;
}
mint operator*(const mint &lhs, const mint &rhs)
{
    return mint(lhs.a) *= rhs;
}
mint operator*(const mint &lhs, const ll &rhs)
{
    return mint(lhs.a) *= rhs;
}
mint operator*(const ll &lhs, const mint &rhs)
{
    return mint(lhs) *= rhs;
}
mint operator/(const mint &lhs, const mint &rhs)
{
    return mint(lhs.a) /= rhs;
}
mint operator/(const mint &lhs, const ll &rhs)
{
    return mint(lhs.a) /= rhs;
}
mint operator/(const ll &lhs, const mint &rhs)
{
    return mint(lhs) /= rhs;
}

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

    mint A = mint(1);
    REP(i, a)
    {
        A = A * mint(n - i);
        A = A / mint(i + 1);
    }
    mint B = mint(1);
    REP(i, b)
    {
        B = B * mint(n - i);
        B = B / mint(i + 1);
    }
    mint ans = mint(2).pow(mint(n)) - 1 - A - B;

    OUT(ans.a);
}


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

long long int dp[405][405];
long long int sum[405];
int main(){
    int N;
    cin >> N;
    int i,j,k,l;
    long long int a[N];
    long long int tmp;
    for(i=0;i<N;i++)cin >> a[i];
    for(i=1;i<N+1;i++)sum[i] = sum[i-1] + a[i-1];
    for(i=1;i<N;i++){
        for(j=0;j<N-i;j++){
            tmp=0;
            for(k=0;k<i;k++){
                if(k==0)tmp=dp[j][j+k]+dp[j+k+1][j+i];
                else tmp=min(tmp,dp[j][j+k]+dp[j+k+1][j+i]);
            }
            dp[j][j+i]=sum[j+i+1]-sum[j]+tmp;
            }
        }
    cout << dp[0][N-1] << endl;
}

Measured memory_bytes: 1536
#include<iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <stack>
#include <cmath>
using namespace std;
struct xl
{
    int x,l;
};
bool cmp(xl a,xl b)
{
    return a.l<b.l;
}
int main()
{
    int n;
    cin>>n;
    xl a[n+5];
    for(int i=0;i<n;i++)
    {
        int a1,a2;
        cin>>a1>>a2;
        a[i].x=a1-a2;
        a[i].l=a1+a2;
    }
    sort(a,a+n,cmp);
    int ans=0;
    if(n>0)
    {
        ans=1;
        int temp=a[0].l;
        for(int i=0;i<n;i++)
        {
            if(a[i].x>=temp)
            {
                temp=a[i].l;
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

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

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;


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

	ll a = n / 2;
	ll b = n - a;

	println(a * b);
}

Measured memory_bytes: 3608
#include <stdio.h>
int main(void) {
  int a = 0, b = 0, i, point;
  for( i = 0; i < 4; i++) {
    scanf("%d",&point);
    a += point;
  }
  for( i = 0; i < 4; i++) {
    scanf("%d",&point);
    b += point;
  }
  printf("%d\n",a>b?a:b);
  return(0);
}

Measured memory_bytes: 592
import sys
from operator import attrgetter
import heapq

def main():
    N,M = [int(i) for i in sys.stdin.readline().strip().split()]
    works = [[] for i in range(10**5+1)]
    ans = 0
    for i in range(N):
        A,B = [int(i) for i in sys.stdin.readline().strip().split()]
        heapq.heappush(works[A], -B)
    
    avaiable_works = []
    for i in range(1, M+1):
        for item in works[i]:
            heapq.heappush(avaiable_works, item)
        if len(avaiable_works) > 0:
            revenue = abs(heapq.heappop(avaiable_works))
        else:
            continue
        ans += revenue
    
    print("%d" % ans)

def solve(N, M, works):
    ans = 0

    return 0

if __name__ == "__main__":
    main()

Measured memory_bytes: 68384
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,k;
	cin>>a>>b>>k;
	if(a<=k)
	{
		if(a+b<k)
		{
			cout<<"NO"<<endl;
			return 0;
		}
		else
		{
			cout<<"YES"<<endl;
		}
	}
	else
	{
		cout<<"NO"<<endl;
		return 0;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<char>> a(h,vector<char>(w));
  rep(i,h){
    rep(j,w){
      cin >> a.at(i).at(j);
    }
  }
  vector<vector<int>> te(h,vector<int>(w,-1));
  queue<pair<int,int>> q;
  rep(i,h){
    rep(j,w){
      if(a.at(i).at(j)=='#'){
        q.push(make_pair(i,j));
        te.at(i).at(j)=0;
      }
    }
  }
  while(q.size()){
    auto z=q.front();
    q.pop();
    rep(i,4){
      int nx=dx[i]+z.first;
      int ny=dy[i]+z.second;
      if(!(nx>=0&&ny>=0&&nx<h&&ny<w))
        continue;
      if(te.at(nx).at(ny)!=-1)
        continue;
      q.push(make_pair(nx,ny));
      te.at(nx).at(ny)=te.at(z.first).at(z.second)+1;
    }
  }
  int m=0;
  rep(i,h){
    rep(j,w){
      m=max(m,te.at(i).at(j));
    }
  }
  cout << m << endl;
}

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

using namespace std;

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

	int a, b, c;
	cin >> a >> b >> c;
	int n5 = 0, n7 = 0;
	if (a == 5)
		n5++;
	else if (a == 7)
		n7++;
	if (b == 5)
		n5++;
	else if (b == 7)
		n7++;
	if (c == 5)
		n5++;
	else if (c == 7)
		n7++;
	if ((n5 == 2) && (n7 == 1))
		cout << "YES";
	else
		cout << "NO";
	return 0;
}

Measured memory_bytes: 256
Figures = {"A": [[0, 1], [1, 0], [1, 1]],
           "B": [[1, 0], [2, 0], [3, 0]],
           "C": [[0, 1], [0, 2], [0, 3]],
           "D": [[1, -1], [1, 0], [2, -1]],
           "E": [[0, 1], [1, 1], [1, 2]],
           "F": [[1, 0], [1, 1], [2, 1]],
           "G": [[0, 1], [1, -1], [1, 0]]}
while True:
    try:
        k = [map(int, list(input())) for i in range(8)]
        l = [[y, x] for y,q in enumerate(k) for x,t in enumerate(q) if t]
        a, b = l[0]
        for i in range(4):
            l[i][0] -= a
            l[i][1] -= b
        for k, v in Figures.items():
            if l[1:] == v:
                print(k)
                break
        input()
    except:
        break

Measured memory_bytes: 7792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#define int long long
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
    int N;
    cin >> N;
    vector<int> A(N), P(N), Q(N);
    for (int i = 0; i < N; i++) { cin >> P[i]; A[i] = i+1; }
    for (int i = 0; i < N; i++) cin >> Q[i];
    int p, q, cnt = 0;
    while (true) {
        if (A == P) p = cnt;
        if (A == Q) q = cnt;
        if (!next_permutation(A.begin(), A.end())) break;
        cnt++;
    }
    
    cout << abs(p-q) << endl;
    return 0;
}

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

using namespace std;
using int64 = long long;

int main() {
    int n, q;
    string s;
    cin >> n >> q >> s;
    vector<int> ac(n, 0);
    for (int i=0; i<n-1; i++) {
        ac[i+1] = ac[i];
        if (s[i]=='A' && s[i+1]=='C')
            ac[i+1]++;
    }

    for (int i=0; i<q; i++) {
        int l, r;
        cin >> l >> r;
        l--; r--;
        cout << ac[r]-ac[l] << endl;
    }
}


Measured memory_bytes: 1472
#include <bits/stdc++.h>
 
using namespace std;
 
 
 
typedef long long ll;
 
int n;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll sum = 0;
    cin >> n;
    for(int i = 1; i <= n; i++)
        if(i % 3 > 0 && i % 5 > 0)
            sum += i;
    cout << sum << "\n";
    return 0;
}

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

int main() {
  long A, B, C, X, Y;

  std::cin >> A;
  std::cin >> B;
  std::cin >> C;
  std::cin >> X;
  std::cin >> Y;

  std::vector<long> ans(3);
  ans[0] = A*X + B*Y;

  if (X>Y) {
    ans[1] = C*2*X;
    ans[2] = C*2*Y + A*(X-Y);
  } else {
    ans[1] = C*2*Y;
    ans[2] = C*2*X + B*(Y-X);
  }

  std::sort(ans.begin(), ans.end());

  std::cout << ans[0] << std::endl;

  return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

S = deque(input())

ans = 0
while S:
	if len(S) == 1:
		S.pop()
	elif S[0] == S[-1]:
		S.pop()
		S.popleft()
	else:
		if S[0] == "x":
			S.append("x")
			ans += 1
		elif S[-1] == "x":
			S.appendleft("x")
			ans += 1
		else:
			print(-1)
			break
else:
	print(ans)

Measured memory_bytes: 5972
class CaesarCipher
  def initialize(str)
    @str_arr = str.split(" ")
    @alphabet = ("a".."z").to_a
  end

  def decipher
    first_word = @str_arr.first.split("").map{|c| c.ord - "a".ord}
    answer = ""
    step_number = 0
    1.step(30, 1) do |i|
      temp = []
      @str_arr.length.times do |j|
        temp.push @str_arr[j].split("").map {|c, s = i|
          if c != "."
            @alphabet[c.ord - "a".ord - s]
          else
            c
          end
        }.join("")
      end
      answer = temp.join(" ")
      break if answer.index("the") || answer.index("this") || answer.index("that")
    end
    answer
  end
end

while line = gets do
  caesar_cipher = CaesarCipher.new(line.chomp)
  puts caesar_cipher.decipher
end

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

int main() {
  int n;cin>>n;
  vector <int> v(n);
  vector <int> c(n);
  int ans=0;

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

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


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

#define ll long long
#define M 1000000007
#define deb(x) cout<<#x<<" "<<x<<endl;
#define foi(a,b) for(int i=a;i<b;i++)
#define foj(a,b) for(int j=a;j<b;j++)
#define fod(a,b) for(int i=a;i>b;i--)
#define MAX  1e9
#define MIN -1e9
#define nl cout<<"\n";
#define show(arr,a,b) for(int i=a;i<b;i++) cout<<arr[i]<<" "; cout<<endl;
#define  mp(a,b) pair<ll,ll> p(a,b)
#define pb push_back
typedef pair<ll,ll> p1;
typedef vector<ll> vecd;
typedef vector<string> vecsd;
typedef map<ll,ll> mpd;
typedef set<ll> setd;
typedef multiset<ll> msetd;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k; cin>>n>>k;
    ll arr[n];
    foi(0,n) cin>>arr[i];
    ll dp[n]={0};
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    foi(2,n) dp[i]=INT_MAX;
    foi(2,n){
        foj(i-k>=0?i-k:0,i){
            dp[i]=min(dp[j]+abs(arr[i]-arr[j]),dp[i]);        
        }
    }
    cout<<dp[n-1]<<"\n";
    return 0;
}


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

int main() {
  int n, D;
  cin >> D >> n;
  int ans;
  if(D==0){
    if(n==100) ans = 101;
    else ans = n;
  }
  else if(D==1) {
    if(n==100) ans = 10100;
    else ans = n*100;
  }
  else {
    if(n==100) ans = 1010000;
    else ans = n*10000;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
template<class T> inline int add(T& a, T b, T M = MOD){a=(a+M)%M;b=(b+M)%M;a=(a+b)%M;return a;};
template<class T> inline int mul(T& a, T b, T M = MOD){if(a>=M)a%=M;if(b>=M)b%=M;a*=b;if(a>=M)a%=M;return a;};
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
////////////////////////////////////////////////////////////////////

int n,k, ans, sum;P p[110000];
priority_queue<P, vector<P>, greater<P>> que;
int cnt[110000];
signed main(){
  cin>>n>>k;
  rep(i,n){
    cin>>p[i].second>>p[i].first;
  }
  sort(p,p+n,greater<P>());
  int v = 0;
  rep(i,k){
    ans += p[i].first;
    sum += p[i].first;
    if(cnt[p[i].second] == 0)v++;
    cnt[p[i].second]++;
    que.push(p[i]);
  }
  ans += v*v;
  repd(i, k, n){
    int t = p[i].second, d = p[i].first;
    if(cnt[t] >= 1)continue;
    int b = false;
    while(!que.empty()){
      if(cnt[que.top().second] > 1){
        b = true;v++;
        sum -= que.top().first;
        sum += d;
        cnt[que.top().second]--;
        cnt[t]++;
        que.pop();
        que.push(p[i]);
        break;
      }
      que.pop();
    }
    if(b){
      chmax(ans, sum+v*v);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4724
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define mt make_tuple
#define ll long long
#define eb emplace_back
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define scanVec(vec , n) for(int i = 0; i < n ; i++){ cin>>vec[i];}
#define printVec(vec , n) for(int i = 0; i < n ; i++){ cout<<vec[i]<<" ";}
#define mod(a,b) ((a%b +b)%b)
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
#define max(a,b) (a<b?b:a)
#define min(a,b) (a>b?b:a) 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define lastEle(vec) vec[vec.size()-1] 
#define SZ(x) ((int)((x).size()))
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++) 
#define ll long long 
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define INF 1001001001
#define PI 3.1415926535897932384626
 
using namespace std;
 using namespace __gnu_pbds;
 template <typename T>
 using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
 
//----------------------------------------------------------------------------------------------------------------------
 
#define p 101 
#define MOD 1000000007 
  
void swap(int &a, int & b){
    int temp = a;
    a = b;
    b = temp;
 
}
 
 
    //     ll l = -1,  r  = exp;
    // ll ans = exp + 50;
    // while (l + 1 < r) {
    //     ll c = (l + r) / 2;
    //     if ( str + c > in + (exp - c) ){
    //         ans = min(ans,c);
    //         r = c;
    //     }else{
    //         l = c;
    //     }
    // }
 
char graph[5005][50005];
vector<bool> used;
int n;
int first,second,third;
 
void dfs( int root, int grandFather, int father ){
    used[root] = true;
    for(int i = 0;i < n;i++){
        if(graph[root][i] == '1'){
            if(grandFather == i){
                first = grandFather; second = father; third = root;
                return;
            }
            if(!used[i]){
                dfs(i,father,root);
            }
 
        }
    }
}
 
 
int main() {
   string s; cin >> s;
   if(s[0] == 'S'){
       cout << "Cloudy";
   }else if(s[0] == 'C'){
       cout << "Rainy";
   }else{
       cout << "Sunny";
   }

   return 0; 
} 


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define F first
#define S second
using namespace std;
int n,m;
char c[1010][1010];
queue< pair<int, PII> > q;
bool visit[1010][1010];
int d1[4]={0,0,1,-1};
int d2[4]={1,-1,0,0};
int res=0;
inline bool ok(int x,int y)
{
	return x>=0 && y>=0 && x<n && y<m && !visit[x][y];
}
int main()
{
	cin >>n>>m;
	for (int i=0;i<n;i++)
	{
		scanf("%s",&c[i]);
		for (int j=0;j<m;j++)
		{
			if (c[i][j]=='#')
			{
				q.push(MP(0,MP(i,j)));
				visit[i][j]=1;
			}
		}
	}
	while (!q.empty())
	{
		int t=q.front().F;
		int x=q.front().S.F;
		int y=q.front().S.S;
		q.pop();
		res=max(res,t);
		for (int i=0;i<4;i++)
		{
			int xi=x+d1[i];
			int yi=y+d2[i];
			if (!ok(xi,yi)) continue;
			visit[xi][yi]=1;
			q.push(MP(t+1,MP(xi,yi)));
		}
	}
	cout <<res;
	return 0;
}

Measured memory_bytes: 14352
import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    n, y = map(int, input().split())
    for i in range(n+1):
        for j in range(n+1):
            if n - i - j < 0:
                continue
            if i * 10000 + j * 5000 + (n-i-j) * 1000 == y:
                print(i, j, n-i-j)
                exit()

    print(-1, -1, -1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int NUM = 2e5 + 5;

int main(){
    ios
    int num_tests=1; 
    //cin>>num_tests;
    while(num_tests-->0){
        string s; cin>>s;
        int n = s.size();
        char curr = 'R';
        int count[2];
        count[0]=0; count[1]=0;
        int ans[n];
        int lastp = -1;
        memset(ans,0,sizeof(ans));
        for(int i=0;i<n;i++){
            if(s[i]==curr) count[i%2]++;
            else{
                if(s[i]=='L'){
                    lastp = i-1;
                    ans[lastp] += count[lastp%2];
                    ans[lastp+1] += count[(lastp+1)%2];
                }
                else{
                    ans[lastp] += count[lastp%2];
                    ans[lastp+1] += count[(lastp+1)%2];
                }
                count[0]=0;
                count[1]=0;
                curr=s[i];
                count[i%2]++;
            }
        }
        ans[lastp] += count[lastp%2];
        ans[lastp+1] += count[(lastp+1)%2];
        for(auto x:ans) cout<<x<<" ";
    }   
}


Measured memory_bytes: 1104
// https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_e
// パナソニックプログラミングコンテスト2020
// E - Three Substrings

/*
Problem.
文字列が3つ与えられて、それらを部分文字列とする、
最短の文字列の長さを求めよ。
Point.
文字列a,bについて
for(0<=i<a.len) for(0<=j<b.len) match(a[i], b[j]) ?
とした時、aを基準としたbの位置がi - jの時について、
最大でmin(a.len, b.len)だけ文字比較が行われる。
つまり、ab[i - j + 10000]は最大でmin(a.len, b.len)回値が更新されうる。
abをfalseで初期化している時、重なっていても齟齬が起きない位置関係i-jについては、
ab[i - j + 10000]はfalseのままで、齟齬が起きる位置関係についてはtrueとなる。
*/

#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>

using namespace std;
using ll = long long;

#define INF 1e4

bool match(char c1, char c2){
  return (c1 == '?' || c2 == '?' || c1 == c2);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  string a, b, c;
  cin >> a >> b >> c;
  vector<bool> ab(20000, false), ac(20000, false), bc(20000, false);
  int A = a.length();
  int B = b.length();
  int C = c.length();

  for(int i = 0; i < A; i++){
    for(int j = 0; j < B; j++){
      if(!match(a[i], b[j])) ab[i-j+10000] = true;
    }
  }
  for(int i = 0; i < A; i++){
    for(int j = 0; j < C; j++){
      if(!match(a[i], c[j])) ac[i-j+10000] = true;
    }
  }
  for(int i = 0; i < B; i++){
    for(int j = 0; j < C; j++){
      if(!match(b[i], c[j])) bc[i-j+10000] = true;
    }
  }
  int ans = 6000;
  for(int i = -4000; i <= 4000; i++){
    for(int j = -4000; j <= 4000; j++){
      if(!ab[i + 10000] && !ac[j + 10000] && !bc[j - i + 10000]){
        int L = min(0, min(i, j));
        int R = max(A, max(B + i, C + j));
        ans = min(ans, R - L);
      }
    }
  }
  cout << ans << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 256