akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        x: usize,
        y: usize,
    }
    println!("{}", x + y / 2);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main(){

    long N;
    cin >> N;

    vector<long> P(N);
    for(long i=0; i<N; i++){
        cin >> P[i];
    }

    long counter = 0;
    int min_until_i = P[0];

    // おしりの値とそれまでのminを比較してminを更新していけばよい．そのときcounterを増やす
    
    for(long i=0; i<N; i++){
        if(P[i] <= min_until_i){
            min_until_i = P[i];
            counter += 1;
        }
    }
    

    cout << counter << endl;

    return 0;
}

Measured memory_bytes: 1792
N, M = map(int, input().split())

A = []
for i in range(N):
  x, y, z = map(int, input().split())
  A.append([
    x+y+z,
    x+y-z,
    x-y+z,
    x-y-z,
    -x+y+z,
    -x+y-z,
    -x-y+z,
    -x-y-z,
  ])

if M == 0:
  print(0)
else:
  print(max([sum(a[-M:]) for a in list(map(sorted, list(zip(*A))))]))

Measured memory_bytes: 3564
// https://atcoder.jp/contests/abc140/tasks/abc140_b
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    REP(i, N) {
        cin >> A[i];
        A[i]--;
    }
    REP(i, N) { cin >> B[i]; }
    REP(i, N - 1) { cin >> C[i]; }
    int ans = 0, before = -2;
    REP(i, N) {
        ans += B[A[i]];
        if (before + 1 == A[i]) {
            ans += C[before];
        }
        before = A[i];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3532
#include <bits/stdc++.h>
 using namespace std;
  int main (){
      int x,y;
      cin >> x >> y;
  int a=0,b=0;
   switch(x){
       case 1:
       a+=1;
       break;
       case 2:
       break;
       case 3:
       a+=1;
       break;
       case 4:
      b+=1;
      break;
      case 5:
      a+=1;
      break;
      case 6:
      b+=1;
      break;
      case 7:
      a+=1;
      break;
      case 8:
      a+=1;
      case 9:
      b+=1;
      break;
      case 10:
      a+=1;
      break;
      case 11:
      b+=1;
      break;
      case 12:
      a+=1;
      break;
   }
         switch(y){
       case 1:
       a+=1;
       break;
       case 2:
       break;
       case 3:
       a+=1;
       break;
       case 4:
      b+=1;
      break;
      case 5:
      a+=1;
      break;
      case 6:
      b+=1;
      break;
      case 7:
      a+=1;
      break;
      case 8:
      a+=1;
      case 9:
      b+=1;
      break;
      case 10:
      a+=1;
      break;
      case 11:
      b+=1;
      break;
      case 12:
      a+=1;
      break;
   }
   if(a==2 || b==2){
       cout << "Yes" << endl;
   }
   else{
       cout << "No" << endl;
   }
  }


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

int main(){
 int n;
 cin >> n;
 int l[n];
 for(int j=0;j<n;++j){
  cin >> l[j];
 }
 for(int i=n-1;i>=1;--i){
  cout << l[i] << " ";
 }
 cout << l[0] << endl;
 return 0;
}

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

using namespace std;

//#define FILE_IO

typedef long long LL;

int N, M;
int bp, nbp, one, sz;
bool bip;
vector <int> edg[100005];
bitset <100005> vis;
int par[100005];

void DFS(int nod, int pr)
{
    if(vis[nod])
    {
        if(pr != par[nod])  bip = 0;
        return;
    }

    vis[nod] = 1;
    sz++;
    par[nod] = pr;
    for(auto nxt: edg[nod])
        DFS(nxt, pr ^ 1);
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    cin >> N >> M;
    for(int i = 1; i <= M; i++)
    {
        int x, y;
        cin >> x >> y;
        edg[x].push_back(y);
        edg[y].push_back(x);
    }

    for(int i = 1; i <= N; i++)
        if(!vis[i])
        {
            sz = 0;
            bip = 1;
            DFS(i, 0);

            if(sz == 1)     one++;
            else if(bip)    bp++;
            else            nbp++;
        }

    LL ansone = 1LL * one * one + 2LL * one * (N - one);
    LL ansbip = 2LL * bp * bp + 1LL * nbp * nbp + 2LL * bp * nbp;
    LL ans = ansone + ansbip;
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 9088
#include <iostream>
#include <stdlib.h>

using namespace std;

int n;
int a[100001];
long long f[100005];


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i=1;i<=n;i++)
        cin >> a[i];
    f[1]=0;
    f[2]=abs(a[1]-a[2]);
    for (int i=3;i<=n;i++){
        f[i] = min(f[i-1]+abs(a[i]-a[i-1]),f[i-2]+abs(a[i]-a[i-2]));
    }
    cout << f[n] ;
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = cos(-1.0);
const double eps = 1e-10;
#define For(i,n,m) for(int i=n;i<=m;++i)

int main() {
	ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
	ll e = 1e9 + 7;
	ll nn, kk;
	cin >> nn >> kk;
	ll ans(0);
	for (ll i = kk; i <= nn; ++i) {
		ll res = (((2 * nn - i + 1)*i/2 - (i - 1) * i / 2 + 1) % e + e) % e;
		ans = ((ans + res) % e + e) % e;
	}
	cout << (ans + 1)%e << "\n";
	
	
	
}

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

using namespace std;

int main()
{
	for(string s1,s2;cin>>s1>>s2;){
		int len1=s1.length(),len2=s2.length();
		int lcslen=0;
		for(int i=-len2+1;i<len2;i++){
			int cnt=0;
			for(int j=max(0,-i);j<min(len1,len2-i);j++){
				if(s1[j]==s2[i+j])	cnt++;
				else	lcslen=max(lcslen,cnt),cnt=0;
			}
			lcslen=max(lcslen,cnt);
		}
		cout<<lcslen<<endl;
	}

	return 0;
}

Measured memory_bytes: 932
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextLong()

  def factorize(n: Long): List[Long] = {
    if (n == 1) {
      Nil
    } else {
      var i = 2L
      var d = 0L
      while (i*i <= n && d == 0) {
        if (n % i == 0) d = i
        i += 1
      }
      if (d == 0) List(n) else d::factorize(n/d)
    }
  }

  val factorMap = factorize(n).groupBy(identity).view.mapValues(_.length).toMap
  val counts = factorMap.map{ case (p, k) =>
    var rest = k
    var e = 1
    var ans = 0
    while (e <= rest) {
      ans += 1
      rest -= e
      e += 1
    }
    ans
  }

  println(counts.sum)
}

