akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace ABC163
{
    public class Solve
    {
        public static void Main(string[] args)
        {
            new ABC_A();
        }
    }
    public class ABC_A
    {
        public ABC_A()
        {
            var r = Ex.ReadInt;
            Ex.Cw(r * 2 * Math.PI);
        }
    }
    public class ABC_B
    {
        public ABC_B()
        {
        }
    }
    public class ABC_C
    {
        public ABC_C()
        {

        }
    }
    public class ABC_D
    {
        public ABC_D()
        {
        }
    }
    public class ABC_E
    {
        public ABC_E()
        {
        }
    }
    public class ABC_F
    {
        public ABC_F()
        {
        }
    }
    public static class Ex
    {
        public static void Cw(this object s) { Console.WriteLine(s); }

        public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.Ordinal); return s.ToList(); }
        public static string yesno(this bool b) { return b ? "yes" : "no"; }
        public static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        public static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        public static string Read { get { return Console.ReadLine().Trim(); } }
        public static int ReadInt { get { return int.Parse(Read); } }
        public static long ReadLong { get { return long.Parse(Read); } }
        public static double ReadDouble { get { return double.Parse(Read); } }
        public static string[] ReadArray() { return Read.Split(' '); }
        public static int[] ReadIntArray() { return Read.Split(' ').Select(int.Parse).ToArray(); }
        public static long[] ReadLongArray() { return Read.Split(' ').Select(long.Parse).ToArray(); }
        public static string[] ReadArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public static int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public static long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 18608
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func init() {
	scanner.Split(bufio.ScanWords)
}

func ScanInt() int {
	scanner.Scan()
	t := scanner.Text()
	n, _ := strconv.Atoi(t)
	return n
}

func main() {
	n, m := ScanInt(), ScanInt()
	if n >= m {
		fmt.Println(0)
		return
	}
	xs := make([]int, m)
	for i := 0; i < m; i++ {
		xs[i] = ScanInt()
	}
	sort.Ints(xs)
	ds := make([]int, m-1)
	for i := 0; i < m-1; i++ {
		ds[i] = xs[i+1] - xs[i]
	}
	ret := 0
	sort.Ints(ds)
	for i := 0; i < m-1-(n-1); i++ {
		ret += ds[i]
	}
	fmt.Println(ret)
}


Measured memory_bytes: 4148
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	double n;
	cin >> n;

	vector<double> a(n);
	for (auto &v : a) {
		cin >> v;
	}

	double sum = 0.0;
	for (int i = 0; i < n; i++) {
		sum += a[i];
	}

	int ans = 0;
	double avg = sum / n, diff = 1e9;
	for (int i = 0; i < n; i++) {
		if (diff > abs(avg - a[i])) {
			diff = abs(avg - a[i]);
			ans = i;
		}
	}

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


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int a,b,c,d,e,f,sum,mn1,mn2;
	mn1=999;
	scanf("%d",&a);
	mn1=min(mn1,a);
	scanf("%d",&b);
	mn1=min(mn1,b);	
	scanf("%d",&c);
	mn1=min(mn1,c);
	scanf("%d",&d);
	mn1=min(mn1,d);
	mn2=999;
	scanf("%d",&e);
	mn2=min(mn2,e);
	scanf("%d",&f);
	mn2=min(mn2,f);
	sum=a+b+c+d+e+f-mn1-mn2;
	printf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 1028
#include<cstdio>
using namespace std;
#define LL long long
LL s(LL x){
	LL ret=0;
	while(x){
		ret+=x%10;
		x/=10;
	}
	return ret;
}
int main(){
	int k;
	scanf("%d",&k);
	LL per=1;
	LL d=1;
	while(k--){
		printf("%lld\n",per);
		if(s(per+d)*(per+d*10)<s(per+d*10)*(per+d)){
			d*=10;
		}
		per+=d;
	}
}


Measured memory_bytes: 128
#include <stdio.h>
int main(){
  int i,n,k,result=1;
  
  scanf("%d %d",&n,&k);
  
  for(i=0;i<n;i++){
    if(i==0){
      result*=k;
    } else {
      result*=(k-1);
    }
  }
  
  printf("%d",result);
}

Measured memory_bytes: 128
import heapq as pq
inf = float("inf")
n,e,r = map(int, input().split())
M = [[] for i in range(n)]

for i in range(e):
    s,t,d = map(int, input().split())
    M[s].append([t,d])
 
def dijkstra(s):
    color = [0] * n
    d = [inf] * n
    d[s] = 0
    H =[]
    pq.heappush(H, [0, s])
 
    while len(H) != 0:
        u2,u1 = pq.heappop(H)
        color[u1] = 1
        if d[u1] < u2:
            continue
        for v1,v2 in M[u1]:
            if color[v1] == 1: continue
            if d[u1] + v2 < d[v1]:
                d[v1] = d[u1] + v2
                pq.heappush(H, [d[v1], v1])
    return d
 
d = dijkstra(r)
for i in d:
 if i == inf: print("INF")
 else: print(i)

