akhauriyash/Code-Regression huggingface dataset:
import scala.io.StdIn.{readInt, readLine};
object Main {
    def main(args: Array[String]): Unit = {
        val n = readInt;
        val g = new Graph(n);
        (0 until n).foreach { i => 
            readLine.split(" ").map(_.toInt).toList match {
                case src :: d :: dst => g.add(src, dst);
                case _ => ()
            }
        }
        g.depthFirstSearch.zipWithIndex.foreach { e => e match {
                case ((d, f), idx) => println("%d %d %d".format(idx + 1, d, f));
            }
        }
    }
}
class Graph(n: Int) {
    val size = n + 1;
    val matrix = Array.ofDim[Int](size, size);
    def add(src: Int, dsts: Seq[Int]): Unit = if (src > 0 && src < size) {
        dsts.foreach { d => if (d > 0 && d < size) matrix(src)(d) = 1};
    }
    def dump(): Unit = matrix.slice(1, size).foreach { a => println(a.slice(1, size).mkString(" "))}
    def depthFirstSearch(): Array[(Int, Int)] = {
        val status = new Array[(Int, Int)](size);
        def go(curr: Int, t1: Int): Int = {
            if (curr >= size) {
                t1;
            } else {
                status(curr) = (t1, -1);
                val t2 = 1 + (1 until size).foldLeft(t1) { (t, i) => 
                    if (matrix(curr)(i) == 1 && status(i) == null) go(i, t + 1) else t;
                };
                status(curr) = (t1, t2);
                t2;
            }
        } 
        (1 until size).foldLeft(0) { (time, i) => 
            if (status(i) == null) go(i, time + 1)else time;
        }
        status.slice(1, size);
    }
}


