akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream> 
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std; 
int main(){
	int n, sum;
	while(cin >> n){
		sum = 0;
		for(int a = 0; a < 10; a++){
			for(int b = 0; b < 10; b++){
			   for(int c = 0; c < 10; c++){
				   for(int d = 0; d < 10; d++){
					   if(n == a + b + c + d){
					   sum++;
					   }
				   }
			   }
			}
		}
		cout << sum << endl;
	}
	return 0;
}


Measured memory_bytes: 3068
#include <iostream>
#include <bits/stdc++.h>
#include <cstdlib>
#include <string>
using namespace std;

int main()
{
    int n;
    string s;
    string org = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    cin >> n >> s;

    string res = "";

    for(int i=0; i < (int)s.size(); i++) {
        int pos = (org.find(s[i]) + n) % 26;
        res += org[pos];
    }

    cout << res << endl;

    return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int n, t[101], d[101], v[101];
int sp[40404];
void solve(){
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> t[i];
		t[i] *= 2;
		d[i] = d[i-1]+t[i];
	}
	for(int i = 1; i <= n; i++){
		cin >> v[i];
		v[i] *= 2;
		fill(sp+d[i-1], sp+d[i], v[i]); //max
	}
	
	for(int i = 1; i <= n; i++){
		if(v[i] > v[i-1]){
			for(int j = d[i-1]; j < d[i]; j++){
				chmin(sp[j], v[i-1]+j-d[i-1]);
			}
		}
		if(v[i] > v[i+1]){
			for(int j = d[i+1]; j >= d[i]; j--){
				chmin(sp[j], v[i+1]+d[i+1]-j);
			}
		}
	}
	for(int i = 1; i < d[n]; i++){
		chmin(sp[i], sp[i-1]+1);
	}
	for(int i = d[n]; i > 0; i--){
		chmin(sp[i], sp[i+1]+1);
	}
	
	i64 ans = 0;
	for(int i = 1; i < d[n]; i++){
		ans += sp[i];
		
	}
	printf("%.10f\n", ans/4.0);
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
	char s[51],t[51];
	scanf("%s%s",s,t);
	int i,j,count,a,b,x=0,index;
	a=strlen(s);
	b=strlen(t);
	for(i=0;i<a;i++)
	{
    	count=0;
		for(j=0;j<b;j++)
		{
			if((s[i+j]==t[j])||(s[i+j]=='?'))
				count++;
		}
		if(count==b)
		{
			x++;
			index=i;
		}
	}
	
	if(x==0) printf("UNRESTORABLE");
	else
	{
		for(j=0;j<b;j++)
		{
			s[index+j]=t[j];
		}
		for(i=0;i<a;i++)
		{
			if(s[i]=='?')
				s[i]='a';
		}
		printf("%s",s);
	}
}

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

map<int, int> mp;

int n;
string s;

int main() {
    cin >> s;
    n = s.length();
    for(char c : s) mp[c] ++;
    if(mp.size() == 2) return cout << "Second" << endl, 0;
    if(n >= 4 && mp.size() == 3) {
        for(int i = 1; i < n - 1; i++) {
            if(mp[s[i]] == 1) {
                return cout << (s[i-1] == s[i+1] ? "Second" : "First") << endl, 0;
            }
        }
    }
    cout << (((s[0] == s[n-1]) ^ (n % 2 == 1) ? "First" : "Second")) << endl;
}

Measured memory_bytes: 512
/* AUTHOR :  SHIVANK JAIN */

#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false)
#define itt cin.tie(0)
#define now cout.tie(0)

using namespace std;

#define ll long long
#define li long int

#define pb push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
#define reprev(i,n,a) for(int i=n;i>=a;i--)
#define endl "\n"

#define vi vector<int>
#define vll vector<ll>
#define vpi vector< pair<int , int> >
#define mapi map<int , int>
#define mapll map<ll ,ll >
#define seti set<int> 

#define fr first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mp make_pair
#define sort(v) sort(v.begin() , v.end())

#define BIG 1000000007
int gcd(int a, int b) 
{ // builtin function __gcd(a,b)
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int main(){

     fast;itt;now;
 
//    #ifndef ONLINE_JUDGE
//    // for getting input from input.txt
//    freopen("input.txt", "r", stdin);
//    // for writing output to output.txt
//     freopen("output.txt", "w", stdout);
//    #endif
    
     int n , k;
	   cin>>n>>k;
	   mapi m;
	 rep(i,0,k){
	 	int t;
	 	cin>>t;
	 	while(t--){
	 		int f;  cin>>f;
	 	   m[f]++;
		 }
	 } 
	 int ans = 0;
	 rep(i,1,n+1)
	  if(m[i] == 0)
	   ++ans;  
	   
	   cout<<ans<<endl;
}

Measured memory_bytes: 3664
using System;
using System.IO;//StreamWriterのために必要
using System.Collections.Generic;//List型を使うために必要

namespace dotnetproj
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            if(a*b%2==0){
                Console.WriteLine("Even");
            }
            else{
                Console.WriteLine("Odd");
            }             
        }
    }
}


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

int CountOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum ++;
    n /= 10;
  }
  return sum;
}
  