Measured memory_bytes: 110720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<string,int> mp;
int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	string s;
	mp["AC"] = 0; mp["WA"] = 0; mp["RE"] = 0; mp["TLE"] = 0;
	for(int i=0;i<n;i++){
		cin>>s;
		mp[s]++;
	}
	cout<<"AC"<<" x "<<mp["AC"]<<endl;
	cout<<"WA"<<" x "<<mp["WA"]<<endl;
	cout<<"TLE"<<" x "<<mp["TLE"]<<endl;
	cout<<"RE"<<" x "<<mp["RE"]<<endl;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	ll n,k,r,s,p;
	string t;
	cin>>n>>k>>r>>s>>p>>t;

	vector<int> used(n,-1);
	ll ans=0;
	rep(pos,n){
		if(used[pos]>0)break;
		char hand = 'a';
		for (int i = pos; i < n; i+=k){
			used[i] = 1;
			if(hand==t[i]){
				hand = 'a';
			}else{
				if(t[i]=='r')ans+=p,hand='r';
				else if(t[i]=='s')ans+=r,hand='s';
				else ans+=s,hand='p';
			}
			// cout<<ans<<endl;
		}
	}

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

Measured memory_bytes: 896
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
using namespace std;

const int N = 5000;
const int M = min(N*(N-1)/2,1000);
int n, m;
map<string, int> a;
int x[N], vstd[N];

typedef pair<int, int> P;

typedef struct edge_def {
  int from; int to; int cost;
  edge_def(int _from, int _to, int _cost) {
   from = _from; to = _to; cost =_cost;
  }
} edge;

vector<edge> es[N];

void dijkstra(int s) {
  memset(vstd, 0, sizeof(vstd));
  priority_queue<P,vector<P>, greater<P> > q;
  q.push(P(0, s));
  vstd[s] = 1;
  
  while(q.size()){
    P p = q.top(); q.pop();
    int v = p.second;
    for (int i=0; i<(int)es[v].size(); i++) {
      edge e = es[v][i];
      if (!vstd[e.to]) {
        x[s] = min(x[s], x[e.to]);
        q.push(P(0, e.to));
        vstd[e.to] = 1;
      }
    }
  }
}

signed main() {
  int i;
  for (i=0; i<N;i++) es[i].clear();
  scanf("%d ", &n);
  for (i=0; i<n; i++) {
    string s; int v;
    cin >> s >> v;
    a[s] = i;
    x[i] = v;
  }
  
  scanf("%d ", &m);
  for (i=0; i<m;i++) {
    string f, t;
    cin >> f >> t;
    int fidx = a[f];
    int tidx = a[t];
    es[fidx].push_back(edge(fidx, tidx, 0));
    es[tidx].push_back(edge(tidx, fidx, 0));
  }
  
  for(i=0; i<n; i++) dijkstra(i);
  
  int res = 0;
  for (i=0; i<n; i++) res += x[i];
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 2040
h,w=map(int,input().split())
b=[list(map(int,input().split()))for i in range(h)]
c=[]
for i in range(h):
  if i%2:b[i]=b[i][::-1]
for i in range(h):
  for j in range(w):
    if b[i][j]%2==0:continue
    y=yy=i
    x=xx=j
    if j==w-1:yy+=1;xx=0
    else:xx+=1
    if not(yy<h and xx<w):continue
    b[yy][xx]+=1
    if yy%2:xx=w-1-xx
    if y%2:x=w-1-x
    c.append([y+1,x+1,yy+1,xx+1])
print(len(c))
for i in c:print(*i)

Measured memory_bytes: 30172
#define PROB ChangingChange

#include <bits/stdc++.h>

using namespace std;
typedef long long LL;
#define rep(i, l, r) for (int i = l; i<r;i++)
#define all(b) b.begin() , b.end()
#define mp(a, b) make_pair(a,b)
#define pb(a) push_back(a)
#define vi vector<int>
#define vd vector<double>
#define vs vector<string>
#define vii vector<pair<int,int>>
#define vvi vector<vector<int>>
#define ii pair<int,int>
#define turnOff(k, i) (k&(~(1<<(i-1))))
#define isOn(k, i) (k&&(1<<i-1)?true:false)
#define pll pair<long long int , long long int>
#define ull unsigned long long int
#define ll  long long int
#define add(a, b) ((a+b)%MOD)
#define sub(a, b) ((a-b+MOD)%MOD)
#define mul(a, b) ((a*b)%MOD)
#ifdef  DEBUG
#define MAXN 105
#else
#define MAXN 5000020
#endif
#define MAXLG 20
#define endl '\n'
#define PI 3.141592653589793238
#define MOD (1000000007)
#define INF (2000000000)
#define EPS (0.00000001)
#define treap treapNode*
vii adj[MAXN];
bool visited[MAXN];
vii cycle;



int gcd(int a, int b) {
    while (a != 0) {
        int c = a;
        a = b % a;
        b = c;
    }
    return b;

}


vi getAllDivisors(int num) {
    vector<int> divs;
    int square_root = (int) sqrt(num) + 1;
    for (int i = 1; i < square_root; i++) {
        if (num % i == 0) {
            if (i * i != num) {
                divs.pb(i);
            }
            divs.pb(num / i);
        }

    }
    return divs;
}

class PROB {
public:

};


ll mod_pow(long x, int y) {
    // exponentiation by squaring
    ll r = 1;
    while (y > 0) {
        if (y % 2 == 1) {
            r = (r * x) % MOD;
        }
        x = (x * x) % MOD;
        y /= 2;
    }
    return r;
}
int max_x=100,max_y=100;
int tree[11][101][101];





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

#ifdef DEBUG
    freopen("input", "r", stdin);
#endif
    int N;
    cin>>N;
    int mul2=0,mul4=0;
    for (int i=0;i<N;i++) {
        int x;
        cin>>x;
        if (x%4==0)mul4++;
        else if (x%2 == 0)mul2++;

    }
    int none = N-mul4-mul2;
    if (mul2 == 0 &&  (none-1<=mul4)) cout<<"Yes";
    else if (mul2 != 0 &&  (none<=mul4)) cout<<"Yes";
    else cout<<"No";
    return 0;

}

