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

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

int threegcd(int x, int y, int z){
  int k=gcd(x,y);
  int l= gcd(k,z);
  return(l);
}

int main() {
  int K;
  cin >> K;    
  long ans=0;
  for(int i=1;i<(K+1); i++){
    for(int j=1; j<(K+1); j++){
      for(int m=1;m<(K+1); m++){
        
        ans = ans + threegcd(i,j,m); 
      }
    }
  }
  cout << ans << endl;
  
  return 0;
  
}
    

Measured memory_bytes: 3636
H, W, h, w = map(int, input().split())
if H % h == 0 and W % w == 0:
	print("No")
elif h == 1:
	print("Yes")
	coef = 999999999 // (w-1)
	plus, minus = coef, -coef * (w-1) - 1
	for _ in range(H):
		print(*[minus if j%w == 0 else plus for j in range(1, W+1)])
elif w == 1:
	print("Yes")
	coef = 999999999 // (h-1)
	plus, minus = coef, -coef * (h-1) - 1
	for i in range(1, H+1):
		print(*[minus if i%h == 0 else plus for _ in range(W)])
else:
	print("Yes")
	coef = min(999999999 // ((h-1) * (w-1)), 1000000000 // (h+w-1))
	plus, minus = coef * (h+w-1), -coef * (h-1) * (w-1) - 1
	for i in range(1, H+1):
		if i%h != 0:
			print(*[minus if j%w == 0 else plus for j in range(1, W+1)])
		else:
			print(*[minus for _ in range(W)])

Measured memory_bytes: 47324
#include <algorithm>
#include <cstdio>
using namespace std;

#define MAX_H (1410)
#define MAX_W (1410)

int tile[MAX_H][MAX_W];
int dp[MAX_H][MAX_W];
int H, W;

int main()
{
    scanf("%d %d", &H, &W);

    for ( int y = 0; y < H; y++ ) {
	for ( int x = 0; x < W; x++ ) {
	    scanf("%d", &tile[y][x]);
	}
    }

    int max_size = 0;
    
    for ( int y = 0; y < H; y++ ) {
	for ( int x = 0; x < W; x++ ) {
	    if ( tile[y][x] == 1 ) {
		dp[y][x] = 0;
	    }
	    else {
		if ( x == 0 || y == 0 ) {
		    dp[y][x] = 1;
		}
		else {
		    dp[y][x] = min( dp[y-1][x-1], min( dp[y-1][x], dp[y][x-1] ) ) + 1;
		}
		max_size = max( max_size, dp[y][x] );
	    }
	}
    }

    printf("%d\n", (max_size * max_size));

    return 0;
}

Measured memory_bytes: 16504
<?php
$nums = explode(' ', trim(fgets(STDIN)));
sort($nums);

if($nums[0] <= $nums[1] && $nums[1] == $nums[2])
{
    echo $nums[0] + (10 * $nums[1] + $nums[2]);
}
elseif($nums[0] == $nums[1] && $nums[1] < $nums[2])
{
    echo (10 * $nums[2] + $nums[1]) + $nums[0];
}
elseif($nums[0] < $nums[1] && $nums[1] < $nums[2])
{
    echo (10 * $nums[2] + $nums[1]) + $nums[0];
}

Measured memory_bytes: 3828
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 s = Math.min(a,b);
    int l = Math.max(a,b);
    for(int i=0;i<l;i++){
      System.out.print(s);
    }
    System.out.println();
  }
}


