akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <type_traits>
using namespace std;

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	os << "{";
	REP(i, (int)v.size()) {
		if (i)
			os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}

ll read() {
	ll i;
	scanf("%" SCNd64, &i);
	return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
	printf("%" PRId64, x);
	if (suc == 1)
		printEoln();
	if (suc == 2)
		printSpace();
}

string readString() {
	static char buf[3341000];
	scanf("%s", buf);
	return string(buf);
}

char *readCharArray() {
	static char buf[3341000];
	static int bufUsed = 0;
	char *ret = buf + bufUsed;
	scanf("%s", ret);
	bufUsed += strlen(ret) + 1;
	return ret;
}

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 (b < a)
		a = b;
}

template <class T> T Sq(const T &t) { return t * t; }


signed main() {
	int N, K;
	cin >> N >> K;
	string S = readString();
	S[K - 1] -= 'A' - 'a';
	cout << S << endl;
}

Measured memory_bytes: 2304
import sys 
try:
	sys.stdin = open('Input.txt', 'r') 
	sys.stdout = open('Output.txt', 'w')
except:
	pass

input = sys.stdin.readline

n,k = map(int,input().split())
l = list(map(int,input().split()))
l.insert(0,0)
# print(l)
d = {}
city = 1
turn = 0
ini = []
cnt = 0
while True:
	if d.get(city) == None:
		d[city] = turn
		turn += 1
		ini.append(city)
		city = l[city]
		# print(city,d)

	else:
		cnt = d[city] - 1
		# print(cnt)
		rep = turn - d[city]
		# print(rep)
		break

if k<=cnt:
	print(ini[k])
else:
	# print(ini)
	# print(((k-cnt-1)%rep))
	print(ini[cnt+1+((k-cnt-1)%rep)])


	

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define endl "\n"

const ll INF = 1e15;
const int MOD = 1e9 + 7;
const double EPS = 1e-7;
const double PI = acos(-1.0);

ll a, b;

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

    cin >> a >> b;

    if ((a + b) & 1)
        cout << "IMPOSSIBLE" << endl;
    else
        cout << ((a + b) >> 1) << endl;
}


Measured memory_bytes: 256
s=input()
n=len(s)+1
a=[0]*n
b=[0]*n
c=[0]*n
for i in range(1,n):
  b[i]=(b[i-1]+1 if s[i-1]=='<' else 0)
for i in range(n-2,-1,-1):
  c[i]=(c[i+1]+1 if s[i]=='>' else 0)
for i in range(n):
  a[i]=max(b[i],c[i])
print(sum(a))

Measured memory_bytes: 31136
#include <iostream>

int main(){
   int X, N, p;
   std::cin >> X >> N;
   bool flag[102];
   std::fill(flag, flag+102, true);
   for(int i=0; i<N; ++i){
      std::cin >> p;
      flag[p] = false;
   }

   int sub = 0;
   while(true){
      if(X-sub>=0 && flag[X-sub]){
	 std::cout << X - sub << std::endl;
	 return 0;
      }else if(X+sub<102 && flag[X+sub]){
	 std::cout << X + sub << std::endl;
	 return 0;
      }
      ++sub;
   }
   return -1;
}


Measured memory_bytes: 3608
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

lint p=1000*1000*1000+7;

int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  map<char,lint> m;
  for(auto c:S)m[c]++;
  lint ans=1;
  for(auto e:m){
    ans*=(e.second+1);
    ans%=p;
  }
  ans--;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string(string(s)); }
string to_string(bool b) { return to_string(int(b)); }
string to_string(char b) { return "'" + string(1, b) + "'"; }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(A v) {
	string res = "{";
	for (const auto& x : v) res += (res == "{" ? "" : ", ") + to_string(x);
	return res + "}";
}
void debug() { cerr << endl; }
template <typename Head, typename... Tail>
void debug(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug(T...);
}
#define db(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define db(...) 42
#endif
typedef long long ll;
typedef long double ld;
struct JumpTable {
	struct Jump {
		int nex;
		// Initialize based on 0 steps.
		ll sum = 0;
	};
	inline Jump combine(const Jump& a, const Jump& b) {
		Jump res;
		res.nex = b.nex;
		res.sum = a.sum + b.sum;
		return res;
	}
	int logMaxSteps;
	vector<vector<Jump>> mat;
	// Constructs jump table on [0..n-1], assuming all queries are <= maxSteps steps.
	// Input jumps for one step.
	JumpTable(vector<Jump> oneStep, ll maxSteps) {
		logMaxSteps = 64 - __builtin_clzll(maxSteps);
		int n = oneStep.size();
		mat = vector<vector<Jump>>(logMaxSteps, vector<Jump>(n));
		mat[0] = oneStep;
		for (int p = 1; p < logMaxSteps; ++p)
			for (int i = 0; i < n; ++i)
				mat[p][i] = combine(mat[p - 1][i], mat[p - 1][mat[p - 1][i].nex]);
	}
	// Returns combine from highest power to lowest power from left to right.
	// E.g. combine(combine(combine(Jump(), mat[18][x]), mat[14][nex^18[x]]), ...)
	Jump jump(int x, ll steps) {
		assert(steps < (1LL << logMaxSteps));
		Jump ret;
		ret.nex = x;
		for (int p = logMaxSteps - 1; p >= 0; --p)
			if (steps & (1LL << p))
				ret = combine(ret, mat[p][ret.nex]);
		return ret;
	}
};
using Jump = JumpTable::Jump;
int main() {
	ll n;
	scanf("%lld", &n);
	int x, m;
	scanf("%d%d", &x, &m);
	vector<Jump> jump(m);
	for (int i = 0; i < m; ++i) {
		jump[i].nex = (ll)i * i % m;
		jump[i].sum = i;
	}
	JumpTable jt(jump, n);
	printf("%lld\n", jt.jump(x, n).sum);
}