int main() {
  int N;
  cin >> N;
  
  int count = 0;
  for(int i = 1; i <= N; i++){
   if ( CountOfDigits(i) % 2 == 1 )
     count++;
 }
  cout << count << endl;
}


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

using namespace std;

typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)

#define TRACE

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

//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);

const int N = 1e5 + 10;
const int MASK = 1 << 16;
VI g[MASK];
int val[N], cnt[16], dp[MASK];
int f(int mask){
  if(mask & 1)mask ^= 1;
  if(mask == 0)return 0;
  if(dp[mask] != -1)return dp[mask];
  int &ret = dp[mask];
  ret = 16;
  assert(__builtin_popcount(mask) > 1);
  REP(i, 16)if(mask & (1 << i)){
    REP(j, 16)if(mask & (1 << j)){
      if(i == j)continue;
      int newmask = mask ^ (1 << i);
      newmask ^= (1 << j);
      int add = 1;
      if(newmask & (1 << (i ^ j))){
        add++;
      }
      newmask ^= (1 << (i ^ j));
      ret = min(ret, add + f(newmask));
    }
  }
  return ret;
}
int main()
{
  SET(dp, -1);
  int n;si(n);
  REP(i, n - 1){
    int x, y, a;
    si(x);si(y);si(a);
    val[x] ^= a;
    val[y] ^= a;
  }
  REP(i, n)cnt[val[i]]++;
  int ans = 0;
  FOR(i, 1, 16){
    ans += cnt[i] / 2;
    //trace(i, cnt[i], ans);
    cnt[i] -= (cnt[i] / 2) * 2;
  }
  int mask = 0;
  FOR(i, 1, 16)if(cnt[i])mask |= (1 << i);
  //trace(bitset<10>(mask));
  dout(ans + f(mask));
  return 0;
}

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

int bubble(int A[],int n){
    int sw=0;
    for(int i=0;i<n;i++){
        for(int j=n-1;j>=i+1;j--){
            if(A[j]<A[j-1]){
                swap(A[j],A[j-1]);
                sw++;
            }
        }
    }
    return sw;
}

int main(){
    int n,A[1010];cin>>n;
    for(int i=0;i<n;i++) cin>>A[i];
    int sw=bubble(A,n);
    for(int i=0;i<n;i++){
        if(i) cout<<" ";
        cout<<A[i];
    }
    cout<<endl;
    cout<<sw<<endl;
}


Measured memory_bytes: 3104
import sys
import math
import bisect

def main():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    for i in range(n):
        if i + k + 1 <= n:
            if A[i+k] > A[i]:
                print('Yes')
            else:
                print('No')

if __name__ == "__main__":
    main()


Measured memory_bytes: 33016
#include <iostream>
#include <cmath>

using namespace std;

int main(){
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x3 = x2-(y2-y1);
    int y3 = y2-(x1-x2);
    int x4 = x3 - (x2-x1);
    int y4 = y3 - (y2-y1);
    printf("%d %d %d %d",x3,y3,x4,y4);
    return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> L(M);
  vector<int> R(M);
  for(int i = 0; i < M; i++) {
    cin >> L.at(i) >> R.at(i);
  }
  sort(L.begin(), L.end()); 
  sort(R.begin(), R.end()); 
  cout << max(0,R.at(0) - L.at(M-1) + 1) << endl;
}


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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  int n, d; cin >> n >> d;
  cout << (n + (2 * d)) / (2 * d + 1) << endl;
}


Measured memory_bytes: 3560
while line = gets
    a,b,c,d,e,f = line.split(" ").map(&:to_i)
    det = (a*e-b*d)
    if det != 0 
        x = ((e*c-b*f)*1.0 / det *1000).round/ 1000.0
        y =( (-c*d+a*f)*1.0 / det *1000).round/ 1000.0
        printf("%.3f %.3f\n",x,y)
    end
end

Measured memory_bytes: 8748
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}
pii Dir[8] = { //?§????
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};
#define int ll
signed main() {
	int w, h, n;

	scnaf("%lld %lld %lld", &w, &h, &n);
	vector<pii> po(n);
	vector<int> ax(n), ay(n);
	REP(i, n) {
		scnaf("%lld %lld", &ay[i], &ax[i]);
		po[i] = {ay[i],ax[i]};
	}
	sort(ALL(ax));
	sort(ALL(ay));
	if (n % 2) {
		pll ans = { ay[(n - 1) / 2],ax[(n - 1) / 2] };

		ll len = 0;
		ll Maxl = 0;
		REP(i, n) {
			ll l = abs(po[i].first - ans.first) + abs(po[i].second - ans.second);
			Maxl = max(Maxl, l);
			len += l * 2;
		}
		printf("%lld\n%lld %lld\n", len - Maxl, ans.first, ans.second);
	}
	else {
		pair<ll, pll> ou = { LLONG_MAX, {} };
		REP(c, 2) {
			REP(cc, 2) {
				pll ans = { ay[(n - c) / 2],ax[(n - cc) / 2] };

				ll len = 0;
				ll Maxl = 0;
				REP(i, n) {
					ll l = abs(po[i].first - ans.first) + abs(po[i].second - ans.second);
					Maxl = max(Maxl, l);
					len += l * 2;
				}
				ou = min(ou, { len - Maxl, {ans.first, ans.second} });
			}
		}
				printf("%lld\n%lld %lld\n", ou.first, ou.second.first, ou.second.second);
	}
	return 0;
}

