akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl

int n,k;
ll a[100005];
ll ans=INF;

int main()
{
	SPEED;	
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=k;i<=n;i++)
	{
		ll cost=0;
		if(a[i]<0)
			cost=abs(a[i-k+1]);
		else
		{
			cost=a[i];
			if(a[i-k+1]<0)
				cost=min(a[i]+2*abs(a[i-k+1]),2*a[i]+abs(a[i-k+1]));
		}
		ans=min(ans,cost);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
str = $stdin.gets.chomp

ans = "No"

if str[0] == str[1] and str[2] == str[3] and str[0] != str[2]
  ans = "Yes"
elsif str[0] == str[2] and str[1] == str[3] and str[0] != str[1]
  ans = "Yes"
elsif str[0] == str[3] and str[1] == str[2] and str[0] != str[1]
  ans = "Yes"
end

puts ans

Measured memory_bytes: 1788
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int,int>;


    int dp[100005];
    
    int main(){
       int n,k;cin>>n>>k;
       VEC(int,h,n);
       rep(i,n)dp[i] = INF;
       dp[0] = 0;dp[1] = abs(h[1]-h[0]);
       REP(i,2,n-1){
           rep(j,k){
               if(i-j-1<0)break;
               dp[i] = min(dp[i],dp[i-j-1]+abs(h[i]-h[i-j-1]));
           }
       }
       cout<<dp[n-1];
    }
    


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
char s[500003];
int main()
{
   scanf("%s",s);
   int a;
   a=strlen(s);
   for(int i=0;i<a-1;i++)
   {
       if(s[i]==s[i+1]){cout<<i+1<<" "<<i+2<<endl;return 0;}
       else if(i+2<a&&s[i]==s[i+2]){cout<<i+1<<" "<<i+3<<endl;return 0;}
       //else if(i+3<a&&s[i]==s[i+3]){cout<<i+1<<" "<<i+4<<endl;return 0;}
   }
   cout<<-1<<" "<<-1<<endl;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int bubbleSort(int A[],int N){
	int sw=0;//swap?????°????¨?????????????
	bool flag=1;
	for(int i=0;flag;i++){
		flag=0;
		for(int j=N-1;j>=i+1;j--){
			if(A[j]<A[j-1]){
				swap(A[j],A[j-1]);
				flag=1;//swap????????????flag???????????????i??????????¶??¶????
				//i????????????????????????????????????????????¨???????¢????????????????
				sw++;
			}
		}

	}
	return sw;

}

int main(){
	int A[100],N,sw;
	cin >> N;
	for(int i=0;i<N;i++)cin >> A[i];

		sw=bubbleSort(A,N);//??¢??°??????????????????????????????
		for(int i=0;i<N;i++){
			if(i)cout << " ";
			cout <<A[i];

		}
	cout <<endl;
	cout <<sw << endl;

	return 0;
	

}

Measured memory_bytes: 3080
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (N, T) = Read2Longs();
            long cost = 1001;
            for (var i = 0; i < N; i++)
            {
                var (c, t) = Read2Longs();
                if (T < t)
                {
                    continue;
                }
                if (cost >= c)
                {
                    cost = c;
                }
            }
            if(cost == 1001) { return "TLE"; }
            return cost;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 28224
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define MAXN 200000
#define DEBUG true

/*
sz[u] -> Size of subtree rooted at node u
cnt[c] -> Number of nodes below a subtree rooted at node with color c
sum[c] -> Number of paths which doesn't go through a node with color c
*/

int N, c[MAXN + 3], cnt[MAXN + 3], sz[MAXN + 3];
LL sum[MAXN + 3];
vector<int> adj[MAXN + 3];

LL C2(int n) {
    return ((LL) n * n + n)/2;
}

void DFS(int u, int prv) {
    sz[u] = 1;
    for (auto v: adj[u]) {
        if (v == prv) continue;

        int prvCnt = cnt[c[u]];

        DFS(v, u);

        int cntOther = sz[v] - (cnt[c[u]] - prvCnt);

        sum[c[u]] += C2(cntOther);
        cnt[c[u]] += cntOther;

        sz[u] += sz[v];
    }

    cnt[c[u]] += 1;
}

int main() {
    cin >> N;
    for (int i = 1; i <= N; i++)
        cin >> c[i];

    for (int i = 1; i < N; i++) {
        int u, v;
        cin >> u >> v;

        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    memset(sz, 0, sizeof(sz));
    memset(cnt, 0, sizeof(cnt));
    memset(sum, 0, sizeof(sum));

    DFS(1, 1);

    for (int c = 1; c <= N; c++) {
        LL all = C2(N);
        LL temp = (sz[1] - cnt[c]);
        cout << all - (sum[c] + C2(temp)) << endl;
    }
}


Measured memory_bytes: 34100
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;
ll dp[30][100000];

int main()
{
    ll n,m;
    cin >> n >> m;
    vector<ll> c(m);
    rep(i,m){
        cin >> c[i];
    }
    for(ll i=0;i<=m;i++){
        for(ll j=0;j<=n;j++){
            dp[i][j]=INF;
        }
    }
    dp[0][0]=0;
    rep(i,m){
        for(ll j=0;j<=n;j++){
            if(j<c[i]){
                dp[i+1][j]=dp[i][j];
            }
            else{
                dp[i+1][j]=min(dp[i][j],dp[i+1][j-c[i]]+1);
            }
            
        }
    }
    cout << dp[m][n] << endl;
    return 0;
} 


Measured memory_bytes: 11384
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    ll ans = 0;
    int tmp;
    ll n, k;
	vector<ll> a, f;
	vector<pair<ll, ll>> m;
	cin >> n >> k;
	REP(i, n){
		cin >> tmp;
		a.push_back((ll)-tmp);
	}
	REP(i, n){
		cin >> tmp;
		f.push_back((ll)tmp);
	}
	sort(a.begin(), a.end());
	sort(f.begin(), f.end());
	REP(i,n){
		m.push_back(make_pair(-a[i]*f[i], f[i]));
	}
	sort(m.begin(), m.end());
	//REP(i, m.size()) cout << m[i].first << ", " << m[i].second << endl;
	
	ll head = -1, tail = m[m.size()-1].first;
	ll now;
	while(head+1 < tail){
		now = (head + tail) /2;
		//cout << now << endl;
		ll rest = k;
		for(int i= m.size()-1; i>=0; i--){
			if(now < m[i].first){
				// << m[i].first << ", " << m[i].second << ", " << rest << endl;
				rest -= (m[i].first - now + m[i].second -1)/ m[i].second; 
			}
		}
		if (rest < 0){
			head = now;
		}
		else tail = now;
		
	}
    cout << tail << endl;
}

Measured memory_bytes: 9584
n_m = gets().split(" ")
n = n_m[0].to_i
m = n_m[1].to_i

n_count = Array.new(n,0)

for i in 1..m
	str = gets().split(" ")
	a = str[0].to_i
	b = str[1].to_i
	n_count[a-1] = n_count[a-1] + 1
	n_count[b-1] = n_count[b-1] + 1
end

for j in 1..n
	puts n_count[j-1]
end

Measured memory_bytes: 1788
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <map>

using namespace std;
#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int MOD = 1000000007;
constexpr int SIZE = 100100;

int dp1[SIZE];
int dp2[SIZE];


int pow(int a, int b) {
  int ret = 1;
  while (b) {
    if (b & 1) {
      ret = ret * a % MOD;
    }
    a = a * a % MOD, b >>= 1;
  }
  return ret;
}

void solve() {
    string L;
    cin >> L;

    int l = 0;
    int ret = 0;
    for (int i = 0; i < L.size(); i++) {
        int len = L.size() - i - 1;
        if (L[i] == '1') {
            ret = (ret + pow(2, l) * pow(3, len)) % MOD;
            l++;
        }
    }

    ret += pow(2, l);
    cout << ret % MOD << endl;

}

signed main() {
    solve();
    return 0;
}


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

//Made with <3 by MinumCoklatPanas
typedef long long ll;
const int INF = 1e9;
const ll INFF = 1e18;
const int MAXN = 510;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double INFD = 1E9;
const double EPS = 1e-9;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,k;
    cin >> n >> k;
    if (n % k == 0)
    {
        cout << 0 << endl;
        return 0;
    }
    ll ans = min(n,k - (n % k));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3560
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

int N,ans;
bool* state;

struct Info{
	Info(){
		x = y = r = 0.0;
		color = 0;
	}
	double x,y,r;
	int color;
};


bool isOverlap(Info left,Info right){
	double dist = sqrt((left.x-right.x)*(left.x-right.x)+(left.y-right.y)*(left.y-right.y));
	return dist <  left.r + right.r;
}


int makeCode(bool removed[]){

	int ret = 0;

	int S = 1;
	for(int i = 0; i <= N-1; i++){
		if(removed[i]){
			ret += S;
		}
		S *= 2;
	}
	return ret;
}


void recursive(Info info[],bool removed[],int count){

	if(count == N || ans == N)return;

	ans = max(ans,count);

	bool check[N],over_rapFLG;

	for(int i = 0; i < N; i++)check[i] = false;

	for(int i = N-1; i >= 0; i--){

		if(removed[i] == true)continue;

		over_rapFLG = false;

		for(int j = i-1; j >=0; j--){

			if(removed[j] == true)continue;

			if(isOverlap(info[i],info[j])){
				over_rapFLG = true;
				break;
			}
		}
		if(!over_rapFLG){
			check[i] = true;
		}
	}

	for(int i = 0; i < N-1; i++){
		for(int k = i+1; k < N; k++){
			if(check[i] == true && check[k] == true && info[i].color == info[k].color){
				if(count == N-2){
					ans = N;
					return;
				}

				bool next_removed[N];
				for(int i = 0; i < N; i++)next_removed[i] = removed[i];
				next_removed[i] = true;
				next_removed[k] = true;

				int code = makeCode(next_removed);

				if(state[code] == false){
					state[code] = true;
					recursive(info,next_removed,count+2);
				}
			}
		}
	}
}

void func(){
	Info info[N];

	int limit = pow(2,N);

	for(int i = 0; i < limit; i++)state[i] = false;

	for(int i = 0; i < N; i++){
		scanf("%lf %lf %lf %d",&info[i].x,&info[i].y,&info[i].r,&info[i].color);
	}

	ans = 0;

	bool removed[N];
	for(int i = 0; i < N; i++)removed[i] = false;

	recursive(info,removed,0);

	printf("%d\n",ans);
}

int main(){

	state = new bool[16777216];

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 19188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		double r = sc.nextDouble();
		double x = Math.PI;

		double menseki = r * r * x;
		double enshu = 2 * x * r;

		System.out.printf("%f", menseki);
		System.out.print( " ");
		System.out.printf("%f", enshu);

	}

}



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

int main() {
  long long N;
  cin >> N;
  vector<long long> A(N);
  for (long long i=0; i<N; i++) {
    cin >> A.at(i);
  }
  
  long long M=0, ans=0;
  for (long long i=1; i<N; i++) {
    M = max(M, A.at(i-1));
    if (M > A.at(i)) {
      ans += (M - A.at(i));
    }
    //cout << ans << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4832
#include <iostream>

using namespace std;

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

    int res = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        if (i % 2 == 0 && a % 2 == 1) {
            res++;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 3608
package main

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

var sc = bufio.NewScanner(os.Stdin)

func inputInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func splitInt(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = inputInt()
	}
	return arr
}

type sortable [][]int

func (s sortable) Len() int { return len(s) }

func (s sortable) Less(i, j int) bool { return s[i][0] < s[j][0] }

func (s sortable) Swap(i, j int) { s[i], s[j] = s[j], s[i] }

func main() {
	sc.Split(bufio.ScanWords)
	n := inputInt()
	as := splitInt(n)
	ans := make([]int, n)
	for i := 0; i < n; i++ {
		ans[as[i]-1] = i + 1
	}

	first := true
	for _, x := range ans {
		if !first {
			fmt.Print(" ")
		}
		fmt.Printf("%d", x)
		first = false
	}
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;



int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n, m;
    cin >> n >> m;
    string s = "";
    for(int i = 0; i < n; i++) s.push_back('*');
    for(int i = 0; i < m; i++){
        int x, k;
        cin >> x >> k;
        x--;
        if(s[x] != '*' && s[x] != '0' + k) return cout << -1, 0;
        s[x] = char ('0' + k);
        if(x + k == 0 && n > 1) return cout << -1, 0;
    }
    for(int i = 0; i < n; i++){
        if(s[i] == '*') s[i] = '0';
    }
    if(s[0] == '0' && n > 1) s[0] = '1';
    cout << s;


    return 0;
}


Measured memory_bytes: 3596
#include<stdio.h>
int main(void){
char a[101][101];
int i,j,H,W,count=-1,start=0;
scanf("%d%d",&H,&W);
for(i=0;i<H;i++){
	scanf("%s",a[i]);
}
for(i=0;i<H;i++){
	for(j=0;j<W;j++){
	if(a[i][j]=='c'){
		printf("0");
		start=1;
		count=0;
		}else{
		printf("%d",count);
		}
	if(j<W-1){
	printf(" ");
	}else{
	printf("\n");
	}
	if(start==1){
	count++;
	}

	}
start=0;
count=-1;
}
return 0;
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(ll i=(a); i<(b); i++)

const ll maxk=1e5+5, maxn=100+5;
ll n,k,a[maxn], dp[maxk];

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    cin>>n>>k;
    rep(i,0,n) cin>>a[i];
    dp[0]=0;
    rep(i,1,k+1) {
        rep(j,0,n) {
            if(a[j]<=i && dp[i-a[j]]==0)
                dp[i]=1;
        }
    }
    cout<<(dp[k]?"First":"Second")<<"\n";
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_N 20000
#define MAX_M 16

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

string l = "qwertasdfgzxcvb";
string s;

int main(){
	while (cin >> s&&s != "#"){
		bool f = 1;
		int co = 0;
		if (l.find(s[0]) != -1)f = 0;
		REP(i, s.size()){
			if (f){
				if (l.find(s[i]) != -1){
					co++;
					f = 0;
				}
			}
			else{
				if (l.find(s[i]) == -1){
					co++;
					f = 1;
				}
			}
		}
		cout << co << endl;
	}
}

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

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=a;i--)
#define per(i,b) gnr(i,0,b)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define fs first
#define sc second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif
#define tmp template<class t>

tmp void chmax(t&a,t b){if(a<b)a=b;}
tmp void chmin(t&a,t b){if(a>b)a=b;}

tmp using vc=vector<t>;
tmp using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.fs<<","<<p.sc<<"}";
}

tmp ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

constexpr ll ten(int n){
	return n==0?1:ten(n-1)*10;
}

tmp void mkuni(vc<t>&v){
	sort(all(v));
	v.erase(unique(all(v)),v.ed);
}

ll read(){ll i;cin>>i;return i;}

using ld=long double;
using cm=complex<ld>;
#define x real()
#define y imag()
const ld eps=1e-12;
int sgn(ld a){return a<-eps?-1:(a>eps?1:0);}
auto cmcmp=[](const cm&a,const cm&b){
	if(sgn(a.x-b.x))return a.x<b.x;
	else return sgn(a.y-b.y)<0;
};

struct ln{
	cm a,b;
	cm dir(){return b-a;}
};
ld dot(cm a,cm b){return a.x*b.x+a.y*b.y;}
ld crs(cm a,cm b){return a.x*b.y-a.y*b.x;}
int ccw(cm a,cm b){return sgn(crs(a,b));}
int ccw(cm a,cm b,cm c){return ccw(b-a,c-a);}
int ccw(ln a,cm b){return ccw(a.a,a.b,b);}

//(-2)[a,-1](0)[b,1](2)
int bet(cm a,cm b,cm c){
	cm d=b-a;
	ld e=dot(d,c-a);
	if(sgn(e)<=0)return sgn(e)-1;
	return sgn(e-norm(d))+1;
}

ld tri2(cm a,cm b,cm c){
	return crs(b-a,c-a);
}

cm proj(ln a,cm b){
	cm c=a.dir();
	return a.a+c*dot(c,b-a.a)/norm(c);
}

cm refl(ln a,cm b){
	return ld(2)*proj(a,b)-b;
}

cm readcm(){
	ld a,b;
	char c;
	cin>>a>>c>>b;
	return cm(a,b);
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
	
	while(1){
		char z;
		cm a=readcm();
		cin>>z;
		cm b=readcm();
		cin>>z;
		cm c=readcm();
		if(cin.eof())break;
		cm d=refl(ln{a,b},c);
		cout<<d.x<<" "<<d.y<<endl;
	}
}



Measured memory_bytes: 3320
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<stack>
#include<cstdlib> 
using namespace std;
int a[100005];
bool v[100005];
int main(){
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]==i) v[i]=false;
		else v[i]=true;
	} 
	for(int i=1;i<n;i++){
		if(v[i]==false&&v[i+1]==false){
			ans++;
			v[i]=true;
			v[i+1]=true;
		}
	} 
	for(int i=1;i<=n;i++){
		if(v[i]==false){
			ans++;
		}
	} 
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 768
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::ops::Bound::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout]
fn main() {
    input! {
        n: u64,
    }
    let M = 1_000_000_007u64;

    let all = mod_pow(10, n, M) + 5 * M;
    let sub1 = mod_pow(9, n, M);
    let sub2 = mod_pow(8, n, M);

    let ans = (all - 2 * sub1 + sub2) % M;
    println!("{}", ans);

}