Measured memory_bytes: 55816
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

inline int input() { int x; scanf("%d", &x); return x; }

const int maxn = 505;
int f[maxn], g[maxn];
int a[maxn][maxn];

void get(int l, int r) {
	/* debug("get %d %d\n", l, r); */
	int n = r - l + 1;
	if(n <= 2) {
		a[l][r] = f[n];
		return;
	}
	int mid = l + g[n] - 1;
	get(l, mid);
	get(mid + 1, r);
	for(int i = l; i <= mid; i ++)
		for(int j = mid + 1; j <= r; j ++)
			a[i][j] = f[n];
}

int main() {
	int n = input();
	f[1] = f[2] = 1;
	for(int i = 3; i <= n; i ++) {
		f[i] = 1000000000;
		for(int j = 1; j < i; j ++) {
			int v = std::max(f[j], f[i - j]) + 1;
			if(v < f[i]) {
				f[i] = v;
				g[i] = j;
			}
		}
	}

	/* for(int i = 1; i <= n; i ++) */
	/* 	debug("%d %d\n", f[i], g[i]); */

	get(1, n);
	for(int i = 1; i <= n; i ++) {
		for(int j = i + 1; j <= n; j ++)
			printf("%d ", a[i][j]);
		puts("");
	}
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
const double PI = acos(-1.0);
const long mod = 1000000007;

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

  int cnt = 0;
  for(int i = 0; i < 1000; i++) {
    int a[3] = {i/100, (i/10)%10, i%10}, process = 0;
    for(int j = 0; j < n; j++) {
      if(process <= 2 & a[process] == (int)(s[j]-'0')) process++;
    }
    if(process == 3) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3628
n,m=map(int,input().split())
d=[list((map(int,input().split()))) for _ in range(m)]
c=[list((map(int,input().split()))) for _ in range(n)]
x=[[0 for _ in range(m)] for _ in range(3)]

for i in range(n):
    for j in range(n):
        x[(i+j)%3][c[i][j]-1]+=1
res=[]
for c1 in range(m):
    for c2 in range(m):
        for c3 in range(m):
            if c1==c2 or c2==c3 or c1==c3:
                pass
            else:
                ans=0
                for i in range(m):
                    ans+=x[0][i]*d[i][c1]
                for i in range(m):
                    ans+=x[1][i]*d[i][c2]
                for i in range(m):
                    ans+=x[2][i]*d[i][c3]
                res.append(ans)
print(min(res))

Measured memory_bytes: 49244
n=int(input())
lim=10**18
ans=1
a = input().split(' ')
for i in range(0,n):
    if int(a[i])==0:
        ans=0
for i in range(0,n):
    if int(a[i])*ans>lim:
        ans=-1
        break
    else:
        ans*=int(a[i])
        
print(ans)

Measured memory_bytes: 19380
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;
typedef long long ll;


int main(){
    ll N; cin >> N;
    vector<ll> A(N), B(N), D;
    ll Asum=0, Bsum = 0;
    for(ll i = 0; i < N; i++) {cin >> A[i]; Asum+= A[i];}
    for(ll i = 0; i < N; i++) {cin >> B[i]; Bsum+= B[i];}
    ll d = Bsum - Asum;
    ll cnt=0;
    for(ll i = 0; i < N; i++){
        if(B[i] - A[i] > 0){
            ll tmp = (B[i] - A[i]) / 2 + (B[i] - A[i]) % 2;
            cnt += tmp;
        }
    }
    if(cnt > d) cout << "No" << endl;
    else cout << "Yes" << endl;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int n;
	cin >> n;
	vector<int> v(n);
	rep(i, n) cin >> v[i];
	cout << *min_element(all(v)) << " " << *max_element(all(v)) << " " << accumulate(all(v), 0LL) << endl;
}


Measured memory_bytes: 3228
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#define rep(i,x) for(int i=0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 10010010010;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
	if (a < b)swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}

int main() {
	ll N, K, X;
	cin >> N >> K >> X;
  cout << (N + K) * X / 2;
}

Measured memory_bytes: 256
def solve():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))

    sm = 0
    for a in A:
        sm = sm + a

    th = sm / (4 * m)
    cnt = 0
    for a in A:
        # print(a, th)
        if a >= th:
            cnt = cnt + 1

    if cnt >= m:
        print('Yes')
    else:
        print('No')