Measured memory_bytes: 61048
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  string s;
  cin >> s;
  int K;
  cin >> K;

  vector<string> v;
  for (int i = 0; i < s.size(); i++) {
    for (int j = 0; j < K && i + j < s.size(); j++) {
      string tmp = s.substr(i, j + 1);
      v.pb(tmp);
    }
  }
  sort(ALL(v));
  UNIQUE(v);

  cout << v[K - 1] << endl;

  return 0;
}


Measured memory_bytes: 1660
#include <iostream>

using namespace std;

int main()
{int a,b,c;
cin>>a>>b>>c;
if(a>b)swap(a,b);
if(b>c)swap(b,c);
if(a>b)swap(a,b);
cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}



Measured memory_bytes: 3080
a, b, k = map(int, input().split())
if a >= k:
    a_r = a - k
    b_r = b
else:
    a_r = 0
    if b >= (k - a):
        b_r = b - (k - a)
    else:
        b_r = 0
print(str(a_r) +" " + str(b_r))

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

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

  vector<int> B(M);
  for (int j = 0; j < M; j++) {
    cin >> B.at(j);
  }

  int count = 0;

  for (int i = 0; i < N; i++) {
    int total = 0;
    for (int j = 0; j < M; j++) {
      int A;
      cin >> A;
      total += A * B.at(j);
    }
    if (total + C > 0) {
      count++;
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)
#if DEBUG
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...) /* ... */
#endif
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
void _OUT() {}; template<class H, class... T> void _OUT(H &h, T &... t) { cout<<' '<<h; _OUT(t...); };
template<class H, class... T> void _P(H &h, T &... t) { cout<<h; _OUT(t...); };
#define _PN(...) _P(__VA_ARGS__); cout << endl;

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 100
#else
#define SIZE 2222
#endif

int N;
vector<int> A(SIZE);
vector<pair<int,int>> B;
// 大きい順にi番目まで/左からj個埋まっている→最大の嬉しさ
int DP[SIZE][SIZE];

void solve() {
    cin>>N;
    REP(i,N) {
        cin>>A[i];
        B.push_back({A[i],i});
    }
    sort(ALL(B));
    reverse(ALL(B));
    DP[0][1] = abs(B[0].second-0)*B[0].first;
    DP[0][0] = abs(B[0].second-(N-1))*B[0].first;
    REP1(i,N-1)REP(j,i+1) {
        // 右へ寄せる
        chmax(DP[i][j], DP[i-1][j]+abs(B[i].second-(N-1-(i-j)))*B[i].first);
        // 左へ寄せる
        chmax(DP[i][j+1], DP[i-1][j]+abs(B[i].second-(j))*B[i].first);
    }
    int ans = 0;
    REP(i,N)chmax(ans,DP[N-1][i]);
    _PN(ans);
}