Measured memory_bytes: 21972
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
const int N=2e5+5;
int n;
map<string,int>m;
map<string,int>::iterator it;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin>>n;
	int mn=0;
	for(int i=0;i<n;i++){
		string str;
		cin>>str;
		m[str]++;
		mn=max(mn,m[str]);
	}
	for(it=m.begin();it!=m.end();it++){
		if((*it).second==mn){
			cout<<(*it).first<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 23808
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pl = pair<ll, ll>;
const ll INF = ll(1e18);
const ll mod = ll(1e9 + 7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rnfor(i,a,b) for(ll (i) = (b) - 1; (i) >= (a); --(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
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; }
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

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

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

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans % mod;
}

vector<ll> FactorialInv, Factorial;

void init_combination(ll MAX){
    Factorial.resize(MAX + 1);
    FactorialInv.resize(MAX + 1);
    Factorial[0] = 1;
    for(int i = 1; i <= MAX; i++){
        Factorial[i] = Factorial[i - 1] * i % mod;
    }
    FactorialInv[MAX] = power(Factorial[MAX], mod - 2);
    for(ll i = MAX - 1; i >= 0; i--) {
        FactorialInv[i] = FactorialInv[i+1] * (i+1) % mod;
    }
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    if(b < 0) return 0;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}


//modの値の確認をすること
int main(){
    ll n;
    cin >> n;
    vector<ll> a(26);
    priority_queue<pl> c;
    rep1(i, 26){
        ll a;
        cin >> a;
        c.push(make_pair(a, i));
    }
    rep0(i, n){
        pf(c.top().second);
        queue<pl> q;
        while (!c.empty()) {
            q.push(c.top());
            c.pop();
        }
        c.push(q.front());
        q.pop();
        while (!q.empty()) {
            c.push(make_pair(q.front().first * 2, q.front().second));
            q.pop();
        }
    }
    return 0;
}


Measured memory_bytes: 3636
from sys import stdin
import sys

data = []

N = int(stdin.readline().rstrip())
for i in range(0, N):
    data.append(stdin.readline().rstrip().split())

cur_t = 0
cur_x = 0
cur_y = 0

for i in range(0, len(data)):
    (next_t, next_x, next_y) = data[i]
    next_t = int(next_t)
    next_x = int(next_x)
    next_y = int(next_y)

    sub_t = next_t - cur_t
    sub_x = abs(next_x - cur_x)
    sub_y = abs(next_y - cur_y)

    if sub_t < sub_x + sub_y:
        print('No')
        sys.exit()

    if sub_t % 2 != (sub_x + sub_y)%2:
        print('No')
        sys.exit()

    cur_t = next_t
    cur_x = next_x
    cur_y = next_y

print('Yes')


Measured memory_bytes: 32148
#include <iostream>
#include <cstdio>
#include <queue>
#include <vector>
using namespace std;

#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
typedef pair<int,int> pii;
#define MAX_V 30
#define INF (1<<30)

struct edge{int to,cost;};
vector<edge> G[MAX_V],IN[MAX_V];
int d[MAX_V];
 
void dijkstra(int s,int V){
    priority_queue< pii,vector<pii>,greater<pii> > que;
    rep(i,V)d[i]=INF;
    d[s]=0;
    que.push(pii(0,s));
     
    while(que.size()){
        pii p=que.top();
        que.pop();
         
        int v=p.second;
        if(d[v]<p.first)continue;
         
        rep(i,G[v].size()){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(pii(d[e.to],e.to));
            }
        }
    }
}

int N,M;
int maze[100][100],tim[100][100];
int main(void){
	cin>>N>>M;
	while(M--){
		int a,b,c,f;
		scanf("%d,%d,%d,%d",&a,&b,&c,&f);
		edge e = {b,c},e1 = {a,f};
		IN[a].push_back( e);
		IN[b].push_back(e1);
	}

	int a,b,c,f;
	scanf("%d,%d,%d,%d",&a,&b,&c,&f);
	rep(i,N+1)G[i] = IN[i];
	dijkstra(a,N+1);
	int s = d[b];
	//cout<<d[b]<<endl;
	rep(i,N+1)G[i] = IN[i];

	dijkstra(b,N+1);
	s += d[a];
	//cout<<d[a]<<endl;
	cout<<c-f-s<<endl;

}

Measured memory_bytes: 1268
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned long long int uint64;
typedef long long int          int64;
 
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void get_N (int64 *n)
{
  (void)scanf("%lld", n);

  return;
}

void get_NK (int64 *n, int64 *k)
{
  
  (void)scanf("%lld %lld", n, k);

  return;
}

void get_N1234 (int64 *n1, int64 *n2, int64 *n3, int64 *n4)
{
  if (n2 == NULL) {
    (void)scanf("%lld", n1);
    return;
  }
  if (n3 == NULL) {
    (void)scanf("%lld %lld", n1, n2);
    return;
  }
  if (n4 == NULL) {
    (void)scanf("%lld %lld %lld", n1, n2, n3);
    return;
  }
  (void)scanf("%lld %lld %lld %lld", n1, n2, n3, n4);
  return;
}

static int cnt = 0;

void omit_LF (void)
{
  char c;
  
  cnt = scanf("%c", &c);
  return;
}

char *get_S (int64 n)
{
  char *buf;
  int  i;

  buf = (char *)malloc((size_t)(n * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  cnt = scanf("%s", buf);

  return buf;
}

char *get_SN (int64 max, int64 *size)
{
  char *buf;
  int  i;
  int  n;

  buf = (char *)malloc((size_t)(max * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  cnt = scanf("%s", buf);

  n = strlen(buf);

  *size = n;
  
  return buf;
}

int64 *get_NSeq (int64 n)
{
  int64 *buf;
  int64 i;

  buf = (int64 *)malloc((size_t)(n * sizeof(int64)));
  for (i=0; i<n; i++) {
    get_N(&buf[i]);
  }

  return buf;
}

typedef struct _tmp_t {
  int64    a;
  int64    b;
} tmp_t;

typedef int64 simple_t;

int compare_simple(const void *a, const void *b)
{
  simple_t *x;
  simple_t *y;

  x = (simple_t *)a;
  y = (simple_t *)b;

  if (x > y) return 1;
  if (y < x) return -1;

  return 0;
}
void qsort_simple (simple_t *array, int size)
{
  qsort(array, size, sizeof(simple_t), compare_simple);
}

int compare_a(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->a > y->a) return 1;
  if (x->a < y->a) return -1;

  return 0;
}

int compare_b(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->b > y->b) return 1;
  if (x->b < y->b) return -1;

  return 0;
}

void qsort_a (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_a);
}

void qsort_b (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_b);
}


int resolve1()
{
  int64 R;
  double pi=3.14159;
  double L;

  get_N(&R);

  L = pi*R*2;

  printf("%lf", L);
  return 0;
}

//
// a + b = X
// a*4 + b*2 = Y
//
// b = X - a
// a*4 + (X-a)*2 = Y
// a*4 + X*2 - a*2 = Y
// a*2 = Y - X*2
// a = (Y - X*2) / 2
//

int resolve2()
{
  int64  X,Y;
  int64  a, b;
  
  get_NK(&X, &Y);

  a = (Y - X*2) / 2;
  if (a < 0) {
    printf ("No");
    return 0;
  }
  b = X - a;
  if (b < 0) {
    printf ("No");
    return 0;
  }

  if ((a + b) != X) {
    printf ("No");
    return 0;
  }

  if ((a*4 + b*2) != Y) {
    printf ("No");
    return 0;
  }

  printf ("Yes");

  return 0;
}


int main()
{

  resolve2();
  
  return 0;
}



Measured memory_bytes: 1736
#include <iostream>
#include <math.h>
#include <algorithm>
#include <queue>
#include <map>
#include <list>
//#include <bits/stdc++.h>


using namespace std;

#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
typedef long long ll;

int main(){
    ll x;
    cin >> x;
    ll deposit = 100;
    ll year = 0;
    while(true) {
        deposit += deposit / 100 ;
        year++;
        if(deposit >= x) break; 
    }
    cout << year << endl;
    return 0;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int a, b;
	cin >> a >> b;
	int i;
	if (a > b)
	{
		for (i = 0; i < a; i++)
			cout << b;
	}
	else
	{
		for (i = 0; i < b; i++)
			cout << a;
	}
	cout << endl;
}

Measured memory_bytes: 3592
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.nextLine());
        int temp = N;
        int s = 0;
        while (temp >= 1) {
            s += temp % 10;
            temp /= 10;
        }
        if (N % s == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23892
MOD = 10**9 + 7
N, M = [int(x) for x in input().split()]
a = set()
for i in range(M):
    a.add(int(input()))

dp = [0]*(N + 1)
dp[0] = 1
for step in range(N):
    if not step in a:
        for width in [1, 2]:
            to = step + width
            if to <= N and not to in a:
                dp[to] = (dp[to] + dp[step]) % MOD

print(dp[N])

Measured memory_bytes: 11884
#include<stdio.h>
int main(void)
{
	int n,k;
	int a[100001];
	int i,j;
	int max;
	int s;
	
	scanf("%d %d",&n,&k);
	while(n!=0 && k!=0){
		s=0;
		for(i=0;i<n;i++){
			scanf("%d",&a[i]);
		}
		for(i=0;i<k;i++){
			s=s+a[i];
		}
		max=s;
		for(i=0;i<n-k;i++){
			s=s-a[i];
			s=s+a[i+k];
			if(max<s){
				max=s;
			}
		}
		printf("%d\n",max);
		scanf("%d %d",&n,&k);
	}
	return 0;
}

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

typedef long long ll;

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

    vector<ll> sum(N + 1);
    for (int i = 0; i < N; i++) {
        sum[i + 1] = sum[i] + A[i];
    }

    unordered_map<ll, ll> hash;
    for (ll n : sum) hash[n]++;

    ll res = 0;
    for (pair<ll, ll> p : hash) {
        res += p.second * (p.second - 1) / 2LL;
    }

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

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int>> A(H, vector<int>(W));
    vector<vector<int>> B(H, vector<int>(W));
    REP(h, H) {
        REP(w, W) {
            cin >> A[h][w];
        }
    }
    REP(h, H) {
        REP(w, W) {
            cin >> B[h][w];
        }
    }
    vector<vector<int>> C(H, vector<int>(W));
    REP(h, H) {
        REP(w, W) {
            C[h][w] = abs(A[h][w] - B[h][w]);
        }
    }

    int M = 6400;
    vector<vector<vector<bool>>> dp(H, vector<vector<bool>>(W, vector<bool>(M, 0)));
    dp[0][0][C[0][0]] = 1;
    FOR(w, 1, W) {
        REP(i, M) {
            if(dp[0][w - 1][i] && i + C[0][w] < M) {
                dp[0][w][i + C[0][w]] = 1;
            }
            if(dp[0][w - 1][i] && 0 <= i - C[0][w]) {
                dp[0][w][i - C[0][w]] = 1;
            }
            if(dp[0][w - 1][i] && 0 <= -i + C[0][w]) {
                dp[0][w][-i + C[0][w]] = 1;
            }
        }
    }
    FOR(h, 1, H) {
        REP(i, M) {
            if(dp[h - 1][0][i] && i + C[h][0] < M) {
                dp[h][0][i + C[h][0]] = 1;
            }
            if(dp[h - 1][0][i] && 0 <= i - C[h][0]) {
                dp[h][0][i - C[h][0]] = 1;
            }
            if(dp[h - 1][0][i] && 0 <= -i + C[h][0]) {
                dp[h][0][-i + C[h][0]] = 1;
            }
        }
    }
    FOR(h, 1, H) {
        FOR(w, 1, W) {
            REP(i, M) {
                if(dp[h][w - 1][i] && i + C[h][w] < M) {
                    dp[h][w][i + C[h][w]] = 1;
                }
                if(dp[h][w - 1][i] && 0 <= i - C[h][w]) {
                    dp[h][w][i - C[h][w]] = 1;
                }
                if(dp[h][w - 1][i] && 0 <= -i + C[h][w]) {
                    dp[h][w][-i + C[h][w]] = 1;
                }

                if(dp[h - 1][w][i] && i + C[h][w] < M) {
                    dp[h][w][i + C[h][w]] = 1;
                }
                if(dp[h - 1][w][i] && 0 <= i - C[h][w]) {
                    dp[h][w][i - C[h][w]] = 1;
                }
                if(dp[h - 1][w][i] && 0 <= -i + C[h][w]) {
                    dp[h][w][-i + C[h][w]] = 1;
                }
            }
        }
    }
    REP(i, M) {
        if(dp[H - 1][W - 1][i]) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}



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

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

Measured memory_bytes: 256
N,D,*xs=$<.read.split.map(&:to_i)
xs=xs.each_slice(D).to_a

ret = 0
N.times do |i|
    (i+1).upto(N-1) do |j|
        x = xs[i].zip(xs[j]).inject(0) {|s,yz|s+=(yz[0]-yz[1])**2}
        x = Math.sqrt(x)
        ret += 1 if x - x.to_i == 0
    end
end

puts ret


Measured memory_bytes: 1788
s = input()
t = input()
s_list = list(s)
t_list = list(t)
s_list.sort()
t_list.sort(reverse = True)
alphabets = [chr(i) for i in range(97, 97+26)]  # 大文字
numbers = [i for i in range(1, 27)]
dict1 = dict(zip(alphabets, numbers))
frag = False
for i in range(min(len(s_list),len(t_list))):
  if dict1[s_list[i]] < dict1[t_list[i]]:
    frag = True
    break
  elif dict1[s_list[i]] > dict1[t_list[i]]:
    break
  elif dict1[s_list[i]] == dict1[t_list[i]]:
    if i == min(len(s_list),len(t_list)) - 1 and len(s_list) < len(t_list):
      frag = True
      break
    else:
      continue
if frag:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int x, y, z;
	cin >> x >> y >> z;
	cout << z << " " <<  x << " " << y << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
s = []
for i in range(N):
    s.append(input())

M = int(input())
t = []
for i in range(M):
    t.append(input())

sum = 0
for i in range(N):
    temp = 0
    sample = s[i]
    for j in range(N):
        if sample == s[j]:
            temp += 1
    for k in range(M):
        if sample == t[k]:
            temp -= 1
    if temp > sum:
        sum = temp
print(sum)

Measured memory_bytes: 3064
n,p = list(map(int,input().split()))
S = input()

if p == 2 or p == 5:
  ans = 0
  for i,s in enumerate(S):
    if int(s)%p == 0:
      ans += i+1
  print(ans)
  exit()

def MS(i,s,pre):
  return (int(s)*i+pre)%p
 
M = [0]*p
M[0] = 1
i = 1
pre = 0
for s in S[::-1]:
  #pre = MS(i,int(s),pre)
  pre = pre + int(s)*i
  pre = pre%p
  M[pre] += 1
  i = i*10%p

ans = sum(map(lambda m:(m*(m-1))//2, M))
print(ans)



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

int main() {
    int N;
    cin >> N;
    int i;
    for(i = 0; i < N; i++){
        string S;
        cin >> S;
        if(S == "Y"){
            cout << "Four" << endl;
            i -= 1;
            break;
        }
    }
    if(i == N){
        cout << "Three" << endl;
    }
}

Measured memory_bytes: 3588
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int H, W, N;
    cin >> H >> W >> N;
    if (H > W) {
        cout << ((N + H - 1) / H) << "\n";
    } else {
        cout << ((N + W - 1) / W) << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(int i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 1e18
#define five 100005;
#define six 1000005;
#define prllclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
int main()
{
       int n;
       cin>>n;
       int a[n];
       arrin(a,n);
       int sum = 0;
       fri(i,1,n-1){
              if(a[i]>a[i-1] && a[i]>a[i+1]){continue;}
              if(a[i]<a[i-1] && a[i]<a[i+1]){continue;}
              sum++;
       }
       cout<<sum<<endl;
}


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

int main()
{
    int d,t,s;
    cin>>d>>t>>s;
    int sum;
    sum=s*t;
    if(sum < d){
        cout<<"No";
    }
    else{
        cout<<"Yes";
    }

    return 0;
}

Measured memory_bytes: 3644
'use strict'

const main = (input) => {
    input = input.split(' ').map(v => parseInt(v))
    const a = input[0]
    const b = input[1]
    const c = input[2]
    if(c >= a && c <= b){
        console.log('Yes')
    }else{
        console.log('No')
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 7372
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    string s;
    cin >> s;
    int mini = 1000;
    for (int i = 0; i < s.size() - 2; i++) {
        int j = (s.at(i) - '0') * 100 + (s.at(i + 1) - '0') * 10 + s.at(i + 2)- '0';
        j = abs(j - 753);
        mini = min(mini, j);
    }
    cout << mini << endl;
}

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

#define ll long long
#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)

//library----------------------------------------------


int main(){
    string n; cin>>n;
    rep(i,n.size()){
        if(n[i]=='1') n[i]='9';
        else if(n[i]=='9') n[i]='1';
    }
    printf("%s\n",n.c_str());
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
public class Main {
    private static boolean elapsed = false;
 
    private void solve(Scanner sc, PrintWriter out) {
        int a = sc.nextInt();   
        int b = sc.nextInt();
        int c = sc.nextInt();
 
        if (a + b == c || a + c == b || b + c == a) {
            out.println("Yes");
        } else {
            out.println("No");
        }
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();
 
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        new Main().solve(sc, out);
        out.flush();
 
        long G = System.currentTimeMillis();
        if (elapsed) {
            System.err.println((G - S) + "ms");
        }
    }
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

void solve() {
  string S;
  int Q;
  cin >> S >> Q;
  string head = "";
  string tail = "";
  int R = 0;
  for (int i = 0; i < Q; i++) {
    int T;
    cin >> T;
    if (T == 1) {
      R++;
      swap(head, tail);
    } else {
      int F;
      char C;
      cin >> F >> C;
      if (F == 1) {
        head = head + C;
      } else {
        tail = tail + C;
      }
    }
  }
  reverse(all(head));
  if (R % 2 == 1) {
    reverse(all(S));
  }
  cout << head;
  cout << S;
  cout << tail << endl;
}

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

  solve();

  return 0;
}


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

int main(){
    int N,A;
    cin >> N >> A;
  if(N%A > 0){  
    if(N/A == 0) cout << 1 <<endl;
    else cout << (N/A) +1 << endl;
  }
  else cout << N/A << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(){
	int S, A, B;
	scanf ("%d %d %d", &S, &A, &B);
	int SA= A-S;
	int SB= B-S;
	(SA<=0)? (SA*=-1) : (SA*=1);
	(SB<=0)? (SB*=-1) : (SB*=1);
	(SA>SB)? (printf("B\n")) : (printf("A\n"));
return 0;
}


Measured memory_bytes: 1576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG
int main(){
    int n;
    cin>>n;
    int a1[n];
    int a2[n];
    rep(i,n){
        cin>>a1[i];
    }
    rep(i,n){
        cin>>a2[i];
    }
//累積和作成
    int s1[n+1];
    int s2[n+1];
    s1[0]=0;
    s2[0]=0;
    rep1(i,n){
        s1[i]=s1[i-1]+a1[i-1];
        s2[i]=s2[i-1]+a2[i-1];
    }
int ans=0;
rep1(i,n){
    int sum;
    sum=s1[i]+(s2[n]-s2[i-1]);
    ans=max(ans,sum);
}
cout<<ans<<endl;


}

Measured memory_bytes: 3596
//       Author: Mostafa Mounir Shehab
 
#include <bits/stdc++.h>
using namespace std;
 
#define PI  3.14159265  // PI = acos(-1)
#define EPS (1e-10)
#define endl "\n"
#define SZ(v) (int)(v.size())
typedef long long ll;
typedef long double ld;
//template <class Type>
 
 
void Fast(){
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL);
}
 
inline int D(){
	int t;
	scanf("%d",&t);
	return t;
}
inline ll llD(){
	ll t;
	scanf("%lld",&t);
	return t;
}
 
 
ll MOD=1e9 + 7;
int OO=1e6;
const int N=1e6 + 5;
int arr[N];
bool visit[N];

ll len=3234566667;

ll n,m,k,cnt,SU,idx,MN,MX,T;
ll l,r,mid;
ll a,b,c,d;
vector<pair<int,int>> v;
vector<int> vec;
string str,s,t,ans;

set<ll> st;

int Solve(ll val,int last){
	
	

	return 0;
	
}

int main(){
	
	cin>>n>>m;
	
	n-=(n/m)*m;
	
	cout<<min(n,abs(n-m))<<endl;
	
	
	

}









Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
#define finn {cout<<"No"<<endl;return 0;}
#define finy {cout<<"Yes"<<endl;return 0;}
//template
//main
signed main(){
  int N;cin>>N;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  map<int,int> m;
  for(int i=0;i<N;i++)m[v[i]]++;
  if(m.size()>3)finn;
  if(m.size()==1){
    if(v[0]==0)finy
    else finn;
  }
  std::vector<int> w(3);
  int cnt=0;
  for(auto p:m)w[cnt++]=p.first;
  if(m.size()==3){
    if((w[0]^w[1])!=w[2])finn;
    for(auto p:m)if(p.second*3!=N)finn;
    finy;
  }
  if(m[0]*3!=N)finn;
  finy;
}


Measured memory_bytes: 5632
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T>vector<T> & cset(vector<T> &A,T e=T()){for(auto &I:A){I=e;} return A;}


ll cnt=0;

ll query(ll a,ll b){
    cnt++;
    cout<<"? "<<a<<" "<<b<<endl;
    ll ret;
    cin>>ret;
    return ret;
}

void answer(vector<ll> A){
    cout<<"!";
    for(int i=0;i<A.size();i++){
        cout<<" "<<A[i];
    }
    cout<<endl;
}


int main(){
    ll n,s,t;
    cin>>n>>s>>t;
    map<ll,ll> M;
    set<ll> used;
    M[0]=s;
    ll dist=query(s,t);
    M[dist]=t;
    used.insert(s);
    used.insert(t);
    for(int i=1;i<=n;i++){
        if(used.count(i)){continue;}
        ll ret=query(s,i);
        if(ret>=dist || M.count(ret)){continue;}
        auto I=M.lower_bound(ret);
        auto T=I; T--;
        ll f=query(T->S,i),s=query(i,I->S);
        if(f+s==(I->F)-(T->F)){
            used.insert(i);
            M[T->F+f]=i;
        }
    }
    vector<ll> ans;
    for(auto &I:M){ans.push_back(I.S);}
    answer(ans);
    assert(cnt<=5*n);
    
    
    
    return 0;
}



Measured memory_bytes: 4648
import sys

def main():

    # sys.stdin = open('input149b.txt')

    a, b, k = map(int, input().split())

    ra = max(0, a - k)
    ka = max(0, k - a) 
    rb = b
    if ka > 0:
        rb = max(0, rb - ka)

    print(str(ra) + ' ' + str(rb))

if __name__ == '__main__':
    main()


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

const int INF=1e18;

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

    int negativeCnt=0;
    int maxSum=0,minAbs=INF;
    for(int i=0;i<N;i++){
        maxSum+=abs(a[i]);
        minAbs=min(minAbs,abs(a[i]));
        if(a[i]<0){
            negativeCnt++;
        }
    }

    if(negativeCnt%2==0){
        cout<<maxSum<<endl;
    }else{
        cout<<maxSum-minAbs*2<<endl;
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;
const int MOD = 1000000007;
const double pi = acos(-1);

const int INF = 1e9 + 1;
vecveci Li(100010);
veci ma(100010,-1);

int main() {
    int N; cin >> N;
    veci A(N);
    REP(i,N) cin >> A[i];
    REP(i,N) {
        int l = -1, r = N;
        while(r-l > 1) {
            int mid = (r+l)/2;
            if(ma[mid] >= A[i]) l = mid;
            else r = mid;
        }
        Li[r].push_back(A[i]);
        ma[r] = A[i];
    }
    /*
    REP(i,N) {
        for(auto x : Li[i]) cout << x << " " ;
        cout << endl;
    }
    */
    int ans = 0;
    REP(i,100010) if(Li[i].size()) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 9512
import Control.Monad

area :: Num a => a -> a -> a
area a b = a * b

perimeter :: Num a => a -> a -> a
perimeter a b = (a * 2) + (b * 2)

main :: IO ()
main = do
  raw <- getLine
  let a = read . head . words $ raw
  let b = read . last . words $ raw
  putStr (show $ area a b)
  putStr " "
  putStrLn (show $ perimeter a b)

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    ll n, m;
    cin >> n >> m;
    ll res = 0;
    if (m >= 2 * n) {
        res += n;
        m -= 2 * n;
        res += m / 4;
        cout << res << endl;
    } else {
        cout << m / 2 << endl;
    }
    
    return 0;
}



Measured memory_bytes: 256
MOD = 1000000007
n,k = map(int,input().split())

comb = [[0]*(i+1) for i in range(n+2)]
comb[0][0] = 1
for i in range(1,n+1):
    for j in range(i+1):
        if j == 0 or j == i:
            comb[i][j] = 1
        else:
            comb[i][j] = comb[i-1][j-1]+comb[i-1][j]
for i in range(1,k+1):
    if k >= i and n-k >= i-1:
        print(comb[k-1][i-1] * comb[n-k+1][i] % MOD)
    else:
        print(0)

Measured memory_bytes: 435040
$dx = [0,1,0,-1]
$dy = [1,0,-1,0]
def bfs(f, sy, sx, steps, q, r, c)
    for i in 0..3
        cy = sy + $dy[i]
        cx = sx + $dx[i]
        if cy.between?(0,r-1) && cx.between?(0,c-1) && steps[cy][cx]==500 && f[cy][cx]!="#"
            q.push([cy,cx])
            steps[cy][cx] = steps[sy][sx] + 1
        end
    end
    while q.size > 0
        cy, cx = q.shift
        steps = bfs(f,cy,cx,steps,q,r,c)
    end
    return steps
end

loop do
    str = gets.split.map(&:to_i)
    if str.size != 2
        next
    end
    h = str[0]
    w = str[1]
    if h==0&&w==0
        exit
    end
    f = Array.new()
    a = Array.new()
    b = Array.new()
    h.times do |i|
        f[i] = gets.chomp
        if f[i].include?("A")
            a[0] = i
            a[1] = f[i].index("A")
        end
        if f[i].include?("B")
            b[0] = i
            b[1] = f[i].index("B")
        end
    end
    steps = Array.new(h).map{Array.new(w,500)}
    steps[a[0]][a[1]] = 0
    q = Array.new()
    steps = bfs(f,a[0],a[1],steps,q,h,w)
    pat = gets.chomp
    cs = 0
    cby = b[0]
    cbx = b[1]
    min = Array.new(3,500)
    loop do
        pat.each_char do |c|
            cs += 1
            case c
            when '5'
                if steps[cby][cbx] > cs
                    next
                end
                if [steps[cby][cbx],cs].max < min[0]
                    min[1] = cby
                    min[2] = cbx
                    min[0] = [steps[cby][cbx],cs].max
                end
            when '8'
                if cby > 0
                    cby -= 1
                end
                if steps[cby][cbx] > cs
                    next
                end
                if [steps[cby][cbx],cs].max < min[0]
                    min[1] = cby
                    min[2] = cbx
                    min[0] = [steps[cby][cbx],cs].max
                end
            when '6'
                if cbx < w-1
                    cbx += 1
                end
                if steps[cby][cbx] > cs
                    next
                end
                if [steps[cby][cbx],cs].max < min[0]
                    min[1] = cby
                    min[2] = cbx
                    min[0] = [steps[cby][cbx],cs].max
                end
            when '4'
                if cbx > 0
                    cbx -= 1
                end
                if steps[cby][cbx] > cs
                    next
                end
                if [steps[cby][cbx],cs].max < min[0]
                    min[1] = cby
                    min[2] = cbx
                    min[0] = [steps[cby][cbx],cs].max
                end
            when '2'
                if cby < h-1
                    cby += 1
                end
                if steps[cby][cbx] > cs
                    next
                end
                if [steps[cby][cbx],cs].max < min[0]
                    min[1] = cby
                    min[2] = cbx
                    min[0] = [steps[cby][cbx],cs].max
                end
            end
        end
        if cs > h*w*pat.length
            break
        end
    end
    puts min[0]==500 ?  "impossible" : min * " "
end

Measured memory_bytes: 6196
#include <stdio.h>
#include <algorithm>

const int N = 1024;
const int M = 16384;

int idx[N], wei[N], str[N], val[N];
long long dp[M];

bool comp(int p, int q)
{
	//return std::min(str[p]-wei[q], str[q]) > std::min(str[q]-wei[p], wei[p]);
	return str[p]-wei[q] > str[q]-wei[p];
}

int main()
{
	int n, i, j, cur, nxt, mx;
	long long ans;
	while (scanf("%d", &n) == 1)
	{
		for (i=0; i<n; i++)
		{
			idx[i] = i;
			scanf("%d%d%d", &wei[i], &str[i], &val[i]);
		}
		std::sort(idx, idx+n, comp);
		mx = -1;
		ans = -1;
		for (i=1; i<=n; i++)
		{
			cur = idx[i-1];
			//printf(".. %d\n", cur);
			for (j=wei[cur]; j<=mx; j++)
			{
				nxt = std::min(j-wei[cur], str[cur]);
				if (dp[j] != -1 && dp[nxt] < dp[j] + val[cur])
				{
					dp[nxt] = dp[j] + val[cur];
					if (ans < dp[nxt])
					{
						ans = dp[nxt];
					}
				}
			}
			if (dp[str[cur]] < val[cur])
			{
				dp[str[cur]] = val[cur];
				for (mx++; mx<str[cur]; mx++)
				{
					dp[mx] = -1;
				}
				if (ans < dp[str[cur]])
				{
					ans = dp[str[cur]];
				}
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ph push
#define ptc putchar
#define enter putchar('\n')
#define mod 998244353
using namespace std;
typedef pair<int,int> pii;
typedef double db;
typedef long double ldb;
typedef long long ll;
typedef long long lnt;
inline int read(){
	int x = 0;char c = getchar();
	while (!isdigit(c)) c = getchar();
	while (isdigit(c)) x = (x << 1) + (x << 3) + c - '0' , c = getchar();
	return x;
}
inline void write(int x){
	if (!x){
       ptc('0');
       return;
	}
	int dg[20] , len = 0;
	while (x) dg[len++] = x % 10 , x /= 10;
	while (len--) ptc(dg[len]+'0');
}
inline void writeln(int x){
	write(x);
	ptc('\n');
}
inline int add(int x,int y){
	x += y;if (x >= mod) x -= mod;
	return x;
}
inline int sub(int x,int y){
	x -= y;if (x < 0) x += mod;
	return x;
}
inline int qpow(int x,int y){
	int res = 1;
	while (y){
		if (y & 1) res = 1ll * res * x % mod;
		x = 1ll * x * x % mod;y >>= 1;
	}
	return res;
}

const int N = 1e5 + 10;
int n , a[N];

int main(){
	cin >> n;
	for (int i = 1;i <= n;i++){
		cin >> a[i];
	}
	int answer = 0;
	for (int i = 1;i <= n;i++){
		int j = i;while(j + 1 <= n && a[j + 1] == a[i]) j++;
		answer += (j - i + 1) >> 1;
		i = j;
	}
	cout<<answer;
	
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <list>
#include <numeric>
using namespace std;

long long combi(long long n, long long k) {
  if (n == k || k == 0)
    return 1;
  else {
    return combi(n - 1, k - 1) + combi(n - 1, k);
  }
}

long long gcd(int a, int b){
  if (a%b == 0){
    return(b);
  }
  else{
    return(gcd(b, a%b));
  }
}

int main(){
  string S,T;
  cin >> S >> T;
  int count=0;

  for(int i=0;i<S.length();i++){
    if(S[i] != T[i]){
      count++;
    }
  }
  
  cout << count << endl;
}
 


Measured memory_bytes: 3912
import std.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.array;
import std.conv;
import std.math;
import std.typecons;
import std.regex;
import std.range;

void main(){

    while(true){
    int[] list;
    auto s1 = readln();
    int n = s1.chomp().to!int;
    if(n == 0) break;
    for(int i=0;i<n;i++){
	int t = readln().chomp().to!int;
	list ~= t;
    }
    list.sort();
    long ans;
    for(int i=1;i<n;i++){
	int s = to!int(list.length);
	ans += list[i-1] * (s-i);
    }
    writeln(ans);
    }

}

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

int n;
vector<int> g[100000];
vector<int> path;

bool search(int cur, int dst, int parent) {
  if (cur == dst) {
    return true;
  }
  for (auto to: g[cur]) {
    if (to == parent) {
      continue;
    }
    bool result = search(to, dst, cur);
    if (result) {
      if (parent != -1) {
        path.push_back(cur);
      }
      return true;
    }
  }
  return false;
}
int main() {
  cin>>n;
  for (int i=0; i<n-1; i++) {
    int a, b;
    cin>>a>>b;
    --a;
    --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  search(0, n-1, -1);
  reverse(path.begin(), path.end());
  int color[n];
  for (int i=0; i<n; i++) color[i] = 0;
  color[0] = 1;
  color[n-1] = -1;
  for (int i=0; i<path.size(); i++) {
    if (i <= (path.size() - 1)/ 2) {
      color[path[i]] = 1;
    } else {
      color[path[i]] = -1;
    }
  }
  for (int i=0; i<n; i++) {
    if (color[i] == 0) {
      continue;
    }
    int c = color[i];
    queue<int> q;
    q.push(i);
    while (!q.empty()) {
      int node = q.front();
      q.pop();
      for (auto to: g[node]) {
        if (color[to] == 0) {
          color[to] = c;
          q.push(to);
        }
      }
    }
  }
  int sum = 0;
  for (int i=0; i<n; i++) sum += color[i];
  if (sum > 0) {
    cout<<"Fennec"<<endl;
  } else {
    cout<<"Snuke"<<endl;
  }
}

Measured memory_bytes: 12668
import java.util.*;
import java.io.*;
import java.math.*;

public class Main{
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    Long[] a = Arrays.stream(in.readLine().split(" ")).map(Long::parseLong).toArray(Long[]::new);
    long[] res = new long[n];
    int last = (int)(1.0*n/2);
    for(int i=0;i<n;i++){
      res[last+(i%2==0?1:-1)*i] = a[i];
      last+=(i%2==0?1:-1)*i;
    }
    if(n%2==0){
      for(int i=0;i<n;i++){
        System.out.print(res[i]);
        System.out.print(" ");
      }
    }else{
      for(int i=n-1;i>=0;i--){
        System.out.print(res[i]);
        System.out.print(" ");
      }
    }
    System.out.println();
  }
}


Measured memory_bytes: 79968
import re

H,W = map(int,input().split())
arr = []

for i in range(H):
  S = list(map(int,input().replace("#","0").replace(".","1")))
  arr.append(S)

ANS = [[] for _ in range(H)]
for i in range(H):
  for j in range(W):
    if j == 0:
      ans = arr[i][j]
    elif arr[i][j-1] == 0:
      ans = arr[i][j]
    else:
      ans = ans + 1
    ANS[i].append(ans)

for i in range(H):
  for j in range(W):
    if j == 0:
      ans = arr[i][W-1-j]
    elif arr[i][W-j] == 0:
      ans = arr[i][W-1-j]
    else:
      ans = ans + 1
    ANS[i][W-1-j] += ans

for j in range(W):
  for i in range(H):
    if i == 0:
      ans = arr[i][j]
    elif arr[i-1][j] == 0:
      ans = arr[i][j]
    else:
      ans = ans + 1
    ANS[i][j] += ans

for j in range(W):
  for i in range(H):
    if i == 0:
      ans = arr[H-1-i][j]
    elif arr[H-i][j] == 0:
      ans = arr[H-1-i][j]
    else:
      ans = ans + 1
    ANS[H-1-i][j] += ans

    
    
ans = []
for j in range(W):
  for i in range(H):
    if arr[i][j] != 0:
      a = ANS[i][j] - 3
      ans.append(a)
print(int(max(ans)))

Measured memory_bytes: 231160
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main implements Runnable {
    public static void main(String[] args) {
        new Thread(null,new Main(), "" ,Runtime.getRuntime().maxMemory()).start();
    }

    public void run() {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int[] ans = new int[n];
        for(int i = 0;i < n - 1;i++) ans[sc.nextInt() - 1]++;
        
        Arrays.stream(ans).forEachOrdered(System.out::println);
    }

}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 57756
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int koma[] = new int[n];
		for(int i = 0; i < n; i++) {
			koma[i] = sc.nextInt();
		}

		int m = sc.nextInt();
		for(int i = 0; i < m; i++) {
			int command = sc.nextInt();
			if(command == n) {
				if(koma[command - 1] != 2019) koma[command - 1]++;
			}
			else if(koma[command - 1] + 1 != koma[command]) {
				koma[command - 1]++;
			}
		}

		for(int i = 0; i < n; i++) System.out.println(koma[i]);
	}

}



Measured memory_bytes: 26528