akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int x, y, z;
	cin >> x >> y >> z;
	cout << z << " " << x << " " << y << endl;
	return 0;
}

Measured memory_bytes: 256
import fractions
N, X = map(int, input().split())
x = list(map(int, input().split()))

x.append(X)
x.sort()

diff = [x[i+1] - x[i] for i in range(N)]
ans = diff[0]
for i in range(1, N):
    ans = fractions.gcd(ans, diff[i])

print(ans)


Measured memory_bytes: 88596
package main

import "fmt"

func main() {
	var D int
	fmt.Scan(&D)
	cs := make([]int, 26)
	for i := 0; i < 26; i++ {
		fmt.Scan(&cs[i])
	}

	ss := make([][26]int, D)
	for i := 0; i < D; i++ {
		for j := 0; j < 26; j++ {
			fmt.Scan(&ss[i][j])
		}
	}

	ts := make([]int, D)
	for d := 0; d < D; d++ {
		sat := int(-1e9)
		t := 0
		for i := 0; i < 26; i++ {
			ts[d] = i + 1
			s := solve(d+1, ts, cs, ss)
			if sat <= s {
				sat = s
				t = ts[d]
			}
		}
		ts[d] = t
	}

	for i := 0; i < len(ts); i++ {
		fmt.Println(ts[i])
	}
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func solve(D int, ts []int, cs []int, ss [][26]int) int {
	last := [26]int{}
	sat := 0
	for d := 0; d < D; d++ {
		j := ts[d] - 1
		last[j] = d + 1
		for i := 0; i < 26; i++ {
			sat -= (d + 1 - last[i]) * cs[i]
		}
		sat += ss[d][j]
	}

	return sat
}


Measured memory_bytes: 2524
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}

int  main(){
  deque<int> x;
  int q;
  cin>>q;
  lp(i,q){
    int n,y,z;
    cin>>n;
    if(n==0){
      cin>>y>>z;
      if(y==0){
	x.push_front(z);
      }
      if(y==1){
	x.push_back(z);
      }
    }
    if(n==1){
      cin>>z;
      cout<<x[z]<<endl;
    }
    if(n==2){
      cin>>z;
      if(z==0){
	x.pop_front();
      }
      if(z==1){
	x.pop_back();
      }
    }
  }
  return 0;
}



Measured memory_bytes: 4508
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,ans=0;
  cin>>n>>m;
  ans=m;
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    m+=a-b;
    if(m<0){
      cout<<0<<endl;
      return 0;
    }
    ans=max(m,ans);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

