akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}

void pribin(int n,int b){
	int bit=(int)pow(2,b-1);
	while(bit){
		printf("%d",(n&bit)!=0);
		bit>>=1;
	}
}

int main(void){
	double n,f[16][2]={0};
	int i,tmp;
	for(i=0;i<16;i++){
		f[i][0]=i;
		f[i][1]=(double)i/16;
	}
	while(1){
		scanf("%lf",&n);
		if(n<0){
			break;
		}
		tmp=n;
		if(tmp>255){
			puts("NA");
		}
		else{
			for(i=0;i<16;i++){
				if(f[i][1]==n-tmp){
					break;
				}
			}
			if(i==16){
				puts("NA");
			}
			else{
				pribin(tmp,8);
				printf(".");
				pribin((int)f[i][0],4);
				puts("");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 688
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N, K, result = 1;
  
  cin >> N >> K;
  
  for ( int i = 0; i < N; i++ ) {
    
    if ( result > K )
      result += K;
    else
      result *= 2;
    
  }
  
  cout << result << endl;
  
}

Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <climits>
using namespace std; 

const int INF = 1 << 29;

int main(){

    int n,k;
    cin >> n>>k;
    vector<int> h(n);
    for(int& i : h){
        cin >> i;
    }

    vector<int> cache(n,INT_MAX);

    cache[0] = 0;
    cache[1] = abs(h[1] - h[0]);

    for(int i = 2; i < n; ++i){
      	for(int j = 1; j<=k; j++)
        {
          	if((i-j)<0)
            {
              break;
            }
        	cache[i] = min(cache[i],cache[i - j] + abs(h[i] - h[i - j]));
        }
    }

    cout << cache[n - 1];
    return 0;
}


Measured memory_bytes: 1024
import java.io.{BufferedReader, InputStreamReader}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val t = in.readLine().split("\\s+").map(_.toLong)
    val a = in.readLine().split("\\s+").map(_.toLong)
    val b = in.readLine().split("\\s+").map(_.toLong)

    val ta0 = t(0) * a(0)
    val ta1 = t(1) * a(1)
    val tb0 = t(0) * b(0)
    val tb1 = t(1) * b(1)

    System.out.println(
      if (ta0 > tb0) {
        solve(ta0, ta1, tb0, tb1)
      } else {
        solve(tb0, tb1, ta0, ta1)
      }
    )
  }

  def solve(ta0: Long, ta1: Long, tb0: Long, tb1: Long): String = {
    if (ta0 + ta1 > tb0 + tb1) {
      "0"
    } else if (ta0 + ta1 == tb0 + tb1) {
      "infinity"
    } else {
      val initial = ta0 - tb0
      val diff = (ta0 - tb0) + (ta1 - tb1)
      val times = initial / -diff
      val just = initial % -diff == 0

      (
        times * 2 + (if (just) 0 else 1)
        ).toString
    }
  }
}


Measured memory_bytes: 27312
// 暫定値がK以下か,Kより大きいかで場合分けする.
#include<iostream>
using namespace std;
int main() {
  int n,k; cin >> n >> k;
  int num=1;
  for(int i=0;i<n;i++){
    if(num<=k) num = num*2;
    else num = num + k;
  }
  cout << num << endl;
  return 0;
}

Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;//, core.stdc.stdio;

alias Tuple!(int, "l", int, "r", int, "x") Condition;
immutable int MOD = 10^^9 + 7;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto C = new Condition[][](N+1);
    foreach (i; 0..M) {
        s = readln.split.map!(to!int);
        C[s[1]] ~= Condition(s[0], s[1], s[2]);
    }

    auto dp = new int[][][](N+1, N+1, N+1);
    dp[0][0][0] = 1;
    
    foreach (i; 0..N) {
        foreach (j; 0..N) {
            foreach (k; 0..N) {
                int mx = max(i, max(j, k));
                (dp[mx+1][j][k] += dp[i][j][k]) %= MOD;
                (dp[i][mx+1][k] += dp[i][j][k]) %= MOD;
                (dp[i][j][mx+1] += dp[i][j][k]) %= MOD;
                foreach (c; C[mx+1]) {
                    if (c.x == 1) {
                        if (j >= c.l || k >= c.l) dp[mx+1][j][k] = 0;
                        if (k >= c.l || i >= c.l) dp[i][mx+1][k] = 0;
                        if (i >= c.l || j >= c.l) dp[i][j][mx+1] = 0;
                    } else if (c.x == 2) {
                        if (j <  c.l && k <  c.l) dp[mx+1][j][k] = 0;
                        if (j >= c.l && k >= c.l) dp[mx+1][j][k] = 0;
                        if (k <  c.l && i <  c.l) dp[i][mx+1][k] = 0;
                        if (k >= c.l && i >= c.l) dp[i][mx+1][k] = 0;
                        if (i <  c.l && j <  c.l) dp[i][j][mx+1] = 0;
                        if (i >= c.l && j >= c.l) dp[i][j][mx+1] = 0;
                    } else {
                        if (j < c.l || k < c.l) dp[mx+1][j][k] = 0;
                        if (k < c.l || i < c.l) dp[i][mx+1][k] = 0;
                        if (i < c.l || j < c.l) dp[i][j][mx+1] = 0;
                    }
                }
            }
        }
    }


    
    int ans = 0;
    
    foreach (i; 0..N+1) {
        foreach (j; 0..N+1) {
            if (dp[i][j][N] != -1) (ans += dp[i][j][N]) %= MOD;
            if (dp[i][N][j] != -1) (ans += dp[i][N][j]) %= MOD;
            if (dp[N][i][j] != -1) (ans += dp[N][i][j]) %= MOD;
        }
    }

    ans.writeln;
}


