akhauriyash/Code-Regression huggingface dataset:
# not AC
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan, degrees
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect
import heapq

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def circumcenter(data):
    #coordinates
    (x1, y1), (x2, y2), (x3, y3) = data

    #length of each side squared and area of the triangle
    a2 = (x2 - x3) **2 + (y2 -y3) ** 2 
    b2 = (x1 - x3) **2 + (y1 -y3) ** 2
    c2 = (x2 - x1) **2 + (y2 -y1) ** 2
    area = ((x2 - x1) * (y3 -y1) - (x3 -x1) * (y2- y1)) / 2

    #is_triangle
    if area == 0:
        return -1
    
    #circumcenter coordinate and radius      
    x = (a2*(b2+c2-a2)*x1 + b2*(c2+a2-b2)*x2 + c2*(a2+b2-c2)*x3) / (16*area*area)
    y = (a2*(b2+c2-a2)*y1 + b2*(c2+a2-b2)*y2 + c2*(a2+b2-c2)*y3) / (16*area*area) 
    r = ((x1-x)**2 + (y1-y)**2)**0.5
    
    #rounding
    x, y, r = map(lambda x:round(x, 20) if x!=int(x) else int(x), (x, y, r))
    
    #return the equation
    return x, y, r

N = INT()
xy = [LIST() for _ in range(N)]
xy.sort()

if N == 2:
    x1, y1 = xy[0]
    x2, y2 = xy[1]
    print((((x2-x1)/2)**2+((y2-y1)/2)**2)**(1/2))
    sys.exit()

ans = INF
epsilon = 10**(-6)
def dist(p1, p2):
    return ((p1[0]-p2[0])**2+(p1[1]-p2[1])**2)**(1/2)

for points in combinations(xy, 3):
    res = circumcenter(points)
    if res == -1:
        continue
    x = res[0]
    y = res[1]
    r = res[2]
    for p in xy:
        if dist(p, (x, y)) > r + epsilon:
            break
    else:
        ans = min(ans, r)

for points in combinations(xy, 2):
    x1, y1 = points[0]
    x2, y2 = points[1]
    x = (x1+x2)/2
    y = (y1+y2)/2
    r = (((x2-x1)/2)**2+((y2-y1)/2)**2)**(1/2)
    for p in xy:
        if dist(p, (x, y)) > r + epsilon:
            break
    else:
        ans = min(ans, r)
    
print(ans)


Measured memory_bytes: 5404
N = int(input())
H = list(map(int,input().split()))

ans = "Yes"

for i in range(N-1):
    if H[i+1] >= H[i] + 1:
        H[i+1] -= 1
    if not H[i+1] >= H[i]:
        ans = "No"

print(ans)

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

int main() {
	int k;
	cin >> k;
	int s[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	cout << s[k - 1] << endl;
	return 0;
}


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

int main() {
    int n;
    string s;
    cin >> s;
    n = s.length();
    for(int i=1;i<n;i++){
        if(s[i] == s[i-1]){
            cout << i << " " << i+1 << endl;
            return 0;
        }
        if(i>2&&s[i] == s[i-2]){
            cout << i-1 << " " << i+1 << endl;
            return 0;
        }
    }
    cout << "-1 -1" << endl;
	return 0;
}

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

int main(){
  int K, S;
  cin >> K >> S;
  int cnt = 0;
  for(int i = 0; i <= K; i++){
    for(int j = 0; j <= K; j++){
      if(i + j <= S && S <= i + j + K){
        cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;n>i;++i)
#define MOD 1000000007
using namespace std;
using ll=int64_t;
using pii=pair<int,int>;
using vi=vector<int>;
using VI=vector<ll>;
using vis=vector<string>;
using vvi=vector<vi>;
//最大公約数
int gcd(int a,int b){
    if(a%b==0)
    return b;
    return gcd(b,a%b);
}
//最小公倍数
int lcm(int a,int b){
   return a*b/gcd(a,b);
}
bool prime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0)
        return false;
    }
    return true;
}
int main(){
    vi a(5);
    rep(i,5)
    cin>>a.at(i);
    rep(i,5){
        if(a.at(i)==0){
            cout<<i+1<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	int hash[10001]={};
	int sum = 0;
	for(int i = 1; i< 100 ; i++){
		for(int j = 1; j < 100 ; j++){
			for(int k = 1 ; k < 100 ; k++){
				sum = i*i+j*j+k*k + i*j + j*k + i*k;
				if(sum >10000){
					break;
				}
				hash[sum]++;
			}
		}
	}
	for(int i = 1; i<=n;i++) cout << hash[i] << endl;
	return 0;
}


Measured memory_bytes: 3636
#標準入力
l = list(map(int,input().split()))

#リストを小さい順に並べる
l.sort()

#4辺を1人組とし、1組の辺が全て同じであれば"yes"でなければ"no"を出力する
if l[0] == l[1] == l[2] == l[3] and l[4] == l[5] == l[6] == l[7] and l[8] == l[9] == l[10] == l[11]:print("yes")
else:print("no")


Measured memory_bytes: 5596
#include<stdio.h>
#define MAX 101
int d[MAX];
int color[MAX];
int f[MAX];
int a[MAX][MAX];
int time;
void visit(int,int);
void dfs(int);
int main(){
  int n,i,j,c,r,tmp;

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      a[i][j]=0;
    }
  }
  for(j = 1;j<=n;j++){
    scanf("%d %d",&c,&r);
  
    for(i = 1;i<=r;i++){
      scanf("%d",&tmp);
      a[c][tmp] = 1;
    }
  }
 dfs(n);
  for(i = 1;i<=n;i++){
    printf("%d %d %d\n",i,d[i],f[i]);
    }

  
  return 0;
}

void dfs(int n){
  int i;
  for(i =1;i<=n;i++){
    color[i] =0;
  }
  time=0;
  for(i=1;i<=n;i++){
    if(color[i] ==0){
      visit(i,n);
    }
  }
}

void visit(int i,int n){
  int j;
  color[i] = 1;
  d[i] =++time;
  for(j =1;j<=n;j++){
    if(a[i][j] ==1 && color[j] ==0){
      visit(j,n);
    }
  }
  color[i] =2;
  f[i] =++time;
}



Measured memory_bytes: 2112
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		//電車
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		//バス
		int c = scanner.nextInt();
		int d = scanner.nextInt();
		int ans = Math.min(a, b);
		ans += Math.min(c, d);
		
		System.out.println(ans);
		
		scanner.close();

	}

}