long gcd(long a,long b)
{

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

int main()
{
    long A,B;
    std::cin >> A >> B;
    if(A<B){
        long temp;
        temp=A;
        A=B;
        B=temp;
    }
    long gcdAB=gcd(A,B);
    long result =A/gcdAB;
    result=result*B;
    std::cout << result << std::endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<string>
#include<numeric>
using namespace std;
typedef long long ll;
//ll mod = 1e9+7;
ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    stack<char> st;
    int ans = 0;
    rep(i, n) {
        if ( st.empty() ) {
            st.push(s[i]);
        }
        else if ( st.top() == '.' ) {
            st.push(s[i]);
        }
        else if ( st.top() == '#' ) {
            if ( s[i] == '.' ) {
                ++ans;
                st.pop();
            }
            else {
                st.push(s[i]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  int ans = 0;
  if (A == B) ans = C;
  if (A == C) ans = B;
  if (B == C) ans = A;

  cout << ans << endl;

  return 0;
}


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

using namespace std;

const int MAX_EL = 1000;

void printArray(int *A, int N) {
    for (int i = 0; i < N; i++) {
        if (i == N -1) 
            cout << A[i];
        else
            cout << A[i] << " ";
    }
    cout << endl;
}
void insertSort(int *A, int N) {
    for (int i = 1; i <= N -1; i++) {
        int v = A[i];
        int j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        printArray(A, N);
    }
}


// cl /EHsc ALDS1_1_A.cpp
// .\ALDS1_1_A.exe < ALDS1_1_A_in1.txt
//
int main(int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;

    // read elements
    int A[MAX_EL] = { 0 };
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    printArray(A, N);
    insertSort(A, N);

    return 0;
}


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

int main()
{
    int n = 0;
    double input = 0.9, sum = 0.0;

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> input;
        sum += 1 / input;
    }

    cout << 1 / sum << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;

//問題 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_A&lang=jp
namespace templete
{
    class CoinChanging
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = input[0]; //値段
            int m = input[1]; //コインの種類
            int[] c = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int[,] dp = new int[m+1, n+1];

            //コインの数の0種類のときはmaxvalue
            for(int i=0; i<=n; i++){
                dp[0,i] = int.MaxValue;
            }

            //0円のときは0
            for(int i=0; i<=m; i++){
                dp[i,0] = 0;
            }

            for(int i=1; i<=m; i++){
                for(int j=0; j<=n; j++){
                    if(j-c[i-1]<0){
                        dp[i,j] = dp[i-1,j];
                    }else{
                        dp[i,j] = Math.Min(dp[i-1,j], dp[i,j-c[i-1]]+1);
                    }
                }
            }

            Console.WriteLine(dp[c.Length, n]);

            //string[] str = Console.ReadLine().Split(' ');
            //string str = Console.ReadLine();

            //Write("改行なし a = {0} b = {1} c = {2}", a, b, c);
            //WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);
            //WriteLine($"答えは{input[0]+input[1]}");
        }

        /// 値のスワップ
        static void Swap<T>(ref T lhs, ref T rhs)
        {
            T temp;
            temp = lhs;
            lhs = rhs;
            rhs = temp;
        }


    }
}


Measured memory_bytes: 13672
#include <cstdio>
#include <set>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>

using namespace std;

#define ll long long
#define ld long double
#define M_PI 3.14159265358979323846264338327950288
const ll N = 1000000000;


void solve() {
    int n, m;
    cin >> n >> m;
    vector<vector<int> > gr(n);
    for (int i = 0; i < m; ++i) {
        int a, b; cin >> a >> b; --a; --b;
        gr[a].emplace_back(b);
        gr[b].emplace_back(a);
    }
    vector<int> ans(n, -1);
    queue<int> q;
    q.push(0);
    ans[0] = 0;
    while(!q.empty()) {
        int old = q.size();
        while (old--) {
            int v = q.front();
            q.pop();
            for (int c : gr[v]) {
                if (ans[c] != -1) continue;
                q.push(c);
                ans[c] = v;
            }
        }
    }
    for (int i = 1; i < ans.size(); ++i) {
        if (ans[i] == -1) {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
    for (int i = 1; i < ans.size(); ++i) {
        cout << ans[i] + 1 << endl;
    }
}

int main(){
    int t;
    t = 1;
    while(t--) {
        solve();
    }
    return 0;
}

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

int w(long long x)
{
	int ans;
	ans=0;
	while (x!=0)
	{
		ans+=x%10;
		x/=10;
	}
	return ans;
}

int main()
{
	int n;
	cin>>n;
	int i,x[n+1],ans=0;
	cin>>x[1];
	for (i=2;i<=n;i++)
	{
		cin>>x[i];
		if (x[i]==x[i-1])
		{
			ans++;
			x[i]=-1;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#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,B;
  char op;
  cin >> A >> op >> B;
  if (op == '+')
  {
    cout << A + B << endl;
  }
  else 
  {
    cout << A - B << endl;
  }  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
long N;
vector<long>A;
int dfs(long n,int i)
{
	if(i==A.size())
	{
		return n==1?0:-1;
	}
	int ans=dfs(n,i+1);
	int t=0;
	while(n%A[i]==0)
	{
		t++;n/=A[i];
		int now=dfs(n,i+1);
		if(now>=0)ans=max(ans,now+t);
	}
	return ans;
}
main()
{
    cin>>N;
	if(N==1)
	{
		cout<<-1<<endl;
		return 0;
	}
    for(int i=1;i<=18;i++)
    {
        for(int j=0;j<1<<i;j++)
        {
            long now=0;
            for(int k=0;k<i;k++)now=now*10+(j>>k&1?8:2);
			if(N%now==0)A.push_back(now);
		}
	}
	cout<<dfs(N,0)<<endl;
}



Measured memory_bytes: 3156
import java.util.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int h = s.nextInt();
    int w = s.nextInt();
    boolean[][] visited = new boolean[h+1][w+1];
    for (int i = 0; i < h; i++) {
      String line = s.next();
      for (int j = 0; j < w; j++) {
        visited[i][j] = line.charAt(j) == '#';
      }
    }
    
    int pi = 0;
    int pj = 0;
    while (pi != h-1 || pj != w-1) {
      visited[pi][pj] = false;
      if (visited[pi][pj+1]) {
        pj++;
      } else if (visited[pi+1][pj]) {
        pi++;
      } else {
        throw new RuntimeException("No destination");
      }
      for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
          if (i < pi || j < pj) {
            if (visited[i][j]) {
              System.out.println("Impossible");
              return;
            }
          }
        }
      }
    }
    System.out.println("Possible");
  }
}


Measured memory_bytes: 10320
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

const int N=1e5+5;
int n,siz[N];
pair <int,int> Edge[N];
struct Node {
	ll dis;int id;
	bool operator < (const Node&b) const {return dis<b.dis;}
} A[N];

template <typename _Tp> inline void IN(_Tp&x) {
	char ch;bool flag=0;x=0;
	while(ch=getchar(),!isdigit(ch)) if(ch=='-') flag=1;
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	if(flag) x=-x;
}

int main() {
	IN(n);
	for(int i=1;i<=n;++i) IN(A[i].dis),A[i].id=i;
	for(int i=1;i<=n;++i) siz[i]=1;
	sort(A+1,A+1+n);
	ll res=0;int cnt=0;
	for(int i=n;i>=2;--i) {
		ll dis=A[i].dis+(siz[i]<<1)-n;
		int pos=lower_bound(A+1,A+1+n,(Node){dis,0})-A;
		if(dis!=A[pos].dis) return puts("-1"),0;
		siz[pos]+=siz[i],Edge[++cnt]=make_pair(A[i].id,A[pos].id),res+=siz[i];
	}
	if(res!=A[1].dis) return puts("-1"),0;
	for(int i=1;i<=cnt;++i) printf("%d %d\n",Edge[i].first,Edge[i].second);
	return 0;
}

Measured memory_bytes: 4096
#include<stdio.h>

int main(void)
{
	double a,b,c,d,e,f,x,y;
	
	while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){
		y=(c*d-f*a)/(b*d-e*a);
		x=(c-(b*y))/a;
		printf("%.3f %.3f\n",x,y);
	}
	return 0;
}

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

const int MAXN = 40001;
const int INF = 1<<28;
int N;
int X[MAXN], Y[MAXN];
bool vis[MAXN];
vector<pair<pair<int,int>,int> > xy, yx;

int dfs(int v) {
  const int &x = X[v];
  const int &y = Y[v];
  vis[v] = true;
  int res = 1;

  int begin, end;

  begin =
    lower_bound(xy.begin(), xy.end(), make_pair(make_pair(x,-INF),-INF))
    - xy.begin();
  end =
    upper_bound(xy.begin(), xy.end(), make_pair(make_pair(x, INF), INF))
    - xy.begin();
  for(int i = begin; i < end; ++i) {
    int nv = xy[i].second;
    if(!vis[nv]) {
      res += dfs(nv);
    }
  }

  begin =
    lower_bound(yx.begin(), yx.end(), make_pair(make_pair(y,-INF),-INF))
    - yx.begin();
  end =
    upper_bound(yx.begin(), yx.end(), make_pair(make_pair(y, INF), INF))
    - yx.begin();
  for(int i = begin; i < end; ++i) {
    int nv = yx[i].second;
    if(!vis[nv]) {
      res += dfs(nv);
    }
  }

  return res;
}

int main() {
  int h, w;
  cin >> N >> w >> h;
  bool kabegiwa = false;
  for(int i = 0; i < N; ++i) {
    int &x = X[i];
    int &y = Y[i];
    cin >> x >> y;
    xy.push_back(make_pair(make_pair(x,y),i));
    yx.push_back(make_pair(make_pair(y,x),i));
    if(x == 1 || x == w || y == 1 || y == h) {
      kabegiwa = true;
    }
  }
  sort(xy.begin(), xy.end());
  sort(yx.begin(), yx.end());
  fill(vis, vis+N, false);
  int num = 0;
  int ans = 0;
  for(int i = 0; i < N; ++i) {
    if(!vis[i]) {
      ++num;
      ans += dfs(i) - 1;
    }
  }
  if(num != 1 && !kabegiwa) {
    ans += 1;
  }
  ans += (num-1) * 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2844
#include<stdio.h>

int S[11],top;

int isempty(int x)
{
  return (top==0);
}

void push(int x)
{
  S[++top]=x;
}

int pop(void)
{
  int x;
  x=S[top--];
  printf("%d\n",x);
  return x;
}

int main(void)
{
  int x;

  while(scanf("%d",&x)!=EOF)
    {
      if(x==0)pop();
      else push(x);
    }
  return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

const int MAXN = 2005;
const int MOD = 924844033;

int N, K;
int fin[MAXN], curr[MAXN];
int sum[MAXN];
int dp[2][MAXN][3];

void load() {
  scanf("%d%d", &N, &K);
}

inline int add(int x, int y) {
  x += y;
  if (x >= MOD) 
    x -= MOD;
  else if (x < 0)
    x += MOD;
  return x;
}

inline int mul(int x, int y) {
  return (long long)x * y % MOD;
}

void calc_dp(int x) {
  memset(dp, 0, sizeof dp);
  memset(sum, 0, sizeof sum);
  vector <int> vals;
  for (int i = x; i <= N; i += 2 * K)
    vals.push_back(i);
  int sz = vals.size();
  
  int c = 0;
  dp[c][0][2] = 1;  
  for (int i = 0; i < sz; i++) {
    c ^= 1;
    memset(dp[c], 0, sizeof dp[c]);
    for (int j = 0; j <= N; j++) {
      if (vals[i] > K)
        dp[c][j][0] = add(dp[c ^ 1][j][0], dp[c ^ 1][j][2]);
      if (vals[i] <= N - K)
        dp[c][j][1] = add(add(dp[c ^ 1][j][0], dp[c ^ 1][j][1]), dp[c ^ 1][j][2]);
      if (j)
        dp[c][j][2] = add(add(dp[c ^ 1][j - 1][0], dp[c ^ 1][j - 1][1]), dp[c ^ 1][j - 1][2]);
    }
  }
  
  for (int i = 0; i <= sz; i++) 
    for (int j = 0; j < 3; j++)
      sum[i] = add(sum[i], dp[c][i][j]);
  
  memset(curr, 0, sizeof curr);
  for (int i = 0; i <= sz; i++)
    for (int j = 0; j <= N - i; j++)
      curr[i + j] = add(curr[i + j], mul(sum[i], fin[j]));
  memcpy(fin, curr, sizeof fin);
}

int solve() {
  fin[0] = 1;
  for (int i = 1; i <= min(2 * K, N); i++)
    calc_dp(i);
      
  int sol = 0, fact = 1;
  for (int i = 0; i <= N; i++) {
    if (i)
      fact = mul(fact, i);
    int tmp = mul(fact, fin[i]);
    sol = add(sol, (N - i) % 2 ? -tmp : tmp);
  }
  
  return sol;
}

int main() {
  load();
  printf("%d\n", solve());
  return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <stack>
#include <string>
#include <ctime>
#include <stdio.h>
#include <string.h>

using namespace std;

#define re return
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int) (x).size())
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repm(i, n) for (int i = 1; i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define vi vector<int>
#define vl vector<long>
#define vll vector<ll>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector< pair<int,int> >
#define ll long long
#define ld long double 
#define str string
// freopen("firesafe.in", "r", stdin);
// freopen("firesafe.out", "w", stdout);
int scp[1010]={0};

queue<char> q;

//map<ll,ll>mmap;
int main(){
   int n;
   cin>>n;
   str s;
   cin>>s;
   rep(i,n){
    if(s[i]=='('&&scp[i]==0)
      for(int j=i+1;j<n;j++){
        if(s[j]==')' && scp[j]==0 && scp[i]==0){
          scp[i]=1;
          scp[j]=1;
          
        }
      }
   }

   int cnt=0;

   for(int i=sz(s)-1;i>=0;i--){
    if(s[i]==')'&& scp[i]!=1){
      cnt++;
    }
   }
   int scp1[1010]={0};
    //cout<<cnt<<endl;
   str ss="";
   for(int i=0;i<cnt;i++){
      ss+='(';
      scp1[i]=1;

   }
   for(int i=0;i<n;i++){
    scp1[i+cnt]=scp[i];
   }
   ss+=s;
   int con=0;
   for(int i=0;i<sz(ss);i++){
    if(ss[i]=='('&&scp1[i]==0){
      con++;
    }
   }
   str sss=ss;
   for(int i=0;i<con;i++){
    sss+=')';
   }

   // str sss="";
   //  for(int i=0;i<sz(ss);i++){
   //    sss+=ss[i];
   //    if(ss[i]=='('&&scp1[i]==0){
   //      sss+=')';
   //    }
   //  }
    cout<<sss<<endl;
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

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


int main() {

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

    vector<int>s(m);
    vector<char>c(m);
    
    rep(i,m){
        cin>>s[i]>>c[i];
    }

    rep2(i,0,1000){
        string I=to_string(i);

        if(I.size()!=n){
            continue;
        }

        bool jdg=true;

        rep(j,m){
            if(I[s[j]-1]!=c[j]){
                jdg=false;
                break;
            }
        }

        if(jdg){
            cout<<I<<endl;
            return 0;
        }
    }

    cout<<-1<<endl;

}


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

//int cnt[26],cnt1[26];
int dp[100005];
int main(){
	int n;
	cin>>n;
	int ar[n];
	for(int i=0;i<n;i++){
		cin>>ar[i];
	}
	dp[0]=0;
	dp[1]=abs(ar[0]-ar[1]);
	for(int i=2;i<n;i++){
		dp[i]=min((dp[i-1]+abs(ar[i]-ar[i-1])),(dp[i-2]+abs(ar[i]-ar[i-2])));
	}
	cout<<dp[n-1]<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int N;
string s;

bool check(vector<char>& v){
  int isseap;
  repp(i,1,N-1){
    isseap = 1;
    if(v[i] !='S') isseap^=1;
    if(s[i] != 'o') isseap^=1;
    if(v[i-1] != 'S') isseap ^=1;
    if(isseap)v[i+1] = 'S';
    else v[i+1] = 'W';
  }
  //0を見る
  isseap = 1;
  if(v[0] !='S') isseap ^=1;
  if(s[0] != 'o') isseap^=1;
  if(v[N-1] != 'S') isseap ^=1;
  if(isseap && v[1] == 'W') return false;
  if(!isseap &&  v[1] == 'S') return false;

  //N-1を見る
  isseap = 1;
  if(v[N-1] !='S') isseap ^=1;
  if(s[N-1] != 'o') isseap^=1;
  if(v[N-2] != 'S') isseap ^=1;
  if(isseap && v[0] == 'W') return false;
  if(!isseap &&  v[0] == 'S') return false;

  return true;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  cin >> N;
  cin >> s;
  vector<char> v(N,'S');
  if(check(v)){
    rep(i,N) cout << v[i];
    cout << endl;
    return 0;
  }
  v[1] = 'W';
  if(check(v)){
    rep(i,N) cout << v[i];
    cout << endl;
    return 0;
  }
  v[0] = 'W';
  if(check(v)){
    rep(i,N) cout << v[i];
    cout << endl;
    return 0;
  }
  v[1] = 'S';
  if(check(v)){
    rep(i,N) cout << v[i];
    cout << endl;
    return 0;
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.*;
public class Main{
	public void solve(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int N = sc.nextInt();
			int K = sc.nextInt();
			int S = sc.nextInt();
			if(N + K + S == 0) break;
			
			int ans = 0;
			for(int i = 0; i < (1 << N); i++){
				if(Integer.bitCount(i) == K){
					int sum = 0;
					for(int j = 0; j < N; j++){
						if((i & (1 << j)) != 0){
							sum += (j + 1);
						}
					}
					if(sum == S) ans++;
				}
			}
			System.out.println(ans);
		}
	}
	
	public static void main(String[] args){
		new Main().solve();
	}
}

Measured memory_bytes: 27444
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let (mut a,mut b,k) = {
        let t = read_vec::<usize>();
        (t[0],t[1],t[2])
    };
    for j in 0..k{
        if j % 2 == 0 {
            a = calc(a) / 2;
            b += a;
        } else {
            b = calc(b) / 2;
            a += b;
        }
    }
    println!("{} {}" ,a,b );
}
fn calc(x:usize) -> usize {
    if x % 2 == 0{
        x 
    } else {
        x - 1 
    }
}

Measured memory_bytes: 4352
S = input()

if int(S[:2]) > 0 and int(S[:2]) < 13:
  if int(S[2:]) > 0 and int(S[2:]) < 13:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if int(S[2:]) > 0 and int(S[2:]) < 13:
    print("YYMM")
  else:
    print("NA")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define mp(x, y) make_pair(x, y)
#define pb(x) emplace_back(x)
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

typedef long long ll;
typedef vector<int> V;
typedef pair<int, int> pii;

const int N = 1e5;
int a[N];
int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    cout << n / (a + b) * a + min(a, n % (a + b));
}

Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

void main() {
    while (solve) {}
}

bool solve() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    if (N == 0) return false;

    auto uf = new UnionFind(N);

    while (M--) {
        auto q = readln.split;
        auto a = q[1].to!int - 1;
        auto b = q[2].to!int - 1;
        if (q[0] == "!") {
            auto w = q[3].to!int;
            uf.unite(a, b, w);
        } else {
            if (uf.find(a) != uf.find(b)) {
                writeln("UNKNOWN");
            } else {
                writeln(uf.weight[b] - uf.weight[a]);
            }
        }
    }

    return true;
}


class UnionFind {
    int N;
    int[] table;
    int[] weight;
    int[][] group;

    this(int n) {
        N = n;
        table = new int[](N);
        fill(table, -1);
        weight = new int[](N);
        group = N.iota.map!(i => [i]).array;
    }

    int find(int x) {
        return table[x] < 0 ? x : (table[x] = find(table[x]));
    }

    void unite(int x, int y, int diff) {
        int ox = x;
        int oy = y;
        x = find(x);
        y = find(y);
        if (x == y) return;

        if (table[x] > table[y]) {
            swap(x, y);
            swap(ox, oy);
            diff *= -1;
        }

        int nw = weight[ox] + diff;
        int ndiff = nw - weight[oy];
        foreach (i; group[y]) weight[i] += ndiff;
        foreach (i; group[y]) group[x] ~= i;
        group[y] = [];

        table[x] += table[y];
        table[y] = x;
    }
}



Measured memory_bytes: 19736
#include<cstdio>
#include<cstring>
int main(){
	int a,b,c,d,i,j;
	while(~scanf("%d%d",&a,&b))
	{
		d=a-b*2;
		if(d>=0)
		printf("%d\n",d);
		else
		printf("0\n");
	}
}

Measured memory_bytes: 128
s=input()
q = int(input())
toggle = "ok"
top = ""
last = ""

for i in range(q):
    si = input().split()
    if si[0] == "1":
        if toggle == "ok":
            toggle = "re"
        else:
            toggle = "ok"
    else:
        if si[1] == "1" and toggle == "ok":
            top += si[2] 
        elif si[1] == "2" and toggle == "re":
            top += si[2] 
        elif si[1] == "1" and toggle == "re":
            last += si[2]
        elif si[1] == "2" and toggle == "ok":
            last += si[2]
if toggle == "ok":
    retop = ''.join(list(reversed(top)))
    print(retop, end="")
    print(s,end="")
    print(last,end="")
else:
    relast = ''.join(list(reversed(last)))
    print(relast,end="")
    res = ''.join(list(reversed(s)))
    print(res,end="")
    print(top,end="")    

Measured memory_bytes: 4852
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

int a, b;

int main() {
	scanf( "%d%d", &a, &b );
	if( a <= 0 && b >= 0 ) return 0 * puts("Zero");
	if( a < 0 && b < 0 ) return 0 * puts(b - a & 1 ? "Positive" : "Negative");
	if( a > 0 && b > 0 ) return 0 * puts("Positive");
	return 0;
}

Measured memory_bytes: 128
import sys

input = sys.stdin.readline


def main():
    N, Q = map(int, input().split())
    S = input().rstrip()
    l = [0] * Q
    r = [0] * Q
    for i in range(Q):
        l[i], r[i] = map(int, input().split())

    T = [0] * (N+1)
    for i in range(2, N+1):
        if S[i-2:i] == "AC":
            T[i] = T[i-1] + 1
        else:
            T[i] = T[i-1]

    for i in range(Q):
        print(T[r[i]] - T[l[i]])


if __name__ == "__main__":
    main()


Measured memory_bytes: 14128
#include<stdio.h>
int main()
{
  int a,b;
  //int n[100005],m[100005];
  scanf("%d %d",&a,&b);
  int x,y,z;
  x=a+b;
  y=a-b;
  z=a*b;
  if(x>=y)
  {
    if(x>=z)
    {
      printf("%d",x);
      return 0;
    }
    else 
     {
      printf("%d",z);
      return 0;
    }
  }
  if(y>=z)
  {
    if(y>=x)
    {
      printf("%d",y);
      return 0;
    }
    else
      {
      printf("%d",x);
      return 0;
    }
  }
  printf("%d",z);
  return 0;
}

Measured memory_bytes: 128
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] count = new int[100003];
        int max = 0;
        
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt() + 1;
        }
        
        for (int i = 0; i < n; i++) {
            count[a[i] - 1]++;
            count[a[i]]++;
            count[a[i] + 1]++;
        }
        
        for (int i = 0; i < count.length; i++) {
            if (max < count[i]) {
                max = count[i];
            }
        }
        System.out.println(max);
    }
}


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

int main(){
    int n;
    cin >> n;
    double d[4];
    valarray<double> x(n), y(n);
    REP(i, n) cin >> x[i];
    REP(i, n) cin >> y[i];
    x = abs(x-y);
    d[3] = x.max();
    d[0] = x.sum();
    y = x * x;
    d[1] = sqrt(y.sum());
    x *= y;
    d[2] = cbrt(x.sum());
    REP(i, 4) cout << fixed << setprecision(5) << d[i] << endl;
}

Measured memory_bytes: 3484
#include<bits/stdc++.h>
using namespace std;
string a,b;
int la,lb;
char ma='{',mb='A'; 
int c(){
	for(int i=0;i<la;i++)
		for(int j=0;j<lb;j++)
			if(a[i]!=b[j])return 0;
	return 1;
}
int main()
{
	cin>>a>>b;
	la=a.length();
	lb=b.length();
	for(int i=0;i<la;i++)if(a[i]<ma)ma=a[i];
	for(int j=0;j<lb;j++)if(b[j]>mb)mb=b[j];
	if(ma<mb)cout<<"Yes";
	else if(ma<mb)cout<<"Yes";
	else if(la<lb){
		if(c()==1)cout<<"Yes";
		else cout<<"No";
	}
	else cout<<"No";
	return 0;
}

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

int main(){
	char s[5001];
	scanf("%s",s);
	int K;
	scanf("%d",&K);
	
	int l=strlen(s);
	int c=0;
	for(int i=0;i<K;i++)c+=l-i;
	
	char sub[c][K+1];
	
	int cc=0;
	for(int i=1;i<=K;i++){
		for(int j=0;j<l-i+1;j++){
			for(int k=0;k<i;k++){
				sub[cc][k]=s[j+k];
				if(k==i-1)for(k;k<K;k++)sub[cc][k+1]='\0';
			}
			cc++;
		}
	}
	
	//sort
	int r=c;
	int swapped=0;
	while(r>1 || swapped==1){
		r=r*10/13;
		swapped=0;
		for(int i=0;i+r<c;i++){
			if(strcmp(sub[i],sub[i+r])>0){
				char tmp[K+1];
				for(int j=0;j<K+1;j++)tmp[j]=sub[i][j];
				for(int j=0;j<K+1;j++)sub[i][j]=sub[i+r][j];
				for(int j=0;j<K+1;j++)sub[i+r][j]=tmp[j];
				swapped=1;
			}
		}
	}
	
	//sort
	r=c;
	swapped=0;
	while(r>1 || swapped==1){
		r=r*10/13;
		swapped=0;
		for(int i=0;i+r<c;i++){
			if(strcmp(sub[i],sub[i+r])>0){
				char tmp[K+1];
				for(int j=0;j<K+1;j++)tmp[j]=sub[i][j];
				for(int j=0;j<K+1;j++)sub[i][j]=sub[i+r][j];
				for(int j=0;j<K+1;j++)sub[i+r][j]=tmp[j];
				swapped=1;
			}
		}
	}
	
	int k=1;
	for(int i=0;i<c;i++){
		if(i>0 && strcmp(sub[i-1],sub[i])!=0)k++;
		if(k==K){
			printf("%s\n",sub[i]);
			return 0;
		}
	}
	
	//for(int i=0;i<c;i++)printf("%s\n",sub[i]);
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int combination(int n, int r)
{
    int tmp=r;
    if(r==0 || r==n){
        return 1;
    }else if(r==1){
        return n;
    }else if(r>n){
        return 0;
    }else{
        for(int i=r-1;i>=1;i--){
            r*=i;
            n*=n-(tmp-i);
        }
        return n/r;
    }
}

int main(void){
    int n,m;
    scanf("%d %d",&n,&m);
    int a=combination(n,2)+combination(m,2);
    printf("%d",a);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
  char str[4]; //'A','B','c','\0'
  scanf("%s",str);
  
  if(str[0] == 'A' && str[1] == 'B' && str[2] == 'C')
    printf("ARC\n");
  else if(str[0] == 'A' && str[1] == 'R' && str[2] == 'C')
    printf("ABC\n");
  
  return 0;
}

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

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

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

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}



int main(){
    int n;cin>>n;
    vector<string>s(n);
    rep(i,n)cin>>s[i];
    map<string,int>mp;
    char c;
    bool f = true;
    rep(i,n){
        if(mp[s[i]])f = false;
        mp[s[i]]++;
        if(i==0)continue;
        if(s[i][0] != s[i-1][s[i-1].size()-1])f = false;
        
    }
    if(f)cout<<"Yes";
    else cout<<"No";
}



Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int n,m,i,j;
    long c;
    scanf("%d %d",&n,&m);
    int a[n][m];
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    int b[m];
    for(i=0;i<m;i++){       
            scanf("%d",&b[i]);
    }
    for(i=0;i<n;i++){
            c=0;
            for(j=0;j<m;j++){
                c+=a[i][j] * b[j];
            }
            printf("%ld\n",c);
            
        
    }
    return 0;
}


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

