akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

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

ll P = 1000000007;
ll L, R;
ll memo[64][2][2][2] = {0};

ll f(int k, int m, int l, int r) {
  if (k < 0) return m == 1;
  if (memo[k][m][l][r] >= 0) return memo[k][m][l][r];

  ll ret = 0;
  for (int li = 0; li < 2; li++)
    for (int ri = 0; ri < 2; ri++) {
      if (li == 0 && l && (L & (1LL << k)) > 0) continue;
      if (ri == 1 && r && (R & (1LL << k)) == 0) continue;
      if (li > ri) continue;
      if (m == 0 && li != ri) continue;
      ret += f(k - 1, m || (li == 1 && ri == 1), l && ((L >> k) & 1) == li, r && ((R >> k) & 1) == ri);
    }
  return memo[k][m][l][r] = ret % P;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cin >> L >> R;
  for (int i = 0; i < 64; i++)
    for (int j = 0; j < 2; j++)
      for (int k = 0; k < 2; k++)
        for (int l = 0; l < 2; l++)
          memo[i][j][k][l] = -1;


  cout << f(61, 0, 1, 1) << endl;
  return 0;
}


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

int main()
{
	pair <string, int> score[10] , tmp;
	int n, w, l, d;
	int flg = 0;
	while (1)
	{
		cin >> n;
		if (n == 0) break;
		if (flg != 0) cout << endl;

		for (int i = 0; i < n; i++)
		{
			cin >> score[i].first >> w >> l >> d;
			score[i].second = w * 3 + d;
		}

		for (int i = 0; i < n; i++)
		{
			for (int j = n-1; j > i; j--)
			{
				if (score[j].second > score[j-1].second)
				{
					tmp=score[j];
					score[j] = score[j - 1];
					score[j - 1] = tmp;
				}
			}
		}

		for (int i = 0; i < n; i++)
		{
			cout << score[i].first << "," << score[i].second << endl;
		}
		flg++;
	}

	return 0;
}

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

using ll = long long int;

typedef pair<int, int> P;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int n;

ll l[MAX_N];
ll r[MAX_N];

pair<ll, ll> p[MAX_N];

ll min_r = INF;
ll max_l = -1L;

inline bool cmp(pair<ll, ll> a, pair<ll, ll> b) {
  return a.first < b.first || (a.first == b.first && a.second > b.second);
}

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    scanf("%lld %lld", &(l[i]), &(r[i]));
    max_l = max(max_l, l[i]);
    min_r = min(min_r, r[i]);
  }

  ll ans = 0L;

  // for case that a part of group is singleton
  for (int i = 0; i < n; ++i) {
    ans = max(ans, max(min_r - max_l + 1, 0LL) + r[i] - l[i] + 1L);
  }

  for (int i = 0; i < n; ++i) {
    p[i].first = max(min_r - l[i] + 1L, 0LL);   // first: fixed right
    p[i].second = max(r[i] - max_l + 1L, 0LL);  // second: fixed left
  }

  sort(p, p + n);

  ll part = p[0].second;
  for (int i = 1; i < n; ++i) {
    ans = max(ans, part + p[i].first);
    part = min(part, p[i].second);
  }

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

  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int fruit[1005];

int main()
{
    int n,k;
    cin>>n>>k;
    for(int i = 0; i < n; i++){
        cin>>fruit[i];
    }
    sort(fruit,fruit+n);
    int sum = 0;
    for(int i = 0; i < k; i++ ){
        sum += fruit[i];
    }
    cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n, sz[100007], fa[100007];
pair<int, int>p[100007];
vector<int>e[100007];
int read()
{
	int num = 0;
	char c = getchar();
	while (c<'0' || c>'9')c = getchar();
	while (c >= '0' && c <= '9')num = num * 10 + c - '0', c = getchar();
	return num;
}
int dfs(int w, int f)
{
	int res = 0;
	for (int i = 0, lim = e[w].size(); i < lim; i++)
		res += dfs(e[w][i], w) + sz[e[w][i]];
	return res;
}
signed main()
{
	n = read();
	for (int i = 1; i <= n; i++)
		p[i] = make_pair(read(), i);
	sort(p + 1, p + n + 1);
	for (int i = n; i > 1; i--)
	{
		int x = p[i].second;
		sz[x]++;
		int pos = lower_bound(p + 1, p + n + 1, make_pair(p[i].first + 2 * sz[x] - n, 0LL)) - p;
		if (pos >= i || p[i].first + 2 * sz[x] - n != p[pos].first) { cout << -1 << endl; return 0; }
		fa[x] = p[pos].second;
		sz[fa[x]] += sz[x];
		e[fa[x]].push_back(x);
	}
	sz[p[1].second]++;
	if(dfs(p[1].second,0)!=p[1].first) { cout << -1 << endl; return 0; }
	for (int i = 1; i <= n; i++)
		if (fa[i])printf("%lld %lld\n", fa[i], i);
	return 0;
}

Measured memory_bytes: 12288
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;


void Main() {
  ll n,k;
  cin >> n >> k;
  ll a[n],b[n];
  rep(i,n) R a[i];
  rep(i,n) R b[i];
  sort(a,a+n);
  sort(b,b+n,greater<ll>());
  ll l=-1,r=MAXL;
  while(l+1<r) {
    ll m=(l+r)/2;
    ll s=0;
    rep(i,n) {
      ll x=a[i]*b[i];
      ll y=ceil((double)max(0LL,x-m)/b[i]);
      s+=y;
    }
    if(s<=k) r=m;
    else l=m;
  }
  pr(r);
}

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


Measured memory_bytes: 3456
/* WORK HARD MAN ! IT DEFINETELY AIN'T EASY FOR THE PRIZE IT HOLDS .... */
/* GET YOUR ASS TO WORK ALREADY */
/* FALTU HI LIKH ... BUT KHALI NI BAITHNA */
#include<bits/stdc++.h>

#define fast ios_base::sync_with_stdio(false); cin.tie(nullptr); cin.tie(nullptr);
#define int long long
#define pb emplace_back
#define range(v) v.begin(),v.end()
#define mod 1000000007
#define inf 1e15
#define pii pair<int,int>
#define ff first
#define ss second
// #define N --

using namespace std;

/* if not able to handle the ques.. see up */
int32_t main() {
	fast
	int t_c = 1;
//	cin >> t_c;
	while (t_c--) {
		int n, k;
		cin >> n >> k;
		vector<int> a(n), dp(n, inf);
		for (int &i : a)
			cin >> i;
		dp[0] = 0;
		for (int i = 1; i < n; i++)
			for (int j = i - 1; j >= max(i - k, (int)0); j--)
				dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));

		cout << dp[n - 1] << endl;

	}
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
char s[11];
int main()
{
	scanf("%s",s+1);
	if(strcmp(s+1,"SUN")==0){
		printf("7\n");
	}else if(strcmp(s+1,"SAT")==0){
		printf("1\n");
	}else if(strcmp(s+1,"FRI")==0){
		printf("2\n");
	}else if(strcmp(s+1,"THU")==0){
		printf("3\n");
	}else if(strcmp(s+1,"WED")==0){
		printf("4\n");
	}else if(strcmp(s+1,"TUE")==0){
		printf("5\n");
	}else if(strcmp(s+1,"MON")==0){
		printf("6\n");
	}
	return 0;
}