Measured memory_bytes: 21716
M,D=map(int,input().split())

ans=0

if D>=22 and M>=4:
    for m in range(M+1)[4:]:
        for d in range(D+1)[22:]:
            if d//10>1 and d%10>1 and (d//10)*(d%10)==m:
                ans+=1

print(str(ans))

Measured memory_bytes: 39408
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
#define fi first
#define se second
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
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 int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


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

    ll n,k;
    cin>>n>>k;
    vll a(n+1);
    rep1(i,n){
        cin>>a[i];
    }

    int cnt=0;
    vector<pint> ed(n+1);

    int roop;

    int cur=a[1];
    ed[1].fi++;
    ed[1].se=cnt;

    rep1(i,n){
        cnt++;
        ed[cur].fi++;
        ed[cur].se=cnt;
        cur=a[cur];
        if(ed[cur].fi>=1){
            cnt++;
            roop = cnt - ed[cur].se;
            break;
        }
    }

    
    if(k <= cnt){
        int cur2=1;
        rep(i,k){
            cur2=a[cur2];
        }
        cout<<cur2<<endl;
        return 0;
    }else{
        k -= cnt;
        k%=roop;
        int cur2=1;
        rep(i,k+cnt){
            cur2=a[cur2];
        }
        cout<<cur2<<endl;
        return 0;
    }

}

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

int main() {

    int n, t, a, h;
    scanf("%d %d %d", &n, &t, &a);
    int idx = 1;
    scanf("%d", &h);
    double ondo = (double) t - h * 0.006;
    double nearest = fabs(a - ondo);

    //    printf("%d\n", n);
    //    printf("%f\n", ondo);
    //    printf("%f\n", nearest);

    for (int i = 1; i < n; i++) {
        scanf("%d", &h);
        ondo = (double) t - h * 0.006;
        //        printf("%f\n", ondo);

        if (fabs(a - ondo) < nearest) {
            nearest = fabs(a - ondo);
            idx = i + 1;
        }

    }

    printf("%d\n", idx);

    return 0;
}


Measured memory_bytes: 1728
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
	int n;
	cin >> n;
	int a, b, c, d;
	a = n / 1000;
	b = (n - a * 1000) / 100;
	c = (n - a * 1000 - b * 100) / 10;
	d = n % 10;
 
	if(a + b + c + d == 7){
		printf("%d+%d+%d+%d=7\n", a, b, c, d);
		return 0;
	}
	if(a + b + c - d == 7){
		printf("%d+%d+%d-%d=7\n", a, b, c, d);
		return 0;
	}
	if(a + b - c + d == 7){
		printf("%d+%d-%d+%d=7\n", a, b, c, d);
		return 0;
	}
	if(a + b - c - d == 7){
		printf("%d+%d-%d-%d=7\n", a, b, c, d);
		return 0;
	}
	if(a - b + c + d == 7){
		printf("%d-%d+%d+%d=7\n", a, b, c, d);
		return 0;
	}
	if(a - b + c - d == 7){
		printf("%d-%d+%d-%d=7\n", a, b, c, d);
		return 0;
	}
	if(a - b - c + d == 7){
		printf("%d-%d-%d+%d=7\n", a, b, c, d);
		return 0;
	}
	if(a - b - c - d == 7){
		printf("%d-%d-%d-%d=7\n", a, b, c, d);
		return 0;
	}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int dp[300][300],dp2[300][300],n;
int main(void){
    while(1){
    cin>>n;
    if(n==0)return 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j){
                dp[i][j]=1;
                cin>>dp2[i][j];
            }
            else {
                dp[i][j]=1e8;
                dp2[i][j]=0;
            }
        }
    }
    for(int j=1;j<n;j++){
        for(int i=0;i+j<n;i++){
            for(int k=i;i+j>k;k++){
                if(dp[i][k]==1&&dp[k+1][i+j]==1){
                    if(abs(dp2[i][k]-dp2[k+1][i+j])<=1)dp[i][i+j]=0;
                    else dp[i][i+j]=min(dp[i][i+j],2);
                }
                else if(dp[i][k]==0&&dp[k+1][i+j]==1){
                    dp[i][i+j]=min(dp[i][i+j],1);
                    dp2[i][i+j]=dp2[k+1][i+j];
                }
                 else if(dp[i][k]==1&&dp[k+1][i+j]==0){
                     dp[i][i+j]=min(dp[i][i+j],1);
                     dp2[i][i+j]=dp2[i][k];
                 }
                 else{
                     dp[i][i+j]=min(dp[i][i+j],dp[i][k]+dp[k+1][i+j]);
                 }
            }
        }
    }
    cout<<n-dp[0][n-1]<<endl;
    }
}