using namespace std;

void call(int n) {
    int i = 1;
    while (++i <= n) {
        int x = i;
        if (x % 3 == 0) {
            cout << " " << i;
            continue;
        }

        do {
            if (x % 10 == 3) {
                cout << " " << i;
                break;
            }
        } while (x /= 10);
    }
    cout << endl;
}

int main() {
    int n;

    cin >> n;

    call(n);

    return 0;
}


Measured memory_bytes: 3072
#include <algorithm>

namespace rika
{
  template <typename T>
  class edge
  {
  public:
    int to;
    T cost;
    
    edge() = default;
    edge(const edge<T>&) = default;
    edge(edge<T>&&) = default;
    edge& operator =(const edge<T>&) = default;
    edge& operator =(edge<T>&&) = default;

    ~edge() = default;

    edge(int _to, T _cost) : to(_to), cost(_cost) {}
  };
}

#include<bits/stdc++.h>
using namespace std;
using namespace rika;
namespace rika
{
  namespace internal
  {
    template <typename TValue, typename TGraph>
    std::pair<TValue, int> visit(int from, int v, const TGraph &g)
    {
      auto r = std::make_pair(TValue(), v);
      try{
      for(auto it = g[v].begin(); it != g[v].end(); ++it)
      {
        if(it->to == from)
          continue;
        auto r2 = visit<TValue>(v, it->to, g);
        if(r2.first + it->cost >= r.first)
          r = std::make_pair(r2.first + it->cost, r2.second);
      }
      }catch(const std::out_of_range &e){}
      return r;
    }
  }