Measured memory_bytes: 128
N,W = map(int,input().split())
w1,v1 = map(int,input().split())
items = {w: [] for w in range(w1,w1+4)}
items[w1].append(v1)

if N==1:
  print(v1)
  exit()

for _ in range(N-1):
  w,v = map(int,input().split())
  items[w].append(v)

lens = {}
for key in sorted(items.keys()):
  items[key].sort(reverse=True)
  lens[key] = len(items[key])

ans = -float('inf')
for i1 in range(lens[w1]+1):
  for i2 in range(lens[w1+1]+1):
    for i3 in range(lens[w1+2]+1):
      if W-i1*w1-i2*(w1+1)-i3*(w1+2) < 0: continue
      i4 = (W-i1*w1-i2*(w1+1)-i3*(w1+2))//(w1+3)
      ans = max(ans, sum(items[w1][:i1])+sum(items[w1+1][:i2])+sum(items[w1+2][:i3])+sum(items[w1+3][:i4]))
print(ans)

Measured memory_bytes: 45528
#include<bits/stdc++.h>
using namespace std;
#define int long long int
signed main()
{
    int n,d,tx,ty;
    cin>>n>>d;
    vector<int> x,y;
    for(int i=0;i<n;i++)
    {
        cin>>tx>>ty;
        x.push_back(tx);
        y.push_back(ty);
    }
    int c=0;
    double dis;
    for(int i=0;i<n;i++)
    {
        dis = sqrt((x[i]*x[i]) + (y[i]*y[i]));
        if(dis<=d)
        c++;
    }
    cout<<c;
}


Measured memory_bytes: 6648
import unittest


class TestC(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(7, 4), 1)

    def test_2(self):
        self.assertEqual(think(2, 6), 2)

    def test_3(self):
        self.assertEqual(think(1000000000000000000, 1), 0)


def solve():
    n, k = read()
    result = think(n, k)
    write(result)


def read():
    return read_int(2)


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(n, k):
    if n % k == 0:
        return 0
    m = n % k
    return min(m, abs(k - m))


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

Measured memory_bytes: 50928
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;cin >> s;
  ll ans = 0;
  ll tmp = 0;
  s.push_back('K');
  rep(i,s.size()){
      if(s[i] == 'A' ||s[i] == 'G' ||s[i] == 'C' ||s[i] == 'T' ){
          tmp++;
      }else{
          if(tmp){
              ans = max(ans, tmp);
              tmp = 0;
          }
      }
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
int n,a[100050];
const int INF=1e5+7;
int res,x;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n;
	for(int i=0;i<n;i++)cin>>x,a[x]++;
	res=a[0]+a[1];
	for(int i=1;i<INF;i++)res=max(res,a[i-1]+a[i]+a[i+1]);
	cout<<res;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;

int main(){
  ll n,k,sum=0,t;
  ll a[100000];
  int bi[41];
  for(int i=0;i<41;i++){
    bi[i]=0;
  }
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }
  for(int i=0;i<n;i++){
    ll p=a[i];
    t=2;
    int j=0;
    while(p!=0){
      if(p%t!=0){
	bi[j]++;
	p-=t/2;
      }
      j++;
      t*=2;
    }
  }
  /*for(int i=0;i<5;i++){
    cout<<bi[i];
  }
  cout<<endl;*/
  t=1099511627776;
  for(int i=40;i>=0;i--){
    //cout<<t<<endl;
    if(t>k){t/=2;continue;}
    else if(bi[i]<((n+1)/2)){
      sum+=((n-(bi[i]*2))*t);
      k-=t;
      t/=2;
      
    }else{
      t/=2;
    }
  }
  cout<<sum<<endl; 
  return 0;
}


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

 ll lcm(ll a, ll b)
{

    ll g=__gcd(a,b);

    return (a/g)*(b);

}

