akhauriyash/Code-Regression huggingface dataset:
S = input()
rS = S[::-1]
k = 0
while True:
    if k == len(rS):
        print("YES")
        break    
    elif rS[k:k + 5] == "maerd":
        k = k + 5
    elif rS[k:k + 5] == "esare":
        k = k + 5
    elif rS[k:k + 7] == "remaerd":
        k = k + 7
    elif rS[k:k + 6] == "resare":
        k = k + 6
    else:
        print("NO")
        break

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


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

  int c[3][3];
  cin>>c[0][0]>>c[0][1]>>c[1][1];

  rep(i,1000){
    c[0][2]=i-c[0][0]-c[0][1];
    c[2][1]=i-c[0][1]-c[1][1];
    c[2][0]=i-c[0][2]-c[1][1];
    c[2][2]=i-c[0][0]-c[1][1];
    c[1][0]=i-c[0][0]-c[2][0];
    c[1][2]=i-c[0][2]-c[2][2];
    if(i==c[1][0]+c[1][1]+c[1][2]){
      rep(i,3){
        rep(j,3){
          if(j) cout<<" ";
          cout<<c[i][j];
        }
        cout<<endl;
      }
      return 0;
    }
  }


}

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

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)

class Point                             
{
public:
	double x, y;
	Point(double x = 0, double y = 0) :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 * (double a) { return Point(a * x, a * y); }
	Point operator / (double b) { return Point(x / b, y / b); }

	double dot(Point a, Point b) { return a.x * b.x + a.y * b.y; }
	double abs() { return sqrt(norm()); }
	double norm(){ return x * x + y * y; }

	bool operator <(const Point &p)const { return x != p.x ? x < p.x : y < p.y; }
	bool operator == (const Point &p) const { return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS; }         
};
typedef Point Vector;              

struct Segment {                        
	Point p1, p2;
	Segment() {}
	Segment(Point p1, Point p2) :p1(p1), p2(p2) {}
};
typedef Segment Line;      

double norm(Vector a) { return a.x*a.x + a.y*a.y; } 
double abs(Vector a) { return sqrt(norm(a)); }        

double dot(Vector a, Vector b) { return a.x*b.x + a.y*b.y; }   
double cross(Vector a, Vector b) { return a.x*b.y - a.y*b.x; }

Point project(Segment s, Point p) {
	Vector base = s.p2 - s.p1;
	double r = dot(p - s.p1, base) / norm(base);
	return s.p1 + base * r;
}

int main() {                                                    
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	Line base = Line(Point(x1, y1), Point(x2, y2));
	int q; cin >> q;
	while (q--) {
		cin >> x1 >> y1;
		Point p = project(base, Point(x1, y1));
		printf("%.8lf %.8lf\n", p.x, p.y);
	}
	return 0;
}