if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
#include<stdio.h>
int main() {
	int N, n[111], i;
	scanf("%d", &N);
	for (i = N; i >= 1; i--) {
		scanf("%d", &n[i]);
	}
	for (i = 1; i <= N; i++) {
		if (i == N)printf("%d\n", n[i]);
		else printf("%d ", n[i]);
	}
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n,k; cin >> n >> k;
  vi a(n); rep(i,n) cin >> a[i];
  rep(cnt,min(k,500)){
    vi imos(n+1);
    rep(i,n){
      imos[max(0,i-a[i])]++;
      imos[min(n,i+a[i]+1)]--;
    }
    rep(i,n) imos[i+1] += imos[i];
    rep(i,n) a[i] = imos[i];
  }
  rep(i,n) cout << a[i] << " ";
  cout << "\n";
  return 0;
}


Measured memory_bytes: 4912
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> D(N);
  for (int i = 0; i < N; i++) D[i]=0;
  int d;
  int m = 0;
  bool flg = false;
  for (int i = 0; i < N; i++){
    cin >> d;
    D[d]++;
    if (i==0 &&  d!=0) flg = true;
    m = max(m,d);
  }
  if (D[0]!=1 || flg){
    cout << 0;
  } else {
    flg = false;
    for (int i = 1; i < m; i++){
      if (D[i]==0) flg = true;
    }
    if (flg){
      cout << 0;
    } else {
      int p = 998244353;
      long long T = 1;
      for (int i = 1; i <= m; i++){
        for (int j = 0; j < D[i]; j++){
          T *= D[i-1];
          T %= p;
        }
      }
      cout << T;
    }
  }
}

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

int main() {
int N,M,X; cin >>N>>M>>X;
vector<int>A(M);
for(int &x : A)
{
  cin >> x;
}
auto LB =lower_bound(A.begin(), A.end(), X);
int left, right;
left= distance(A.begin(), LB);
right= M-left;
cout << min (left, right) << endl;


  return 0;
}

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

/*
int	gcd(int A, int B) {
	while (0!=B) {
		A %=B;
		swap(A, B);
	}
	return A;
}
*/

#define	MOD 1000000007

int	main() {
	int X, A, B;
	cin >>X >>A >>B;
	if (B<=A)
		cout <<"delicious" <<endl;
	else if (B<=A+X)
		cout <<"safe" <<endl;
	else
		cout <<"dangerous" <<endl;
	return 0;
}



Measured memory_bytes: 256
<?php
fscanf(STDIN, "%s", $string);


$length = strlen($string);

for($i = 0; $i<$length ; $i++){
    $count = substr_count($string, $string[$i]);

  	if($count > 1){
    	echo 'no';
      	return;
    } 
}

echo 'yes';

?>

Measured memory_bytes: 4856
#include<stdio.h>

int main(void)
{
   int a;
   int b[100];
   int i;
   
   scanf("%d", &a);
   
   for(i=1;i<=a;i++){
      scanf("%d", &b[i]);}
      
   for(i=a;i>=1;i--){
      printf("%d", b[i]);
   	if(i==1){
   		printf("\n");
   		break;}
	  printf(" ");}
      
   return 0;
}


Measured memory_bytes: 2092
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define F first
#define S second
#define int long long
#define lint long long
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define SET(x, val) memset(x, val, sizeof(x))
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 2e3 + 5, MOD1 = 1e9 + 7, MOD2 = 998244353;
const lint INF = 1e18;

int n, m, x, par[N], cost, ans=1, mult=1, cnt;
struct edge
{
    int u, v, w;
} e[N];
struct ejsrt
{
    bool operator()(const edge &a, const edge &b)
    {
        return a.w < b.w;
    }
};
void reset()
{
    for(int i = 1; i <= n; i++)
    {
        par[i]=i;
    }
    cost=0;
}
int fnd(int x)
{
    if(par[x]==x) return x;
    return par[x]=fnd(par[x]);
}
void uni(int u, int v)
{
    par[u]=v;
}
void span()
{
    for(int i = 0; i < m; i++)
    {
        if(fnd(e[i].u)==fnd(e[i].v)) continue;
        uni(fnd(e[i].u), fnd(e[i].v)); cost+=e[i].w;
    }
}
signed main()
{
    cin >> n >> m >> x;
    for(int i = 0; i < m; i++)
    {
        cin >> e[i].u >> e[i].v >> e[i].w;
    }
    sort(e, e+m, ejsrt());
    for(int i = 0; i < m; i++)
    {
        reset();
        uni(fnd(e[i].u), fnd(e[i].v)); cost+=e[i].w;
        span();
        if(cost>x) ans=(ans*2)%MOD1;
        else if(cost==x) mult=(mult*2)%MOD1;
        else cnt++;
    }
    if(mult==1)
    {
        cout << 0;
        return 0;
    }
    mult = (mult+MOD1-1)%MOD1;
    if(cnt!=0) ans=(ans*2)%MOD1;
    else mult = (mult+MOD1-1)%MOD1;
    ans = (ans*mult)%MOD1;
    cout << ans;
}

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