  template <typename TValue, typename TGraph>
  TValue tree_diameter(const TGraph &g)
  {
    using namespace internal;
    auto r1 = visit<TValue>(-1, 0, g);
    auto r2 = visit<TValue>(-1, r1.second, g);
    return r2.first;
  }
}

#include<bits/stdc++.h>
using namespace std;
using namespace rika;
int main()
{
  int N;
  cin >> N;
  vector<vector<edge<int>>> g(N * 10);
  for(int i = 0; i < N - 1; i++)
  {
    int s, t, w;
    cin >> s >> t >> w;
    g[s].push_back(edge<int>(t, w));
    g[t].push_back(edge<int>(s, w));
  }
  cout << tree_diameter<int>(g) << endl;
}

Measured memory_bytes: 35360
n,k = map(int,input().split())
A = list(map(int,input().split()))
ans = 0

import collections
c = collections.Counter(A)
c = c.most_common()

m = len(set(A))

if m > k:
    for i in range(m-k):
        ans += c[-1-i][1]
        
print(ans)

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  reverse(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    cout << a.at(i);
    if (i == n - 1) {
      cout << endl;
    }
    else {
      cout << " ";
    }
  }
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <string>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    llong n,a[200100]={},ans=0,h;
    cin >> n;
    for(int i=0;i<n;i++) cin >> a[i];
    
    h = a[0];
    for(int i=0;i<n;i++){
        if (h <= a[i]) h = a[i];
        else ans += h - a[i];
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5152
#pragma GCC target ("avx2") 
#pragma GCC optimization ("O3") 
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define fast_az_fuk ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long 
#define int ll 
#define ull unsigned ll
#define ld long double 
#define pb push_back 
#define pf push_front
#define dll deque<ll> 
#define vll vector<ll> 
#define pll pair<ll,ll> 
#define mapll map<ll,ll>
#define endl "\n" 
#define all(v) v.begin(),v.end() 
#define ms(a,x) memset(a,x,sizeof(a))
using namespace std;
void swap(auto*,auto*);
int32_t main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fast_az_fuk
    ll x; cin>>x;
    if(x==0) cout<<1; else cout<<0;
    return 0;
}
void swap(auto &a,auto &b)
{
    auto temp=a; a=b; b=temp;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100010
#define INF 10000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    OUT(min(n*a,b));
	return 0;
}

Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let c1: String = input();
    let c2: String = input();
    let c2r: String = c2.chars().rev().collect();
    println!("{}", if c2r == c1 { "YES" } else { "NO" });
}