Measured memory_bytes: 5204
#include <stdio.h>
#include <string.h>

int main(void){
  char s[11],t[12];
  scanf("%s",s);
  scanf("%s",t);
  int i=0;
  if(strncmp(s,t,strlen(s)) != 0 || strlen(s)+1 != strlen(t)){
    printf("No\n");
  }else{
    printf("Yes\n");
  }
  return 0;
}


Measured memory_bytes: 1712
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int main() {
  int x; cin >> x;
  if(isin(x,400,600)) {cout << 8 << endl; return 0;}
  if(isin(x,600,800)) {cout << 7 << endl; return 0;}
  if(isin(x,800,1000)) {cout << 6 << endl; return 0;}
  if(isin(x,1000,1200)) {cout << 5 << endl; return 0;}
  if(isin(x,1200,1400)) {cout << 4 << endl; return 0;}
  if(isin(x,1400,1600)) {cout << 3 << endl; return 0;}
  if(isin(x,1600,1800)) {cout << 2 << endl; return 0;}
  if(isin(x,1800,2000)) {cout << 1 << endl; return 0;}

  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
double res;
int n,a[1011];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	res=0; for(int i=1;i<=n;i++) res+=1.0/a[i];
	res=1.0/res; printf("%.14lf",res);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include <cmath>
#include<bits/stdc++.h>
//for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define pi pair<int,int> 
using namespace std;
using ll = long long;
int main(){
    int a,b,c; cin >> a >> b >> c;
    if(c-a+b>=0) cout << c-a+b;
    else cout << '0';
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int X = sc.nextInt();
    int Y = sc.nextInt();

    sc.close(); 

    long sum1 = 0;
    long sum2 = 0;
    long sum3 = 0;
    long sum = 0;

    if (X < Y) {
      sum1 += 2 * X * C;
      sum1 += (Y - X) * B;
    } else {
      sum1 += 2 * Y * C;
      sum1 += (X - Y) * A;
    }

    sum = sum1;

    sum2 = X * A + Y * B;

    sum = Math.min(sum, sum2);

    if (X < Y) {
      sum3 += 2 * Y * C;
    } else {
      sum3 += 2 * X * C;
    }

    System.out.println(Math.min(sum, sum3));
  
  }

}