Measured memory_bytes: 118656
#include<bits/stdc++.h>
#define ii pair<int,int>
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define int long long int
#define modulo 1000000007
using namespace std;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<ii> arr;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        arr.pb(mp(x,i));
    }
    sort(all(arr));
    for(int i=0;i<n;i++)cout<<arr[i].second<<" ";
}


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

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

int main()
{
    int A, B;
    cin >> A >> B;
    if (A >= 13)
    {
        cout << B << endl;
    }
    else if (A >= 6)
    {
        cout << B/2 << endl;
    }
    else
    {
        cout << 0 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main(){
  int PayManey, coin_1yen;
  cin >> PayManey >> coin_1yen;
  if((PayManey % 500) <= coin_1yen){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import sys

N=int(input())
temp=0
ans=[]
for i in range(1,N+1):
  temp+=i
  if temp==N:
    for j in range(1,i+1):
      print(j)
    else:
      sys.exit()
  elif temp>N:
    for j in range(1,i+1):
      if j==temp-N:
        continue
      print(j)
    else:
      sys.exit()


Measured memory_bytes: 9224
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    long long H,W;

    while(1){
        
        cin >> H >> W;

        if(H==0 && W==0){
            break;
        }

        for(long long i=1;i<=H;i++){

            for(long long j=1;j<=W;j++){
                if(i==1||i==H){
                    cout << "#";
                }else{
                    if(j==1||j==W){
                        cout << "#";
                    }else{
                        cout << ".";
                    }
                }
                
            }

            cout << endl;

        }
        cout << endl;
    }


    return 0;

}


Measured memory_bytes: 3088
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
#define REP(i,a,b) for(in i=(in)(a);i<(in)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const in inf=1e9+7;
using P=pair<in,in>;
vector<in> dx={0,1,-1,0};
vector<in> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    in n,m;
    cin>>n>>m;
    vector<P> a(n);
    rep(i,n) cin>>a[i].first>>a[i].second;
    vector<P> wv1(0),wv2(0);
    for(in tmp = 0;tmp< (1<<(n/2)); tmp++){
        bitset<20> s(tmp);
        in w=0,v=0;
        rep(i,n/2){
            if(!s.test(i)) continue;
            v +=a[i].first;
            w +=a[i].second;
        }
        if(w>m) continue;
        wv1.emplace_back(w,v);
    }
    for(in tmp = 0;tmp< (1<<(n-n/2)); tmp++){
        bitset<20> s(tmp);
        in w=0,v=0;
        rep(i,n-n/2){
            if(!s.test(i)) continue;
            v +=a[n/2+i].first;
            w +=a[n/2+i].second;
        }
        if(w>m) continue;
        wv2.emplace_back(w,v);
    }
    sort(all(wv1));
    sort(all(wv2));
    vector<P> w1(0),w2(0);
    in w=-1,v=-1;
    rep(i,wv1.size()){
        if(i<wv1.size()-1 && wv1[i].first==wv1[i+1].first) continue;
        in ww,vv;
        tie(ww,vv)=wv1[i];
        if(vv>v){
            v=vv;
            w1.emplace_back(ww,vv);
        }
    }
    v=-1;
    rep(i,wv2.size()){
        if(i<wv2.size()-1 && wv2[i].first==wv2[i+1].first) continue;
        in ww,vv;
        tie(ww,vv)=wv2[i];
        if(vv>v){
            v=vv;
            w2.emplace_back(ww,vv);
        }
    }
    in ans=0;
    rep(i,w1.size()){
        in x,y;//weight,value
        tie(x,y)=w1[i];
        y += (*(lower_bound(all(w2),P(m-x+1,0))-1)).second;
        ans =max(ans,y);
    }
    cout<<ans<<endl;
}/*
./problem.exe
*/


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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)

int main() {
  u32 n;
  cin >> n;
  vector<u32> a(n);
  rep(i, n) { cin >> a[i]; }

  u32 ans = 0;
  rep(i, n) {
    if ((a[i] & 1) == 1 && (i & 1) == 0)
      ans++;
  }
  cout << ans;

  return 0;
}


Measured memory_bytes: 3568
n = int(input())
l = list(map(int, input().split()))

ans = 0

for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if l[i] == l[j]:
                continue
            if l[j] == l[k]:
                continue
            if l[i] == l[k]:
                continue
            if max(l[i], l[j], l[k]) * 2 < l[i] + l[j] + l[k]:
                ans += 1

print(ans)

Measured memory_bytes: 74324
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
    int n ;
    cin >> n;
    set<string>se;
    for(int i = 0; i < n ; i++)
    {
    	string s;
    	cin >> s;
    	se.insert(s);
	}
	cout<<se.size()<<endl;

  }


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

   int a,b,ans;
   cin >> a >> b;
   if(a>b)
   {
     cout << 2*a-1 << endl;
   }
  else if(a==b)
  {
    cout << a+b << endl;
  }
   else
   { cout << 2*b-1 << endl;
   }
  return 0;
}
     

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.parseLong;
//import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j,k;
		Scanner sc = new Scanner(System.in);
		int n = parseInt(sc.next());
		int m = parseInt(sc.next());
		int X = parseInt(sc.next());
		int Y = parseInt(sc.next());
		int[] x = new int[n];
		for(i=0;i<n;i++) {
			x[i] = parseInt(sc.next());
		}
		int[] y = new int[m];
		for(i=0;i<m;i++) {
			y[i] = parseInt(sc.next());
		}
		sc.close();
		Arrays.sort(x);
		Arrays.sort(y);
		boolean f = false;
		if(x[n-1]<y[0] && X<y[0] && x[n-1]<Y) f = true;
		out.println(f?"No War":"War");
	}
}