Measured memory_bytes: 3756
#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>;
const int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  vector<int> a(4);
  string now;
  rep(i, n) {
    cin >> now;
    if(now == "AC") a[0]++;
    if(now == "WA") a[1]++;
    if(now == "TLE") a[2]++;
    if(now == "RE") a[3]++;
  }
  cout << "AC x " << a[0] <<endl;
  cout << "WA x " << a[1] <<endl;
  cout << "TLE x " << a[2] <<endl;
  cout << "RE x " << a[3] <<endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int H, W;
	cin >> H >> W;

	vector<vector<int>> grid(H, vector<int>(W));
	int before_i;
	int before_j;
	bool flag = false;
	queue<tuple<int, int, int, int>> ans;
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			cin >> grid[i][j];
		}
	}

	for (int i = 0; i < H; i++)
	{
		if (i & 1)
			for (int j = 0; j < W; j++)
			{
				if (flag)
					ans.push(make_tuple(before_i + 1, before_j + 1, i + 1, j + 1));
				if (grid[i][j] & 1)
					flag = !flag;
				before_i = i;
				before_j = j;
			}
		else
			for (int j = W - 1; 0 <= j; j--)
			{
				if (flag)
					ans.push(make_tuple(before_i + 1, before_j + 1, i + 1, j + 1));
				if (grid[i][j] & 1)
					flag = !flag;
				before_i = i;
				before_j = j;
			}
	}

	cout << ans.size() << endl;
	for (; !ans.empty();)
	{
		auto t = ans.front();
		ans.pop();
		cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << " " << get<3>(t) << endl;
	}
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

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