Measured memory_bytes: 25300
#include<cstdio>
int a[50+5];

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= n; i++) scanf("%d",&a[i]);
    int ans = 0;
    for(int i = 1; i <= n; i++){
        for(int j = i+1; j <= n; j++){
            ans += a[i]*a[j];
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 100010
using namespace std;
ll n,m,h[N];
bool hv[N];
int main(){
	ll i,x,y,ans=0;
	memset(hv,true,sizeof(hv));
	cin>>n>>m;
	for(i=0;i<n;i++)
	{
		cin>>h[i];
	}
	for(i=0;i<m;i++)
	{
		cin>>x>>y;
		x--;
		y--;
		if(h[x]<=h[y])
		{
			hv[x]=false;
		}
		if(h[y]<=h[x])
		{
			hv[y]=false;
		}
	}
	for(i=0;i<n;i++)
	{
		if(hv[i])
		{
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, h;
    cin >> a >> b >> h;
    int area = h * (a + b) / 2;
    cout << area << endl;
    return 0;
}


Measured memory_bytes: 256
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
import sys,bisect,string,math,time,functools,random
def Golf():*a,=map(int,open(0))
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[];g=[[] for i in range(n)]
    for i in range(E):
        inp=LI();org_inp.append(inp)
        if index==0:inp[0]-=1;inp[1]-=1
        if len(inp)==2:
            a,b=inp;g[a].append(b)
            if not Directed:g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp;aa=(inp[0],inp[2]);bb=(inp[1],inp[2]);g[a].append(bb)
            if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=[],replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2);found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def bit_combination(k,n=2):return [[tb//(n**bt)%n for bt in range(k)] for tb in range(n**k)]
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)

YN=['YES','NO'];Yn=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

h,w=LI()
h,w,g,sg=GGI(h,w)
dp=[1e6]*(h*w)
dp[w+1]=g[w+1]

for j in range(h*w-w):
  for d in (1,w):
    dp[j+d]=min(dp[j]+(g[j]*2+g[j+d]==1),dp[j+d])

print(dp[-w-2])


Measured memory_bytes: 41324
//love yjl forever
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int INF=0x3f3f3f3f,N=10+5,M=1000+5;
int n,m,K;
int a[N][M],s[N][M];
int sum(int x,int y,int xa,int ya)
{
	return s[xa][ya]-s[xa][y-1]-s[x-1][ya]+s[x-1][y-1];
}
int dp[N][M],b[N];
bool ok(int mid,int jl)
{
	int last=0;
	int t=0;
	for(int i=1;i<=n;i++)
	{
		if(b[i]) 
		{
			t=max(t,sum(last+1,jl+1,i,mid));
			last=i;
		}
	}
	return t<=K;
}
void print()
{
	int i;
	for(i=1;i<=n;i++)	
		cout<<b[i]<<" ";
	cout<<endl;
}
int main()
{
/*	freopen("","r",stdin);
	freopen("","w",stdout);*/
	int i,j,k;
	scanf("%d %d %d ",&n,&m,&K);
	char c;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			c=getchar();
			a[i][j]=c-'0';
			s[i][j]=s[i][j-1]+s[i-1][j]-s[i-1][j-1]+a[i][j];
		}
		c=getchar();
	}
	
//	for(i=1;i<=n;i++)
//	{
//		for(j=1;j<=m;j++)
//			cout<<s[i][j]<<" ";
//		cout<<endl;
//	}
//	cout<<sum(2,2,3,4);
	int ans=INF;b[n]=1;
	for(int msk=0;msk<(1<<(n-1));msk++)
	{
		int tmp=0;
		for(i=0;i<n-1;i++)
		{
			if((msk>>i)&1) b[i+1]=1,tmp++;
			else b[i+1]=0;
		}
		j=0;
		int f=1;
		while(j!=m)
		{
			int l=j+1,r=m,an=0;
			while(l<=r)
			{
				int mid=l+r>>1;
				if(ok(mid,j))
				{
					l=mid+1;
					an=mid;
				}
				else 
					r=mid-1;
			}
			
			if(an==0){
				f=0;
				break;
			}
			
			j=an;
			if(j!=m)
				tmp++;
		}
		if(f==0) continue;
		ans=min(ans,tmp);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  unsigned long long N;
  cin >> N;
  unsigned long long a[N];
  unsigned long long ans = 1;
  for(unsigned long long i=0;i<=N-1;i++){
    cin >> a[i];
    if(a[i]==0){
      ans = 0;
      break;
    }
  }
  int s=1;
  if(ans != 0){
    for(unsigned long long i=0;i<=N-1;i++){
      if(a[i]>1000000000000000000/ans){
        s=0;
        break;
      }
      ans = ans*a[i];
    }
  }
  if(s==1){
    cout << ans;
  }else{
    cout << "-1";
  }
}

Measured memory_bytes: 4336
n=int(input())
a=[list(map(int,input().split())) for i in range(2)]
ans=0
for i in range(n):
  cnt=0
  for j in range(i+1):
    cnt+=a[0][j]
  for j in range(i,n):
    cnt+=a[1][j]
  ans=max(ans,cnt)
print(ans)


Measured memory_bytes: 3060
import sys
input = sys.stdin.readline
def linput():
    return list(map(int, input().split()))

def main():
    # N = int(input())
    A,B = linput()
    # vA = linput()
    # S = input()
    # mX = [linput() for _ in [0,]*N]

    # res = 0
    # res = -(-N//M)
    vA = [str(A)*B, str(B)*A]
    vA.sort()
    res = vA[0]

    print(res)

main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
const int N = 200000+5;

int n, a[N], sum;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]); sum ^= a[i];
    }
    for (int i = 1; i <= n; i++)
        printf("%d%c", sum^a[i], " \n"[i == n]);
    return 0;
}


Measured memory_bytes: 4536
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AGC034A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();
            int N = int.Parse(input[0]);
            int A = int.Parse(input[1]);
            int B = int.Parse(input[2]);
            int C = int.Parse(input[3]);
            int D = int.Parse(input[4]);

            string S = Console.ReadLine();
            bool check = true;
            bool wide = false;
            //岩が連続して２つ置かれている時は進めない
            for (int i = A; i < Math.Max(D, C) - 2; i++)
            {
                if (S.Substring(i, 1) == "#" && S.Substring(i + 1, 1) == "#")
                {
                    check = false;
                    break;
                }
            }
            //３つ連続してスペースがある時、追い抜ける
            for (int i = B; i < D - 3; i++)
            {
                if (S.Substring(i, 1) == "." && S.Substring(i + 1, 1) == "." && S.Substring(i + 2, 1) == ".")
                {
                    wide = true;
                }
            }
            //Bの左横と右横がスペースなら追い抜ける
            if (S.Substring(B, 1) == "." && S.Substring(B - 2, 1) == ".")
            {
                wide = true;
            }
            //Bの右側にスペースが２つあれば、追い抜ける
            if (S.Substring(B, 1) == "." && S.Substring(B + 1, 1) == ".")
            {
                wide = true;
            }
            //Dが最後尾でなくて、その左右にスペースがあるなら、追い抜ける
            if (D < C && D < S.Length - 1)
            {
                if (S.Substring(D, 1) == "." && S.Substring(D - 2, 1) == ".")
                {
                    wide = true;
                    check = true;
                }
            }
            //追い抜く必要がある時、追い抜けるか
            if (D < C && S.Substring(D - 2, 1) == "#")
            {
                if (wide == true)
                {
                    check = true;
                }
                else
                {
                    check = false;
                }
            }
            if (check == false)
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }
        }
    }
}