Measured memory_bytes: 20820
#include <bits/stdc++.h>
using longlong=long long;

[[maybe_unused]]auto cmn=[](auto&& a,auto b){if(a>b){a=b;return true;}return false;};
[[maybe_unused]]auto cmx=[](auto&& a,auto b){if(a<b){a=b;return true;}return false;};

int main(){
    std::cin.tie(nullptr);std::cin.sync_with_stdio(false);
    int n;std::cin>>n;
    std::vector<int>dp(n+1);
    std::iota(dp.begin(),dp.end(),0);
    for(int i=6;i<=n;i*=6){
        for(int j=0;j+i<=n;j++){
            cmn(dp.at(j+i),dp.at(j)+1);
        }
    }
    for(int i=9;i<=n;i*=9){
        for(int j=0;j+i<=n;j++){
            cmn(dp.at(j+i),dp.at(j)+1);
        }
    }
    std::cout<<dp.at(n)<<std::endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <unordered_map>
#include <random>
#include <queue>
#include <iomanip>

#define BIG 1000000007
#define LLMAX 9223372036854775807
#define LLMIN (-9223372036854775808)
#define long long long

using namespace std;

typedef struct N{
    int index;
    set<int> connects;
} Node;

void ansout(set<pair<int,int>>& out){
    string s;
    cout << out.size() << endl;
    for(auto au = out.begin();au != out.end();++au){
        s += to_string((*au).first + 1) + " " + to_string((*au).second + 1) + "\n";
    }
    cout << s;
}

int main(){
    long n,k;
    cin >> n >> k;
    if(n == 2){
        if(k == 0)cout << "1" << endl << "1 2" << endl;
        else cout << "-1" << endl;
        return 0;
    }

    if(k > (n - 1) * (n - 2) / 2){
        cout << "-1" << endl;
        return 0;
    }

    set<pair<int,int>> conn;

    for(int i = 1;i < n;++i)conn.insert({0,i});

    if(k == (n - 1) * (n - 2) / 2){
        ansout(conn);
        return 0;
    }

    if(k < (n - 1) * (n - 2) / 2){
        long s = (n - 1) * (n - 2) / 2;
        for(int i = 1;i < n;++i){
            for(int j = i + 1;j < n;++j){
                conn.insert({i,j});
                --s;
                if(s == k){
                    ansout(conn);
                    return 0;
                }
            }
        }
    }
}







Measured memory_bytes: 640
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
char s[777777];int n;ll res,cnt;
int main() {
	scanf("%s",s+1);n=strlen(s+1);
	rep(i,1,n)if(s[i]=='W')cnt++,res+=i;
	cout<<res-cnt*(cnt+1)/2;
	return 0;
}


Measured memory_bytes: 384
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl

#define rep(i, n) REP(i, 0, n)                  // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++) // x, x + 1, ..., n-1
#define FOREACH(x, a) for(auto &(x) : (a))

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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

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

    int n, ans = 0;
    string s;
    cin >> n >> s;
    rep(i, 1000) {
        int c[3] = {i / 100, (i / 10) % 10, i % 10};
        int cnt  = 0;
        rep(j, n) {
            if(s[j] == ('0' + c[cnt])) cnt++;
            if(cnt == 3) break;
        }
        if(cnt == 3) ans++;
    }
    COUT(ans);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define F first
#define S second
const int N=1000005;
#define M 1000000007
#define double long double
#define BINF 1000000000000000001
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN  1000005
using namespace std;



#undef int
int main(){
#define int long long int
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);


    int n,k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; i++)
        cin >> a[i];
    int x = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            if(a[i] > a[j]) x++;
        }
    }

    int b[n];
    for(int i = 0; i < n; i++)
        b[i] = a[i];

    int lol = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(i != j){
                if(a[i] > a[j]) lol++;
            }
        }
    }

    int y = (k * (k - 1)) / 2;
    y %= M;
    y = (y * lol) % M;

    x = (k * x) % M;

    int ans = (x + y) % M;

    cout << ans;
    
    