int main( )
{
    ll n, i, x, k, mx = 1;
    map<long int, long int> mp;
    vector<int> v;
    cin >> n;
    ll ara[n+1];
    for (i = 1; i <= n; i++)
    {
        cin>>ara[i];

    }
    for (i = 1; i <= n; i++)
    {
        mx=lcm(mx,ara[i]);

    }
    cout<<mx<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
        //#define m ((long long)1e9+7)
        #define f first
        #define s second
        #define pb push_back
        typedef long long ll;
        using namespace std;
        int dp[100001]={0},n,m;vector<vector<int>> v(100001);int visit[100001]={0};
        void input()
        {
            int a,b;
            for(int i=0;i<m;i++)
            {
                cin>>a>>b;
                v[a].pb(b);   
            }
        }
        int dfs(int a)
        {
            if(v[a].size()==0)
            return dp[a];
            if(dp[a]!=0)
            return dp[a];
            for(int i=0;i<v[a].size();i++)
            {
                dp[a]=max(dp[a],1+dfs(v[a][i]));
            }
            return dp[a];
        }
        void display()
        {
            int ma=0;
            for(int i=1;i<=n;i++)
            ma=max(ma,dp[i]);
            cout<<ma<<endl;
        }
        int main() {
            ios_base::sync_with_stdio(false);cin.tie(NULL);
        	cin>>n>>m;
        	input();
        	for(int i=1;i<=n;i++)
        	if(dp[i]==0)
        	dp[i]=dfs(i);
        	display();
        }

Measured memory_bytes: 7552
import Data.List
 
main = interact $ unlines . map (show . comb_of_numseq . map read . words) . lines
 
comb_of_numseq [n,s] = perms s [1..n] [0..9]

perms 0 [] _ = 1
perms _ [] _ = 0
perms s' aas@(a:as) ccs@(c:cs)
 | s' > sum (zipWith (*) (reverse aas) (reverse ccs)) = 0
 | s' < sum (zipWith (*) aas ccs') = 0
 | otherwise = sum [perms (s'-a*c') as (delete c' ccs) | c'<-ccs]
 where ccs' = if c==0 then reverse (take (length as) cs) else reverse (take (length aas) ccs)

Measured memory_bytes: 4932
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int[] a=new int[n+2];
    int sum=0;
    for(int i=1;i<=n;i++){
      a[i]=sc.nextInt();
    }
    for(int i=0;i<=n;i++){
      sum+=Math.abs(a[i+1]-a[i]);
    }
    int[] b=new int[n];
    for(int i=0;i<n;i++){
      b[i]=Math.abs(a[i+2]-a[i+1])+
           Math.abs(a[i+1]-a[i  ])-
           Math.abs(a[i+2]-a[i  ]);
    }
    for(int i=0;i<n;i++){
      System.out.println(sum-b[i]);
    }
  }
}

Measured memory_bytes: 63080
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>

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

typedef long long ll;

using namespace std;

ll dp[100005][13];