Measured memory_bytes: 44924
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
using namespace std;
int main() {
	long long a, b;
	cin >> a >> b;
	if ((a + b) % 2 == 0) {
		cout << (a + b) / 2 << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

int main(){
    string s;
    cin >> s;
    rep(i,s.size()){
        if(i%2==0){
            if(s[i]=='R'||s[i]=='U'||s[i]=='D'){

            }else{
                cout << "No" << endl;
                return 0;
            }
        }else{
            
            if(s[i]=='L'||s[i]=='U'||s[i]=='D'){

            }else{
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  /*  while(x->left != NIL){
    x = x->left;
  }
  return x;
  */
}

Node treeMaximum(Node x){
 /* while(x->right != NIL){
    x = x->right; 
  }
  return x;
 */}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key)return u;
  if(k < u->key)return treeSearch(u->left,k);
  else return treeSearch(u->right,k);
}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else
      x = x->right;
  }
  z->parent = y;

  if(y == NIL){
    root = z;
  }
  else if(z->key < y->key){
    y->left = z;
  }
  else
    y->right = z;
}

void inorder(Node u){

  if(u != NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){

  if(u != NIL){
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20464
object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val _ = readLine
    val datA = readLine.split(" ").map(_.toLong)

    def judgement(acc: (Long, Long), cur: (Long, Long)): (Long, Long) = {
      val sum = acc._1
      val count = acc._2
      val a = cur._1
      if (sum > 0) {
        if (sum + a >= 0) (-1, count + math.abs(sum + a) + 1)
        else (sum + a, count)
      }
      else { // (sum < 0)
        if (sum + a <= 0) (1, count + math.abs(sum + a) + 1)
        else (sum + a, count)
      } // not care for sum == 0
    }

    val posA = datA.tail.map(a => (a, 0L)).foldLeft(
      if (datA.head == 0) (1L, 1L)
      else (datA.head, 0L)
    ){ judgement(_, _) }
    val negA = datA.tail.map(a => (a, 0L)).foldLeft(
      if (datA.head == 0) (-1L, 1L)
      else (if(datA.head > 0) -1L else 1L, math.abs(datA.head) + 1)
    ){ judgement(_, _) }

    val ans = math.min(posA._2, negA._2)
    println(ans)
  }
}

Measured memory_bytes: 55004
#include <iostream>
#include <vector>
using namespace std;
using ll = long long ;

int main()
{
    int k;
    cin >> k;
    vector<ll> a;
    for(int i=1; i<= 9; ++i) a.push_back(i);
    while(1){
        if(k<=a.size()){
            cout << a[k-1] << endl;
            return 0;
        }
        k -= a.size();
        
        vector<ll> old;
        swap(old,a);
        for(ll x : old){
            for(int i=-1; i<=1; ++i){
            int d = x%10 + i;
            if(d < 0 || d > 9) continue;
            ll nx = x*10 +d;
            a.push_back(nx);
            }

        }
    }

    return 0;
}

Measured memory_bytes: 1712
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <list>
#include <string.h>
#include <functional>
#include <unordered_set>
#define rep(i, n) for(int i = 0; i < n; i++)
//#include <Windows.h>
//#include "Library.h"
//#include "Math.h"
using namespace std;
typedef long long int ll; typedef pair <int, int> P; typedef vector <int> vecint;
const int INF = 100000000000;
const double EPS = 10e-9;
int main()
{
	int n; cin >> n;
	ll prev = 2, prev1 = 1;
	if (n == 0) cout << 2 << endl;
	else if (n == 1) cout << 1 << endl;
	else
	{
		rep(i, n - 1)
		{
			ll tmp = prev + prev1;
			prev = prev1;
			prev1 = tmp;
		}
		cout << prev1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

using namespace std;
typedef long long llong;

#define MAX 100001

int main()
{
  int N, Q;
  llong a, b, c;
  llong A[MAX], ans = 0;
  scanf("%d", &N);

  for (int i = 0; i < MAX; i++)
  {
    A[i] = 0;
  }

  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &a);
    A[a]++;
    ans += a;
  }
  scanf("%d", &Q);

  llong tmp = 0;
  for (int i = 0; i < Q; i++)
  {
    scanf("%lld", &b);
    scanf("%lld", &c);
    tmp = A[b];
    A[c] += tmp;
    A[b] = 0;
    ans = ans - b * tmp + c * tmp;
    printf("%lld\n", ans);
  }

  return 0;
}

Measured memory_bytes: 2512
s = input()
t= input()
len_t = len(t)
len_s = len(s)

ans = len_t
for i in  range(len_s - len_t+1):
    s_sub = s[i:len_t + i]
    ans  = min(ans, len([... for i in range(len_t) if t[i] != s_sub[i]]))
print(ans)

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

int main() {
    ll N;
    cin >> N;
    ll t=1;
    while(t*(t-1) < 2*N){
        t++;
    }
    if(t*(t-1) != 2*N){
        cout <<"No" << endl;
        return 0;
    }
    cout <<"Yes" << endl;
    cout <<t <<endl;
    vector<vector<ll>> ans(t);
    ll num =1;
    for(int i=0;i<t;i++){
        for(int j=(i+1);j<t;j++){
            ans[i].push_back(num);
            ans[j].push_back(num);
            num++;
        }
    }
    for(int i=0;i<t;i++){
        cout << ans[i].size() <<" ";
        for(int a:ans[i]){
            cout << a <<" ";
        }
        cout <<endl;
    }

    return 0;
}

Measured memory_bytes: 3200
#!/usr/bin/env python3
import sys

NO = "IMPOSSIBLE"  # type: str


def solve(A: int, B: int):
    K = (A + B)/2
    if K % 1 == 0:
        print(int(K))
    else:
        print('IMPOSSIBLE')
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
H1, M1, H2, M2, K = map(int, input().split())

# 10:00->15:00
# 10:00->12:00

# 起きている時間を計算する（単位分

import datetime

def get_waking_time(H,I,J,K):
    d1 = datetime.datetime(year=2020, month=5, day=30, hour=H, minute=I, microsecond=0)
    d2 = datetime.datetime(year=2020, month=5, day=30, hour=J, minute=K, microsecond=0)
    delta = d2 -d1
    return delta.seconds/60


print(int(get_waking_time(H1,M1,H2,M2)-K))

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

int main() {
  string S;
  cin >> S;
  int ans = 0;
  for(int i = 0; i < S.size(); ++i) {
    if(S[i] == '+') {
      ans++;
    } else {
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}

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

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

    int costs[n+1];
    costs[1]=0;
    costs[0]=0;
    costs[2] = abs(arr[1] - arr[0]);

    for(int i=3; i<=n; i++){
        int option1= costs[i-1] + abs(arr[i-1] - arr[i-2]);
        int option2 = costs[i-2] + abs(arr[i-1] - arr[i-3]);
        //cout << option1 << ' ' << option2 << endl;
        costs[i] = min(option1, option2);
        //cout << costs[i] << endl;
    }

    cout << costs[n] << endl;
}


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

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

AB = [tuple(map(int, input().split())) for i in range(M)]

graph = [[] for _ in range(N)]

for a, b in AB:
  a, b = a-1, b-1
  graph[a].append(b)
  graph[b].append(a)

  ans = 0

for i, h in enumerate(H):
  flag = True
  for to in graph[i]:
    if H[i] > H[to]:
      continue
    else:
      flag = False
    
  if flag:
    ans += 1
  
print(ans)

Measured memory_bytes: 42976
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n,k; cin>>n>>k;
    vector<ll> v(n);
    rep(i,n) cin>>v[i];

    ll ans = 0;
    for (int l = 0; l <= k; ++l) {
        for (int r = 0; r <= k-l; ++r) {
            if (l+r>n) continue;
            int del = k-l-r;
            vector<ll> tmp;
            for (int i = 0; i < min(l,n); ++i) {
                tmp.push_back(v[i]);
            }
            int ri = min(n-l,r);
            for (int i = n-1; i >= max(0,n-ri); --i) {
                tmp.push_back(v[i]);
            }
            sort(tmp.begin(), tmp.end());
            ll ret = 0;
            rep(i,tmp.size()) {
                if (tmp[i]<0) {
                    if (del>0) {
                        --del;
                        continue;
                    }
                }
                ret += tmp[i];
            }
            chmax(ans,ret);
        }
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
//
//AtCoder Beginner Contest 179
//A
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>
#include <numeric>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    if (s[s.size()-1]=='s') cout << s + "es" << endl;
    else cout << s + "s" << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define eps 1e-8
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

int N,W;
int val[101],weight[101];
int dp[101][100001];

int f(int i,int v){//min weight with val v up till index (i,N-1)
    if(i==N && v==0)return 0;
    if(i==N && v!=0)return INT_MAX;
    if(v<0)return INT_MAX;
    if(dp[i][v]!=-1)return dp[i][v];
    
    int a=weight[i]+f(i+1,v-val[i]);
    int b=f(i+1,v);
    
    return dp[i][v]=min(a,b);
}

signed main(){
    FASTER;
    memset(dp,-1,sizeof dp);
    cin>>N>>W;
    for(int i=0;i<N;i++)cin>>weight[i]>>val[i];
    
    int ans=0;
    for(int vall=100000;vall>=0;vall--){
        if(f(0,vall)<=W){
            ans=vall;
            break;
        }
    }
    cout<<ans;
}



Measured memory_bytes: 79232
#include<iostream>

using namespace std;

int main(){
  int rot, ans = 0;
  bool flag = false;
  
  cin >> rot;
  
  while(!flag){
    ans++;
    if(rot*ans%360 == 0)
      flag = true;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int INF = 100100101;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  vector<int> a(5);
  int mini = INF;
  int sum = 0;
  int itr;
  rep(i,5) {
    cin >> a[i];
    if(a[i]%10 != 0 && a[i]%10 < mini){
      mini = a[i]%10;
      itr = i;
    }
  }
  rep(i,5){
    if(i != itr){
      sum+=ceil(double(a[i]/10.0))*10;
    }
    else{
      sum+=a[i];
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size() 
#define UB upper_bound
#define LB lower_bound
#define BP(x) __builtin_popcountll(x)
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int getRand(int l, int r) {
   uniform_int_distribution<int> uid(l, r);
   return uid(rng);
}

const int INF = 1e18 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;

void solve() {
   int n, xr = 0; cin >> n;
   int data[n+5];
   for(int i = 1; i <= n; i++) {
      cin >> data[i];
      xr ^= data[i];
   }
   int ans[n+5];
   for(int i = 1; i <= n; i++) {
     ans[i] = data[i] ^ xr;
     cout << ans[i] << " ";
   }
}

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

  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif
   int t = 1;  //cin >> t;
   for(int i = 1; i <= t; i++) {
      solve();
  }
}    


Measured memory_bytes: 6668
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

int h,w;
string s[110];


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

    cin>>h>>w;
    rep(i,h) cin>>s[i];

    int dp[h][w];
    rep(i,h)rep(j,w) dp[i][j]=INF;
    dp[0][0]=(s[0][0]=='#');
    rep(i,h){
        rep(j,w){
            if(i!=0){
                int pl;
                if(s[i-1][j]=='.' and s[i][j]=='#') pl=1;
                else pl=0;
                chmin(dp[i][j],dp[i-1][j]+pl);
            }
            if(j!=0){
                int pl;
                if(s[i][j-1]=='.' and s[i][j]=='#') pl=1;
                else pl=0;
                chmin(dp[i][j],dp[i][j-1]+pl);
            }
        }
    }
    cout<<dp[h-1][w-1]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>
#include<utility>

#define P 1000000007

using namespace std;

int main() {
  string s;
  cin >> s;
  bool b = false;
  for(int i = 0; i < s.size()/2; i++) {
    if(s[i] != s[s.size() - 1 - i]) b = true;
  }
  if(b) cout << "No" << endl;
  else cout << "Yes" << 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);
    String N = sc.next();
    if (N.charAt(0) == '7' || N.charAt(1) == '7' || N.charAt(2) == '7' ) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 26844
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    unused_imports,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::{fastout, input, marker::*};
//use std::collections::HashSet;
use std::collections::*;
//use std::collections::BTreeMap;
//use std::cmp::*;
//use std::num;
//use petgraph::unionfind::UnionFind;

#[fastout()]
fn main() {
    input! {
        N:usize, mut S:[String;N]
    }
    S.sort();
    //println!("{:?}", S);
    let emptystring = "".to_string();
    let mut m = HashMap::new();
    let mut set = BTreeSet::new();
    //let S: Vec<String> = S.iter().map(|s| s.iter().collect::<String>()).collect();
    let mut max = 0;
    for i in 0..N {
        *m.entry(S[i].clone()).or_insert(0) += 1;
        let k = *m.get(&S[i]).unwrap();
        max = std::cmp::max(max, k);
        set.insert(&S[i]);
    }
    for s in set {
        //        let s = S[i];
        if *m.get(s).unwrap() == max {
            println!("{}", s.to_string());
        }
    }
}


Measured memory_bytes: 33616
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			//出力の都度更新をやめる
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);


			Ans();

			//更新する
			Console.Out.Flush();
			
		}

      
      public static void Ans() {

			var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
			var NumArray = retreiveLongArray();

			var isOdd = N % 2 == 1;

			if (isOdd) {
				if (NumArray.Where(x =>x==0).Count()!=1) {
					Console.WriteLine(0);
					return;
				}
			}


			var pairNum = N / 2;
	
			var toujou = Enumerable.Repeat(0, (int)N + 1).ToArray();
			//成立する並びかチェック
			for (int i = 0; i < N; i++) {
				var num = NumArray[i];
				toujou[num]++;
			}
			var count = isOdd ? 2 : 1;
			for (int i = 0; i < pairNum; i++) {
				if (toujou[count] !=2) {
					Console.WriteLine(0);
					return;
				}
				count += 2;
			}

			//答えの出力
			long ans = 1;

			for (int i = 0; i < pairNum; i++) {
				ans *= 2;
				ans %= _mod;
			}

			Console.WriteLine(ans);

		}

		private static long _mod = 1000000000 + 7;
		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}


Measured memory_bytes: 36768
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			
			double[][] cost = new double[n][n];
			for(int i=0;i<n;i++){
				Arrays.fill(cost[i], Integer.MAX_VALUE);
				cost[i][i] = 0;
			}
			
			int[] id = new int[n];
			int[] x = new int[n];
			int[] y = new int[n];
			double p;
			for(int i=0;i<n;i++){
				id[i] = sc.nextInt();
				x[i] = sc.nextInt();
				y[i] = sc.nextInt();
				for(int j=i-1;j>=0;j--){
					p = Math.sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]));
					if(p<=50){
						cost[i][j] = p;
						cost[j][i] = p;
					}
				}
			}

			
			int m = sc.nextInt();
			int s = -1;
			int g = -1;
			for(int z=0;z<m;z++){
				int ins = sc.nextInt();
				int ing = sc.nextInt();
				for(int i=0;i<n;i++){
					if(id[i]==ins) s = i;
					if(id[i]==ing) g = i;
				}
				
				ArrayDeque<Integer> que = new ArrayDeque<Integer>();
				int[] path = new int[n];
				Arrays.fill(path, -1);
				double[] min = new double[n];
				Arrays.fill(min, Integer.MAX_VALUE);
				que.offer(s);
				min[s] = 0;
				while(que.size()!=0){
					int q = que.poll();
					for(int i=0;i<n;i++){
						if(cost[i][q]!=Integer.MAX_VALUE && min[i] > min[q] + cost[i][q]){
							min[i] = min[q] + cost[i][q];
							path[i] = q;
							que.offer(i);
						}
					}
				}
				
				LinkedList<Integer> list = new LinkedList<Integer>();

				int h;
				boolean flag = false;
				while(g!=s){
					if(g==-1){
						flag = true;
						break;
					}
					list.push(path[g]);
					h = path[g];
					g = h;
				}
				if(flag==true) System.out.println("NA");
				else{
					while(list.size()!=0)  System.out.print(id[list.pollFirst()] + " ");
					System.out.println(ing);
				}
			}
		}	
	}	
}