Measured memory_bytes: 4352
import functools
import threading
import sys


class SearchProblem(object):
    def __init__(self, N, H):
        self.N = N
        self.H = H

    def isEnd(self, i):
        return i == self.N

    def succ(self, i):
        res = []
        if i + 1 <= self.N:
            res.append((i + 1, abs(self.H[i + 1] - self.H[i])))
        if i + 2 <= self.N:
            res.append((i + 2, abs(self.H[i + 2] - self.H[i])))
        return res


def solve(problem: SearchProblem):
    @functools.lru_cache(maxsize=None)
    def future_cost(s):
        if problem.isEnd(s):
            return 0
        else:
            return min(
                cost + future_cost(next_state) for next_state, cost in problem.succ(s)
            )

    return future_cost(1)


def main():
    N = int(input())
    H = [None] + [int(x) for x in input().split(" ")]
    problem = SearchProblem(N, H)
    print(solve(problem))


if __name__ == "__main__":

    sys.setrecursionlimit(1024 * 1024 * 2)
    threading.stack_size(128 * 1024 * 1024 * 2)
    threading.Thread(target=main).start()


Measured memory_bytes: 473092
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

class Vector2
{
public:
	Vector2(){}
	Vector2( double _x, double _y ) : x( _x ), y( _y ){}
	~Vector2(){}