return 0;    
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=200005;
const int MOD=1000000007;
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())

int N,K;
int A[MAXN];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>N>>K;
	FOR(i,1,N)cin>>A[i];
	multiset<int>sy,sn;
	int y=0,n=0;
	int ans=0;
	FOR(i,0,N){
		sy.clear();sn.clear();
		y=n=0;
		FOR(j,1,i){
			sy.insert(A[j]);
			y+=A[j];
		}
		DEC(j,N+1,i+1){
			if(j!=N+1)sy.insert(A[j]);
			y+=A[j];
			while(sz(sn)&&sz(sn)>K-i-(N-j+1)){
				n-=*sn.rbegin();
				y+=*sn.rbegin();
				sy.insert(*sn.rbegin());
				sn.erase(--sn.end());
			}
			while(sz(sy)&&*sy.begin()<0&&sz(sn)<K-i-(N-j+1)){
				sn.insert(*sy.begin());
				n+=*sy.begin();
				y-=*sy.begin();
				sy.erase(sy.begin());
			}
			while(sz(sy)&&sz(sn)&&*sy.begin()<*sn.rbegin()){
				int tmp=*sn.rbegin();
				sn.erase(--sn.end());
				sy.insert(tmp);
				n-=tmp;
				y+=tmp;
				n+=*sy.begin();
				y-=*sy.begin();
				sn.insert(*sy.begin());
				sy.erase(sy.begin());
			}
			if(sz(sn)<=K-i-(N-j+1))ans=max(ans,y);
		}
	}
	cout<<ans<<"\n";
}
/*
*/


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

using namespace std;

int main(void) {
	int A, B;
	cin >> A >> B;
	for(int val = 0; val <= 10000; ++val) {
		if(val * 108 / 100 == val + A && val * 110 / 100 == val + B) {
			cout << val << '\n';
			return 0;
		}
	}
	cout << "-1\n";
	return 0;
}



Measured memory_bytes: 256
using System;
using System.Linq;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class program{
  static void Main(string[] args){
    program p = new program();
    p.Run();
  }
  void Run(){
	int[] dis=Readint();
    int[] an =new int[3];
    an[0]=dis[0]+dis[1];
    an[1]=dis[1]+dis[2];
    an[2]=dis[2]+dis[0];
    WriteLine(an.Min().ToString());
  }

  int[] Readint(){
    string[] s = ReadLine().Split();
    int[] res=new int[s.Length];
    Parallel.For(0,s.Length,i=>{
      res[i]=int.Parse(s[i]);
    });
    return res;
  }
}




Measured memory_bytes: 13652
import math

N,D=map(int,input().split())
A=[]
for _ in range(N):
    tmp=list(map(int,input().split()))
    A.append(tmp)
ans = 0
for i in range(N):
    for j in range(N):
        if i < j:
            tmp = 0
            for d in range(D):
                tmp += (A[i][d] - A[j][d]) ** 2
            if math.sqrt(tmp) % 1 == 0:
                ans += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <unordered_set>

using namespace std;