Measured memory_bytes: 19012
line = input()
count = 0
S = []
mojisuu = len(line)

for i in range(mojisuu):
    S.append(line[i])

if mojisuu % 2 == 0:
    for j in range(int(mojisuu/2)):
        if S[j] != S[j*(-1)-1]:
            count += 1


else:
    for k in range(int((mojisuu - 1)/2)):
        if S[k] != S[k*(-1)-1]:
            count += 1

print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);
using namespace std;

const int N=100005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x=(x+y)%mod;}
inline void read(int &x){
	x=0;char ch=getchar(),rev=0;
	while(ch>'9'||ch<'0') rev=(ch=='-'),ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	x=rev?-x:x;
}
inline int exp(int x,int y){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

int n,a,b,c,d;

int main(){
#ifdef rqgao2014
	freopen("input.txt","r",stdin);
#endif
	scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
	for(int i=1;i<n;i++){
		ll L=(ll)a+(ll)(n-i)*c-(ll)d*(i-1),R=(ll)a+(ll)(n-i)*d-(ll)c*(i-1);
		if(L<=b&&R>=b){puts("YES");return 0;}
	}
	puts("NO");
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using static System.Console;

namespace b {
static class Extensions {
   public static int ToInt(this string str) {
      return int.Parse(str);
   }

   public static int[] readIntArr() {
      return ReadLine().Split(' ').Select(int.Parse).ToArray();
   }
}

class Program {
   static bool couldBeMonth(int a) {
      return a != 0 && a <= 12;
   }

   public static void Main(string[] args) {
      var tmp = ReadLine();

      var upper = tmp.Substring(0, 2).ToInt();
      var lower = tmp.Substring(2, 2).ToInt();

      if (couldBeMonth(upper) && couldBeMonth(lower)) {
         WriteLine("AMBIGUOUS");
      }
      else if (couldBeMonth(upper)) {
         WriteLine("MMYY");
      }
      else if (couldBeMonth(lower)) {
         WriteLine("YYMM");
      }
      else {
         WriteLine("NA");
      }

   }
}

}


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

int main()
{
    // input
    int n, w;
    cin >> n >> w;
    vector<int> weights(n+1);
    vector<ll> values (n+1);

    rep(i, n){
        cin >> weights[i+1];// weight
        cin >> values[i+1]; // values
    }


    // dp
    vector<vector<ll>> dp (n+1, vector<ll>(w+1));
    rep(m,w+1){
        dp[0][m] = 0;
    }

    rep(i, n){
        rep(m, w+1){
            if(weights[i+1] > m) dp[i+1][m] = dp[i][m];
            else dp[i+1][m] = max(dp[i][m], dp[i][m-weights[i+1]] + values[i+1]);
        }
    }
    
    cout << dp[n][w] << endl;
    return 0;
}

Measured memory_bytes: 80256
/*
    When you are not practicing someone else is,
    and the day u meet them u will Lose.

    So, all you need is Practice, Practice and Practice.
*/
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,a,b)       for(i=a;i<=b;i++)
#define FOR(i,a,b)      for(i=a;i>=b;i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define sz(v)           (int)v.size()
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p) {int ans=1;x%=mod;while(p>0){if(p&1)ans=(ans*x)%mod;p=p>>1;x=(x*x)%mod;}return ans;}
int inv(int x){return po(x,mod-2)%mod;}
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
/**********************************************************************************/