int main(){
	// 各桁ごとに余りを計算してもよいことが前提
	// ?44 なら ? * 100 + 4 * 10 + 4 であるので、全体の余りも各桁(各項)の余りを足せば良い
    string S;
    cin >> S;

    int S_size = S.size();
    // dp配列の初期化
    dp[0][0] = 1;

    REP(i, S_size) {
    	char digit = S[i];
    	int c;
    	if (digit == '?') c = -1;
    	else c = digit - '0';

    	REP(j, 10) {
    		if (c != -1 && c != j) continue;
    		REP(k, 13) {
    			// 先頭i桁までで13で割った余りがk となるものを足しこむ
    			// (k * 10 + j) % 13 は上から(i + 1) 桁目の数字がj であるの13で割った余り
    			// k は一つ上の桁まで考えたときの余りであるので10倍する
    			dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
    		}
       	}
   		// 答えが大きくなることがあるため13で割った余りにしておく
		REP(j, 13) {
			dp[i + 1][j] %= MOD;
		}
    }

    ll ans = dp[S_size][5];

    cout << ans << endl;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int k;
    cin >> k;
    LL res = 0;
    for(int i = 1; i <= k; ++i) {
        for(int j = 1; j <= k; ++j) {
            for(int l = 1; l <= k; ++l) {
                res += __gcd(i, __gcd(j, l));

            }
        }
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define REP(i,y) for(int i=0; i<y; ++i)

int main(){
  int N, M, A, K, ans=0;
  cin >> N >> M;
  int tmp[M];
  REP(i,M) tmp[i]=0;
  REP(i,N){
    cin >> K;
    REP(j,K){
      cin >> A;
      tmp[A-1]++;
    }
  }
  REP(i,M) ans += (tmp[i]==N);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter
val pw = PrintWriter(System.out)

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

fun func() {
    val n = next()
    val aa = listOfInt()
    println(aa.max()!!-aa.min()!!)
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 37608
import java.util.HashSet;
import java.util.Scanner;

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

        int n = scan.nextInt();
        int k = scan.nextInt();
        HashSet<Integer> hash = new HashSet<>();

        for (int x = 0; x < k; x++) {
            int inner = scan.nextInt();
            for (int y = 0; y < inner; y++) {
                hash.add(scan.nextInt());
            }
        }

        System.out.println(n - hash.size());
   }
}

Measured memory_bytes: 46144
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;

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

    vector<int> p(n);

    rep(i, n) { cin >> p[i]; }

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

    int total = 0;
    rep(i, k) { total += p[i]; }

    cout << total << endl;
}


Measured memory_bytes: 3596
#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;

int main(){
  int N;
  cin >> N;
  pair<int, int> p[N];
  for(int i = 0; i < N; i++){
    cin >> p[i].first;
    p[i].second = i + 1;
  }

  sort(p, p + N);

  for(int i = 0; i < N; i++){
    cout << p[i].second << " ";
  }
  cout << endl;
  return 0;
}


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

int N;

int main() {
    cin >> N;

    vector<ll> lucas;
    for (int i = 0; i <= N; i++) {
        if (i == 0) lucas.push_back(2);
        else if (i == 1) lucas.push_back(1);
        else {
            lucas.push_back(lucas[i-1] + lucas[i-2]);
        }
    }

    cout << lucas[N] << endl;

    return 0;
}


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

typedef long long ll;

int a[12][12];

int main()
{
	int n, m, x;
	cin >> n >> m >> x;
	vector<int> c(n);
	rep(i, n)
	{
		cin >> c[i];
		rep(j, m)
			cin >> a[i][j];
	}
	//bit全探索 1<<nで、1の後ろにn個0がつく
	//n=3 => 1000 なので(s = 0000; s < 1000 s++)の0〜7まで
	int ans = INT_MAX;
	//1<<n == 2^n;
	rep (s, 1<<n)
	{
		int cost = 0;
		vector<int> d(m);
		rep(i, n)
		{
			//bit が１の時つまり本が選ばれた時
			//(s=010,i=1)の時 sの1をi個右に移動010＝>001
			if (s>>i&1)
			{
				cost += c[i];
				rep(j,m)
					d[j] += a[i][j];
			}
		}
		bool ok = true;
		rep (j, m)
		{
			if (d[j] < x)
				ok = false;
		}
		if (ok == true)
			ans = min(ans, cost);
	}
	if (ans == INT_MAX)
		cout << -1 << endl;
	else
		cout << ans << endl;
	return (0);
}


Measured memory_bytes: 3600
import java.rmi.activation.ActivationGroup_Stub;
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> al = new ArrayList<Integer>();
        double total = 0;

        int N = sc.nextInt();
        int M = sc.nextInt();
        for (int i = 0; i < N; i++) {
            al.add(sc.nextInt());
        }

        int count = 0;
        for (int i = 0; i < N; i++) {
            total += al.get(i);
        }

        for (int j = 0; j < N; j++) {
            if (al.get(j) >= (total/(4*M))) {
                count++;
            }
            else {
                count = count;
            }
        }

        if (count >= M) {
            System.out.println("Yes");
        }

        else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
H, W = map(int, input().split(' '))

grids = []
for i in range(H):
    grids.append(list(input()))

for i in range(H):
    for j in range(W):
        if grids[i][j] == '.':
            continue

        if i == 0 and j == 0:
            if grids[i][j + 1] == '.' and grids[i + 1][j] == '.':
                print("No")
                exit()

        elif i == 0 and j == W - 1:
            if grids[i][j - 1] == '.' and grids[i + 1][j] == '.':
                print("No")
                exit()

        elif i == 0:
            if grids[i][j - 1] == '.' and grids[i][j + 1] == '.' and grids[i + 1][j] == '.':
                    print("No")
                    exit()

        elif i == H - 1 and j == 0:
            if grids[i][j + 1] == '.' and grids[i - 1][j] == '.':
                print("No")
                exit()

        elif i == H - 1 and j == W - 1:
            if grids[i][j - 1] == '.' and grids[i - 1][j] == '.':
                print("No")
                exit()

        elif i == H - 1:
            if grids[i][j - 1] == '.' and grids[i][j + 1] == '.' and grids[i - 1][j] == '.':
                print("No")
                exit()

        elif j == 0:
            if grids[i - 1][j] == '.' and grids[i][j + 1] == '.' and grids[i + 1][j] == '.':
                    print("No")
                    exit()

        elif j == W - 1:
            if grids[i - 1][j] == '.' and grids[i][j - 1] == '.' and grids[i + 1][j] == '.':
                    print("No")
                    exit()

        else:
            if grids[i - 1][j] == '.' and grids[i + 1][j] == '.' and grids[i][j - 1] == '.' and grids[i][j + 1] == '.':
                    print("No")
                    exit()

print("Yes")

Measured memory_bytes: 3192
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
int N;
int G[100][100];
int d[100];
int used[100];
const int INF=1000000000;
void dijkstra(int s){
  for(int u=0;u<N;u++)d[u]=INF;
  d[s]=0;
  while(1){   
    int v=-1;
    for(int u=0;u<N;u++){
      if((v==-1 || d[v]>d[u]) && !used[u])v=u;
    }
    if(v==-1)break;
    used[v]=1;
    for(int u=0;u<N;u++){
      d[u]=min(d[u],d[v]+G[v][u]);
    }
  }
}
int main(){

  for(int i=0;i<100;i++){
    for(int j=0;j<100;j++){
      G[i][j]=INF;
      if(i==j)G[i][j]=0;
    }
  }
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    int u,k,c,v;
    scanf("%d %d",&u,&k);
    for(int j=0;j<k;j++){
      scanf("%d %d",&v,&c);
      G[u][v]=c;
     
    }
  }
  dijkstra(0);
  for(int i=0;i<N;i++)printf("%d %d\n",i,d[i]);
  return 0;
}