using namespace std;

int main()
{
    int h,w,n,cnt,x;
    cin>>h>>w>>n;
    x=n/max(h,w);
    if(n%max(h,w)!=0) cout<<x+1<<endl;
    else cout<<x<<endl;
}

Measured memory_bytes: 256
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
#define mod9 1000000009LL
#define mod7 1000000007LL
#define INF  1023456789LL
#define INF16 10000000000000000LL
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/
#define N 101010
void build(){

}
int n , m;
vector< int > g[ N ];
void init(){
  n = getint();
  m = getint(); while( m -- ){
    int ai = getint();
    int bi = getint();
    g[ ai ].push_back( bi );
    g[ bi ].push_back( ai );
  }
}
bool vst[ N ];
vector<int> res;
void go( int now ){
  res.push_back( now );
  vst[ now ] = true;
  for( int x : g[ now ] ){
    if( vst[ x ] ) continue;
    go( x );
    return;
  }
}
void solve(){
  res.push_back( 1 );
  vst[ 1 ] = true;
  go( g[ 1 ][ 0 ] );
  reverse( res.begin() , res.end() );
  for( int x : g[ 1 ] ){
    if( vst[ x ] ) continue;
    go( x );
    break;
  }
  printf( "%d\n" , (int)res.size() );
  for( size_t i = 0 ; i < res.size() ; i ++ )
    printf( "%d%c" , res[ i ] , " \n"[ i + 1 == res.size() ] );
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


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

int main() {
	string a, b; cin >> a >> b;
	if (a.size() > b.size()) cout << "GREATER";
	else if (a.size() < b.size())cout << "LESS";
	else {
		for (int i = 0; i < a.size(); i++) {
			if (a[i] - '0' > b[i] - '0')cout << "GREATER";
			else if (a[i] - '0' < b[i] - '0') cout << "LESS";
			else cout << "EQUAL";
			break;
		}
	}
	cout << endl;
	
	return 0;
}

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

int main(){
    int n,k;
    cin>>n>>k;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    vector<bool>b(n-k,false);
    for(int i=0;i<(n-k);i++){
        if(a[i+k]>a[i])b[i]=true;
    }
    for(int i=0;i<n-k;i++){
        if(b[i])cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

Measured memory_bytes: 4840
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define erep(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

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

  if(n == 0) {
    cout << 0 << endl;
    return 0;
  }

  string ans;
  while(n) {
    if(n % -2) {
      ans += "1";
      n--;
    }
    else ans += "0";
    n /= -2;
  }
  reverse(all(ans));
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 1000000000
int main(){
  int r,g,b,n;
  cin>>r>>g>>b>>n;
  int cnt=0;
  for(int i=0;i<=3000;i++){
    for(int j=0;j<=3000;j++){
      if(n-r*i-g*j>=0&&(n-r*i-g*j)%b==0)cnt++;
    }
  }
  cout<<cnt<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
 
  string s;
  cin >> s;
  
  if(s[5]=='0'&&(s[6]=='1' ||s[6]=='2'||s[6]=='3'||s[6]=='4')) cout << "Heisei" << endl;
  else cout << "TBD" << endl;
  
}

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

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

  vector<bool> check_ac(n+1, false);
  vector<int> count_wa(n+1, 0);
  while ( m-- > 0 ) {
    int p;
    string s;
    cin >> p >> s;
    if ( s == "AC" ) {
      check_ac[p] = true;
    }
    if ( s == "WA" ) {
      if ( !check_ac[p] ) { count_wa[p]++; }
    }
  }

  int ac = 0, wa = 0;
  for ( int i = 1; i <= n; i++ ) {
    if ( check_ac[i] ) {
      ac++;
      wa += count_wa[i];
    }
  }
  cout << ac << ' ' << wa << endl;
  return 0;
}


Measured memory_bytes: 3692
#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 gcd(int a, int b) {
    int r;
    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int main() {
    int K, a, b, c;
    ll sum = 0;
    cin >> K;
    for (int i = 1; i <= K; i++) {
        for (int j = 1; j <= K; j++) {
            for (int k = 1; k <= K; k++) {
                int tmp;
                a = i;
                b = j;
                c = k;
                if (a < b) {
                    tmp = a;
                    a = b;
                    b = tmp;
                }
                int q = gcd(a, b);
                if (c < q) {
                    tmp = c;
                    c = q;
                    q = tmp;
                }
                sum += gcd(c, q);
            }
        }
    }
    cout << sum << endl;
    return 0;
}

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

using namespace std;
typedef pair<long long, int> PII;
const long long INF = 1e15;
const int MAX = 1e5 + 5;
long long dis[MAX];
vector <PII> adj[MAX];

void dijkstra (int x) {
    priority_queue <PII, vector <PII>, greater<PII> > pq;
    PII p;
    int to, from;
    long long dist, dist1;
    dis[x] = 0;
    pq.push({0, x});
    while (!pq.empty()) {
        p = pq.top();
        pq.pop();
        from = p.second;
        dist = p.first;
        for (PII p1 : adj[from]) {
            to = p1.first;
            dist1 = p1.second;
            if (dis[to] > dist + dist1) {
                dis[to] = dist + dist1;
                pq.push({dis[to], to});
            }
        }
    }
}

int main(int argc, char* argv[])
{
    if(argc == 2 or argc == 3) freopen(argv[1], "r", stdin);
    if(argc == 3) freopen(argv[2], "w", stdout);
    ios::sync_with_stdio(false);
    int n, q, x, y, a, b, c, k;
    long long ans;
    cin >> n;
    for (int i = 1; i < n; i++) {
        cin >> a >> b >> c;
        adj[a].push_back({b, c});
        adj[b].push_back({a, c});
    }
    for (int i = 0; i <= n; i++) {
        dis[i] = INF;
    }
    cin >> q >> k;
    dijkstra(k);
    while (q--) {
        cin >> x >> y;
        ans = dis[x] + dis[y];
        cout << ans << endl;
    }
    return 0;
}


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

using namespace std;

const int MAXN = 18;
int a[1 << MAXN];
int ans[1 << MAXN];

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < (1 << n); i++)
    {
        cin >> a[i];
    }
    for (int i = 1; i < (1 << n); i++)
    {
        int big1 = a[0];
        int big2 = a[i];
        if (big1 < big2)
            swap(big1, big2);
        int sub = i & (i - 1);
        while (sub > 0)
        {
            int x = a[sub];
            if (x > big2)
            {
                big2 = x;
                if (big1 < big2)
                    swap(big1, big2);
            }
            sub = i & (sub - 1);
        }
        ans[i] = big1 + big2;
    }
    int t = ans[1];
    for (int i = 1; i < (1 << n); i++)
    {
        t = max(t, ans[i]);
        cout << t << "\n";
    }
    return 0;
}


Measured memory_bytes: 5120
#define ll long long
#define ffor(i,a,b) for (int i=(a);i<(b);i++)
#define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;

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

	int n,k,x,y;
	cin >> n;
	cin >> k;
	cin >> x;
	cin >> y;
	if(n < k) cout << n*x << endl;
	else cout << k*x + (n-k)*y << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int flag=0;
		
		int group[][];
		group = new int[3][];
		
		int first[] = {1,3,5,7,8,10,12};
		int second[] = {4,6,9,11,0,0,0};
		int third[]={2,0,0,0,0,0,0};
		
		group[0]=first;
		group[1]=second;
		group[2]=third;
		
		int i;
		int j;
		
		for (i = 0; i < 2; i++) {
			for(j=0; j<7; j++){
				if(a==group[i][j]||b==group[i][j]){
					flag=flag+1;
				}
			}
			if(flag==2){
				System.out.println("Yes");
				break;
			}
			if(flag==2){
				break;
			}
			flag=0;
		}
		if(flag==0){
			System.out.println("No");
		}
	}
}

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