const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r,f,q;








void sol()
{   
    cin>>n;
   
    int mx1=-inf,mx2=-inf,mn1=inf,mn2=inf;

    fo(i,n)
    {
        cin>>x>>y;
        mx1=max(mx1,x+y);
        mn1=min(mn1,x+y);
        mx2=max(mx2,x-y);
        mn2=min(mn2,x-y);
    }
    cout<<max(mx1-mn1,mx2-mn2);
    
    
}





int32_t main()
{   
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //pre();
    //sp(10);
    // w(t)
    sol();
    return 0;
}


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

long long v, e,  a[105][105], b[105][105], s, t, d, inf = 1e18;

int main(){
	for( int i = 0 ; i < 104 ; i++ ){
		for( int j = 0 ; j < 104 ; j++ ){
			a[i][j] = inf;
			if( i == j ) a[i][j] = 0;
		}
	}
	cin >> v >> e;
	
	for( int i = 0 ; i < e ; i++ ){
		cin >> s >> t >> d;
		a[s][t] = d;
	}
	
	for( int k = 0 ; k < v ; k++ ){
		for( int i = 0 ; i < v ; i++ ){
			for( int j = 0 ; j < v ; j++ ){
				a[i][j] = min( a[i][j], a[i][k] + a[k][j] );
			}
		}
	}
	
	for( int i = 0 ; i < v ; i++  ){
		for( int j = 0 ; j < v ; j++ ){
			b[i][j] = a[i][j];
		}
	}
	
	for( int k = 0 ; k < v ; k++ ){
		for( int i = 0 ; i < v ; i++ ){
			for( int j = 0 ; j < v ; j++ ){
				b[i][j] = min( b[i][j], b[i][k] + b[k][j] );
			}
		}
	}
	
	for( int i = 0 ; i < v ; i++  ){
		for( int j = 0 ; j < v ; j++ ){
			if( a[i][j] != b[i][j] ){
				cout << "NEGATIVE CYCLE" << endl;
				exit(0);
			}			 
		}
	}
		
	for( int i = 0 ; i < v ; i++  ){
		for( int j = 0 ; j < v ; j++ ){
			if( j != 0 ) cout << ' ';
			if( a[i][j] > 2e9 ) cout << "INF";
			else cout << a[i][j]; 
		}
		cout << endl;
	}
}



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