int main()
{
	int n, t[100], m, p, x, sum[100];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}
	cin >> m;
	for (int i = 0; i < m; i++) {
		sum[i] = 0;
		cin >> p;
		cin >> x;
		for (int j = 0; j < n; j++) {
			if (j != p - 1) {
				sum[i] += t[j];
			}
			else {
				sum[i] += x;
			}
		}
	}
	for (int i = 0; i < m; i++) {
		cout << sum[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
    for(auto &e:t) fill_v(e,v);
}

template<ll mod = static_cast<ll>(1e9+7)>
class mint{
    ll _n;

    /* modの範囲に収めた数を返す */
    ll getModV(ll n) {
        while(n < 0) n += mod;

        return n % mod;
    }

public:
    mint(ll n): _n{n} {
        _n = getModV(_n);
    }

    mint(){_n = 0;}

    mint& operator=(const mint& v) {
        _n =  v._n;
        return *this;
    }

    mint& operator+=(const mint& v){
        _n = getModV(_n + v._n);
        return *this;
    }

    friend mint operator+(const mint& v, const mint& u) {
        return mint(v) += u;
    }

    mint& operator-=(const mint& v) {
        _n = getModV(_n - v._n);
        return *this;
    }

    friend mint operator-(const mint& v, const mint& u) {
        return mint(v) -= u;
    }

    mint& operator*=(const mint& v) {
        _n = getModV(_n * v._n );
        return *this;
    }

    friend mint operator*(const mint& v, const mint& u) {
        return mint(v) *= u;
    }

    mint& operator/=(const mint& v) {
        return *this *= getIndV(v);
    }

    friend mint operator/(const mint& v, const mint& u) {
        return mint(v) /= u;
    }

    friend bool operator<(const mint& v, const mint& u) {
      return v._n < u._n;
    }

    friend bool operator<=(const mint& v, const mint& u) {
      return v._n <= u._n;
    }
    
    friend ostream& operator<<(ostream& out, const mint& v) {
        return out << v._n;
    }

    friend istream& operator>>(istream& is, mint& v) {
      is >> v._n;
      return is;
    }

    /* 逆元 */
    friend mint getIndV(const mint& v) {
        return mpow(v, mod - 2);
    }

    friend mint mpow(const mint& v, const int& n) {
        if(n == 0LL) return mint(1LL);
        else{
            if(n % 2) return mpow(v * v, n / 2) * v;
            else return mpow(v * v, n / 2);
        }
    }
};

int main() {
  constexpr int mod = 1e9 + 7, lim = 1e6;
  using mint = mint<mod>;
  int h, w, a, b; cin >> h >> w >> a >> b;

  vector<mint> fac(lim+1, 1), dfac(lim+1, 1);
  for(int i=1; i<=lim; i++) fac[i] = fac[i-1] * mint(i);

  dfac[lim] = getIndV(fac[lim]);
  for(int i=lim-1; i>=1; i--) dfac[i] = dfac[i+1] * mint(i+1);

  function<mint(int, int)> comb = [&](int fh, int fw){
    mint ret = fac[fh + fw] / fac[fh] / fac[fw];
    return ret;
  };

  mint ans = 0;
  for(int fh = 0; fh < h - a; fh++){
    mint ret = comb(fh, b - 1) * comb(h - fh - 1, w - b - 1);
    ans += ret;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 15872
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

MOD = 998244353
N, S = lr()
A = lr()
dp = [0] * (S+1)
answer = 0
for a in A:
    dp[0] += 1 # Lの数は１個ずつ加わる
    prev = dp[:]
    for i in range(S-a+1):
        dp[i+a] += prev[i]
    answer += dp[-1] # その位置をRとした時

print(answer % MOD)
# 26


Measured memory_bytes: 82268
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    ll r=0,t;
    if(C<D){
        t=C;
        C=D;
        D=t;
    }
    ll p=C,q=D;
    while(p%q!=0){
        r=p%q;
        p=q;
        q=r;
    }
    ll E=C*D/q;
    cout << (B-A+1)-(B/C-(A-1)/C)-(B/D-(A-1)/D)+(B/E-(A-1)/E);
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		final int N = sc.nextInt();
		final int M = sc.nextInt();
		sc.nextLine();

		if (N >= M) {
			System.out.println("0");
			return;
		}

		final int[] Xs = new int[M];
		int min = Integer.MAX_VALUE;
		int max = -1;
		for (int i = 0; i < M; i++) {
			final int X = sc.nextInt();
			Xs[i] = X;

			if (X > max) {
				max = X;
			}

			if (X < min) {
				min = X;
			}
		}

		Arrays.sort(Xs);

		final Map<Integer, Integer> dist = new HashMap<>();
		for (int i = 0; i < M - 1; i++) {
			dist.put(i, Math.abs(Xs[i + 1] - Xs[i]));
		}
		List<Map.Entry<Integer, Integer>> sortedDist = dist.entrySet().stream()
				.sorted(Map.Entry.comparingByValue(new Comparator<Integer>() {

					@Override
					public int compare(Integer arg0, Integer arg1) {
						return Integer.compare(arg1, arg0);
					}

				})).collect(Collectors.toList());

		final int[] pos = new int[N];
		pos[0] = Xs[0];

		for (int i = 1; i < N; i++) {
			final Map.Entry<Integer, Integer> e = sortedDist.get(i - 1);
			pos[i] = Xs[e.getKey() + 1];
		}

		Arrays.sort(pos);
		
		int posCounter = 0;
		int currentStone = pos[0];
		int op = 0;
		for (int i = 0; i < M; i++) {
			final int X = Xs[i];
			if (X == currentStone) {
				continue;
			}

			if (posCounter == N - 1) {
				op += X - currentStone;
				currentStone = X;
			} else {
				final int rightStone = pos[posCounter + 1];
				if (X >= rightStone) {
					posCounter++;
					op += X - rightStone;
					currentStone = X;
				} else {
					op += X - currentStone;
					currentStone = X;
				}
			}
		}

		System.out.println(op);
	}

}

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


using namespace std;

int main(){

	long long N, a;

	cin >> N;
	bool win = false;
	for(long long i = 0; i<N; i++){
		cin >> a;
		if( a % 2 == 1){
			win = true;
		}
	}

	if(win == true){
		cout << "first" << endl;
	} else {
		cout << "second" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long     ll;
#define fr            first
#define sc            second
#define com(i,n)      for(int i=0;i<n;i++)
#define dom(i,n)      for(int i=1;i<=n;i++)
#define mom(i,n)      for(int i=n;i>=0;i--)
#define sortI(a,n)    sort(a,a+n)
#define sortD(a,n)    sort(a,a+n,greater<int>())
#define sortvi(a)     sort(a.begin(),a.end())
#define sortvd(a)     sort(a.begin(),a.end(),greater<int>())
#define sumall(a,x)   accumulate(a.begin(),a.end(),x)
#define pi            3.14159265358979323846264338327950
using namespace std;
map<ll,ll>mp;
int main()
{
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double ans,con,x,y;
    x=2.00*pi*(h/12.0+m/720.0);
    y=2.00*pi*(m/60.0);
    con=fabs(x-y);
    ans=sqrt(a*a+b*b-2*a*b*cos(con));
    cout <<fixed << setprecision(20)<< ans << endl;
}


Measured memory_bytes: 4204
#include <bits/stdc++.h>
using namespace std;
// Creating shortcut for an integer pair 
typedef  pair<int, int> iPair; 
  
// Structure to represent a graph 
struct Graph 
{ 
    int V, E; 
    vector< pair<int, iPair> > edges; 
  
    // Constructor 
    Graph(int V, int E) 
    { 
        this->V = V; 
        this->E = E; 
    } 
  
    // Utility function to add an edge 
    void addEdge(int u, int v, int w) 
    { 
        edges.push_back({w, {u, v}}); 
    } 
  
    // Function to find MST using Kruskal's 
    // MST algorithm 
    long long kruskalMST(); 
}; 
  
// To represent Disjoint Sets 
struct DisjointSets 
{ 
    int *parent, *rnk; 
    int n; 
  
    // Constructor. 
    DisjointSets(int n) 
    { 
        // Allocate memory 
        this->n = n; 
        parent = new int[n+1]; 
        rnk = new int[n+1]; 
  
        // Initially, all vertices are in 
        // different sets and have rank 0. 
        for (int i = 0; i <= n; i++) 
        { 
            rnk[i] = 0; 
  
            //every element is parent of itself 
            parent[i] = i; 
        } 
    } 
  
    // Find the parent of a node 'u' 
    // Path Compression 
    int find(int u) 
    { 
        /* Make the parent of the nodes in the path 
           from u--> parent[u] point to parent[u] */
        if (u != parent[u]) 
            parent[u] = find(parent[u]); 
        return parent[u]; 
    } 
  
    // Union by rank 
    void merge(int x, int y) 
    { 
        x = find(x), y = find(y); 
  
        /* Make tree with smaller height 
           a subtree of the other tree  */
        if (rnk[x] > rnk[y]) 
            parent[y] = x; 
        else // If rnk[x] <= rnk[y] 
            parent[x] = y; 
  
        if (rnk[x] == rnk[y]) 
            rnk[y]++; 
    } 
}; 
  
 /* Functions returns weight of the MST*/ 
  
long long Graph::kruskalMST() 
{ 
    long long mst_wt = 0; // Initialize result 
  
    // Sort edges in increasing order on basis of cost 
    sort(edges.begin(), edges.end()); 
  
    // Create disjoint sets 
    DisjointSets ds(V); 
  
    // Iterate through all sorted edges 
    vector< pair<int, iPair> >::iterator it; 
    for (it=edges.begin(); it!=edges.end(); it++) 
    { 
        int u = it->second.first; 
        int v = it->second.second; 
  
        int set_u = ds.find(u); 
        int set_v = ds.find(v); 
  
        // Check if the selected edge is creating 
        // a cycle or not (Cycle is created if u 
        // and v belong to same set) 
        if (set_u != set_v) 
        { 
  
            // Update MST weight 
            mst_wt += it->first; 
  
            // Merge two sets 
            ds.merge(set_u, set_v); 
        } 
    } 
  
    return mst_wt; 
} 
int main() {
  long long N,answer=0;
  cin >> N;
  pair<int,int> x[N],y[N];
  Graph G(N,2*N-2);
  for (int i = 0; i < N; i++) {
    cin >> x[i].first >> y[i].first;
    x[i].second = i;
    y[i].second = i;
  }
  sort(x,x+N);
  sort(y,y+N);
  for (int i = 1; i < N; i++) {
    G.addEdge(x[i-1].second,x[i].second,x[i].first-x[i-1].first);
    G.addEdge(y[i-1].second,y[i].second,y[i].first-y[i-1].first);
  }
  cout << G.kruskalMST();
}

Measured memory_bytes: 7976
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int n,m,ans;
vector<vi> e;
bool u[100];

void rec(int c,int use)
{
	if(use>=ans)return;
	
	int p=0;
	for(;p<n;p++)
	{
		if(u[p])continue;
		bool cand=0;
		fr(i,e[p])
		{
			if(u[*i])goto NEXT;
			if(*i>=c)cand=1;
		}
		if(!cand)return; else break;
		NEXT:;
	}
	if(p==n)
	{
		ans=min(ans,use); return;
	}
	if(c>=n)return;
	
	rec(c+1,use);
	u[c]=1; rec(c+1,use+1); u[c]=0;
}
int main()
{
	while(scanf("%d%d",&n,&m),n)
	{
		assert(n<100&&m<5000);
		e.clear(); e.resize(n);
		rep(i,n)u[i]=0;
		
		rep(i,m)
		{
			int x,y; scanf("%d%d",&x,&y);
			e[x].pb(y); e[y].pb(x);
		}
		ans=n; rec(0,0);
		printf("%d\n",ans);
	}
	return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v),end()
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;

template<typename A,typename B> inline void chmin(A &a,B b){if(a>b) a=b;}
template<typename A,typename B> inline void chmax(A &a,B b){if(a<b) a=b;}
//-----------------------------------------------------------------------

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


    while(true)
    {
        int n,p,cnt[50]={0};
        cin>>n>>p;
        if(n==0 && p==0) break;
     
        int t=p;
        while(true)
        {
            REP(i,n){
                if(t>0) t--,cnt[i]++;
                else t+=cnt[i],cnt[i]=0;
                if(t==0 && cnt[i]==p){
                    cout<<i<<endl;
                    goto g;
                }
            }
        }
        g:;
    }

}

Measured memory_bytes: 3012
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
vector<int>r,g,b;
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n;
		cin >> n ;
		string s;
		cin>>s;
		fn{
			if(s[i]=='R'){
				r.pb(i);
			}
			else if(s[i]=='G'){
				g.pb(i);
			}
			else
				b.pb(i);
		}
		sort(all(r));
		sort(all(b));
		sort(all(g));
		int ans =0 ;
		for(auto x : r){
			int cnt =0 ,cnt2 =0;
			map<int,int>mp;
			for(auto i : g){
				if(i>x)break;
				cnt++;
				mp[x-i]++;
			}	
			int com = 0;
			for(int i = b.size()-1;i>=0;i--){
				
				if(b[i]<x)break;
				if(mp[b[i]-x])com++;
				cnt2++;
			}
			ans+=cnt2*cnt - com;
			cnt2 =0,cnt =0 ;
			mp.clear();
			for(auto i : b){
				if(i>x)break;
				cnt++;
				mp[x-i]++;
			}	
			com = 0;
			for(int i = g.size()-1;i>=0;i--){
				
				if(g[i]<x)break;
				if(mp[g[i]-x])com++;
				cnt2++;
			}
			ans+=cnt2*cnt - com;
		}
		for(auto x : g){
			int cnt =0 ,cnt2 =0;
			map<int,int>mp;
			for(auto i : r){
				if(i>x)break;
				cnt++;
				mp[x-i]++;
			}	
			int com = 0;
			for(int i = b.size()-1;i>=0;i--){
				
				if(b[i]<x)break;
				if(mp[b[i]-x])com++;
				cnt2++;
			}
			ans+=cnt2*cnt - com;
			cnt2 =0,cnt =0 ;
			mp.clear();
			for(auto i : b){
				if(i>x)break;
				cnt++;
				mp[x-i]++;
			}	
			com = 0;
			for(int i = r.size()-1;i>=0;i--){
				
				if(r[i]<x)break;
				if(mp[r[i]-x])com++;
				cnt2++;
			}
			ans+=cnt2*cnt - com;
		}
		for(auto x : b){
			int cnt =0 ,cnt2 =0;
			map<int,int>mp;
			for(auto i : g){
				if(i>x)break;
				cnt++;
				mp[x-i]++;
			}	
			int com = 0;
			for(int i = r.size()-1;i>=0;i--){
				
				if(r[i]<x)break;
				if(mp[r[i]-x])com++;
				cnt2++;
			}
			ans+=cnt2*cnt - com;
			cnt2 =0,cnt =0 ;
			mp.clear();
			for(auto i : r){
				if(i>x)break;
				cnt++;
				mp[x-i]++;
			}	
			com = 0;
			for(int i = g.size()-1;i>=0;i--){
				
				if(g[i]<x)break;
				if(mp[g[i]-x])com++;
				cnt2++;
			}
			ans+=cnt2*cnt - com;
		}
		cout <<ans;


	
	
	}
	cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

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

constexpr int MOD = 1000000007;

class mint {
  int n;

 public:
  mint(int n_ = 0) : n(n_) {}
  explicit operator int() { return n; }
  friend mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
  friend mint operator+(mint a, mint b) {
    int x = a.n + b.n;
    return x - (x >= MOD) * MOD;
  }
  friend mint operator-(mint a, mint b) {
    int x = a.n - b.n;
    return x + (x < 0) * MOD;
  }
  friend mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
  friend mint &operator+=(mint &a, mint b) { return a = a + b; }
  friend mint &operator-=(mint &a, mint b) { return a = a - b; }
  friend mint &operator*=(mint &a, mint b) { return a = a * b; }
  friend bool operator==(mint a, mint b) { return a.n == b.n; }
  friend bool operator!=(mint a, mint b) { return a.n != b.n; }
  friend istream &operator>>(istream &i, mint &a) { return i >> a.n; }
  friend ostream &operator<<(ostream &o, mint a) { return o << a.n; }
};

mint modpow(mint a, long long b) {
  mint res = 1;
  while (b > 0) {
    if (b & 1) res *= a;
    a *= a;
    b >>= 1;
  }
  return res;
}

mint modinv(mint n) {
  int a = (int)n, b = MOD;
  int s = 1, t = 0;
  while (b != 0) {
    int q = a / b;
    a -= q * b;
    s -= q * t;
    swap(a, b);
    swap(s, t);
  }
  return s >= 0 ? s : s + MOD;
}

mint C(int n, int r) {
  mint res = 1;
  rep(i, r) {
    res *= n - i;
    res *= modinv(i + 1);
  }
  return res;
}

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  mint ans = modpow(2, n) - 1;
  ans -= C(n, a);
  ans -= C(n, b);
  cout << ans << endl;
}


