akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    string A="AC";
    string B="WA";
    cin>>s;
    bool flag=false;
    if(s[0]=='A')
    {
        for(int i=2;i<s.size()-1;i++)
        {
            if(!flag&&s[i]=='C')
            {
                flag=true;
                continue;
            }
            if(s[i]>='A'&&s[i]<='Z'&&s[i]!='C')
            {
                flag=false;
                break;
            }
            if(flag&&s[i]>='A'&&s[i]<='Z')
            {
                flag=false;
                break;
            }
        }
    }
    if(s[1]>='A'&&s[1]<='Z'||s[s.size()-1]>='A'&&s[s.size()-1]<='Z') flag=false;
    if(flag)
        cout<<A;
    else cout<<B;
}


Measured memory_bytes: 256
def gcd(a, b):
	"""Compute the greatest common divisor of a and b"""
	while b > 0:
		a, b = b, a % b
	return a

def lcm(a, b):
	"""Compute the lowest common multiple of a and b"""
	return a * b // gcd(a, b)

def resolve():
	n = int(input())
	ans = int(input())
	for _ in range(n-1):
		ans = lcm(ans, int(input()))
	print(ans)
resolve()

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


int main(){
    ll n;
    cin >> n;
    ll mod=1e9+7;
    ll a[n];
    for(ll i=0;i<n;i++) cin >> a[i];
    vector<ll> x(n,0);
    vector<ll> y(n,0);
    vector<ll> z(n,0);
    for(ll i=0;i<n-1;i++){
        if(x[i]==a[i]){
            x[i+1]=x[i]+1;
            y[i+1]=y[i];
            z[i+1]=z[i];
        }
        else if(y[i]==a[i]){
            x[i+1]=x[i];
            y[i+1]=y[i]+1;
            z[i+1]=z[i];
        }
        else if(z[i]==a[i]){
            x[i+1]=x[i];
            y[i+1]=y[i];
            z[i+1]=z[i]+1;
        }
    }
    ll res=1;
    for(ll i=0;i<n;i++){
        ll count=0;
        if(x[i]==a[i]) count++;
        if(y[i]==a[i]) count++;
        if(z[i]==a[i]) count++;
        res*=count;
        res%=mod;
    }
    cout << res << endl;
    return 0;
}  


Measured memory_bytes: 6352
fn solve<R: BufRead, W: Write>(_reader: R, _writer: &mut W) {
  let mut _scanner = Scanner::new(_reader);
  #[allow(unused_macros)]
  macro_rules! scan {
    ($t:ty) => { _scanner.next::<$t>() };
    ($($t:ty),+) => { ($(scan!($t)),+) };
    ($t:ty; $n:expr) => {{
      let mut vec = Vec::with_capacity($n);
      for _ in 0..$n {
        vec.push(scan!($t));
      }
      vec
    }};
    ($t_0:ty, $t_1:ty; $n:expr) => { scan!($t_0 = 0, $t_1 = 1; $n) };
    ($t_0:ty, $t_1:ty, $t_2:ty; $n:expr) => { scan!($t_0 = 0, $t_1 = 1, $t_2 = 2; $n) };
    ($($t:ty = $i:tt),+; $n:expr) => {{
      let mut vecs = ($(Vec::<$t>::with_capacity($n)),+);
      for _ in 0..$n {$(
        vecs.$i.push(scan!($t));
      )+}
      vecs
    }};
  }
  #[allow(unused_macros)]
  macro_rules! println {
    () => { writeln!(_writer).unwrap() };
    ($fmt:expr) => { writeln!(_writer, $fmt).unwrap() };
    ($fmt:expr, $($arg:tt)*) => { writeln!(_writer, $fmt, $($arg)*).unwrap() };
  }

  let (a, b, x) = scan!(i64, i64, i64);
  let ans = if x >= a && x <= a + b { "YES" } else { "NO" };
  println!("{}", ans);
}

fn main() {
  let stdin = stdin();
  let stdout = stdout();
  #[cfg(debug_assertions)]
  let mut writer = stdout.lock();
  #[cfg(not(debug_assertions))]
  let mut writer = BufWriter::new(stdout.lock());
  solve(stdin.lock(), &mut writer);
  writer.flush().unwrap();
}

use io::Scanner;
use std::io::{stdin, stdout, BufRead, BufWriter, Write};

pub mod io {
  pub use self::scanner::*;

  mod scanner {
    use std::fmt::Debug;
    use std::io::BufRead;
    use std::str;
    use std::str::FromStr;

    pub struct Scanner<R: BufRead> {
      reader: R,
      buffer: Vec<u8>,
      position: usize,
    }

    impl<R: BufRead> Scanner<R> {
      pub fn new(reader: R) -> Self {
        Scanner { reader: reader, buffer: vec![], position: 0 }
      }

      pub fn next<T: FromStr>(&mut self) -> T
      where
        T::Err: Debug,
      {
        if self.buffer.is_empty() {
          self.read_line();
        }
        loop {
          match self.buffer.get(self.position) {
            Some(&b' ') => self.position += 1,
            Some(&b'\n') => self.read_line(),
            Some(_) => break,
            None => panic!("EOF reached"),
          }
        }
        let start = self.position;
        loop {
          match self.buffer.get(self.position) {
            Some(&b' ') | Some(&b'\n') | None => break,
            Some(_) => self.position += 1,
          }
        }
        str::from_utf8(&self.buffer[start..self.position]).unwrap().parse().unwrap()
      }