int n;
int warp[10001];
char map[10001];

void solve(int pos, int& ans ,vector<int>& path){
	if( count( path.begin() , path.end() , pos ) ){
		ans++;
		for(vector<int>::iterator it = path.begin() ; it != path.end() ; ++it ){
			map[ *it ] = 1;
		}
		return ;
	}
	if( map[pos] == 0 ){
		path.push_back( pos );
		solve( warp[pos] , ans , path );
	}
}

int main(){

	while( cin >> n , n ){
		for(int y=0 ; y<n ; ++y ){
			for(int x=0 ; x<n ; ++x ){
				int mx,my;
				cin >> mx >> my;
				warp[y*n+x] = my*n + mx;
				map[y*n+x]  = 0;
			}
		}
		int ans = 0;
		for(int pos=0 ; pos<n*n ; ++pos ){
			if( map[pos] == 0 ){
				vector<int> path;
				solve( pos , ans , path );
			}
		}
		cout << ans << endl;
	}
}

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

using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef pair<ul, ul> P;

const int INF = 1e9;
const int MOD =1e9+7;
const ll LINF = 1e18;

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

    for(int i = 0; i < s.size(); i+=2){
        ans += s[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

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

    int n, m;
    cin >> n >> m;

    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 256
program pyramid
  implicit none
  integer :: n, x(100) = 0, y(100) = 0, h(100) = 0, i
  integer :: cx, cy, ch, mx, my, mh = -1
  read(*,*) n
  do i = 1, n
    read(*,*) x(i), y(i), h(i)
    if (mh < h(i)) then
      mx = x(i)
      my = y(i)
      mh = h(i)
    end if
  end do
  do cx = 0, 100
    do cy = 0, 100
      ch = mh+abs(mx-cx)+abs(my-cy)
      do i = 1, n
        if (max(ch-abs(cx-x(i))-abs(cy-y(i)),0) /= h(i)) goto 100
      end do
      write(*,'(i0,x,i0,x,i0)') cx, cy, ch
      stop
100 end do
  end do
end program pyramid

Measured memory_bytes: 768
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        for(int i = 0; i < N; i++){
            list.add(sc.nextInt());
        }
        Collections.sort(list);
        System.out.println(list.get(N / 2) - list.get((N / 2) - 1));
    }
}