Measured memory_bytes: 3292
'use strict'
function main(input) {
  const args = input.split('\n')
  const num = parseInt(args[0])
  const str = args[1].split(' ')
  const str1 = str[0].split('')
  const str2 = str[1].split('')
  let out = ''
  for (let i = 0; i < num; i++) {
    out += str1[i]
    out += str2[i]
  }
  
  console.log(out)
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();     
        int N = r.i();
        Set<Integer> set = new HashSet<>();
        for(int i = 0; i < N; i++){
            int a = r.i();
            if(!set.remove(a))
                set.add(a);
        }
        println(set.size());
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 38356
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
int x;
cin>>x;
if(x>100 || x<0)
    return 0;

int y=0;

for(int i=0;i<=x;i++)
{
 if(i%2!=0)
        y=y+1;
}
double r=(y*1.0)/x;
cout<<fixed;
cout<<setprecision(9)<<r;
return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

#include <inttypes.h>
using namespace std;

int main()
{
	int32_t N;
	char s1[60], s2[60];
	scanf("%d%s%s", &N, s1, s2);

	int64_t res = 1;

	int32_t i = 0;
	int32_t prev = -1; // 0: tate, 1: yoko
	while (i < N) {
		if (s1[i] == s2[i]) {
			if (prev == -1) {
				res *= 3;
			} else if (prev == 0) {
				res *= 2;
			}
			prev = 0;
			i++;
		} else {
			if (prev == -1) {
				res *= 6;
			} else if (prev == 0) {
				res *= 2;
			} else {
				res *= 3;
			}
			prev = 1;
			i += 2;
		}
		res %= 1000000007;
	}

	printf("%" PRId64 "\n", res);

	return 0;
}

Measured memory_bytes: 256
//Link : https://atcoder.jp/contests/code-festival-2017-qualb/tasks/code_festival_2017_qualb_d

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 2002

int in[N],cc[N];
int deg[N];

int gcd(int x,int y) {
  if(x==0) {
    return y;
  }
  return gcd(y%x,x);
}
vector<int> adj[N];
int vis[N];

vector<int> merge(vector<int> a,vector<int> b) {
  vector<int> ret;
  int apos  =0,bpos = 0;
  while(apos<a.size() && bpos< b.size()) {
    if(a[apos]>b[bpos]) {
      ret.push_back(a[apos++]);
    } else {
      ret.push_back(b[bpos++]);
    }
  }
  while(apos<a.size() ) {
    ret.push_back(a[apos++]);
  }
  while(bpos< b.size()) {
    ret.push_back(b[bpos++]);
  }
  return ret;
}

int mini;
void dfs(int node) {
  vis[node] = 1;
  mini = min(mini,node);
  for(int ch : adj[node]) {
    if(!vis[ch]) {
      dfs(ch);
    }
  }
}

vector<int> dfs2(int node) {
  vis[node] = 2;
  vector<int> ret;
  while(cc[node]>1) {
      --cc[node];
      ret.push_back(in[node]);
  }
  for(int ch : adj[node]) {
    if(vis[ch]!=2) {
      vector<int> tmp = dfs2(ch);
      ret = merge(ret,tmp);
    }
  }
  vector<int> out;
  while(cc[node]>0) {
    --cc[node];
    out.push_back(in[node]);
  }
  for(int i=0;i<ret.size();++i) {
    out.push_back(ret[i]);
  }
  return out;
}

void solve() {
  int n;
  scanf("%d ", &n);
  for(int i=0;i<n;++i) {
    scanf("%d",&in[i]);
  }
  sort(in,in+n);
  int pos=0;
  for(int i=0;i<n;++i) {
    cc[pos] = 1;
    in[pos] = in[i];
    ++pos;
  }
  int num = 0;
  for(int i=0;i<pos;++i) {
    for(int j=i+1;j<pos;++j) {
      if(gcd(in[i],in[j])!=1) {
        adj[i].push_back(j);
        adj[j].push_back(i);
      }
    }
  }
  vector<int> ret;
  for(int i=0;i<pos;++i) {
    if(!vis[i]) {
      mini = 1e9;
      dfs(i);
      vector<int> out = dfs2(mini);
      ret = merge(ret,out);
    }
  }
  assert(ret.size()==n);
  for(int i=0;i<n;++i) {
    printf("%d ", ret[i]);
  }
  putchar('\n');
}

int main() {
    //freopen("input.txt","r",stdin);
    solve();
    return 0;
}


Measured memory_bytes: 18048
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

void solve() {
    int a, b, c;
    cin>>a>>b>>c;
    cout<<c<<' '<<a<<' '<<b<<endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int t = 1;
    //cin>>t;
    for(int tests = 1; tests <= t; tests++) {
        //cout<<"Case #"<<tests<<": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
def solve():
    N = int(input())
    a = list(map(int, input().split()))

    cnt = 0
    cur_num = 0
    for elem in a:
        if elem == cur_num + 1:
            cur_num += 1
        else:
            cnt += 1
    
    ans = 0
    if cur_num == 0:
        ans = -1
    else:
        ans = cnt
    
    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 77644
s = input()
n = len(s)
total = 0
for i in range(2 ** (n-1)):
    num = ""
    for j in range(n):
        if j == n-1:
            num += s[j]
        elif ((i >> j) & 1):
            num += s[j] + ","
        else:
            num += s[j]
    num2 = list(num.split(","))
    map(int,num2)
    for k in num2:
        total += int(k)
print(total)

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

int main(){
	int N; cin >> N;
	if(N<=9){
		cout << N;
	}
	else if(N>9 && N<=99){
		cout << 9;
	}
	else if(N>99 && N<=999){
		cout << 9 + (N-100+1);
	}
	else if(N>999 && N<=9999){
		cout << 9 + (999-100+1);
	}
	else if(N>9999 && N<=99999){
		cout << 9 + (999-100+1) + (N-10000+1);
	}
	else if(N==100000){
		cout << 9+ (999-100+1) + (99999-10000+1);
	}
} 

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

using namespace std;

int main()
{
	string s, ans;
	int m;

	while (true)
	{
		cin >> s;
		if (s == "-")
			break;

		cin >> m;

		while (m--)
		{
			int h;
			cin >> h;

			// 1.
			//string temp = s.substr(h);
			//s.replace(s.size() - h, h, s.substr(0, h));
			//s.replace(0, temp.size(), temp);

			// 2.
			string temp = s.substr(0, h);
			s.erase(0, h);
			s += temp;
		}

		ans += s + "\n";
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 1224
import re
S_ = input()
T = input()

Srev = "".join(reversed(S_))
Trev = "".join(reversed(T))

pattern = "".join(["[{}?]".format(t) for t in Trev])
ans = re.sub(pattern, Trev, Srev, count=1)
ans = "".join(reversed(ans.replace("?", "a")))
if ans.count(T):
    print(ans)
else:
    print("UNRESTORABLE")

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

#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<long long,long long>
#define FOR(i,a,b)  for(long long i=a;i<b;++i)
#define RFOR(i,a,b) for(long long i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        400005
#define all(v)      v.begin(),v.end()
#define sz(x)       (long long)x.size()
//#define mod         1000000007
#define pqueue      priority_queue<long long>
#define pdqueue     priority_queue< long long,vector<long long> ,greater< long long >>
 
typedef long long ll;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//const long long md = 998244353;
 
/*const long long mod = 998244353;
long long power(long long a,long long n)
{
	if(n == 1)return a%mod;
	if(n == 0)return 1;
	if(n&1)return ((a%mod)*(power((a*a)%mod,n/2))%mod)%mod;
	return power((a*a)%mod,n/2)%mod;
}
*/


int main()
{
	ll n, ans, ans2;
	cin >> n;

	ll x;
	cin >> x;

	ll dpA[5];
	ll dpB[5];
	ll *dp1;
	ll *dp2;

	dpA[0] = x;
	dpA[1] = x == 0 ? 2 : x % 2;
	dpA[2] = (x+1)%2;
	dpA[3] = x == 0 ? 2 : x % 2;
	dpA[4] = x;
    dp2 = dpA;
	FOR (i,1,n) {
		cin >> x;

		if (i % 2 > 0) {
			dp1 = dpA;
			dp2 = dpB;
		} else {
			dp1 = dpB;
			dp2 = dpA;
		}
      cerr << dp1[0] << " " << dp1[1] << " " << dp1[2] << " " << dp1[3] << " " << dp1[4] << endl;
		ll minT = min(dp1[0], dp1[1]);
		dp2[0] = dp1[0] + x;
		dp2[1] = minT + (x == 0 ? 2 : x % 2);
		minT = min(minT, dp1[2]);
		dp2[2] = minT + (x+1)%2;
		minT = min(minT, dp1[3]);
		dp2[3] = minT + (x == 0 ? 2 : x % 2);
		minT = min(minT, dp1[4]);
		dp2[4] = minT+x;
	}

	ans = min(dp2[0], dp2[1]);
	ans2 = min(dp2[2], dp2[3]);
	ans = min(ans, ans2);
	ans = min(ans, dp2[4]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <cstring>
#include <map>
const int inf=0x3ffffff;
using namespace std;
int dd[210][210];
int use[210];
int ss[210];
int num=0;
int ans;
int temp=0;
int now=1;
void dfs(int n)
 {use[n]=true;
  if(now==num) 
   {
     ans=min(ans,temp);
     use[n]=false;
     return;
    }
  for(int i=1;i<=num;i++)
   {if(!use[ss[i]])
     {temp+=dd[n][ss[i]];
      now++;
      dfs(ss[i]);
      temp-=dd[n][ss[i]];
      now--;
     }
   }
   use[n]=false;
 }
int main(int argc, char** argv) {
     int n;
     int m;
     int all;
     while(scanf("%d%d%d",&n,&m,&all)!=EOF)
       {num=all;
        ans=0;
	    for(int i=1;i<=all;i++)
         scanf("%d",&ss[i]);
        for(int i=1;i<=n;i++)
         for(int j=1;j<=n;j++)
          dd[i][j]=inf;
       	for(int i=1;i<=n;i++)
        dd[i][i]=0;
        for(int i=1;i<=m;i++)
		 {int a,b,c;
		  scanf("%d%d%d",&a,&b,&c);
		  dd[a][b]=dd[b][a]=c;
		 }
		for(int i=1;i<=n;i++)
		 for(int j=1;j<=n;j++)
		   for(int k=1;k<=n;k++)
		    if(dd[j][k]>dd[j][i]+dd[i][k])
			 dd[k][j]=dd[j][k]=dd[j][i]+dd[i][k];
		ans=inf;
		for(int i=1;i<=all;i++)
		 {
			temp=0;
			now=1;
	        memset(use,0,sizeof(use));
	        dfs(ss[i]);
	    }
	    printf("%d\n",ans);
       }
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B,L,R;
string S,T;
const ll MOD = 998244353;
typedef pair<ll,ll> P;

int main() {
    cin>>N>>K;
    vec a(N);
    rep(i,N) cin>>a[i];
    mat dp(45,vec(2,0));
    bool wait = true;
    for(int i = 40; i >= 0; --i){
        bool k = (K >> i)&1;
        ll fbit = 1ULL << i;
        rep(j,2 - wait){ //もってくるdp[i+1][j]のj
            for(int x = 0; x <= (j ? 1 : k); ++x){
                ll plus = 0;
                rep(p,N){
                    plus += (x ^ ((a.at(p) >> i)&1LL)) ? fbit : 0;
                }
                dp.at(i).at(j || (x < k)) = max(dp.at(i).at(j || (x < k)),dp.at(i+1).at(j) + plus);
            }
        }
        if(wait && k) wait = false;
    }
    cout<<max(dp[0][0],dp[0][1])<<endl;
    /*rep(j,2){
        rep(i,41){
            cout<<dp[i][j]<<' ';
        }
        cout<<endl;
        cout<<endl;
    }*/
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

struct dice {
  int label[7];
};

struct dice *make_dice(int *num) {
  int i;
  struct dice *dice1;
  dice1 = (struct dice *)malloc(sizeof(struct dice));
  for(i = 1;i <= 6;i++) {
    dice1->label[i] = num[i];
  }
  return dice1;
}

void turnS(struct dice *a) {
  int temp;
  temp = a->label[1];
  a->label[1] = a->label[5];
  a->label[5] = a->label[6];
  a->label[6] = a->label[2];
  a->label[2] = temp;
}

void turnW(struct dice *a) {
  int temp;
  temp = a->label[1];
  a->label[1] = a->label[3];
  a->label[3] = a->label[6];
  a->label[6] = a->label[4];
  a->label[4] = temp;
}

void turnN(struct dice *a) {
  int temp;
  temp = a->label[1];
  a->label[1] = a->label[2];
  a->label[2] = a->label[6];
  a->label[6] = a->label[5];
  a->label[5] = temp;
}

void turnE(struct dice *a) {
  int temp;
  temp = a->label[1];
  a->label[1] = a->label[4];
  a->label[4] = a->label[6];
  a->label[6] = a->label[3];
  a->label[3] = temp;
}

void spin(struct dice *a) {
  turnS(a);
  turnE(a);
  turnN(a);
}

int cmp_dice(struct dice *a, struct dice *b) {
  int i;
  for(i = 1;i <= 6;i++) {
    if(a->label[i] != b->label[i]) return 1;
  }
  return 0;
}

int cmp_dice2(struct dice *dice1, struct dice *dice2) {
  int i,j;
  
  for(i = 0;i < 4;i++) {
    for(j = 0;j < 4;j++) {
      if(cmp_dice(dice1, dice2) == 0) break;
      spin(dice1);
    }
    if(cmp_dice(dice1, dice2) == 0) break;
    turnW(dice1);
  }
  for(i = 0;i < 4;i++) {
    for(j = 0;j < 4;j++) {
      if(cmp_dice(dice1, dice2) == 0) break;
      spin(dice1);
    }
    if(cmp_dice(dice1, dice2) == 0) break;
    turnS(dice1);
  }
  if(cmp_dice(dice1, dice2) == 0) {
    return 0;
  }else{
    return 1;
  }
}

int main() {
  int i,j,n,t,num[7];
  struct dice **dice;

  scanf("%d", &n);
  dice = (struct dice **)malloc(sizeof(struct dice *)*n);
  for(i = 0;i < n;i++) {
    for(j = 1;j <= 6;j++) {
      scanf("%d", num+j);
    }
    dice[i] = make_dice(num);
  }
  t = 0;
  for(i = 0;i < n-1;i++) {
    for(j = i+1; j < n;j++) {
      t += 1 - cmp_dice2(dice[i], dice[j]);
    }
  }

  if(t == 0) {
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 584
n = int(input())
s = input()
r = 0
g = 0
b = 0
for i in range(n):
    if s[i] == 'R':
        r += 1
    elif s[i] == 'G':
        g += 1
    else:
        b += 1
ans = r*g*b
for i in range(n-2):
    for j in range(i+1,n-1):
        k = 2*j - i
        if k < n:
            if s[i] != s[j] and s[j] != s[k] and s[k] != s[i] :
                ans -= 1
print(ans)

Measured memory_bytes: 73472
<?php
fscanf(STDIN, "%d", $n);
for($i = 0; $i < $n; $i++) {
    fscanf(STDIN, "%d %d", $x[], $y[]);
}

$d = 1;
for($i = 1; $i <= $n; $i++) {
    $d = $d * $i;
}

$pair = 0;
for($i = 1; $i <= $n-1; $i++) {
    $pair = $pair + $i; 
}
$move = $d * ($n-1) / $pair;
$totalLength = 0;
for($i = 0; $i < $n-1; $i++) {
    for($j = $i+1; $j < $n; $j++) {
        $totalLength += $pairLength = sqrt(pow($x[$i] - $x[$j], 2) + (pow($y[$i] - $y[$j], 2)));
    }
}
$totalLength = $totalLength * $move;
$averageLength = $totalLength / $d;
echo $averageLength;
?>

Measured memory_bytes: 4604
'use strict';

function Main(input) {
    let tmp = input.trim().split('\n');
    const N = Number(tmp[0]);
    const A = tmp[1].split(' ').map((v) => Number(v)).sort((a, b) => a - b);

    const maxNum = A[N - 1];
    const resultArr = new Array(maxNum + 1).fill(0);
    for (const i of A) {
        resultArr[i] += 1;
    }
    
    for (let i = 0; i < maxNum + 1; i++) {
        if (resultArr[i] === 0) continue;
        for (let j = i * 2; j < maxNum + 1; j += i) {
            resultArr[j] = 0
        }
    }

    console.log(String(resultArr.filter(v => v === 1).length))
    return;
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7;

int main(){
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int power = 1%MOD;
	for(int i=1; i<=n; i++)
		power = 1ll * power * i % MOD;
	cout << power << endl;
	return 0;
}


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

 double pi=3.14159265358979323846;

 
int main(){
    int t=1;
    //cin>>t;
    while(t--){
        double a,b,h,m;
        cin>>a>>b>>h>>m;
        double t=60*h+m;
        double a1=0.5*t;
        double a2=6*t;
        double theta=(abs(a2-a1));
        double ans=a*a+b*b-2*a*b*cos((pi/180)*theta);
        printf("%.20lf",sqrt(ans));
        
    }


    
}

Measured memory_bytes: 4228
#include<iostream> //15
using namespace std;

int main(){
	int a=0;
	int b[100];
	int i=0;
	int j=0;
	int n=0;
	int m=0;
	int t=0;
	int s[100];
	
	cin>>n;
	cin>>m;
	for(i=0;i<m;i++){
		cin>>b[i];
	}
	for(i=0;i<n;i++){
		s[i]=0;
	}
	for(i=0;i<m;i++){
		for(j=0;j<n;j++){
			cin>>a;
			if(a==b[i]){
				s[j]++;
			}else{
				t++;
			}
		}
		s[b[i]-1]=s[b[i]-1]+t;
		t=0;
	}
	for(i=0;i<n;i++){
		cout<<s[i]<<endl;
	}
}

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

using namespace std;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

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

    int w, h;
    vector<string> wall;
    vector< vector<int> > dist;
    int tx;
    int ty;

    while(cin >> w >> h, w){

        wall.resize((h << 1) - 1);

        cin.ignore();
        for (auto& x : wall)
            getline(cin, x);

        dist.assign(h, vector<int>(w, 0));
        dist[0][0] = 1;

        for(int d = 1; d < w * h; d++)
            for(int y = 0; y < h; y++)
                for(int x = 0; x < w; x++)
                    if(dist[y][x] == d)
                        for(int r = 0; r < 4; r++){
                            tx = x + dx[r];
                            ty = y + dy[r];

                            if(0 > tx || tx >= w || 0 > ty || ty >= h)
                                continue;

                            if(dist[ty][tx] != 0)
                                continue;

                            if (wall[ty + y][tx + x] == '0')
                                dist[ty][tx] = d + 1;
                        }

        cout << dist[h-1][w-1] << endl;

    }

    return 0;

}

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

using namespace std;

class Node{
    public:
        Node():nc(0),id(-1){}
        int nc;
        Node* l;
        Node* r;
        Node* p;
        int id;
};

Node* root;

bool find(Node* node,int id){
    if(node->id==-1)
        return false;
    if(node->id==id)
        return true;
    if(node->id>id){
        if(node->l==nullptr)
            return false;
        return find(node->l,id);
    }else{
        if(node->r==nullptr)
            return false;
        return find(node->r,id);
    }
}

Node* dfs(Node* node,int id){
     // cout<<"dfs id:"<<node->id<<" nc:"<<node->nc<<endl;
     if(node->id==-1)
        return node;
     
     //cout<<"node-id:"<<node->id<<" id"<<id<<endl;
     if(node->id>id){
       if(node->l==nullptr){
            node->l = new Node();
            node->l->p = node;
     //      cout<<"node-p:"<<node->id<<endl;
            node->nc++;
            return node->l;
        }else{
            return dfs(node->l, id);
        }
      }else{
        if(node->r==nullptr){
           node->r = new Node();
           node->r->p = node;
           node->nc++;
           return node->r;
        }
        return dfs(node->r, id);
      }
}

void insert(int id){
//     cout<<"ins"<<endl;
     Node* leaf = dfs(root,id);
     //cout<<"leaf"<<leaf->id<<" p:"<<leaf->p->id<<endl;
     leaf->id = id;      
     
}

bool pf=true;
void pro(Node* n){
    if(n->id!=-1){
        if(pf||n->id!=root->id)
            cout<<" "<<n->id;
        if(n->id==root->id)
            pf=false;
        if(n->l!=nullptr)
            if(n->l->id!=-1)
                pro(n->l);
        if(n->r!=nullptr){
            if(n->r->id!=-1)
            pro(n->r);
        }
    }
}

bool ifr=true;
void ino(Node* n){
    if(n->id!=-1){
        //cout<<"id:"<<n->id<<endl;
        if(n->l!=nullptr){
            if(n->l->id!=-1)
                ino(n->l);
        }
        if(ifr||n->id!=root->id)
            cout<<" "<<n->id;
        if(n->id==root->id)
            ifr=false;
        if(n->r!=nullptr){
            if(n->r->id!=-1)
                ino(n->r);
        }
    }
}

void print(){
    //cout<<"ino"<<endl;
    ino(root);
    cout<<endl;
    ifr=true;
    //cout<<"pro"<<endl;
    pro(root);
    pf=true;
    cout<<endl;
}

int main(){
    int n, id;
    string cmd;
    bool flag=true;
    root = new Node();
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>cmd;
        if(cmd=="insert"){
            cin>>id;
            if(flag){
                root->id=id;
                root->p = new Node();
                flag=false;
            }
            insert(id);
        }else if(cmd=="find"){
            cin>>id;
            if(find(root,id))
                cout<<"yes"<<endl;
            else
                cout<<"no"<<endl;
        }else{
            print();
        }
    }
    delete root;
    return 0;
}

Measured memory_bytes: 19964
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,k,sum=0;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n,greater<int>());
  for(int i=0;i<k;i++){
    sum+=a[i];
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	unsigned long int a, b, c;
	int i;
	char S[11], T[11], k;

	for (i = 0; i < 11; i++) {
		scanf("%c", &(S[i]));
		if (S[i] == '\n') {
			a = i;
			break;
		}
	}

	for (i = 0; i < a; i++) {
		scanf("%c", &(T[i]));
		if (T[i] != S[i]) {
			printf("No");
			return 0;
		}
	}

	scanf("%c", &(k));
	if ('\n' == k) {
		printf("No");
		return 0;
	}

	scanf("%c", &(k));
	if ('\n' != k) {
		printf("No");
		return 0;
	}

	printf("Yes");

	return 0;
}

Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (auto &i : v) {
    cin >> i;
  }
  int q;
  cin >> q;
  while (q--) {
    int k;
    cin >> k;
    cout << lower_bound(v.begin(), v.end(), k) - v.begin() << " ";
    cout << upper_bound(v.begin(), v.end(), k) - v.begin() << endl;
  }
}


Measured memory_bytes: 3084
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

int main() {
	lint A, V, B, W, T;
	cin >> A >> V >> B >> W >> T;
	if (V - W <= 0) {
		cout << "NO" << endl;
	}
	else {
		if (abs(A - B) <= T * (V - W)) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 3640
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 1))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (ql:quickload :cl-debug-print))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS

(declaim (inline read-line-into))
(defun read-line-into (buf-str &optional (in *standard-input*) (terminate-char #\Newline))
  (declare (simple-base-string buf-str))
  (loop for ch of-type base-char =
           #-swank (code-char (read-byte in nil #\Newline))
           #+swank (read-char in nil #\Newline)
        for idx = 0 then (1+ idx)
        until (char= ch #\Newline)
        do (setf (aref buf-str idx) ch)
        finally (setf (aref buf-str idx) terminate-char)
                (return buf-str)))

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

;; Hauptteil

(deftype uint nil `(integer 0 ,(expt 10 9)))
(defun main ()
  (declare #.OPT)
  (let* ((n (read))
         (k (read))
         (table (make-array (list n) :element-type 'uint))
         (buf (make-string 11 :element-type 'standard-char :initial-element #\Newline)))
    (declare (uint k)
             ((simple-array uint (*)) table))
    (dotimes (idx n)
      (setf (aref table idx)
            (parse-integer (read-line-into buf *standard-input* #\Newline) :junk-allowed t)))
    (stable-sort table #'<)
    (println
     (loop for begin-idx from 0
           for end-idx from (- (min k (length table)) 1) below (length table)
           minimize (- (aref table end-idx) (aref table begin-idx))))))

#-swank(main)


Measured memory_bytes: 20704
from collections import Counter
N, M = map(int, input().split())
cnt = Counter(map(int, input().split()))

for _ in range(M):
    B, C = map(int, input().split())
    cnt[C] += B

ans = 0
for n, c in sorted(cnt.items(), reverse=True):
    if N == 0:
        break
    mi = min(c, N)
    ans += mi * n
    N -= mi
print(ans)


Measured memory_bytes: 40352
#!/usr/bin/env python3
# bit全探索

# input
n, m, x = map(int, input().split())
c = [-1 for _ in range(n)]
a = [[-1 for _ in range(m)] for _ in range(n)]
for i in range(n):
    tmp = list(map(int, input().split()))
    c[i] = tmp[0]
    a[i] = tmp[1:]

# calc
ans = []
for s in range(1<<n):
    rikaido = [0 for _ in range(m)]
    cost = 0 
    for i in range(n):
        if s>>i&1:
            cost += c[i]
            for j in range(m):
                rikaido[j] += a[i][j]
    ok = True
    for j in range(m):
        if rikaido[j] < x:
            ok = False
            break
    if ok: 
        ans.append(cost)

if len(ans) > 0:
    print(min(ans))
else:
    print(-1)


Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define iter vector<int>::iterator
#define mod 998244353
#define inf 1e16

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;

    int a[n];
    int sum=0;
    for(int i=0;i<n;i++)
    {
    	cin>>a[i];
    	sum+=a[i];
    }
    int dp[n][n];//dp[i][j] gives the maximum points scored in the interval i to j
    int x,y,z;
    for(int k=0;k<n;k++)
    {
    	for(int i=0,j=k;j<n;j++,i++)
    	{
    		x=0;y=0;z=0;
    		if(i+2<=j)
    			x=dp[i+2][j];
    		if(i+1<=j-1)
    			y=dp[i+1][j-1];
    		if(i<=j-2)
    			z=dp[i][j-2];

    		dp[i][j]=max(a[i]+min(x,y),a[j]+min(y,z));
    	}
    }
    int ans=(2*dp[0][n-1])-sum;
    //cout<<dp[0][n-1]<<" "<<sum-dp[0][n-1]<<"\n";
    cout<<ans<<"\n";
}

Measured memory_bytes: 70400
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<deque>
#include<iomanip>
#include<tuple>
#include<stack>
using namespace std;
typedef long long ll;

typedef pair<int, int> pii;
typedef tuple<int, int, int> ti3;

//const ll MOD_CONST = 1000000007;
const ll MOD_CONST = 998244353;


const int INF = 1000000000;
const ll BIG_NUM = 1000000000000000000;



int main() {
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#include<time.h>
#include<stdlib.h>
#define pb push_back
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define clr(x) x.clear()
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vi>
#define mp make_pair
#define hell 1000000007

using namespace std;

int main()
{
    IOS
    int n;
    cin>>n;
    int arr[n+1];
    ll dp[n+1];
    for(int i=1;i<=n;i++)
        cin>>arr[i];
    dp[n-1]=abs(arr[n]-arr[n-1]);
    dp[n-2]=min((ll)abs(arr[n]-arr[n-2]),abs(arr[n-2]-arr[n-1])+dp[n-1]);
    for(int i=n-3;i>=1;i--)
        dp[i]=min((ll)abs(arr[i+2]-arr[i])+dp[i+2],(ll)abs(arr[i+1]-arr[i])+dp[i+1]);
    cout<<dp[1];
    return 0;
}


Measured memory_bytes: 1408
n = int(input())
As = list(map(int, input().split()))

a = max(As)

# 一番a/2に近い数を選ぶ
b = None
dist = float('inf')
for i in range(n):
    if As[i] != a and abs(As[i] - a/2) < dist:
        dist = abs(As[i] - a/2)
        b = As[i]

print(a, b)


Measured memory_bytes: 14052
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
typedef long long ll;
#define mp make_pair
int n,k;
ll a[1005];
ll ans=0;
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=0;i<k;i++){
		ans+=a[i];
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl '\n'
typedef long long ll;
//	Table is the complete reverse of dp
//	Always think of the pattern (LCM, GCD)
//	Be careful of unsigned
//	Think of a solution that gets TLE and optimize it
//	Use binary search
//	Solve on paper first
bool chk(int& x, int& y, int& z)
{
	if(y > z && y > x)
		return x + z > y;
	if(x > y && x > z)
		return y + z > x;
	return x + y > z;
}
int main()
{
    cin.tie(nullptr); ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    int *x = new int[n];
    for(int i = 0; i < n; i++)
    	cin >> x[i];
    ll sum = 0;
    for(int i = 0; i < n; i++)
    	for(int j = i + 1; j < n; j++)
    		if(x[i] != x[j])
				for(int k = j + 1; k < n; k++)
					if(x[i] != x[k] && x[j] != x[k] && chk(x[i], x[j], x[k]))
						sum++;
    cout << sum;
}


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

int main()
{
	string str;
	cin >>str;
	
	int N;
	cin >> N;
	
	int a, b;
	string cmd, par;
	
	for(int i = 0; i < N; ++i)
	{
		cin >> cmd >> a >> b;
		if(cmd == "replace")
		{
			cin >> par;
			str.replace(a, b - a + 1, par);
		}
		else if(cmd == "reverse")
		{
			for(int i = a, j = b; i < j; ++i, --j)
			{
				char temp = str[i];
				str[i] = str[j];
				str[j] = temp;
			}
		}
		else
		{
			cout << str.substr(a, b - a + 1) << endl;
		}
	}

    return 0;
}



Measured memory_bytes: 3212
n = int(input())
point = []
ans = -1
for i in range(n):
    point.append(list(map(int, input().split())))
x_sub_y = []
x_plus_y = []
for i in range(n):
    x_sub_y.append(point[i][0] - point[i][1])
    x_plus_y.append(point[i][0] + point[i][1])
x_sub_y.sort()
x_plus_y.sort()
ans = max(ans, x_sub_y[-1] - x_sub_y[0], x_plus_y[-1] - x_plus_y[0])
print(ans)

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

int main()
{
    int_fast16_t n,a,b,osum;
    int_fast64_t s = 0;
    std::cin >> n >> a >> b;
    for (int_fast16_t i = 1; i <= n; i++)
    {
        std::string ost = std::to_string(i);
        osum = 0;
        for (auto j = 0; j < (int)ost.size(); j++)
        {
            osum += (ost[j] - '0');
        }
        if( osum >= a && osum <= b)
        {
            s += i;
        }
    }
    std::cout << s << std::endl;
}

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

int main() {
	std::string s;
	int n;
	std::cin >> n >> s;
	if (n % 2 != 0)
		std::cout << "No";
	else {
		std::string k(s, 0, n / 2);
		std::string m(s, n / 2, n / 2);
		if (k == m) {
			std::cout << "Yes";
		}
		else
			std::cout << "No";
	}
	return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>

int main()
{
	int a, b, c, tmp;

	scanf("%d %d %d", &a, &b, &c);

	if (a > b)
	{
		tmp = a;
		a = b;
		b = tmp;
	}
	
	if (b > c)
	{
		tmp = b;
		b = c;
		c = tmp;
	}

	if (a > b)
	{
		tmp = a;
		a = b;
		b = tmp;
	}

	printf("%d %d %d\n", a, b, c);

    return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define ll long long
#define nes ios_base :: sync_with_stdio(0); cin.tie(0);
using namespace std;
const ll mo=1e9+7;
ll mod(ll n){
	return (n+mo)%mo;
}
int main(){
	nes;
	string s;
	cin>>s;
	if(s[s.size()-1]=='s'){
	s+='e';
	s+='s';
	}
	else s+='s';
	cout<<s;
	return 0;
}

Measured memory_bytes: 3660
#include<iostream>
using namespace std;
int main(){
  int a[200],b[200],i,num,k=0;
  cin>>num;
  for(i=0;i<num;i++){
    cin>>a[i]>>b[i];
  }
  
  for(i=0;i<num;i++){
    if(a[i]==b[i]){
      if(a[i+1]==b[i+1]){
        if(a[i+2]==b[i+2]){
          k++;
          break;
        }
      }
    }
  }
  
  if(k!=0)
    cout<<"Yes";
  else 
    cout<<"No";
  return 0;
}

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


int main() {
  int A,B;
  cin >> A >> B;

  int res = 0;
  
  if(A >= 10 || B >= 10){
  	res = -1; 
  }
  else{
    res = A*B;
  }
  cout << res << endl;
}







Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

lli n;
lli ans = 0;
int main(){
    cin >> n;
    for(lli i = 0;i < n;i++){
        lli x;
        cin >> x;
        for(lli j = 2;j*j <= x;j++){
            if(x%j == 0){
                ans--;break;
            }
        }
        ans++;
    }
    cout << ans << endl;
}

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

typedef long long int LLI;

int n;
LLI d[10];
LLI v[10];

bool input() {
  cin >> n;
  if (!n) {
    return false;
  }
  for (int i = 0; i < n; ++i) {
    cin >> d[i] >> v[i];
  }
  return true;
}

LLI gcd(LLI a, LLI b) {
  if (a < b) {
    return gcd(b, a);
  }

  while (b) {
    LLI t = a % b;
    a = b;
    b = t;
  }
  return a;
}

LLI lcm(LLI a, LLI b) {
  LLI g = gcd(a, b);
  return a / g * b;
}

void solve() {
  for (int i = 0; i < n; ++i) {
    LLI m = gcd(d[i], v[i]);
    d[i] /= m;
    v[i] /= m;
  }
  LLI g = d[0];
  for (int i = 1; i < n; ++i) {
    g = lcm(g, d[i]);
  }
  for (int i = 0; i < n; ++i) {
    v[i] *= g / d[i];
  }
  g = v[0];
  for (int i = 1; i < n; ++i) {
    g = gcd(g, v[i]);
  }
  for (int i = 0; i < n; ++i) {
    v[i] /= g;
  }
  for (int i = 0; i < n; ++i) {
    cout << v[i] << endl;
  }
}

int main() {
  while (input()) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3116
#include"bits/stdc++.h"
using namespace std;

int main(){
    int n;
    cin >> n;
    int w,h;
    int x,y;
    int s,t;
    int ans;
    int cnt;
    while (n!=0){
        cin >> w >> h;
        vector<vector<bool>> persimmon(h, vector<bool>(w));
        for (int i = 0; i<h; i++){
            for (int j = 0; j<w; j++) persimmon[i][j] = false;
        }
        for (int i = 0; i<n; i++){
            cin >> x >> y;
            persimmon[y-1][x-1] = true;
        }
        cin >> s >> t;
        ans = 0;
        for (int i = 0; i+t <= h; i++){
            for (int j = 0; j+s <= w; j++){
                cnt = 0;
                for (int k = 0; k<t; k++){
                    for (int l = 0; l<s; l++){
                        if (persimmon[i+k][j+l]) cnt++;
                    }
                }
                ans = max(ans, cnt);
            }
        }
        cout << ans << endl;
        cin >> n;
        
    }
}



Measured memory_bytes: 3100
#include "bits/stdc++.h"
using namespace std;

constexpr long long MOD = 1000000007;

int main() {
	int N, W;
	cin >> N >> W;
	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	sort(A.begin(), A.end(), greater<int>());
	vector<vector<long long> > DP(N + 1, vector<long long>(W + 1, 0));
	DP[0][0] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= W; j++) {
			DP[i + 1][j] += DP[i][j];
			DP[i + 1][j] %= MOD;
			if (j + A[i] <= W) {
				DP[i + 1][j + A[i]] += DP[i][j];
				DP[i + 1][j + A[i]] %= MOD;
			}
		}
	}
	int SUM = 0;
	long long ANS = 0;
	for (int i = N - 1; i >= 0; i--) {
		int MIN = W - SUM - A[i], MAX = W - SUM;
		for (int j = max(MIN, -1) + 1; j <= max(MAX, -1); j++) {
			ANS += DP[i][j];
			ANS %= MOD;
		}
		SUM += A[i];
	}
	if (SUM <= W) ANS++, ANS %= MOD;
	cout << ANS << endl;
}


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

using namespace std;

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

    vector<vector<long long>> dp(n, vector<long long>(n, 0));
    for (int i = n - 1; i >= 0; --i) {
        for (int j = i; j < n; ++j) {
            if (i == j) dp[i][j] = a[i];
            else dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1]);
        }
    }
    
    cout << dp[0][n - 1] << endl;
     
    return 0;
}


Measured memory_bytes: 70656
import Control.Applicative( (<$>))
import Data.Array.IArray
import Data.Array.Unboxed

main = do
    n_ <- readLn
    as_ <- map read . words <$> getLine
    let
	arr::UArray Int Int
	arr = listArray (1,n_) $ as_

	enumDown 1 = let
			next = if even n_
				then enumUp 3
				else enumUp 2
		     in
			(arr!1):next
	enumDown 2 = (arr!2):(enumDown 1)
	enumDown n = (arr!n):(enumDown $ n-2)
	enumUp n
	  | n/=n_-1	= (arr!n):(enumUp $ n+2)
	  | otherwise	= [arr!(n_-1)]
    
	print' [] = return ()
	print' (i:is) = do
	    putStr $ (show i)++" "
	    print' is

    case n_ of
	1   -> print $ arr!1
	2   -> print' [arr!2, arr!1]
	n   -> print' $ enumDown n

Measured memory_bytes: 63100
function main(input) {
  const tmp = input.trim().split('\n')
  const n = parseInt(tmp[0])

  const m = new Map()

  for (let i = 1; i <= n; i++) {
    const s = tmp[i]
    const ss = s.split('').sort().join('')

    if (m.has(ss)) {
      m.set(ss, m.get(ss) + 1)
    } else {
      m.set(ss, 1)
    }
  }

  let answer = 0
  m.forEach((v, _) => {
    answer += (v - 1) * v / 2
  })

  console.log(answer)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 62960
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>
#include <set>
#include <bitset>
#include <limits>

using namespace std;

#define ll long long

int main(void){
    double n;
    cin >> n;
    vector<double> v(n);
    for(int i = 0;i < n;++i)    cin >> v[i];

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

    double ans = (v[0]+v[1])/2.0;
    for(int i = 2;i < n;++i){
        ans = (ans+v[i])/2.0;
    }

    cout << ans << endl;

    return 0;
}

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

typedef long long ll;
 
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  string ans = "NO";
  for(int i=0; i<b; i++){
    if(a*i%b==c) ans = "YES";
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

const int nmax = 1e5 + 10;

int n;
int a[nmax];

bool used[nmax];
vector < int > g[nmax];

vector < int > _merge(vector < int > a, vector < int > b) {
    vector < int > res;

    int it1 = 0; int it2 = 0;
    while (it1 < a.size() || it2 < b.size()) {
        if (it1 == a.size())
            res.push_back(b[it2++]);
        else if (it2 == b.size())
            res.push_back(a[it1++]);
        else
            (a[it1] > b[it2]) ? res.push_back(a[it1++]) : res.push_back(b[it2++]);
    }

    return res;
}

vector < int > dfs(int node) {
    used[node] = 1;

    vector < int > res;
    for (auto &it : g[node]) {
        if (used[it]) continue;
        res = _merge(res, dfs(it));
    }

    res.push_back(0);
    for (int i = res.size() - 1; i ; --i) res[i] = res[i-1];
    res[0] = a[node];

    return res;
}

int gcd(int a, int b) {
    while (b) {
        int r = a % b;
        a = b;
        b = r;
    }

    return a;
}

int main()
{
    //freopen("input","r",stdin);
    //freopen("output","w",stdout);

    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
        scanf("%d", &a[i]);

    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; ++i)
        for (int j = i + 1; j <= n; ++j) {
            if (gcd(a[i], a[j]) == 1) continue;
            g[i].push_back(j);
            g[j].push_back(i);
        }

    vector < int > ans;
    for (int i = 1; i <= n; ++i) {
        if (used[i]) continue;
        ans = _merge(ans, dfs(i));
    }

    for (auto &it : ans) printf("%d ", it);

    return 0;
}


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

int main() {
	int N;
	cin >> N;
	int t[110000], x[110000], y[110000];
	t[0] = x[0] = y[0] = 0;
	for (int i = 0; i < N; i++) cin >> t[i+1] >> x[i+1] >> y[i+1];

	bool flag = true;
	for (int i = 0; i < N && flag; i++) {
		int time = t[i+1] - t[i];
		int dir = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
		if (time < dir) flag = false;
		if (dir % 2 != time % 2) flag = false;
	}

	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 4752
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp>   
using namespace std;
using namespace __gnu_pbds;  
typedef tree<int, null_type, less<int>, rb_tree_tag,  tree_order_statistics_node_update>  ordered_set; 
typedef long long ll;
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define ff(i, c, n) for (ll i = c; i < n; i++)
#define fr(i, c, n) for (ll i = c; i >= n; --i)

// DEBUGGING TEMPLATE
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
const ll mod=1000000007;
const ll mod1=998244353;

ll modpow(ll a, ll b, ll c)
{ //a^b%c in O(logb)
	ll res = 1;
	while (b > 0)
	{
		if (b & 1)
		{
			res = (res * a) % c;
		}
		a = (a * a) % c;
		b >>= 1;
	}
	return res;
}
ll modinv(ll m, ll n)
{ //modular inverse of n w.r.t m provided 1<=n<=(m-1) in O(logn) and m is prime
	ll inv[n + 1];
	inv[1] = 1;
	for (int i = 2; i < n + 1; ++i)
		inv[i] = (m - (m / i) * inv[m % i] % m) % m;
	return inv[n];
}

void solve(){
	string s;
	cin >> s;
	ff(i, 0, s.length()) {
		if(i % 2 && s[i] != 'i') { cout << "No"; return;}
		if(i % 2 == 0 && s[i] != 'h'){ cout<<"No"; return;}

	}
	if(s.length() % 2 == 1){cout<<"No";return;}
	cout<<"Yes";
}

//a+b=a^b+2*(a&b)
int main()
{
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	t = 1;
	while(t--){
		solve();
	}


	return 0;
}


Measured memory_bytes: 256