#[allow(dead_code)]
pub fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}
#[allow(dead_code)]
pub fn lcm(a: u64, b: u64) -> u64 {
    a / gcd(a, b) * b
}
#[allow(dead_code)]
/// (gcd, x, y)
pub fn extgcd(a: i64, b: i64) -> (i64, i64, i64) {
    if b == 0 {
        (a, 1, 0)
    } else {
        let (gcd, x, y) = extgcd(b, a % b);
        (gcd, y, x - (a / b) * y)
    }
}
#[allow(dead_code)]
/// x ^ n % m
pub fn mod_pow(x: u64, n: u64, m: u64) -> u64 {
    let mut res = 1;
    let mut x = x % m;
    let mut n = n;
    while n > 0 {
        if n & 1 == 1 {
            res = (res * x) % m;
        }
        x = (x * x) % m;
        n >>= 1;
    }
    res
}
#[allow(dead_code)]
pub fn mod_inverse(a: u64, m: u64) -> u64 {
    let (_, x, _) = extgcd(a as i64, m as i64);
    ((m as i64 + x) as u64 % m) % m
}
#[allow(dead_code)]
pub fn fact_table(len: usize, m: u64) -> Vec<u64> {
    let mut res = vec![1; len + 1];
    for i in 1..len + 1 {
        res[i] = (i as u64 * res[i - 1]) % m;
    }
    res
}
#[allow(dead_code)]
/// Factorial and Inverse factorial table
pub fn fact_inv_table(size: usize, m: u64) -> (Vec<u64>, Vec<u64>) {
    let mut fact = vec![1; size];
    let mut fact_inv = vec![1; size];
    for i in 2..size {
        fact[i] = fact[i - 1] * i as u64 % m;
        fact_inv[i] = m - ((m / i as u64) * fact_inv[(m % i as u64) as usize] % m);
    }
    for i in 1..size {
        fact_inv[i] = fact_inv[i - 1] * fact_inv[i] % m;
    }
    (fact, fact_inv)
}
#[allow(dead_code)]
/// (a mod p, e when n! = a p\^e)
pub fn mod_fact(n: u64, p: u64, fact: &[u64]) -> (u64, u64) {
    if n == 0 {
        (1, 0)
    } else {
        let (a, b) = mod_fact(n / p, p, fact);
        let pow = b + n / p;
        if n / p % 2 != 0 {
            (a * (p - fact[(n % p) as usize]) % p, pow)
        } else {
            (a * fact[(n % p) as usize] % p, pow)
        }
    }
}
#[allow(dead_code)]
/// C(n, k) % p
pub fn mod_comb(n: u64, k: u64, p: u64, fact: &[u64]) -> u64 {
    if n < k {
        0
    } else {
        let (a1, e1) = mod_fact(n, p, fact);
        let (a2, e2) = mod_fact(k, p, fact);
        let (a3, e3) = mod_fact(n - k, p, fact);
        if e1 > e2 + e3 {
            0
        } else {
            a1 * mod_inverse(a2 * a3 % p, p) % p
        }
    }
}
#[allow(dead_code)]
/// H(n, k) % p
pub fn mod_comb_repetition(n: u64, k: u64, p: u64, fact: &[u64]) -> u64 {
    mod_comb(n - 1 + k, n - 1, p, fact)
}


