akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
using namespace std;

int main()
{
	string s;
	cin >> s;
	int counter = 0;
	if (s.at(0) == '1') {
		counter++;
	}
	if (s.at(1) == '1') {
		counter++;
	}
	if (s.at(2) == '1') {
		counter++;
	}
	cout << counter << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <string.h>
#include <math.h>
#include <map>
#include <time.h>
using namespace std;

int main(){
	int N, ans = 0;
	string A, B, C;

	cin >> N >> A >> B >> C;

	for (int i = 0; i < N; ++i){
		map<char, int> m;
		++m[A[i]];
		++m[B[i]];
		++m[C[i]];
		ans += m.size() - 1;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("YES\n")
#define ptn printf("NO\n")
//==========================Code here==========================
LL m, k;
int main() {
	cin >> m >> k;
	LL gg = 0;
	for (LL i = 0; i < (1 << m); ++i) if (i != k) gg ^= i;
	if (k == 0) {
		for (LL i = 0; i < (1 << m); ++i) printf("%lld %lld ", i, i);
		return 0;
	}
	if (gg != k) return printf("-1\n"), 0;
	printf("%lld ", k);
	for (LL i = 0; i < (1 << m); ++i) if (i != k) printf("%lld ", i);
	printf("%lld ", k);
	for (LL i = (1 << m) - 1; i >= 0; --i) if (i != k) printf("%lld ", i);
	return 0;
}

Measured memory_bytes: 1792
import java.util.*;
import static java.lang.System.*;
import java.math.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();
		char[] T = sc.next().toCharArray();
		int cnt = 0;
		for(int i = 0; i < S.length; i++) {
			if (S[i] == T[i])
				cnt++;
		}
		out.println(cnt);
		
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <bits/stdc++.h>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define INF 1000000000
#define MOD 1000000007
#define PI acos(-1)
#define M 998244353
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ll long long
#define endl "\n"
#define fori(i, a, b) for(i=a; i<b; i++)
#define ford(i, a, b) for(i=a; i>b; i--)
using namespace std;
const ll N = 500043;
ll fact[N];
ll add(ll x, ll y)
{
	x += y;
	while(x >= MOD) x -= MOD;
	while(x < 0) x += MOD;
	return x;
}
ll mul(ll x, ll y)
{
	return (x * 1ll * y) % MOD;
}
ll mulmod(ll a, ll b)
{
    ll res = 0;
    a = a % MOD;
    while (b>0)
    {
        if (b % 2 == 1)
            res = (res + a) % MOD;
        a = (a * 2) % MOD;
        b /= 2;
    }
    return res % MOD; 
}
ll binpow(ll x, ll y)
{
	ll z = 1;
	while(y > 0)
	{
		if(y % 2 == 1)
			z = mul(z, x);
		x = mul(x, x);
		y /= 2;
	}
	return z;
}
ll inv(ll x)
{
	return binpow(x, MOD - 2);
}
ll divide(ll x, ll y)
{
	return mul(x, inv(y));
}
void precalc()
{
	fact[0] = 1;
	ll i;
	fori(i, 1, N)
		fact[i] = mul(i, fact[i - 1]);
}
ll C(ll n, ll k)
{
	if(k > n)
	    return 0;
	return divide(fact[n], mul(fact[n-k], fact[k]));
}

void solve()
{
    ll n;
    cin >> n;
    ll a[n];
    ll freq[100043];
    memset(freq, 0, sizeof(freq));
    ll i, sum=0;
    fori(i, 0, n)
    {
        cin >> a[i];
        sum += a[i];
        freq[a[i]]++;
    }
    ll q;
    cin >> q;
    ll b, c;
    while(q--)
    {
        cin >> b >> c;
        sum = sum + (c-b)*freq[b];
        freq[c] += freq[b];
        freq[b] = 0;
        cout << sum << endl;
    }
}
signed main()
{
    io
    int t;
    t=1;
    // cin >> t;
    while(t--)
        // cout << solve() << endl;
        solve();
    return 0;
}

Measured memory_bytes: 5220
n = int(input())
A = list(map(int, input().split()))

d = dict()
for a in A:
    d[a] = d.get(a, 0) + 1

two, four = [], []
for k, v in d.items():
    if v >= 2:
        two.append(k)
    if v >= 4:
        four.append(k)

two = sorted(two)
four = sorted(four)
ans = []
if four != []:
    ans.append(four[-1]**2)
if len(two) >= 2:
    ans.append(two[-1]*two[-2])

if ans == []:
    print(0)
else:
    print(max(ans))

Measured memory_bytes: 18060
#include<iostream>
#include<vector>
using namespace std;
const int BIG = 1e5+1;
int main(){
  int n;
  cin >> n;
  int t[BIG],x[BIG],y[BIG];
  t[0]=0,x[0]=0,y[0]=0;
  for(int i=1;i<=n;i++){
    cin >> t[i] >> x[i] >> y[i];
  }
  int dt,dx,dy;
  int can = 1;
  for(int i=1;i<=n;i++){
    dt = t[i]-t[i-1];
    dx = abs(x[i]-x[i-1]);
    dy = abs(y[i]-y[i-1]);
    if(dt >= dx+dy && (dt-dx-dy) %2 == 0){
      //
    }else{
      //cout << dt << dx << dy;
      can = 0;
      break;
    }
  }
  if(can){
    cout << "Yes";
  }else{
    cout <<  "No";
  }
}


Measured memory_bytes: 1408
from collections import Counter 
from collections import defaultdict
from collections import deque
from functools import reduce
import math
import itertools
import heapq
import numpy as np
import bisect
import sys
sys.setrecursionlimit(10**6)


def bfs(s,n,node):
    #頂点が探索済みかどうかのチェック配列
    check=[False for _ in range(n)]
    check[s]=True
    #次見る頂点を格納するキュー
    queue=deque([s])
    visited_num=1

    #問題固有の配列
    #color_check=[[True for _ in range(l)] for _ in range(n)]
    color=[-1 for _ in range(n)]
    color[s]=0
    
    while visited_num<n:
        #グラフが全連結ではない場合
        if len(queue)==0:
            #空配列を返す
            #現状までの計算済み配列を返してもいいと思う
            return color

        now_vertex=queue.popleft()
        #インデックスがない場合は
        for next_vertex in node[now_vertex]:


            if check[next_vertex]==True:
                continue

            queue.append(next_vertex)
            check[next_vertex]=True

            #問題固有の計算
            color[next_vertex]=color[now_vertex]+1
            visited_num+=1

    return color

#n=int(input())z
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
ceil=lambda x,y: (x+y-1)//y
input_list = lambda : list(map(int,input().split()))



#n=int(input())
#n,m=input_list()
a=input_list()

s=a[0]*60+a[1]
e=a[2]*60+a[3]
print(e-s-a[4])



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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;

void solve() {

}

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  int cnt = 0;
  rep(i,n) {
    if( i-1>=0 && i+1<n ) {
      priority_queue<int> Q;
      Q.push(p[i-1]);
      Q.push(p[i]);
      Q.push(p[i+1]);
      Q.pop();
      if( Q.top() == p[i] ) {
	++cnt;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


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

int main() {
    vector<pair<int, int>> A(5);
    for (int i = 0; i < 5; i++) {
        cin >> A[i].second;
        A[i].first = A[i].second % 10;
        if (A[i].first == 0) A[i].first += 10;
    }
    
    sort(A.begin(), A.end());
    int ans = 0;
    for (int i = 1; i < 5; i++) {
        int add = A[i].second + (10-A[i].first)%10;
        ans += add;
    }
    ans += A[0].second;
    cout << ans << endl;
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    string S[N];
    double X[N];
    double ans;

    for(int i=0;i<N;i++){
        cin>> X[i]>> S[i];
        if(S[i]=="JPY")ans += X[i];
        else ans+= 380000*X[i];
    }
  
  cout <<ans;

}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i < n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i < n; i++)

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::pair<ll, ll> pll;

using namespace std;

class UnionFind {
public:
    v_ll parents; 
    v_ll size; 

    // Constructor
    UnionFind(ll size_): parents(size_), size(size_, 1) {
       lrep(i, size_) { parents[i] = i; }
    }

    void init(ll size_) {
        parents.resize(size_);
        size.assign(size_, 1);
        lrep(i, size_) { parents[i] = i; }
        //cout << "Union find init." << endl; print();
    }

    // Find
    ll root(ll x) { 
        while (parents[x] != x) {
            x = parents[x] = parents[parents[x]]; 
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (size[x] < size[y]) swap(x, y);
        size[x] += size[y];
        parents[y] = x;
        //cout << "Union find merge(" << x << "," << y << ")" << endl; print();
        return true;
    }

    bool issame(ll x, ll y) { 
        return root(x) == root(y);
    }

    ll get_size(ll x) {
        return size[root(x)];
    }
    
    void print() {
        for(size_t i = 0; i < parents.size(); i++) {
            cout << "parents[" << i << "]," << parents[i] << ",size," << size[i] << endl;
        }
    }
};

int main() {

    ll N, M, a, b;
    cin >> N >> M;
    vector<pll> vec(M);
    lrep(i, M) {
        cin >> a >> b; 
        --a, --b;
        vec[i].first = a;
        vec[i].second = b;
    }

    UnionFind uf(N);
    ll res = 0;
    lrep(i, M) {
    //ll i = 0;
        uf.init(N);
        lrep(j, M) {
            if (j == i) continue;
            uf.merge(vec[j].first, vec[j].second);
        }
        if (uf.get_size(0) < N) res++;
    }

    cout << res << endl;

    return 0;
}


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

int main() {
    long long n, m, d;
    scanf("%lld%lld%lld", &n, &m, &d);
    double ans;
    if (d == 0) ans = (double)(m-1)/n;
    else ans = (double)((n-d)*2*(m-1))/(n*n);
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    static ll a[100000];
    REP(i,n){
        cin >> a[i];
    }
    ll be = 0;
    while(1){
        ll b = INF;
        sort(a+be,a+n);
        //REP(i,n)cout << a[i] << " ";
        //cout << endl;
        if(be>=n-1 || b==1 || b==0){
            cout << a[n-1] << endl;
            return 0;
        }
        FOR(i,be,n){
            if(a[i]==1){
                cout << "1" << endl;
                return 0;
            }
            if(b!=0&&b!=1&&b!=INF){
                a[i] %= b;
            }else if(a[i]!=0 && a[i]!=1){
                b = a[i];
                be = i;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define lb long double
#define pb push_back
#define qwerty1 first
#define qwerty2 second
#define qwerty3 -> first
#define qwerty4 -> second
#define umap unordered_map
#define uset unordered_set
#define pii pair < int , int >
#define pq priority_queue

using namespace std;

const int N = 100005;
const int M = 1000000007;
const lb PI = acos(-1);

ll a , b , c , k;

int main()
{
    ios_base::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);

    ll s;

    cin >> a >> b >> c >> k;

    if(k <= a)
        cout << k;
    else
    {
        s = a;
        k -= a;

        if(k <= b)
            cout << s;
        else
        {
            k -= b;

            cout << s - k;
        }
    }

    return 0;
}


Measured memory_bytes: 3652
package main

import (
	"bufio"
	"errors"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	for stdin.Scan() {
		in := stdin.Text()
		out, _ := do(in)
		fmt.Println(out)
	}

}

func do(in string) (string, error) {
	s := strings.Split(in, " ")
	if len(s) != 2 {
		return "", errors.New("len")
	}
	count, err := strconv.Atoi(s[0])
	if err != nil {
		return "", errors.New("count")
	}
	value, err := strconv.Atoi(s[1])
	if err != nil {
		return "", errors.New("value")
	}

	value = value / 1000

	var a, b, c = -1, -1, -1

	for x := 0; x <= count; x++ {
		for y := 0; y <= count; y++ {
			if 9*x+4*y == value-count && x+y <= count {
				a = x
				b = y
			}
		}
	}
	if a == -1 || b == -1 {
		c = -1
	} else {
		c = count - a - b
	}

	return strconv.Itoa(a) + " " + strconv.Itoa(b) + " " + strconv.Itoa(c), nil
}


Measured memory_bytes: 640
(defun main ()
  (let* ((n (read))
	 (s (make-array n))
	 (ac 0)
	 (wa 0)
	 (tle 0)
	 (re 0))
    (dotimes (i n)
      (setf (aref s i) (read)))
    (setf ac (- n (length (remove 'ac s))))
    (setf wa (- n (length (remove 'wa s))))
    (setf tle (- n (length (remove 'tle s))))
    (setf re (- n ac wa tle))
    (format t "AC x ~a~%" ac)
    (format t "WA x ~a~%" wa)
    (format t "TLE x ~a~%" tle)
    (format t "RE x ~a~%" re)))

(main)

Measured memory_bytes: 76860
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int a = saori.saori_hayami();
		int b = saori.saori_hayami();
		if(a-b > 0){
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 23124
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<functional>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX


signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int ans = 1;
	int  N;
	vector<int> l, A, B;
	
	
	cin>>N;
	
	A.resize(N);

	for(int i = 0; i < N; i++){
		cin>>A[i];
	}
	reverse(A.begin(), A.end());
	
	for(int i = 0; i < N; i++){
		if(l.size() == 0 || l.back() <= A[i]){
			l.push_back(A[i]);
		} else {
			int it = upper_bound(l.begin(), l.end(), A[i]) - l.begin();
			l[it] = A[i];
		}
	}
	
	
	cout<<l.size()<<endl;
	
	return 0;
}

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

int main(){
	int x , y, temp;
	cin >> x >> y;
	while(x != 0 || y != 0){
		if (x > y){
			temp = x;
			x = y;
			y = temp;
		}
	cout << x << " " << y << endl ;
	
	cin >> x >> y;
	}
	
	return 0;
}

Measured memory_bytes: 3084
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int xs = sc.nextInt();
		int ys = sc.nextInt();
		int xt = sc.nextInt();
		int yt = sc.nextInt();
		int n = sc.nextInt();
		Obj[] arr = new Obj[n + 2];
		for (int i = 1; i <= n; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			int r = sc.nextInt();
			Obj o = new Obj(i, x, y, r, 1e18);
			arr[i] = o;
		}
		sc.close();

		arr[0] = new Obj(0, xs, ys, 0, 0);
		arr[n + 1] = new Obj(n + 1, xt, yt, 0, 1e18);

		PriorityQueue<Obj> que = new PriorityQueue<>((o1, o2) -> Double.compare(o1.d, o2.d));
		que.add(arr[0]);
		double[] d = new double[n + 2];
		Arrays.fill(d, 1e18);
		d[0] = 0;
		while (!que.isEmpty()) {
			Obj cur = que.poll();
			if (cur.d != d[cur.i]) {
				continue;
			}
			for (int i = 1; i < n + 2; i++) {
				Obj next = arr[i];
				double dd = Math.hypot(cur.x - next.x, cur.y - next.y);
				double alt = cur.d + Math.max(dd - cur.r - next.r, 0);
				if (alt < d[i]) {
					que.add(new Obj(i, next.x, next.y, next.r, alt));
					d[i] = alt;
				}
			}
		}
		System.out.println(d[n + 1]);
	}

	static class Obj {
		int i, x, y, r;
		double d;

		public Obj(int i, int x, int y, int r, double d) {
			this.i = i;
			this.x = x;
			this.y = y;
			this.r = r;
			this.d = d;
		}
	}
}


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

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

    static class AAccepted {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            char[] c = in.next().toCharArray();
            int res = 0;
            for (char ch : c) {
                if (ch == '1') res++;
            }
            out.println(res);
        }

    }
}



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

const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    cout << *max_element(a.begin(),a.end())-*min_element(a.begin(),a.end()) << endl;
    return 0;
}

Measured memory_bytes: 256
let i_inp_list : unit -> int list = fun () ->
  let inp_split = Str.split (Str.regexp " ") (input_line stdin) in
  List.map (fun x -> int_of_string x) (inp_split)

let rec inp_loop : (unit -> 'a) -> int -> 'a list = fun inp_fun n ->
  if n = 0 then []
  else
    let x = inp_fun () in
    x :: inp_loop inp_fun (n - 1)
    
let rec d2 p q sum =
  match (p, q) with
    ([], []) -> sum
  | (x :: xs, y :: ys) ->
     d2 xs ys (sum + (x - y) * (x - y))
  | _ -> raise (Failure "Invalid input")
    
let check p q =
  let d2' = d2 p q 0 in
  let d = int_of_float (sqrt (float_of_int d2')) in
  d * d = d2'
    
let () =
  let (n, d) = Scanf.sscanf (input_line stdin) "%d %d" (fun a b -> (a, b)) in
  let l = inp_loop i_inp_list n in
  let rec pairs : 'a list -> int = function
      [] -> 0
    | x :: xs -> List.fold_left
                   (fun sum y ->
                     if check x y then
                       sum + 1
                     else
                       sum) 0 xs
                 + (pairs xs)
  in
  let ans = pairs l in
  print_int ans;
  print_newline ()


Measured memory_bytes: 384
use proconio::input;

fn main() {
    input! {
        n: i32,
        m: usize,
        a: [i32; m]
    }

    solve(n, &a);
}

fn solve(n: i32, a: &[i32]) {
    let s = n - a.iter().fold(0, |s, x| s + x);
    match s.cmp(&0) {
        std::cmp::Ordering::Less => println!("-1"),
        _ => println!("{}", s),
    }
}


Measured memory_bytes: 2204
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        String[] cards = new String[52];
        char[] suto = { 'S', 'H', 'C', 'D' };
        for (int i = 0; i < 4; i++) {
            for (int j = 1; j <= 13; j++) {
                cards[i * 13 + j - 1] = "" + suto[i] + " " + j + "%n";
            }
        }

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());

        for (int i = 0; i < n; i++) {
            String card = sc.nextLine();
            for (int j = 0; j < 52; j++) {
                // System.out.println("card=" + card + " cards[" + j + "]=" + cards[j]);
                if (cards[j].equals(card + "%n")) {
                    cards[j] = "";
                    break;
                }
            }
        }

        for (int i = 0; i < 52; i++) {
            System.out.printf(cards[i]);
        }

    }

}


Measured memory_bytes: 26392
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INF 184497440
#define MMM 200000

int temp[20][MMM] = {};

signed main(){
	int D, G, te[2][20] = {}, MA=0, ans = INF;
	cin>>D>>G; G/=100;
	for(int i = 0; i < 20; i++)
		for(int j = 1; j < MMM; j++)temp[i][j] = INF;
	temp[0][0] = 0;
	for(int i = 1; i <= D; i++){
		cin>>te[0][i]>>te[1][i];
		te[1][i] /= 100;
		MA += te[0][i]*i+te[1][i];
	}
	
	for(int i = 1; i <= D; i++){//cout<<i<<G<<"---"<<endl;
		for(int j = 0; j < MMM; j++){//cout<<temp[i][j]<<"  ";
			
			if(temp[i-1][j] == INF)continue;//cout<<i<<" "<<j<<endl;
			for(int k = 1; k <= te[0][i]; k++){//cout<<"k = "<<k<<endl;
				if(k==te[0][i]){
					//if(j < te[0][i])
					//cout<<" AA "<<j<<"+"<<te[1][i]<<"+"<<i*te[0][i]<<" "<<temp[i-1][j] + te[0][i]<<endl;
					temp[i][j+te[1][i] + i*te[0][i]] = min(temp[i][j+te[1][i] + i*te[0][i]], temp[i-1][j] + te[0][i]);
				}else{
					//if(j < i)continue;
					//cout<<temp[i-1][j]<<" A "<<k<<endl;
					temp[i][j+k*i] = min(temp[i][j+k*i], temp[i-1][j]+k);
				}
			}
			temp[i][j] = min(temp[i][j], temp[i-1][j]);
		}//cout<<endl;
	}//cout<<endl;
	/*for(int j = 1; j <= D; j++){
	for(int i = 0; i <= 10; i++){
		cout<<i<<" "<<temp[j][i]<<endl;
	}
	}
	*/
	for(int j = G; j < MMM; j++){
		ans = min(ans, temp[D][j]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 31488
#include <iostream>
#include <map>
#define maxn 200005
using namespace std;
map<long long,int> cnt;
int n;
long long ans,tmp,a;
int main(){
    cin >> n;
    cnt[0] = 1;
    for(int i = 1;i<=n;i++){
        cin >> a;
        tmp += a;
        ans += cnt[tmp];
        ++cnt[tmp];
    }
    cout << ans;
}

Measured memory_bytes: 12800
local UnionFind={}

UnionFind.getroot=function(self,x)
    local rx=self.par[x]
    return rx==x and x or self:getroot(rx)
end

UnionFind.same=function(self,x,y)
    return self:getroot(x)==self:getroot(y)
end

UnionFind.unite=function(self,x,y)
    x=self:getroot(x)
    y=self:getroot(y)
    if x==y then
        return
    end
    if self.rank[x]<self.rank[y] then
        self.par[x]=y
        self.size[y]=self.size[y]+self.size[x]
    elseif self.rank[x]>self.rank[y] then
        self.par[y]=x
        self.size[x]=self.size[x]+self.size[y]
    else
        self.rank[x]=self.rank[x]+1
        self.par[y]=x
        self.size[x]=self.size[x]+self.size[y]
    end
end

UnionFind.getsize=function(self,x)
    return self.size[self:getroot(x)]
end

UnionFind.new=function(self,n)
    local obj={par={},rank={},size={}}
    for i=1,n do
        obj.par[i]=i
        obj.rank[i]=1
        obj.size[i]=1
    end
    setmetatable(obj,{__index=UnionFind})
    return obj
end

----------

local n,k,l=io.read("n","n","n")
local road=UnionFind:new(n)
local rail=UnionFind:new(n)

for i=1,k do
    local p,q=io.read("n","n")
    road:unite(p,q)
end

for i=1,l do
    local r,s=io.read("n","n")
    rail:unite(r,s)
end

local counter={}
for i=1,n do
    local key=road:getroot(i).." "..rail:getroot(i)
    counter[key]=(counter[key] or 0)+1
end

for i=1,n do
    local key=road:getroot(i).." "..rail:getroot(i)
    io.write(counter[key].." ")
end
print()

Measured memory_bytes: 56336
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

int main(void){
	int N;
	cin >> N;
	int ans = INF;
	int sum = 0;
	vector<int> A(N);
	vector<int> S(N+1);
	for(int i = 0; i < N; i++){
		cin >> A[i];
		sum += A[i];
		S[i+1] = S[i] + A[i];
	}
	for(int i = 0; i <= N; i++){
		ans = min(ans, abs(sum - S[i] - S[i]));
	}
	cout << ans << endl;

}


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

long N, X;

int main(void) {

    while (true) {
        cin >> N >> X;
        if (N == 0 && X == 0) {
            break;
        }

        long ans = 0;
        for (long i = 1; i <= N; i++) {
            for (long j = i+1; j <= N; j++) {
                for (long k = j+1; k <= N; k++) {
                    if (i + j + k == X) {
                        ans++;
                    }
                }
            }
        }

        cout << ans << endl;
    }

    return 0;

}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  string s;
  cin>>s;
  int n=s.size(), sn=0;
  rep(i,n){ 
    int digit = s.at(i) - '0';
    sn+=digit;
  }
  int S = stoi(s);
  if(S%sn==0){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define NIL -1

struct Node{int p=NIL,l=NIL,r=NIL,d=0;};

void printTree(int n, Node T[]){
	for(int i=0;i<n;i++){
		Node nd=T[i];
		cout << "node " << i << ": ";
		cout << "parent = " << nd.p << ", ";
		cout << "depth = " << nd.d << ", ";
		if(nd.p==NIL) cout << "root";
		else if(nd.l==NIL) cout << "leaf";
		else cout << "internal node";
		cout << ", [";
		int c=nd.l;
		while(c!=NIL){
			 cout << c;
			 c = T[c].r;
			 if(c!=NIL) cout << ", ";
		}
		cout << "]" << endl;
	}
}

void setDepth(Node T[], int id, int d){
	T[id].d=d;
	if(T[id].l!=NIL) setDepth(T,T[id].l,d+1);
	if(T[id].r!=NIL) setDepth(T,T[id].r,d);
}

int main(){
	int n,i,id,j,k,c,s,r;
	cin >> n;
	Node T[n];
	for(i=0;i<n;i++){
		cin >> id >> k;
		for(j=0;j<k;j++){
			cin >> c;
			T[c].p=id;
			if(j==0)T[id].l=c;
			else T[s].r=c;
			s=c;
		}
	}
	for(i=0;i<n;i++) if(T[i].p==NIL) r=i;
	setDepth(T,r,0);
	printTree(n,T);
	return 0;
}



Measured memory_bytes: 4548
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.Arrays;
import java.lang.Math;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        String x = fs.next();
        char[] xx = x.toCharArray();

        ArrayList<Integer> summer = new ArrayList<>();

        for (int i = 0; i<xx.length;i++) {
            summer.add((int) xx[i]-48);
        }

        int sum =0;
        for (int i = 0; i<summer.size(); i++) {
            sum+=summer.get(i);
        }
        if (sum % 9 == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }




    }


    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");

        public String next() {
            while (!st.hasMoreElements())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

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

        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
    }

}



Measured memory_bytes: 39304
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();

		int area = (A-1) * (B-1);
		System.out.println(area);
	}

}


Measured memory_bytes: 22100
N = int(input())
red = list([input() for _ in range(N)])

M = int(input())
blue = list([input() for _ in range(M)])

redwords = set(red)

maxyen = 0
for word in redwords:
    red_count = red.count(word)
    blue_count = blue.count(word)
    if red_count - blue_count > maxyen:
        maxyen = red_count - blue_count

print(maxyen)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;
int main()
{
	int n;
	cin >> n;

	n-=2;
	cout << 180*n << endl;
	return 0;
}

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

using namespace std;


int main()
{
	string s;
	cin >> s;
	string reverseS = "";
	int q;
	cin >> q;
	bool gyaku = false;
	for (int i = 0; i < q; i++) {
		int t;
		cin >> t;

		if (t == 1) {
			gyaku = !gyaku;
		}
		else {
			int f; string c;
			cin >> f >> c;
			if ((!gyaku && (f == 1)) || (gyaku && (f == 2)) ) {
				reverseS = reverseS + c;
			}
			else {
				s = s + c;
			}
		}
	}


	if (gyaku) {
		for (int i = 0; i < s.length(); i++) {
			cout << s.substr(s.length() - 1 - i, 1);
		}
		cout << reverseS << endl;
	}
	else {
		for (int i = 0; i < reverseS.length(); i++) {
			cout << reverseS.substr(reverseS.length() - 1 - i, 1);
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 1520
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, k, l, ans = 1e18;
  scanf("%lld", &l);
  ll dp[l][5], a[l];
  for(i = 0; i < l; ++i) scanf("%lld", &a[i]);
  for(i = 0; i < l; ++i) for(j = 0; j < 5; ++j) dp[i][j] = 1e18;
  dp[0][0] = dp[0][4] = a[0], dp[0][1] = dp[0][3] = a[0] ? a[0] % 2 : 2, dp[0][2] = a[0] % 2 ? 0 : 1;
  for(i = 1; i < l; ++i) {
    for(j = 0; j < 5; ++j) for(k = j; k < 5; ++k) {
      if(!k || k == 4) {
        if(dp[i][k] > dp[i - 1][j] + a[i]) dp[i][k] = dp[i - 1][j] + a[i];
      } else if(k == 1 || k == 3) {
        if(dp[i][k] > dp[i - 1][j] + (a[i] ? a[i] % 2 : 2)) dp[i][k] = dp[i - 1][j] + (a[i] ? a[i] % 2 : 2);
      } else {
        if(dp[i][k] > dp[i - 1][j] + (a[i] % 2 ? 0 : 1)) dp[i][k] = dp[i - 1][j] + (a[i] % 2 ? 0 : 1);
      }
    }
  }
  for(i = 0; i < 5; ++i) if(ans > dp[l - 1][i]) ans = dp[l - 1][i];
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 9600
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
lint dp[200100][10];
lint inf=12345678901234567LL;
lint a[200100];
int main()
{
	int n;
	cin>>n;rep(i,n) cin>>a[i];a[n]=-inf;a[n+1]=0;
	rep(i,n+10) rep(j,8) dp[i][j]=-inf;
	//dp[0][0]=0;
	int lim=(n%2)+1;
	rep(i,lim+1) dp[i][i]=a[i];
	//cout<<dp[2][2]<<endl;
	rep(i,n) rep(j,lim+1) rep(k,lim-j+1){
		dp[i+k+2][j+k]=max(dp[i+k+2][j+k],dp[i][j]+a[i+k+2]);
	}
	rep(i,n) rep(j,lim+1){
		//cout<<i<<' '<<j<<' '<<dp[i][j]<<endl;
	}
	lint out=-inf;
	rep(i,lim+1) out=max(out,dp[n+1][i]);
	cout<<out<<endl;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main()
{   
    long long n, m;
    while (cin >> n >> m && n > 0) {

        vector<pair<int, int>> pd(n);
        int d, p;

        REP(i, n) {
            cin >> d; cin >> p;
            pd[i] = make_pair(p, d);
        }

        /* 各区間における襲われる期待値を昇順 */
        sort(pd.begin(), pd.end());
        
        /* 総合距離から守ることができ'ない'距離 guard を算出 */
        long long d_sum = 0;
        REP(i, n) d_sum += pd[i].second;
        long long guard = d_sum - m;

        /* guard分の期待値 p_sum を算出　*/
        long long p_sum = 0;

        for (int i = 0; i < n; i++) {
            if (guard <= 0)  break;

            if (guard >= pd[i].second) {
                guard -= pd[i].second;
                p_sum += (pd[i].first * pd[i].second);
            }

            else if (m > 0) {
                p_sum += (pd[i].first * guard);
                guard = 0;
            }
        }

        cout << p_sum << endl;
    }
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007


int main() {
	int N;
	string S;
	cin>>N>>S;
	int red=0;
	fx(N){
		if(S.at(x)=='R'){
			red++;
		}else{
			red--;
		}
	}
	if(red>0){
		ce("Yes")
	}else{
		ce("No")
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for(int i = (int)(n); i>=0; --i)
struct fast_ios { fast_ios(){cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast_ios_;

int main()
{
    int N, M;
    cin >> N >> M;
    
    int sum=0;
    vector<int> a(N);
    rep(i, N)
    {
        cin >> a[i];
        sum+= a[i];
    }

    double m4 = sum/4.0/M;
    int mm=M;
    rep(i, N)
    {
        if(a[i] >= m4)
        {
            --mm;
        }
        if(mm==0)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
int main(){
    long long n, m, ans=0;
    scanf("%lld %lld", &n, &m);
    if(n == 1 || m == 1){
        if(n == 1 && m == 1)
            ans = 1;
        else if(n == 1)
            ans = m-2;
        else
            ans = n-2;
    }
    else ans = (n-2)*(m-2);
    printf("%lld", ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = 10e9;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/

int main() {
    ll N,M;
    cin>>N>>M;
    vp e(M);
    REP(i,M){
        ll a,b;
        cin>>a>>b;
        e[i]=make_pair(a,b);
    }
    sort(e.begin(),e.end(),[](const P& e1,const P& e2){return e1.second<e2.second;});
    ll prev=0;
    REP(i,M){
        //cout<<e[i].first<<","<<prev<<","<<e[i].second<<endl;
        if(e[i].first>prev/*||e[i].second>=prev*/){
            ans++;
            prev=e[i].second-1;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

const ll INF = 1ll << 60;
ll MOD = 1e9 + 7;

int main()
{

    string s;
    cin >> s;

    cout << (s[0] == '1' ? 9 : 1);
    cout << (s[1] == '1' ? 9 : 1);
    cout << (s[2] == '1' ? 9 : 1) << endl;

    return 0;
}

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

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

using ll = int64_t;

using namespace std;

struct Sieve{

    // MAX : 1e7
    int n,p = 0;
    vector<int> prime;
    vector<bool> is_prime;

    Sieve(int n):n(n),is_prime(n+1,true){
        is_prime[0] = is_prime[1] = false;
        for(int i = 2;i <= n;i++){
            if(is_prime[i]){
                prime.push_back(i);
                p++;
                for(int j = 2 * i;j <= n;j += i) is_prime[j] = false;
            }
        }
    }

    map<int,int> prime_factor(int n){
        map<int,int> res;

        for(int i : prime){
            if(i > n) break;
            if(n % i == 0){
                int cnt = 0;
                while(n % i == 0){
                    cnt++;
                    n /= i;
                }
                res[i] = cnt;
            }
        }

        if(n != 1) res[n] = 1;

        return res;
    }

};


int main(void){
   
    int64_t n;cin >> n;
    int64_t ans = 0;
    for(int64_t i = 1;i <= n;i++){
        int64_t y = n / i;
        ans += i * (y*(y+1))/2;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
const int INF = 114514810;
const int MOD = 1000000007;
const double EPS = 1e-10;
typedef int weight;
struct edge
{
	int to; weight cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
typedef vector<vector<edge>> Graph;
//int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
int place(int x, int y, int w) { return w*x + y; }
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///


int main()
{
	int n, m;
	cin >> n >> m;
	vi to(n), v(m);
	int t = 0;
	REP(i, n)
	{
		cin >> to[i];
		if (to[i]) t++;
	}
	vector<vi> from(2);
	REP(i, m) cin >> v[i];
	REP(i, 2)
	{
		int tmp = i;
		REP(j, m)
		{
			REP(k, v[j])
			{
				from[i].push_back(tmp);
			}
			tmp = 1 - tmp;
		}
	}
	int ans = INF;
	REP(i, 2)
	{
		if (count(ALL(from[i]), 1) != t) continue;
		int cnt = 0;
		vi tmp = from[i];
		REP(j, n)
		{
			if (tmp[j] != to[j])
			{
				for (int k = j;; k++)
				{
					if (tmp[k] == to[j])
					{
						cnt += k - j;
						swap(tmp[j], tmp[k]);
						break;
					}
				}
			}
		}
		chmin(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

const int INF = 500002;
int p[102];
P dp[102][102][502];
bool visited[102][102][502];
int n;

P dfs(int pos, int r, int ex){
    if(pos == n) return P(0, 0);
    if(visited[pos][r][ex]) return dp[pos][r][ex];
    int pay = 1000;
    while(pay < p[pos]) pay += 1000;
    int nex = ex + pay - p[pos];
    int nr = r + nex / 500;
    nex %= 500;
    P ret = dfs(pos+1, r, ex);
    if(nr > 0){
        P res = dfs(pos+1, nr-1, nex);
        ret = max(ret, P(res.first + 1, res.second - p[pos]));
    }else{
        P res = dfs(pos+1, nr, nex);
        ret = max(ret, P(res.first, res.second - p[pos]));
    }
    dp[pos][r][ex] = ret;
    visited[pos][r][ex] = true;
    return ret;
}

int main(){
    while(true){
        cin >> n;
        if(n == 0) break;

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

        memset(visited, 0, sizeof(visited));
        P ans = dfs(0, 0, 0);
        cout << ans.first << " " << -ans.second << endl;
    }

    return 0;
}


Measured memory_bytes: 27976