akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

int main(void){


  int n,t,a;
  std::cin >> n >> t >> a;
  int h[n];

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

  double bestdiff = 1e8;
  int bestid = -1;
  for(int i=0; i<n; i++){
    double temp = std::abs(t-h[i]*0.006-a);
    if (bestdiff > temp){
      bestdiff = temp;
      bestid = i;
    }
  }

  std::cout << (bestid+1) << std::endl;
  return 0;
}


















Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
#define N 5050
const int mod=1e9+7;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int p[N],n,s[N],vis[N],tot,nd,dp[N],ans,fac[N],pw[N];
vector<int> G[N];
#define ck(x) (x>=mod?x-mod:x)
void dfs(int u){
	vis[u]=1;
	++s[tot];
	for(auto v:G[u]){
		++nd;
		if(!vis[v])dfs(v);
	}
}
int main(){
	n=read();
	for(int i=1;i<=n;++i){
		p[i]=read();
		if(~p[i]){
			G[p[i]].push_back(i);
			G[i].push_back(p[i]);
		}
	}
	pw[0]=fac[0]=1;
	for(int i=1;i<=n;++i){
		pw[i]=1LL*pw[i-1]*(n-1)%mod;
		fac[i]=1LL*fac[i-1]*i%mod;
	}
	int tmp=n;
	for(int i=1;i<=n;++i){
		if(!vis[i]){
			++tot;nd=0;
			dfs(i);
			if(nd==(s[tot]<<1)){
				s[tot]=0;
				--tmp,--tot;
			}
		}
	}
	ans=1LL*tmp*pw[tot]%mod;
	dp[0]=1;
	for(int i=1;i<=tot;++i){
		for(int j=i;j>=1;--j){
			dp[j]=(dp[j]+1LL*dp[j-1]*s[i]%mod)%mod;
		}
	}
	for(int i=2;i<=tot;++i){
		ans=(ans-1LL*dp[i]*pw[tot-i]%mod*fac[i-1]%mod+mod)%mod;
	}
	for(int i=1;i<=tot;++i){
		ans=(ans-1LL*(s[i]-1)*pw[tot-1]%mod+mod)%mod;
	}
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 3992
#include <stdio.h>

int field[100][100][3];

int main(void)
{
    int N, M, D;
    char in_str[101];
    int n;
    int i, j;
    
    scanf("%d%d%d", &N, &M, &D);
    
    for (i = 0; i < N; i++){
        scanf("%s", in_str);
        for (j = 0; j < M; j++){
            if (in_str[j] == '#'){
                field[i][j][0] = 1;
            }
        }
    }
    
    for (i = 0; i < N; i++){
        n = 0;
        for (j = M - 1; j >= 0; j--){
            if (field[i][j][0] == 0){
                n++;
                field[i][j][1] = n;
            }
            else {
                n = 0;
            }
        }
    }
    
    for (j = 0; j < M; j++){
        n = 0;
        for (i = N - 1; i >= 0; i--){
            if (field[i][j][0] == 0){
                n++;
                field[i][j][2] = n;
            }
            else {
                n = 0;
            }
        }
    }
#if 0
    for (i = 0; i < N; i++){
        for (j = 0; j < M; j++){
            printf("[%d,%d]", field[i][j][1], field[i][j][2]);
        }
        printf("\n");
    }
#endif
    n = 0;
    for (i = 0; i < N; i++){
        for (j = 0; j < M; j++){
            if (field[i][j][1] >= D){
                n++;
            }
            if (field[i][j][2] >= D){
                n++;
            }
        }
    }

    printf("%d\n", n);
    
    return (0);
}








Measured memory_bytes: 2080
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    ll r, d, x; cin >> r >> d >> x;
    ll pre = x;
    REP(i, 10){
        pre = r * pre - d;
        cout << pre << endl;
    }
}

Measured memory_bytes: 256
N, M = map(int, input().split())

MOD = int(1e9) + 7

tmp = abs(N - M)
if tmp >= 2:
    print(0)
else:
    ans = 2
    if tmp == 1:
        ans = 1
    for i in range(2, N+1):
        ans *= i
        ans = ans % MOD
    for i in range(2, M+1):
        ans *= i
        ans = ans % MOD
    print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    ld pi = 3.1415926535;
    ld r;
    cin >> r;
    cout << sp(10) << 2*r*pi << endl;
}

Measured memory_bytes: 3784
#include <iostream>
using namespace std;
int main(void){
  int w,h,x,y,r;
  cin>>w>>h>>x>>y>>r;
  bool flg=true;
  flg=x-r>=0?flg:false;
  flg=x+r<=w?flg:false;
  flg=y-r>=0?flg:false;
  flg=y+r<=h?flg:false;
  if(flg) cout<<"Yes"<<endl;
  else  cout << "No" <<endl;
  return 0;
}



Measured memory_bytes: 3096
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <deque>

#include <bits/stdc++.h>

using namespace std;

struct Point {
    Point() {x=0,y=0;}
    Point(int _x,int _y){x  =_x,y=_y;}

    int x,y;
};