signed main(){
    int x; cin >> x;
    int ans = 0;

    int val = 100;

    while (val < x) {
        val += val / 100;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

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

signed main(){
  int N;
  cin>>N;
  int A[4];
  rep(i,4)A[i]=0;
  rep(i,N){
    char H;
    cin>>H;
    if(H=='G')A[0]+=1;
    if(H=='W')A[1]+=1;
    if(H=='P')A[2]+=1;
    if(H=='Y')A[3]+=1;
  }
  int ans=0;
  rep(i,4){
    if(A[i]>0)ans+=1;
  }
  if(ans==4)cout<<"Four"<<endl;
  else cout<<"Three"<<endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000LL;
constexpr auto MOD = 1000000007;

int main() {

	int n, m;
	cin >> n >> m;
	vvi e(3*n);
	rep(i, m) {
		int u, v;
		cin >> u >> v;
		u--;v--;
		rep(j, 3)e[j * n + u].push_back(((j + 1) % 3) * n + v);
	}
	int s, t;
	cin >> s >> t;
	s--;t--;

	vi dist(3 * n, INF);
	dist[s] = 0;
	queue<int> q;
	q.push(s);
	while (!q.empty()) {
		int v = q.front();q.pop();
		for (auto vv : e[v]) {
			if (dist[vv] < INF)continue;
			dist[vv] = dist[v] + 1;
			q.push(vv);
		}
	}

	if (dist[t] == INF)dist[t] = -3;
	cout << dist[t] / 3 << endl;
}

Measured memory_bytes: 17792
#include<stdio.h>
#include<math.h>

int main(void){
  int n;
  int i;
  double buf;
  double ary_x[100];
  double ary_y[100];
  double dis[4]={0};

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%lf",&ary_x[i]);
  }
  for(i=0;i<n;i++){
    scanf("%lf",&ary_y[i]);
  }

  /* p=1 の処理 */
  for(i=0;i<n;i++){
    buf = ary_x[i] - ary_y[i];
    if(buf<0){
      buf = (-1) * buf;
    }
    dis[0] += buf;
  }

  /* p=2 の処理 */
  for(i=0;i<n;i++){
    buf = pow((ary_x[i] - ary_y[i]),2);
    dis[1] += buf;
  }
  dis[1] = sqrt(dis[1]);

  
  /* p=3 の処理 */
  for(i=0;i<n;i++){
    buf = pow((ary_x[i] - ary_y[i]),3);
    if(buf<0){
      buf = (-1) * buf;
    }
    dis[2] += buf;
  }
  dis[2] = cbrt(dis[2]);

  
  /* p=∞ の処理 */
  for(i=0;i<n;i++){
    buf = (ary_x[i] - ary_y[i]);
    if(buf<0){
      buf = (-1) * buf;
    }
    if(buf>dis[3]){
      dis[3] = buf;
    }
  }

  
  for(i=0;i<4;i++){
    printf("%f\n",dis[i]);
  }
  
  return 0;
}

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

int main(){

    int n;
    cin>>n;
    for(int a=1;a<=9;a++)
      for(int b=1;b<=9;b++){
        if(a*b==n){
        cout<<"Yes";
        return 0;
        }
    }   
    cout<<"No";
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(int x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

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

int isPrime(int x) {
  int i;
  if (x < 2) return 0;
  else if (x == 2) return 1;

  if (x % 2 == 0) return 0;
  for (i = 3; i*i <= x; i += 2) {
    if (x % i == 0) return 0;
  }
  return 1;
};

static const int MAX = 100005;

bool check(int x) {
  if (x % 2 == 0) {
    return false;
  }
  return (isPrime(x) && isPrime((x+1)/2));
};

int main() {
  int Q;
  cin >> Q;
  int l, r;

  vector<int> A;

  rep(i, 1, MAX) {
    if (check(i)) {
      A.pb(i);
    }
  }

  rep(i, 0, Q) {
    cin >> l >> r;
    int llidx = lbidx(A, l);
    int rlbidx = lbidx(A, r);
    int dis = rlbidx - llidx;
    if (r == A[rlbidx]) {
      dis++;
    }

    cout << max(0, dis) << endl;
  }

  return 0;
};


Measured memory_bytes: 640
while True:
    n = int(input())
    if n == 0:
        break

    ans = [0,0,0,0,0,0,0]
    for l in range(n):
        a = int(input())
        a = a // 10
        if a > 6:
            a = 6
        ans[a] += 1

    for i in range(7):
        print(ans[i])


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

using namespace std;
const int INF=1e9+5;
int main(){
	string s,t;
	cin>>s>>t;
	int n=s.length();
	int m=t.length();
	vector<vector<int>> dp(n+1,vector<int>(m+1));
	for(int i=0;i<n+1;i++){
		for(int j=0;j<m+1;j++){
			if(i==0 || j==0){
				dp[i][j]=0;}
			else if(s[i-1]==t[j-1]) {
				dp[i][j]=1+dp[i-1][j-1];
				//cout<<s[i-1];
				}
			else{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}}
		   int index = dp[n][m]; 
			char lcs[index+1]; 
			lcs[index] = '\0';
   int i = n, j = m; 
   while (i > 0 && j > 0) 
   { 
      if (s[i-1] == t[j-1]) 
      { 
          lcs[index-1] = s[i-1];  
          i--; j--; index--;     
      } 
      else if (dp[i-1][j] > dp[i][j-1]) 
         i--; 
      else
         j--; 
   } 
  
   // Print the lcs 
   cout << lcs<<endl;;  
		//cout<<dp[n][m];
		
				
}

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

using namespace std;
vector<vector<int> >mtx,mtx3;
vector<int>vis;
int cnt=0;
int n;
void dfs(int i,int j,int tr,long long ttl=0ll){
    cnt++;
    vis[i]=1;
    if(ttl==(long long)mtx[j][i])
        mtx3[j][i]++;
    else{
        vis[i]=0;
        return ;
    }
    for(int k=0;k<n;k++){
        if(!vis[k]){
            dfs(k,j,tr,ttl+(long long)mtx[i][k]);
        }
    }
    vis[i]=0;
}
int main()
{
    ///{}
    ios_base::sync_with_stdio(0);
    cin.tie(0);  cout.tie(0);
    cin>>n;
    mtx=vector<vector<int> >(n,vector<int>(n));
    mtx3=mtx;
    long long ans=0ll;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>mtx[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=i;j<n;j++){
            ans+=(long long)mtx[i][j];
        }
    }
    vector<vector<int> >mtx2=mtx;
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                mtx2[i][j]=min(mtx2[i][j],mtx2[i][k]+mtx2[k][j]);
            }
        }
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(mtx2[i][j]!=mtx[i][j]||mtx[i][j]!=mtx[j][i]){
                cout<<-1<<'\n';
                return 0;
            }
        }
    }

    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                if(k==j||k==i)
                    continue;
                if(mtx[i][k]+mtx[k][j]==mtx[i][j]&&mtx3[i][j]==0){
                    ans-=(long long)mtx[i][j];
                    mtx3[i][j]=1;
                }
            }
        }
    }

    cout<<ans<<'\n';

    return 0;
}
/**
10
0 1 1 1 1 1 1 1 1 1
1 0 1 1 1 1 1 1 1 1
1 1 0 1 1 1 1 1 1 1
1 1 1 0 1 1 1 1 1 1
1 1 1 1 0 1 1 1 1 1
1 1 1 1 1 0 1 1 1 1
1 1 1 1 1 1 0 1 1 1
1 1 1 1 1 1 1 0 1 1
1 1 1 1 1 1 1 1 0 1
1 1 1 1 1 1 1 1 1 0
*/