Measured memory_bytes: 27080
#include <bits/stdc++.h>
#define il inline
#define ri register int
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define mid ((l+r)>>1)
#define MAXN
#define MAXM
#define mod
#define inf (1<<30)
#define eps (1e-6)
#define alpha 0.75
#define rep(i, x, y) for(ri i = x; i <= y; ++i)
#define repd(i, x, y) for(ri i = x; i >= y; --i)
#define file(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, int> pli;
typedef pair <int, ll> pil;
typedef pair <ll, ll> pll;
template <typename T> il bool chkmin(T &x, T y) {return x > y ? x = y, 1 : 0;}
template <typename T> il bool chkmax(T &x, T y) {return x < y ? x = y, 1 : 0;}
template <typename T> il void read(T &x) {
	char ch = getchar(); int f = 1; x = 0;
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = x*10+ch-'0', ch = getchar();
	x *= f;
}
template <typename T, typename... Args> il void read(T &x, Args &...args) {
	read(x), read(args...);
}
ll a, b;
ll calc(ll x, ll y) {
	if(!y) return -x;
	return calc(y, x % y) + x / y * y * 2;
}
int main() {
	read(a, b);
	printf("%lld\n", a + calc(max(b, a-b), min(b, a-b)));
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> ii;
#define inf 1e9
#define F first
#define S second
#define dbg(x) cout<<#x<<" value : "<<x<<"\n";
#define rep(i,j,k) for(int i = (j); i <= (k); i++)
#define rep__(i,j,k) for(int i = (j); i < (k); i++)
#define per(i,j,k) for(int i = (j); i >= (k); i--)
#define per__(i,j,k) for(int i = (j); i > (k); i--)
#define mst(a,b) memset(a,b,sizeof(a))
#define sf(n) scanf("%d",&n)
#define stf(n,m) scanf("%d%d",&n,&m)
#define pf(n) printf("%d\n",n)
#define slf(n) scanf("%lld",&n)
#define plf(n) printf("%lld\n",n)
priority_queue<int,vector<int>,less<int> > q;
const int N=1e5+10;
const int mod=1e9+7;
int T,n,m,f[N];
void solve(){
	return ;
}
int main()
{
	sf(n);
	int last,now,count=0,num=0;
	sf(last);
	rep(i,2,n){
		sf(now);
		if(now<=last){
			num++;
		}else{
			count=max(num,count);
			num=0;
		}
		last=now;
	}
	count = max(num,count);
	cout<<count<<endl;
	solve();
	return 0;
} 

Measured memory_bytes: 256
// Ivan Carvalho
// Problem D - Educational Dynamic Programming Contest - AtCoder
// Link : https://atcoder.jp/contests/dp
#include <bits/stdc++.h>
using namespace std;

const int MAXW = 1e5 + 10;

long long knapsack[MAXW];
int N,W;

int main(){

	cin >> N >> W;

	for(int item = 1;item<=N;item++){
		int w,v;
		cin >> w >> v;
		for(int i = W;i>=w;i--) knapsack[i] = max(knapsack[i-w] + v,knapsack[i]);
	}

	long long best = 0;
	for(int i = 0;i<=W;i++) best = max(best,knapsack[i]);
	cout << best << endl;

	return 0;

}

Measured memory_bytes: 4344
let MOD = 1000000007

let [| N; M |] = stdin.ReadLine().Split() |> Array.map int

let a =
    [| for _ in [ 1..M ] do
        yield (stdin.ReadLine() |> int) |]

let dp = Array.zeroCreate<int> (N + 1)

dp.[0] <- 1

let rec resolver idx i =
    if i = N + 1 then ()
    elif idx < M && a.[idx] = i then
        dp.[i] <- 0
        resolver (idx + 1) (i + 1)
    else
        dp.[i] <- (dp.[i - 1] + if i <> 1 then dp.[i - 2]
                                else 0)
                  % MOD
        resolver idx (i + 1)

resolver 0 1

dp.[N] |> stdout.WriteLine


Measured memory_bytes: 19536
#include<iostream>
#include<vector>
#include<string>
#include<string.h>
#include<stdlib.h>
using namespace std;
int main()
{
    int n;
    char w[100000][11];
    int flg=0;

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>w[i];
    }
    for(int i=1;i<n;i++){
        if(w[i-1][strlen(w[i-1])-1]!=w[i][0]){
            flg=1;
            break;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(strcmp(w[i],w[j])<0){
                char tmp[11];
                strcpy(tmp,w[i]);
                strcpy(w[i],w[j]);
                strcpy(w[j],tmp);
            }
        }
    }
    for(int i=1;i<n;i++){
        if(strcmp(w[i],w[i-1])==0){
            flg=1;
            break;
        }
    }
    //for(int i=0;i<n;i++)cout<<w[i]<<endl;
    if(flg==1){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
/*
ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int M=2000005;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

ll nCk(ll n,ll k){
	return Div(F[n],F[n-k]*F[k]%mod);
}

ll nPk(ll n,ll k){
	return nCk(n,k)*F[k]%mod;
}*/

const int M=200005;
int n,a[M];
string s;
vi b[2],d;

int main(){
	for(int i=1;i<M;i++){
		int x=i,t=0;
		while(x) t+=x%2,x/=2;
		a[i]=a[i%t]+1;
	}
	cin>>n>>s;
	d=vi(n);
	int t=0;
	reverse(s.begin(),s.end());
	for(auto c:s) t+=c-'0';
	int sm=0,x=1;
	for(int i=0;i<n;i++){
		if(s[i]=='1') (sm+=x)%=t+1;
		(x*=2)%=t+1;
	}
	x=1;
	for(int i=0;i<n;i++){
		if(s[i]=='0') d[i]=a[(sm+x)%(t+1)]+1;
		(x*=2)%=t+1;
	}
	if(t==1){
		for(int i=0;i<n;i++) if(s[i]=='1') d[i]=0;
	}
	if(t>1){
	sm=0,x=1;
	for(int i=0;i<n;i++){
		if(s[i]=='1') (sm+=x)%=t-1;
		(x*=2)%=t-1;
	}
	x=1;
	for(int i=0;i<n;i++){
		if(s[i]=='1') d[i]=a[(sm-x+t-1)%(t-1)]+1;
		(x*=2)%=t-1;
	}
	}
	reverse(d.begin(),d.end());
	for(auto i:d) cout<<i<<endl;
}

Measured memory_bytes: 5164
import java.util.Scanner;

public class Main {

	public static void main(String args[]){

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int p;
		String S;

		int ac = 0;
		int wa = 0;
		int score[] = new int[n];
		for(int i = 0; i < n; i++){
			score[i] = 0;
		}
		
		for(int i = 0; i < m; i++){
			p = scan.nextInt()-1;
			S = scan.next();
			
			if(score[p] >= 0){
				
				if(S.equals("AC")){
					ac++;
					wa += score[p];
					score[p] = -1;
				}
				else{
					score[p]++;
				}
				
			}
			
		}
		
		System.out.println(ac+" "+wa);

	}
}

Measured memory_bytes: 63956
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <complex>

using namespace std;

#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
double const pi = acos(-1);
double const inf = 1e100;
double const eps = 1e-8;

typedef complex<double> point;
typedef vector<point> polygon;

inline double cross(const point& a, const point& b) {
    return imag(conj(a)*b);
}

inline double dot(const point& a, const point& b) {
    return real(conj(a)*b);
}

struct line : public vector<point> {
    line(const point &a, const point &b) {
        push_back(a); push_back(b);
    }
};

inline int ccw(point a, point b, point c) {
    b -= a; c -= a;
    if (cross(b, c) > 0)   return +1;       // counter clockwise
    if (cross(b, c) < 0)   return -1;       // clockwise
    if (dot(b, c) < 0)     return +2;       // c--a--b on line
    if (norm(b) < norm(c)) return -2;       // a--b--c on line
    return 0;
}

bool intersectSS(const line &s, const line &t) {
    return
        ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
        ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}

point projection(const line &l, const point &p) {
    double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
    return l[0] + t*(l[0]-l[1]);
}

bool intersectSP(const line &s, const point &p) {
    return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < eps; // triangle inequality
}

double distanceSP(const line &s, const point &p) {
    const point r = projection(s, p);
    if (intersectSP(s, r)) return abs(r - p);
    return min(abs(s[0] - p), abs(s[1] - p));
}

double distanceSS(const line &s, const line &t) {
    if (intersectSS(s, t)) return 0;
    return min(min(distanceSP(s,t[0]), distanceSP(s,t[1])),
               min(distanceSP(t,s[0]), distanceSP(t,s[1])));
}

int N,M,L;
double x[128], y[128], a[128], r[128];

double u = 2*pi/5;
double distanceStarStar(int s1, int s2){
    point p1(x[s1],y[s1]), p2(x[s2],y[s2]);
    double r1=r[s1], r2=r[s2], t1=a[s1], t2=a[s2];
    double res = inf;
    rep(i1,5)rep(i2,5){
        line l1(p1 + polar(r1,t1+u*i1 + pi/2),
                p1 + polar(r1,t1+u*(2+i1) + pi/2));
        line l2(p2 + polar(r2,t2+u*i2 + pi/2),
                p2 + polar(r2,t2+u*(2+i2) + pi/2));
        res = min(res, distanceSS(l1,l2));
        if(abs(res)<eps) return 0;
    }
    return res;
}

double solve(){
    M--; L--;
    double d[128][128];
    rep(i,N)loop(j,i,N){
        d[i][j] = i==j ? 0 : distanceStarStar(i,j);
        d[j][i] = d[i][j];
    }
    rep(k,N)rep(i,N)rep(j,N){
        d[i][j] = min(d[i][k]+d[k][j], d[i][j]);
    }
    return d[M][L];
}

int main(){
    while(scanf("%d%d%d",&N,&M,&L), N|M|L){
        rep(i,N){
            scanf("%lf%lf%lf%lf",x+i,y+i,a+i,r+i);
            a[i]=a[i]*pi/180;
        }
        printf("%.20lf\n",solve());
    }
}

Measured memory_bytes: 1364
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する

bool check(vector<int> unlike,int num){
    while (num > 0){
        REP(i,0,unlike.size()){
            if(num % 10 == unlike[i]) return false;
        }
        num /= 10;
    }
    return true;
}

int main() {
    int N;
    cin >> N;
    int K;
    cin >> K;
    vector<int> unlike(K);
    REP(i,0,K){
        cin >> unlike[i];
    }

    for(int i = N; i < 100000; i++){
        if(check(unlike,i)){
            cout << i << endl;
            return 0;
        }
    }


    return 0;

}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{

int n, i, j, count, temp, min;
count = 0;
	
scanf("%d", &n);

int A[n];

for(i=0; i<n ; i++)
{
	scanf("%d", &A[i]);
}
		
for(i = 0; i <n; i++)
{
	min = i;
			
	for(j=i; j<n ; j++)
	{
			
		if(A[j] < A[min])
		{
			min = j;
			
		}
		
		
	}
	
	temp = A[i];
	A[i] = A[min];
	A[min] = temp;
	
	if(A[i] != A[min])
	{
		count++;
	}
	
}
		
for(i=0; i<n-1; i++)
{
	printf("%d ", A[i]);

}
	
printf("%d\n", A[n-1]);
	
printf("%d\n", count);
	
return 0;
	
	
}


Measured memory_bytes: 2088
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <set>
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
#define ms(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define eps 0.0000000001
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define random(a, b) rand()*rand()%(b-a+1)+a
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 100000 + 10;
const int mod = 1e9+7;
int F[110][15];
int p[110][15];
int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    IOS
    int n;
    cin >> n;
    for(int i = 1;i<=n;i++)
        for(int j = 1;j<=10;j++)
            cin >> F[i][j];
    for(int i = 1;i<=n;i++)
        for(int j = 0;j<=10;j++)
            cin >> p[i][j];
    int ans = -inf;
    for(int x = 1;x<(1<<10);x++){
        for(int j = 1;j<=10;j++)
            F[0][j] = (x>>(j-1))&1;
        int hh = 0;
        for(int i = 1;i<=n;i++){
            int c = 0;
            for(int j = 1;j<=10;j++){
                if(F[0][j]&&F[i][j])    c++;
            }
            hh += p[i][c];
        }
        ans = max(ans, hh);
    }
    cout << ans << endl;
    return 0;
}


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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

ll a, x, res = 0;

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

	cin >> x;
	a = 100;
	while (a < x) {
		a *= 1.01l;
		res++;
	}
	cout << res << endl;

	return 0;
}

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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	char ch;
	for (int i=0; i<3; i++)
		for (int j=0; j<3; j++) {
			cin>>ch;
			if(i==j) cout << ch;
		}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#define LL long long