// 重载相应的比较运算符
bool operator < (Point a, Point b)
{
    return a.x == b.x ? a.y < b.y : a.x < b.x;
}
long long gcd(long a, long b) {
    return b ? gcd(b, a % b) : a;
}

int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};
char dc[] = {'R', 'L', 'D', 'U'};
char dcc[] = {'L', 'R', 'U', 'D'};

int k,n,m;

void solvee(){
    cin >> n >> m;
    vector<long long> c(n+1);
    vector<long long> res(n+1);
    vector<vector<long long> > nxt(n+1);
    for(int i = 1; i <= n; i++) scanf("%lld", &c[i]);
    for(int i = 0; i < m; i++) {
        int u,v;
        scanf("%d%d", &u,&v);
        res[u] += c[v];
        nxt[v].push_back(u);
    }
    long long ans = res[1];
    for(int i = 1; i <= n; i++) {

        for(int j = 1; j < (1<<nxt[i].size()); j++) {
            cout << i<< ' '<< j<<endl;
            long long sum = c[i];
            for(int k = 0; k < nxt[i].size(); k++) {
                if(j&(1<<k)) {
                    sum += res[nxt[i][k]]-c[i];
                }
            }
            cout << "sum = " <<sum<<endl;
            ans = gcd(ans, sum);
        }
    }

    cout << ans <<endl;
}

char s[1000000+10];

int main() {
    deque<char> s;
    string ss;
    cin >> ss;
    for(int i = 0; i < ss.size(); i++) {
        s.push_back(ss[i]);
    }

    int n;
    cin >> n;
    int fx = 1;
    while(n--) {
        int op;
        scanf("%d", &op);
        if(op == 1) {
            fx = 1-fx;
        } else {
            char c[10];
            scanf("%d%s", &op, c);
            if(fx == 1 && op == 1 || fx == 0 && op == 2) {
                s.push_front(c[0]);
            } else {
                s.push_back(c[0]);
            }
        }
    }
    if(fx == 0) {
        reverse(s.begin(), s.end());
    }

    for(auto c : s) {
        putchar(c);
    }
    puts("");
    return 0;
}




Measured memory_bytes: 896
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