int main() {
	unordered_set<int> col;
	int a,b,c;
	cin >> a >> b >> c;
	col.insert(a);
	col.insert(b);
	col.insert(c);
	cout << col.size() << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>

#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar(' ')
#define EL putchar('\n')
#define inf 2147483647
#define File(a) freopen(a ".in", "r", stdin), freopen(a ".out", "w", stdout)

template<class T>
inline void read(T&);
template<class T>
inline void write(const T&);

typedef long long ll;
typedef const long long & cll;
typedef const int & ci;

const int N = 100005;

int fa[N], siz[N];
int u[N], v[N];
ll ans[N];

int find(int);

int main () {
    int n, m;
    read(n), read(m);
    for (int i = 1; i <= n; ++i) {
        fa[i] = i;
        siz[i] = 1;
    }
    for (int i = 1; i <= m; ++i) {
        read(u[i]), read(v[i]);
    }
    ll now = n * 1ll * (n - 1) / 2;
    for (int i = m; i >= 1; --i) {
        ans[i] = now;
        int fu = find(u[i]), fv = find(v[i]);
        if (fu != fv) {
            fa[fv] = fu;
            now -= siz[fu] * 1ll * siz[fv];
            siz[fu] += siz[fv];
        }
    }
    for (int i = 1; i <= m; ++i) {
        write(ans[i]), EL;
    }
    return 0;
}

template<class T>
void read(T &Re) {
    T k = 0;
    char ch = getchar();
    int flag = 1;
    while (!isNum(ch)) {
        if (ch == '-') {
            flag = -1;
        }
        ch = getchar();
    }
    while (isNum(ch)) {
        k = (k << 1) + (k << 3) + ch - '0';
        ch = getchar();
    }
    Re = flag * k;
}
template<class T>
void write(const T &Wr) {
    if (Wr < 0) {
        putchar('-');
        write(-Wr);
    } else {
        if (Wr < 10) {
            putchar(Wr + '0');
        } else {
            write(Wr / 10);
            putchar((Wr % 10) + '0');
        }
    }
}

int find(int x) {
    return fa[x] == x ? x : fa[x] = find(fa[x]);
}


Measured memory_bytes: 3712
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;

int main()
{
  int N, K; cin >> N >> K;
  vector<int> V(N);
  for(int i = 0; i < N; i++) cin >> V[i];

  int ans = 0;
  //k: num of operation
  for(int k = 0; k <= min(K, 2 * N); k++){
    //j: num of push, num of pop operation = k - j
    for(int j = max(0, k - N); j <= k/2; j++){
      //i: num of pop from left
      for(int i = 0; i <= k - j; i++){
        //have: vector of my jewels
      	vector<int> have;
        for(int l = 0; l < i; l++) have.push_back(V[l]);
        for(int r = 0; r < k - j - i; r++) have.push_back(V[N - r - 1]);
        sort(have.begin(), have.end());
        int sum = 0;
        for(int m = j; m < have.size(); m++) sum += have[m];
        if(sum > ans) ans = sum;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n,m,k=map(int,input().split())
l=[]
for i in range(n):
    l.append(list(input()))
res=0
for i in range(2**n-1):
    for j in range(2**m-1):
        b=0
        for x in range(n):
            for y in range(m):
                c=2**x
                d=2**y
                if i&c==0 and j&d==0 and l[x][y]=="#":
                    b+=1
        if b==k:
            res+=1
print(res)

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,sum=0;
	map<ll,ll> m;
	cin >> n;
	vll a(n);
	rep(i,n){
		cin >> a[i];
		m[a[i]]++;
	}
	for(auto& e:m){
		sum+=e.second*(e.second-1)/2;
	}
	rep(i,n){
		cout << sum-(m[a[i]]-1) << endl;
	}
	return 0;
}

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

using namespace std;

#define boost ios::sync_with_stdio(0);cin.tie(0);
#define forn(i,n) for ( int i=0 ; i < n ; i++ )
#define all(a) (a).begin(), (a).end()
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ll long long
#define endl '\n'
#define mod 1000000007

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

int main()
{
	//freopen ("f.in","r",stdin);
 	//freopen ("f.out","w",stdout);
	boost
	//code
	int n;
	cin >> n;
	ll ans = 0;
	vector<ll> yo;
	forn(i,n){
		ll a,b;
		cin >> a >> b;
		yo.push_back(a+b);
		ans -= b;
	}
	sort(all(yo));
	reverse(all(yo));
	forn(i,n){
		if(i%2) continue;
		ans += yo[i];
	}	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1400
// O O O O O O O O O O O O O O O OO O OO O OO O O O TTCH O TTTCH O TTTCH O O O O
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
#include <cassert>
 
using namespace std;

#define int long long
#define y1 y11
#define double long double
#define less less228
#define left left228
#define right right228
#define list list228



template<typename T> void uin(T &a, T b) {
    if (b < a) a = b;
}
template<typename T> void uax(T &a, T b) {
    if (b > a) a = b;
}
 
 
random_device rnd;
 
template<typename T> void shuffle(vector< T > &v) {
    for (int i = 1; i < (int)v.size(); ++i) {
        swap(v[rnd() % i], v[i]);
    }
    for (int i = (int)v.size() - 1; i; --i) {
        swap(v[rnd() % i], v[i]);
    }
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    if (a + b >= c - 1) {
        cout << a + c << endl;
    } else {
        cout << a + a + b + 1 << endl;
    }
    return 0;
}
// RU_023



Measured memory_bytes: 256
#include<iostream>

using namespace std;

int use[10001][1261];

int main(){

	while(1){
		int N,M,r,q;
		int t,n,m,s;
		int ts,te;

		cin>>N>>M;

		if(N==0&&M==0) break;

		cin>>r;
		for(int i=0;i<=M;i++){
			for(int j=0;j<=1260;j++){
				use[i][j]=0;
			}
		}
		for(int i=0;i<r;i++){
			cin>>t>>n>>m>>s;
			if(s==0) use[m][t]--;
			if(s==1) use[m][t]++;
		}
		for(int i=0;i<=M;i++){
			for(int j=1;j<=1260;j++){
				use[i][j]+=use[i][j-1];
			}
		}
		cin>>q;
		for(int i=0;i<q;i++){
			cin>>ts>>te>>m;
			int ans=0;
			for(int j=ts;j<te;j++){
				if(use[m][j]!=0) ans++;
			}
			cout<<ans<<endl;
		}
	}
}

Measured memory_bytes: 50304
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
struct Pair{
    int x,y;
}p[100005];
struct edge{
    int s,t,cost;
}e[2][100005];
int s[100005],t[100005],fa[100005];
int Find(int x){return x==fa[x]?x:fa[x]=Find(fa[x]);}
bool Cmpx(int a,int b){
    return p[a].x<p[b].x;
}
bool Cmpy(int a,int b){
    return p[a].y<p[b].y;
}
bool Cmpe(edge a,edge b){
    return a.cost<b.cost;
}
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>p[i].x>>p[i].y;
        fa[i]=i;
        s[i]=i;t[i]=i;
    }
    sort(s,s+n,Cmpx);
    sort(t,t+n,Cmpy);
    for(int i=0;i<n-1;i++){
        e[0][i].s=s[i+1];
        e[0][i].t=s[i];
        e[0][i].cost=p[s[i+1]].x-p[s[i]].x;
    }
    for(int i=0;i<n-1;i++){
        e[1][i].s=t[i+1];
        e[1][i].t=t[i];
        e[1][i].cost=p[t[i+1]].y-p[t[i]].y;
    }
    sort(e[0],e[0]+n-1,Cmpe);
    sort(e[1],e[1]+n-1,Cmpe);
    int i=0,j=0,count=0;
    long long cost=0;
    while(count<n-1){
        if(i<=n-1&&e[0][i].cost<=e[1][j].cost){
            int x=Find(e[0][i].s),y=Find(e[0][i].t);
            fa[x]=y;
            cost+=e[0][i].cost;
        }else{
            int x=Find(e[1][j].s),y=Find(e[1][j].t);
            fa[x]=y;
            cost+=e[1][j].cost;
        }
        count++;
        while(i<n-1&&Find(e[0][i].s)==Find(e[0][i].t))i++;
        while(j<n-1&&Find(e[1][j].s)==Find(e[1][j].t))j++;
    }
    cout<<cost<<endl;
    return 0;
}


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

int main()
{
	int x, y;
	int t;

	for (;;) {
		scanf("%d %d", &x, &y);
		if (x == 0 && y == 0) break;
		if (x > y) t = x, x = y, y = t;
		printf("%d %d\n", x, y);
	}
	return 0;
}


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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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

const int N = 1e5 + 5;

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int a, b; cin >> a >> b;
	cout << 6 - a - b << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>	
int main(void)
{
		int L,a,b,c,d,y,yy,g,h,i;
		scanf("%d",&L);					
		scanf("%d",&a);						
		scanf("%d",&b);						
		scanf("%d",&c);						
		scanf("%d",&d);
		if(a%c>0) {
			g=a/c;
			yy=g+1;
		}	
		else {
			g=a/c;
			yy=g;
		}
		if(b%d>0) {
			h=b/d;
			y=h+1;
		}
		else {
			h=b/d;
			y=h;
		}	
		if(yy>y) {				
			i=L-yy;
			printf("%d\n",i);
		}	
		else {
			i=L-y;		
			printf("%d\n",i);	
		}
		
		return 0;		
}						


Measured memory_bytes: 2056
#include<iostream>
#include<cstddef>


using ui32 = std::uint32_t;

int main(){

	std::uint32_t n;

	std::cin >> n;

	auto t{ n };
	ui32 ans{ 0 };

	const ui32 cents[4] = { 25, 10, 5, 1 };
	
	for( const auto cent : cents )
	{
		ans += t / cent;
		t %= cent;
	}

	std::cout << ans << "\n";
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ULL unsigned long long
#define LL long long

using namespace std;

int main(){
	LL N,M,A,sum=0;
	
	cin >> N >> M;
	for(LL i=0;i<M;i++){
		cin >> A;
		sum+=A;
	}
	
	cout << (N-sum<0 ? -1:N-sum) << endl;
	return 0;
}

Measured memory_bytes: 3636
import sys
# from math import gcd
from fractions import gcd

input = sys.stdin.readline

A, B = list(map(int,input().split()))

n = gcd(A,B)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

frl = factorization(n)
if frl[0][0]==1:
	ans = 1
else:
	ans = len(frl)+1
print(ans)

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

#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define endl '\n'
#define int long long

typedef pair<int,int> pii;
const int N = 1e6+5;
const int INF = 1e9;
const int MOD = 1e9+7;

string s;
int dp1[N], dp2[N];
//dp1[i]: #pairs a + b (from 1..i) guarentee < L
//dp2[i]: #pairs a + b (from 1..i) not guarentee < L
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> s;
	int n = s.length();
	s = '*' + s;
	dp1[0] = 0; 
	dp2[0] = 1;
	for(int i=1; i<=n; i++){
		if (s[i] == '0') {
			dp1[i] = 3*dp1[i-1];
			dp2[i] = dp2[i-1];
		} else {
			dp1[i] = 3*dp1[i-1] + dp2[i-1];
			dp2[i] = 2*dp2[i-1];
		}
		dp1[i] %= MOD;
		dp2[i] %= MOD;
	}
	int ans = dp1[n] + dp2[n];
	ans %= MOD;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5228
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    a = [str(i) for i in input().split()]
    ans = a[0].upper()[0] +a[1].upper()[0]+a[2].upper()[0]
    print(ans)

Measured memory_bytes: 3828
#include<iostream>
#include<string>
int main(){
	std::string S,T;
	std::cin>>S>>T;
	int ans=0;
	for(int i=0;i<S.length();i++){
		if(S[i]!=T[i]){
			ans++;
		}
	}
	std::cout<<ans;

	return 0;
}


Measured memory_bytes: 3464
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll s; cin >> s;
    ll w; cin >> w;
    if (s <= w){
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
    return 0;
}

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

signed main() {
    int N, K;
    cin >> N >> K;

    vector<int> A(N);
    for (int& x : A) cin >> x;

    int x = 0;
    for (int i = 40; i >= 0; i--) {
        int t = x + (1LL<<i);
        int a = 0, b = 0;
        for (int j = 0; j < N; j++) {
            a += A[j] ^ t;
            b += A[j] ^ x;
        }
        if (a > b && t <= K) {
            x = t;
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        ans += A[i] ^ x;
    }
    cout << ans << endl;

    return 0;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	vi a (N);
	vi b (N);
	F0R(i, N) cin >> a[i];
	F0R(i, N) cin >> b[i];
	reverse(b.begin(), b.end());

	int l = 0;
	int r = N-1;
	
	bool fail = false;
	F0R(i, N) if (a[i] == b[i]) {
		if (l < N && (b[l] != a[i] && b[i] != a[l])) {
			swap(b[l], b[i]); ++l;
		} else if (r >= 0 && (b[r] != a[i] && b[i] != a[r])) {
			swap(b[r], b[i]); --r;
		} else {
			fail = true;
		}
	}

	if (fail) {
		print("No");
	} else {
		print("Yes");
		for (int x : b) cout << x << " ";
		cout << endl;
	}
}

Measured memory_bytes: 4756
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		long w = Long.parseLong(str[0]);
		long h = Long.parseLong(str[1]);
		long x = Long.parseLong(str[2]);
		long y = Long.parseLong(str[3]);

		double ans = (double) (w * h) / 2;
		System.out.print(ans + " ");

		if (2 * x == w && 2 * y == h) {
			System.out.print("1");
		} else {
			System.out.print("0");
		}
		System.out.println();
	}
}


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

int main(){
int a,N;
cin >> N;
 for(int i = 0;i < 50000;i++){
    int b = i*1.08;
    if(b == N){
        cout << i <<endl;
        break; 
    }
a++;
 }

 if(a == 50000){
    cout << ":(" << endl;
 }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cassert>
#include<cmath>
#define EPS 1e-10
using namespace std;
int m,n;
double total;
double dp[110][110];
int Just;
//vector<double> matrix[110];
double matrix[110][110];
/*
double rec(int next,int counter){
  if(dp[next][counter] > 0)return dp[next][counter];
  if(counter  == 0){
    return 1.0;
  }
  double HANMA = 0.0,test=0.0;
 
 
  for(int i=0;i<n;i++){   
    
    //HANMA = max(HANMA,rec(i,counter-1)*matrix[next][i]);
    test = rec(i,counter-1)*matrix[next][i];
    if(test > HANMA)HANMA = test;
  }  
  dp[Just][counter] = HANMA;
  return HANMA;
}
*/


int main(){
  
  double In;
 
  while(cin >> n >> m && n && m){
    //for(int i=0;i<=n;i++)matrix[i].clear();
    
    for(int i=m;i>=0;i--)for(int j=0;j<n;j++)dp[j][i] = -10;
   
 

    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	scanf("%lf",&matrix[i][j]);
      }
    }
  for(int i=0;i<n;i++)dp[i][0] = dp[i][1] = 1;

    double ans = -1; 
    for(int i=2;i<=m;i++){
      for(int j=0;j<n;j++){
	ans = -1;
	for(int k=0;k<n;k++)if(ans < dp[k][i-1]*matrix[j][k])ans = dp[k][i-1]*matrix[j][k];
      
	dp[j][i] = ans;
      }
    }  
 
    double Fans = 0;
    for(int i=0;i<n;i++)if(Fans < dp[i][m])Fans = dp[i][m];
      //cout << endl;

    printf("%.2f\n",Fans);

  }
  return 0;
}

Measured memory_bytes: 1460