Measured memory_bytes: 4276
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<class T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<class T>inline auto vec2(class vector<T>::size_type h,class vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
template<class RandomAccessIterator>inline void psortb(RandomAccessIterator first,RandomAccessIterator last){using P=pair<decltype(first->first),decltype(first->second)>;sort(first,last,[](const P&p1,const P&p2){return p1.second<p2.second||(p1.second==p2.second&&p1.first<p2.first);});}

int main()
{
    ll n=in();
    ll x=0;
    vector<ll>a(n);for(ll i=0;i<n;++i)x^=a[i]=in();
    for(ll i=0;i<n;++i){
        if(i)cout<<' ';
        cout<<(x^a[i]);
    }
    cout<<endl;
}


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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(int i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const ll powll = 1LL<<1;

int main(void){
    int n,a,b; cin >>n >> a >> b;
    cout << min(b,a*n) << "\n";
}

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

using namespace std;

int32_t main() {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    long long n;

    cin >> n;

    long long h;

    cin >> h;

    cout << ceil(n/(long double)h) << '\n';

    return 0;

}



Measured memory_bytes: 3780
import numpy as np
N=int(input())
A = [int(i) for i in input().split()]
A = np.array(A)
sumA=sum(A)
indexA = np.arange(0,N,2)
firstx = sum(A[indexA]) - sumA//2
xlist = [firstx]
for i in range(1,N):
  xlist.append(A[i-1]-xlist[i-1])
  
ans = np.array(xlist)*2
for i in ans:
	print(i)

Measured memory_bytes: 23124
#include <cstdio>
#include <vector>
#include <algorithm>

int main() {
  size_t H, W, N;
  scanf("%zu %zu %zu", &H, &W, &N);

  std::vector<int> cc;
  cc.reserve(H*W);
  for (size_t i = 1; i <= N; ++i) {
    int a;
    scanf("%d", &a);
    for (int j = 0; j < a; ++j)
      cc.push_back(i);
  }
  
  std::vector<std::vector<int>> res(H, std::vector<int>(W));
  for (size_t i = 0; i < H; ++i) {
    if (i % 2 == 0) {
      for (size_t j = 0; j < W; ++j)
        res[i][j] = cc[i*W+j];
    } else {
      for (size_t j = W; j--;)
        res[i][j] = cc[i*W+W-j-1];
    }
  }

  for (size_t i = 0; i < H; ++i)
    for (size_t j = 0; j < W; ++j)
      printf("%d%c", res[i][j], j+1<W? ' ':'\n');
}


Measured memory_bytes: 384
k, t = map(int, input().split())
a = [int(_) for _ in input().split()]

if t == 1:
    print(k-1)
else:
    a.sort(reverse=True)
    num = a[0] - 1
    cnt = 0
    for i in range(1, t):
        cnt += a[i]
    print(max(num-cnt, 0))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  string S;cin>>S;
  vector<int> sum(N+1,0);//#の個数
  for(int i=1;i<N+1;i++)sum[i]=(S[i-1]=='#')+sum[i-1];
  int min=N;
  for(int i=0;i<N+1;i++){
    int tmp=sum[i]+(N-i)-(sum[N]-sum[i]);
    if(tmp<min)min=tmp;
  }
  cout<<min;
}

Measured memory_bytes: 1412
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define INF 1e9
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    string divs[4] = {"dream", "dreamer", "erase", "eraser"};
    string s; cin >> s;
    rep(i,4) reverse(ALL(divs[i]));
    reverse(ALL(s));
    bool can = true;
    for(int i = 0; i < s.size();){
        bool can2 = false;
        rep(j,4){
            string str = divs[j];
            if(s.substr(i,str.size())==str){
                can2 = true;
                i += str.size();
            }
        }
        if(can2 == false){
            can = false;
            break;
        }
    }
    if(can) cout << "YES" << endl;
    else cout << "NO" << endl;
 

    return 0;
}

Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Scanner;