Measured memory_bytes: 3248
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
using namespace std;
const int MAXN = 1e5 + 10;
const ll MOD = 1e9 + 7;
ll N, M, Q;
char str[110];
vector<ll> vec;

int main()
{
	int i, j;
	ll K;
	scanf("%s %lld", str, &K);
	N = strlen(str);

	ll cnt = 0LL;
	for (i = 0; i < N;++i) {
		++cnt;
		if (i == N - 1 || str[i] != str[i + 1]) {
			vec.push_back(cnt);
			cnt = 0LL;
		}
	}

	int sz = vec.size();
	if (sz == 1) {
		printf("%lld", N*K / 2LL);
	}
	else {
		ll sum = 0LL;
		for (i = 0; i < sz; ++i) sum += vec[i]/2LL;

		if (str[0] == str[N - 1]) {
			sum -= vec[0] / 2LL;
			sum -= vec[sz - 1] / 2LL;
			sum *= K;
			sum += ((vec[0] + vec[sz - 1]) / 2LL) * (K - 1LL);
			sum += (vec[0] / 2LL + vec[sz - 1] / 2LL);
			printf("%lld", sum);
		}
		else {
			printf("%lld", sum*K);
		}
	}
	return 0;
}

Measured memory_bytes: 256
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 2e5 + 10, inf = 1e7;

vector<int> pts[N];
set<pii> seen;

int main() {
	fast_cin();
	int h, w, n;
	cin >> h >> w >> n;
	for (int i = 1; i <= n; ++i) {
		int x, y;
		cin >> x >> y;
		pts[y].pb(x);
		seen.insert({x, y});
	}
	int best = inf, best_tak = inf, moves = 0;
	int x = 1;
	for (int y = 1; y <= w; ++y) {
		pts[y].pb(h + 1);
		seen.insert({h + 1, y});
		sort(pts[y].begin(), pts[y].end());
		int block = *upper_bound(pts[y].begin(), pts[y].end(), x) - x;
		// cout << x << ' ' << y << ' ' << moves << ' ' << block << endl;
		if (moves + max(1, block - 1) < best) {
			best = moves + max(1, block - 1);
			best_tak = moves + block;
		} else if (moves + max(1, block - 1) == best) {
			best_tak = min(best_tak, moves + block);
		}
		bool ok = true;
		while (true) {
			++moves;
			++x;
			if (seen.count({x, y}) or y == w) {
				ok = false;
				break;
			}
			if (!seen.count({x, y + 1})) {
				break;
			}
		}
		if (!ok) {
			break;
		}
	}
	cout << best_tak << endl;
}

Measured memory_bytes: 26112
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# TLE
# O(HW(H+W)) で10^8になるので無理

H, W = map(int, input().split())

S = [input() for _ in range(H)]
NUM = [[0] * (W) for _ in range(H)]

for r in range(H):
    cnt = 0
    for c in range(W):
        if S[r][c] == '#':
            cnt = 0
        else:
            cnt += 1
            NUM[r][c] += cnt

    cnt = 0
    for c in range(W - 1, -1, -1):
        if S[r][c] == '#':
            cnt = 0
        else:
            cnt += 1
            NUM[r][c] += cnt

for c in range(W):
    cnt = 0
    for r in range(H):
        if S[r][c] == '#':
            cnt = 0
        else:
            cnt += 1
            NUM[r][c] += cnt

    cnt = 0
    for r in range(H - 1, -1, -1):
        if S[r][c] == '#':
            cnt = 0
        else:
            cnt += 1
            NUM[r][c] += cnt

ans = 4
for i in range(H):
    t = max(NUM[i])
    ans = max(ans, t)

print(ans-3)


Measured memory_bytes: 96088
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }


int main() {
	int r,d,x;
	cin >> r >> d >> x;
	REP(i, 10) {
		int res = r * x - d;
		put(res);
		x = res;
	}
	return 0;
}



Measured memory_bytes: 256
#105という数は, 非常に特殊な性質を持つ - 奇数なのに, 約数が 8個もある.
#さて, 1以上 N以下の奇数のうち, 正の約数を ちょうど 8個持つようなものの個数を求めよ.
#1<=N<=200

N = int(input())