Measured memory_bytes: 3636
#解説を見て
 # 初期入力
K =int(input())

# 最小約数(mathは3.5以降) 
from functools import reduce
import math #(2020-0405  fractions→math)
def lcm_base(x, y):
    return  math.gcd(x, y) # 「//」はフロートにせずにintにする
def lcm_list(numbers):
    return reduce(lcm_base, numbers)

#
saisyou_koyakusu =[]
saisyou_koyakusu_2 =[]
for i in range(1,K+1):
    for j in range(1,K+1):
        saisyou_koyakusu.append(lcm_base(i,j))
for j in saisyou_koyakusu:
    for i in range(1,K+1):
        saisyou_koyakusu_2.append(lcm_base(j,i))

    
print(sum(saisyou_koyakusu_2))

Measured memory_bytes: 72164
#include <bits/stdc++.h>
#define rep(i, n) for (long long int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
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 long long INF = 1LL << 60;
int cnt = 0;
int main()
{
    int r, g, b;
    cin >> r >> g >> b;
    int x = 100 * r + 10 * g + b;
    if (x % 4 == 0)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 3560
#include<iostream>
#include<set>
#include<vector>

int main(void){
    int n, q, t;
    std::string s;
    std::vector<std::set<int>> sc(26);
    std::cin >> n >> s >> q;
    for(int i = 0; i < n; i++){
        sc[s[i] - 'a'].insert(i);
    }
    for(int i = 0; i < q; i++){
        std::cin >> t;
        if(t == 1){
            int i;
            char c;
            std::cin >> i >> c;
            --i;
            sc[s[i] - 'a'].erase(i);
            sc[c - 'a'].insert(i);
            s[i] = c;

        }
        else{
            int l, r;
            int ans = 0;
            std::cin >> l >> r;
            l--;
            for(int j = 0; j < 26; j++){
                auto cur = sc[j].lower_bound(l);
                if(cur != sc[j].end() && *cur < r){
                    ans++;
                }
            }
            std::cout << ans << std::endl;
        }
    }
    return 0;
}

Measured memory_bytes: 27208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef tuple<int,int,int> tp;

int main(){
	int N;
	cin >> N;
	vector<int> L(N);
	for(int i=0; i<N; i++)cin >> L[i];
	sort(L.begin(),L.end());

	int ans = 0;
	for(int i=0; i<N; i++){
		for(int j=i+1; j<N; j++){
			int a = L[i],  b = L[j];
			int k = lower_bound(L.begin()+j,L.end(),a+b)-L.begin();
			ans += max(k-(j+1), 0);
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;



signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll n=s.size();
    string t=s.substr(0,n-1);
    if(s[n-1]!='0'){
        prt(-1)return 0;
    }
    string u=t;
    reverse(u.begin(), u.end());
    if(u!=t){
        prt(-1)return 0;
    }
    if(u[0]!='1'){
        prt(-1)return 0;
    }
    vector<P> ans(0);
    ll root=2;
    ans.emplace_back(P(1,2));
    for(ll i=1;i<=n-2;++i){
        if(t[i]=='1'){
            ans.emplace_back(P(root,i+2));
            root=i+2;
        }else {
            ans.emplace_back(P(root,i+2));
        }
    }
    for(auto p: ans){
        cout<<p.first<<" "<<p.second<<endl;
    }fl

    
    return 0;
}


Measured memory_bytes: 3392
from functools import reduce

def main():
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    a, b, c = (_ for _ in input().split())
    if b == '+':
        print(int(a)+int(c))
    else:
        print(int(a)-int(c))
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
//
// Created by 伊東麻沙美 on 2019/10/22.
//

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


int main(){

    int p,q,r;
    cin>>p>>q>>r;

    int min;
    int num1,num2,num3;

    num1 = p+q;
    num2 = q+r;
    num3 = r+p;

    min = num1;
    if(min>num2){
        min = num2;
    }
    if(min>num3){
        min = num3;
    }
    cout<<min;
    //cin>>a>>b>>x;
    //scanf("%d%s%d",&i,&x,&j);


       // printf("%d",i+j);
       //cout<<i+j<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    int h,w;
    char s[105][105];
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++) cin>>s[i][j];
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<2;j++){
            for(int k=0;k<w;k++) cout<<s[i][k];
            cout<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
	int count=1;
	int a[10000];
	while (true) {
		cin >> a[count];
		if (a[count] == 0) {
			break;
		}
		count++;
	}
	for (int i = 1; i < count; i++) {
		cout << "Case " << i << ": " << a[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
int db[1000000],n;
int main(){
	for(int i=1;i<=400;i++){
		for(int j=1;j<=400;j++){
			for(int k=1;k<=400;k++){
				int o=i*i+j*j+k*k+i*j+i*k+j*k;
				if(o<=20000)db[o]++;
			}
		}
	}
	cin>>n;
	for(int i=1;i<=n;i++){
		cout<<db[i]<<endl;
	}
	return 0;
}

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


int main(){
    int n;
    bool flag=true;
    int pre=-100000;
    cin >> n;
    vector<ll>hei(n);
    rep(i,n) cin >> hei[i];
    rep(i,n){
        if(pre<=hei[i]-1) pre=hei[i]-1;
        else if(pre<=hei[i]) pre=hei[i];
        else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
      string[] input = Console.ReadLine().Split();
      int x = int.Parse(input[0]);
      int a = int.Parse(input[1]);
      int b = int.Parse(input[2]);
      if (Math.Abs(x-a)>Math.Abs(x-b))
      {
        Console.WriteLine("B");
      }
      else
      {
        Console.WriteLine("A");
      }
    }
}


Measured memory_bytes: 27432
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<map>
#include<set>
using namespace std;
string s, t;
set<string> S;
 
void Work()
{
    int lens = s.size();
    int lent = t.size();
    for(int i = 0; i < lens; i++)
    {
        if(s[i] == '?' || s[i] == t[0])
        {
            string tmp = s;              
            for(int j = 0; j < i; j++)
                if(tmp[j] == '?')
                    tmp[j] ='a';    
            bool can = false;
            for(int j = 0; j < lent; j++)    
            {
 
                if(tmp[i+j]!= '?' && tmp[i+j] != t[j])  
                    break;
                tmp[i+j] = t[j];
                if(j == lent - 1) can = true;
            }
            if(can)
            {
                for(int j = i + lent; j < lens; j++) if(tmp[j] == '?') tmp[j] = 'a';//处理匹配后的字符
                S.insert(tmp);  
            }
        }
    }
    if(S.size() == 0) cout << "UNRESTORABLE" << endl;
    else cout << *S.begin() << endl;
}
int main()
{
    cin >> s >> t;
    Work();
}


Measured memory_bytes: 256
<?php
$bitCoinLate = 380000.0;
$sum = 0;
$N = fgets(STDIN);
for($i=0; $i<$N; $i++){
  fscanf(STDIN,"%e %s",$x,$u);
  if($u === "JPY"){
    $sum += $x;
  }elseif($u === "BTC"){
    $sum += $x*$bitCoinLate;
  }else{
    //必要のないコード
    echo "error";
    exit(1);
  }
}
echo $sum;

Measured memory_bytes: 3576
# Aizu Problem ITP_1_4_B: Circle
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")

pi = math.pi
r = float(input())
print("%.6f %.6f" % (pi * r**2, 2 * pi * r))

Measured memory_bytes: 7556
pub struct ProconReader<R: std::io::Read> {
    reader: R,
}

impl<R: std::io::Read> ProconReader<R> {
    pub fn new(reader: R) -> Self {
        Self { reader }
    }
    pub fn get<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&byte| byte == b' ' || byte == b'\n' || byte == b'\r')
            .take_while(|&byte| byte != b' ' && byte != b'\n' && byte != b'\r')
            .collect::<Vec<_>>();
        std::str::from_utf8(&buf)
            .unwrap()
            .parse()
            .ok()
            .expect("Parse Error.")
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut rd = ProconReader::new(stdin.lock());

    let s: String = rd.get();
    let t: String = rd.get();

    let s = s.chars().collect::<Vec<_>>();
    let t = t.chars().collect::<Vec<_>>();
    let mut ans = t.len();
    for i in 0..s.len() {
        if i + t.len() > s.len() {
            break;
        }
        let mut cnt = 0;
        for j in 0..t.len() {
            if s[i + j] != t[j] {
                cnt += 1;
            }
        }
        ans = std::cmp::min(ans, cnt);
    }
    println!("{}", ans);
}

Measured memory_bytes: 2156
n = int(input())
t, a = [int(x) for x in input().split()]
locations =[int(x) for x in input().split()]
# print(min([(i+1,abs(a - (t - x * 6e-3))) for i, x in enumerate(locations)],key=(lambda j:j[1]))[0])
diff = [abs(a - (t - x * 6e-3)) for x in locations]
print(diff.index(min(diff))+1)


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

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

  ll N; cin >> N;
  ll K; cin >> K;
  vector<ll> H(N); for (ll i = 0; i < N; i++) cin >> H[i];
  sort(H.rbegin(), H.rend());

  ll ans = 0;
  for (int i = K; i < N; i++) {
    ans += H[i];
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<ll> par;
//     vector<ll> siz;
    
//     UnionFind(ll N): par(N), siz(N,1) {
//         for (ll i=0;i<N;i++) par[i] = i;
//     }

//     ll root(ll x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         if (rx == ry) return;
//         // if (siz[rx] < siz[ry]) swap(rx,ry);
//         par[rx] = ry;
//         siz[ry] += siz[rx];
//     }

//     bool same(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         return rx == ry;
//     }

//     ll size(ll x) {
//         return siz[root(x)];
//     }
// };

//     vector<ll> par;
//     vector<ll> siz;
    
//     UnionFind(ll N): par(N), siz(N,1LL) {
//         for (ll i=0;i<N;i++) par[i] = i;
//     }

//     ll root(ll x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//         siz[ry] += siz[rx];
//     }

//     bool same(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         return rx == ry;
//     }

//     ll size(ll x) {
//         return siz[root(x)];
//     }
// };

int main(void) {
    int N, M;
    vector<ll> H(100010);
    vector<multiset<int>> S(100010);
    cin >> N >> M;
    for (int i=1;i<=N;i++) cin >> H[i];
    for (int j=0;j<M;j++) {
        int a, b;
        cin >> a >> b;
        S[a].insert(b);
        S[b].insert(a);
    }

    int res = 0;
    for (int i=1;i<=N;i++) {
        multiset<ll> V;
        for (auto itr: S[i]) {
            V.insert(H[itr]);
        }
        if (V.empty()) res++;
        else if (V.lower_bound(H[i]) == V.end()) res++; 
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 22016
import java.util.*;
import java.io.*;

public class Main {
    public static void changeLastLetter(String original){
    	String pre = original.substring(0,original.length()-1);
    	for(char x=(char)(original.charAt(original.length()-1)+1);x<='z';x++){
    	    if(!pre.contains(Character.toString(x))){
    	    	System.out.println(pre+x);
    	    	System.exit(0);
    	    }
    	}
    }
    public static void addOneLetter(String original){
    	for(char x='a';x<='z';x++){
    	    if(!original.contains(Character.toString(x))){
    	    	System.out.println(original+x);
    	    	System.exit(0);
    	    }
    	}
    }
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        
        addOneLetter(S);
        
        while(!S.equals("")){
        	changeLastLetter(S);
        	
        	S = S.substring(0,S.length()-1);
        	
        }
        System.out.println(-1);
    }
}

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

int w,h,cnt,cheak[124][124];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
char mas[124][124];

void fbs(int x,int y,char c);
void Set(void);

main(){
  while(1){
    cin >> h >> w;
    if(h==0 && w==0){
      break;
    }
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> mas[i][j];
      }
    }
    Set();
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(cheak[i][j]==0){
	  fbs(j,i,mas[i][j]);
	  cnt++;
	}
      }
    }
    cout << cnt << endl;
  }
}

void fbs(int x,int y,char c){
  cheak[y][x]=1;
  for(int i=0;i<4;i++){
    int nx=dx[i]+x;
    int ny=dy[i]+y;
    if(nx>=0 && nx<w && ny>=0 && ny<h && mas[ny][nx]==c && cheak[ny][nx]==0){
      fbs(nx,ny,c);
    }
  }
}

void Set(void){
  cnt=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cheak[i][j]=0;
    }
  }
}