using namespace std;

char str[20];

int main() {
	scanf("%s", str);
	int n = strlen(str);
	int sum = 1 << n - 1;
	LL ans = 0;
	for (int i = 0; i < sum; ++i) {
		LL cur = 0;
		for (int j = 0; j < n; ++j) {
			cur = cur * 10 + str[j] - '0';
			if (i & (1 << j)) {
				ans += cur;
				cur = 0;
			}
		}
		ans += cur;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e5+10;
int a[3][SIZE];
void noo(){
    puts("No");
    exit(0);
}
int rev[2],cn[2],d[SIZE];
bool used[SIZE];
int main(){
    DRI(N);
    REP(i,3)REP(j,N)RI(a[i][j]);
    REP(i,N){
        if(a[1][i]%3!=2)noo();
        if((a[1][i]/3)%2!=i%2)noo();
        if(abs(a[1][i]-a[0][i])!=1||abs(a[1][i]-a[2][i])!=1)noo();
        if(a[1][i]<a[0][i])rev[i&1]++;
        d[i]=a[1][i]/3;
    }
    REP(i,N){
        if(used[i])continue;
        int me=i;
        used[me]=1;
        cn[i&1]++;
        while(!used[d[me]]){
            me=d[me];
            used[me]=1;
        }
    }
    if(((N+1)/2-cn[0])%2!=rev[1]%2)noo();
    if((N/2-cn[1])%2!=rev[0]%2)noo();
    return 0*puts("Yes");
}


Measured memory_bytes: 1920
#include<stdio.h>
#define N 100
int main(){
  int i,j,n,v,A[N],k;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  for(i=0;i<n-1;i++) printf("%d ",A[i]); printf("%d",A[n-1]);
  printf("\n");
  for(i=1;i<n;i++){
    v=A[i];
    j=i-1;
    while(j>=0&&A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    for(k=0;k<n-1;k++){
      printf("%d ",A[k]);
    }
    printf("%d",A[n-1]);
    printf("\n");
  }
  return 0;
}



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

using namespace std;

bool check(string s) {
    string rev = s;
    reverse(rev.begin(), rev.end());
    return rev == s;
}

string s;

string sub(int l, int r) {
    string ret;
    while (l <= r) {
        ret += s[l - 1];
        l++;
    }
    return ret;
}

int main() {
    cin >> s;
    int n = s.size();
    if (check(s) && check(sub(1, (n - 1) / 2)) && check(sub((n + 3) / 2, n)))
        puts("Yes");
    else
        puts("No");
}


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

using namespace std;
typedef long long ll;


ll gcd(ll a, ll b)
{
    return b != 0 ? gcd(b, a % b) : a;
} 

int main() {
  ll N; cin >> N;
  vector<ll> A(N);
  for (ll j=0; j < N; ++j) cin >> A[j];

  vector<ll> cache(N);
  cache[0] = A[1];
  for (ll j=1; j < N; ++j) {
    cache[j] = A[0];
  }
  ll tmp = A[0];
  for (ll j=2; j < N; ++j) {
    tmp = gcd(tmp, A[j-1]);
    cache[j] = tmp;
  }
  tmp = A[N-1];
  for (ll j=N-2; j >= 0; --j) {
    tmp = gcd(tmp, A[j+1]);
    cache[j] = gcd(cache[j], tmp);
  }
  ll ans=cache[0];
  for (ll j=0; j < N; ++j) {
    ans = max(ans, cache[j]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

  void sort(int a[], int left, int right){

	int p;
	int L = left, R = right;		
	int temp;
	p = a[(left + right) / 2];

	while (1)
	{
		while (a[L] < p) L++; while (a[R] > p)
			R--;
		
		if (L >= R)
			break;

		temp = a[R];
		a[R] = a[L];
		a[L] = temp;

		L++;
		R--;
    }

	if (left < L - 1) sort(a, left, L - 1); if (right > R + 1)
		sort(a, R + 1, right); 
}
int main(){
  int n,i;
  int d[100000];
  scanf("%d",&n);
  for( i=0;i<n;i++){
    scanf("%d",&d[i]);
  }
  printf("\n");
  sort(d,0,i-1);
  int ans=d[i/2]-d[i/2-1];
  printf("%d",ans);
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 998244353
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,s;

int main(){
  ll ans=0;
 cin >> n >> s;
  vi a(n),dp(s+1,0),dp2(s+1,0);
  REP(i,n) cin>>a[i];

  dp[0]=1;
  dp2[0]=1;
  REP(i,n){
    ll aa=a[i];
    for(ll j=0;j<s+1;j++){
      if ((j+aa)<(s+1)){
        if (j==0){
          dp2[j+aa]=(dp[j+aa]+dp[j]*(i+1)%MOD)%MOD;
        }else{
          dp2[j+aa]=(dp[j+aa]+dp[j])%MOD;
        }
      }
    }
    
    ll xxx=(dp2[s]-dp[s]+MOD)%MOD;
    xxx=xxx*(n-i)%MOD;
    ans=(ans+xxx)%MOD;
    for(ll j=0;j<s+1;j++)
      dp[j]=dp2[j];

  }

  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
    int k, n; cin >> k >> n;
    vector<int> a(n + 1);
    for (int i = 0; i < n; i++) {
        cin >> a[i + 1];
    }
    int ans = k - a[n] + a[1];
    for (int i = 0; i < n; i++) {
        ans = max(ans, a[i + 1] - a[i]);
    }
    cout << k - ans << endl;
    return 0;
}

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

#define MAX 100

int main(void) {
  int n;
  int input[MAX];

  cin >> n;

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

  int count = 0;
  int flag = 1;
  while(flag) {
    flag = 0;
    for(int j = n - 1; j >= 1; j--) {
      if(input[j - 1] > input[j]) {
        int tmp = input[j];
        input[j] = input[j - 1];
        input[j - 1] = tmp;
        flag = 1;
        count++;
      }
    }
  }

  for(int i = 0; i < n; i++) {
    if(i == 0) {
      cout << input[i];
    }
    else {
      cout << " " << input[i];
    }
  }
  cout << endl;
  cout << count << endl;

  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define append push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  if (n == 1) {
    cout << "Hello World" << endl;
  } else {
    int a,b;
    cin >> a >> b;
    cout << a+b << endl;
  }
  return 0;
}


Measured memory_bytes: 3572
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum  # accumulate

def solve():
    N, K = MI()
    # A = LI1()

    D = [[0] * N for _ in range(int(log2(K))+1)]
    D[0] = LI1()
    
    for i in range(1, int(log2(K))+1):
        for j in range(N):
            tmp = D[i-1][j]
            D[i][j] = D[i-1][tmp]
    # print(D)
    
    v = 0
    while K > 0:
        tmp = int(log2(K))
        K = K - 2 ** tmp
        v = D[tmp][v]
        # print(tmp, K, v)
    print(v+1)

if __name__ == '__main__':
    solve()


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

using namespace std;

int main()
{
  int n,i,j;
  long long r=0,g=0,b=0;
  string s;
  
  cin >> n >> s;
  
  for(auto p:s){
    if(p == 'R') r++;
    else if(p == 'G') g++;
    else b++;
  }
  
  long long ans = (long long)r*g*b;
  
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(s[i] == s[j]) continue;
      
      int idx = (j-i)+j;
      
      if(idx < n && s[i]!=s[idx] && s[j]!=s[idx]) ans--;
    }
  }
  
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>
int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	if(a < b){
		printf("a < b\n");
	}else if(a > b){
		printf("a > b\n");
	}else {
		printf("a == b\n");
	}
	return 0;
}

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



int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  map<int,int> M;
  REP(i,N) {
    cin >> A[i];
    M[A[i]]++;
  }
  int ans = 0;
  REP(i,N) {
    M[A[i]]--;
    int find = 0;
    for (int j = 1; j*j<=A[i]; ++j) {
      if (A[i]%j==0) {
        if (M[j]!=0) {
          find = 1; 
          break;
        }
        if (A[i]/j!=j)
          if (M[A[i]/j]!=0) {
            find = 1;
            break;
          }
      }
    }
    if (find == 0) {
      ans++;
    }
    M[A[i]]++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 32612
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll Q, H, S, D, N;
    cin >> Q >> H >> S >> D >> N;
    ll num1 = min(Q * 4, min(H * 2, S));
    if (N % 2 == 0)
    {
        cout << min(N * num1, (N / 2) * D) << endl;
    }
    else
    {
        cout << min((N - 1) * num1, (N / 2) * D) + num1 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define P pair<int, int>
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
const int MAX_N = 1005;
const int MOD = 10007;

string S;
int dp[MAX_N][(1 << 3)], N, must[MAX_N];

int main() {
  cin >>N >>S;
  REP(i, S.length()){
    if(S[i] == 'J') must[i] = 1;
    if(S[i] == 'O') must[i] = 2;
    if(S[i] == 'I') must[i] = 4;
  }
  memset(dp, 0, sizeof(dp));
  dp[0][1] = 1;
  REP(i, N){
    REP(now, (1 << 3)){
      if(dp[i][now] == 0) continue;
      REP(next, (1 << 3)){
        if((now & next) == 0 || (next & must[i]) == 0) continue;
        dp[i + 1][next] = (dp[i + 1][next] + dp[i][now]) % MOD;
      }
    }
  }
  int ans = 0;
  REP(i, (1 << 3))
    ans = (ans + dp[N][i]) % MOD;
  cout <<ans <<endl;

  
  return 0;
}

Measured memory_bytes: 1248
#include <iostream>
#include <vector>
#include <algorithm>
#include <chrono>

using namespace std;
using namespace std::chrono;

const int MOD = 1e+9 + 7;

int main() {
  auto start = high_resolution_clock::now();

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

  long long res = 1;
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i)
    res = res * i % MOD;

  cout << res << endl;

  cerr << "Total execution time : " << duration_cast<milliseconds>(high_resolution_clock::now() - start).count() << " ms" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  const int N = 200005;

int32_t main()
{



    IOS

    

    int n,k;
    cin >> n >> k;

    set<int> s;


    for(int i = 1; i <= k; i++)
    {
      int d;
      cin >> d;

      for(int i = 1;i <= d; i++)
      {
        int x;
        cin >> x;
        s.insert(x);
      }


    }

    int ans = 0;

    for(int i = 1; i <=n; i++)
      {
        if(!s.count(i))ans++;
      }

      cout << ans;  

















    
    return 0;
}



Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
//void dfs(unordered_map<int,unordered_set<int>>&m,int st)
 int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    long long int t;
    
    int n,m1;
    cin>>n>>m1;

    unordered_map<int,unordered_set<int>>m;

    for(int i=0;i<m1;i++)
    {
         int x,y;
         cin>>x>>y;

         if(m[x].find(y)==m[x].end())
            m[x].insert(y);
         if(m[y].find(x)==m[y].end())
            m[y].insert(x);
    }
    vector<bool>visit(n+1,0);
    queue<int>q;
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(visit[i]==1)
            continue;
        else
        {
            //cout<<"test"<<endl;
            q.push(i);
            int ll=0;
            while(!q.empty())
            {
                int tt=q.front();
               
                q.pop();
                if(visit[tt]==1)
                    continue;
                // cout<<"test"<<" "<<tt<<" "<<i<<endl;
                visit[tt]=1;
                ll+=1;
                for(auto &aa:m[tt])
                    q.push(aa);
            }
            if(ll>ans)
                ans=ll;
        }
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 41492
r = 10001
sqrt = int(r**0.5)
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
	if p[i]:
		p[2*i+1::i+1] = [0 for x in range(2*i+1,r,i+1)]

while True:
	n = int(raw_input())
	if n == 0: break
	for i in range(n,1,-1):
		if p[i-1] and p[i-3]:
			print i-2,i
			break

Measured memory_bytes: 4704
def p(x):
 for i in[2,3,5,7,9,11,13,17,19,21,23]:
  if x%i==0:return[1,0][x>i]
 i=29
 while i<=x**.5:
  if x%i==0:return 0
  i+=2
 return 1
n=int(input())
print(sum([p(int(input()))for _ in range(n)]))

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

typedef long long ll;

int main()
{
	ll a,b,n;
	scanf("%lld%lld%lld",&a,&b,&n);
	printf("%lld\n",(a*(min(b-1,n)))/b-a*((min(b-1,n))/b));
}


Measured memory_bytes: 3848
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lines = line.split(" ");

		int L = Integer.parseInt(lines[0]);
		int R = Integer.parseInt(lines[1]);
		int d = Integer.parseInt(lines[2]);
		int count = 0;

		for(int i = L; i <= R; i++) {
			if(i % d == 0) {
				count++;
			}
		}

		System.out.println(count);
	}

}


Measured memory_bytes: 35604
import java.util.*;

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

        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] h = new int[n];
        for(int i = 0; i < n; i++){
            h[i] = sc.nextInt();
        }

        boolean[] bl = new boolean[n];
        Arrays.fill(bl, true);

        for(int i = 0; i < m; i++){
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            if(h[a] == h[b]){
                bl[a] = false;
                bl[b] = false;
            }else if(h[a] < h[b]){
                bl[a] = false;
            }else{
                bl[b] = false;
            }
        }

        int ans = 0;
        for(int i = 0; i < n; i++){
            if(bl[i]){
                ans++;
            }
        }

        System.out.println(ans);

    }
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a + b > c + d) cout << "Left" << endl;
  else if (a + b == c + d) cout << "Balanced" << endl;
  else cout << "Right" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
    cin >> s;
    int a[15], l = 0;
    for(int i = 0; i < s.size(); i++)
    {
        a[l++] = s[i]-'0';
    }
    int com = (1 << (l-1));
    long long ans = 0;
    for(int i = 0; i < com; i++)
    {
        long long t = 0;
        for(int j = 0; j < l; j++)
        {
            t = (t*10)+a[j];
            if((1<<j) & i)ans+=t, t = 0;
        }
        ans+=t;
    }
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0;i<N;i++)cin >> a.at(i);
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int Alice=0;
    int Bob=0;
    for(int i=0;i<N;i+=2){
        Alice+=a.at(i);        
    }
    for(int i=1;i<N;i+=2){
        Bob+=a.at(i);
    }
    cout << Alice-Bob << endl;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String s=sc.next();
    int sl=s.length();
    int dp[][] = new int[sl][13];
    int bt[] = new int[13];
    int modder = 1000000007;
    
    for(int i=0;i<13;i++){
      bt[i]=(i*10)%13;
    }
    for(int i=0;i<sl;i++){
      Arrays.fill(dp[i],0);
    }
    
    if(s.charAt(0)=='?'){
      for(int i=0;i<10;i++){
        dp[0][i]=1;
      }
    }else{
      dp[0][Integer.valueOf(s.charAt(0))-48]=1;
    }
    
    for(int i=1;i<sl;i++){
      for(int j=0;j<13;j++){
        if(s.charAt(i)=='?'){
          for(int k=0;k<10;k++){
            dp[i][(bt[j]+k)%13]=(dp[i][(bt[j]+k)%13]+dp[i-1][j])%modder;
          }
        }else{
          dp[i][(bt[j]+Integer.valueOf(s.charAt(i))-48)%13]=dp[i-1][j];
        }
      }
    }
    System.out.println(dp[sl-1][5]);
  }
}