Measured memory_bytes: 193532
#include<stdio.h>

int main(void){

int n,a;
scanf("%d",&n);

int num[n]; int quick[n];
for(a = 0; a< n; a++) scanf("%d",&num[a]);
for(a = 0; a< n; a++)  quick[a] = num[a];

void Swap(int x[ ], int i, int j)
{
    int temp;

    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
}

void QSort(int x[ ], int left, int right)
{
    int i, j;
    int pivot;

    i = left;                      
    j = right;                    

 pivot = x[(left + right) / 2]; 

    while (1) {                    

        while (x[i] < pivot)       
            i++;                   

        while (pivot < x[j])      
            j--;                  
        if (i >= j)               
            break;                 

        Swap(x, i, j);             
        i++;                    
        j--;
    }


    if (left < i - 1)            
        QSort(x, left, i - 1);   
    if (j + 1 <  right)         
        QSort(x, j + 1, right);  
}



QSort(quick,0,n-1);


for(a = 0; a < n; a++){
if(num[a] >= quick[n/2]) printf("%d\n",quick[n/2 - 1]);
else printf("%d\n",quick[n/2]);
}
 

return 0;
}

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

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
typedef vector<int> V;
typedef vector<V> VV;
V path;
VV g;
int N;
int dfs(int v,int p){
    if(v==N-1)return 1;
    int res=0;
    for(auto &u:g[v])if(u!=p){
            res|=dfs(u,v);
    }
    if(res&&v!=0)path.pb(v);
    return res;
}
int main(){
    cin>>N;g.resize(N);
    REP(i,N-1){
        int a,b;
        cin>>a>>b;
        a--,b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    dfs(0,0);
    V color(N,-1);
    color.front()=0;
    color.back()=1;
    reverse(ALL(path));
    int m=path.size();
    {
        int bg=0,ed=m-1;
        while(bg<ed){
            color[path[bg++]]=0;
            color[path[ed--]]=1;
        }
        if(bg==ed)color[path[bg]]=0;
    }
    queue<int> que;
    que.push(0);
    for(auto &it:path){
        que.push(it);//cout<<it+1<<endl;
    }
    que.push(N-1);
    while(que.size()){
        int v=que.front();que.pop();
        for(auto &u:g[v])if(color[u]==-1){
                color[u]=color[v];
                que.push(u);
            }
    }
    int X=0,Y=0;
    REP(i,N)if(color[i]==0)X++;else Y++;
    if(X<=Y)cout<<"Snuke"<<endl;
    else cout<<"Fennec"<<endl;
    return 0;
}


Measured memory_bytes: 13176
while True:
    n,k=map(int,input().split())
    if n==0 and k==0:
        break
    a=[int(input()) for _ in range(n)]
    s=sum(a[0:k])
    ss=[s]
    for i in range (k,n):
        s=s+a[i]-a[i-k]
        ss.append(s)
    print(max(ss))
    


Measured memory_bytes: 11700
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 7400000;

int main()
{
    int m,n;
    while(scanf(" %d %d", &m, &n),m)
    {
        vector<bool> x(N);
        int i;
        for(i=m; i<N; ++i)
        {
            if(!x[i])
            {
                for(int j=i; j<N; j+=i) x[j]=true;
                --n;
                if(n==0) break;
            }
        }

        while(x[i]==1) ++i;
        cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 4076
#include<bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define fs first
#define sc second
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<tuple<ll,ll>> vtl;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
#define pf(a) cout << (a) << endl;
#define be(x) (x).begin(),(x).end()
bool is_prime(ll n){
    if(n==2)return true;
    else if(n<2||n%2==0)return false;
    ll i=3;
    while(i<=sqrt(n)){
        if(n%i==0)return false;
        i+=2;
    }
    return true;
}
void solve(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans=0;
    rep(i,n-2){
        if(s.substr(i,3)=="ABC")ans++;
    }
    cout<<ans<<endl;
}

int main(){
    cout<<std::fixed<<std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int minb = 1000000006;

int path = 0;
int N, M;
vector<vector<int>> G;
vector<int> used;

void dfs(int a) {
	bool h = true;
	for (int i = 0; i < N; i++) {
		if (!used[i])h = false;
	}
	if (h)path++;
	for (int i = 0; i <G[a].size() ; i++) {
		if (used[G[a][i]])continue;
		used[G[a][i]] = true;
		dfs(G[a][i]);
		used[G[a][i]] = false;
	}
}

int main() {
	cin >> N >> M;
	G = vector<vector<int>>(N);
	used = vector<int>(N);
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	used[0] = true;
	dfs(0);
	cout << path << endl;
}

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

int DFS(const std::vector<std::vector<int>> &connection, std::vector<bool>& seenTable, int v, int depth)
{
    // 深さ == 全ノード数になったらOK
    if (depth == seenTable.size())
        return 1;

    seenTable[v] = true;

    int result = 0;
    for (auto connectTo : connection[v])
    {
        // 途中で通った道を通る経路はダメ
        if (seenTable[connectTo])
            continue;

        result += DFS(connection, seenTable, connectTo, depth + 1);
    }

    seenTable[v] = false;

    return result;
}

int main()
{
    // 頂点数と辺数
    int N, M;
    std::cin >> N >> M;

    std::vector<std::vector<int>> connection(N);
    for (int i = 0; i < M; ++i)
    {
        int a, b;
        std::cin >> a >> b;
        connection[a-1].push_back(b-1);
        connection[b-1].push_back(a-1);
    }

    int startNode = 0;
    std::vector<bool> seenTable(N, false);
    std::cout << DFS(connection, seenTable, startNode, 1);
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
*A, = map(int, input().split())
C = Counter(A)
dup = 0
acc = 0
k = len(C)
for c in C.values():
    acc += c
    if c > 1:
        dup += c - 1

print(k if dup % 2 == 0 else k - 1)


Measured memory_bytes: 18656
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> P2;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, M, K;
int A[100000];
int U[100000], R[100000];
int find(int x) {
  if (U[x] == x) return x;
  return U[x] = find(U[x]);
}
void unite(int x, int y) {
  x = find(x), y = find(y);
  if (x == y) return;
  if (R[x] < R[y]) swap(x, y);
  U[y] = x;
  R[x] += R[y];
}
bool same(int x, int y) { return find(x) == find(y); }

vector<int> G[100000];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> M >> K;
  rep(i, N) {
    cin >> A[i], A[i]--;
    if (A[i] != -1) G[A[i]].pb(i);
    U[i] = i, R[i] = 1;
  }
  rep(c, K) for (int x : G[c]) unite(x, G[c][0]);
  vector<P2> edges;
  rep(i, M) {
    int a, b, w;
    cin >> a >> b >> w;
    a--, b--;
    edges.pb(P2(w, P(a, b)));
  }
  sort(all(edges));
  long long sum = 0;
  int cnt = K-1;
  for (P2 p : edges) {
    if (cnt == 0) break;
    int w = p._1, u = p._2._1, v = p._2._2;
    if (same(u, v)) continue;
    sum += w;
    unite(u, v);
    cnt--;
  }
  if (cnt > 0) cout << -1 << "\n";
  else cout << sum << "\n";
  return 0;
}


Measured memory_bytes: 8568
#include <stdio.h>
 
#define S(num)  ((num) * (num))
#define H(n)    ((5.0) * (n) - (5.0))
 
int main(void)
{
    float in_data;
    float time;
    float high;
    int i;
     
    while (scanf("%f", &in_data) != EOF){
        in_data*=in_data/19.6;
        i = 0;
        while (1)if (H(++i) >= in_data)break;
         
        printf("%d\n", i);
    }
     
    return (0);
}

Measured memory_bytes: 624
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;

const ll Q = 1000000007;

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    ll n;
    cin >> n;
    
    if ( n == 1 ){
        cout << 3 << endl;
        return 0;
    }
    
    string s;
    cin >> s;
    
    vector<ll> seq;
    for ( ll i = 0; i < n - 1; i++ ){
        if ( s[i] == s[i+1] ){
            seq.push_back(1);
            i++;
        } else {
            seq.push_back(0);
            if ( i == n - 2 ) seq.push_back(0);
        }
    }
    
    ll m = seq.size();
    ll ans;
    
    if (seq[0] == 0) ans = 3;
    else ans = 6;
    
    for ( ll i = 0; i < m - 1; i++ ){
        if ( seq[i] == 0 && seq[i+1] == 0 ) ans *= 2;
        else if ( seq[i] == 0 && seq[i+1] == 1 ) ans *= 2;
        else if ( seq[i] == 1 && seq[i+1] == 0 ) ans *= 1;
        else if ( seq[i] == 1 && seq[i+1] == 1 ) ans *= 3;
        ans %= Q;
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

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

using namespace std;

int calc(vector<int>& col, int i, bool isl) {
  if (i==col.size()-1) return 0;
  if (isl) {
    if (col[i] <= col[i+1]) 
      return calc(col, i+1, false);
    else
      return calc(col, i+1, true) + 1;
  } else {
    if (col[i] >= col[i+1])
      return calc(col, i+1, true);
    else
      return calc(col, i+1, false) + 1;
  }
}

int main() {
  while(1){
    string notes;
    cin>>notes;
    if(notes=="#")break;
    int n=notes.size();
    vector<int> col(n);
    REP(i,n) {
      col[i] = (notes[i] - '1') % 3;
    }
    int viol = calc(col, 0, true);
    int vior = calc(col, 0, false);
    cout << min(viol,vior) << endl;
  }
  return 0;
}

Measured memory_bytes: 2160
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  vector<ll> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      for (int k = j + 1; k < N; k++) {
        if (L[i] != L[j] && L[j] != L[k] && L[k] != L[i]) {
          if (L[i] + L[j] > L[k] && L[k] + L[j] > L[i] && L[i] + L[k] > L[j])
            ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001LL;
//constexpr double INF = 1e10;
constexpr double EPS = 1e-10;
using number = long long;

int main() {
    int n; cin >> n;
    bool f = false;
    rep(i, 9) rep(j, 9) {
        if (n == (i + 1) * (j + 1)) f = true;
    }
    cout << (f ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    n, m, X, Y = map(int, input().split())
    x = list(map(int, input().split()))
    y = list(map(int, input().split()))
    war = "War"
    for z in range(X + 1, Y + 1):
        if all([i < z for i in x]) and all([i >= z for i in y]):
            war = "No War"
            break

    print(war)


if __name__ == "__main__":
    main()


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

using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using f64 = double;
using f80 = long double;

#define FOR(v, a, b) for(i64 v = (a); v < (b); ++v)
#define FORE(v, a, b) for(i64 v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(i64 v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

using namespace std;

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T> void pout(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void pout(const T &value, const Args&... args){std::cout << value << " ";pout(args...);}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  int K;
  string S;

  while(cin >> K >> S){
    if((int)S.size() <= K) pout(S);
    else{
      std::cout << S.substr(0, K) << "..." << "\n";
    }
  }

  return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
  
typedef complex<double> P;
namespace std{
  bool operator < (const P &a,const P &b){
    return ( a.real()==b.real() ? a.imag() < b.imag() : a.real() < b.real() );
  }
};
  
P getCrossPointCC(P p1,double r1,P p2,double r2){
  double cA = (r1*r1+norm(p1-p2)-r2*r2) / (2.0*r1*abs(p1-p2));
  return p1+(p2-p1)/abs(p1-p2)*r1*P(cA,sqrt(1.0-cA*cA));
}
  
int n;
P p1,p2;
double px,py,r1,r2;
  
int main(){
    
  cin>>px>>py>>r1;
  p1=P(px,py);
  cin>>px>>py>>r2;
  p2=P(px,py);
    
  P A=getCrossPointCC(p1,r1,p2,r2);
  P B=getCrossPointCC(p2,r2,p1,r1);
  P a=min(A,B),b=max(A,B);
  printf("%.9f %.9f %.9f %.9f\n",a.real(),a.imag(),b.real(),b.imag());
  return 0;
}

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

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int gcd(int a,int b){
  while(b!=0){
    a%=b;
    swap(a,b);
  }
  return a;
}

int kaizyou(int N){
  int num=1;
  for(int i=1;i<=N;i++){
  num*=i;
  }
  return num;
}

int dy[]={-1,0,1,0};
int dx[]={0,-1,0,1};

int mod=1e9+7;

signed main() {
  int r;
  cin >> r;
  cout <<3*pow(r,2) << endl;
}

  
  
  

Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    A = [input() for _ in range(N)]
    B = [input() for _ in range(M)]
    
    def match(y, x):
        for i in range(M):
            for j in range(M):
                if A[y+i][x+j] != B[i][j]:
                    return False
        return True
    
    if any(match(i, j) for j in range(N-M+1) for i in range(N-M+1)):
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Measured memory_bytes: 9144
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

class UnionFind{
public:
  vector<int> par;
  vector<int> rank;
  vector<int> sz;
  int N;

  UnionFind(int n){N = n;}

  //初期化
  void init(){
    for(int i=0;i<N;i++){
      par.push_back(i);
      rank.push_back(0);
      sz.push_back(1);
    }
  }

  //木の根を求める
  int find(int x){
    if(par[x]==x) return x;
    else{
      par[x]=find(par[x]);
      return par[x];
    }
  }

  //xとyの集合の併合
  void unite(int x, int y){
    x=find(x);
    y=find(y);
    if(x == y) return;

    if(rank[x] < rank[y]){
      par[x] = y;
      sz[y] += sz[x];
    }else{
      par[y] = x;
      sz[x] += sz[y];
      if(rank[x] == rank[y]) rank[x]++;
    }
  }

  //x,yが同じ集合にあるか
  bool same(int x, int y){
    return find(x) == find(y);
  }

  //xの木のサイズ
  int size(int x){
    return sz[find(x)];
  }
};

//===============================================
int main(){
  int N, M;
  cin >> N >> M;

  UnionFind uf = UnionFind(N);
  uf.init();

  for(int i = 0; i < M; i++){
    int x, y, z;
    cin >> x >> y >> z;
    x--; y--;
    uf.unite(x, y);
  }

  int ans = 0;
  bool vsd[N];
  fill(vsd, vsd + N, false);
  for(int i = 0; i < N; i++){
    vsd[uf.find(i)] = true;
  }
  for(int i=0;i<N;i++){
    if(vsd[i]) ans++;
  }

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


Measured memory_bytes: 1772
IDENTIFICATION DIVISION.
PROGRAM-ID. 166B.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP        PIC X(4000).
01 N          PIC 9(03).
01 K          PIC 9(03).
01 D          PIC 9(03).
01 TBL.
   03 D1      OCCURS 100.
      05 A    PIC 9(03).
01 I          PIC 9(01) COMP.
01 J          PIC 9(03) COMP.
01 X          PIC 9(03) COMP.
01 P1         PIC 9(04) COMP.
01 P2         PIC 9(04) COMP.
01 CNT        PIC 9(03).
01 OUT        PIC Z(2)9.
*>
PROCEDURE DIVISION.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ' '
      INTO N K.
*>
  MOVE ZERO TO TBL.
  PERFORM VARYING J FROM 1 BY 1 UNTIL J > K
    ACCEPT D
    ACCEPT INP
    MOVE 1 TO P1
    PERFORM VARYING I FROM 1 BY 1 UNTIL I > D
      PERFORM VARYING P2 FROM P1 BY 1 UNTIL INP(P2:1) = ' '
      END-PERFORM
      MOVE INP(P1:P2 - P1) TO X
      ADD  1 TO A(X)
      COMPUTE P1 = P2 + 1
    END-PERFORM
  END-PERFORM.
*>
  MOVE ZERO TO CNT.
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > N
    IF (A(I) = 0) 
      ADD 1 TO CNT
    END-IF
  END-PERFORM.
*>
  MOVE CNT TO OUT.
  DISPLAY FUNCTION TRIM(OUT).
  STOP RUN.


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

using namespace std;

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

    char ch;
    cin >> ch;
    if (ch >= 65 && ch <= 90)
        cout << 'A';
    else
        cout << 'a';

    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <stdint.h>
#include <iostream>
#include <fstream>
#include <cassert>
#include <climits>
using namespace std;

#define DEBUG (0)

#if DEBUG
#define DPRINTF(...) do { \
    printf("D(L%d) %s: ", __LINE__, __func__); \
    printf(__VA_ARGS__); \
  } while (false)
#else
#define DPRINTF(...)
#endif // DEBUG

const uint64_t kInvalid = 0;

#if 0
uint64_t calFibonacci(int num, uint64_t *pArray)
{
  if (pArray[num-1] == kInvalid)
    pArray[num-1] = calFibonacci(num-1, pArray);

  if (pArray[num-2] == kInvalid)
    pArray[num-2] = calFibonacci(num-2, pArray);

  return pArray[num-1] + pArray[num-2];
}
#endif


uint64_t calFibonacci(int num, uint64_t *pArray)
{
  assert(num >= 0);

  if (num == 0 | num == 1)
    return 1;

  if (pArray[num] != kInvalid)
    return pArray[num];

  pArray[num] = calFibonacci(num-1, pArray) + calFibonacci(num-2, pArray);
  return pArray[num];
}


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

  DPRINTF("numOfFibonacci %d\n", numOfFibonacci);

  if (numOfFibonacci <= 1)
  {
    cout << "1" << endl;
    return 0;
  }

  uint64_t fibonacci[numOfFibonacci + 1];

  // init
  for (int i = 0; i <= numOfFibonacci; i++)
  {
    fibonacci[i] = kInvalid;
  }

  //fibonacci[0] = 1;
  //fibonacci[1] = 1;

  uint64_t ans = calFibonacci(numOfFibonacci, fibonacci);
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3100
use std::io::*;
use std::str::*;

fn read<T: FromStr>(s: &mut StdinLock) -> Option<T> {
    let s = s.by_ref()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn sum_digits(num: u32) -> u32 {
    num.to_string()
        .chars()
        .fold(0, |acc, y| acc + y.to_digit(10).unwrap())
}

pub fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();

    let n: u32 = read(&mut stdin).unwrap();
    let a: u32 = read(&mut stdin).unwrap();
    let b: u32 = read(&mut stdin).unwrap();

    let result = (1..n + 1)
        .map(|x| (x, sum_digits(x)))
        .filter(|x| x.1 >= a && x.1 <= b)
        .fold(0, |acc, x| acc + x.0);

    println!("{:?}", result);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

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

    ll H, W, K;
    cin >> H >> W >> K;
    vector<vector<char>> s(H, vector<char>(W));
    Rep (i, H) {
        Rep (j, W) {
            cin >> s[i][j];
        }
    }

    mat ans(H, vec(W, 0));
    ll tmp = 1;
    bool check = false;
    bool row = false;
    vector<bool> rows(H, false);
    Rep (i, H) {
        row = false;
        Rep (j, W) {
            if (s[i][j] == '#') {
                row = true;
                if (check) {
                    tmp++;
                } else {
                    check = true;
                }
            }
            ans[i][j] = tmp;
        }
        if (row) {
            rows[i] = true;
            tmp++;
            check = false;
        }
    }

    // Rep (i, H) {
    //     cout << rows[i] << " ";
    // }
    // cout << "\n";

    Rep (i, H) {
        if (rows[i] == false) {
            ll same;
            ll j = i+1;
            while (j < H && rows[j] == false) {
                j++;
            }
            if (j < H) {
                same = j;
            } else {
                j = i-1;
                while (j >= 0 && rows[j] == false) {
                    j--;
                }
                same = j;
            }

            Rep (k, W) {
                ans[i][k] = ans[same][k];
            }
        }
    }

    Rep (i, H) {
        Rep (j, W) {
            cout << ans[i][j] << " ";
        }
        cout << "\n";
    }
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()

const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    cout<<n*(n-1)/2+m*(m-1)/2<<endl;
}

Measured memory_bytes: 256
// luogu-judger-enable-o2
#include <iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a%3==0){
	cout<<"Possible"<<endl;	
	return 0;
	}
	if(b%3==0){
	cout<<"Possible"<<endl;	
	return 0;
	}
	if((a+b)%3==0){
	cout<<"Possible"<<endl;	
	return 0;
	}
	 else cout<<"Impossible"<<endl;
}

Measured memory_bytes: 256
package main

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

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for D - Binomial Coefficients
	var n int
	fmt.Scan(&n)

	sc.Split(bufio.ScanWords)
	a := make([]int, n)
	var max int
	var l, m int
	for i := 0; i < n; i++ {
		a[i] = nextInt()
		if max < a[i] {
			max = a[i]
			l = a[i]
		}
	}

	var min int = 10000000000
	var ans int

	for i := 0; i < n; i++ {
		if a[i] == 0 || a[i] == max {
			continue
		}
		ans = int(math.Abs((math.Ceil(float64(max / 2))) - float64(a[i])))
		if min > ans {
			min = ans
			m = a[i]
		}
	}

	fmt.Println(l, m)
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  int h, max = -1;
  for (int i = 0; i < n; i++) {
    cin >> h;
    if (h > max) max = h;
    if (h < max - 1) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 256
import queue 
n,m = map(int, input().split())

ma = [[] for i in range(n+1)]
for i in range(m):
  a,b = map(int, input().split())
  ma[a].append(b)
  ma[b].append(a)

ans = 0
def dfs(i):
  global ans
  if all(reach[1:]):
    ans += 1
  for j in ma[i]:
    if reach[j] == 1:
      continue
    reach[j] = 1
    dfs(j)
    reach[j] = 0

reach=[0]*(n+1)
reach[1] = 1
dfs(1)
print(ans)

Measured memory_bytes: 9636
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
      if (
          (S.at(0) == S.at(1) && S.at(2) == S.at(3) && S.at(0) != S.at(3)) ||
          (S.at(0) == S.at(2) && S.at(1) == S.at(3) && S.at(0) != S.at(3)) ||
          (S.at(0) == S.at(3) && S.at(1) == S.at(2) && S.at(0) != S.at(2))
      ) {
          cout << "Yes" << endl;
      }
      else {
          cout << "No" << endl;
      }
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) ((a) < (b) ? (b) : (a))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;



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

ll lcm(ll a,ll b) {
	return a / gcd(a, b) * b;
}



int main() {
	int i, j, k;
	ll N, M, K;
	ll ans = 0;
	
	int A[3][3];
	rep(i, 0, 3) {
		int a, b, c;
		cin >> a >> b >> c;
		A[i][0] = a;
		A[i][1] = b;
		A[i][2] = c;
	}
	cin >> N;
	rep(i, 0, N) {
		int t;
		cin >> t;
		rep(j, 0, 3)rep(k, 0, 3) {
			if (A[j][k] == t)
				A[j][k] = -1;
		}
	}

	rep(i, 0, 3) {
		if (A[i][0] + A[i][1] + A[i][2] == -3) {
			cout << "Yes";
			return 0;
		}
		if (A[0][i] + A[1][i] + A[2][i] == -3) {
			cout << "Yes";
			return 0;
		}
	}
	if (A[0][0] + A[1][1] + A[2][2] == -3) {
		cout << "Yes";
		return 0;
	}
	if (A[2][0] + A[1][1] + A[0][2] == -3) {
		cout << "Yes";
		return 0;
	}
	cout << "No";
	return 0;


}


Measured memory_bytes: 256
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  vector<int> A(5);
  int k;
  loop(i,0,5) cin >> A[i];
  cin >> k; 
  loop(i,0,4) loop(j,i+1,5) {
    if (abs(A[i]-A[j]) > k) {
      cout << ":(" << endl;
      return;
    }
  }
  
  cout << "Yay!" << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	static class Pair {
		long x, y;

		@Override
		public int hashCode() {
			long value = x % 9999991 + y % 9999991;
			return Long.hashCode(value);
		}

		@Override
		public boolean equals(Object obj) {
			Pair pair = (Pair) obj;
			if (this.x == pair.x && this.y == pair.y) {
				return true;
			} else {
				return false;
			}
		}

		Pair(long x, long y) {
			this.x = x;
			this.y = y;
		}
	}

	int N;
	long[] x, y;
	int result;
	Comparator<Pair> xFirst, yFirst;

	Main(int N, long[] x, long[] y) {
		this.N = N;
		this.x = x;
		this.y = y;
		this.xFirst = new Comparator<Pair>() {
			@Override
			public int compare(Pair o1, Pair o2) {
				if (o1.x < o2.x) {
					return -1;
				} else if (o1.x > o2.x) {
					return 1;
				} else {
					if (o1.y < o2.y) {
						return -1;
					} else if (o1.y > o2.y) {
						return 1;
					} else {
						return 0;
					}
				}
			}
		};
		this.yFirst = new Comparator<Pair>() {
			@Override
			public int compare(Pair o1, Pair o2) {
				if (o1.y < o2.y) {
					return -1;
				} else if (o1.y > o2.y) {
					return 1;
				} else {
					if (o1.x < o2.x) {
						return -1;
					} else if (o1.x > o2.x) {
						return 1;
					} else {
						return 0;
					}
				}
			}
		};
		calc();
		System.out.println(result);
	}

	void calc() {
		if (N == 1) {
			result = 1;
			return;
		}
		List<Pair> pairs = this.getPairs();
		Map<Pair, Integer> count = new HashMap<>();
		for (int i = 0; i + 1 < pairs.size(); ++i) {
			for (int j = i + 1; j < pairs.size(); ++j) {
				Pair p1 = pairs.get(i);
				Pair p2 = pairs.get(j);
				Pair src2dst = new Pair(p2.x - p1.x, p2.y - p1.y);
				Pair dst2src = new Pair(p1.x - p2.x, p1.y - p2.y);
				if (!count.containsKey(src2dst)) {
					count.put(src2dst, 1);
				} else {
					count.put(src2dst, count.get(src2dst) + 1);
				}
				if (!count.containsKey(dst2src)) {
					count.put(dst2src, 1);
				} else {
					count.put(dst2src, count.get(dst2src) + 1);
				}
			}
		}
		int max = Collections.max(count.values());
		result = N - max;
	}

	List<Pair> getPairs() {
		List<Pair> result = new ArrayList<>();
		for (int i = 0; i < N; ++i) {
			result.add(new Pair(x[i], y[i]));
		}
		return result;
	}

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		int N = Integer.parseInt(in.readLine());
		long[] x = new long[N];
		long[] y = new long[N];
		for (int i = 0; i < N; ++i) {
			String[] tokens = in.readLine().split(" ");
			x[i] = Long.parseLong(tokens[0]);
			y[i] = Long.parseLong(tokens[1]);
		}
		in.close();
		Main ins = new Main(N, x, y);
	}

}

Measured memory_bytes: 24020
#include <stdio.h>
int main(void)
{
	int W, H, x, y, r;
	scanf("%d %d %d %d %d ", &W, &H, &x, &y, &r);
	if(x<r||W<x+r)
	{
		printf("No\n");
	}
	else if(y<r||H<y+r)
	{
		printf("No\n");
	}
	else
	{
		printf("Yes\n");
	}
	
	return 0;
}


Measured memory_bytes: 2612
import sys
sys.setrecursionlimit(10**7)
def main():
    N, M = map(int, input().split())
    l = [[] for _ in range(N)]
    for _ in range(M):
        a, b = map(int, input().split())
        l[a-1].append(b-1)
    c = [0] * N
    loop = []
    def cyclic(n):
        if c[n] == 2:
            return False
        if c[n] == 1:
            loop.append(n)
            return True
        c[n] = 1
        for i in l[n]:
            if cyclic(i):
                loop.append(n)
                return True
        c[n] = 2
        return False
    for i in range(N):
        if cyclic(i):
            break
    if len(loop) == 0:
        print(-1)
        return
    loop.reverse()
    t = loop[-1]
    loop = loop[loop.index(t):]
    ll = set(loop)
    flag = True
    while flag:
        for i, v in enumerate(loop[:-1]):
            flag2 = False
            for j in l[v]:
                if j in ll and loop[i + 1] != j:
                    if loop.index(j) == 0:
                        loop = loop[:i+1] + [j]
                    elif loop.index(j) < i:
                        loop = loop[loop.index(j):i+1] + [j]
                    else:
                        loop = loop[:i+1] + loop[loop.index(j):]
                    ll = set(loop)
                    flag2 = True
                    break
            if flag2:
                break
        else:
            flag = False
    loop = set(loop)
    print(len(loop))
    for i in loop:
        print(i+1)
    return
main()


Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

#define eps (1e-10)
struct Point{
    double x,y;
    Point(){}
    Point(double x,double y):x(x),y(y){}
    Point operator+(Point p) {return Point(x+p.x,y+p.y);}
    Point operator-(Point p) {return Point(x-p.x,y-p.y);}
    Point operator*(Point p) {return Point(x*p.x-y*p.y,x*p.y+y*p.x);}
    Point operator*(double k){return Point(x*k,y*k);}
    double norm(){return x*x+y*y;}
    double abs(){return sqrt(norm());}
    bool operator == (const Point &p) const{return fabs(x-p.x)<eps && fabs(y-p.y)<eps;}
    double arg(){return atan2(y,x);}
    double dot(Point p){return x*p.x+y*p.y;}
    double det(Point p){return x*p.y-y*p.x;}
};
bool cmp_x(const Point& p,const Point& q){
  if(p.x!=q.x) return p.x<q.x;
  return p.y<q.y;
}
struct Line{
    Point p1,p2;
    Line(){}
    Line(Point p1, Point p2):p1(p1),p2(p2){}
};
struct Circle{
    double r;
    Point p;
    Circle(){}
    Circle(Point p,double r):p(p),r(r){}
};
int ccw(Point a,Point b,Point c){
    Point t1=b-a,t2=c-a;
    if(t1.det(t2)> eps) return 1;//counter clockwise
    if(t1.det(t2)< -eps) return -1;//clockwise
    if(t1.dot(t2)< -eps) return 2;//c-a-b online
    if(t1.norm()<t2.norm()) return -2;//a-b-c online
    return 0;//a-c-b online
}
Point project(Line l,Point p){
    Point base=l.p2-l.p1;
    double r=(p-l.p1).dot(base)/base.norm();
    return l.p1+base*r;
}
double distance(Line l,Point p){
    Point r=project(l,p);
    return (p-r).abs();
    /*
    if(abs(ccw(l.p1,l.p2,r))==0) return (p-r).abs();//projection not online
    else return min((p-l.p1).abs(),(p-l.p2).abs());
    */
}
bool isIntersectCC(Circle c1,Circle c2){
    return (c1.p-c2.p).abs()<=c1.r+c2.r+eps;
}
bool isIntersectCL(Circle c,Line l){
    return distance(l,c.p)<=c.r+eps;
}
pair<Point,Point> CrossPointsCC(Circle c1,Circle c2){
    assert(isIntersectCC(c1,c2));
    double d=(c1.p-c2.p).abs();
    double k=acos((d*d+c1.r*c1.r-c2.r*c2.r)/(c1.r*d*2));
    return make_pair(c1.p+(c2.p-c1.p)*Point(cos(k),sin(k))*(c1.r/d),c1.p+(c2.p-c1.p)*Point(cos(-k),sin(-k))*(c1.r/d));
}
pair<Point,Point> CrossPointsCL(Circle c,Line l){
    assert(isIntersectCL(c,l));
    Point p=project(l,c.p);
    double q=sqrt(c.r*c.r-(p-c.p).norm());
    Point e=(l.p2-l.p1)*(1.0/(l.p2-l.p1).abs());
    return make_pair(p+e*q,p-e*q);
}
int main(){
    double cx,cy,r;
    double x1,y1,x2,y2;
    int q;
    cin>>cx>>cy>>r;
    Circle c(Point(cx,cy),r);
    cin>>q;
    rep(i,q){
        cin>>x1>>y1>>x2>>y2;
        Line l(Point(x1,y1),Point(x2,y2));
        pair<Point,Point> pp=CrossPointsCL(c,l);
        if(!cmp_x(pp.first,pp.second)) swap(pp.first,pp.second);
        cout<<fixed<<setprecision(12)<<pp.first.x<<" "<<pp.first.y<<" "<<pp.second.x<<" "<<pp.second.y<<endl;
    }
    return 0;
}


Measured memory_bytes: 3288
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(double i=(a);i<(b);i++)
#define REP(i,n) rep(i,0,n)

int main()
{
    double n;
    cin>>n;
    vector<double>r(n);
    REP(i,n)cin>>r.at(i);
    double max=0;
    REP(i,n)
    {
        double y;
        cin>>y;
        r.at(i)-=y;
        r.at(i)=abs(r.at(i));
        if(r.at(i)>max)max=r.at(i);
    }
    for(double i=1;i<=3;i++)
    {
        double sum=0;
        REP(j,n)sum+=pow(r.at(j),i);
        cout<<fixed<<setprecision(10)<<pow(sum,1/i)<<endl;
    }cout<<max<<endl;
    
}




Measured memory_bytes: 3448
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let n = read int
    printfn "%i" (pown n 3)
    0

Measured memory_bytes: 13916
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
using namespace std;
int main()
{
    const double rate = 380000.0;
    int n;
    cin >> n;
    double ans = 0;
    rep(i, n)
    {
        double x;
        string u;
        cin >> x >> u;
        ans += (u == "JPY") ? x : x * rate;
    }
    printf("%lf", ans);
}


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

int main() {
	
	int n; cin>>n;
	deque<int>a;
	int b; cin >> b;
	a.push_back(b);
	for(int i=1; i<n; i++) {
		int b; cin >> b;
		auto it = lower_bound(a.begin(), a.end(), b);
		if(it==a.end()) {
			if(a.back()<b) a.back()=b;
			else a.push_back(b);
		}
		else {
			if(it==a.begin()) a.push_front(b);
			else *(it-1) = b;
		}
	}
	cout << a.size() << endl;
}


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

long long N, M;
priority_queue<long long> price;

int main(){
	cin >> N >> M;
	for(long long i = 0; i < N; i++){
		long long tmp;
		cin >> tmp;
		price.push(tmp);
	}

	for(long long i = 0; i < M; i++){
		long long p = price.top();
		price.pop();
		price.push(p/2);
	}

	long long ans = 0;
	while(!price.empty()){
		ans += price.top();
		price.pop();
	}
	cout << ans << endl;
}



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

using namespace std;

int main()
{
  string s;
  cin >> s;
  if (s.length() % 2 == 1)
    cout << "No\n";
  else
  {
    int f = 0;
    for (int i = 0; i < s.length() - 1; i += 2)
    {
      if (s[i] != 'h' || s[i + 1] != 'i')
      {
        f = 1;
        break;
      }
    }
    if (f)
      cout << "No\n";
    else
      cout << "Yes\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
using namespace std;

void swap(int& a, int& b) {
    int c = a;
    a = b;
    b = c;
}
int GetGCD(int a, int b) {
    if(a < b) {
        swap(a, b);
    }
    while(b != 0) {
        int rem = a % b;
        a = b;
        b = rem;
    }
    return a;
}

int main() {
    int n = 3;
    cin >> n;
    vector<int> v(n, 0);
    for(int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    
    vector<int> pre(n, v[0]);
    vector<int> pos(n, v[n - 1]);
    
    for(int i = 1; i < n; ++i) {
        pre[i] = GetGCD(pre[i - 1], v[i]);
    }
    
    for(int i = n - 2; i >= 0; --i) {
        pos[i] = GetGCD(pos[i + 1], v[i]);
    }
    
    int maxGCD = 0;
    for(int i = 0; i < n; ++i) {
        if(i == 0) {
            maxGCD = max(maxGCD, pos[i + 1]);
        }
        if(i == n - 1) {
            maxGCD = max(maxGCD, pre[i - 1]);
        }
        if(i > 0 && i < n - 1) {
            maxGCD = max(maxGCD, GetGCD(pre[i - 1], pos[i + 1]));
        }
    }
    
    cout << maxGCD << endl;
    
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>

using namespace std;

int main(){
  string s;
  cin >> s;
  int count = 0;
  for(int i=0; i<s.size(); i++){
    if( s.at(i) == 'o') count++;
  }
  if(8 <= 15 - s.size() + count  ){
    cout << "YES";
  }else{
    cout << "NO";
  }
  return 0;
}


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

using namespace std;
int n;
int H,W,T;
string str;
bool used[26],flg;

int A[26],B[26],C[26],D[26];

char t[50][50];

char tmp;

void input();
void init();

bool check(char ch){
  int z= ch-'A';
  for(int i=A[z];i<=C[z];i++){
    for(int j=D[z];j<=B[z];j++){
      if(t[i][j]=='?')continue;
      if(t[i][j]!=ch)return false;
    }
  }
  return true;
}

void draw(char ch){
  int z=ch-'A';
  for(int i=A[z];i<=C[z];i++){
    for(int j=D[z];j<=B[z];j++){
      t[i][j]='?';
    }
  }
}

int main(){
  cin>>T;
  while(T--){
    init();
    input();

    while(1){
 
      flg=false;

      for(int i=0;i<26;i++){
	if(used[i]==false)continue;
	if(check(i+'A')==true){
	  flg=true;
	  draw(i+'A');
	  used[i]=false;
	  break;
	}
      }
      if(flg==false)break;
    }

    flg=false;
    for(int i=0;i<26;i++)flg|=used[i];
    cout<<(flg?"SUSPICIOUS":"SAFE")<<endl;
  }
  return 0;
}

void input(){
  int X;
  cin>>H>>W;
  for(int i=0;i<H;i++){
    cin>>str;
    for(int j=0;j<W;j++){
      t[i][j]=str[j];
      if(t[i][j]=='.')continue;
      X=t[i][j]-'A';
      used[X]=true;
      A[X]=min(A[X],i);
      B[X]=max(B[X],j);
      C[X]=max(C[X],i);
      D[X]=min(D[X],j);
    }
  }
}

void init(){
  for(int i=0;i<26;i++){
    A[i]=50;
    B[i]=0;
    C[i]=0;
    D[i]=50;
    used[i]=false;
  }
}

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

int main() {
  int n,m;cin>>n>>m;
  vector<int> a(n),b(n),c(m),d(m);
  rep(i,n)cin>>a[i]>>b[i];
  rep(i,m)cin>>c[i]>>d[i];
  rep(i,n){
    int x=1e9,ans;
    rep(j,m){
      int cnt=abs(a[i]-c[j])+abs(b[i]-d[j]);
      if(cnt<x){
        x=min(x,cnt);
        ans=j+1;
      }
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3608