Measured memory_bytes: 2200
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeSynonymInstances #-}

import Control.Applicative
import Control.DeepSeq
import Control.Monad
import Control.Monad.ST
import qualified Data.Array as A
import qualified Data.Array.IArray as IA
import qualified Data.Array.IO as AI
import qualified Data.Array.MArray as MA
import qualified Data.Array.ST as STA
import qualified Data.Array.Unboxed as AU
import Data.Bits
import qualified Data.ByteString.Char8 as BS
import Data.Char
import qualified Data.Graph as G
import Data.Int
import qualified Data.IntMap as IM
import qualified Data.IntSet as IS
import Data.List
import qualified Data.Map.Strict as M
import Data.Maybe
import Data.Ord
import qualified Data.Sequence as SQ
import qualified Data.Set as S
import Data.Time
import qualified Data.Tree as T
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

class Printable a where
  format :: a -> String

instance Printable Int where
  format = show

instance Printable Integer where
  format = show

instance Printable Double where
  format = show

instance Printable Float where
  format = show

instance Printable Char where
  format = show

instance Printable String where
  format x = x

instance Printable Bool where
  format = show

put :: Printable a => a -> IO ()
put = putStr . format

putLn :: Printable a => a -> IO ()
putLn = putStrLn . format

putList :: Printable a => [a] -> IO ()
putList [a] = put a
putList (a:as) = do
  put a
  putStr " "
  putList as

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