Measured memory_bytes: 32804
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  int a[4], b[4];
  while(cin >> a[0]){
    rep(i, 3)cin >> a[i+1];
    rep(i, 4)cin >> b[i];
    int hit = 0;
    int blow = 0;
    rep(i, 4){
      if(a[i] == b[i])hit++;
      rep(j, 4){
        if(a[i] == b[j]){
          blow++;
          break;
        }
      }
    }
    cout << hit << " " << blow - hit << endl;
  }
	return 0;
}



Measured memory_bytes: 2968
#include <iostream>
#include <iomanip>
#include <string>
#include <unordered_map>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  ll k, n, sum, max = -1, first_a, a, old_a = 0;
  cin >> k >> n;
  for (ll i = 0; i < n; ++i)
  {
    cin >> a;
    if (i == 0) first_a = a;
    if (a - old_a > max)
    {
      max = a - old_a;
    }
    old_a = a;
  }
  if (k - a + first_a > max) max = k - a + first_a;

  cout << k - max << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String x = sc.next();
        String y = sc.next();
        if(x.compareTo(y)<0) {
            System.out.println("<");
        }else if(x.compareTo(y)>0){
            System.out.println(">");
        }else{
            System.out.println("=");
        }
    }
}

Measured memory_bytes: 23764
x, k, d = map(int, input().split())
if x < 0:
    x = abs(x)
    xsign = -1