/**
 * Created 2017/06/01.
 */
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    ArrayList<Integer> ary = new ArrayList<>();

    for (int i = 0; i < 2; i++) {
      int input = sc.nextInt();
      ary.add(input);
    }

    int a = ary.get(0);
    int b = ary.get(1);

    if (a < b) {
      System.out.println("a < b");
    } else if (a > b) {
      System.out.println("a > b");
    } else {
      System.out.println("a == b");
    }
  }
}

Measured memory_bytes: 26148
class point:
    def __init__(self, x, y):
        self.x = x
        self.y = y
    def sub(self, p):
        return point(self.x - p.x, self.y - p.y)

while 1:
    try:
        x1, y1, x2, y2, x3, y3, xp, yp = map(float, raw_input().split())
        A = point(x1, y1)
        B = point(x2, y2)
        C = point(x3, y3)
        P = point(xp, yp)

        AB = B.sub(A)
        BP = P.sub(B)
        BC = C.sub(B)
        CP = P.sub(C)
        CA = A.sub(C)
        AP = P.sub(A)

        c1 = AB.x * BP.y - AB.y * BP.x
        c2 = BC.x * CP.y - BC.y * CP.x
        c3 = CA.x * AP.y - CA.y * AP.x

        if((c1 > 0) and (c2 > 0) and (c3 > 0) or (c1 < 0) and (c2 < 0) and (c3 < 0)): print "YES"
        else: print "NO"
    except:
        break

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