struct Union_Find {
  vector<int> data;
  Union_Find(int size) { data = vector<int>(size, -1); }
  bool union_set(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) {
      if (data[y] < data[x])
        swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  bool find(int x, int y) { return root(x) == root(y); }
  int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
  int size(int x) { return -data[root(x)]; }
};

int main() {
  GI(N);
  int siz = 1e5 + 1;
  Union_Find ufx(siz), ufy(siz);
  vector<vector<int>> listx(siz), listy(siz);
  FOR(i, N) {
    GI2(x, y);
    if (listy[y].size() > 0) {
      ufx.union_set(x, listy[y][0]);
    }
    listx[x].push_back(y);
    listy[y].push_back(x);
  }
  vector<unordered_set<int>> unions(siz);
  vector<int> sizes(siz);
  vector<int> roots(siz);
  FOR(i, siz) { roots[i] = ufx.root(i); }
  FOR(i, siz) {
    if (roots[i] >= 0) {
      for (int y : listx[i]) {
        unions[roots[i]].insert(y);
      }
      sizes[roots[i]] += listx[i].size();
    } else if (ufx.data[i] < -1) {
      for (int y : listx[i]) {
        unions[i].insert(y);
      }
      sizes[i] += listx[i].size();
    }
  }
  ll ans = 0;
  FOR(i, siz) {
    if (ufx.data[i] < -1) {
      ans += -ufx.data[i] * unions[i].size();
      ans -= sizes[i];
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 17280
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, A,B = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    print(min(A*N,B))





if __name__ == "__main__":
    main()

Measured memory_bytes: 72812
import sys
input = lambda: sys.stdin.readline().rstrip()

N = int(input())
S = input()

R = []
G = []
B = []

for i in range(N):
    if S[i] == 'R':
        R.append(i)
    if S[i] == 'G':
        G.append(i)
    if S[i] == 'B':
        B.append(i)

base = len(R)*len(G)*len(B)

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        k = 2*j - i
        if k >= N or S[i] == S[j] or S[j] == S[k] or S[k] == S[i]:
            continue
        cnt += 1

print(base-cnt) 

Measured memory_bytes: 68188
// 03.txt, 12.txt で, WA版.
// 解き直し.
// ABC 132解説.
// https://img.atcoder.jp/abc132/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const LL MOD = 1e9 + 7;
const LL MAX_K = 101;
const LL MAX_N = 1e5;
LL dp[MAX_K][MAX_N];

int main() {

    // 1. 入力情報取得.
    LL N, K;
    scanf("%lld %lld", &N, &K);

    // 2. 解説通り.
    // dp[i][x]: 最後の整数が, x であるような i個 の 整数を並べて条件を満たせる場合の数.
    // ex.
    // [入力例]
    // 10 3
    // ※下記, dp[3][XX] については, 計算方法を ()内 に, 記載した.
    // dp[1][1]  = 1, dp[2][1]  = 10, dp[3][1]  = 27 (= dp[2][1] + ... + dp[2][10])
    // dp[1][2]  = 1, dp[2][2]  = 5,  dp[3][2]  = 22 (= dp[2][1] + dp[2][2] + dp[2][3] + dp[2][4] + dp[2][5])
    // dp[1][3]  = 1, dp[2][3]  = 3,  dp[3][3]  = 18 (= dp[2][1] + dp[2][2] + dp[2][3])
    // dp[1][4]  = 1, dp[2][4]  = 2,  dp[3][4]  = 15 (= dp[2][1] + dp[2][2])
    // dp[1][5]  = 1, dp[2][5]  = 2,  dp[3][5]  = 15 (= dp[2][1] + dp[2][2])
    // dp[1][6]  = 1, dp[2][6]  = 1,  dp[3][6]  = 10 (= dp[2][1])
    // dp[1][7]  = 1, dp[2][7]  = 1,  dp[3][7]  = 10 (= dp[2][1])
    // dp[1][8]  = 1, dp[2][8]  = 1,  dp[3][8]  = 10 (= dp[2][1])
    // dp[1][9]  = 1, dp[2][9]  = 1,  dp[3][9]  = 10 (= dp[2][1])
    // dp[1][10] = 1, dp[2][10] = 1,  dp[3][10] = 10 (= dp[2][1])
    // -> dp[3][1] + dp[3][2] + ... + dp[3][9] + dp[3][10] = 147通り と 計算するようである.

    // LL nr = sqrt(N + 0.0);
    LL nr = sqrt(N + 0.0) + 1;
    LL ir = N / nr;
    for(LL x = 1; x < nr + ir; x++) dp[1][x] = 1;
    
    for(LL k = 2; k <= K; k++){
         
         // 2-1. N ～ r まで集計.
         // ex.
         // x = 5 に 6 ～ 10, x = 4 に 4 ～ 5, x = 3 に 3 を 集約.
         for(LL x = nr + ir - 1; x >= nr; x--){
             dp[k][x] = dp[k - 1][nr + ir - x];
             dp[k][x] %= MOD;
             dp[k][x] += dp[k][x + 1];
             dp[k][x] %= MOD;
         }
         
         // 2-2. r - 1～ 1 まで集計.
         // ex.
         // x = 2 ～ 1 までを集計.
         for(LL x = nr - 1; x > 0; x--){
             dp[k][x] = dp[k][x + 1];
             dp[k][x] %= MOD;
             dp[k][x] += dp[k - 1][nr + ir - x] * (N / x - N / (x + 1));
             dp[k][x] %= MOD;
         }
    }
    // for(LL x = 1; x < nr + ir; x++) cout << dp[K][x] << " ";
    // cout << endl;
    
    // 3. 後処理.
    LL ans = 0;
    for(LL x = 1; x < nr; x++)       ans += dp[K][x], ans %= MOD;
    for(LL x = nr; x < nr + ir; x++) ans += dp[K][x] * (N / (nr + ir - x) - N / (nr + ir - x + 1)), ans %= MOD;
    printf("%lld\n", ans);
    return 0;

}

Measured memory_bytes: 77568
#include<bits/stdc++.h>
using namespace std;
int n;long long a[201],v[70];
inline bool ins(long long x)
{
	for(int i=62;i>=0;i--) if((x>>i)&1)
	{
		if(v[i]) x^=v[i];
		else {v[i]=x;return 1;}
	}
	return 0;
}
char s[201];
inline void solve()
{
	cin>>n;
	memset(v,0,sizeof(v));
	for(int i=1;i<=n;i++) cin>>a[i];
	scanf("%s",s+1);
	for(int i=n;i;i--)
	{
		if(s[i]=='0') ins(a[i]);
		else if(ins(a[i])) {puts("1");return;}
	}
	puts("0");
}
int main()
{
	int T;cin>>T;
	while(T--) solve();
	return 0;
}

Measured memory_bytes: 3720
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
E = []
for a in A:
    for b in B:
        E.append(a + b)
E.sort(reverse=True)
E = E[:K]
ans = []
for e in E:
    for c in C:
        ans.append(e + c)
ans.sort(reverse=True)
ans = ans[:K]
for x in ans:
    print(x)

Measured memory_bytes: 148200
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-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; }

int main() {
    int n, m; cin >> n >> m;
    vector<set<int>> g(n);
    rep(i, m) {
        int a, b; cin >> a >> b;
        a--; b--;
        g[a].insert(b);
        g[b].insert(a);
    }

    vector<int> v(n);
    rep(i, n) v[i] = i;

    ll ans = 0;
    do {
        if (v[0] != 0) continue;
        bool ok = true;
        rep(i, n-1) {
            int from = v[i];
            int to = v[i+1];
            if (g[from].find(to) == g[from].end()) {
                ok = false;
            }
        }
        if (ok) ans++;
    } while (next_permutation(all(v)));

    cout << ans << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>a>>b>>c>>d;
    rep(i,n+1){
        if(n-i-1<0||i>=n)continue;
        tmp=c*(n-i-1)-d*(i);
        tmpp=d*(n-i-1)-c*(i);
        if(tmp<=b-a&&b-a<=tmpp){
            Cout("YES");
            return 0;
        }
    }
    Cout("NO");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<typename S, typename T>
void xmin(S&a, T const&b){if(b<a) a=b;}
template<typename S, typename T>
void xmax(S&a, T const&b){if(b>a) a=b;}

signed main()
{
    #ifdef LOCAL_RUN
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
    int TTT; cin >> TTT; while(TTT--){
    #else
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
    #endif // LOCAL_RUN

    string s, t;
    cin >> s >> t;

    bool can = false;
    for(int it=0;it<1000;++it){
        if(s == t) can = true;
        rotate(s.begin(), s.begin()+1, s.end());
    }
    if(can){
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }



    #ifdef LOCAL_RUN
    }
    #endif // LOCAL_RUN
    return 0;
}


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

template<typename F>
inline constexpr decltype(auto) fix(F&& f) noexcept {
	return[f = std::forward<F>(f)](auto&&... args) {
		return f(f, std::forward<decltype(args)>(args)...);
	};
}

int main() {
	int n;
	std::cin >> n;

	std::vector<int> preord(n), inord(n);
	for (auto&& e : preord) {
		std::cin >> e;
		--e;
	}
	for (auto&& e : inord) {
		std::cin >> e;
		--e;
	}

	std::vector<int> ans;
	ans.reserve(n);

	fix([&](auto solve, int ps, int is, int len) -> void {
		const int root = preord[ps];

		int ir = is;
		while (inord[ir] != root)
			++ir;

		const int leftLen = ir - is;
		if (leftLen != 0)
			solve(solve, ps + 1, is, leftLen);
		
		const int rightLen = len - (ir - is + 1);
		if (rightLen != 0)
			solve(solve, ps + leftLen + 1, ir + 1, rightLen);

		ans.push_back(root);
	})(0, 0, n);

	std::cout << ans[0] + 1;
	for (int i = 1; i < n; ++i)
		std::cout << " " << ans[i] + 1;

	std::cout << std::endl;
}


Measured memory_bytes: 3108
def main():
    S = input()
    N = len(S)-1
    ans = 0
    for bit in range(1 << N):
        op = ["" for _ in range(N)]
        for i in range(N):
            if bit & (1 << i):
                op[i] = "+"
        s = "".join(S[i]+op[i] for i in range(N)) + S[-1]
        ans += sum(int(t) for t in s.split('+'))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 43096
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
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; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;

const int M = 200005;

const int D = 60;

int main(){
    ll N,K; cin >> N >> K;
    vector<vector<int>> to(D, vector<int>(N, 0));
    rep(i,N) cin >> to[0][i];
    rep(i,N) to[0][i]--;
    rep(i,D-1){
        rep(j, N){
            to[i+1][j] = to[i][to[i][j]];
        }
    }

    int v = 0;
    for (int i = D-1; i >= 0; i--){
        ll l = 1LL << i;
        if (l <= K){
            v = to[i][v];
            K -= l;
        }
    }

    cout << v + 1 << endl;
}

Measured memory_bytes: 51036
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (a > b) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int r; cin >> r;

  if (r < 1200) cout << "ABC" << endl;
  else if (r < 2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;

  return (0);
}


Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

vector<int> v;
int A, B, C, K;
int main(void){
    cin >> A >> B >> C >> K;
    if(K <= A) cout << K << endl;
    else if(A < K and K <= A+B) cout << A << endl;
    else if(A+B < K and K <= A+B+C) cout << A - (K-A-B) << endl;

    return 0;
}



Measured memory_bytes: 3632
#!/usr/bin/env python3

from collections import defaultdict
# クラスカル法を使う

V, E = map(int, input().split())
D = 0
tree = []
vertices = defaultdict(set)
for i in range(V):
    tree.append(i)          # 全ての頂点は自分の頂点 index と同じ index の木に属す
    vertices[i].add(i)

edges = []
for i in range(E):
    s, t, d = map(int, input().split())
    edges.append((s, t, d))

edges.sort(key=lambda x: x[2])
while edges:
    if V == 1:
        break
    s, t, d = edges.pop(0)
    if tree[s] != tree[t]:
        new = min(tree[s], tree[t])
        old = max(tree[s], tree[t])
        vertices[new] = vertices[new] | vertices[old]
        for vertex in vertices[old]:
            tree[vertex] = new

        D += d
        V -= 1
print(D)

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

int main() {
	int a, b;
	char op;

	while(cin >> a >> op >> b) {
		int ans = 0;

		switch(op) {
			case '+':
				ans = a + b;
				break;
			case '-':
			ans = a - b;
					break;
			case '*':
				ans = a * b;
				break;
			case '/':
				ans = a / b;
				break;
			case '?':
				return 0;
			default:
				break;
		}

		cout << ans << endl;
	}
}

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

using lint = long long;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<vector<T>>;
template <typename T> using VVV = vector<vector<vector<T>>>;
#define rep(i, n) for(int i = 0; i < int(n); i++)
#define repu(i, a, b, s) for(int i = int(a); i < int(b); i += int(s))
#define repd(i, a, b, s) for(int i = int(a); i > int(b); i += int(s))
#define endl "\n"
constexpr lint INF = 2e18;
constexpr lint MOD = 1e9 + 7;

void solve() {
    V<lint> arr(3);

    for (auto && it:arr){
        cin >> it;
    }

    sort(arr.begin(), arr.end());

    lint ans = arr[1] - arr[0] + arr[2] - arr[1];
    cout << ans << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}

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

int main() {
	int len1,len2,dia;
	int rectangle = 0,lozenge = 0;
	
	while( scanf("%d,%d,%d",&len1,&len2,&dia) == 3 ){
		if ( len1 * len1 + len2 * len2 == dia * dia ){
			rectangle++;
		} else if( len1 == len2 ) {
			lozenge++;
		}
	}
	
	cout << rectangle << endl << lozenge << endl;
	
	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N;
    cin >> N;

    vector<ll> A(N);

    for(ll i = 0; i < N; i++) {
        cin >> A[i];
        A[i] -= i + 1LL;

        //cout << A[i] << endl;
    }

    ll front = *min_element(A.begin(), A.end());

    for(ll i = 0; i < N; i++) {
        A[i] -= front;
    }

    ll left = 0;
    ll right = 2LL * pow(10, 10);

    ll ans = 0;

    while(left < right) {
        ll mid1 = (left + right) / 2;
        ll mid2 = mid1 + 1;
        ll count1 = 0;
        ll count2 = 0;
        for(int i = 0; i < N; i++) {
            count1 += abs(A[i] - mid1);
            count2 += abs(A[i] - mid2);
        }

        //cerr << mid1 << endl;

        if(count1 >= count2) {
            left = mid2;
            ans = count2;
        } else {
            right = mid1;
            ans = count1;
        }
    }

    cout << ans << endl;
}

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

const int mod = 998244353;

map<string, int> dp;

void add(int &a, int b){
    a += b;
    if(a >= mod)
        a -= mod;
}

void merge(string &a, string b){
    int n = b.length();
    for(int i = 0;i < n;i++){
        if(b[i] == '0')
            a[i] = '0';
    }
}

int Dp(string s){
    if(s == "")
        return 1;
    if(dp.find(s) != dp.end())
       return dp[s]; 
    int n = s.length();
    int ans = 0;
    int val = Dp(s.substr(1, n - 1));
    add(ans, val);
    if(s[0] == '1')
        add(ans, val); 
    for(int len = 1;len <= n;len++){
        string str = s.substr(0, len);
        for(int j = 2;j * len <= n;j++){
            string x = s.substr((j - 1) * len, len);
            merge(str, x);
            string s1 = s.substr(j * len, n - j * len);
            val = 1LL * Dp(s1) * Dp(str) % mod;
            add(ans, val);
        }
    }
    dp[s] = ans;
    return ans;
}

string S;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> S; 
    cout << Dp(S) << endl;
    return 0;
}


Measured memory_bytes: 5632
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::f64::consts::PI;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();

    let n = line[0];
    let t = line[1];
    let mut ab = Vec::with_capacity(n);
    for i in 0..n {
        let line: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();

        ab.push((line[0], line[1]));
    }

    ab.sort_by(|i,j| i.0.cmp(&j.0));

    let mut memo = vec![0; t + 1];

    for i in 0..n {
        let mut tmp = memo.clone();
        let a = ab[i].0;
        let b = ab[i].1;
        for j in 0..t {
            let tar = cmp::min(t, j + a);
            memo[tar] = cmp::max(tmp[tar], tmp[j] + b);
        }
    }

    println!("{}", memo[t]);
}


Measured memory_bytes: 4352
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string>
#include <string.h>
using namespace std;

const int MAX_N=10000;
int n,y;

int main(){
	cin >> y >> n;
	
	if(y==0){
		if(n>=1989) 	 cout << "H" << n-1989+1 << endl;
		else if(n>=1926) cout << "S" << n-1926+1 << endl;
		else if(n>=1912) cout << "T" << n-1912+1 << endl;
		else if(n>=1868) cout << "M" << n-1868+1 << endl;
	}else if(y==1){
		cout << n+1868-1 << endl;
	}else if(y==2){
		cout << n+1912-1 << endl;
	}else if(y==3){
		cout << n+1926-1 << endl;
	}else if(y==4){
		cout << n+1989-1 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3120
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define INF 2000000000
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int n,a,t=0,b=0;
	cin >> n;
	rep(i, n) {
		cin >> a;
		b = max(a, b);
		t += a;
	}
	if (b >= t - b) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}



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

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    for(int i = 1; i < n; i++){
        if (i >= n) break ;
        ans += (n - 1) / i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int k,x;
	vector<int>v;
	cin>>k>>x;
	for(int i=x-k+1;i<=x+k-1;i++)
	{
		cout<<i;
		if(i!=x+k-1)cout<<" ";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <string>
#define ll long long
#define MAXN 100100

using namespace std;
int P[MAXN];
int vis[ MAXN ];
int vis2[ MAXN ];
int id;
void sieve(){
	for(int i = 2;i * i <= MAXN;i++){
		if(!vis[i]){
			P[++id] = i;
			for(ll j = (ll)i * i;j <= MAXN;j = j + i){
				vis[j] = 1;
			}
		}
	}
}


int judge(int x){
	int y = (x + 1) / 2;
	if(x == 1) return 0;//非常重要 
	for(int i = 1;i <= id;i++){
		if( (x != P[i]) && (x % P[i])==0 ) return 0;
		if( (y != P[i]) && (y % P[i])==0 ) return 0;
	}
	return 1;
}

int S[MAXN];
int main(){
	sieve();
	int n;
	scanf("%d",&n);
	for(int i = 1;i <= MAXN;i += 2){
		if(judge(i)) vis2[i] = 1;
	}
	for(int k = 1;k <= MAXN;k++){
		S[k] += S[k - 1] + vis2[k];
	}
	for(int i = 1;i <= n;i++){
		int l,r;
		scanf("%d%d",&l,&r);
		/*int ans = 0;
		for(int j = l;j <= r;j += 2){
			ans += vis2[j];
		}*///复杂度太大了，前缀和优化 
		int ans = S[r] - S[l - 1];
		printf("%d\n",ans);
	}
	return 0; 
} 

Measured memory_bytes: 1664
from itertools import permutations
N, C = map(int, input().split())
D = [list(map(int, input().split())) for i in range(C)]  # 違和感
G = [list(map(int, input().split())) for i in range(N)]  # 初期盤面
X = [[0] * C for i in range(3)]  # modが0~2 × 各色への変更 の違和感の和

for c in range(C):  # 色
    tmp = [0] * 3  # 各modの違和感の和
    for i in range(N):
        for j in range(N):
            tmp[(i + j) % 3] += D[G[i][j] - 1][c]
    for t in range(3):
        X[t][c] = tmp[t]

ans = float('inf')
for c1, c2, c3 in permutations(range(C), 3):
    ans = min(ans, X[0][c1] + X[1][c2] + X[2][c3])

print(ans)


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

using namespace std;

typedef long long ll;

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

	int n, x;
	cin >> n >> x;

	vector<int> m(n);
	rep(i, n) cin >> m[i];

	sort(m.begin(), m.end());

	int ans = 0;
	for(int i = 0; i < n; i++){
		ans++;
		x -= m[i];
	}

	cout << ans + x / m[0] << endl;
}


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

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

fn main() {
    let mut a:usize=read!();
    if a==1||a==2 {println!("4")}
    else { 
        let mut b=0;
        while a!=1 {
            if a%2==0 {a/=2;b+=1}
            else{a=a*3+1;b+=1}
        }
        println!("{}",b+2)
    }
}

Measured memory_bytes: 2136
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  char c;
  cin >> c;
  if(c >= 'A' && c <= 'Z')
  {
    cout << "A\n";
  }
  else if(c >= 'a' && c <= 'z')
  {
    cout << "a\n";
  }
  return 0;
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

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

template<typename T, typename U>
void print1(T Array, U size) {
  for (int i = 0; i < size; i++) {
    cout << Array[i] << " ";
  }
  cout << endl;
}

template<typename T>
void print(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

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

int n;

int rec(int stage) {
  if (stage == 0) {
    return 1;
  }

  int ans = 0;

  for (int i = 1; i <= 3; i++) {
    if (stage - i < 0) continue;
    ans += rec(stage - i);
  }

  return ans;
}

signed main() {
  while (1) {
    cin >> n;
    if (n == 0) break;
    int t = (rec(n) + 3650 - 1) / 3650;
    cout << t << endl;
  }

  return 0;
}


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

using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, a, b) for (int64_t i = (a); i < (b); ++i)
const int MOD = 1e9 + 7;
typedef long long ll;
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

int main() {
  int n;
  string s;
  cin >> n >> s;
  int count = 0;
  while (!(s.find("ABC") == string::npos)) {
    int k = s.find("ABC");
    s = s.substr(k + 3, s.size() - 1);
    count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
def gcd(a,b):
  if a%b==0:
    return b
  else:
    return gcd(b,a%b)

n,x=map(int,input().split())
r=list(map(int,input().split()))
r.append(x)
r.sort()
d=[]
e=[]
for i in range(n):
  if r[i+1]!=r[i]:
    d.append(r[i+1]-r[i])
d=list(set(d))
ans=gcd(d[0],d[-1])
for y in d:
  if y%ans!=0:
    ans=gcd(ans,y)
print(ans)

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

int main()
{
    int n,x;
    cin>>n>>x;

    vector<int> l(n);
    for(int i=0;i<n;i++){
        cin>>l.at(i);
    }

    int di=0;
    int di_1=0;
    int cnt=1;
    for(int i=0;i<n;i++){
        di=di_1+l.at(i);
        di_1=di;
        if(di<=x)
            cnt++;
    }

    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
	int N; cin >> N;
	map<double, pair<double, double>> mp;

	for (int i = 0; i < N; i++) {
		double x, y; cin >> x >> y;
		if (x == 0 && y == 0) { continue; }
		double t = atan2(y, x);
		if (mp.find(t) != mp.end()) {
			mp[t].first += x;
			mp[t].second += y;
		}
		else {
			mp.insert({ t, { x,y } });
		}
	}

	vector<double> theta;
	vector<pair<double, double>> point;
	for (auto itr = mp.begin(); itr != mp.end(); itr++) {
		point.push_back({ itr->second.first, itr->second.second });
		theta.push_back(itr->first);
	}

	double ans = 0;
	
	N = theta.size();

	for (int i = 1; i < N; i++) {
		point[i].first += point[i - 1].first;
		point[i].second += point[i - 1].second;
	}

	for (int i = 0; i < N; i++) {
		for (int j = i; j < N; j++) {
			double x1 = point[j].first - point[i].first;
			double y1 = point[j].second - point[i].second;

			double x2 = point[N - 1].first - x1;
			double y2 = point[N - 1].second - y1;

			ans = max(ans, max(x1 * x1 + y1 * y1, x2 * x2 + y2 * y2));
		}
	}

	cout << setprecision(20) << sqrt(ans) << endl;

	return 0;
}

Measured memory_bytes: 512
def solve():
  s = input()
  can = True
  isn = "N" in s
  isw = "W" in s
  iss = "S" in s
  ise = "E" in s
  if isn or iss:
    if isn and iss:
      pass
    else:
      print("No")
      exit()
  if isw or ise:
    if isw and ise:
      pass
    else:
      print("No")
      exit()
  print("Yes")
  
solve()

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

int main(){
  string S;
  cin >> S;
  int L=S.size();
  int Ans=0;
  for(int i=0; i<L-1; i++){
    if(S.at(i)=='A' && S.at(i+1)=='C'){
      Ans=1;
      cout << "Yes" << endl;
      break;
    }
  }
  if(Ans==0){
    cout << "No" << endl;
  }
}

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

typedef long long ll;

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

int main(){
    ll n, x;
    scanf("%lld %lld", &n, &x);
    printf("%lld\n", 3*(n-gcd(n, x)));
    return 0;
}


Measured memory_bytes: 256
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        a: u32,
        b: u32
    }
    for x in 1..1001 {
        if x *  8 / 100 == a &&
           x * 10 / 100 == b {
            println!("{}", x);
            return;
        }
    }
    println!("-1");
}
/* vim:set foldmethod=marker: */


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;

int main(){
	int n;
	while(cin>>n,n){
		int data[86450]={0},a,b,c,A,B,C,ans=0;
		for(;n>0;n--){
			scanf("%d:%d:%d %d:%d:%d",&a,&b,&c,&A,&B,&C);
			b+=(a*60);
			c+=(b*60);
			B+=(A*60);
			C+=(B*60);
			data[c]++;
			data[C]--;
		}
		for(int i=1;i<86440;i++){
			data[i]+=data[i-1];
		}
		for(int i=0;i<86445;i++){
			ans=max(ans,data[i]);
		}
		cout<<ans<<endl;
	}
	
	
	
	
	return 0;
}


Measured memory_bytes: 1584
#include <stdio.h>
long long f(long long b,long long x){return x<b?x:f(b,x/b)+x%b;}
long long g(){
	long long n,s,b=2,r=-1,z;
	scanf("%lld%lld",&n,&s);
	if(n<s)return -1;
	if(n==s)return n+1;
	for(;b*b<=n;b++)if(f(b,n)==s)return b;
	for(b=1;b*b<=n-s;b++)if((n-s)%b==0&&f(z=(n-s)/b+1,n)==s)r=z;
	return r;
}
int main(){printf("%lld\n",g());}

Measured memory_bytes: 128
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
      
        String s = sc.next();
        StringBuilder answer = new StringBuilder();
        
        for(int i=0;i < s.length();i++){
          //System.out.println(s.charAt(i));
          
          if (String.valueOf(s.charAt(i)).equals("B")){
            if (answer.length() > 0)
              answer.setLength(answer.length()-1);
          } else {
            answer.append(s.charAt(i));
          }
        }
      
        System.out.println(answer);
        
	} 
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
  int a[3],buff,i,j;
  char str[100],*p;
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  a[0]=atoi(p);
  p=strtok(NULL," \n");
  a[1]=atoi(p);
  p=strtok(NULL," \n");
  a[2]=atoi(p);
  
  for(i=0;i<3;i++){
    for(j=2;j>i;j--){
      if(a[j-1]>a[j]){
        buff=a[j-1],a[j-1]=a[j],a[j]=buff;
      }
    }
  }
  
  printf("%d\n",a[0]+a[1]);
  
  
  return 0;
}

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

int main(){
	int num;//number of data sets
	int temp;

	cin >> num;

	int a[num],b[num],c[num];
	double x,y,z;

	for (int i = 0; i < num; i++)
	{
		cin >> a[i] >> b[i] >> c[i];
	}

	//直角三角形の判別
	for (int i = 0; i < num; i++)
	{
		if (a[i] > b[i])
		{
			temp = a[i]; 
			a[i] = b[i]; 
			b[i] = temp;
		}
		if (b[i] > c[i])
		{
			temp = b[i];
			b[i] = c[i];
			c[i] = temp;
		}

		x = c[i]*c[i];
		y = a[i]*a[i];
		z = b[i]*b[i];

		if(x == (y + z)){
			cout << "YES" << endl;
		} else{
			cout << "NO" << endl;
		}

	}

	return 0;
}


Measured memory_bytes: 3088
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline
import copy

def main():
    questions=[]
    dp=[]
    n = int(input())
    questions=list(map(int,input().split()))
    m = int(input())
    drinks=[list(map(int,input().split())) for _ in range(m)]
    for drink in drinks:
        dp=copy.deepcopy(questions)
        dp[drink[0]-1]=drink[1]
        print(sum(dp))
    
if __name__=="__main__":
    main()

Measured memory_bytes: 9336
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
const int INF=1e9+10;
vec w[500100],o[500010];
bool u[500010];
pa ans[500010];
int nedge,q[2000010],rt,S,T,d[2000010],maxmatch,n,h[500010],too[2000010],hed[1000010],nxt[2000010],cap[2000010];
void ae(int x,int y,int w){
	nxt[++nedge]=hed[x];
	hed[x]=nedge;
	too[nedge]=y;
	cap[nedge]=w;
}
void add(int x,int y,int w){
	ae(x,y,w),ae(y,x,0);
}
bool build(){
	int he=0,ta=1;
	q[1]=S;
	FOR(i,S,T) d[i]=-1;
	d[S]=0;
	while (he!=ta){
		int x=q[++he];
		for (int i=hed[x];i;i=nxt[i]){
			int y=too[i];
			if (!cap[i] || d[y]!=-1) continue;
			d[y]=d[x]+1;
			q[++ta]=y;
		}
	}
	return (d[T]!=-1);
}
int fnd(int x,int flo){
	if (x==T) return flo;
	int ret,w=0;
	for (int i=hed[x];i && w<flo;i=nxt[i]){
		int y=too[i];
		if (d[y]==d[x]+1 && cap[i] && (ret=fnd(y,min(flo-w,cap[i]))))
			cap[i]-=ret,cap[i^1]+=ret,w+=ret;
	}
	if (!w) d[x]=-1;
	return w;
}
int dinic(){
	int ans=0;
	while (build())
		while (1){
			int flo=fnd(S,INF);
			if (!flo) break;
			ans+=flo;
		}
	return ans;
}
void dfs(int x){
	if (u[x]) return;
	u[x]=1;
	for (int i=hed[x];i;i=nxt[i]){
		int y=too[i];
		if (!cap[i]) continue;
		dfs(y);
	}
}
int main(){
	cin>>n;
	FOR(i,1,n-1){
		int t,x;
		getint(t);
		while (t--){
			getint(x);
			w[i].pb(x);
			o[x].pb(i);
		}
	}
	S=0;
	nedge=1;
	T=n+n;
	FOR(i,1,n) add(S,i,1);
	FOR(i,n+1,n+n-1) add(i,T,1);
	FOR(x,1,n-1){
		FOR(i,0,SZ(w[x])-1)
			add(w[x][i],x+n,1);
	}
	maxmatch=dinic();
	if (maxmatch<n-1) return puts("-1"),0;
	dfs(S);
	FOR(i,1,n) if (!u[i]) return puts("-1"),0;
	for (int i=hed[S];i;i=nxt[i]){
		int y=too[i];
		if (cap[i]){rt=y;break;}
	}
	FOR(x,1,n){
		if (x==rt) continue;
		for (int i=hed[x];i;i=nxt[i]){
			int y=too[i];
			if (!cap[i] && y>=n+1 && y<=n+n-1){h[y-n]=x;break;}
		}
	}
	FOR(i,1,n) u[i]=0;
	int he=0,ta=1;
	q[1]=rt;
	u[rt]=1;
	while (ta<n){
		int x=q[++he];
		FOR(i,0,SZ(o[x])-1){
			int y=h[o[x][i]];
			if (u[y]) continue;
			u[y]=1;
			ans[o[x][i]]=mp(x,y);
			q[++ta]=y;
		}
	}
	FOR(i,1,n-1) printf("%d %d\n",ans[i].fi,ans[i].se);
	return 0;
}

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

bool checkValidity(ll a, ll b, ll c) {
    if (a + b <= c || a + c <= b || b + c <= a) 
        return false; 
    else
        return true; 
} 

int main() {
    ll n,ans = 0;
    cin>>n;
    vector<ll> a(n);
    for(ll i=0;i<n;i++) cin>>a[i];
    for(ll i=0;i<n;i++) {
        for(ll j=i+1;j<n;j++) {
            for(ll k=j+1;k<n;k++) {
                if(a[i] != a[j] and a[j] != a[k] and a[k] != a[i] and checkValidity(a[i], a[j], a[k])) ans++;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3636
N, K = map(int, raw_input().split())
S = raw_input()

x = 0
for i in range(N):
  if (S[i]=="L" and 0<i and S[i-1]=="L" or
      S[i]=="R" and i<N-1 and S[i+1]=="R"):
    x += 1
print min(x+2*K, N-1)


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

using str = string;
using ss = stringstream;

int a[26];

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

    str w;
    cin>>w;

    for(int i=0;i<w.size();i++)a[w[i]-'a']++;

    bool ans=true;

    for(int i=0;i<26;i++)if(a[i]%2)ans=false;

    puts(ans?"Yes":"No");

    return 0;
}


Measured memory_bytes: 3628