Measured memory_bytes: 60272
//https://atcoder.jp/contests/agc020/tasks/agc020_b
//B - Ice Rink Game
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in");
    //std::ifstream in("./input.txt");
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll K; cin>>K;
    vector<ll> ak(K);
    for(auto&& a:ak){
        cin>>a;
    }
    //反対から
    ll min=2,max=3;
    //assert(ak.back()==2);
    if(ak.back()!=2){
        cout<<-1<<endl;
        return 0;
    }
    for(ll i=ak.size()-1;i>=0;--i){
        ll a=ak.at(i);
        ll lv = (min+a-1)/a;
        min = lv * a;
        ll rv = max / a;
        max = rv * a + a-1;
        if (min>max || min<=0|| max<=0){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<min<<" "<<max<<endl;
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
A = [int(a) for a in input().split()] + [10000]
B = [int(b) for b in input().split()]
C = [int(c) for c in input().split()]
ans = 0
for i,j in enumerate(A[:len(A)-1]):
    ans += B[i]
    if A[i+1] == j+1:
        ans += C[j-1]
        
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <utility>
#include <stdlib.h>

using namespace std;

struct SPoint{
  int x;
  int y;
  int t;
};

SPoint points[100001];

bool isOk(SPoint from, SPoint to){
  int time = to.t - from.t;
  int xtime = abs(to.x - from.x);
  int ytime = abs(to.y - from.y);
  if(xtime + ytime > time){
    return false;
  }
  time -= (xtime + ytime);
  return (time % 2 == 0);
}

int main(){
  int N;
  scanf("%d", &N);
  points[0].x = 0; points[0].y = 0; points[0].t = 0;
  for(int i=0; i < N; i++){
    scanf("%d %d %d", &points[i+1].t, &points[i+1].x, &points[i+1].y);
  }
  // N番まで使われている
  //  printf("%d %d %d\n", points[0].x, points[0].y, points[0].t);
  bool ok = true;
  for(int i=0; i < N; i++){
    // if(isOk(points[i], points[i+1])){
    //   printf("Y\n");
    // }else{
    //   printf("N\n");
    // }
    ok &= isOk(points[i], points[i+1]);
  }

  if(ok){
    printf("Yes\n");
  }else{
    printf("No\n");
  }

  return 0;
}



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

using namespace std;
bool check(vector<vector<bool>>B)
{
	for(int i=0;i<3;i++)
	{
		if(B[i][0]&&B[i][1]&&B[i][2])
			return true;
	}
	for(int i=0;i<3;i++)
	{
		if(B[0][i]&&B[1][i]&&B[2][i])
			return true;
	}
	if(B[0][0]&&B[1][1]&&B[2][2])
		return true;
	if(B[0][2]&&B[1][1]&&B[2][0])
		return true;

	return false;
}

int main()
{
	// int n;
	// cin>>n;
	// cout<<(n+1)/2<<endl;
	// return 0;

	vector<vector<int>>A(3,vector<int>(3));
	vector<vector<bool>>B(3,vector<bool>(3,false));
	for(int i=0;i<3;i++)
	{
		for(int j=0;j<3;j++)
		{
			int a;
			cin>>a;
			A[i][j]=a;
		}
	}

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

	for(int i=0;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			for(int k=0;k<3;k++)
			{
				if(A[j][k]==C[i])
				{
					B[j][k]=true;
					if(check(B))
					{
						cout<<"Yes"<<endl;
						return 0;
					}
				}
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
#define mi 600851475143

int main()
{FAST
ll n;
cin>>n;
ll a=n%10;
  if(a==2||a==4||a==5||a==7||a==9)
   cout<<"hon"<<"\n";
   if(a==0||a==1||a==6||a==8)
   cout<<"pon"<<"\n";
   if(a==3)
   cout<<"bon"<<"\n";

	
}

Measured memory_bytes: 3652
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>

#define rep(i,a,n) for(int i=a; i<n; i++)
typedef long long int ll;
const int MAXN = 110;
const ll MAXM = 55;

ll comb[MAXM][MAXM];
double ac[MAXN][MAXM];

int main() {
  rep(i,0,MAXM) comb[i][0] = 1;
  rep(i,1,MAXM) rep(j,1,i+1) comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
  
  int N, M, L;
  scanf("%d %d %d", &N, &M, &L);

  if (N == 0)
    return 1;

  std::vector<int> T(N), V(N);
  std::vector<double> P(N);
  for (int i=0; i<N; ++i) {
    int p;
    scanf("%d %d %d", &p, &T[i], &V[i]);
    P[i] = p / 100.0;
  }

  rep(i,0,N) rep(j,0,M+1) {
    double prev = (j ? ac[i][j-1] : 0);
    ac[i][j] = prev + comb[M][j] * pow(P[i], j) * pow(1-P[i], M-j);
  }

  rep(i,0,N) {
    double ans = 0;
    rep(j,0,M+1) {
      double cur = ac[i][j] - (j ? ac[i][j-1] : 0);
      double user_time = 1.0 * L / V[i] + T[i] * j;
      rep(x,0,N) {
        if(x == i) continue;
        bool flag = false;
        rep(y,0,M+1) {
          double rival_time = 1.0 * L / V[x] + T[x] * y;
          if(user_time < rival_time) {
            flag = true;
            double rival_prob = ac[x][M] - (y ? ac[x][y-1] : 0);
            cur *= rival_prob;
            // printf("user = (%d, %d), rival = (%d, %d), prob = %.12f\n", i+1, j, x+1, y, rival_prob);
            break;
          }
        }
        if(!flag) cur = 0;
      }
      ans += cur;
    }
    printf("%.12f\n", ans);
  }
  return 0;
}

Measured memory_bytes: 3056
def main(N, lst):
    L = []
    for i in range(len(lst)):
        target = lst[i]
        L.append({"id":i+1, "store":target[0], "point":int(target[1])})
    L.sort(key = lambda x:x["point"], reverse = True)
    L.sort(key = lambda x:x["store"])
    for i in range(len(L)):
        print(L[i]["id"])

N = int(input())
lst = list(list(map(str, input().split())) for _ in range(N))
main(N, lst)

Measured memory_bytes: 3064
package main

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

var sc = bufio.NewScanner(os.Stdin)

func maxScanTokenSize(size int) {
	buf := make([]byte, 0, size)
	sc.Buffer(buf, size)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextBytes() []byte {
	sc.Scan()
	return sc.Bytes()
}

func nextInt() int {
	s := nextString()
	i, _ := strconv.Atoi(s)
	return i
}

func scanTwoInts() (int, int) {
	var a, b int
	fmt.Scan(&a, &b)
	return a, b
}

func scanThreeInts() (int, int, int) {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	return a, b, c
}

func main() {
	// maxScanTokenSize(100000)
	// sc.Split(bufio.ScanWords)

	N := nextInt()

	max := 0
	ans := 0
	for i := 0; i < N; i++ {
		p := nextInt()
		ans += p
		if p > max {
			max = p
		}
	}
	ans -= max / 2
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
int main(){
  int N; std::cin >> N;
  std::vector<int>A(N),B;
  for(auto&e : A)
    std::cin >> e;
  B = A;
  std::sort(B.begin(),B.end(),std::greater<>());
  for(auto e : A){
    std:: cout << (e == B.front() ? B.at(1) : B.front()) << std:: endl;
  }
}

Measured memory_bytes: 3200
serial = [int(i) for i in '1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'.split(', ')]

num = int(input())

print(serial[num - 1])

Measured memory_bytes: 2940
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
ll mod = 1e9+7;
vector<ll>dp;
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int>a;
    rep(i,n){
        if(i<n-1 and s[i]==s[i+1]){
            a.push_back(2);
            i++;
        }else{
            a.push_back(1);
        }
    }
    n = (int)a.size();
    ll ans;
    if(a[0] == 2)ans = 6;
    else ans = 3;
    for(int i = 1; i < n; i++){
        if(a[i-1] == 2 and a[i] == 2){
            ans *= 3;
        }
        if(a[i-1] == 2 and a[i] == 1){
            ans *= 1;
        }
        if(a[i-1] == 1 and a[i] == 2){
            ans *= 2;
        }
        if(a[i-1] == 1 and a[i] == 1){
            ans *= 2;
        }
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
int d[3333];
int main()
{
	int num, kai;
	scanf("%d%d", &num, &kai);
	int r = 0;
	for (int i = 1; i <= num; i++)
	{
		for (int j = 1; j <= kai; j++)
		{
			if (i == (j / 10)*(j % 10))
			{
				if (j / 10 > 1 && j % 10 > 1)r++;
			}
		}
	}
	printf("%d\n", r);
}

Measured memory_bytes: 760
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int dm = 1 << 21;
char dn[dm], * di = dn;
inline void putint(int X) {
	if (X < 0) {
		*di++ = '-';
		X = -X;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

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


	int K, X, Y;
	scanf("%d", &K);
	scanf("%d", &X);
	scanf("%d", &Y);

	if (K == 1) {
		putint(X + Y);
		rep1(i, X) {
			putint(i);
			*di++ = '0';
			*di++ = '\n';
		}
		char cx[6];
		int ketax = 0;
		if (X == 0) {
			*cx = '0';
			ketax = 1;
		}
		while (X) {
			*(cx + ketax) = '0' + X % 10;
			X /= 10;
			ketax++;
		}
		rep1(i, Y) {
			for (int i = ketax - 1; i >= 0; i--)* di++ = (*(cx + i));
			*di++ = '\n';
			putint(i);
		}
		fwrite(dn, 1, di - dn, stdout);
		Would you please return 0;

	}

	vector<pair<int, int>> kotae;
	int m = abs(X) + abs(Y);
	int xpn, ypn;

	if (K % 2 == 0 && m % 2) {
		printf("-1");
		return 0;
	}
	while (m / K >= 2) {
		if (abs(X) < abs(Y)) {
			ypn = (Y >= 0) ? 1 : -1;
			kotae.pb(mp(0, ypn * K));
			Y -= ypn * K;
		}
		else {
			xpn = (X >= 0) ? 1 : -1;
			kotae.pb(mp(xpn * K, 0));
			X -= xpn * K;
		}
		m = abs(X) + abs(Y);
	}
	if (m == K) {
		kotae.pb(mp(X, Y));
	}
	else {
		if (m & 1) {
			if (abs(X) < abs(Y)) {
				ypn = (Y >= 0) ? 1 : -1;
				kotae.pb(mp(0, ypn * K));
				Y -= ypn * K;
			}
			else {
				xpn = (X >= 0) ? 1 : -1;
				kotae.pb(mp(xpn * K, 0));
				X -= xpn * K;
			}
		}

		int yorimiti = (2 * K - abs(X) - abs(Y)) / 2;
		if (abs(X) < abs(Y)) {
			xpn = (X >= 0) ? 1 : -1;
			ypn = (Y >= 0) ? 1 : -1;

			kotae.pb(mp(X + xpn * yorimiti, ypn * (K - abs(X + xpn * yorimiti))));
			Y -= ypn * (K - abs(X + xpn * yorimiti));
			X -= X + xpn * yorimiti;
			kotae.pb(mp(X, Y));
		}
		else {
			xpn = (X >= 0) ? 1 : -1;
			ypn = (Y >= 0) ? 1 : -1;
			kotae.pb(mp(xpn * (K - abs(Y + ypn * yorimiti)), Y + ypn * yorimiti));
			X -= xpn * (K - abs(Y + ypn * yorimiti));
			Y -= Y + ypn * yorimiti;
			kotae.pb(mp(X, Y));
		}
	}

	putint(kotae.size());
	int xp = 0, yp = 0;;
	rep(i, kotae.size()) {
		xp += kotae[i].first;
		yp += kotae[i].second;
		if (xp == 0) {
			*di++ = '0';
			*di++ = '\n';
		}
		else putint(xp);
		if (yp == 0) {
			*di++ = '0';
			*di++ = '\n';
		}
		else putint(yp);
	}

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
const int INF = 1e8;

int dp[1001];
bool dfs(VVI& G, VI& xs, int u, int p){
  for(int to: G[u]){
	if(to == p) continue;
	if(!dfs(G, xs, to, u))
	  return false;
  }

  int crt = 0, nxt = 1;
  VVI kp(2, VI(xs[u]+1, INF));
  kp[crt][0] = 0;
  for(int to: G[u]){
	if(to == p) continue;
	fill(ALL(kp[nxt]), INF);
	for(int w=xs[u];w>=xs[to];--w)
	  mini(kp[nxt][w], kp[crt][w-xs[to]] + dp[to]);

	for(int w=xs[u];w>=dp[to];--w)
	  mini(kp[nxt][w], kp[crt][w-dp[to]] + xs[to]);

	swap(crt, nxt);
  }

  dp[u] = INF;
  REP(i,xs[u]+1)
	mini(dp[u], kp[crt][i]);
  return (dp[u] < INF);
}

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

  int N;
  cin >> N;
  VVI G(N);
  REP(i,N-1){
	int u;
	cin >> u;
	--u;
	G[i+1].PB(u);
	G[u].PB(i+1);
  }

  VI xs(N);
  REP(i,N) cin >> xs[i];
  cout << (dfs(G, xs, 0, -1)?"POSSIBLE": "IMPOSSIBLE") << endl;

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
pair<int,int> work[200200];
int main()
{
	int N;
	cin>>N;
	for(int i=0;i<N;i++)
		cin>>work[i].second>>work[i].first;
	sort(work,work+N);
	int Time=0;
	for(int i=0;i<N;i++)
	{
		if(Time+work[i].second>work[i].first)
		{
			puts("No");
			return 0;
		}
		Time+=work[i].second;
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 1792
import scala.io.StdIn
object Main extends App {
  val N = StdIn.readLine().toInt
  var m = scala.collection.mutable.HashMap.empty[String, Long]

  (1 to N).foreach {
    i =>
      val s = StdIn.readLine().toString.sorted
      if (m.contains(s)) {
        m(s) = m(s) + 1L
      } else {
        m.update(s, 1L)
      }
  }
  println(m.values.map(n => n * (n-1L) / 2L).sum)
}


Measured memory_bytes: 50788