akhauriyash/Code-Regression huggingface dataset:
import sys
import math

def to_f(e):
  return float(e)

n = int(raw_input().rstrip())
for i in range(n):
  line = raw_input().rstrip() 
  x1, y1, x2, y2, x3, y3 = map(to_f, line.split(" "))
  a1 = 2*(x2-x1)
  a2 = 2*(x3-x1)
  b1 = 2*(y2-y1)
  b2 = 2*(y3-y1)
  c1 = x1**2-x2**2+y1**2-y2**2
  c2 = x1**2-x3**2+y1**2-y3**2
  xp = (b1*c2-b2*c1)/(a1*b2-a2*b1)
  yp = (c1*a2-c2*a1)/(a1*b2-a2*b1)
  r  = round(math.sqrt((xp-x1)**2+(yp-y1)**2), 3)
  #print(str(xp.format()+ " " + str(yp) + " " + str(r))
  print "%.3f %.3f %.3f" % (xp, yp, r)

Measured memory_bytes: 6500
#include<stdio.h>
#include<math.h>
#define eps 1.0e-10

typedef struct{
  double x;
  double y;
}point;

typedef struct{
  double x;
  double y;
  double r;
}circle;

//cross of two circles
//https://shogo82148.github.io/homepage/memo/geometry/circle-cross.html
int twocirles_cross(circle c1,circle c2,point res[2]){
  double dx,dy,a;
  dx=c1.x;dy=c1.y;
  c1.x-=dx;c1.y-=dy;
  c2.x-=dx;c2.y-=dy;
  a=(c2.x*c2.x+c2.y*c2.y+c1.r*c1.r-c2.r*c2.r)/2;
  if(((c2.x*c2.x+c2.y*c2.y)*c1.r*c1.r-a*a)<0.0){return -1;}
  res[0].x = dx+
  ((a*c2.x+c2.y*sqrt((c2.x*c2.x+c2.y*c2.y)*c1.r*c1.r-a*a))
  /*---------------------------------------------------*/ /
                  (c2.x*c2.x+c2.y*c2.y));

  res[0].y = dy+
  ((a*c2.y-c2.x*sqrt((c2.x*c2.x+c2.y*c2.y)*c1.r*c1.r-a*a))
  /*---------------------------------------------------*/ /
                  (c2.x*c2.x+c2.y*c2.y));

  res[1].x = dx+
  ((a*c2.x-c2.y*sqrt((c2.x*c2.x+c2.y*c2.y)*c1.r*c1.r-a*a))
  /*---------------------------------------------------*/ /
                  (c2.x*c2.x+c2.y*c2.y));

  res[1].y = dy+
  ((a*c2.y+c2.x*sqrt((c2.x*c2.x+c2.y*c2.y)*c1.r*c1.r-a*a))
  /*---------------------------------------------------*/ /
                  (c2.x*c2.x+c2.y*c2.y));
  return 1;
}

int n,tg;
point pts[64];
double c[64];

int eval(point pt,double t){
  int i,res=0;
  double r;
  for(i=0;i<n;i++){
    r=sqrt((pt.x-pts[i].x)*(pt.x-pts[i].x)+(pt.y-pts[i].y)*(pt.y-pts[i].y));
    r*=c[i];
    if(r<=eps+t){res++;}
    //printf("[%d %.12lf] : %d\n",i,r,res);
  }
  return res;
}

int main(){
  int i,j,k,fl;
  double st=0,fi=334334.0,te;
  circle cs[64];
  point ccp[2],cp;
  scanf("%d%d",&n,&tg);
  for(i=0;i<n;i++){
    scanf("%lf%lf%lf",&pts[i].x,&pts[i].y,&c[i]);
  }
  for(i=0;i<200;i++){
    if(st>fi){break;}
    te=(st+fi)/2.0;
    for(j=0;j<n;j++){
      cs[j].x=pts[j].x;
      cs[j].y=pts[j].y;
      cs[j].r=te/c[j];
    }
    fl=0;
    for(j=0;j<n;j++){
      cp.x=cs[j].x;
      cp.y=cs[j].y;
      //printf("%.12lf %.12lf %.12lf\n",cs[j].x,cs[j].y,cs[j].r);
      if(eval(cp,te)>=tg){fl=1;}
      for(k=j+1;k<n;k++){
        if(twocirles_cross(cs[j],cs[k],ccp)==-1){continue;}
        //printf("<%.12lf %.12lf>\n",ccp[0].x,ccp[0].y);
        //printf("<%.12lf %.12lf>\n",ccp[1].x,ccp[1].y);
        if(eval(ccp[0],te)>=tg){fl=1;}
        if(eval(ccp[1],te)>=tg){fl=1;}
      }
    }
    //printf("%.12lf : %d\n",te,fl);
    if(fl==1){fi=te;}
    else{st=te;}
  }
  printf("%.12lf\n",(st+fi)/2.0);
}