	double length2pow() const { return x*x + y*y; }

	double x, y;
};

const double RADIUS = 1.0;

int main(){
	int n;
	char c;

	while ( cin >> n && n ){
		vector< Vector2 > list;
		int maxCount = 1;
		for( int i = 0; i < n; ++i ){
			Vector2 v;
			cin >> v.x >> c >> v.y;
			list.push_back( v );
		}
		for( int i = 0; i < n - 1; ++i ){
			for( int j = i+1; j < n; ++j ){
				Vector2 distance( list[ j ].x - list[ i ].x, list[ j ].y - list[ i ].y );
				Vector2 pc1, pc2;
				double len = sqrt( distance.length2pow() );
				if( len > RADIUS * RADIUS * 2 ){
					continue;
				}else if( len == RADIUS * RADIUS * 2 ){
					pc1.x = pc2.x = list[ i ].x + distance.x / 2;
					pc1.y = pc2.y = list[ i ].y + distance.y / 2;
				}else{
					Vector2 m( distance.x / 2, distance.y / 2 );
					double mx = list[ i ].x + m.x;
					double my = list[ i ].y + m.y;
					double ml = m.length2pow();
					double side = RADIUS * RADIUS - ml;
					double rate = sqrt( side / ml );
					Vector2 tv( -m.y * rate, m.x * rate );
					pc1.x = mx + tv.x;
					pc1.y = my + tv.y;
					pc2.x = mx - tv.x;
					pc2.y = my - tv.y;

					int cnt1 = 2, cnt2 = 2;
					for( int k = 0; k < n; ++k ){
						if( k == i || k == j ){
							continue;
						}
						Vector2 td1( list[ k ].x - pc1.x, list[ k ].y - pc1.y );
						Vector2 td2( list[ k ].x - pc2.x, list[ k ].y - pc2.y );
						if( td1.length2pow() <= RADIUS * RADIUS ){
							++cnt1;
						}
						if( td2.length2pow() <= RADIUS * RADIUS ){
							++cnt2;
						}
					}
					maxCount = max( maxCount, max( cnt1, cnt2 ) );
				}
			}
		}

		cout << maxCount << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

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

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  string S;
  cin >> S;
  cout << "2018/01/" << S[8] << S[9] << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:usize,
    }
    println!("{}",if a<1000 {"ABC"}else{"ABD"})
}