      fn read_line(&mut self) {
        self.position = 0;
        self.buffer.clear();
        self.reader.read_until(b'\n', &mut self.buffer).unwrap();
      }
    }
  }
}


Measured memory_bytes: 4352
#include<stdio.h>
#define N 100001

int main(){
  
  int x,n,A[N],i,j,y,z;

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }

  x = A[n];
  i = 0;

  for(j=1;j<=n-1;j++){
    if(A[j] <= x){
      i = i+1;
      y = A[j];
      A[j] = A[i];
      A[i] = y;
    }
  }

  z = A[n];
  A[n] = A[i+1];
  A[i+1] = z;

  for(j=1;j<=n;j++){
    if(j == n){
      printf("%d\n",A[j]);}
    else if(j == i+1){ printf("[%d] ",A[j]);}
    else printf("%d ",A[j]);
  }
  return 0;
}
  



Measured memory_bytes: 2104
while True:
    n = int(input())
    if n == 0: break
  
    data = {}
    staff = []
    for i in range(n):
        tmp = [int(el) for el in input().split(' ')]
        if tmp[0] in data:
            data[tmp[0]] += tmp[1] * tmp[2]
        else:
            data[tmp[0]] = tmp[1] * tmp[2]
            staff.append(tmp[0])
  
    if max(data.values()) < 1e6:
        print('NA')
    else:
        for k in staff:
            if data[k] >= 1e6:
                print(k)

Measured memory_bytes: 7824
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;