Measured memory_bytes: 128
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();

		String[] Ws = W.split(" ");
		long x = Long.parseLong(Ws[0]);

		long ans = x/11;
		ans=ans*2;
		if(x%11==0){

		}else if(x%11<=6){
			ans++;
		}else{
			ans+=2;
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,i;
    cin>>n;
    ll dp[n][3],a[n][3];
    for(i=0;i<n;i++)
    {
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    for(i=1;i<n;i++)
    {
        dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=a[i][2]+max(dp[i-1][0],dp[i-1][1]);
    }
    cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<"\n";
}


Measured memory_bytes: 4992
N, M = [int(i) for i in input().split()]

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

divisors = make_divisors(M)
for d in reversed(divisors):
    if M // d >= N:
        print(d)
        break

Measured memory_bytes: 38640
#include<iostream>
using namespace std;
int main()
{
    int N,a,d;
    cin >> N;
    if(N<1000) cout << 1000-N << endl;
    else {
            d=N%1000;
    if(d==0) cout << d << endl;
    else {
            a=1000-d;
            cout << a << endl;
    }
    }
    return 0;
}


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

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

using namespace std;

int n;
char s[100001];
int k;

int main(){
	scanf("%s%d", s, &k);
	n = strlen(s);

	rep(i, n){
		int p = s[i] != 'a' ? 26 - s[i] + 'a' : 0;
		if(p <= k){
			k -= p;
			s[i] = 'a';
		}
	}
	if(k > 0){
		s[n - 1] = char((s[n - 1] - 'a' + k) % 26 + 'a');	
	}
	printf("%s\n", s);
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<malloc.h>
using namespace std;

typedef struct zifu
{
	char a;
	struct zifu *next;
}zifu;

zifu *shuru();
int tongji(zifu *head);

int main()
{
	int i;
	zifu *head;
	head=shuru();
	i=tongji(head);
	if(i) cout << "Yes"<<endl;
	else cout <<"No"<<endl;
	return 0;
}

zifu *shuru()
{
	zifu *head;
	head=(zifu*)malloc(sizeof(zifu));
	head->next =NULL;
	int flag=1;
	do
	{
		zifu *p;
	    p=(zifu*)malloc(sizeof(zifu));
		scanf("%c",&p->a );
		if(p->a !='\n')
		{
			p->next =head->next ;
			head->next =p;
		}
		else
		{
			flag=0;
		}
	}while(flag);
	return head;
}

int tongji(zifu *head)
{
	char c;
	zifu *p,*q;
	int sum;
while(head->next !=NULL)
{
		
	sum=0;
	q=head;
	p=head->next;
    c=p->a;
	do
	{
		if(c==p->a)
		{
			sum++;
			q->next =p->next ;//如果等于，进行了sum++运算，就删除节点。 
		}
		else
		{
			q=p;//如果不等于，q移动到p处。（循环开始时，q永远是p的上一个节点） 
		}
		p=p->next ;
	}while(p!=NULL);
	if(sum%2 !=0)
	{
		return 0;
	}
}
	return 1;
}

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



int main(){
	string c;
	cin >>c;
	int n=(int)c.length();
	vector<string>s(n);
	rep(i,n)s[i]=c[i];
	vector<string>S(s.size());
	rep(i,n)S[i]=s[i];
	bool f=true;
	reverse(S.begin(),S.end());
	rep(i,n)if(s.at(i)!=S[i])f=false;
	for(int i=0;i<(n-1)/2;i++)s[i]=S[(n-3)/2-i];
	for(int i=(n+1)/2;i<n;i++)s[i]=S[(3*n-1)/2-i];
	rep(i,n)if(s[i]!=S[i])f=false;



	if(f)cout << "Yes";
	else cout << "No";

	
}


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

struct Edge {
  int from, to, cost;
};

int main() {
  int l;
  cin >> l;
  int r = log2(l);
  vector<Edge> edges;
  int n = r + 1;
  for (int i = 0; i < r; i++) {
    edges.push_back(Edge{i + 1, i + 2, 0});
    edges.push_back(Edge{i + 1, i + 2, 1 << i});
  }
  int pow_r = 1 << r;
  for (int i = r; i >= 1 && l - pow_r > 0; i--) {
    int pow_i = 1 << (i - 1);
    if (l - pow_r >= pow_i) {
      l -= pow_i;
      edges.push_back(Edge{i, n, l});
    }
  }

  cout << n << " " << edges.size() << endl;
  for (Edge e : edges) cout << e.from << " " << e.to << " " << e.cost << endl;
  return 0;
}


Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<long long> > vvll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define INF 1000000000
#define MOD 1000000007
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define p_q priority_queue

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

#define MN 100005
int a, b;

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

    cin >> a >> b;
    if(a >= 13) cout << b;
    else if(a < 6) cout << 0;
    else cout << b/2;
    cout << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n;
long long a,f[200100],s;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a;
		if(i&1) s+=a;
		if(i==1) continue;
		if(i&1) f[i]=max(f[i-2]+a,f[i-1]);
		else f[i]=max(f[i-2]+a,s);
	}
	cout<<f[n]<<endl;
	return 0;
}


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