main = do
  n <- getLine
  put $ f n

f [] = []
f (n:ns)
  | n == '1' = "9" ++ f ns
  | otherwise = "1" ++ f ns

Measured memory_bytes: 380
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2104

"""
import sys
from sys import stdin
from bisect import bisect_left
input = stdin.readline


def main(args):
    t = int(input())
    for _ in range(t):
        n, k = map(int, input().split())
        houses = [int(x) for x in input().split()]

        if k >= n:              #  ????????¨?????????????????¨?????§??????
            print(0)
            continue


        diff = []
        prev = houses[0]
        for i, h in enumerate(houses[1:]):
            diff.append((h - prev, i))
            prev = h


        diff.sort(reverse=True)
        points = diff[:k-1]


        cable_total = 0
        prev = 0
        for _, p in points:
            cable_total += houses[p] - houses[prev]
            prev = p + 1
        if prev != (n - 1):
            cable_total += houses[-1] - houses[prev]

        print(cable_total)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 34056
#include<iostream>

using namespace std;

#define	mp	make_pair
#define	Y	first
#define	X	second

typedef	pair<int,int>	pii;

pii floor[100][100];
int visited[100][100];

int main(){
	for(int n;cin>>n,n;){
		for(int i=0;i<n;i++)for(int j=0;j<n;j++){
			cin>>floor[i][j].X>>floor[i][j].Y;
			visited[i][j]=-1;
		}

		int cnt=0,loops=0;
		for(int i=0;i<n;i++)for(int j=0;j<n;j++){
			if(visited[i][j]==-1){
				int y=i,x=j;
				do{
					visited[y][x]=loops;
					pii nxt=floor[y][x];
					y=nxt.Y;
					x=nxt.X;
				}while(visited[y][x]==-1);
				if(visited[y][x]==loops)	cnt++;
				loops++;
			}
		}

		cout<<cnt<<endl;
	}

	return 0;
}

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

char c[25][25];
void dfs(int x,int y,int w,int h) {
	c[x][y] = '!';

	for (int i = -1;i <= 1;i++) {
		int ax = x + i;
		if (ax >= 0 && ax < h&&c[ax][y] == '.')dfs(ax, y, w, h);
	}
	for (int i = -1;i<= 1;i++) {
		int ay = y + i;
		if (ay >= 0 && ay < w&&c[x][ay] == '.')dfs(x, ay, w, h);
	}
}

int main() {
	int w, h;
	while (cin >> w >> h,w,h) {
		for (int i = 0;i < h;i++) {
			for (int j = 0;j < w;j++)cin >> c[i][j];
		}

		for (int i = 0;i < h;i++) {
			for (int j = 0;j < w;j++) {
				if (c[i][j] == '@')dfs(i,j,w,h);
			}
		}
		int al = 0;
		for (int i = 0;i < h;i++) {
			for (int j = 0;j < w;j++) {
				if (c[i][j] == '!')al++;
			}
		}
		cout << al << endl;
	}
	return 0;
}

Measured memory_bytes: 2980
#include <bits/stdc++.h>
using namespace std;
const int N = 1e2+5;
int n, a[N], ans;
int main()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i) scanf("%d", a+i);
    for(int i = 1, c = 0; i <= n+1; ++i)
        if(a[i] != a[i-1]) ans += c/2, c = 1; else ++c;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3776
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int n;
  cin>>n;
  LL c[n];
  LL com[n]; //0~iまでの組み合わせ
  map<int, int> mp; //最後に見たciの位置
  REP(i, n){
    cin>>c[i];
    mp[c[i]]=-1;
  }

  if(n==1){
    cout<<1<<endl;
    return 0;
  }
  com[0] = 1;
  mp[c[0]]=0;
  int forw;
  FOR(i, 1, n){
    forw = mp[c[i]];
    if(forw==i-1 || forw==-1) {
      com[i]=com[i-1];
    }
    else{
      com[i] = com[forw] + com[i-1];
      com[i] %= MOD;
    }
    mp[c[i]]=i;
    //cout<<com[i]<<endl;
  }

  cout<<com[n-1]<<endl;

  return 0;
}


Measured memory_bytes: 12800
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int a[110][110];
int dp[110][110];

int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        memset(a,0,sizeof(a));
        for(int i=1;i<=2;i++)
            for(int j=1;j<=n;j++)
            scanf("%d",&a[i][j]);
        memset(dp,0,sizeof(dp));

        for(int i=1;i<=2;i++)
            for(int j=1;j<=n;j++)
            dp[i][j]=a[i][j]+max(dp[i-1][j],dp[i][j-1]);
        printf("%d\n",dp[2][n]);
    }
    return 0;
}


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

int main() {
  int N,M,i,count;
  cin >> N >>M;
 if(N <=M){
 i+=M;
   if(N <=M-1){
   i+=M-1;
   }else{
   i+=N;
   }
 }
 else {
 i+=N;
   if(N-1 <=1){
   i+=M;
 	}else{
   i+=N-1;
   }
 }  
 cout << i << endl;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a, b, c ,d;
	cin >> a >> b;
	c = a + b;
	if (c%2 == 1)
		d = c/2 + 1;
	else
		d = c/2;
	cout << d << endl;
	return 0;
}

Measured memory_bytes: 256
// Aizu Vol-0 0072: Carden Lanternl
// 2017.8.6

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

char *gets(char *);
char buf[100], *p;
int getInt(void)
{
	int n = 0;
	while (isspace(*p) || *p == ',') p++;
	while (isdigit(*p)) n = 10 * n + (*p++ - '0');
	return n;
}

#define INF 0x77777777
#define MAX 100
int N;
int d[MAX + 2][MAX + 2];
int visited[MAX];
int Q[MAX + 2], end;

int main()
{
	int a, b, i, j, k, n, m, min, ans;

	while (1) {
		gets(p = buf); if (!(N = getInt())) break;
		gets(p = buf); m = getInt();
		memset(d, 0x77, sizeof(d));
		for (i = 0; i < m; i++) {
			gets(p = buf); a = getInt(), b = getInt(), j = getInt()/100-1;
			if (j < d[a][b]) d[a][b] = d[b][a] = j;
		}
		memset(visited, 0, sizeof(visited));
		ans = 0, visited[0] = 1, n = 1, Q[0] = 0, end = 1;
		while (n < N) {
			for (k = end-1, min = INF; k >= 0; k--) {
				i = Q[k];
				for (j = 0; j < N; j++) {
					if (!visited[j] && d[i][j] < min) min = d[i][j], a = i, b = j;
				}
			}
			ans += min, visited[b] = 1, n++, Q[end++] = b;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 564
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::vec::Vec;
use std::{vec, cmp, num};


struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

// create Vec<char> from String
#[allow(dead_code)]
fn to_chars(s: String) -> vec::Vec<char> {
    let mut cs = s.chars();
    let mut res = vec::Vec::new();
    while let Some(c) = cs.next() {
        res.push(c);
    }
    res
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let r: i32 = sc.read();
    let g: i32 = sc.read();
    println!("{}", 2 * g - r);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
  int m,n;

  while(1){
    
    cin>>m>>n;
    
    if(m==0 && n==0)break;
    
    int a[10000];
    string b[10000];
    int c[10000];
    int k[10000];
    
    for(int i=0;i<n;i++){
      cin>>b[i];
      if((i+1)%15==0 ){
	if(b[i]=="FizzBuzz"){a[i]=1;}else{a[i]=0;}
      }else if((i+1)%3==0){
	if(b[i]=="Fizz"){a[i]=1;}else{a[i]=0;}
      }else if((i+1)%5==0){
	if(b[i]=="Buzz"){a[i]=1;}else{a[i]=0;}
      }else if(b[i]!="FizzBuzz"&&b[i]!="Buzz"&&b[i]!="Fizz"){
	c[i]=atoi(b[i].c_str());
	int d=i+1;
	if(c[i]==d){a[i]=1;}else{a[i]=0;}
      }else{a[i]=0;}
  
    }
    
    for(int i=0;i<=m;i++){k[i]=1;}
    int e=0;
    int count=0;
    int t=0;
    int q=0;

    for(int i=0;i<n;i++){
      
      for(int j=0;j<m;j++){
	if(k[j]==0){count++;}
      }
      if(count==m-1){
	for(int j=0;j<m;j++){
	  if(k[j]==1){
	    q++;
	    if(q==1){cout<<j+1;}
	    else{cout<<" "<<j+1;}
	  }
	}
	cout<<endl;
	i=n;
	t=1;
      }
      else if(k[e]==0){
	e++;
	i--;
      }else if(a[i]==0){
	k[e]=0;
	e++;
      }else if(a[i]==1){
	k[e]=1;
	e++;
      }
      if(e>m-1){e=0;}
      else{count=0;}
    }

    q=0;
    if(t!=1){
      for(int i=0;i<m;i++){
	if(k[i]==1){
	  q++;
	  if(q==1){cout<<i+1;}
	  else{cout<<" "<<i+1;}
	}
      }
      cout<<endl;
      
    }
  }
}



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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    ll N; cin >> N;
    ll P[200005];
    ll mi = LLONG_MAX;
    ll ans = 0;
    for (int i = 0;i < N;i++){
        cin >> P[i];
        if(i == 0){
            ans++;
            mi = P[i];
            continue;
        }
        if(mi >= P[i]){
            ans++;
            mi = P[i];
        }
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#include <complex>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef complex<double> P;

vector<P> pos;
double theta;

double move (double len )
{
	P p = pos.back();

	P q = p + len*exp (complex<double> (.0, theta*M_PI/180. ) );
	pos.push_back (q); 
}

void koch (int n, double len )
{
	if (n == 0 ){
		move (len );
	}else{
		koch (n-1, len );
		theta += 60.;
		koch (n-1, len );
		theta -= 120.;
		koch (n-1, len );
		theta += 60.;
		koch (n-1, len );
	} // end if		
}
int main()
{
	pos.clear();

	ios_base::sync_with_stdio(0);
	int n; cin >> n;
	P p1 = P(0., 0. );
	P p2 = P(100., 0. );
	double len = abs (p2 - p1)/pow(3., n);

	theta = 0.;
	pos.push_back (p1 );

	koch (n, len );

	rep (i, pos.size() ) printf ("%.8lf %.8lf\n", pos[i].real(), pos[i].imag() );

	return 0;
}

Measured memory_bytes: 1404
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) begin(x),end(x)

#define forn(i, n) for (int i = 0; i < n; ++i)
#define rforn(i, n) for (int i = n - 1; i >= 0; --i)

const int N = 2e5 + 5, M = 1e9 + 7; // 998244353
const int dx[]{0, 1, 0, -1}, dy[]{1, 0, -1, 0};
const ll INF = 1e18 + 10LL;
const ld PI = 4.0 * atan((ld) 1.0), EPS = 1e-6;
const char nl = '\n';

template <typename T> inline T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> inline T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> void ckmin(T& a, T b) { a = min(a, b); }
template <class T> void ckmax(T& a, T b) { a = max(a, b); }
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

string YN(bool x) { return x ? "YES" : "NO"; }

ll pow(ll b, ll e, ll m = 0LL, ll ans = 1LL) { while (e) { if (e & 1LL) { ans *= b; if (m) ans %= m; } b *= b, e >>= 1LL; if (m) b %= m; } return ans; }

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

void solve(int tcn) {
	ll x;
	cin >> x;
	ll k = lcm(x, 360LL) / x;
	cout << k << nl;
}

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

	int t = 1; //cin >> t;
	for (int i = 1; i <= t; ++i) {
		solve(i);
	}
	return 0;
}


Measured memory_bytes: 3612
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=10007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string str;cin>>str;
	llint ans=0,i,x=0;
	for(i=0;i<str.size();i++){
		if(str[i]=='B'){x++;}
		else{ans+=x;}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 720
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *                                                                       *
 *          Fortis Fortuna Adiuvat                                       * 
 *                          "Fortune Favours the bold"                   *
 *                                                                       *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define vll vector<int>
#define pb push_back
#define pll pair<int, int>
#define w(t) int t; cin >> t; while(t--)
#define print(x,y) cout << x << " " << y << endl
#define deb(x) cout << #x << " = " << x << endl
#define deb2(x, y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define setbits(x) __builtin_popcountll(x)
#define endl "\n"

template <typename T>
void write(vector<T> &a) {        
    for(auto it = a.begin(); it != a.end(); it++)
        cout << *it << " ";
    cout << endl;}
void random(int nMin, int nMax, int n){
    srand(time(0));
    for(int i = 0; i < n; i++){
        double var = nMin + (int)((double)rand() / ((double)RAND_MAX+1) * (nMax-nMin+1));cout << var << " ";}cout << endl;
}
///////////Helper Functions///////////


////////////Main Method///////////////
int32_t main()
{
//////////////////////////////////////////////////////////
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cout << setprecision(15);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif
//////////////////// Code Here ///////////////////////////    
{
    int n;cin >> n;
    if(n >= 30)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}    
return 0 ;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int main(void){
    int n;

    cin >> n;
 
    vector<int> btn(n);
    vector<int> alrdy(n);

    for (int i = 0; i < n; i++ ) {
        btn[i] = 0;
        alrdy[i] = 0;
    }

    int current = 0;
    int number = 0;

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

    for (int i = 0; i< n; i++) {
        current = btn[current];

        if (alrdy[current] == 1) {
            printf("-1 \n");
            return 0;
        } else {
            alrdy[current] = 1;
            number++;
        }

        if (current == 1) {
            printf("%d \n", number);
            return 0;
        }
    }

    printf("-1 \n");
    return 0;
}

Measured memory_bytes: 1024
fn main(){
  let list: Vec<i32> = read_vec();
  println!("{}", list[0] * list[1]);
}

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

Measured memory_bytes: 2136
import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new
		// File("D:\\UserArea\\J0124567\\Downloads\\ALDS1_6_A-in9.txt"));

		int q = scan.nextInt();

		for (int i = 0; i < q; i++) {
			String s1 = scan.next();
			String s2 = scan.next();
			for (int x = 0; x < save.length; x++)
				for (int y = 0; y < save[0].length; y++)
					save[x][y] = -1;
			System.out.println(Msubs(s1, s2, 0, 0));
		}

		scan.close();
		System.exit(0);
	}

	static int[][] save = new int[1000][1000];

	private static int Msubs(String s1, String s2, int p1, int p2) {
		if (p1 == s1.length() || p2 == s2.length())
			return 0;
		if (save[p1][p2] == -1) {
			if (s1.charAt(p1) == s2.charAt(p2))
				save[p1][p2] = 1 + Msubs(s1, s2, p1 + 1, p2 + 1);
			else
				save[p1][p2] = Math.max(Msubs(s1, s2, p1 + 1, p2), Msubs(s1, s2, p1, p2 + 1));
		}
		return save[p1][p2];
	}
}



Measured memory_bytes: 33128
from bisect import bisect_left

n = input()
a = list(map(int, input().split()))
a.sort()
N = a[-1]
i = bisect_left(a, (N + 1) // 2)
K1 = a[i]
K2 = a[i - 1]
if K1 != N and N - K1 > K2:
    K = K1
else:
    K = K2
print(N, K)

Measured memory_bytes: 14428
using System;
using System.Linq;
using System.Collections.Generic;

class Mondai
{
    static void Main()
    {
        var waru= 1000000007;
        var nm = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        var N = nm[0];
        var M = nm[1];
        var a = new int[M];
        for (int i=0;i<M;++i) a[i] = Int32.Parse(Console.ReadLine());
        var dp = new int[N + 1];
        dp[0] = 1;
        var index = 0;
        for (int i=1;i<=N;++i)
        {
            if (index<M && a[index] == i)
            {
                index++;
                continue;
            }
            dp[i] = (dp[i]+dp[i - 1])% waru;
            if(2<=i)dp[i] = (dp[i]+dp[i - 2])% waru;
        }
        Console.WriteLine(dp[N]);
    }
}

Measured memory_bytes: 13920
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int A = int.Parse(s[0]);
            int B = int.Parse(s[1]);

            int ans = 0;

            if (A>B)
            {
                ans += A;
                A--;
                ans += A;
            }
            else if (B>A)
            {
                ans += B;
                B--;
                ans += B;
            }
            else
            {
                ans = A + B;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
const int mod=998244353;
typedef long long ll;

int gi() {
	int x=0,o=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}

char s[N];
int n,ans=1,cnt[4],tot[210];
vector<char> v[210];

int main() {
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	cin>>n;scanf("%s",s+1);
	v['R']={'G','B'},v['G']={'R','B'},v['B']={'R','G'};
	for(int i=n+n+n;i;i--) {
		bool fl=1;
		for(auto c:v[s[i]]) if(!tot[c]) fl=0;
		if(fl) {
			ans=1ll*ans*cnt[2]%mod,--cnt[2];
			for(auto c:v[s[i]]) --tot[c];
		}
		else {
			bool fl=0;
			char id;
			for(auto c:v[s[i]]) if(tot[c]) fl=1,id=c;
			if(fl&&cnt[1]&&tot[id]>tot[s[i]]) {
				ans=1ll*ans*cnt[1]%mod,--cnt[1],++cnt[2];
				++tot[s[i]];
			}
			else ++cnt[1],++tot[s[i]];
		}
		//cerr<<i<<' '<<cnt[1]<<' '<<cnt[2]<<' '<<cnt[3]<<' '<<ans<<endl;
	}
	for(int i=1;i<=n;i++) ans=1ll*ans*i%mod;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 512
import java.util.*
 
fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}
 
object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val R = sc.next().toInt()
        pw.println(Math.PI * R * 2)
    }
}

Measured memory_bytes: 36532
#include <iostream>

using namespace std;

int Integral(int h, int d)
{
	if(h >= 600)	return 0;
	else		return (h*h*d) + Integral(h+d, d);

}
int main()
{
	int d;

	while (cin >> d)
	{
		cout << Integral(d, d) << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
//ITP 1_8_A
#include <iostream>
#include<string>
using namespace std;

int main() {
	string s;
	getline(cin,s);
	for(int i=0; i<s.length(); i++)
	{
		if(s[i]>='a'&&s[i]<='z')s[i]-='a'-'A';
		else if(s[i]>='A'&&s[i]<='Z')s[i]+='a'-'A';
	}
	cout << s << endl;
	return 0;
}



Measured memory_bytes: 3104
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
int a, b;
int main() {
	scanf("%d%d", &a, &b);
	if(a > b)printf("%d\n", a - 1);
	else printf("%d\n", a);
	return 0;
}

Measured memory_bytes: 128