Measured memory_bytes: 15712
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        int[] read= inta();
        WriteLine(read[2]/read[0]*read[1]);
    
    }
    //各種読取
    static string rstr(){
        return ReadLine();
    }
    static int rint(){
        return int.Parse(ReadLine());
    }
    static long rlong(){
        return long.Parse(ReadLine());
    }
    static string[] stra(){
        return ReadLine().Split(' ');
    }
    static int[] inta(){
        string[] read_str_array = ReadLine().Split(' ');
        int[] return_int_array = new int[read_str_array.Length];
        for(int countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
        }
        return return_int_array;
    }
    static int[,] inta2(int num_array,int in_array){
        int[,] int_array2 = new int[num_array,in_array];
        for(int i=0;i<num_array;i++){
            int[] temp_array = inta();
            for(int j=0;j<in_array;j++){
                int_array2[i,j] = temp_array[j];
            }
        }
        return int_array2;
    }
    static long[] longa(){
        string[] read_str_array = ReadLine().Split(' ');
        long[] return_long_array = new long[read_str_array.Length];
        for(long countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_long_array[countup_i] = long.Parse(read_str_array[countup_i]);
        }
        return return_long_array;
    }
    static double[] doublea(){
        string[] read_str_array = ReadLine().Split(' ');
        double[] return_double_array = new double[read_str_array.Length];
        for(long countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_double_array[countup_i] = long.Parse(read_str_array[countup_i]);
        }
        return return_double_array;
    }
    // A/B小数点以下切上
    static long divideup(long divided,long divid){
        long temp_divide = divided/divid;
        if(divided % divid > 0){
            temp_divide++;
        }
        return temp_divide;
    }
    static long GCD(long a,long b){
        if(a < b){
            long temp = a;
            a = b;
            b = temp;
        }
        if(a % b == 0){ return b; }
        else{
            long temp = b;
            b = a%b;
            a = temp;
            return GCD(a,b);
        }
    }
    static long LCM(long a,long b){
        return a * b / GCD(a,b);
    }
}
//知見
// (string) hogestr -> (char[]) hoge
    // char hoge = hogestr.ToCharArray();
// (char[]) hoge -> (string) hogestr
    // string hoge = new string(hoge);
// Hashtable ×  Dictionary ○
// Dictionary hoge<string,int>
    // hoge.ContainsKey(string) -> return boolean
    // hoge[string] -> return int
    // hoge[int] -> CE
// Dictionary hoge<int1,int2>
    // hoge<int1,int2>: hoge[int1] -> return int2
    // KeyValuePair<int,int> k <-> k.Key == int1 / k.Value == int2
// SortedDictionary() > SortedList() ???
// キュー　-> 幅優先 ???
// スタック -> 深さ優先 ???


Measured memory_bytes: 13140
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
struct mint{
    using ull=unsigned long long int;
    ull v;
    mint(ll vv=0){s(vv%mod+mod);}
    mint& s(ull vv){
        v=vv<mod?vv:vv-mod;
        return *this;
    }
    //オーバーロード
    mint operator-()const{return mint()-*this;}//mint型にキャスト
    mint&operator+=(const mint&val){return s(v+val.v);}
    mint&operator-=(const mint&val){return s(v+mod-val.v);}
    mint&operator*=(const mint&val){
        v=ull(v)*val.v%mod;
        return *this;
    }
    mint&operator/=(const mint&val){return *this*=val.inv();}
    mint operator+(const mint&val){return mint(*this)+=val;}
    mint operator-(const mint&val){return mint(*this)-=val;}
    mint operator*(const mint&val){return mint(*this)*=val;}
    mint operator/(const mint&val){return mint(*this)/=val;}
    mint pow(ll n)const{
        mint res(1),x(*this);
        while(n){
            if(n&1)res*=x;
            x*=x;
            n>>=1;
        }
        return res;
    }
    mint inv()const{return pow(mod-2);}
    //拡張ユークリッドの互除法
    /* mint inv()const{
        int x,y;
        int g=extgcd(v,mod,x,y);
        assert(g==1);
        if(x<0)x+=mod;
        return mint(x);
    }*/
    friend ostream& operator<<(ostream&os,const mint&val){
        return os<<val.v;
    }//出力
    bool operator<(const mint&val)const{return v<val.v;}
    bool operator==(const mint&val)const{return v==val.v;}
    bool operator>(const mint&val)const{return v>val.v;}
};
const ll MAX = 2000010;//設定
mint fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void init(){
    fac[0] = fac[1] = 1;
    for(int i=1;i<MAX;i++)fac[i]=fac[i-1]*i;
    finv[MAX-1]=fac[MAX-1].inv();
    for(int i=MAX-2;i>=0;i--)finv[i]=finv[i+1]*(i+1);
    for(int i=MAX-2;i>=1;i--)inv[i]=finv[i]+fac[i-1];
}
//階乗
mint factor(ll n,ll k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return fac[n]*finv[k];
}
// 二項係数計算
mint COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[k] * finv[n - k];
}
int main(){
  mint ans=0,res=0;
  ll n,m;
  cin>>n>>m;
  V<ll> a(n),b(m);
  for(int i=0;i<n;i++){
      cin>>a[i];
  }
  for(int i=0;i<m;i++){
      cin>>b[i];
  }
  for(int i=0;i<n-1;i++)ans+=mint(a[i+1]-a[i])*mint(i+1)*mint(n-i-1);
  for(int i=0;i<m-1;i++)res+=mint(b[i+1]-b[i])*mint(i+1)*mint(m-i-1);
  ans*=res;
  cout<<ans<<"\n";
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, n, m) for (int i = n; i < m; i++)
#define ll long long int