int gcd(int x, int y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̕ϐ� (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }


int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    sort(p.begin(), p.end());
    int ans = 0;
    for (int i = 0; i < k; i++) {
        ans += p[i];
    }
    cout << ans << endl;
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

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

#define ll long long

using namespace std;

const int MAXN = 100010;
const int MAXM = 100010;
const int MAXINT = 2147483647;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;

int n, m, k;
int ans, tot, cnt;

int a[MAXN];

string s;

inline int read() {
	int s = 0, f = 1;
	char ch = getchar();
	while ('0' > ch || ch > '9') {if (ch == '-') f = -1; ch = getchar();}
	while ('0' <= ch && ch <= '9') {s = (s << 3) + (s << 1) + ch - 48; ch = getchar();}
	return s * f;
}

int main(){
	int T;
	scanf("%d", &n);
	printf("%d\n", (1000 - n % 1000) % 1000);
	return 0;
}

/*

*/


Measured memory_bytes: 3828
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

func getString() string {
	sc.Scan()
	return sc.Text()
}

const mod = 1000000007

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()

	ans := 1
	for i := 1; i <= N; i++ {
		ans = (ans * i) % mod
	}
	out(ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    int a, b, c;
    cin >> a >> b >> c;
    if((a % 2 == 0) && (a == b) && (b == c)){
        cout << -1 << endl;
        return 0;
    }
    int i = 0;
    while((a % 2 == 0) && (b % 2 == 0) && (c % 2 == 0)){
        int d = (b + c) / 2;
        int e = (c + a) / 2;
        int f = (a + b) / 2;
        a = d;
        b = e;
        c = f;
        i++;
    }
    cout << i << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	long long int i, j, x;
	scanf("%lld", &x);
	
	for(i = -1001; i < 1002; i++){
		for(j = -1001; j < 1002; j++){
			if(i * i * i *i * i - j * j * j * j * j == x){
				printf("%lld %lld\n", i, j);
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1696
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define el cout << endl
#define sp(x) cout << setprecision(x);
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
#define vi vector<int> 
#define vvi vector<vector<int>> 
#define pii pair<int,int>
#define vpii vector<pair<int,int>> 
#define vl vector<ll> 
#define vvl vector<vector<ll>> 
#define vd vector<double> 
#define vvd vector<vector<double>> 
#define vb vector<bool> 
#define vvb vector<vector<bool>>
#define vs vector<string>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
int inf_i = 1001001000;
ll inf_l = 1001001001001000;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a * b / g; }
bool is_prime(ll x) { for (ll i = 2; i * i <= x; i++) { if (x % i == 0)return false; } return true; }

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m, r;
	cin >> n >> m >> r;
	vi rs(r);
	rep(i, r)
	{
		int x;
		cin >> x;
		rs[i] = x - 1;
	}
	sort(all(rs));
	vvi cost(n, vi(n, inf_i));
	rep(i, m)
	{
		int a, b, c;
		cin >> a >> b >> c;
		a--;  b--;
		cost[a][b] = c;
		cost[b][a] = c;
	}
	rep(k, n)rep(i, n)rep(j, n)
	{
		chmin(cost[i][j], cost[i][k] + cost[k][j]);
	}
	int ans = inf_i;
	do
	{
		int tmp = 0;
		rep(i, sz(rs)-1)
		{
			tmp += cost[rs[i]][rs[i + 1]];
		}
		chmin(ans, tmp);
	} while (next_permutation(all(rs)));
	co(ans);
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#include<math.h>

void rev(char *s){
	int i,d=strlen(s);
	char tmp;
	for(i=0;i<d/2;i++){
		tmp=*(s+i); *(s+i)=*(s+d-i-1); *(s+d-i-1)=tmp;
	}
}
int main(){
	int n,p,q,x,y,dt,i,j,k,t,u,flag;
	char str1[1024],str2[1024],msg[2048],*v,*w;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",str1);
		scanf("%s",str2);
		rev(str1);
		rev(str2);
		flag=strlen(str1)>strlen(str2);
		t=(!flag)*strlen(str2)+flag*strlen(str1);
		u=flag*strlen(str2)+(!flag)*strlen(str1);
		v=(flag ? str1 : str2);
		w=(flag ? str2 : str1);
		strcpy(msg,v);
		for(j=0;j<u;j++){
		for(dt=0,k=j;k<t;k++){
			x=*(v+k)-'0'; y=abs(((k==j)*(*(w+k)-'0'))%48); p=x+y; q=p%10;
			msg[k]=(q+dt)%10+'0';
			dt=(p+dt)/10;
			if(k==t-1&&dt>0){
				msg[k+1]=dt+'0';
				msg[k+2]='\0';
				break;
			}
			if(!dt)break;
		}
		strcpy(v,msg);
		}
		rev(msg);
		if(strlen(msg)<=80){
			for(j=0;j<strlen(msg);j++) printf("%d",msg[j]-'0');
			printf("\n");
		}else{
			printf("overflow\n");
		}
		memset(msg,NULL,sizeof(msg));
	}
	return 0;
}

Measured memory_bytes: 628
#include<bits/stdc++.h>
using namespace std;
int main(){
  long n,m,k,temp;
  cin >> n >> m >> k;
  vector<long> a(n+1,0),b(m+1,0);
  for(int i=1;i<=n;i++){
    cin >> temp;
    a.at(i) = a.at(i-1) + temp;
  }
  for(int i=1;i<=m;i++){
    cin >> temp;
    b.at(i) = b.at(i-1) + temp;
  }
  int b_idx=m,ans=0;
  for(int i=0;i<=n;i++){
    if(a.at(i)>k)break;
    while(a.at(i) + b.at(b_idx) > k)b_idx--;
    ans=max(ans,i+b_idx);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6404
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();
		double hAngle = h * 30.0 + m * 0.5;
		double mAngle = m * 6.0; 
		double angle = mAngle - hAngle;
		if(Math.abs(mAngle - hAngle) > 180 ) {
			angle = 360.0 - angle;
		}else {			
			angle *= -1;
		}
		double cos = Math.cos(Math.toRadians(angle));
		double result =  Math.sqrt(a*a + b*b - (2.0*a*b*cos));
		System.out.println(result);
		sc.close();
	}
}


Measured memory_bytes: 36068
function Main(input) {
	input = input.split("\n");
  	colors = input[0].split(" ");
	tmp = input[1].split(" ");
  	let s = colors[0];
  	let a = tmp[0];
  	let b = tmp[1];
  	let u = input[2];
  
  	if(u === s){
      a --;
    }else{
      b --;
    }
  
	console.log(a,b);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29552
def hoge() gets.split.map(&:to_i) end
n = gets.to_i; t,a = hoge(); h = hoge()

d = p = 1000000
(1..n).to_a.each do |i|
  fuga = (a-(t-h[i-1]*0.006)).abs
  if fuga < d then d = fuga; p = i end
end

p p

Measured memory_bytes: 1788
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値
//グローバル変数
vector<long long> fact, fact_inv, inv;

//二項係数前処理計算量O(SIZE)
void init_nCk(int SIZE) {
    fact.resize(SIZE + 5);
    fact_inv.resize(SIZE + 5);
    inv.resize(SIZE + 5);
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE + 5; i++) {
        fact[i] = fact[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
}
    
//nCk　計算量(1)
ll nCk(int n, int k) {
    assert(!(n < k));
    assert(!(n < 0 || k < 0));
    return fact[n] * (fact_inv[k] * fact_inv[n - k] % MOD) % MOD;
}

int main(){
    int N;
    cin>>N;
    vector<ll> A(N);
    REP(i,N) cin>>A[i];
    vector<ll> S(N+1,0);
    map<ll,ll> mp;
    mp[0]++;
    REP(i,N){
        S[i+1]=S[i]+A[i];
        mp[S[i+1]]++;
    }

    init_nCk(20100);
    ll ans=0;
    for(auto itr=mp.begin();itr!=mp.end();itr++){
        ll num=itr->second;
        if(num>=2) ans+=(num*(num-1))/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 19256
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if(a + b == 15) {
        cout << "+" << endl;
    } else if(a * b == 15) {
        cout << "*" << endl;
    } else {
        cout << "x" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#define INF 1 << 30

int min(int a,int b){
  if(a < b){
    return a;
  }
  return b;
}

int main(void){
  int N,Ma,Mb;
  scanf("%d%d%d",&N,&Ma,&Mb);

  int a[N],b[N],c[N];
  for(int i = 0;i < N;i++){
    scanf("%d%d%d",&a[i],&b[i],&c[i]);
  }

  int dp[N+1][401][401];
  for(int i = 0;i <= N;i++){
    for(int j = 0;j <= 400;j++){
      for(int k = 0;k <= 400;k++){
        dp[i][j][k] = INF;
      }
    }
  }
  dp[0][0][0] = 0;

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

  int ans = INF;
  for(int i = 1;i <= 400;i++){
    for(int j = 1;j <= 400;j++){
      if(i*Mb == j*Ma){
        ans = min(ans,dp[N][i][j]);
      }
    }
  }

  if(ans == INF) printf("-1\n");
  else printf("%d\n",ans);
  
  
  return 0;
}

Measured memory_bytes: 25856
N = int(input())
A=[]
B=[]
# for i in range(N):
#     a, b = map(int, input().split())
#     A.append(a)
#     B.append(b)
x = [list(map(int, input().split())) for i in range(N)]  # x11 x12
x.sort(key=lambda x: x[1])
limit = 0
for i in range(N):
    limit += x[i][0]
    if limit > x[i][1]:
        print('No')
        exit()
    else:
        pass
else:
    print('Yes')

Measured memory_bytes: 53720
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

total = 0
idx_a = idx_b = 0
while idx_a < n and total + A[idx_a] <= k:
    total += A[idx_a]
    idx_a += 1
while idx_b < m and total + B[idx_b] <= k:
    total += B[idx_b]
    idx_b += 1

ans = idx_a + idx_b
while idx_a > 0:
    idx_a -= 1
    total -= A[idx_a]
    while idx_b < m and total + B[idx_b] <= k:
        total += B[idx_b]
        idx_b += 1
    ans = max(ans, idx_a + idx_b)
print(ans)

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

ll solve(ll x, ll c, ll d) {
	ll lcm = (c * d) / __gcd(c, d);
	ll cnt_c = x / c;
	ll cnt_d = x / d;
	ll cnt_lcm = x / lcm;
	ll cnt_cd = cnt_c + cnt_d - cnt_lcm;
	return x - cnt_cd;
}

int main(int argc, char const *argv[])
{
	ll a, b, c, d; cin >> a >> b >> c >> d;
	printf("%lld\n", solve(b, c, d) - solve(a - 1, c, d));
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		freopen("a.txt", "r", stdin);
		//freopen("b.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	string s;
	cin >> s;

	int n = s.length();
	ll ans = 0, aa = 0;
	for (int p = 0; p < n; ++p)
	{
		if (s[p] == 'A')
			++aa;
		else
		{
			if (s[p] != 'B')
			{
				aa = 0;
				continue;
			}

			if (p+1 < n && s[p+1] == 'C')
			{
				ans += aa;
				++p;
			}
			else
			{
				aa = 0;
			}
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-11;



int main() {

    int a,v,b,w,t;
    cin>>a>>v>>b>>w>>t;
    int d=abs(a-b);
    if(a!=b&&w>=v){
        fin("NO");
    } else if(a==b){
        fin("YES");
    } else {
        int time = ceil(d/(double)(v-w));
        YN(time <=t);
    }
}


Measured memory_bytes: 3744
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<deque>
#include<iomanip>
#include<set>
#include<unordered_set>
#include<tuple>
#include<map>
#include<memory>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<double> VD;
typedef pair<int, int> P1;
typedef long long int ll;

//number
#define INF 1e9
#define NUM 1000000007

//itr
#define all(x) begin(x),end(x)

//repeat
#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++)

//max,min
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

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

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	retur5n a * (b / g);
}*/

int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}

//grid template
int x[] = { -1, 0, 1, 0 };
int y[] = { 0,-1,0,1 };
int xx[] = { -1,-1,1,1 };
int yy[] = { 1,-1,1,-1 };

int main() {
	int m, nmin, nmax;
	while (true) {
		cin >> m >> nmin >> nmax;
		if (m == 0 && nmax == 0 && nmin == 0) {
			return 0;
		}

		VI p(m);
		rep(i, m) cin >> p[i];

		int ans = 0, maxv = -1;
		for (int i = nmin; i <= nmax; i++) {
			int div = p[i - 1] - p[i];
			if (max(div, maxv) == div || div==maxv) {
				//cout << div << " " << i << endl;
				maxv = div;
				ans = i;
			}
		}
		cout << ans << endl;

	}
	return 0;
}


Measured memory_bytes: 3084
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
const ll inf=1e15;
typedef pair<ll, int> P;
int N, M;
// ダイクストラO(elogv)
struct edge{
  int to, cost;
  edge(int t, ll c) {
    to = t, cost = c;
  }
};
vector<edge> G[100005];
ll d[100005];
void dijkstra(int s){
  priority_queue<P, vector<P>, greater<P> > que;
  FOR(i,1,N+1) d[i] = inf;
  d[s] = 0;
  que.push(P(0, s));
  while(!que.empty()){
    P p = que.top(); que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    for(edge nx : G[v]){
      if(d[nx.to] > d[v] + nx.cost){
        d[nx.to] = d[v] + nx.cost;
        que.push(P(d[nx.to], nx.to));
      }
    }
  }
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int s,t;
  cin>>N>>M>>s>>t;
  FOR(i,0,M){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    G[a].push_back(edge(b,d));
    G[a].push_back(edge(c,d));
    G[b].push_back(edge(a,d));
    G[b].push_back(edge(c,d));
    G[c].push_back(edge(a,d));
    G[c].push_back(edge(b,d));
  }
  dijkstra(s);
  cout<<d[t]<<endl;
  return 0;
}


Measured memory_bytes: 16664
#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>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1LL << 60;

int main() {

    ll N,M;
    cin >> N >> M ;
    ll s[10][10];
    ll k[10];
    ll p[10];
    rep(i,M){
        cin >> k[i];
        rep(j,k[i]){
            cin >> s[i][j];
        }
    }
    rep(i,M){
        cin >> p[i];
    }

    int ans=0;
    for(int bit=0;bit<(1<<N);bit++){
        int res=0;
        for(int i=0;i<M;i++){
            int cnt=0;
            for(int j=0;j<k[i];j++){
                if(bit&(1<<s[i][j]-1)){
                    cnt++;
                }
            }
            if(cnt%2==p[i]){
                res++;
            }
        }
        if(res==M){
            ans++;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {

	long h, w;
	cin >> h >> w;

	char a;
	for (long i = 0; i <= h+1; i++) {
		for (long j = 0; j <= w+1; j++) {
			if (i == 0 || i == h + 1 || j == 0 || j == w + 1) {
				cout << '#';
			}
			else {
				cin >> a;
				cout << a;
			}
		}
		cout << endl;
	}

}

Measured memory_bytes: 256
base = 10^9 + 7

-- O(N^2)で十分と解説にあったので比較
doCount :: [Int] -> [(Integer,Integer)]
doCount as = loop [] as
  where
    cnt v xs = fromIntegral $ length $ filter (v >) xs
    loop as (b:bs) = (cnt b as, cnt b bs) : loop (b:as) bs
    loop _ [] = []
  
compute :: Integer -> Integer -> [Int] -> Integer
compute n k as = foldl1 add $ map f $ doCount as
  where
    f (x, y) = k * y + k * (k-1) * (x+y) `div` 2
    add x y = (x+y) `mod` base

main = do
  li <- getLine
  let [n,k] = map read $ words li
  li <- getLine
  let as = map read $ words li
  let ans = compute n k as
  print ans


Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
using namespace std;
using v = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}

int main(int argc, char *argv[]){
    string s; cin >> s;
    int a, z;
    rep(i, s.size()){
        if(s[i] == 'A'){a = i; break;}
    }
    for(int i = s.size() - 1; i >= 0; i--){if(s[i] == 'Z'){z = i; break;}}
    cout << z-a+1 << endl;
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    FOR(i,1,n){
        if (i%3==0){
            cout<<" "<<i;
        }else{
            int x = i;
            bool ok=false;
            while(x){
                if (x%10==3){
                    ok = true;
                    break;
                }
                x/=10;
            }
            if (ok) cout<<" "<<i;
        }
    }
    cout<<"\n";
    return 0;
}



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

template <typename T>
void maxSelf(T& a,T b){
    a=max(a,b);
}
const int INF =1e9+7;
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);    
    string s,t;
    cin>>s>>t;
    vector<vector<pair<int,pair<int,int>>>>dp(s.length()+1,vector<pair<int,pair<int,int>>>(t.length()+1,{-INF,{0,0}}));
    dp[0][0]={0,{0,0}};
    for(int i=0;i<s.length();i++){
        for(int j=0;j<t.length();j++){
            if(s[i]==t[j]){
                maxSelf(dp[i+1][j+1],make_pair(dp[i][j].first+1,make_pair(i,j)));
            }
            maxSelf(dp[i+1][j],make_pair(dp[i][j].first,make_pair(i,j)));
            maxSelf(dp[i][j+1],make_pair(dp[i][j].first,make_pair(i,j)));
        }
    }
    pair<int,pair<int,int>> ans={0,{0,0}};
    for(int i=0;i<=s.length();i++){
        for(int j=0;j<=t.length();j++){
                maxSelf(ans,make_pair(dp[i][j].first,make_pair(i,j)));   
        }
    }    
    string str;
    pair<int,int>cur=ans.second;
    while(cur.first>0 && cur.second>0){
        int i=cur.first;
        int j=cur.second;
        pair<int,int>prev=dp[i][j].second;
        if(prev == make_pair(i-1,j-1)){
            str+=s[i-1];
        }
        cur=prev;
    }
    reverse(str.begin(),str.end());
        cout<<str;
}

Measured memory_bytes: 105984
import sys

import numpy as np
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
"""dd = [(-1, 0), (0, 1), (1, 0), (0, -1)];
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)];
ddn9 = ddn + [(0, 0)]
for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""

def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]  # WideIntPoint
def ws(): return sys.stdin.readline().split()
def si(): return int(sys.stdin.readline())  # SingleInt
def ss(): return input()
def hi(n): return [si() for _ in range(n)]
def hs(n): return [ss() for _ in range(n)]  # HeightString
def s_list(): return list(input())
def mi(n): return [wi() for _ in range(n)]  # MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]  # NumberGrid
def grid(n): return [s_list() for _ in range(n)]


def main():

    n,m = map(str, input().split())
    d = list(map(int, input().split()))
    use = []
    for i in range(0,10):
        if i not in d:
           use.append(str(i))
    #print(use)
    ans_list = []
    for start in use:
        stack = deque()
        stack.append(start)
        ans = ''
        while stack:
            x = stack.pop()
            if int(n) <= int(x):
                ans_list.append(int(x))
            else:
                for tumu in use:
                    if len(x + tumu) <= len(n) + 1:
                        stack.append(x + tumu)

    print(min(ans_list))

if __name__ == '__main__':
    main()


Measured memory_bytes: 15704
while True:
    H, W = [int(x) for x in input().split() if x.isdigit()]
    if H ==0 and W == 0:
        break
    else:
        for i in range(H):
            print("#", end='')
            if i == 0 or i == H-1:
                for j in range(W-2):
                    print("#", end='')
            else:
                for j in range(W-2):
                    print(".", end='')
            print("#")
        print("")

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> t chmax(t&a,u b){if(a<b)a=b; return a;};
template<class t, class u> t chmin(t&a,u b){if(a>b)a=b; return a;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, K;
  IN(N,K);
  vll a(N);
  REP(i,N) IN(a[i]);
  sort(ALL(a));
  vb dp(K+1, true);
  dp[0] = false;
  REP(j,K+1){
    bool flag_tmp = false;
    REP(k,N){
      if(j-a[k]<0) break;
      if(!dp[j-a[k]]) flag_tmp = true;
    }
    dp[j] = flag_tmp;
  }

  if(dp[K]) OUT("First\n");
  else OUT("Second\n");

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long 
#define F first
#define S second
#define pb push_back
#define REP(i,a,b) for (int i = a; i <= b; i++)

int main()
{
 ll x;ll ans=0;ll y=0;
 cin >> x;
 y=x%500;
 x/=500;
 y/=5;
 ans+=x*1000;
 ans+=y*5;
 
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
a_max, v_max = 0, -1

gets.to_i.times do
  a, v = gets.split.map(&:to_i)
  a_max, v_max = a, v if v_max < v
  a_max = a if v_max == v && a < a_max
end

puts "#{a_max} #{v_max}"

Measured memory_bytes: 6104
import Foundation

func main() {
    guard let line = readLine() , let line2 = readLine() else { return }
    let n = Int(line)!
    let l = line2.components(separatedBy: " ").compactMap() { Int($0) }
    guard n >= 3 else {
        print(0)
        return
    }
    var count = 0
    for i in 0..<(n-2) {
        for j in (i+1)..<(n-1) {
            for k in (j+1)..<n {
                if check(j: l[i], k: l[j], l: l[k]) {
                    count += 1
                }
            }
        }
    }
    print(count)
}

func check(j: Int, k: Int, l: Int) -> Bool {
    return mul(a: j, b: k, c: l) && mul(a: k, b: l, c: j) && mul(a: l, b: j, c: k)
}

func mul(a: Int, b: Int, c: Int) -> Bool {
    return a + b > c && a != b
}

main()


Measured memory_bytes: 14172
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int x;
  cin >> x;
  int ans = 0;
  for (int i = 1; i <= 1000; i++) {
    for (int j = 2; j <= 9; j++) {
      int tmp = pow(i, j) + 0.5;
      if (tmp <= x){
        ans = max(ans, tmp);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include<stdio.h>
 
  int main(void){
 
      int x = 0,y = 0,ans,ans_2;
 
      scanf("%d %d",&x,&y);
 
      ans = x * y;
      ans_2 = x*2 + y*2;
 
      printf("%d %d\n",ans,ans_2);
 
      return 0;
  }

Measured memory_bytes: 596
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>

using namespace std;

typedef long long ll;

const ll mod = 1000 * 1000 * 1000 + 7;

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

ll pw(ll x, ll n) {
  ll result = 1;
  while (n > 0) {
    if (n % 2 == 1) {
      n--;
      result = result * x % mod;
    } else {
      x = x * x % mod;
      n /= 2;
    }
  }
  return result;
}

int main()
{
  ll n, m, t;
  cin >> n >> m >> t;

  ll times = 1;
  ll g = gcd(n, t);
  times *= g;
  n /= g;

  g = gcd(m, t);
  times *= g;
  m /= g;

  ll result = (pw(2, n) + pw(2, m) + pw(2, gcd(n, m)) - 3 + mod) % mod;

  result = pw(result, times);

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main (){
    int a, b, c, count = 0;
    scanf("%d %d %d", &a,&b,&c);
    while(1){
        if(c % a == 0)
            count++;
            if(a == b)
                        break;
                 a++;
}
    printf("%d\n", count);
    return 0;
}

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


int main() {
long N,M;
cin>>N>>M;
vector<long> a(N);
for(int i=0;i<N;i++){
  cin>>a[i];
  a[i]%=M;
}
long ans=0;
vector<long> r(N);
r[0]=a[0];
if(r[0]==0) ans++;

for(int i=1;i<N;i++){
  r[i]=r[i-1]+a[i];
  r[i]%=M;
  if(r[i]==0) ans++;
}

map<long,long> modm;
for(int i=0;i<N;i++){
modm[r[i]]++;
}

for (auto& x:modm) {
  long n=x.second;
  ans+=n*(n-1)/2;
        }
cout<<ans<<endl;
}


Measured memory_bytes: 8792
#include <cstdio>
#include <cmath>
using namespace std;

void pos(double a, double b, double x[3]) {
  double aa, bb;
  aa = a * M_PI / 180.;
  bb = b * M_PI / 180.;
  x[0] = cos(aa)*cos(bb);
  x[1] = cos(aa)*sin(bb);
  x[2] = sin(aa);
}

int main() {
  double a, b, c, d, x[3], y[3], dot, t;
  int ans;
  while (1) {
    scanf("%lf %lf %lf %lf", &a, &b, &c, &d);
    if (a == -1 && b == -1 && c == -1 && d == -1) break;
    pos(a, b, x);
    pos(c, d, y);
    dot = x[0]*y[0]+x[1]*y[1]+x[2]*y[2];
    if (dot < -1.) dot = -1.;
    else if (dot > 1.) dot = 1.;
    t = acos(dot);
    ans = (int)round(t * 6378.1);
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 1108
import math
import itertools
n = int(input())
nn = math.factorial(n)
X = []
Y = []
for _ in range(n):
  x, y = map(int, input().split())
  X.append(x)
  Y.append(y)
xx = list(itertools.permutations(X, n))
yy = list(itertools.permutations(Y, n))
c = 0
for k in range(nn):
  s = 0
  for i in range(n-1):
    s += math.sqrt((xx[k][i] - xx[k][i+1])**2 + (yy[k][i] - yy[k][i+1])**2)
  c += s
print(c/nn)

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

int main() {
  int h, w, i, j, ans = 1;
  cin >> h >> w;
  
  vector<vector<char>> s(h + 2, vector<char>(w + 2, '.'));
  for(i = 1; i <= h; i++){
    for(j = 1; j <= w; j++){
      cin >> s.at(i).at(j);
    }
  }
  
  for(i = 1; i <= h; i++){
    for(j = 1; j <= w; j++){
      if(s.at(i).at(j) == '#' && s.at(i).at(j + 1) == '.' && s.at(i).at(j - 1) == '.' 
        && s.at(i + 1).at(j) == '.' && s.at(i - 1).at(j) == '.'){
        ans = 0;
      }
    }
  }
  
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << endl;}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
int main() {
	var(int, r, g);
	print(g * 2 - r);
	return 0;
}


Measured memory_bytes: 256
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>
#include <iomanip>

using namespace std;


int main() {

	int n;
	cin >> n;
	int small = 1e6;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int tmp; cin >> tmp;
		small = min(small, tmp);
		if (small == tmp)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# Your code here!
x,y=gets.split(" ").map(&:to_i)
z=100000
total=0
case x
when 3 then
    total+=z
when 2 then
    total+=z*2
when 1 then
    total+=z*3
else
    total+=0
end

case y
when 3 then
    total+=z
when 2 then
    total+=z*2
when 1 then
    total+=z*3
else
    total+=0
end

if x==y&&x==1
    total+=100000*4
end

p total

Measured memory_bytes: 1788