Measured memory_bytes: 2116
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	char a[3], b[3];
	cin >> a >> b;
	if ((a[0] == b[2]) && (a[1] == b[1]) && (a[2] == b[0]))
		printf("YES");
	else
		printf("NO");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline void read(T &x)
{
	x=0;
	static int p;p=1;
	static char c;c=getchar();
	while(!isdigit(c)){if(c=='-')p=-1;c=getchar();}
	while(isdigit(c)) {x=(x<<1)+(x<<3)+(c-'0');c=getchar();}
	x*=p;
}
int h,w,n;
typedef pair<int,int> pi;
map<pi,int>mp;
long long ans[10];
int main()
{
//	freopen("ARC061D.in","r",stdin);
//	freopen("ARC061D.out","w",stdout);
	read(h);read(w);
	read(n);
	for(int i=1;i<=n;i++)
	{
		static int a,b;
		read(a);read(b);
		for(int j=max(1,a-2);j<=min(a,h-2);j++)
			for(int k=max(1,b-2);k<=min(b,w-2);k++)
				mp[pi(j,k)]++;
	}
	long long sum=0;
	for(auto it:mp)ans[it.second]++;
	for(int i=1;i<=9;i++)sum+=ans[i];
	ans[0]=(long long)(h-2ll)*(w-2ll)-sum;
	for(int i=0;i<=9;i++)
		cout<<ans[i]<<endl;
	return 0;
}

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

