akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
# define ll long long
#define endl "\n"
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int n,k;cin>>n>>k;
	map<int,int>m;
	while(k--)
	{
		int d;cin>>d;
		int arr[d];
		for(int i=0;i<d;i++)
		{
			cin>>arr[i];
			m[arr[i]]++;
		}
		
	}
	ll count=0;
		for(int i=1;i<=n;i++)
		{
			if(m[i]==0)
			{
				count++;
			}
		}
	cout<<count;
}

Measured memory_bytes: 3664
# EduDPA - Frog 1
n = int(input())
lst = list(map(int, input().rstrip().split()))
ans = [0] + [float("inf")] * (n - 1)
for i in range(1, n):
    ans[i] = min(ans[i], ans[i - 1] + abs(lst[i] - lst[i - 1]))
    
    if i == 1:
        continue
    ans[i] = min(ans[i], ans[i - 2] + abs(lst[i] - lst[i - 2]))

print(ans[-1])

Measured memory_bytes: 13980
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int n, m, X, Y;
  	cin >> n >> m >> X >> Y;
  	vi x(n+1), y(m+1);
  	rep(i,n) cin >> x[i];
  	x[n] = X;
  	rep(i,m) cin >> y[i];
  	y[m] = Y;
  	sort(all(x));
  	sort(all(y));
  	if(x[n]<y[0]) puts("No War");
  	else puts("War");
  	return;
}

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

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

int main(){
    string s;
    int j=0;

    cin>>s;

    for(int i=0;i<49;i++){
        if(s[2*i+1]=='R'){
            j++;
        }
    }

    for(int i=0;i<49;i++){
        if(s[2*i]=='L'){
            j++;
        }
    }

    if(j==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;

}

Measured memory_bytes: 256
//
// Created by 13783 on 2020/4/2.
//
#include<iostream>
using namespace std;
string s,t;
const int len=3e3+2;
int dp[len][len];
int n;
void solve(){
    for(int i=0;i<s.length();i++){
        for(int j=0;j<t.length();j++){
            if(s[i]==t[j]){
                dp[i+1][j+1]=dp[i][j]+1;
            } else
                dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
        }
    }
    string ans;
    int i=s.length(),j=t.length();
    while(i>0&&j>0){
        if(dp[i][j]==dp[i-1][j]){
            i--;
        }
        else if(dp[i][j-1]==dp[i][j]){
            j--;
        }
        else
        {
            i--;
            j--;
            ans=s[i]+ans;
        }
    }
    cout<<ans;
}
int main(){
    cin>>s>>t;
    solve();
    return 0;
}

Measured memory_bytes: 35456
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
   string S;
   cin >> S;
   int cnt0 = 0;
   int cnt1 = 0;
   for (int i = 0; i < (int)S.size(); i++) {
      if (S[i] == '0') cnt0++;
      else cnt1++;
   }
   cout << min(cnt0, cnt1) * 2 << endl;
   return 0;
}


Measured memory_bytes: 512
import statistics

n = int(input())
a = []
b = []

for i in range(n):
  _a, _b = map(int, input().split())
  a.append(_a)
  b.append(_b)

max_median = statistics.median(b)
min_median = statistics.median(a)
if n % 2 == 0:
  print(int((max_median - min_median) * 2) + 1)
else:
  print(int(max_median - min_median) + 1)

Measured memory_bytes: 28836
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順
#include <map>

using namespace std;
using ll = long long int;

int main(){
    ll N;cin>>N;
    vector<ll> A(N+1);
    map<ll,ll> sum;
    map<ll,ll> dif;
    for(int i=1;i<=N;i++){
        cin >> A[i];
        sum[i+A[i]]++;
        if(i-A[i]>1){
            dif[i-A[i]]++;
        }
    }
    ll ans = 0;
    for(auto i=dif.begin();i!=dif.end();i++){
        ans += i->second * sum[i->first];
    }
    cout << ans << endl;
}

Measured memory_bytes: 23864
import Control.Applicative
import Data.List
import Control.Monad
strToInt s = (read :: String -> Int) s

main :: IO ()
main = do
    -- スペース区切り整数の入力
    [a, b, c, d] <- map strToInt . words <$> getLine
    -- 出力
    putStrLn $ output a b c d
        where
            output a b c d
                | (a + b) > (c + d) = "Left"
                | (a + b) == (c + d)= "Balanced"
                | otherwise = "Right"


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

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

const long long INF = 1LL << 60;
//入力
int N;
ll h[100050];
//DPテーブル
ll dp[100050];