else:
    xsign = 1

nn, r = divmod(x, d)
kk = k-nn
if kk <= 0:
    print(x-k*d)
elif kk%2 == 0:
    print(r)
else:
    print(abs(r-d))


Measured memory_bytes: 61600
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
 int a,b,c,d,e,x,y,z,h,j,k;
 cin>>a>>b>>c>>d>>e;
 x=abs(a);
 y=x*c;
 h=b-a;
 j=h*e;
 z=b*e;
 if(a<0){
         k=y+d+z;
         cout<<k<<endl;
 }
    else if(a>0){
                 cout<<j<<endl;
                }
 }


Measured memory_bytes: 3116
import java.util.Scanner;

class Main{

	public static void main(String[] args){

		Scanner sc =new Scanner(System.in);

		int n=sc.nextInt();

		int x[]=new int [n];
		int y[]=new int [n];

		for(int i=0;i<n;i++) 
			x[i]=sc.nextInt();

		for(int i=0;i<n;i++) 
			y[i]=sc.nextInt();

		System.out.printf("%.8f\n",dis_1(x,y));
		System.out.printf("%.8f\n",dis_2(x,y));
		System.out.printf("%.8f\n",dis_3(x,y));
		System.out.printf("%.8f\n",dis_o(x,y));

	}

	private static double dis_1(int x[],int y[]) {

		double dis=0;

		for(int i=0;i<x.length;i++)
			dis+=Math.abs(x[i]-y[i]);

		return dis;
	}

	private static double dis_2(int x[],int y[]) {

		double dis=0;

		for(int i=0;i<x.length;i++)
			dis+=(x[i]-y[i])*(x[i]-y[i]);

		return Math.sqrt(dis);
	}

	private static double dis_3(int x[],int y[]) {

		double dis=0;

		for(int i=0;i<x.length;i++)
			dis+=(x[i]-y[i])*(x[i]-y[i])*Math.abs(x[i]-y[i]);

		return Math.cbrt(dis);
	}

	private static double dis_o(int x[],int y[]) {

		double max_dis=0;
		double dis=0;

		for(int i=0;i<x.length;i++) {
			dis=Math.abs(x[i]-y[i]);
			if(dis>max_dis)
				max_dis=dis;
		}

		return max_dis;
	}

}



Measured memory_bytes: 26644