Measured memory_bytes: 1692
#include<cstdio>
#define ll long long 

const int N=1e7+7;
int b[N];
int n,t;

int main()
{
	ll x;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&x);
		b[x%N]++;
	}
	scanf("%d",&t); if(t>n){printf("NO"); return 0;}
	for(int i=1;i<=t;i++){
		scanf("%lld",&x); x=x%N;
		b[x]--;
		if(b[x]<0){
			printf("NO"); return 0;
		}
	}
	printf("YES");
	return 0;
}

Measured memory_bytes: 39168
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;
    cin >> n;
    vector<ll> X,Y,h;
    rep(i,n){
        int a,b,c;
        cin >> a >> b >> c;
        if(c==0) continue;
        X.push_back(a);
        Y.push_back(b);
        h.push_back(c);
    }
    if(h.size()==1){
        cout << X[0] << " " << Y[0] << " " << h[0] << endl;
        return 0;
    }
    for(int x=0;x<=100;x++){
        for(int y=0;y<=100;y++){
            ll v = h[0] + abs(X[0] - x) + abs(Y[0] - y);
            v = max(v,0LL);
            //cout << "v is " << v << endl;
            bool ok = true;
            for(int k=1;k<h.size();k++){
                ll vh = v - abs(X[k] - x) - abs(Y[k] - y);
                vh = max(vh,0LL);
                //cout << "vh is " << vh << endl;
                if(vh==h[k]){
                    continue;
                }else{
                    ok = false;
                    break;
                }
            }
            if(ok){
                cout << x << " " << y << " " << v << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
using System;

namespace _094_CalculationofArea
{
	class Program
	{
		static void Main ( string[] args )
		{
			const decimal tsubo = 3.305785m;

			decimal[] edge = Array.ConvertAll (Console.ReadLine ().Split (' '), decimal.Parse);

			Console.WriteLine (edge[0] * edge[1] / tsubo);
		}
	}
}

Measured memory_bytes: 9392