int main(){

	int N, K;
	string S;

	cin >> N >> S >> K;

	for(int i = 0; i < S.size(); i++){
		if(S[i] != S[K-1]){
			S[i] = '*';
		}
	}

	cout << S << endl;

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;
string arr[1000005];
char str[1000005];

int main() {
    //freopen("test.in", "r", stdin);
    //  freopen("ac.txt", "w", stdout);
    int n;
    scanf("%d", &n);
    vector<int> vec;
    for (int i = 0; i < n; ++i) {
        scanf("%s", str);
        arr[i] = string(str);
        vec.push_back(i);
    }
    sort(vec.begin(), vec.end(), [](int x, int y) {
        return arr[x].size() < arr[y].size();
    });
    long long ans = 0;
    unordered_map<size_t, int> hash;
    for (int i = 0; i < n; ++i) {
        string &S = arr[vec[i]];
        int vis = 0, sz = S.size();
        size_t h = 0;
        for (int i = 0; i < sz; ++i) {
            int id = S[i] - 'a' + 1;
            if ((vis >> id) & 1) continue;
            vis |= (1 << id);
            h = 1;
            if (hash.find((h * 31) + id) != hash.end()) ans += hash[(h * 31) + id];
            for (int j = sz - 1; j > i; --j) {
                h *= 31;
                h += (S[j] - 'a' + 1);
                if (hash.find((h * 31) + id) != hash.end()) ans += hash[(h * 31) + id];
            }
        }
        h = 1;
        for (int j = sz - 1; ~j; --j) {
            h *= 31;
            h += (S[j] - 'a' + 1);
        }
        ++hash[h];
    }
    cout << ans;
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define INF 2000000000

int compare_int( const void * a , const void * b ) {
  /* 引数はvoid*型と規定されているのでint型にcastする */
  if( *( long * )a < *( long * )b ) {
    return -1;
  }
  else
  if( *( long * )a == *( long * )b ) {
    return 0;
  }
  return 1;
}

int main(){
		int n;
		long a[200000],ans=0,ans2=0,minimum=INF,maximum=0,i,sc=0,sc2=INF;
		scanf("%d",&n);
		for(i=0;i<n;i++){
				scanf("%ld",&a[i]);
				a[i]-=(i+1);
		}
		qsort(a,n,sizeof(long),compare_int);
		if(n%2==1)sc=a[n/2];
		else {
				sc=a[(n-1)/2];
				sc2=a[n/2];
		//		sc=(sc+sc2)/2;
		}
		for(i=0;i<n;i++){
				ans+=abs(a[i]-sc);
				if(n%2==0)ans2+=abs(a[i]-sc2);
		}
		if(n%2==1)printf("%ld\n",ans);
		else {
				printf("%ld\n",min(ans,ans2));
		}
		//printf("%ld\n",ans);
		return 0;
}


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

int main(){
  ll a,c;
  double b;
  cin >>a >>b;
  c = b*100+0.5;
  ll ans = a*c/100;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 
 
using namespace std;
long long mod=1e9+7;
long long INF=1e7;
double EPS = 1e-12;
typedef long long int lld;
double tick(){static clock_t oldt;clock_t newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt = newt;return diff;}
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define scd(a) scanf("%d",&a)
#define scd2(a,b) scanf("%d%d",&a,&b)
#define scd3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scf(a) scanf("%lf",&a)
#define scf2(a,b) scanf("%lf%lf",&a,&b)
#define scf3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define all(c) c.begin(), c.end()
#define sz(a) ((int)a.size())
#define Error(x) cout<< #x << " = " << (x) <<endl;
#define Error2(a,b) cout<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define Error3(a,b,c) cout<<"("<<#a<<" , "<<#b<<" , "<<#c<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<")\n";
#define Error4(a,b,c,d) cout<<"("<<#a<<" , "<<#b<<" , "<<#c<<" , "<<#d<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<" , "<<(d)<<")\n";
#define errop(a) cout<<#a<<" = ( "<<((a).x)<<" , "<<((a).y)<<" )\n";
#define mset(a, v) memset(a, v, sizeof(a))
#define popcount __builtin_popcountll
 
typedef pair<lld,lld> PA;
 
lld powP(lld a,lld b){
    if(b==0) return 1%mod;
    lld k;
    k=powP(a,b/2);
    k=k*k%mod;
    if(b%2==0) return k;
    else return a*k%mod;
}
 
bool bitSet(lld n,lld i){
    if((n&(1LL<<i))!=0) return true;
    else return false;
}
 
lld findGcd(lld a,lld b){
    if(a==0) return b;
    else return findGcd(b%a,a);
}
 
#define lim 500010
#define lim2 200003
#define qqqqqq 210
// inline lld sqr(lld x) { return x * x; }
// unordered_map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];
// vector<lld> V[lim];
// int X[lim],Y[lim],C[lim];
// string S[lim];
lld A[lim],B[lim];
// map<lld,lld> M;

int main(){
    lld T,i,n,m,p,j,l,e,r,b,c,k,q,a,d,w,x,y,v,z,t,curr,prev,sum,ans,pos,val,countA,indicator;
    {
        lld n,a,b,c,d;
        sc3(n,a,b);
        sc2(c,d);
        n--;
        bool poss = false;
        for(lld i = n;i>=0;i-=2){
            lld diff = abs(a-b);
            x = i*c - (n-i)/2*(d-c);
            y = i*d + (n-i)/2*(d-c);
            // Error3(x,diff,y);
            if(x <= diff && y >= diff){
                // Error3(x,diff,y);
                poss = true;
            }
        }
        if(poss) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
a = []
for i in range(h):
    b = input()
    if len(set(b)) > 1 or b[0] == '#':
        a.append(b)
c = list(range(w))
for i in range(w):
    f = 0
    for j in range(len(a)):
        if a[j][i] == '#':
            f = 1
            break
    if f == 0:
        c.remove(i)

for j in range(len(a)):
    for i in c:
        print(a[j][i],end = '')
    print('')


Measured memory_bytes: 9132
/// In The Name Of God

#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

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

using namespace std;

int n, m;

map <int, vector <int > > g[N];

map <int, int> d[N];

int c[N];

int main() {
	#ifdef IOI2018
		freopen ("in.txt", "r", stdin);
    freopen ("E.out", "w", stdout);
	#endif
	Kazakhstan
	cin >> n >> m;
	rep(i, 1, m) {
		int a, b, c;
		cin >> a >> b >> c;
		g[a][c].pb(b);
    g[b][c].pb(a);
	}
	d[1][0] = 0;
	set < pair <int, pair <int, int> > > st;
	st.insert({0, {1, 0}});
  vector <bool> was(n + 1, 0);
	while (sz(st)) {
		int dist = st.begin() -> f;
		int v = st.begin() -> s.f, last = st.begin() -> s.s;
		st.erase(st.begin());
    
    if (!was[v]) {
      for (auto it : g[v]) {
        int C = it.f;
        for (auto to : it.s) {
          if (!d[to].count(C) || d[to][C] > dist + 1) {
            st.erase({d[to][C], {to, C}});
            d[to][C] = dist + 1;
            st.insert({d[to][C], {to, C}});
          }
        }
      }
      was[v] = 1;
    }

    if (sz(g[v][last])) {
      int C = last;
      for (auto to : g[v][last]) {
        if (!d[to].count(last) || d[to][last] > dist) {
          st.erase({d[to][C], {to, C}});
          d[to][C] = dist;
          st.insert({d[to][C], {to, C}});
        }
      }
      g[v][last].clear();
      g[v].erase(last);
    }
  }
  int ans = inf;
  for (auto it : d[n]) ans = min(ans, it.s);
  cout << (ans == inf ? -1 : ans);
	ioi
}


Measured memory_bytes: 105728
fun main(args: Array<String>) {
    val (n,k) = readLine()!!.split(" ").map { it.toLong() }

    (1..k).joinToString("\n") { i ->
        val ans = combination(k-1, i-1) x combination(n-k+1, i)
        ans.toString()
    }.let { println(it) }
}



const val MOD = 1000000007L
const val FACT_MAX = 10000

infix fun Long.x(other: Long) = (this*other)%MOD
infix fun Long.t(other: Long) = (this+other)%MOD

val fact = run {
    val fact = LongArray(FACT_MAX+1)
    fact[0] = 1L
    for (i in 1..FACT_MAX) fact[i] = fact[i-1] x i.toLong()
    fact.toList()
}

fun pow(base: Long, exp: Long): Long{
    var base = base
    var exp = exp
    var ret = 1L
    while (exp>0) {
        if(exp%2==1L) ret = ret x base
        base = base x base
        exp /= 2
    }
    return ret
}

fun inv(n: Long) = pow(n, MOD-2)

fun combination(n: Long, k: Long) : Long{
    if(n<k) return 0L
    val n = n.toInt()
    val k = k.toInt()
    val denominator = fact[k] x fact[n-k]
    return fact[n] x pow(denominator, MOD-2)
}


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

int main() {

    long long int n;
    cin >> n;

    long long int ans = 0;
    for ( long long int i = 1; i <= n; i++ ) {
        long long int p = i;
        while( p >= 100 ) {
            p /= 100;
        }
        if ( p < 10 ) ans++;
    }

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        int n=sc.nextInt();
        int[] array= new int[n];
        int sum=0;
        for(int i=0;i<n;i++){
            array[i]=sc.nextInt();
            sum+=array[i];
        }
        int min=sum;
        int minnum=0;
        for (int i=0;i<n;i++){
            if (Math.abs(sum-array[i]*n)<min){
                min=Math.abs(sum-array[i]*n);
                minnum=i;
            }
        }
        System.out.println(minnum);
    }
}


Measured memory_bytes: 21972
#include <stdio.h>

int main(){
    int num=0,i=0;
    double sum=0.0,ans=0.0;
    scanf("%d",&num);
    int yoshio[num];
    for(i=0;i<num;i++){
        scanf("%d",&yoshio[i]);
        sum+=1/(double)yoshio[i];
    }
    ans=1/sum;
    printf("%lf\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
signed main(void)
{
  int X,N,a,left,right,P[102]={};
  if(scanf("%d %d",&X,&N)>0)
  {
    if(N==0)return printf("%d\n",X),0;
    for(int i=0;i<102;i++){P[i]=i;}
    while(N--)
    {
      if(scanf("%d",&a)==1){P[a]=102;}
    }
    for(int i=X;i>=0;i--)
    {
      if(P[i]==102)continue;
      left=i;break;
    }
    for(int i=X;i<102;i++)
    {
      if(P[i]==102)continue;
      right=i;break;
    }
    return printf("%d\n",(X-left<=right-X)?left:right),0;
  }
}

Measured memory_bytes: 1732
N = int(input())
A = [0]
A.extend(list(map(int, input().split())))
#print(A)
A.append(0)
money = [0]
for i in range(1, len(A)):
    money[0] += abs(A[i] - A[i - 1])

#print(money)
for i in range(1, N + 1):
    money.append(money[0])
    money[i] -= abs(A[i] - A[i - 1])
    #print(money[i])
    money[i] -= abs(A[i] - A[i + 1])
    #print(money[i])
    money[i] += abs(A[i + 1] - A[i - 1])
    print(money[i])
#print(money[1:])


Measured memory_bytes: 14048
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int n,a,b;
vector<int> ret;
void dfs(int l,int r,int mask){
    if((mask&(mask-1))==0){
        ret.pb(l);
        ret.pb(r);
        return;
    }
    int x=l^r;
    int tb=x&-x,tc=mask^tb;
    int td=tc&-tc;
    dfs(l,l^td,tc);
    dfs(l^tb^td,r,tc);
}
int main(){
    cin>>n>>a>>b;
    if(__builtin_popcount(a)%2==__builtin_popcount(b)%2){
        cout<<"NO"<<endl;
        return 0;
    }
    dfs(a,b,(1<<n)-1);
    cout<<"YES"<<endl;
    rep(i,ret.size()){
        cout<<ret[i]<<" ";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 1656
N = int(input())
S = list(input())
ans = 0
r = S.count("R")
g = S.count("G")
b = S.count("B")
ans += r*g*b
m = 0
if N >= 3:
  for i in range(N-2):
    for j in range(i+1,N-1):
      k = 2*j-i
      if  k < N and S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
        m += 1
print(ans-m)

Measured memory_bytes: 9152
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef vector<vector<P>> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<ll> vec;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    double r;
    cin>>r;
    cout<<r*r*M_PI<<" "<<2*r*M_PI<<endl;
}


Measured memory_bytes: 3292
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const int INF = 2000000000;

int a, b, c, d;

int main(){
  cin >> a >> b >> c >> d;
  cout << max(a*b, c*d) <<endl;
}
  

Measured memory_bytes: 256
def d_grid_components(A, B):  # 白マス,黒マスの連結成分の個数
    H, W = 100, 100  # グリッドの縦と横。入力に関わらず定数(条件の最大値)とする
    # 100x100グリッドの上半分を黒で、下半分を白で塗りつぶす
    grid = [['#'] * W for _ in range(50)] + [['.'] * W for _ in range(50)]

    def fill(start, end, num, symbol):
        # start列からend-1列まで、num個のsymbolを1マスおきに置いていく
        for h in range(start, end, 2):
            for w in range(1, W, 2):
                if num > 0:
                    grid[h][w] = symbol
                    num -= 1
                else:
                    return
        return None

    fill(1, 50, A - 1, '.')  # 黒ゾーンに1つおきに1x1白マスをA-1個置く
    fill(51, 100, B - 1, '#')  # 白ゾーンに1つおきに1x1黒マスをB-1個置く

    ans = '100 100\n' + '\n'.join([''.join(row) for row in grid])
    return ans

A, B = [int(i) for i in input().split()]
print(d_grid_components(A, B))

Measured memory_bytes: 3188
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  ll a,b=0;cin>>a>>b;
  cout<<(a*3+b)/2;
}


Measured memory_bytes: 26980
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] t = new int[N+1];
		int[] x = new int[N+1];
		int[] y = new int[N+1];
		for( int i=1; i<=N; i++ ){
			t[i] = sc.nextInt();
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		for( int i=1; i<=N; i++ ){
			int a = (x[i]-x[i-1])+(y[i]-y[i-1]);
			int b = t[i]-t[i-1];
			if( a>b || (b-a)%2!=0 ){
				System.out.println("No");
				break;
			}
			if( i==N ){
				System.out.println("Yes");
			}
		}
	}
}


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

using namespace std;

int main()
{
    int n;
    string w[100];

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

    for (int i = 1; i < n; i++) {
        if (w[i - 1].back() != w[i].front()) {
            cout << "No" << endl;
            return 0;
        }

        for (int j = 0; j < i; j++) {
            if (w[j] == w[i]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    int n = 0;
    cin >> n;
    vector<int> d(n);
    for (int i=0; i<n; i++) {
        cin >> d.at(i);
    }
    sort(d.begin(), d.end());
    cout << d.at(n/2) - d.at(n/2-1) << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n; scanf("%d",&n);
	bool flg = true;
	for(int i=0;i<n;i++){
		int x; scanf("%d",&x);
		if(!flg) continue;
		if(x%2!=0) flg = false;
	}
	if(flg) printf("second");
	else printf("first");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
    string S;
    cin >> S;
    string ans(S.size(), 'x');
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

const int maxn = 110;

ll n;
ll a[maxn];
ll ans;

int main()
{
	scanf("%lld",&n); for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	
	ans=0ll;
	if(a[1]>=n)
	{
		ans=a[1]-n+1ll;
		for(int i=1;i<=n;i++) a[i]-=ans;
		ans*=n;
	}
	for(int i=n;i>=2;i--)
	{
		ll x=a[i-1],y=a[i];
		if(y-x>=n)
		{
			ll tmp=n+1ll; //n-i+1
			ll temp=(y-x-(n-1ll)+tmp-1ll)/tmp;
			
			ll dec=temp*(ll)(n-i+1); ans+=dec;
			for(int j=1;j<i;j++) a[j]+=dec;
			for(int j=i;j<=n;j++) a[j]-=(ll)i*temp;
		}
		sort(a+1,a+n+1);
	}
	if(a[1]>=n)
	{
		ll temp=a[1]-n+1ll;
		ans+=n*temp;
		for(int i=1;i<=n;i++) a[i]-=temp;
	}
	while(a[n]>=n)
	{
		ll temp=a[n]/n; ans+=temp; a[n]-=temp*n;
		for(int i=1;i<n;i++) a[i]+=temp;
		sort(a+1,a+n+1);
	}
	printf("%lld\n",ans);
	
	return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

using edge=struct {int to,cap,cost,rev;};
using G=vector<vector<edge>>;
const int inf=1<<29;

void add_edge(G &graph,int a,int b,int c,int d){
	graph[a].push_back({b,c,d,int(graph[b].size())});
	graph[b].push_back({a,0,-d,int(graph[a].size()-1)});
}

int min_cost_flow(G &graph,int s,int t,int f){
	using W=ll;
	W res=0;
	while(f){
		int n=graph.size(),update;
		vector<W> dist(n,inf),pv(n,0),pe(n,0);
		dist[s]=0;

		rep(loop,n){
			update=false;
			rep(v,n)rep(i,graph[v].size()){
				edge &e=graph[v][i];
				if(e.cap>0 && chmin(dist[e.to],dist[v]+e.cost)){
					pv[e.to]=v,pe[e.to]=i;
					update=true;
				}
			}
			if(!update) break;
		}

		if(dist[t]==inf) return -1;

		int d=f;
		for(int v=t;v!=s;v=pv[v]) chmin(d,graph[pv[v]][pe[v]].cap);
		f-=d,res+=d*dist[t];

		for(int v=t;v!=s;v=pv[v]){
			edge &e=graph[pv[v]][pe[v]];
			e.cap-=d;
			graph[v][e.rev].cap+=d;
		}
	}
	return res;
}

int a[110],b[110][110],l[110];


int main(void){
	int n,m,k;
	cin >> n >> m >> k;
	rep(i,n) cin >> a[i];
	rep(i,m)rep(j,n) cin >> b[i][j];
	rep(i,m) cin >> l[i];

	const int my=n+m,hub=my+1,s=hub+1,t=s+1,all=t+1;
	G graph(all);

	rep(i,n) add_edge(graph,s,i,1,0);

	rep(i,n){
		rep(j,m) add_edge(graph,i,j+n,1,-b[j][i]);
		add_edge(graph,i,my,1,-a[i]);
	}

	rep(j,m) add_edge(graph,j+n,hub,l[j],0);

	add_edge(graph,hub,t,n-k,0);
	add_edge(graph,my,t,inf,0);

	cout << -min_cost_flow(graph,s,t,n) << endl;

	return 0;
}

Measured memory_bytes: 3308
class UnionFind:
  def __init__(self, n):
    self.parents = list(range(n))
    self.ranks = [0] * n

  def root(self, x):
    if self.parents[x] == x:
      return x
    else:
      y = self.root(self.parents[x])
      self.parents[x] = y
      return y

  def same(self, x, y):
    return self.root(x) == self.root(y)

  def unite(self, x, y):
    x = self.root(x)
    y = self.root(y)
    if x == y:
      return
    if self.ranks[x] < self.ranks[y]:
      self.parents[x] = y
    else:
      self.parents[y] = x
      if self.ranks[x] == self.ranks[y]:
        self.ranks[x] += 1

n = int(input())
X = [None] * n
Y = [None] * n
for i in range(n):
  x, y = map(int, input().split())
  X[i] = (x, i)
  Y[i] = (y, i)
X.sort(key=lambda x: x[0])
Y.sort(key=lambda y: y[0])
Z = [None] * (2 * n - 2)
for i in range(n - 1):
  Z[2 * i] = (X[i + 1][0] - X[i][0], X[i][1], X[i + 1][1])
  Z[2 * i + 1] = (Y[i + 1][0] - Y[i][0], Y[i][1], Y[i + 1][1])
Z.sort(key=lambda z: z[0])

u = UnionFind(n)
total = 0
count = 0
for z in Z:
  d, a, b = z
  if not u.same(a, b):
    u.unite(a, b)
    total += d
    count += 1
    if count == n - 1:
      break
print(total)

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

#define int long long int

signed main()
{
    int n,i,s=0,mod=1000000007;
    cin>>n;
    int a[n],res=0;
    for(i=0;i<n;i++) cin>>a[i];
    for(i=n-1;i>=0;i--)
    {
        res+=a[i]*s;
        s+=a[i];
        res%=mod;
        s%=mod;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 5212
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
 
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
mod = 10**9 + 7

#dp[i] : 集合iから始めたときの場合の数
dp = [-1] * (1 << n)
dp[(1 << n) - 1] = 1

def dfs(s, cnt):
    if dp[s] != -1:
        return dp[s]
    res = 0
    for i in range(n):
        if (s >> i) & 1 == 0 and a[cnt][i] == 1:
            res += dfs(s + (1 << i), cnt+1)
    dp[s] = res % mod
    return dp[s]
 
print(dfs(0, 0))

Measured memory_bytes: 64092
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = 1e9 + 7; constexpr ll LINF = 1ll << 60; constexpr double EPS = 1e-6;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int main() {
    ll N, M;
    cin >> N >> M;

    if (N == 1 && M == 1) {
        write(1);
    }
    else if (N == 1 || M == 1) {
        write(N * M - 2);
    }
    else {
        write((N - 2) * (M - 2));
    }
}

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

using namespace std;
typedef long long ll;

int main(){
    int a,b;
    cin >> a >> b;

    if(a-2*b >=0){
        cout << a-2*b << endl;
    }else{
        cout << 0 << endl;
    }

}

Measured memory_bytes: 256
ABCD = input()

def dfs(i, f, sum):
    if i==3:
        if sum==7:
            print(f + '=7')
            exit()
    else:
        dfs(i+1, f + "-" + ABCD[i+1], sum - int(ABCD[i+1]))
        dfs(i+1, f + "+" + ABCD[i+1], sum + int(ABCD[i+1]))

dfs(0, ABCD[0], int(ABCD[0]))

Measured memory_bytes: 9200
package main

import "fmt"

func main() {
	var n, a, b int
	var s string
	_, _ = fmt.Scan(&n, &a, &b, &s)
	var sum,b_rank = 0,0
	for i := 0; i < n; i++ {
		if s[i] == 'a' && sum < a + b {
			sum++
			fmt.Println("Yes")
		}else if s[i] == 'b' && sum < a + b && b_rank < b{
			sum++
			b_rank++
			fmt.Println("Yes")
		}else{
			fmt.Println("No")
		}
	}
}


Measured memory_bytes: 2568
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var a, b string
	con.Scan(&a, &b)
	for len(a) < len(b) {
		a = "0" + a
	}
	for len(b) < len(a) {
		b = "0" + b
	}
	if a == b {
		con.Println("EQUAL")
	}
	if a < b {
		con.Println("LESS")
	}
	if a > b {
		con.Println("GREATER")
	}
	return nil
}


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

int main(void){
    long long A,B;cin>>A>>B;
    if(A==0||B==0){
        cout<<"Zero"<<endl;
        return 0;
    }
    if(A<=0&&0<=B){
        cout<<"Zero"<<endl;
        return 0;
    }
    if(A>0&&B>0){
        cout<<"Positive"<<endl;
        return 0;
    }
    if((B-A)%2==1){
        cout<<"Positive"<<endl;
        return 0;
    }
    if((B-A)%2==0){
        cout<<"Negative"<<endl;
        return 0;
    }
}

Measured memory_bytes: 3568
# import sys
# readline = sys.stdin.readline
# generator = (readline().strip() for _ in range(N))

# N, M = map(int, input().split())
# As = list(map(int, input().split()))
# queries = (input() for _ in range(N))


def solve():
    n = input()
    t = 0
    for s in n:
        t += int(s)

    return ['Yes', 'No'][t % 9 != 0]


def main():
    print(solve())


if __name__ == "__main__":
    main()


Measured memory_bytes: 9324
// 2015/07/14 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	while(true){
		int N;
		cin >> N;

		if(N==0)
			break;

		int n[10] = {0};		// 参加者の札数
		int m = 0;			// 場にある札数

		for(int i=0; i<100; i++){
			char c;
			cin >> c;

			n[i%N]++;

			if(c=='S'){		// 坊主ならば
				m += n[i%N];
				n[i%N] = 0;
			}
			else if(c=='L'){	// 姫ならば
				n[i%N] += m;
				m = 0;
			}
		}

		sort(n, n+N);			// ソート

		for(int i=0; i<N; i++){
			cout << n[i] << ' ';
		}
		cout << m << endl;
	}

	return 0;
}

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

void solve()
{
    int N;
    string S;
    cin >> S;
    N = S.size();
    S += "DDDD";

    long long ans = 0;
    auto A_cnt = 0;
    for(auto i = 0; i < N; ++i)
    {
        if(S[i] == 'A') {
            A_cnt++;
        }
        else if(S[i] == 'B' && S[i+1] == 'C') {
            ans += A_cnt;
            i++;
        }
        else {
            A_cnt = 0;
        }
    }

    cout << ans << endl;
}

int main()
{
    cin.sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
}

Measured memory_bytes: 720
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);

char a[200005], b[200005];

int main() {
#ifdef LOCAL
  auto start_clock = clock();
  freopen("in", "r", stdin);
#endif
  scanf("%s%s", a, b);
  int n = strlen(a);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] != b[i]) {
      ans += 1;
    }
  }
  printf("%d\n", ans);


#ifdef LOCAL
 auto end_clock = clock();
 cout << "Time:" << (end_clock - start_clock) / CLOCKS_PER_SEC << endl;
#endif
  return 0;
}

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

int main() {
	static long long M, D, C, CSUM = 0, COUNT = 0, ANS = 0;
	cin >> M;
	for (int i = 0; i < M; i++) {
		cin >> D >> C;
		CSUM += C;
		COUNT += D * C;
		ANS += COUNT / 9;
		COUNT %= 9;
	}
	if (COUNT == 0) ANS--;
	cout << ANS + CSUM - 1 << endl;
}

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

int main(){
    int get_time1,get_time2;
    int sleep_time1,sleep_time2;
    int study_time;
    cin>>get_time1>>get_time2>>sleep_time1>>sleep_time2>>study_time;

    int get_sum,sleep_sum;
    get_sum = get_time1*60 + get_time2;
    sleep_sum = sleep_time1*60 + sleep_time2;
    sleep_sum -= study_time;

    int time = sleep_sum - get_sum;

    cout<<time<<endl;

    return 0;
}

Measured memory_bytes: 3160
from sys import stdin

class Node(object):
    def __init__(self, parent=None, left=None, right=None):
        self.parent = parent
        self.left = left
        self.right = right

class BinarySearchTree(object):
    def __init__(self):
        self.tree = {}
        self.root = None

    def insert(self, z):
        if not self.tree:
            self.tree[z] = Node(parent=-1)
            self.root = z
        else:
            x = self.root
            while x != None:
                y = x
                if z < x:
                    x = self.tree[x].left
                else:
                    x = self.tree[x].right

            self.tree[z] = Node(parent=y)
            if z < y:
                self.tree[y].left = z
            else:
                self.tree[y].right = z

    def print_nodes(self):
        A = [] # Preorder
        B = [] # Inorder
        def walk_tree(u):
            if u == None:
                return
            r = self.tree[u].right
            l = self.tree[u].left
            A.append(u)
            walk_tree(l)
            B.append(u)
            walk_tree(r)

        walk_tree(self.root)
        print(" ", end="")
        print(*B, sep=" ")
        print(" ", end="")
        print(*A, sep=" ")

    def find(self, k):
        x = self.root
        while x != None and k != x:
            if k < x:
                x = self.tree[x].left
            else:
                x = self.tree[x].right
        return x

    def find_print(self, k):
        if self.find(k) != None:
            print("yes")
        else:
            print("no")

def read_and_print_BSTree(bst, n):
    for _ in range(n):
        cmd = stdin.readline().strip().split()
        if cmd[0] == 'insert':
            bst.insert(int(cmd[1]))
        elif cmd[0] == 'print':
            bst.print_nodes()
        elif cmd[0] == 'find':
            bst.find_print(int(cmd[1]))

n = int(input())
bst = BinarySearchTree()
read_and_print_BSTree(bst, n)


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

int main() {
  int N, M;

  cin >> N >> M;

  cout << (N*(N-1) / 2) + (M*(M-1) / 2) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
/*
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
#include<cstdlib>
#include<typeinfo>
#include<stack>
#include<cassert>
#include<functional>
*/
#define int long long int
#define double long double
using namespace std;
#define INT_DMAX 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i,n) for(int (i)=0, i##_len = (n);(i)<i##_len;(i)++)
#define reps(i,x) for(int (i)=1;(i)<=(int)(x);(i)++)
#define rrep(i,x) for(int (i)=((int)(x)-1);(i)>=0;(i)--)
#define rreps(i,x) for(int (i)=((int)(x));(i)>0;(i)--)
#define FOR(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1)<<(n))
#define all(x) (x).begin(),(x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl 
#define nint int
using namespace std;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
typedef pair<int,int> p;
typedef pair<double,double> dop;
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 gcd(int a,int b){return b?gcd(b,a%b):a;}
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;


signed main()
{
int n;
std:cin >> n;
std::vector<std::string> slist;
for(int i = 0; i < n; i++){
    std::string temp;
    std::cin >> temp;
    slist.pb(temp);
}

std::vector<int> wlist(26,0);
for(int i = 0; i < slist[0].length(); i++){
    wlist[(int)slist[0][i] - (int)'a']++;
}
for(int i = 1; i < n; i++){
    std::vector<int> twlist(26,0);
    for(int j = 0; j < slist[i].length(); j++){
        twlist[(int)slist[i][j] - (int)'a']++;
    }
    for(int j = 0; j < 26; j++){
        wlist[j] = std::min(wlist[j],twlist[j]);
    } 
}
for(int i = 0; i < 26; i++){
    for(int j = 0; j < wlist[i]; j++){
        std::cout << (char)('a' + i);
    }
}
std::cout << std::endl;
return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	if n >= m {
		fmt.Println(0)
		return
	}

	xs := make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&xs[i])
	}
	sort.Ints(xs)

	distances := make([]int, len(xs)-1)
	for i, x := range xs[:len(xs)-1] {
		distances[i] = xs[i+1] - x
	}
	sort.Ints(distances)

	length := len(distances) - int(n) + 1
	var sum int
	for _, d := range distances[:length] {
		sum = sum + d
	}
	fmt.Println(sum)
}


Measured memory_bytes: 5504
<?php
//$N = (int)trim(fgets(STDIN));
//$S = trim(fgets(STDIN));
list($H,$W,$K) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$c = array_map('intval',explode(" ",trim(fgets(STDIN))));

$tot = 0;
$res=0;
$yoko=array();
$tate=array();
for($i=0;$i<$H;$i++) {
  $c[] = trim(fgets(STDIN));
}
for($i=0;$i<1<<$H;$i++) {
  for($j=0;$j<1<<$W;$j++) {
    $w = kurocnt($i,$j);
    if ($w==$K) {
      $res++;
    }
  }
}
printf("%d\n",$res);

function kurocnt($i,$j) {
  global $c,$H,$W,$K;
  //$i = 選ばれた行の位置（ビット）
  //$j = 選ばれた列の位置（ビット）
  $t = 0;
  $s = 0;
  $skiph=array();
  $wkipw=array();
  for($h=0;$h<$H;$h++) {
    if ($i & (1 << $h)) {
      $skiph[]=$h;
      continue;
    }
    for($w=0;$w<$W;$w++) {
      if ($j & (1 << $w)) {
        $skipw[]=$w;
        continue;;
      }
      if ($c[$h][$w]=='#') {
        $t++;
      }
    }
  }
  return $t;
}


Measured memory_bytes: 16244
/*
    CP Submission
*/

#include<bits/stdc++.h>

using namespace std;

/* Shortcuts */
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(), x.end()
#define VAL(x) cout << #x << ": " << (x) << endl;
#define LOG(x) cout << (x) << endl;
#define SZ(x) (int)(x.size())
#define REP(i, a, b) for(int i = a; i < b; i++)
#define LOGR(x) for(auto a : (x)) cout << a << '\n';

/* typedefs */
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <char> vc;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <string,string> mss;

int n;
vector<double> probs;

const int MAXN = 3e3+5;

// dp[i][j] = probability of getting j heads with the first i coins
double dp[MAXN][MAXN];

double getProb(int idx, int n_coin){
    if(idx < 0) return n_coin == 0;
    if(n_coin < 0) return 0;
    if(n_coin > idx + 1) return 0;
    if(dp[idx][n_coin] != -1) return dp[idx][n_coin];
    return dp[idx][n_coin] = probs[idx] * getProb(idx-1,n_coin-1)
        + (1 - probs[idx]) * getProb(idx-1,n_coin);
}

int main(){

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

    cin>>n;

    probs = vector<double>(n);

    REP(i,0,n){
        cin>>probs[i];
    }

    REP(i,0,MAXN) REP(j,0,MAXN) dp[i][j] = -1;

    double ans = 0;

    for(int i = n/2+1; i<=n; i++){
        ans+=getProb(n-1,i);
    }

    cout<<fixed<<setprecision(15);

    LOG(ans);





    return 0;
}


Measured memory_bytes: 71040
#include<cstdio>
#include<algorithm>
#include<map>

#define se second

using namespace std;

int n,i,x,ans;

map<int,int>mp;

int main()
{
      scanf("%d",&n);
      for (i=1;i<=n;++i) scanf("%d",&x),mp[x]++;
      for (map<int,int>::iterator it=mp.begin();it!=mp.end();++it)
         ans+=it->se-1;
     printf("%d\n",n-ans-(ans%2));
}

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

int main()
{
    long long int n,m,ans;cin>>n>>m;
    
    if(n==1 || m==1)ans = abs(n*m-2);
    else if(n==2 || m==2)ans=0;
    else ans = (n-2)*(m-2);

    cout<<ans<<endl;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=m.inverse(); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }

	mint inverse()const{
		int a=x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint pow(mint m,long long k){
	mint res=1;
	for(;k>0;k>>=1,m*=m) if(k&1) res*=m;
	return res;
}

int main(){
	vector<mint> fact(2e6+1);
	fact[0]=1;
	rep(i,2e6) fact[i+1]=fact[i]*(i+1);

	int x,y; cin>>x>>y;

	if((x+y)%3!=0) return cout<<"0\n",0;

	int n=(x+y)/3;
	x-=n;
	y-=n;
	if(x<0 || y<0) return cout<<"0\n",0;

	cout<<fact[x+y]/(fact[x]*fact[y])<<'\n';

	return 0;
}


Measured memory_bytes: 8064
n = gets.chomp.to_i
a = []
n.times do
  a << gets.chomp.to_i
end
# p a
m = a[0]
p = 0
a.each_with_index do |item, index|
  if m < item then
    m = item
    p = index
  end
end
a[p] = 0
m_1 = a[0]
a.each do |item|
  if m_1 < item then
    m_1 = item
  end
end
1.upto(n) do |x|
  if x == p + 1 then
    puts m_1
  else
    puts m
  end
end

Measured memory_bytes: 4732
#define  _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#pragma comment (linker, "/STACK:526000000")

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll
void solve() {
	while (true) {
		int n;
		cin >> n;
		vector<int> ans;
		REP(i, n) {
			int a;
			cin >> a;
			ans.push_back(a);
		}
		int now = -1;
		REP(i, n) {
			for (int q = i + 1; q < n; ++q) {
				string geko = to_string(ans[i] * ans[q]);
				int ok = 1;
				for (int i = 1; i < geko.size(); ++i) {
					if (geko[i - 1] != geko[i] - 1) {
						ok = 0;
					}
				}
				if (ok == 1) {
					now = max(now, ans[i] * ans[q]);
				}
			}
		}
		cout << now << endl;
		return;
	}
}
#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3300