int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> h[i];
    }
    for(int i = 0; i < 100050; i++){
        dp[i] = INF;
    }
    dp[0] = 0;
    for(int i = 1; i < N; i++){
        chmin(dp[i],dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1) chmin(dp[i],dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
using namespace std;

int main(){
	char buf[101];
	while( scanf("%s", &buf) != EOF ){
		for(int i=0; buf[i]!=0; i++){
				if(buf[i]!='@') printf("%c", buf[i]);
			else{
				for(int j=0;j<buf[i+1]-48;j++) printf("%c", buf[i+2]);
				i+=2;
			}
		}
		printf("\n");
	}
	return 0;
}

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

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

const int MOD = 1e9 + 7;
const int INFi = 2e9 + 1;
const lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(i, vec) for(auto &(i) : (vec))


template <class T> inline int argmin(vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


int main(void){
  int n, a, b; cin >> n >> a >> b;
  Vint X(n);
  vREP(ele, X) cin >> ele;
  lli diff, res = 0;
  REP(i, n - 1){
    diff = X.at(i + 1) - X.at(i);
    res += min(a * diff, (lli)b);
  }
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
import java.util.HashMap;

public class Main{

    static Scanner scan;

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

        final int n = scan.nextInt();
        String command, str;

        HashMap<String, String> h = new HashMap<String, String>();

        for(int i = 0; i < n; i++) {
            command = scan.next();
            str = scan.next();

            switch(command) {
                case "insert":
                    h.put(str, "yes");
                    break;
                case "find":
                    if(h.containsKey(str)) System.out.println(h.get(str));
                    else System.out.println("no");
                    break;
            }
        }
    }
}



Measured memory_bytes: 252456
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;

const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 97;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

template < class T > inline void fastScan(T &x){
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}



int main(){
  int test = 1;
  //fastScan(test);
  while(test--){
    ll n, a, b, c = 1ll * 1e18;
    fastScan(n);
    fastScan(a);
    fastScan(b);
    ll aa = a, bb = b - a + 1, cc = aa - 1;
    while((bb - 1) & 1){
      bb--;
      cc++;
    }
    c = min(c, cc + (bb - 1) / 2);
    aa = a + (n - b), bb = n, cc = n - b;
    while((n - aa) & 1){
      aa++;
      cc++;
    }
    c = min(c, cc + (n - aa) / 2);
    if((b - a) % 2ll == 0){
      c = min(c, (b - a) / 2);
    }
    printf("%lld\n", c);
  }
  return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <map>
#include <deque>
#include <queue>
#include <tuple>
using namespace std;

#define prec(i) cout << fixed << setprecision(i)

void output_yn(bool isYes) {
	if (isYes)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

const long long MOD = 1000000007;

long long fact(long long k) {
	long long sum = 1;
	for (long long i = 2; i <= k; i++)
		sum *= i;

	return sum;
}

long long fact_mod(long long k) {
	long long sum = 1;
	for (long long i = 2; i <= k; i++)
		sum = (sum * i) % MOD;

	return sum;
}

int ctoi(char c) {
	if (c >= '0' && c <= '9')
		return c - '0';
	else
		return -1;
}

long long pow_mod(int a, int b) {
	long long ans = 1;
	for (int i = 0; i < b; i++)
		ans = (ans * a) % MOD;

	return ans;
}

long long powll(long long a, long long  b) {
	long long ans = 1;
	for (long long i = 0; i < b; i++)
		ans = ans * a;

	return ans;
}

long long modinv(long long a) {

	long long b = MOD, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= MOD;
	if (u < 0) u += MOD;

	return u;
}

long long _gcd(long long a, long long b)
{
	if (a < b)
		swap(a, b);

	if (a % b == 0)
		return b;
	else
		return _gcd(b, a % b);
}

long long _lcm(long long a, long long b)
{
	return (((a * b) % MOD) * modinv(_gcd(a, b))) % MOD;
}

long long ncr(long long n, long long r) {
	long long sum = 1;
	for (long long i = r + 1; i <= n; i++)
		sum *= i;

	return sum;
}


int main()
{
	int sum = 0;
	string n;
	cin >> n;

	for (int i = 0; i < n.size(); i++) {
		sum += n[i] - '0';
	}

	output_yn(sum % 9 == 0);

	return 0;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll N;
    cin>>N;
    ll i,a[N],j;
    for(i=0;i<N;i++) cin>>a[i];
    ll dp[N][N];
    for(i=0;i<N;i++)
    {
        for(j=0;j<N;j++)
        {
            if(j+i<N)
            {
                if(i==0) dp[j][j]=a[j];
                else dp[j][j+i]=max(a[j]-dp[j+1][j+i],a[j+i]-dp[j][j+i-1]);
            }
        }
    }
    cout<<dp[0][N-1]<<endl;
    return 0;
}


Measured memory_bytes: 70400
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = nextInt();
  var sum = 0;
  for(var i = 1; i <= N; i++){
    if(i % 3 != 0 && i % 5 != 0){
      sum += i;
    }
  }
  myout(sum);
}

Measured memory_bytes: 35192
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/

/////////////////////////////////
#define MAX_N 305//調節！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
int par[MAX_N],dep[MAX_N];//depはrankのこと
//n要素で初期化//忘れないように！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
void init(int n){
    for(int i=0;i<=n-1;i++){//頂点番号は0~n-1
        par[i]=i;
        dep[i]=0;
    }
}
//木の根を求める
int find(int x){
    return par[x]==x?x:par[x]=find(par[x]);
}
//xとyの属する集合を併合
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;
    if(dep[x]<dep[y]){
        par[x]=y;
    }else{
        par[y]=x;
        if(dep[x]==dep[y])dep[x]++;
    }
}
//xとyが同じ集合に属するか否か
bool same(int x,int y){
    return find(x)==find(y);
}

//////////////////////////////////////

ll INF=30000000005;

struct edge {
    int from,to;
    ll cost;
    
    bool operator<( const edge& right ) const {
        return cost < right.cost;
    }
};
int n;
vector<i_i>v[MAX_N];
ll dis(int s,int t){
    ll mind[n];for(int i=0;i<=n-1;i++)mind[i]=INF;
    mind[s]=0;
    queue<ll>q;q.push(s);
    while(!q.empty()){
        ll top=q.front();q.pop();
        for(auto x:v[top]){
            ll y=x.first,dist=x.second;
            if(dist+mind[top]<mind[y]){
                mind[y]=mind[top]+dist;
                q.push(y);
            }
        }
    }
    return mind[t];
}

int main(){
    cin>>n;
    init(n);
    vector<edge> e;
    for(int i=0;i<=n-1;i++){
        for(int j=0;j<=n-1;j++){
            ll c;cin>>c;
            if(i<j)e.push_back(edge{i,j,c});
        }
    }
    sort(e.begin(),e.end());
    ll ans=0;
    for(auto x:e){
        ll s=x.from,t=x.to,c=x.cost;
        if(same(s,t)){
            ll d=dis(s,t);
            if(d<c){
                cout<<-1<<endl;
                return 0;
            }else if(d>c){
                v[s].push_back(make_pair(t,c));
                v[t].push_back(make_pair(s,c));
                ans+=c;
            }
        }else{
            v[s].push_back(make_pair(t,c));
            v[t].push_back(make_pair(s,c));
            ans+=c;
            unite(s,t);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const int MOD = 1e9+7;
const int INF = 1<<30;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    string s, t;
    cin >> s >> t;

    if (s.length() != t.length()) {
        cout << "NO" << endl;
        return 0;
    }

    bool ok = true;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] != t[t.length() - 1 - i]) ok = false;
    }

    if (ok) cout << "YES" << endl;
    else cout << "NO" << endl;


    return 0;
}

Measured memory_bytes: 256
function Main(input) {
    var tmp = input.split(" ");
    var N = parseInt(tmp[0],10);
    var M =parseInt(tmp[1],10);

    //組み合わせの考え方
    //偶数＋偶数＝偶数(1)
    //奇数＋偶数＝奇数(2)
    //奇数＋奇数＝偶数(3)
    //であるため
    //(1)=N*(N-1),(3)=M*(M-1)の和が
    //N+Mのボールから任意の2のボールを取るときの偶数となる場合の数となる。
    
        console.log((N*(N-1)+M*(M-1))/2);
    
    

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

struct StronglyConnectedComponents {
    int id = 0;
    vector<vector<int>> gg, rg;
    vector<int> comp, order, seen, depth;
    StronglyConnectedComponents(int v) : \
    gg(v), rg(v), comp(v, -1), seen(v, 0), depth(v, 1) { }
    void add_edge(int x, int y) {
        gg[x].emplace_back(y);
        rg[y].emplace_back(x);
    }
    void dfs(int u) {           // order, seen
        seen[u] = true;
        for (int v: gg[u]) if (!seen[v]) dfs(v);
        order.emplace_back(u);
    }
    void rdfs(int u, int id) {  // comp, depth
        comp[u] = id;
        for (int v: rg[u]) {
            if (comp[v] == -1) rdfs(v, id);
            depth[u] = max(depth[u], depth[v] + 1);
        }
    }
    int build() {
        for (int u = 0; u < gg.size(); ++u) if (!seen[u]) dfs(u);
        reverse(begin(order), end(order));
        for (int u: order) if (comp[u] == -1) rdfs(u, id++);
        return id;
    }
    vector<vector<int>> make_graph() {
        vector<vector<int>> g_comp(id);
        set<pair<int, int>> connect;
        for (int u = 0; u < gg.size(); ++u) for (int v: gg[u]) {
            int x = comp[u], y = comp[v];
            if (x == y) continue;
            if (connect.count({x, y})) continue;
            g_comp[x].emplace_back(y);
            connect.emplace(x, y);
        }
        return g_comp;
    }
    int operator[](int k) { return comp[k]; }
};

int main() {
    int V, E; cin >> V >> E;
    StronglyConnectedComponents scc(V);
    while (E--) {
        int s, t; cin >> s >> t;
        scc.add_edge(s, t);
    }
    scc.build();
    int Q; cin >> Q;
    while (Q--) {
        int u, v; cin >> u >> v;
        cout << (scc[u] == scc[v]) << endl;
    }
    return 0;
}


Measured memory_bytes: 4592
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

alias sread = () => readln.chomp();

void main()
{
    auto np = aryread();
    auto n = np[0];
    auto p = np[1];

    auto f = factorize(p);

    long result = 1;

    foreach(k,v;f)
    {
        result *= k ^^ (v/n);
    }

    result.writeln;
}

long[long] factorize(long x)
{
    assert(0 < x, "x is negative");
    long[long] ps;
    while ((x & 1) == 0)
    {
        x /= 2;
        ps[2] = (2 in ps) ? ps[2] + 1 : 1;
    }
    for (long i = 3; i * i <= x; i += 2)
        while (x % i == 0)
        {
            x /= i;
            ps[i] = (i in ps) ? ps[i] + 1 : 1;
        }
    if (x != 1)
        ps[x] = (x in ps) ? ps[x] + 1 : 1;
    return ps;
}

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

int main()
{
	int num;
	double xa,xb,ya,yb,ra,rb;
	double dist;
	cin >> num;
	for( int i = 0; i < num; i++ ) {
		cin >> xa >> ya >> ra >> xb >> yb >> rb;
		
		dist = sqrt( (xa-xb)*(xa-xb) + (ya-yb)*(ya-yb) );
		if( dist > ra + rb ) {
			cout << 0 << endl;
		}
		else if( ra - dist > rb) {
				cout << 2 << endl;
		}
		else if( rb - dist > ra) {
				cout << -2 << endl;
		}
		else
			cout << 1 << endl;
	}

	return 0;
}

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

int main() {
  int arr[26]={0}, n, max=0;
  string s;
  cin >> n >> s;

  for (int i=0; i<n; i++) {
    arr[s[i]-'a']++;
    
    int arr2[26]={0};
    for (int j=i+1; j<n; j++) {
      arr2[s[j]-'a']++;
    }
    
    int cnt=0;
    for (int j=0; j<26; j++) {
      if (arr[j]!=0 && arr2[j]!=0) cnt++;
    }

    if (max<cnt) max=cnt;
  }

  cout << max;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

using namespace std;

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

    REP(i, N)
    cin >> a[i];

    sort(ALL(a));

    int remain = 0;

    for (int i = 0; i < N;) {
        int current = a[i];
        i++;
        int n = 1;
        while (current == a[i] && i < N) {
            i++;
            n++;
        }
        int remove = n - current;

        if (0 <= remove)
            remain += remove;
        else
            remain += n;
    }

    cout << remain << endl;

    return 0;
}


Measured memory_bytes: 640
import math
A,B = list(map(int,input().split()))
list08 = []
list10 = []
for i in range(math.floor(A/0.08),math.ceil((A+1)/0.08)+1):
    if math.floor(i*0.08) == A:
        list08.append(i)
for i in range(math.floor(B/0.10),math.ceil((B+1)/0.1)+1):
    if math.floor(i*0.10) == B:
        list10.append(i)
ans = list(set(list08) & set(list10))
if ans ==[]:
    print(-1)
else:
    print(min(ans))


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

int main() {
	int n;cin>>n;
  	string ans="";
  	while(n!=0){
    	if(n%2!=0){
          	n--;
        	ans="1"+ans;
        }else{
        	ans="0"+ans;
        }
      n/=-2;
    }
  	if(ans=="")ans="0";
  	cout<<ans<<endl;
}



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

int main(){
    int i=0,x[3000],y[3000];
    
    while(1){
        cin >> x[i] >> y[i];
        if(x[i] == 0 && y[i] == 0) break;
        i++;
    }
    i = 0;
    while(1){
        if(x[i] == 0 && y[i] == 0) break;
        if(x[i] <= y[i]) cout << x[i] << " " << y[i] << endl;
        else cout << y[i] << " " << x[i] << endl;
        i++;
    }
    return 0;
}


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

using namespace std;

typedef long long ll;

const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T>
inline void chkmax(T&a, T b) { a = a > b ? a : b; }

const int MAXN = 100010;

int n;
int k;
int res;
int a[MAXN];
vector<int> to[MAXN];

inline int dfs(int x) {
	int mx = 1;
	for(auto u : to[x]) chkmax(mx, dfs(u) + 1);
	if(x != 1 && a[x] != 1 && mx == k) return ++res, 0;
	else return mx;
}

int main() {
#ifdef LOCAL
	FILE("");
#endif

	n = ri, k = ri;

	for(int i = 1; i <= n; i++) a[i] = ri;
	res = a[1] != 1;

	for(int i = 2; i <= n; i++) to[a[i]].push_back(i);

	dfs(1), printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

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

  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && b != c) {
    puts("Yes");
  } else if (a == c && a != b) {
    puts("Yes");
  } else if (b == c && a != b) {
    puts("Yes");
  } else {
    puts("No");
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(register int i=(a);i<(b);++i)
#define ROF(i,a,b) for(register int i=(a);i>=(b);--i)
#define pi pair<int,int>
#define mk(a,b) make_pair(a,b)
#define mygc(c) (c)=getchar()
#define mypc(c) putchar(c)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef double db;
const int maxn = 3005;
const int maxm = 20000;
const int inf = 2147483647;
typedef long long ll;
const double eps = 1e-9;
const long long INF = 9223372036854775807ll;
ll qpow(ll a,ll b,ll c){ll ans=1;while(b){if(b&1)ans=ans*a%c;a=a*a%c;b>>=1;}return ans;}
inline void rd(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
inline void rd(ll *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
inline void rd(db *x){scanf("%lf",x);}
inline int rd(char c[]){int i,s=0;for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}c[s++]=i;for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}c[s]='\0';return s;}
inline void rd(int a[],int n){FOR(i,0,n)rd(&a[i]);}
inline void rd(ll a[],int n){FOR(i,0,n)rd(&a[i]);}
template <class T, class S> inline void rd(T *x, S *y){rd(x);rd(y);}
template <class T, class S, class U> inline void rd(T *x, S *y, U *z){rd(x);rd(y);rd(z);}
template <class T, class S, class U, class V> inline void rd(T *x, S *y, U *z, V *w){rd(x);rd(y);rd(z);rd(w);}
inline void wr(int x){if(x < 10) putchar('0' + x); else wr(x / 10), wr(x % 10);}
inline void wr(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
inline void wr(ll x, char c){int s=0,m=0;char f[20];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
inline void wr(db x, char c){printf("%.15f",x);mypc(c);}
inline void wr(const char c[]){int i;for(i=0;c[i]!='\0';i++)mypc(c[i]);}
inline void wr(const char x[], char c){int i;for(i=0;x[i]!='\0';i++)mypc(x[i]);mypc(c);}
template<class T> inline void wrn(T x){wr(x,'\n');}
template<class T, class S> inline void wrn(T x, S y){wr(x,' ');wr(y,'\n');}
template<class T, class S, class U> inline void wrn(T x, S y, U z){wr(x,' ');wr(y,' ');wr(z,'\n');}
template<class T, class S, class U,class H> inline void wrn(T x, S y, U z,H h){wr(x,' ');wr(y,' ');wr(z,' ');wr(h,'\n');}
template<class T> inline void wra(T x[], int n){int i;if(!n){mypc('\n');return;}FOR(i,0,n-1)wr(x[i],' ');wr(x[n-1],'\n');}



int main(){
	ll n;
	rd(&n);
	ll ans=0;
	for(register ll i = 1;i*i<=n;++i){
		if(n%i==0){
			ans=i;
		}
	} 
	wrn(ans-1+(n/ans-1));
}

Measured memory_bytes: 3648
N = int(input())
B = list(map(int,input().split()))

dp = [10**8]*N
for i in range(N-1):
    if dp[i]>B[i]:
        dp[i]=B[i]
    if dp[i+1]>B[i]:
        dp[i+1]=B[i]
    
print(sum(dp))

Measured memory_bytes: 9100
/*
  AOJ 0547
  Title:Commute routes
  @kankichi573
*/
#include <stdio.h>
#define WARI 100000

int memo[100][100][2][2];

int solve2(int x,int y,int l2,int l1)
{
  int ret;

  if(x==0)
    {
      if(l2==1 && l1==0)
	ret=0;
      else
	ret=1;
    }
  else if(y==0)
    {
      if(l2==0 && l1==1)
	ret=0;
      else
	ret=1;
    }
  else
    {
      if((ret=memo[x][y][l2][l1]))
	return(ret);

      ret=0;
      if(!(l2==0 && l1==1))
	ret  = solve2(x-1,y,l1,0); 
      if(!(l2==1 && l1==0))
	ret += solve2(x,y-1,l1,1);
      
      ret %= WARI;
    }
  memo[x][y][l2][l1]=ret;
  return(ret);
}

int solve(int x,int y)
{
  int ret;
  ret  = solve2(x-2,y  ,0,0);
  ret += solve2(x-1,y-1,1,0);
  ret += solve2(x-1,y-1,0,1);
  ret += solve2(x  ,y-2,1,1);
  ret %= WARI;
  return(ret);
}

main()
{
  int ret,w,h;
  while(scanf("%d %d",&w,&h) && (w||h))
    {
      ret=solve(w-1,h-1);
      printf("%d\n",ret);
    }
  return(0);
}

Measured memory_bytes: 768
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
#import numpy as np
N,M,Q = map(int,input().split())
d = []
abcd = [list(map(int,input().split())) for _ in range(Q)]
def makearr(N,M,A):#あとNこ
    if N == 0:
        d.append(A)
        return
    else:
        n = len(A)
        prev = A[n-1]
        for i in range(prev,M+1):
            A.append(i)
            makearr(N-1,M,A)
            A = A[:n]
for k in range(M):
    A = [k+1]
    makearr(N-1,M,A)
Max = 0
for li in d:
    s = 0
    for k in range(Q):
        a,b,c,d = abcd[k]
        if li[b-1] - li[a-1] == c:
            s += d
    Max = max(Max,s)
print(Max)

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

long long N, K;
vector<long long> sumV(100001);

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

  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  if(N <= K){
    cout << N * X <<endl;
  } else{
    cout << K * X + (N - K) * Y <<endl;
  }
}


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

typedef long long int ll;

int main()
{
	ll n;
	scanf("%lld",&n);
	ll cnt=0;
	for(ll i=1;i<=n;i++)
	{
		cnt+=i*(n/i)*(n/i+1);
	}
	printf("%lld\n",cnt/2);
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=(n)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1e9+7
#define MOD 1e9+7
#define max3(a,b,c) max(a,max(b,c)) 
#define mix3(a,b,c) mix(a,mix(b,c))

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main(){
   
    int n,w;cin>>n>>w;
    vi weight(n+1,0),val(n+1,0);
    repa(i,1,n+1)cin>>weight[i]>>val[i];

    int vs=n*1e3+1;
    vi dp(vs,w+1);
    int ans=0;
    dp[0]=0;

    repa(i,1,n+1){
        rrep(j,vs){
            if(dp[j]+weight[i]<=w){
                dp[j+val[i]] = min(dp[j+val[i]],dp[j]+weight[i]);
                ans = max(ans,j+val[i]);
                // cout<<"i = "<<i<<"  dp["<<j+val[i]<<"] = "<<dp[j+val[i]]<<endl;
            }
        }
    }

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

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll fun(ll n)
{
	return ((n*(n-1))/2);
}
ll findSum(map<ll,ll> m,ll n)
{
	ll sum=0;
	for(ll i=1;i<=n;i++)
		sum+=fun(m[i]);
	return sum;
}
int main()
{
	ll n;
	cin>>n;
	vector<ll> a(n+1);
	map<ll,ll> m;
	for(ll i=1;i<=n;i++)
	{
		cin>>a[i];;
		m[a[i]]++;
	}
	ll sum=findSum(m,n);
	for(ll k=1;k<=n;k++)
	{
		ll t=a[k];
		ll tc=fun(m[a[k]]);
		ll p=m[a[k]]-1;
		ll temp=sum-tc+fun(p);
		cout<<temp<<endl;
	}
	return 0;
}

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

using namespace std;

long long n, a, b, c, d;

signed main() {
	scanf("%lld%lld%lld%lld%lld", &n, &a, &b, &c, &d);
	for(long long m = 0; m <= n-1; m++)
		if((n-m-1)*c-m*d <= b-a && (n-m-1)*d-m*c >= b-a) {
			printf("YES");
			return 0;
		}
	printf("NO");
	return 0;
}

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

int main(){
    string a,b;
    cin>>a;
    for(int i=0; i<a.length(); i++){
        if(a[i]!='B')b.push_back(a[i]);
        else if(!b.empty()) b.pop_back();
    }
    cout<<b;
return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;



int main(void){

string ws;
int n;
	while(cin >> n){
		if(n==0 || cin.eof()) break;
		vector<vector<int> > hg(n+1,vector<int>(n+1,0));
		rep(i,n) rep(j,n) cin >> hg[i][j];
		rep(i,n) rep(j,n){
			hg[n][i] += hg[j][i];
			hg[i][n] += hg[i][j];
		}
		rep(i,n) hg[n][n] += hg[i][n];
		rep(i,n+1){
			rep(j,n+1) printf("%5d",hg[i][j]);
			printf("\n");
		}
	}
	return 0;
	
}

Measured memory_bytes: 1216
t1, t2 = map(int,input().split())
a1, a2 = map(int,input().split())
b1, b2 = map(int,input().split())

c1 = a1 * t1
c2 = a2 * t2
d1 = b1 * t1
d2 = b2 * t2

if c1 + c2 == d1 + d2:
    print("infinity")
    exit(0)

if c1 + c2 < d1 + d2:
    c1, d1 = d1, c1
    c2, d2 = d2, c2

# print(c1, c2, d1, d2)

def check(mid):
    if mid % 2 == 0:
        a = (c1 + c2) * (mid // 2)
        b = (d1 + d2) * (mid // 2)
        f1 = a < b
        a += c1
        b += d1
        if a == b:
            return True
        f2 = a < b
        return f1 != f2
    else:
        a = (c1 + c2) * (mid // 2) + c1
        b = (d1 + d2) * (mid // 2) + d1
        f1 = a < b
        a += c2
        b += d2
        if a == b:
            return True
        f2 = a < b
        return f1 != f2

ok, ng = 0, 10 ** 20
while ng - ok > 1:
    mid = (ok + ng) // 2
    if check(mid):
        ok = mid
    else:
        ng = mid

print(ok)

Measured memory_bytes: 38524
#include<cstdio>
#include<cmath>
bool isp(int nu){
	int i = 1;
	if(nu == 1) return false;
	else if(nu == 2) return 1;
	int sqr = sqrt(nu) + 1;
	for(i = 2;i <= sqr;i++) if(nu % i == 0) return false;
	return true;
}
int main(){
    short sum=0, n;
    scanf("%d", &n);
    for(;n>0;n--){
        int temp;
        scanf("%d", &temp);
        if(isp(temp)) sum++;
    }
    printf("%d\n", sum);
}



Measured memory_bytes: 2704
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#define ll long long
#define il inline
using namespace std;
const int N = 100 + 5;
int a[ N ]; 
int main()
{
    int n, m, x,c;
    cin >> n >> m >> x;
    for( int i = 1; i<=m;++i){
    	cin >> c;
    	a[c]=1;
    }
    int num1=0,num2=0;
    for(int i=1;i<x;i++) num1+=a[i];
    for(int i=x+1;i<=n;i++) num2+=a[i];
    cout<<min(num1,num2)<<endl;
    return 0;
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

llong N, drink[4], many[4] = {1,2,4,8};

llong solve(vector<int> v){
	if(v.size() == 4){
		llong res = 0;
		llong cp = N;
		for(int i = 0; i < 4; i++){
			int buy = v[i];
			res += cp/many[buy]*drink[buy];
			cp %= many[buy];
		}
		// cerr << res << endl;

		return res + (cp > 0 ? inf : 0);
	}

	llong ret = inf;
	v.push_back(0);
	for(int i = 0; i < 4; i++){
		v[v.size()-1] = i;
		ret = min(ret, solve(v));
	}

	return ret;
}

int main(){
	for(int i = 0; i < 4; i++)
		cin >> drink[i];
	cin >> N;
	N *= 4;

	cout << solve(vector<int>()) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for(int i=m; i<n; i++)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <typename T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0; }
template <typename T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1;} return 0; }
const int INF = 1000000000;

char maze[50][51];
int sx,sy,gx,gy;
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int d[50][51];
int H,W;

int bfs(){
    queue<P> que;
    rep(i,0,50) rep(j,0,51) d[i][j]=INF;
    d[sy][sx]=0;
    que.push(P(sy,sx));
    while(que.size()){
        P p=que.front(); que.pop();
        if(p.first==gy && p.second==gx) break;
        rep(i,0,4){
            int nx=p.second+dx[i],ny=p.first+dy[i];
            if(0<=nx&&nx<W&&0<=ny&&ny<H&&maze[ny][nx]=='.'&&d[ny][nx]==INF){
                que.push(P(ny,nx));
                d[ny][nx]=d[p.first][p.second]+1;
            }
        }
    }
    return d[gy][gx];
}

int main() {
    cin>>H>>W;
    int white=0, black=0;
    rep(i,0,H) rep(j,0,W){
        cin>>maze[i][j];
        if(maze[i][j]=='#') black++;
        else white++;
    } 
    sx=0,sy=0;
    gx=W-1,gy=H-1;
    int ans=bfs();
    if(ans==INF) cout<<-1<<endl;
    else cout<<white-ans-1<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string a, b;
    cin >> a >> b;
    if (a[0] == b[2] and a[2] == b[0] and a[1] == b[1]) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

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

using namespace std;

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

    long long a[ n ];
    int zero = 0;

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

    if( zero )
    {
        cout << 0 << "\n";
    }
    else{
    long long prod = 1;

    for( int i = 0; i < n; i++ )
    {
        if( a[ i ] <= 1000000000000000000 / prod )
        {
            prod *= a[ i ];
        }
        else
        {
            prod = -1;
            break;
        }
    }

    cout << prod << "\n";
    }

    return 0;
}

Measured memory_bytes: 4344
#include <stdio.h>
 
class Dice{
public:
    Dice(){
        number = new int[6];
        work = new int[6];
    };
    ~Dice(){
        delete[] number;
        delete[] work;
    };
 
    void setLabel(int index,int num){
        number[index] = num;
    };
 
    void roll(char dst){
        for(int i = 0; i < 6; i++) work[i] = number[i];
        switch(dst){
        case 'E':
            setNumber(work[3],work[1],work[0],work[5],work[4],work[2]);
            break;
        case 'N':
            setNumber(work[1],work[5],work[2],work[3],work[0],work[4]);
            break;
        case 'S':
            setNumber(work[4],work[0],work[2],work[3],work[5],work[1]);
            break;
        case 'W':
            setNumber(work[2],work[1],work[5],work[0],work[4],work[3]);
            break;
        }
    };
 
    int returnPeek(){
        return number[0];
    }
 
private:
    void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
        number[0] = n0;
        number[1] = n1;
        number[2] = n2;
        number[3] = n3;
        number[4] = n4;
        number[5] = n5;
    }
 
private:
    int* number;
    int* work;
};
 
int main(){
    Dice dice;
    int label;
    char ch;
    for(int i = 0; i < 6; i++){
        scanf("%d",&label);
        dice.setLabel(i,label);
    }
    getchar(); 
    while((ch = getchar()) != '\n'){
        dice.roll(ch);
    }
    printf("%d\n",dice.returnPeek());
}


Measured memory_bytes: 2716
// Aizu Vol-5 0515: School Road
// 2017.8.30 bal4u@uu

#include <stdio.h>
#include <string.h>

int p[17][17];
char map[17][17];

int main()
{
	int a, b, n, x, y;

	while (scanf("%d%d", &a, &b) && a) {
		memset(map, 0, sizeof(map));
		memset(p, 0, sizeof(p));
		scanf("%d", &n); while (n-- > 0) scanf("%d%d", &x, &y), map[x][y] = 1;
		for (x = 1; x <= a; x++) if (map[x][1]) break; else p[x][1] = 1;
		for (y = 1; y <= b; y++) if (map[1][y]) break; else p[1][y] = 1;
		for (y = 2; y <= b; y++) for (x = 2; x <= a; x++) {
			if (map[x][y]) continue;
			if (!map[x-1][y]) p[x][y] += p[x-1][y];
			if (!map[x][y-1]) p[x][y] += p[x][y-1];
		}
		printf("%d\n", p[a][b]);
	}
	return 0;
}

Measured memory_bytes: 600
//#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define rep(i, beg, end) for (int i = (beg); i < (end); i++)
#define rrep(i, beg, end) for (int i = (beg); i >= (end); i--)
#define sp(i) setprecision(i) << fixed
#define ini(a, b) memset(a, b, sizeof(a))
typedef long long ll;
typedef pair<double, double> P;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 100010;
ull p_hash(ull x, ull y) { return (x + y) * (x + y + 1) / 2 + y; } //NxN->N
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

struct E
{
    int a, b, c;
    bool operator<(const E &ot)
    {
        return c < ot.c;
    }
};
vector<E> es;

int id[N];

int root(int u)
{
    if (id[u] != u)
        id[u] = root(id[u]);

    return id[u];
}

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m;
    cin >> n >> m;

    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        es.push_back({a, b, 1});
    }

    for (int i = 1; i <= n; i++)
        id[i] = i;

    int res = 0;
    for (auto e : es)
    {
        int u = root(e.a), v = root(e.b);
        if (u != v)
        {
            id[u] = v;
            res++;
        }
    }

    cout << n - 1 - res << endl;

    return 0;
}


Measured memory_bytes: 4860
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const ll N = 1e5 + 5, MOD = 1e9+7;

ll n;
ll a[N],ans;
ll x[N],l[N],r[N];

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin>>n;

    for( ll i=1; i<=n; i++ )       cin>>a[i];

    l[1]=a[1],r[n]=a[n];
    for( ll i=2; i<=n; i++ )       l[i]=__gcd(l[i-1],a[i]);
    for( ll i=n-1; i>=0; i-- )     r[i]=__gcd(r[i+1],a[i]);
    x[1]=r[2];
    x[n]=l[n-1];
    for( ll i=2; i<n; i++ )       x[i]=__gcd(l[i-1],r[i+1]);
    sort(x+1,x+n+1);

    cout<<x[n]<<endl;
    return 0;
}




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

int main() {
  int a,b;
  int ans=0;
  cin >> a >> b;
  for(int i=a;i<b+1;i++){
    if((i/10000==i%10)&&(i%10000/1000==i%100/10)){
      ans++;
    }
  }
  
  cout << ans << "\n";
}

Measured memory_bytes: 256
N = int(input())
lis = []
for _ in range(N):
    a, b = map(int, input().split())
    dic = {}
    dic["a"] = a
    dic["b"] = b
    lis.append(dic)
lis_sort = sorted(lis, key=lambda x:(x["b"], x["a"]))
t = 0
for dic in lis_sort:
    t += dic["a"]
    if t > dic["b"]:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 92980
#ABC 127 C Prison
N,M= map(int,input().split())
MIN=0
MAX=N
for i in range(M):
    L,R= map(int,input().split())
    MAX=min(MAX,R)
    MIN=max(MIN,L)
ans =MAX-MIN+1
if ans <0:
    print(0)
else:
    print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false), cin.tie(0);
    vector<int>c;
    for(int i=0;i<10;i++){
        int a;
        cin>>a;
        c.push_back(a);
    }
    sort(c.begin(),c.end());
    cout<<c[c.size()-1]<<endl;
    cout<<c[c.size()-2]<<endl;
    cout<<c[c.size()-3]<<endl;
	return 0;
}



Measured memory_bytes: 3140
#include <iostream>

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

   int a[3];
   a[0] = n/100;
   a[1] = (n-a[0]*100)/10;
   a[2] = n%10;

   for(int i=0; i<3; ++i){
      if(a[i]==1) a[i] = 9;
      else if(a[i]==9) a[i] = 1;
   }
  
   n = a[0]*100 + a[1]*10 + a[2];

   std::cout << n << std::endl;
   return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
lmap = [[0] * w for i in range(h)]
inf = 2**31-1
for i in range(h):
    s = input()
    for j in range(w):
        if s[j] == "#":
            lmap[i][j] = 1
        else:
            lmap[i][j] = 0


def bfs(i, j):
    que = []
    que.append([i, j])
    dmap = [[inf] * w for i in range(h)]
    dmap[i][j] = 0
    dmax = 0

    vec = [[-1, 0], [1, 0], [0, -1], [0, 1]]

    while len(que) > 0:
        pt = que.pop(0)
        # print(pt)
        for v in vec:
            y = pt[0] + v[0]
            x = pt[1] + v[1]
            if x >= 0 and x < w and y >= 0 and y < h and lmap[y][x] == 0 and dmap[y][x] == inf:
                que.append([y, x])
                d = dmap[pt[0]][pt[1]] + 1
                dmax = max(dmax, d)
                dmap[y][x] = d

    # print(dmap)
    return dmax


ans = 0
for i in range(h):
    for j in range(w):
        if lmap[i][j] == 0:
            r = bfs(i, j)
            # print(r)
            ans = max(r, ans)

print(ans)


Measured memory_bytes: 3188
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

// functions and classes

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

	double a, b, x;
	cin >> a >> b >> x;

	double low = 0.0, high = 90.0;
	double mid = (low + high) / 2.0;
	for (ll i = 0; i < 60; ++i)
	{
		double threshold;
		if (b / a > tan(PI * mid / 180.0))
			threshold = a * a * (b - a * tan(PI * mid / 180.0) / 2);
		else
			threshold = a * b * b * tan(PI * (90.0 - mid) / 180.0) / 2.0;
		
		if (threshold < x)
			high = mid;
		else
			low = mid;

		mid = (low + high) / 2.0;
	}

	cout << std::setprecision(12) << mid << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include<string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int A, B;
    cin >> A >> B;
    if ((A + B) % 3 == 0 || A % 3 == 0 || B % 3 == 0) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }
    return 0;
}

Measured memory_bytes: 256