using namespace std;

int main()
{
  int p, q, r;
  cin >> p >> q >> r;
  cout << min(min(p + q, q + r), r + p) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#define rep(i,f,t) for(int i=f;i<t;i++)
#define ll long long
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<ll> vec(n+1,0);
	for(int i=1;i<=n/2;i++){
		for(int j=i;j<=n;j+=i){
			vec[j]++;
		}
	}
	ll ans=0;
	rep(i,1,n+1){
		if(i>n/2){
			ans=ans+((vec[i]+(ll)1)*(ll)i);
		}
		else{
			ans=ans+vec[i]*(ll)i;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 81400
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 9999999999999999999;
const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;
const int SIZE = 1 << 17;

int main() {
	int a, b, k[100005], sum = 0;
	cin >> a >> b;
	vector<int>dis;
	for (int i = 0; i < b; ++i) { cin >> k[i]; }
	sort(k, k + b);
	if (a >= b) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 1; i < b; ++i) {
		dis.push_back(abs(k[i] - k[i - 1]));
		sum += abs(k[i] - k[i - 1]);
	}
	sort(dis.rbegin(), dis.rend());
	for (int i = 0; i < a - 1; ++i) {
		sum -= dis[i];
	}
	cout << sum << endl;
}

Measured memory_bytes: 1276
b[11]={63,6,91,79,102,109,125,39,127,111,0},q=11,k,n,p,i,j;main(){for(;~scanf("%d",&n)&~n;)for(i=0;i<n&&scanf("%d",&k);i++,q=k)for(j=7;j>-1;j--?printf("%d",(p>>j)&1):puts(""))p=i?b[q]^b[k]:b[k];exit(0);}

Measured memory_bytes: 612
ant= []
while a = gets do
    ant.push(a)
end

k = ant.last.to_i
ant.delete_at(ant.length-1)

connect = "Yay!"
last = ant[0].to_i
ant.each do |a|
    distance = a.to_i - last.to_i
    if distance.to_i > k
        connect = ":("
    end
end

puts connect

Measured memory_bytes: 1788
using System;
using System.Collections.Generic;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();

        int sum = sc.NextInt() + sc.NextInt() + sc.NextInt();
        Console.WriteLine(sum >= 22 ? "bust" : "win");
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int sz = s.size();
    int n; cin >> n;
    int l[n], r[n];
    for (int i = 0; i < n; i++) {
        cin >> l[i] >> r[i]; l[i]--;
        if (r[i] <= (sz+1)/2) continue;
        if (l[i] <= (sz+1)/2) {
            r[i] = sz - r[i];
            if (r[i] < l[i]) swap(l[i], r[i]);
        } else {
            l[i] = sz - l[i];
            r[i] = sz - r[i];
            swap(l[i], r[i]);
        }
    }

    int m = sz/2+1;
    int diff[m];
    for (int i = 0; i <= sz/2; i++) {
        s[i] -= s[sz-i-1]; s[sz-i-1] = 0;
        if (!i) diff[i] = s[i];
        else diff[i] = (s[i] - s[i-1] + 52) % 26;
    }

    set<int> e[m];
    for (int i = 0; i < n; i++) {
        if (r[i] * 2 > sz) r[i]--;
        if (l[i] != r[i]) {
            e[l[i]].emplace(r[i]);
            e[r[i]].emplace(l[i]);
        }
    }
    vector<bool> vis(m, 0);
    auto dfs = [&vis, &diff, &e](auto f, int curr) -> int {
        int ret = 0;
        vis[curr] = 1;
        for (auto &to: e[curr]) {
            if (vis[to]) continue;
            ret += f(f, to);
        }
        return ret + diff[curr];
    };
    bool ok = true;
    for (int i = 0; i < m; i++) {
        if (!vis[i]) ok &= (dfs(dfs, i) % 26 == 0);
    }
    if (ok) cout << "YES\n";
    else cout << "NO\n";
    return 0;
}

Measured memory_bytes: 14416
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if (a == b)
			System.out.println(c);
		if (a == c)
			System.out.println(b);
		if (b == c)
			System.out.println(a);
		sc.close();
	}
}

Measured memory_bytes: 23892
S = list(input())

rain_max = 0
rain_cnt = 0
flag = False
for i in range(len(S)):
    if S[i] == 'R':
        rain_cnt += 1
    else:
        if rain_cnt > rain_max:
            rain_max = rain_cnt
            flag = True
        rain_cnt = 0

if not flag:
    rain_max = rain_cnt

print(rain_max)

Measured memory_bytes: 9040
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int n,m,x;
bool a[27],b[27];
int c[5][5][5],t[5][5][5];
string w;

