akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC119C
{
    class Program
    {
        static void Main(string[] args)
        {
            N = ReadInt;
            A = ReadInt;
            B = ReadInt;
            C = ReadInt;

            L = new int[N];
            for (int i = 0; i < N; i++)
            {
                L[i] = ReadInt;
            }

            int ans = Dfs(0, 0, 0, 0, 0);
            Console.WriteLine(ans - 30);
        }

        static int N;
        static int[] L;
        static int A;
        static int B;
        static int C;

        //長さの全バリエーションを探索
        static int Dfs(int a, int b, int c, int depth, int mp)
        {
            if (depth == N)
            {
                if (a == 0 || b == 0 || c == 0) return int.MaxValue;
                return mp + Math.Abs(a - A) + Math.Abs(b - B) + Math.Abs(c - C);
            }

            int[] cand = new int[4];
            cand[0] = Dfs(a + L[depth], b, c, depth + 1, mp + 10);
            cand[1] = Dfs(a, b + L[depth], c, depth + 1, mp + 10);
            cand[2] = Dfs(a, b, c + L[depth], depth + 1, mp + 10);
            cand[3] = Dfs(a, b, c, depth + 1, mp);

            return cand.Min();
        }

    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] NextLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


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

int main()
{
 string a;
 cin>>a;
  long int ans=1;
  for(long int i=1;i<a.length();)
  {
      if(a[i]!=a[i-1])
      {
          ans++;
          i++;
      }
      else
      {
          if(a.length()-i-1==1)
          {
              ans++;
              i+=2;
          }
          else if(a.length()-i-1==0)
          break ;
          else
          {
              ans+=2;
              i+=3;
          }
      }
  }
  cout<<ans;
}

Measured memory_bytes: 640
use proconio::input;
use num::integer::gcd;

fn main() {
    input! {
        k: i64,
    }
    let mut ans = 0;
    for a in 1..=k {
        for b in 1..=k {
            for c in 1..=k {
                ans += gcd(a,gcd(b,c))
            } 
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 2136
//length of the longest path in a directed acyclic graph
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1e9+5;
vector<int> g[100005];
vector<bool> visited(100005,false);
vector<int> indegree(100005,0);
vector<int> dist(100005,0);

void dfs(int s){
	visited[s] = true;
	for(int v: g[s]){
		dist[v] = max(dist[v],1+dist[s]);
		indegree[v]--;
		if(indegree[v] == 0) dfs(v);
	}
}

int32_t main(){
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
   	int n,m;
    cin>>n>>m;
    while(m--){
    	int a,b;
    	cin>>a>>b;
    	g[a].push_back(b);
    	++indegree[b];
    }
    for(int i = 1; i <= n; i++){
    	if(!visited[i] && indegree[i] == 0){
    		dfs(i);
    	}
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
    	ans = max(ans,dist[i]);
    }
    cout<<ans;
}

Measured memory_bytes: 10496
#include <stdio.h>  
  
#define N 10  
  
int main(void)  
{  
    int n, ans, i;  
  
    scanf("%d", &n);  
    while(n--) {  
        ans = 1;  
        int a, b=-1, c=-1;  
        for(i=1; i<=N; i++) {  
            scanf("%d", &a);  
            if(ans) {  
                if(a > b)  
                    b = a;  
                else if(a > c)  
                    c = a;  
                else  
                    ans = 0;  
            }  
        }  
  
        printf("%s\n", ans ? "YES" : "NO");  
    }  
  
    return 0;  
}  

Measured memory_bytes: 2580
def gcd(a, b):
    if a < b:
        a, b = b, a
    while b:
        a, b = b, a % b
    return a


A, B, K = map(int, input().split())

x = gcd(A, B)
y = list()
for i in range(1, x+1):
    if x % i == 0:
        y.append(i)
y = y[::-1]
print(y[K-1])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(1010);
	rep(i,n + 1){
		int m = i;
		for(int j = 2; j <= i; j++){
			while(m % j == 0){
				a.at(j)++;
				m /= j;
			}
		}
	}
	ll ans = 1;
	rep(i,1001){
		if(a.at(i)){
			ans *= a.at(i) + 1;
			ans %= mod;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;
string s;
int c;
string u="CODEFESTIVAL2016";
int main()
{
	cin>>s;
	int t=s.size();
	rep(i,t)
	{
		if(s[i]!=u[i])c++;
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long 
int F[2100010];

int Mul(int a, int b) {
	return ((a % mod) * (b % mod)) % mod;
}

void fact(void) {
	F[0] = 1;
	F[1] = 1;
	for (int i = 2; i <= 2100000; i++) {
		F[i] = Mul(i, F[i - 1]);
	}
}
int square(int x) {
	return (x * x) % mod;
}

int power(int x, int y) {
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}

int Div(int a, int b) {
	return Mul(a, power(b, mod - 2));
}
int P(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return Div(F[n], F[n - r]);
}

int C(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	int ret;
	ret = Div(F[n], Mul(F[n - r], F[r]));
	return ret;
}
int H(int n, int r) {
	if (n == 0 && r == 0) return 1;
	return C(n + r - 1, r);
}
vector<int> v[100010];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    fact();
    int n; cin >> n;
    int a[100010];
    rep(i, n + 1) cin >> a[i];
    rep(i, n + 1) v[a[i]].push_back(i);
    int num = 0;
    rep(i, n) {
        if(v[i + 1].size() == 2) num = i + 1;
    }
    int L = v[num].front();
    int R = n - v[num].back();
    //cout << L << " " << R << endl;
    rep(i, n + 1) {
        cout << (C(n + 1, i + 1) - C(L + R, i) + mod )% mod << endl;
    }


    return 0;
}


Measured memory_bytes: 23936
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print1(a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=200005;
//i_am_noob
int n,a[maxn],minn=4e18,ans=0;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n;
	rep(n) cin >> a[i];
	rep(n) if(a[i]<minn){
		minn=a[i];
		ans++;
	}
	print1(ans);
	return 0;
}

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

using namespace std;

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

  int n;
  long long a, b, m;
  cin >> n >> m;
  vector<pair<long long, long long>> vec;
  while (n--) {
    cin >> a >> b;
    vec.push_back({a, b});
  }
  sort(vec.begin(), vec.end(), [&](pair<long long, long long> x, pair<long long, long long> y) {return x.first < y.first;});
  long long res = 0;
  for (auto &p : vec) {
    res += p.first * min(p.second, m);
    m -= min(p.second, m);
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 2420
#include<iostream>
using namespace std;
 
int main() {
	int N, m;
	cin >> N;
	m = N;
	int c = 0;
	while (m > 0) {
		c += m % 10;
		m /= 10;
	}
	if (N % c == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>

#define LENGTH 256

int main(void){
  char input[LENGTH];
  int n,result;
  fgets(input,LENGTH-1,stdin);
  sscanf(input,"%d",&n);

  result = n % 1000;
  if(result != 0){
  result = 1000 - result;
}
  printf("%d\n",result);

  return 0;
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int a,b,t,ans;

int main(){
    cin >> a >> b >> t;
    for(int i = a;i <= t;i += a){
        ans += b;
    }
    cout << ans << endl;
}

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

string getResult(string S, int w){
  const size_t size = S.size();
  string result = "";
  for(size_t i = 0; i < size; i += w){
    result.push_back(S[i]);
  }
  return result;
}

int main(){
  string S;
  int w;
  cin >> S >> w;
  
  string result = getResult(S, w);  
  cout << result;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int sum=0;
  int si=s.size();
  rep(i,si){
    if(s[i]=='o'){
      sum++;
    }
  }
  cout<<(sum+15-si>=8 ? "YES" : "NO")<<'\n';
  return(0);
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int w=stdIn.nextInt(),a=stdIn.nextInt(),b=stdIn.nextInt();
		if(b+w>=a&&a+w>=b) System.out.print(0);
		else if(a>b+w) System.out.print(a-b-w);
		else System.out.print(b-a-w);
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
const int MAXN=10000;
const int INF=400000;
using namespace std;

map<long long, int> pos;

void mainp()
{
	string s;
	cin>>s;
	
	pos[0]=0;
	long long num=0ll;
	int temp=INF;
	for(int i=s.size()-1; i>=0; i--)
	{
		num^=(1<<(s[i]-'a'));
		temp=INF;
		for(int j=0; j<26; j++)
		{
			num^=(1<<j);
			if(pos.count(num)) temp=min(temp, pos[num]);
			num^=(1<<j);
		}
		if(pos.count(num)) temp=min(temp, pos[num]);
		
		if(!pos.count(num)) pos[num]=temp+1;
		else if(pos[num]>temp+1) pos[num]=temp+1;
	}
	
	cout<<temp+1<<endl;
}
int main()
{
	mainp();
	return 0;
}


Measured memory_bytes: 12932
#include<bits/stdc++.h>
int main()
{
  char s[101],str[101];
  int num=0,i=0,j,lenth=0;
  scanf("%s",s);
  while(s[i]!='\0')
  {
  i++;
  lenth++;
  }
  for(i=lenth-1,j=0;i>=j;i--,j++)
  {

  if(s[i]!=s[j])
  {
  num++;
  }

  }
 printf("%d",num);
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  cin>>s;
  reverse(s.begin(), s.end());
  string ans="";
  if(s[0] == '2' || s[0] == '4' || s[0] == '5' || s[0] == '7' || s[0] == '9') ans = "hon";
  else if(s[0] == '0' || s[0] == '1' || s[0] == '6' || s[0] == '8') ans = "pon";
  else if(s[0] == '3') ans = "bon";
  else assert(0);
  cout<<ans<<endl;


  return 0;
}


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

vector< pair< pair<int, int>, int > > X;

int getDig(int N)
{
    int ans = ((N & (N+1)) == 0);
    
    while(N)
        ans++, N/= 2;
    
    return ans;
}

int main() {

    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);
    
    int L;
    cin >> L;
    
    L--;
    
    int curr = 1;
    int N = getDig(L);
    
    while(L)
    {
        X.push_back({{curr, curr+1}, 0});
        
        if(L % 2 == 0)
            X.push_back({{curr, N}, L});
        
        X.push_back({{curr, curr+1}, (L+1)/2});
        L = (L-1)/2, curr++;
    }
    
    cout << N << " " << X.size() << "\n";
    
    for(auto x : X)
        cout << x.first.first << " " << x.first.second << " " << x.second << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
#define mp make_pair
#define pb push_back
#define BE begin()
#define EN end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
typedef string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int N;
int A[100010];
msi s;
int solve(){
  rep(i,N){
    auto itr=s.lower_bound(A[i]);
    if(itr==s.BE){
      s.insert(A[i]);
    }
    else{
      s.erase(--itr);
      s.insert(A[i]);
    }
  }
  return s.size();
}
int main(){
  cin>>N;
  rep(i,N) cin>>A[i];
  prin(solve());
  //  for(auto itr=s.begin();itr!=s.end();itr++){
  //    prin(*itr);
  //  }
  return 0;
}


Measured memory_bytes: 5376
#include<iostream>
#include<fstream>
#include<algorithm>
#include<string>
#include<cstring>

using namespace std;

int N;

const int MAXN = 100000 + 10;

int A[MAXN];
int main() {
	cin >> N;
	for (int i = 0; i < N; i++)
		cin >> A[i];

	sort(A, A + N);
	int Ans = 0;
	int Cur = A[0];
	int Count = 0;
	for (int i = 0; i < N; i++) {
		if (Cur == A[i]) {
			Count++;
			continue;
		}
		else {
			if (Count >= Cur)
				Ans += (Count - Cur);
			else
				Ans += Count;

			Count = 1;
			Cur = A[i];
		}
	}

	if (Count >= Cur)
		Ans += (Count - Cur);
	else
		Ans += Count;

	cout << Ans << endl;

	return 0;
}

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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 1e5 + 5;


int32_t main()
{
	GO;
	int n;
	cin >> n;
	int ans = 1e17;
	for (int i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ans = min({ans, i + n / i - 2});
		}
	}
	cout << ans << endl;
	return 0;
}

//!

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

int main() {
  char in;
  cin >> in;
  if(in=='A')
    cout << "T";
  
  else if(in=='T')
    cout << "A";
  
  else if(in=='G')
    cout << "C";
  
  else if(in=='C')
    cout << "G";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define P pair<int, int>
#define V vector<int>
#define M map<int, int>
#define itn int
#define tin int
#define tni int
bool dbg = false;
string S;
set<string> ss[200010];
int ans;

void solve()
{

    int L = (int)S.size();
    int f = 0;
    itn e = 0;
    string t = " ";
    while (e < L) {
        string s = S.substr(f, e - f + 1);
        int l = (int)s.size();
        if (s == t) {
            e++;
        } else {
            t = s;
            e++;
            f = e;
            ans++;
        }
    }
    cout << ans << endl;
}


signed main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> S;
    solve();
    return 0;
}


Measured memory_bytes: 10192
#include<bits/stdc++.h>
#define ll long long
#define pii pair<ll ,int>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn =504;
ll n,m,t;
ll a[maxn];
string s;
int main(){
    ios::sync_with_stdio(false);
//    #ifdef NK
//        freopen("in.txt","r",stdin);
//    #endif
    cin>>t;
    while(t--){
        vector<ll>b;
        cin>>n;
        for(int i=1;i<=n;i++)cin>>a[i];
        cin>>s;
        s="#"+s;
        int ok=1;
        for(int i=n;i;i--){
            ll v=a[i];
            for(ll x:b){
                v=min(v,v^x);
            }
            if(s[i]=='1'){

                if(v){
                    ok=0;
                    break;
                }
            }else{
                b.push_back(v);
            }

        }
        cout<<(ok?"0\n":"1\n");
    }

    return 0;
}


Measured memory_bytes: 3572
#include<stdio.h>
main(){
  int a,b,i,j,c[100][100];
  char s[100][100];
  while(1){
    scanf("%d %d",&a,&b);
    if(a==0 && b==0){
      break;
    }
    for(i=0;i<a;i++){
      scanf("%s",s[i]);
      for(j=0;j<b;j++){
	c[i][j]=0;
      }
    }
    i=0;
    j=0;
    while(1){
      if(c[i][j]==1){
	printf("LOOP\n");
	break;
      }
      else if(s[i][j]=='>'){
	c[i][j]=1;
	j++;
      }
      else if(s[i][j]=='<'){
	c[i][j]=1;
	j--;
      }
      else if(s[i][j]=='v'){
	c[i][j]=1;
	i++;
      }
      else if(s[i][j]=='^'){
	c[i][j]=1;
	i--;
      }
      else if(s[i][j]=='.'){
	printf("%d %d\n",j,i);
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 664
fun main(args: Array<String>) {
    val N = nextInt()
    val A = listOfInt()
    var sum = 0L
    var min = Int.MAX_VALUE
    var fu = 0
    for (a in A) {
        var b: Int
        if (a < 0) { fu += 1; b = -a } else b = a
        sum += b
        if (min > b) min = b
    }
    val ans = if (fu % 2 == 1) sum - min * 2 else sum
    println(ans)
}
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)

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

#define x1 x19260817
#define y1 y19268107

int n;
long long ans;
struct point {
  int x, y;
  double v;
  point(int x = 0, int y = 0)
  : x(x), y(y) { v = (abs(x) + abs(y) ? atan2(y, x) : -1e9); }
  friend bool operator < (const point &x, const point &y) {
    return x.v < y.v;
  }
} a[205];

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    int x, y; scanf("%d%d", &x, &y);
    a[i] = point(x, y);
  }
  sort(a + 1, a + n + 1);
  for (int i = n + 1; i <= n * 2; ++i)
    a[i] = a[i - n];
  for (int i = 1; i <= 2 * n; ++i)
    for (int l = 1; l <= n; ++l) {
      long long x = 0, y = 0;
      for (int j = 1; j <= l; ++j) {
        if (i + j > 2 * n) break;
        x += a[i + j].x, y += a[i + j].y;
        ans = max(ans, x * x + y * y);
      }
    }
  printf("%.12f\n", sqrt(ans));
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		final int DATA_SIZE = 10;
		int height;
		int first=-1,second=-1,third=-1;
		for(int i=0; i<DATA_SIZE; i++) {
			height = scanner.nextInt();
			if(height>first) {
				third = second;
				second = first;
				first = height;
			} else if(height>second) {
				third = second;
				second = height;
			} else if(height>third) {
				third = height;
			}
		}
		
		System.out.printf("%d\n%d\n%d\n",first, second, third);
	}

}

Measured memory_bytes: 26424
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ll long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fr(i, a, b) for(int i=a; i>=b; i--)
#define l long int
#define endl '\n'
#define pb push_back
#define pf pop.front()
using namespace std;


void solve()
{
l k;
cin>>k;
l cnt=1;
l i=7;
int y=1;
for(ll cnt=1;cnt<1e7;cnt++)
{
	if(i%k ==0)
	{
	cout<<cnt<<endl;
	y=0;
	break;
	}
	else{
		i*=10;
		i+=7;
		i %=k;
	}
	
	
}
if(y) cout<<"-1";
}


int32_t main()
{
FAST
l T=1;
//cin>>T;
while(T--)
{
solve();
}
}










Measured memory_bytes: 3636
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import *
from bisect import *

def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]

INF = 1 << 60

N, K, Q = reads()
A = reads()

A.append(-INF)
def getlub(y):
  v = []
  l = 0
  for i in range(N+1):
    if A[i] < y:
      w = A[l:i]
      w.sort()
      if len(w) >= K-1:
        v.extend(w[:len(w)-K+1])
      l = i + 1
  v.sort()
  return v[Q-1] if len(v) >= Q else INF

ans = INF
for Y in A[:-1]:
  X = getlub(Y)
  ans = min(ans, X - Y)
print(ans)

Measured memory_bytes: 45020
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <sstream>
#include <set>
using namespace std;
using ll = long long;

class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

char s[520][520];

int main() {
  int H, W;
  while (scanf("%d%d", &H, &W) != EOF) {
    for (int i : range(H)) scanf(" %s", s[i]);

    for (int i : range(H)) {
      for (int j : range(W)) {
        if (j != W - 1 && (j == 0 || i % 2 == 0 || s[i][j] == '#')) printf("#");
        else printf(".");
      }
      puts("");
    }

    puts("");

    for (int i : range(H)) {
      for (int j : range(W)) {
        if (j != 0 && (j == W - 1 || i % 2 == 1 || s[i][j] == '#')) printf("#");
        else printf(".");
      }
      puts("");
    }
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const ll mod = 1e9 + 7;

vll dijkstra(vvll &e, ll s) {
    ll n = e.size();
    vll d(n), used(n);
    queue<ll> que;
    d[s] = 0;
    used[s] = 1;
    que.push(s);
    while (!que.empty()) {
        ll cur = que.front();
        que.pop();
        for (auto nxt : e[cur]) {
            if (used[nxt]) continue;
            d[nxt] = d[cur] + 1;
            que.push(nxt);
            used[nxt] = 1;
        }
    }
    return d;
}

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

    ll n, u, v;
    cin >> n >> u >> v;
    u--, v--;
    ll a, b;
    vvll e(n);
    REP(i, n - 1) {
        cin >> a >> b;
        a--, b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    vll du = dijkstra(e, u), dv = dijkstra(e, v);

    ll res = dv[u] - 1;
    REP(i, n) {
        if (dv[i] >= du[i]) res = max(res, dv[i] - 1);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 8816
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

LL dp[100001][2][101] = {};  // keta, smaller, sum % D

int main() {
  string S; cin >> S;
  int D; cin >> D;
  int N = S.size();
  dp[0][0][0] = 1;

  for (int i = 0; i < N; ++i) {
    int d = S[i] - '0';
    for (int sum = 0; sum < D; ++sum) {
      for (int n = 0; n < 10; ++n) {
        int nsum = (sum + n) % D;
        if (n < d) {
          dp[i + 1][1][nsum] += dp[i][0][sum] + dp[i][1][sum];
        } else if (n == d) {
          dp[i + 1][0][nsum] += dp[i][0][sum];
          dp[i + 1][1][nsum] += dp[i][1][sum];
        } else {
          dp[i + 1][1][nsum] += dp[i][1][sum];
        }

        dp[i + 1][0][nsum] %= kMod;
        dp[i + 1][1][nsum] %= kMod;
      }
    }
  }
  cout << (dp[N][0][0] + dp[N][1][0] + kMod - 1) % kMod << endl;
}


Measured memory_bytes: 19380
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 #define int long long

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second


using namespace __gnu_pbds;
using namespace std;
// const int mod=1e9+7;
 const int mod=998244353;
 // const int mod=1e9+9;
// const int INF=4e18+10;
const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i;


typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

template<typename T1,typename T2>
void set_min(T1& a, T2 b)
{
    a=min(a, (T1)b);
}


int multiply(int a, int b, int in_mod){return (a*b)%in_mod;}
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);

        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}


void solve()
{

    int n;
    cin>>n;
    int s;
    cin>>s;
    readv(a,n);

    a.insert(a.begin(),0);

    vector<vector<int>> dp(n+1, vector<int> (s+1));
    dp[0][0] = power(2, n, mod)%mod;

    int temp = mod_inv(2, mod);
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=s;j++)
        {
            dp[i][j] = dp[i-1][j];
            if(j>=a[i])
            {
                dp[i][j] +=dp[i-1][j-a[i]]*temp%mod;
                dp[i][j]%=mod;
            }
        }
    } 
    cout<<dp[n][s]<<endl;

}

signed main()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    auto clk=clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------
    int t=1;
    // cin>>t;
    for(int test=1;test<=t;test++)
    {
        // cout<<"Case #"<<test<<": ";
        // cout<<endl;
        solve();
        // cout<<endl;

    }

    // -------------------------------------Code ends here------------------------------------------------------------------


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
}


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

# define x first
# define y second
# define mp make_pair
// everything goes according to my plan
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right

//put debug temp

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") {
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}


int main()
{
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  int n, k;
  cin >> n >> k;
  int a[n+1];
  for (int i = 1; i <= n; i++)
  	cin >> a[i];

   bitset<5000> dp[n+1], ds[n+2];
   dp[0][0] = 1;
   ds[n+1][0 ] =1;
  for (int i = 1; i <= n; i++) {
  	dp[i] = ((dp[i - 1] << a[i]) | (dp[i - 1]));
  }
  for (int  i= n; i >= 1; i--) {
  	ds[i ]= ((ds[i+ 1] << a[i]) | ds[i + 1]);
  }
  int ans = 0;
  vec<int> pref(k+1);

  for (int i = 1; i <= n; i++) {
  	bool good = 1;
  	pref[0] = (dp[i-1][0] == 1);
  	for (int j = 1; j <= k; j++) {
  		pref[j] = (pref[j - 1] + (dp[i-1][j] == 1));
  	}

  	for (int f = 0; f <= k-1; f++) {
  		int s = k-a[i] - f;
  		//cout << i << ' ' << f << ' ' << s << ' ' << k-1-f << endl;
  		if (ds[i+1][f] == 1 && pref[k-1-f] - (s <= 0 ? 0 : pref[s - 1]) >= 1) {
  			good = 0;
  			//cout << i << ' ' << f << ' ' << s << endl;
  			break;
  		}
  	}
 	if (good)
 		ans++;
  }
  cout << ans;


  return 0;
}





// Coded by Z..

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yes(){
    cout << "Yes" << endl;
}

void no (){
    cout << "No" << endl;
}

ll cel (ll a, ll b){
    if (a % b == 0) return a / b;
    else return a / b + 1;
}

ll gcds(ll a, ll b){
    ll c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

int main() {
    int a, b, k; cin >> a >> b >> k;
    int cnt = 0;
    for (int i = 105; i >= 1; i--){
        if (a % i == 0 && b % i == 0) cnt++;
        if (cnt == k){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3632
;; E - Roaming

(defparameter *modulus* (+ (expt 10 9) 7))

(defun solve (n k)
  "sum((n人をn-m部屋に空き部屋なしで分ける) * (m個の空き部屋の配置)
       for m in range(0, min(k, n-1) + 1))"
  ; = sum(choose(n-1, n-m-1) * choose(n, m))
  ; = sum(choose(n-1, m) * choose(n, m))
  ; = sum((n-m) * choose(n, m)**2)/n
  ; choose(n, m+1) = choose(n, m) * (n-m)/(m+1)
  (mod/ (loop for m from 0 below (min n (1+ k))
              and choose-n-m = 1
                  then (mod/ (mod* choose-n-m (- n m)) (1+ m))
          sum (mod* (- n m) choose-n-m choose-n-m))
        n))

(defun main ()
  (let ((n (read))
        (k (read)))
    (princ (solve n k))))

;; modulo addition/product/division

(defun mod+ (&rest rest)
  (mod (apply #'+ rest) *modulus*))

(defun mod* (&rest rest)
  (mod (apply #'* rest) *modulus*))

(defun mod/ (num &rest denom)
  (apply #'mod* (cons num (mapcar #'mod-inverse denom))))

(defun bit-sequence (v)
  "(bit-sequence 13) => (1 1 0 1)"
  (nreverse
    (loop for x = v then (ash x -1) while (plusp x)
          collect (logand x 1))))

(let ((modulus-2-bits (bit-sequence (- *modulus* 2))))
  ; Mが素数のとき，a^(M-2) ≡ a^(-1) mod M (フェルマーの小定理より)
  (defun mod-inverse (a)
    (loop for b in modulus-2-bits
          for e = a then (mod* e e (if (zerop b) 1 a))
          finally (return e))))

(main)


Measured memory_bytes: 57952
/*
    Written by Nitrogens
    Desire for getting accepted!!
*/
#include <cstdio>
#include <ctime>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <bitset>
#include <stack>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 1e5+5;
const int Mod = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e = exp(1);
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first
#define pb push_back
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl

int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);

    int x;
    scanf("%d", &x);
    int delta = 1, ans = 0;
    while (x > 0) {
        x -= delta;
        delta++;
        ans++;
    }
    printf("%d\n", ans);

    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
using namespace std;

int main(){

	int N;
	scanf("%d",&N);

	int** table = new int*[N];
	for(int i = 0; i < N; i++)table[i] = new int[3];

	int ans = 0;

	for(int i = 0; i < N; i++){
		scanf("%d %d %d",&table[i][0],&table[i][1],&table[i][2]);
		for(int k = 0; k <= 1; k++){
			for(int j = 2; j > k; j--){
				if(table[i][j] > table[i][j-1])swap(table[i][j],table[i][j-1]);
			}
		}
	}

	for(int i = 0; i < N-1; i++){
		for(int k = i+1; k < N; k++){
			if(table[i][0] == table[k][0] && table[i][1] == table[k][1] && table[i][2] == table[k][2]){
				ans++;
				break;
			}
		}
	}

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

    return 0;
}


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

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define tll tuple<ll, ll, ll>
#define all(c) c.begin(),c.end()

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
 
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;

//command
//c++ atcoder.cpp -std=c++14
//./a.out

//fill(score, score+202020, 0);
#define NN 2020202

ll kai(ll x){
  if (x <= 1) return 1;
  else return x * kai(x - 1);
}

int main(){
  ll n;
  cin >> n;
  ll x, y;
  vl vec[n];
  for (int i=0;i<n;i++){
    cin >> x >> y;
    vec[i].push_back(x);
    vec[i].push_back(y);
  }
  
  double ans = 0;
  for (int i=0;i<n;i++){
    for (int j=i+1;j<n;j++){
      ans += sqrt((vec[i][0] - vec[j][0])*(vec[i][0] - vec[j][0]) + (vec[i][1] - vec[j][1])*(vec[i][1] - vec[j][1]));
      //cout << setprecision(12) << ans << endl;
    }
  }

  //float multi = kai(n) * (n - 1) / (n*(n-1)/2);
  //cout << n << " " << kai(n) << " " << multi << endl;
  //ans *= multi;
  ans = ans/(n*(n-1)/2) * (n-1);

  cout << setprecision(14) << ans << endl;
}



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

namespace Prac
{
    class Program
    {
        static void Main(string[] args)
        {
            var ns = new List<int>();
            var xs = new List<int>();
            List<int> results = new List<int>();
            var result = 0;
            var temp = new int[2];
            while (true)
            {
                temp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                if ((temp[0] == 0) && (temp[1] == 0))
                    break;
                ns.Add(temp[0]);
                xs.Add(temp[1]);
            }
            int k = 0;
            for (var i = 0; i < ns.Count; i++)
            {
                for (var j = 1; j <= xs[i] / 3; j++)
                {
                    k = j + 1;
                    for (; k <= (xs[i] - j) / 2; k++)
                    {
                        if (((xs[i] - j - k) <= ns[i]) && ((xs[i] - j - k) > (k)))
                            result++;
                    }
                }
                results.Add(result);
                result = 0;
            }
            foreach(var r in results)
            Console.WriteLine(r);

        }
    
    }
}

Measured memory_bytes: 5944
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    //                      7    6    5     4     3     2     1
    vector<string> day = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string str;
    cin >> str;
    rep(i,7){
        if(str == day[i]){ cout << 7-i << endl; break;}
    }


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int a,b,k,c=0;
  cin>>a>>b>>k;
  for(int i=100; i>=1; i--) {
    if(a%i==0&&b%i==0) {
      c++;
    }
    if(c==k) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
H,W = map(int,input().split())
A = [list(input()) for _ in range(H)]

emp_row = [False] * H
emp_col = [False] * W

for i in range(H):
  isEmp = True
  for j in range(W):
    if A[i][j] == "#":
      isEmp = False
      break
  emp_row[i] = isEmp
  
for i in range(W):
  isEmp = True
  for j in range(H):
    if A[j][i] == "#":
      isEmp = False
  emp_col[i] = isEmp
  
ANS = []
for i in range(H):
  if emp_row[i]:
    continue
  row = []
  for j in range(W):
    if emp_col[j]:
      continue
    row.append(A[i][j])
  ANS.append(row)
  
for a in ANS:
  print("".join(a))
    

Measured memory_bytes: 3188
import java.io.*
import java.util.*

val pw = PrintWriter(System.out)
const val MOD = 1000000007L
const val INF = 2147483647
const val LINF = 9223372036854775807L

fun main(args: Array<String>) {
    solve()
    pw.flush()
}

fun solve() {
    val n = nextInt()
    val ary = intAry2(n + 1, 3)
    repeat(n){
        val (t, x, y) = nextIntList()
        ary[it][0] = t
        ary[it][1] = x
        ary[it][2] = y
    }
    ary[n][0] = 0
    ary[n][1] = 0
    ary[n][2] = 0
    ary.sortBy { it[0] }

    for (i in 0 until n){
        val time = ary[i + 1][0] - ary[i][0]
        val dist = abs((ary[i + 1][1] + ary[i + 1][2]) - (ary[i][1] + ary[i][2]))
        if(time % 2 != dist % 2 || dist > time){
            println("No")
            return
        }
    }

    println("Yes")


}


fun println(v: String) {
    pw.println(v)
}

fun print(v: String) {
    pw.print(v)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ").toMutableList()
fun nextIntList(index: Int = 0) = next().split(" ").map { it.toInt() + index }.toMutableList()
fun nextLongList(index: Long = 0L) = next().split(" ").map { it.toLong() + index }.toMutableList()
fun nextDoubleList() = next().split(" ").map { it.toDouble() }.toMutableList()

fun ary(n: Int, init: String = "") = Array(n) { init }
fun intAry(n: Int, init: Int = 0) = IntArray(n) { init }
fun longAry(n: Int, init: Long = 0L) = LongArray(n) { init }
fun doubleAry(n: Int, init: Double = 0.0) = DoubleArray(n) { init }
fun ary2(n: Int, m: Int, init: String = "") = Array(n) { Array(m) { init } }
fun intAry2(n: Int, m: Int, init: Int = 0) = Array(n) { IntArray(m) { init } }
fun longAry2(n: Int, m: Int, init: Long = 0) = Array(n) { LongArray(m) { init } }
fun doubleAry2(n: Int, m: Int, init: Double = 0.0) = Array(n) { DoubleArray(m) { init } }
fun ary3(n: Int, m: Int, k: Int, init: String = "") = Array(n) { Array(m) { Array(k) { init } } }
fun intAry3(n: Int, m: Int, k: Int, init: Int = 0) = Array(n) { Array(m) { IntArray(k) { init } } }
fun longAry3(n: Int, m: Int, k: Int, init: Long = 0L) = Array(n) { Array(m) { LongArray(k) { init } } }
fun doubleAry3(n: Int, m: Int, k: Int, init: Double = 0.0) = Array(n) { Array(m) { DoubleArray(k) { init } } }

fun abs(n: Int): Int = Math.abs(n)
fun abs(n: Long): Long = Math.abs(n)
fun abs(n: Double): Double = Math.abs(n)
fun max(a: Int = -INF, b: Int = -INF, c: Int = -INF, d: Int = -INF, e: Int = -INF): Int = listOf(a, b, c, d, e).max()!!
fun max(a: Long = -LINF, b: Long = -LINF, c: Long = -LINF, d: Long = -LINF, e: Long = -LINF): Long =
    listOf(a, b, c, d, e).max()!!.toLong()

fun min(a: Int = INF, b: Int = INF, c: Int = INF, d: Int = INF, e: Int = INF): Int = listOf(a, b, c, d, e).min()!!
fun min(a: Long = LINF, b: Long = LINF, c: Long = LINF, d: Long = LINF, e: Long = LINF): Long =
    listOf(a, b, c, d, e).min()!!.toLong()


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

using namespace std;

int main()
{
    int num = 753;
    string s;
    cin >> s;

    int cur = 1000000;
    for(int i = 0; i < s.length() - 2; i++){
        int subs = stoi(s.substr(i, 3));
        int diff = abs(num - subs);
        if(diff < cur){
            cur = diff;
        }
    }
    cout << cur << endl;
    return 0;
}

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

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

    int v[n];
    for(int i=0;i<n;i++) cin >> v[i];

    int count=0;

    bool flag = 1;
    while(flag){
        flag = 0;
        for(int j=n-1;j>=1;j--){
            if(v[j] < v[j-1]){
                int tmp = v[j];
                v[j] = v[j-1];
                v[j-1] = tmp;
                flag = 1;
                count++;
            }
        }
    }
    for(int i=0;i<n-1;i++) cout << v[i] << " ";
    cout << v[n-1] << endl;
    cout << count << endl;
}

Measured memory_bytes: 1164