#define MAX_N 6
#define MAX_X 100000
#define INF 10000000000

int N = 6;
// int X = 615;
int X;
// int w[] = {100, 101, 102, 103, 104, 105};

int main() {
    cin >> X;
    int target_max = MAX_X / 100;
    for (int i = 1; i <= target_max; i++) {
        if (i * 100 <= X && X <= i * 105) {
            printf("1\n");
            return 0;
        }
    }

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

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

using namespace std;
typedef long long ll;

bool choose1 (const pair <string,pair <int,int> >  &a, 
			  const pair <string,pair <int,int> >  &b)
{	
	if (a.first == b.first) {return b.second.first < a.second.first; }
	return  (a.first < b.first)	;
}



vector <pair <string, pair <int,int> > > v1;


int main()
{
	//freopen("t.txt","r",stdin);
	int n;
	cin>>n;
	for (int i=1;i<=n;i++){
		string name; int point;
		cin>> name>> point;
		v1.push_back( make_pair (name, make_pair (point,i)) );
	}
	
	
	
	sort (v1.begin(),v1.end(),choose1);
	for (int i=0;i<n;i++){
		cout<<  v1[i].second.second<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#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;
    cin >> n;
    vector <int> x(n);
    vector <int> y(n);
    rep(i,n){
        cin >> x[i] >> y[i];
    }

    int nkai;
    nkai=1;
    rep(i,n){
        nkai*=(i+1);
    }
    double wa=0;

    rep(i,n){
        for(int j=i+1;j<n;++j){
            wa+=pow(double(pow(x[i]-x[j],2)+pow(y[i]-y[j],2)),0.5);
        }
    }

n=double(n);
    
    printf("%.10f\n",wa*2.0/n);
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <math.h>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <queue>
#include <vector>

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); --(i))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define SORT(A) std::sort((A).begin(), (A).end())
#define ALL(A) (A).begin(), (A).end()
// 座標圧縮 (for vector) : ソートしてから使うのが一般的 ; SORT(A) => COORDINATE_COMPRESSION(A)
#define COORDINATE_COMPRESSION(A) (A).erase(unique((A).begin(),(A).end()),(A).end())

using lli = long long int;
using pii = std::pair<int, int>;

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

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


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


std::vector<int> A, B;
std::vector<lli> S;

int main(void){
    int n; lli m; scanf("%d%lld", &n, &m);
    A.resize(n); B.resize(n);
    REP(i, n) scanf("%d", &A[i]), B[i] = A[i];
    
    std::sort(A.begin(), A.end());
    std::sort(B.begin(), B.end(), std::greater<int>());
    S.resize(n + 1);
    S[0] = 0; REP(i, n) S[i+1] = S[i] + B[i];

    int ok = 0, ng = 2 * B[0] + 1;
    lli sum = 0;
    while(ng - ok > 1){
        int mid = (ok + ng) / 2;
        lli cnt = 0;
        int right = 0;
        lli s = 0;
        REP(left, n){
            while(right < n and A[left] + B[right] >= mid) right++;
            s += S[right] + lli(A[left]) * right;
            cnt += right;
        }
        if(cnt >= m) ok = mid, sum = s - lli(mid) * (cnt - m);
        else ng = mid;
    }
    printf("%lld\n", sum);
    
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int n;
	cin>>n;
	int ans=0;
	if(n%2==0){
		ans=n/2-1;
		cout<<ans<<endl;
		return 0;
	}else{
		ans=(n+1)/2-1;
		cout<<ans<<endl;
		return 0;
	}
	return 0;
}


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

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

const int INF=1000000001;
vector<int> v[200010];

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


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

vector<ll> arr;
ll n, k;

int isOk(ll x){
    bool odd = false;
    ll cnt=0;
    for(int i=0;i<n;i++){
        cnt+=(arr[i]/x + (arr[i]%x!=0)-1);
    }
    return (cnt<=k);
}

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

    arr.assign(n,0);
    for(int i=0;i<n;i++){
        cin >> arr[i];
    }
    ll l = 1, r = 1e9, med = -1, answ = -1;
    while(l<=r){
        med = l + (r-l)/2;
        if(isOk(med)){
            answ = med;
            r = med-1;
        }
        else{
            l = med+1;
        }
    }

    cout << answ << '\n';

    return 0;
}

Measured memory_bytes: 4792
import java.util.*;

public class Main {
		public static void main(String[] args) {
		
	   Scanner sc = new Scanner(System.in);
	  
	   String a = sc.next();
	   
	    if(a.contains("AB") || a.contains("BA")){
		   System.out.println("Yes");
	   }else{
	   		   System.out.println("No");
	   }   
	    
	   
	   }
}



Measured memory_bytes: 21588
(loop repeat (1- (read)) 
      with x = (read) and y = (read) and u and v
      with maxu = (+ x y) and minu = (+ x y) and maxv = (- x y) and minv = (- x y)
      do 
      (setf x (read)
            y (read))
      (setf u (+ x y)
            v (- x y))
      (setf minu (min minu u)
            maxu (max maxu u)
            minv (min minv v)
            maxv (max maxv v))
      finally (princ (max (- maxu minu)
                          (- maxv minv ))))

Measured memory_bytes: 77244