int main(){
  int z = 1;
  while(cin >> n,n){
    if(z!=1)cout << endl;
    rep(i,5)rep(j,5){
      cin >> w;
      rep(k,5)c[i][j][k] = w[k]-'0';
    }
    rep(i,27)a[i] = b[i] = false;
    cin >> m; rep(i,m){cin >> x; a[x] = true;}
    cin >> m; rep(i,m){cin >> x; b[x] = true;}

    rep(d,n){
      rep(i,5)rep(j,5)rep(k,5){
	int s = -c[i][j][k];
	rep(ii,3)rep(jj,3)rep(kk,3){
	  if(i+ii-1<0 || i+ii-1>4 || j+jj-1<0 || j+jj-1>4 ||
	     k+kk-1<0 || k+kk-1>4)continue;
	  s += c[i+ii-1][j+jj-1][k+kk-1];
	}
	t[i][j][k] = c[i][j][k];
	if((!c[i][j][k] && a[s])||(c[i][j][k] && !b[s]))t[i][j][k] = !t[i][j][k];
      }
      swap(c,t);
    }
    cout << "Case " << z << ":\n";
    rep(i,5){ rep(j,5){ rep(k,5)cout << c[i][j][k]; cout << endl; } if(i<4)cout << endl; } 
    z++;
  }
}

Measured memory_bytes: 1208
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<tuple>
#include<set>
#include<map>
#include<cctype>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;
const int MOD = 1e9 + 7;

string a;
ll cntw;
ll ans;
int main(void) {
	cin >> a;
	int n = a.length();
	FOR(i, 0, n) {
		if (a[i] == 'W') {
			ans += i - cntw;
			cntw++;
		}
	}
	ct(ans);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int h,w;
  cin>>h>>w;
  vector<string> t(h);
  REP(i,h) cin>>t[i];
  vector<vecint> cnt(h, vecint(w, 0));
  REP(i,h){
    int old = -1;
    REP(j,w) {
      if (t[i][j] == '#') {
        int sum = j-old-1;
        FOR(k,old+1,j) {
          cnt[i][k] += sum;
        }
        old = j;
      }
    }
    int sum = w-old-1;
    FOR(k,old+1,w) {
      cnt[i][k] += sum;
    }
  }
  REP(i,w) {
    int old=-1;
    REP(j,h) {
      if(t[j][i] == '#') {
        int sum = j-old-1;
        FOR(k,old+1,j) {
          cnt[k][i] += sum;
        }
        old = j;
      }
    }
    int sum = h-old-1;
    FOR(k,old+1,h) {
      cnt[k][i] += sum;
    }
  }
  int mx=0;
  REP(i,h)REP(j,w) mx=max(mx,cnt[i][j]);
  cout<<mx-1<<endl;
  return 0;
}


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

int main(){
	int a,b;
	cin >> a >> b;
	if(a>0)cout << "Positive" << endl;
	else{
		if(b>=0)cout << "Zero" << endl;
		else {
			if((b-a)%2==0)cout << "Negative" << endl;
			else cout << "Positive" << endl;
		}
	}
	return 0;
}

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