#define DB	double
#define lf	else if
#define	I64	long long
#define Rd()	(rand() << 15 | rand())
#define For(i,a,b)	for(int i=a;i<=b;i++)
#define Rep(i,a,b)	for(int i=a;i>=b;i--)
	
#define fi	first
#define se	second
#define MK	make_pair
#define PA	pair<int, int>

#define CH	(ch=getchar())
int		IN()	{
		int x= 0, f= 0, ch;
		for (; CH < '0' || ch > '9';)	f= (ch == '-');
		for (; ch >= '0' && ch <= '9'; CH)	(x*= 10)+= ch - '0';
		return	f ? -x : x;
}

int		A, B;

int		main()	{
		A= IN();
		B= IN();
		
		if	(B < 10)	A*=10;
		lf	(B < 100)	A*= 100;
			else	A*= 1000;
		A+= B;
		
		int c= sqrt(A);
		if	(c*c == A)	puts("Yes");
			else	puts("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	string str; cin>>str;
	if(str=="SAT")cout<<1;
    else if(str=="MON")cout<<6;
    else if(str=="TUE")cout<<5;
    else if(str=="WED")cout<<4;
    else if(str=="THU")cout<<3;
    else if(str=="FRI")cout<<2;
    else if(str=="SUN")cout<<7;
}


Measured memory_bytes: 3576