Nlist = list(range(1,N+1, 2))
ans = 0
for n in Nlist:
    tmp = 1
    for i in range(1, (N+1)//2):
        if n % i == 0:
            tmp += 1
    if tmp == 8:
        ans += 1

print(ans)

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    
    int n = 1;
    if(b != a) n++;
    if (c != a && c != b) n++;
    
    cout << n<< endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 500;
const int MAX_M = 50000;

/* typedef */

typedef vector<int> vi;

struct UFT {
  int links[MAX_N], ranks[MAX_N], sizes[MAX_N];
  
  UFT() {}

  void clear(int n) {
    for (int i = 0; i < n; i++)
      links[i] = i, ranks[i] = sizes[i] = 1;
  }

  int root(int i) {
    int i0 = i;
    while (links[i0] != i0) i0 = links[i0];
    return (links[i] = i0);
  }

  int rank(int i) { return ranks[root(i)]; }
  int size(int i) { return sizes[root(i)]; }
  bool same(int i, int j) { return root(i) == root(j); }
  
  int merge(int i0, int i1) {
    int r0 = root(i0), r1 = root(i1);
    int mr;
    if (ranks[r0] == ranks[r1]) {
      links[r1] = r0;
      sizes[r0] += sizes[r1];
      ranks[r0]++;
      mr = r0;
    }
    else if (ranks[r0] > ranks[r1]) {
      links[r1] = r0;
      sizes[r0] += sizes[r1];
      mr = r0;
    }
    else {
      links[r0] = r1;
      sizes[r1] += sizes[r0];
      mr = r1;
    }
    return mr;
  }
};

struct Edge {
  int a, b, c;
  Edge() {}
  Edge(int _a, int _b, int _c) { a = _a, b = _b, c = _c; }
  void set(int _a, int _b, int _c) { a = _a, b = _b, c = _c; }
  bool operator<(const Edge& e) const { return c < e.c; }
};

/* global variables */

UFT uft;
Edge edges[MAX_M];

/* main */

int main() {
  int n, m;
  cin >> n >> m;
  
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    edges[i].set(a, b, c);
  }

  sort(edges, edges + m);

  uft.clear(n);
  vi ve;
  int min_csum = 0;
  
  for (int i = 0; i < m; i++) {
    Edge& ei = edges[i];

    int ra = uft.root(ei.a), rb = uft.root(ei.b);
    if (ra == rb) continue;

    int r = uft.merge(ra, rb);
    min_csum += ei.c;
    ve.push_back(i);

    if (uft.size(r) == n) break;
  }
  // cout << min_csum << ' ' << ve.size() << endl;

  int nobnum = 0, nobsum = 0;

  for (int i = 0; i < ve.size(); i++) {
    uft.clear(n);
    int csum = 0;
    bool found = false;
    
    for (int j = 0; j < m; j++) {
      if (j == ve[i]) continue;

      Edge& ej = edges[j];

      int ra = uft.root(ej.a), rb = uft.root(ej.b);
      if (ra == rb) continue;

      int r = uft.merge(ra, rb);
      csum += ej.c;

      if (csum >= min_csum || uft.size(r) == n) {
	if (csum == min_csum && uft.size(r) == n) found = true;
	break;
      }
    }

    if (! found) {
      nobnum++;
      nobsum += edges[ve[i]].c;
    }
  }

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

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

int main() {
  int n, m, ans = 0; cin >> n >> m;
  vector<vector<int>> v(m+1);
  rep(i, n) {
    int a, b; cin >> a >> b;
    if (m < a) continue;
    v[a].push_back(b);
  }
  priority_queue<int> q;
  for (int i = 1; i <= m; i++) {
    for (auto p : v[i]) q.push(p);
    if (q.empty()) continue;
    ans += q.top(); q.pop();
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5504
int m[2000][2000];
main(){
	int N,K;
	for(scanf("%d%d",&N,&K);N--;){
		int x,y;char c;
		scanf("%d%d%*c%c",&x,&y,&c);
		if(c=='W'){x+=K;}
		for(int i=0;i<2;++i){
			x%=2*K;
			y%=2*K;
			if(x<K){
				if(y<K){
					++m[y][x];
					--m[y][x+K];
					--m[y+K][x];
					++m[y+K][x+K];
				}else{
					++m[y][x];
					--m[y][x+K];
					
					++m[0][x];
					--m[0][x+K];
					--m[y-K][x];
					++m[y-K][x+K];
				}
			}else{
				if(y<K){
					++m[y][x];
					--m[y+K][x];
					
					++m[y][0];
					--m[y][x-K];
					--m[y+K][0];
					++m[y+K][x-K];
				}else{
					++m[y][x];
					
					++m[y][0];
					--m[y][x-K];
					
					++m[0][x];
					--m[y-K][x];
					
					++m[0][0];
					--m[0][x-K];
					--m[y-K][0];
					++m[y-K][x-K];
				}
			}
			x+=K;
			y+=K;
		}
	}
	for(int y=0;y<2*K;++y){
		for(int x=1;x<2*K;++x){
			m[y][x]+=m[y][x-1];
		}
	}
	int z=0;
	for(int x=0;x<2*K;++x){
		for(int y=0;y<2*K;++y){
			if(y){
				m[y][x]+=m[y-1][x];
			}
			if(m[y][x]>z){
				z=m[y][x];
			}
		}
	}
	printf("%d",z);
}


Measured memory_bytes: 15744
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

signed main()
{
  cin.tie(nullptr), ios::sync_with_stdio(false);

  int n; cin >> n;
  cout << (n<1200? "ABC" : "ARC") << LF;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define assign(x,val) memset(x,val,sizeof(x))
#define motherfucker  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define for0(i,n) for(ll i=0;i<n;++i)
#define for1(i,n) for(ll i=1;i<=n;++i)
#define ford(i,n) for(ll i=n;i>=1;--i)
#define forg(i,a,b) for(ll i=a;i<b;++i)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpl;
long long mod = 1000000007;
const long double PI = (long double)(3.1415926535897932384626433832795);
 
 
void solve(){
	ll n, k;cin>>n>>k;
	if(n*500>=k) cout<<"Yes\n";
	else cout<<"No\n";
}
 
int main(){
	
	motherfucker
	ll t = 1;
	//cin>>t;
	for0(i, t){
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
inp = []
i = 0
j = 0
k = 0
l = 0

while True:
    inp.append(list(map(int, input().split())))
    if inp[i][0] == 0 and inp[i][1] == 0:
        del inp[i]
        break
    i += 1

for j in range(len(inp)):
    for k in range(inp[j][0]):
        for l in range(inp[j][1]):
            if (k+l) % 2 == 0:
                print(end="#")
            else:
                print(end=".")
        print("")
    print("")
        




Measured memory_bytes: 6308
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,ans=0,MAX,cnt;
  cin >> n;
  long long a[n],b[n],c[n],d[n];
  bool f[n];
  pair<long long,long long> re[n],bl[n];
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
    re[i]=make_pair(a[i],b[i]);
    f[i]=true;
  }
  for(int i=0;i<n;i++){
    cin >> c[i] >> d[i];
    bl[i]=make_pair(c[i],d[i]);
  }
  sort(re,re+n);
  sort(bl,bl+n);
  for(int i=0;i<n;i++){
    MAX=-1;
    cnt=0;
    while(re[cnt].first<bl[i].first){
      if(re[cnt].first<bl[i].first and re[cnt].second<bl[i].second and f[cnt]){
        MAX=max(MAX,re[cnt].second);
      }
      cnt++;
    }
    if(MAX!=-1){
      while(re[cnt].second!=MAX){
        cnt--;
      }
      f[cnt]=false;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    s=chomp(readline())
    cnt=Dict{Char,Int}()
    for i in 1:4
        try
            cnt[s[i]]+=1
        catch
            cnt[s[i]]=1
        end
    end
    flg=true
    for i in values(cnt)
        if i!=2
            flg=false
            break
        end
    end
    println(ifelse(flg,"Yes","No"))
end
main()

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

int a, b;

int solve() {
  scanf("%d %d", &a, &b);
  printf("%d\n", a * b);
  return 0;
}

int main() {
  int t = 1;
  // scanf("%d", &t);
  for (int tc = 0; tc < t; ++tc) {
    // printf("Case #%d: ", tc+1);
    solve();
  }
  return 0;
}


Measured memory_bytes: 3816
#!/usr/bin/env ruby

attrs = Array.new
while line = $stdin.gets
  attrs << line.chomp.split
end

A = attrs[0][0]
B = attrs[0][1]
C = attrs[0][2]

if (A == B && A != C) || (A == C && A != B) || (C == B && A != C) then
  puts 'Yes'
else
  puts "No"
end

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef DEBUG
//    freopen("solution.out", "w", stdout);
    freopen("1.in", "r", stdin);
#endif
    int n, m;
    cin >> n >> m;
    vector<int> obs(n);
    set<int> bad;
    for (int i = 0; i < n; ++i) {
        cin >> obs[i];
    }
    int a, b, ah, bh;
    for (int i = 0; i < m; ++i) {
        cin >> a >> b;
        ah = obs[a - 1], bh = obs[b - 1];
        if (ah == bh) {
            bad.insert(a), bad.insert(b);
        } else if (ah > bh) {
            bad.insert(b);
        } else {
            bad.insert(a);
        }
    }
    cout << n - bad.size() << "\n";

    return 0;
}


Measured memory_bytes: 6380
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-9, pi = acos(-1.0);
namespace std {
    bool operator<(const Point &lhs, const Point &rhs) {
        if (lhs.real() < rhs.real() - eps) return true;
        if (lhs.real() > rhs.real() + eps) return false;
        return lhs.imag() < rhs.imag();
    }
}
Point input_point() {ld x, y; cin >> x >> y; return Point(x, y);} // ????????\???
bool eq(ld a, ld b) {return (abs(a - b) < eps);} // ????????????????????????
ld dot(Point a, Point b) {return real(conj(a) * b);} // ??????
ld cross(Point a, Point b) {return imag(conj(a) * b);} // ??????

// ??´????????????
class Line {
public:
    Point a, b;
    Line() : a(Point(0, 0)), b(Point(0, 0)) {}
    Line(Point a, Point b) : a(a), b(b) {}
    Point operator[](const int _num) {
        if (_num == 0)return a;
        else if (_num == 1)return b;
        else assert(false);
    }
};

// ????????????
class Circle {
public:
    Point p;
    ld r;
    Circle() : p(Point(0, 0)), r(0) {}
    Circle(Point p, ld r) : p(p), r(r) {}
};

// ??????????¶?
Point proj(Line l, Point p) {
    ld t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
    return l.a + t * (l.a - l.b);
}

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
//    Point p1 = input_point(),p2 = input_point(); Line l(p1,p2);
    Line l(input_point(),input_point());
    int q; cin >> q;
    for(int i = 0; i < q;i++){
        //   Point p = input_point(); Point x = proj(l,p);
        Point x = proj(l,input_point());
        cout << fixed << setprecision(10) << x.real() << " " << x.imag() << endl;
    }
    return 0;
}

Measured memory_bytes: 3368
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

D = int(input())
c = [int(x) for x in input().split()]
s = []
for _ in range(D):
    s.append([int(x) for x in input().split()])
t = [int(input()) for x in range(D)]
last = [0]*26
ans = 0
for i in range(1, D + 1):
    ans += s[i - 1][t[i - 1] - 1]
    last[t[i - 1] - 1] = i
    for j in range(26):
        ans -= c[j]*(i - last[j])
    print(ans)



Measured memory_bytes: 68324
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    int n;
    cin>>n;
    int h[n];
    rep(i,n)cin>>h[i];
    int res=0;
    int mx=0;
    rep(i,n){
        if(h[i]>=mx){
            res++;
        }
        mx=max(mx,h[i]);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int n, m;
	int a[100], b[100];
	cin >> n >> m;
	vector<vector<int>>vec(100);
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
		vec[a[i]].emplace_back(b[i]);
		vec[b[i]].emplace_back(a[i]);
	}
	queue<int> que;
	int ans = 0;
	for (int j = 0; j < m; j++) {
		que.push(1);
		bool bo[100] = { false };
		bo[1] = true;
		int co = 0;
		while (!que.empty()) {
			int now = que.front();
			for (int i = 0; i < vec[now].size(); i++) {
				if (bo[vec[now][i]] == false) {
					if (now != a[j] || vec[now][i] != b[j]) {
						if (now != b[j] || vec[now][i] != a[j]) {
							que.push(vec[now][i]);
							bo[vec[now][i]] = true;
							co++;
						}
					}
				}
			}
			que.pop();
		}
		if (co != n - 1) {
			ans++;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		String[] a = new String[H];
		for(int i = 0; i < H; i++) {
			a[i] = sc.next();
		}
		StringBuilder buf = new StringBuilder();
		for(int i = 0; i < W+2; i++) {
			buf.append("#");
		}
		String frame = buf.toString();
		for(int i = 0; i < H+2; i++) {
			if(i == 0 || i == H+1) {
				System.out.println(frame);
			}else {
				System.out.println("#" + a[i-1] + "#");
			}
		}
	}
}


Measured memory_bytes: 30704
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	int length[10];
	int v1;
	int v2;
	char comma;
	while (cin>>length[0]>>comma>> length[1]>>comma>> length[2]>>comma>> length[3]>>comma>> length[4]>>comma>> length[5]>>comma>> length[6]>>comma>> length[7]>>comma>> length[8]>>comma>>length[9]>>comma>>v1>>comma>>v2){
	double sum=0;
	REP(i,10)
		sum += length[i];
	double time = sum / (double)(v1+v2);
	double go=time*(double)v1;
	REP(i,10){
		if (go <= (double)length[i] + 1e-10){
		cout<<(i+1)<<endl;
		break;
		}else
			go -= (double)length[i];
	}
	}
	return 0;
}

Measured memory_bytes: 2996
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.NavigableSet;
import java.util.TreeSet;

import static java.lang.Integer.parseInt;

/**
 * Darts
 * JOI 2008 ??¬???3
 */
public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

//		long ts = System.nanoTime();

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int N, M;
			N = parseInt(line.substring(0, line.indexOf(' ')));
			M = parseInt(line.substring(line.indexOf(' ') + 1));
			if ((N | M) == 0) break;

			int[] Pa = new int[N + 1];
			NavigableSet<Integer> Pt = new TreeSet<>();

			for (int i = 1; i <= N; i++) {
				Pa[i] = parseInt(br.readLine());
			}

			for (int i = 0; i < Pa.length; i++) {
				for (int j = 0; j < Pa.length; j++) {
					if (i <= j && Pa[i] + Pa[j] <= M) Pt.add(Pa[i] + Pa[j]);
				}
			}

			Pa = new int[Pt.size()];
			int _i = 0;
			for (int p : Pt) {
				Pa[_i] = p;
				_i++;
			}

			int max = 0;
			for (int i = 0; i < Pa.length; i++) {
				if (Pa[i] > M / 2) break;
				max = Math.max(max, Pa[i] + Pt.floor(M - Pa[i]));
			}
			System.out.println(max);
		}
//		System.out.println((System.nanoTime() - ts) / 1000 / 1000);
	}//end main
}

Measured memory_bytes: 167848
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long N = sc.nextLong();
		
		int ans = 0;
		for(long d=2; d*d<=N; d++) {
			if(N%d==0) {
				int count = 0;
				while(N%d==0) {
					count++;
					N/=d;
				}
				for(int i=1; ; i++) {
					count-=i;
					if(count>=0)
						ans++;
					else
						break;
				}
			}
		}
		if(N>1)
			ans++;
		
		System.out.println(ans);
		sc.close();
	}
}


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

int main(){
    string S;
    cin >> S;

    const int n = S.size();

    string str_temp1(n, ' ');
    string str_temp2(n, ' ');
    
    for(int i = 0; i < n; ++i){
        if(i & 1){
            str_temp1[i] = '0';
            str_temp2[i] = '1';
        }else{
            str_temp1[i] = '1';
            str_temp2[i] = '0';
        }
    }

    int ans1, ans2;
    ans1 = ans2 = 0;
    for(int i = 0; i < n; ++i){
        if(S[i] != str_temp1[i]){
            ++ans1;
        }

        if(S[i] != str_temp2[i]){
            ++ans2;
        }
    }

    cout << min(ans1, ans2) << endl;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

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

    if(s[0] == s[2]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256