int main()
{
    int Q;
    cin >> Q;
    for ( int i = 0; i < Q; i++ ) {
        int c, a, n;
        cin >> c >> a >> n;
        //CAN
        int cnt = min ( { c, a, n } );
        c -= cnt, a -= cnt, n -= cnt;
        //CCA
        int val = min ( c / 2, a );
        cnt += val;
        c -= val * 2, a -= val;
        //CCC
        cnt += c / 3;
        cout << cnt << endl;
    }
    return ( 0 );
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using Int = unsigned long long;
typedef pair<int,int> P;
typedef priority_queue<int> Pr;
typedef vector<int> Vi;
typedef vector<P> Vp;
int const MOD = 1000000007;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
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(nullptr); ios::sync_with_stdio(false);

    int n; cin>>n; int a[n],b[n],c[n-1];
    for (int i = 0; i < n; i++)cin>>a[i];
    for (int i = 0; i < n; i++)cin>>b[i];
    for (int i = 0; i < n-1; i++)cin>>c[i];
    int ans=0;
    for (int i = 0; i < n; i++){
      ans+=b[a[i]-1];
      if(i&&a[i-1]+1==a[i])ans+=c[a[i-1]-1];
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/integer/common_factor_rt.hpp>
using namespace std;
using ll=long long;
const int MOD=1000000007;

int main() {
  int n,m;
  cin >> n >> m;
  if(m==1 || n>=m){
    cout << 0 << endl;
    return 0;
  }
  vector<int> x(m);
  for(int i=0;i<m;i++){
    cin >> x.at(i);
  }
  sort(x.begin(),x.end());
  int max=x.at(m-1)-x.at(0);
  if(n==1){
    cout << max << endl;
    return 0;
  }
  vector<int> sa(m-1);
  for(int j=0;j<m-1;j++){
    sa.at(j)=x.at(j+1)-x.at(j);
  }
  sort(sa.begin(),sa.end());
  reverse(sa.begin(),sa.end());
  int sum=0;
  for(int i=0;i<n-1;i++){
    sum+=sa.at(i);
  }
  cout << max-sum << endl;
}

Measured memory_bytes: 3920
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a;
	cin>> a;
	cout << 3*a*a << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 1000000

char S[N][13];
int m=999983; //素数

void insert(char *);
int find(char *);
int getnum(char); //文字列から数字を得る
int getkey(char *); //文字列からkeyを得る
int h1(int);
int h2(int);

int main()
{
  int n,i;
  char command[7],array[13];
  
  scanf("%d",&n);
  if(n>N) exit(1);
  for(i=0;i<n;i++){
    scanf("%s %s",command,array);
    if(strlen(array)<1 || strlen(array)>12) exit(2);
    if(command[0]=='i'){
      insert(array);
      //printf("確認\n");
    }
    else if(command[0]=='f'){
      if(find(array)) printf("yes\n");
      else printf("no\n");
    }
    //else printf("処理なし\n");
  } 
  return 0;
}

void insert(char *array)
{
  int key,h,i;

  key=getkey(&array[0]);

  for(i=0;;i++){
    h = (h1(key)+i*h2(key))%m;
    if(strlen(S[h])==0){
      strcpy(S[h],array);
      //printf("確認：%s\n",S[h]);
      //printf("%s\n",array);
      break;
    }
  }
}

int find(char *array)
{
  int key,i,h;

  key=getkey(&array[0]);

  for(i=0;;i++){
    h = (h1(key)+i*h2(key))%m;
    if(strcmp(S[h],array)==0) return 1;
    else if(strlen(S[h])==0) return 0;
  }

  return 0;
		 
}

int getnum(char c)
{
  if(c=='A') return 1;
  else if(c=='C') return 2;
  else if(c=='G') return 3;
  else if(c=='T') return 4;
  else return 0;
}

int getkey(char *array)
{
  int i,sum=0,n=1;
  
  for(i=0;i<strlen(array);i++){
    sum += n*getnum(array[i]);
    n *=7;
  }
  return sum;
}

int h1(int key)
{
  return key%m;
}

int h2(int key)
{
  return 1+(key%(m-1));
}



Measured memory_bytes: 14480
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt(),m = scanner.nextInt();
		int[] studentx = new int[n];
		int[] studenty = new int[n];
		int[] checkx = new int[m];
		int[] checky = new int[m];
		for(int i=0;i<n;i++){
			studentx[i] = scanner.nextInt();
			studenty[i] = scanner.nextInt();
		}
		for(int i=0;i<m;i++){
			checkx[i] = scanner.nextInt();
			checky[i] = scanner.nextInt();
		}
		int[] result = new int[n];
		for(int i=0;i<n;i++){
			int min = Integer.MAX_VALUE;
			int x = 0;
			for(int j=0;j<m;j++){
				int dis = Math.abs(studentx[i] - checkx[j]) + Math.abs(studenty[i] - checky[j]);
				if(dis < min){
					min = dis;
					x = j;
				}
			}
			result[i] = x + 1;
		}
		for(int i=0;i<n;i++){
			System.out.println(result[i]);
		}
	}

}


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

int main(){
    long long N, MIN=0,co=0;
    cin >> N;
    vector<long long> P(N);

    for(int i=0; i<N; i++)
        cin >> P[i];

    MIN = P[0];

    for(int i=1; i<N; i++){
        MIN = min(P[i], MIN);
        if(MIN < P[i])
            co++;
    }

    cout << N-co << endl;
}

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

typedef long long ll;
int const INF = 1000000000;

int n;
int a[40], b[40], c[40];
int Ma, Mb;
int dp[41][401][401];

int check(){
    int mini = INF;
    for (int ca = 1; ca <= 400; ca++){
        for (int cb = 1; cb <= 400; cb++){
            if(ca * Mb == cb * Ma){
                mini = min(mini, dp[n][ca][cb]);
            }
        }
    }
    if (mini == INF){
        return -1;
    } else {
        return mini;
    }
}

int main(){
    cin >> n >> Ma >> Mb;
    for (int i = 0; i < n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    for (int i = 0; i <= n; i++){
        for (int j = 0; j <= 400; j++){
            for (int k = 0; k <= 400; k++){
                dp[i][j][k] = INF;
            }
        }
    }
    dp[0][0][0] = 0;

    for (int i = 0; i < n; i++){
        for (int ca = 0; ca <= 400;ca++){
            for (int cb = 0; cb <= 400; cb++){
                if (dp[i][ca][cb] == INF) continue;
                dp[i+1][ca][cb] = min(dp[i+1][ca][cb], dp[i][ca][cb]);
                dp[i+1][ca+a[i]][cb+b[i]] = min(dp[i+1][ca+a[i]][cb+b[i]], dp[i][ca][cb] + c[i]);
            }
        }
    }

    cout << check() << endl;
}


Measured memory_bytes: 25984
n,m,x = map(int,input().split())
A = list(map(int,input().split()))
# xより小さい料金所と大きい料金所の数をかぞえたら終了
left = 0
right = 0
for a in A:
  if a < x:
    left += 1
  else:
    right += 1
print(min(left,right))


Measured memory_bytes: 2940