akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
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;
}

class Warshall_floyd {
  private:
    int vertex;
    const int INF = 1'050'000'000;

  public:
    vector<vector<int>> cost;
    Warshall_floyd(int N) {
        vertex = N;
        cost.resize(N, vector<int>(N, INF));
        for (int i = 0; i < vertex; i++) {
            cost[i][i] = 0;
        }
    }
    void path(int x, int y, int weight) {
        cost[x][y] = weight;
        cost[y][x] = weight;
    }
    void calc() {
        for (int k = 0; k < vertex; k++) {
            for (int i = 0; i < vertex; i++) {
                for (int j = 0; j < vertex; j++) {
                    cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
                }
            }
        }
    }
};

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

    int N, M, R;
    cin >> N >> M >> R;
    vector<int> r(R);
    REP(i, R) {
        cin >> r[i];
        r[i]--;
    }
    auto g = Warshall_floyd(N);
    REP(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        g.path(a, b, c);
    }
    g.calc();

    int ans = INF32;
    SORT(r);
    do {
        int sum = 0;
        REP(i, r.size() - 1) { sum += g.cost[r[i]][r[i + 1]]; }
        chmin(ans, sum);

    } while (next_permutation(ALL(r)));

    std::cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        int[] B = new int[n-1];
        Arrays.setAll(B, i -> Integer.parseInt(sc.next()));
        ans += B[0] + B[n - 2];
        for(int i = 1; i < n - 1; i++) ans += Math.min(B[i - 1], B[i]);
        System.out.println(ans);
    }
}


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

int main(){

    vector<int>v(4);
    for(int i=0;i<4;i++)cin>>v[i];
    sort(v.begin(), v.end());
    if(v[0]==1 && v[1]==4 && v[2]==7 && v[3]==9){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
a, b = gets.split(" ").map(&:to_i)
ls = []
rs = []
result = nil
b.times do |i|
  l, r = gets.split(" ").map(&:to_i)
  ls << l
  rs << r
end
l_max = ls.max
r_min = rs.min
puts l_max > r_min ? 0 : (l_max..r_min).size

Measured memory_bytes: 3464
def main():
    # 
    K = int(input())
    S = input()
    # S = list(map(int, input().split(' ')))
    # print(S, W)
    
    # if :
    #     print('')
    # else:
    #     print('')
    
    len_s = len(S)
    
    if len_s <= K:
        print(S)
    else:
        a = S[0:K] + '...'
        print(a)
        
    

main()

Measured memory_bytes: 61644
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	ll n, m;

	cin>>n>>m;

	vll a(n);

	vPll bc(m);

	rep(i, n) cin>>a[i];

	rep(i, m) cin>>bc[i].second>>bc[i].first;

	sort(all(a)); sort(all(bc)); reverse(all(bc));

	int ptr=0;
	bool flag=false;
	rep(i, m){
		rep(j, bc[i].second){
			if(a[ptr]>=bc[i].first) break;
			a[ptr++]=bc[i].first;
			if(ptr==n){
				flag=true; break;
			}
		}
		if(flag) break;
	}

	ll ans=0;
	rep(i, n) ans+=a[i];

	cout<<ans<<endl;
}


Measured memory_bytes: 2560
fn main() {
    let _: i32 = readln();
    let a: Vec<i64> = readln();
    let s: i64 = a.iter().sum();
    let mut t: i64 = 0;
    let mut answer = i64::max_value();
    for (i, &x) in a.iter().enumerate() {
        t += x;
        if i+1 != a.len() {
            answer = min(answer, (t - (s - t)).abs());
        }
    }
    println!("{}", answer);;
}

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::HashSet;

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n { vs.push(readln()); }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(String, bool, f32, f64, isize, i8, i16, i32, i64, usize, u8, u16, u32, u64);
impl<T> FromLn for Vec<T> where T: FromLn {
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);

Measured memory_bytes: 10492
while True:
    n,k = map(int,input().split())
    if n == 0 and k==0:
        break
    a = [int(input()) for i in range(n)]
    s = [0] * n
    s[0] = sum(a[0:k])
    for i in range(1, n-k+1):
        s[i] = s[i-1] - a[i-1] + a[k+i-1]
    print(max(s))


Measured memory_bytes: 11888
n = int(input())
a = [int(input()) for i in range(n)]
visited = [0]*n

ans = 0
pos = 0
while True:
    ans += 1
    if visited[pos] == 1:
        print(-1)
        exit()
    visited[pos] = 1
    pos = a[pos] - 1
    if pos == 1:
        print(ans)
        exit()


Measured memory_bytes: 50080
//
// Created by yamunaku on 2020/06/27.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    //CFS;
    int n;
    cin >> n;
    cout << n + n * n + n * n * n << endl;
    return 0;
}

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int g = sc.nextInt();
        int b = sc.nextInt();
        int n = sc.nextInt();
        int cnt = 0;
        for (int i = 0; i <= n / r; i++) {
            for (int j = 0; j <= n / g; j++) {
                if (r * i + g * j > n) {
                    break;
                }
                if ((n - r * i - g * j) % b == 0) {
                    cnt++;
                }
            }
        }
        System.out.println(cnt);
    }

}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <stdlib.h>
#define ll long long
#define MOD_P 1000000007
using namespace std;

int main()
{
	int n, m, c, answer, sum;
	int success = 0;
	cin >> n >> m >> c;

	vector<int> quest(m);

	for (int j = 0; j < m; j++) {
		cin >> quest[j];
	}

	for (int i = 0; i < n; i++) {
		sum = 0;
		for (int j = 0; j < m; j++) {
			cin >> answer;
			sum += answer * quest[j];
		}
		if (sum + c > 0) {
			success++;
		}
	}

	printf("%d", success);
	
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  string s;
  cin >> s;
  int n = (int) s.size();
  vector<int> a(n + 1);
  for (int i = 1; i <= n; i++) {
    if (s[i - 1] == '<') a[i] = a[i - 1] + 1;
  }
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == '>') a[i] = max(a[i], a[i + 1] + 1);
  }
  long long ans = 0;
  for (int i = 0; i <= n; i++) ans += a[i];
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 2844
N, M = map(int, input().split())
accepted = set()
penalty = 0
wa_cnt =  [0]*N

for m in range(M):
    p,s = input().split()
    p = int(p) - 1
    if p in accepted:
        continue
    elif s == 'AC':
        accepted.add(p)
        penalty += wa_cnt[p]
    else:
        wa_cnt[p] += 1
print(len(accepted), penalty)




Measured memory_bytes: 18340
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main(){
        int left,right,counter=0;
        cin >> left>>right;
        for(int i=left ; i<=right ; i++ ){
                ostringstream str;
                str << i;
                string integer=str.str();
                bool signal=true;
                for(int l=0 ; l<integer.size()/2 ; l++ ){
                        if(integer[l]!=integer[integer.size()-l-1]){
                                signal=false;
                                break;
                        }
                }
                if(signal)
                        counter++;
        }
        cout << counter << endl;
}

Measured memory_bytes: 256
def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result

arr_data = getinputdata()

sa = arr_data[0][0]
sb = arr_data[1][0]
sc = arr_data[2][0]

#print(sa,sb,sc)
#kbn = 1


chkflg = True
if sa == "":

    chkflg = False

else:
    if sa[0] == "a":
        kbn = 1  
    elif sa[0] == "b":
        kbn = 2
    elif sa[0] == "c":
        kbn = 3

sa = sa.replace(sa[0], "", 1)

    
while chkflg:
    
#    print(sa,sb,sc,kbn)
    
    if kbn == 1:

        if sa == "":
        
            chkflg = False
        
        else:
            if sa[0] == "a":
                kbn = 1  
            elif sa[0] == "b":
                kbn = 2
            elif sa[0] == "c":
                kbn = 3
        
            sa = sa.replace(sa[0], "", 1)
        
    elif kbn == 2:
      
        if sb == "":
        
            chkflg = False
        
        else:

            if sb[0] == "a":
                kbn = 1  
            elif sb[0] == "b":
                kbn = 2
            elif sb[0] == "c":
                kbn = 3

          
            sb = sb.replace(sb[0], "", 1)

    elif kbn == 3:
        
        
        if sc == "":
        
            chkflg = False
        
        else:

            if sc[0] == "a":
                kbn = 1  
            elif sc[0] == "b":
                kbn = 2
            elif sc[0] == "c":
                kbn = 3

            sc = sc.replace(sc[0], "", 1)
        
#print("A" if flg==1 else "B" if flg==2 else "C")

if kbn==1:    
    print("A")
elif kbn==2:
    print("B")
elif kbn==3:
    print("C")
        

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		for (int i = 1; i <= n; i++) {
			int cnt = 0;
			for (int x = 1; x*x < i ; x++) {
				for (int y = 1; x*x + x*y + y*y < i ; y++) {
					for (int z = 1; ; z++) {
						int sum = x*x + y*y + z*z + x*y + y*z + z*x;
						if (sum == i) {
							cnt++;
							break;
						} else if (sum > i) {
							break;
						}
					}
				}
			}
			System.out.println(cnt);
		}
		
	}
}


Measured memory_bytes: 39196
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo (1LL<<63-1)
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >

using namespace std;

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

const long double Pi=acos(-1),e=2.718;
const int N=2e5+10, mod=1e9+7;


int main ()
{
    FASTIO
    int n;
    cin >> n;
    long double sum=0;
    for(int i=0;i<n;i++){
        long double a;
        cin >> a;
        sum += 1/a;
    }
    cout << fixed << setprecision(20) << 1/sum << endl;
    return 0;
}
/**

*/


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] c = s.toCharArray();
        char[] p = new char[s.length()];
        int x = 0;
        for(int i = 0;i < s.length();i++){
            if(c[i] == 'B'){
                x--;
                if(x < 0){
                    x = 0;
                }
                continue;
            }
            p[x] = c[i];
            x++;
        }
        for(int i = 0;i < x;i++){
            System.out.print(p[i]);
        }
        System.out.println();
    }
}


Measured memory_bytes: 21204
// Standard I/O
#include <iostream>
#include <sstream>
#include <cstdio>
// Standard Library
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
// Template Class
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
// Container Control
#include <algorithm>

using namespace std;

#define rep( i, n ) for( int i = 0; i < n; ++i )
#define irep( i, n ) for( int i = n-1; i >= 0; --i )
#define reep( i, s, n ) for ( int i = s; i < n; ++i )
#define ireep( i, n, s ) for ( int i = n-1; i >= s; --i )
#define foreach(itr, x) for( typeof(x.begin()) itr = x.begin(); itr != x.end(); ++itr)

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all( v ) v.begin(), v.end()
#define fs first
#define sc second
#define vc vector

// for visualizer.html
double SCALE = 1.0;
double OFFSET_X = 0.0;
double OFFSET_Y = 0.0;
#define LINE(x,y,a,b) cerr << "line(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(a) + OFFSET_X << ","										\
	<< SCALE*(b) + OFFSET_Y << ")" << endl;
#define CIRCLE(x,y,r) cerr << "circle(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(r) << ")" << endl;

typedef long long ll;
typedef complex<double> Point;

typedef pair<int, int> pii;
typedef pair<int, pii> ipii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector< vector<int> > vii;
typedef vector< vector<double> > vdd;

typedef vector<int>::iterator vi_itr;

const int IINF = 1 << 28;
const int MOD = 1e9+7;
const double INF = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1.0);

// Direction : L U R D
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1 };

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

    cin >> a >> b >> c >> d;

    cout << (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iterator>
#include <deque>
#include <string>
#include <queue>
#include <omp.h>
#include <fstream>   // ifstream, ofstream
typedef int64_t ll;
using namespace std;
const ll INF=1e10;
const double EPS=1e-8;
const ll mod = 1000000007;
int main(){
	ll r;
	cin>>r;
	cout<<3*r*r<<endl;

}


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

struct Node {
  int key;
  Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int key) {
  Node *y = NIL;
  Node *x = root;
  Node *z = new Node();
  z->key = key;

  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;
  }
}

Node* find(Node *node, int key) {
  while (node != NIL && key != node->key) {
    if (key < node->key) {
      node = node->left;
    } else {
      node = node->right;
    }
  }
  return node;
}

void printPreorder(Node *node) {
  cout << " " << node->key;
  if (node->left != NIL) printPreorder(node->left);
  if (node->right != NIL) printPreorder(node->right);
}

void printInorder(Node *node) {
  if (node->left != NIL) printInorder(node->left);
  cout << " " << node->key;
  if (node->right != NIL) printInorder(node->right);
}

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

  int n;
  cin >> n;

  string command;
  int v;
  for (int i = 0; i < n; i++) {
    cin >> command;
    if (command == "insert") {
      cin >> v;
      insert(v);
    } else if (command == "find") {
      cin >> v;
      if(find(root, v) == NIL) {
        cout << "no" << endl;
      } else {
        cout << "yes" << endl;
      }
    } else if (command  == "print") {
      printInorder(root);
      cout << endl;
      printPreorder(root);
      cout << endl;
    }
  }

  return 0;
}

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

using namespace std;

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

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(int i = (int)m; i < (int)n; i++)
#define rep(i,n) REP(i,0,n)
#define rep2(i,n) REP(i,1,n+1)
#define rep3(i,n) REP(i,0,n+1)
#define REPM(i,m,n) for(int i = (int)m; i >= (int)n; i--)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define repll(i,n) REPLL(i,0,n)
#define repll2(i,n) REPLL(i,1,n+1)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define Size(s) (int) s.size()

//------------------------------------------------------

int main() {
    int h, w;
    cin >> h >> w;
    char s[h][w];
    rep(i, h) rep(j, w) cin >> s[i][j];

    bool suc = true;

    rep(i, h) rep(j, w) {
        if (s[i][j] == '.') continue;
        bool cant = true;
        if (i - 1 >= 0 && s[i - 1][j] == '#') cant = false;
        if (j - 1 >= 0 && s[i][j - 1] == '#') cant = false;
        if (i + 1 < h && s[i + 1][j] == '#') cant = false;
        if (j + 1 < h && s[i][j + 1] == '#') cant = false;
        if (cant) suc = false;
    }

    Yes(suc);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Set         std::set
#define PQueue      std::priority_queue
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define HashMap     std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    template<class A, class B> A power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    template<class A, class B> A power ( A x, B n ) { return power( x, n, 1000000007 ); }
    template<class A> A gcd ( A x, A y ) { return x % y ? gcd( y, x % y ) : y; }
    template<class A, class B> A lcm   ( A x,  B y ) { return ( x / gcd(x, y) * y ); }
    template<class A> inline A abs ( A n ) { return ( n < 0 ) ? -n : n; }
    template<class A, class B> inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B> inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    int w[300300], e[300300];

    signed call_of_Cthulhu( signed datum ) {

        int n;
        String s;
        read n >> s;
        for ( int i = 0; i < n; i++ ) {
            w[i+1] = w[i];
            if ( s[i] == 'W' ) {
                w[i+1]++;
            }
        }
        for ( int i = n-1; i != -1; i-- ) {
            e[i-1] = e[i];
            if ( s[i] == 'E' ) {
                e[i-1]++;
            }
        }
        int min = INF;
        for ( int i = 0; i < n; i++ ) {
            chmin ( min, w[i] + e[i] );
        }

        echo min fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 2964
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(VECTOR) (VECTOR).begin(), (VECTOR).end()

int main(){

	ll H, W;
	cin >> H >> W;
	ll ans = 10000000000;
	if(W >= 3){
		if(W%3 == 0)ans = 0;
		else ans = H;
	}
	if(H >= 3){
		if(H%3 == 0)ans = 0;
		else ans = min(ans, W);
	}
	ll a, b, c;
	for(ll i = 1; i < W; i ++){
		a = i * H;
		if(H%2 == 0){
			b = H * W - a;
			b /= 2;
			c = b;
		}
		else{
			b = (W - i) * (H / 2);
			c = (W - i) * (H / 2 + 1);
		}
		ans = min(ans, max(a, max(b, c)) - min(a, min(b, c)));
	}
	for(ll i = 1; i < H; i ++){
		a = i * W;
		if(W%2 == 0){
			b = H * W - a;
			b /= 2;
			c = b;
		}
		else{
			b = (H - i) * (W / 2);
			c = (H - i) * (W / 2 + 1);
		}
		ans = min(ans, max(a, max(b, c)) - min(a, min(b, c)));
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int N;
	while(~scanf("%d", &N)) {
		vector<int> A(1 << N);
		for(int i = 0; i < 1 << N; ++ i)
			scanf("%d", &A[i]);
		rep(k, N) {
			vi nA(1 << (N - k - 1));
			rep(i, 1 << (N - k - 1)) {
				int X = A[i * 2 + 0], Y = A[i * 2 + 1];
				if(X == Y)
					nA[i] = X;
				else
					nA[i] = max(X, Y) - min(X, Y);
			}
			A.swap(nA);
		}
		int ans = A[0];
		printf("%d\n", ans);
	}
	return 0;
}


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

int main()
{
	int a, b, c; cin >> a >> b >> c;

	if (a + b == c || b + c == a || c + a == b) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<string>
using namespace std;
string ch;
set<string>  s;
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>ch;
		s.insert(ch);
	}
	int sum=0;
	sum=s.size();
	cout<<sum;
	return 0;
	return 0;
 } 

Measured memory_bytes: 19188
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		for (;;) {
			String deck = sc.next();
			if ("-".equals(deck)) break;
			int m = sc.nextInt();
			for (int i = 0; i < m; i++) {
				int h = sc.nextInt();
				String A = deck.substring(0, h);
				deck = deck.substring(h) + A;
			}
			System.out.println(deck);
		}
	}
}



Measured memory_bytes: 26456
N = int(input())
H = list(map(int, input().split()))
is_ng = False
t_max = H[0]
for i in range(1, len(H)):
    t_max = max(t_max, H[i])
    if t_max-1 > H[i]:
        is_ng = True
        break
print('YNeos'[is_ng::2])

Measured memory_bytes: 14224
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc159/tasks/abc159_d>
 問題文============================================================
 D - Banned K
 =================================================================
 解説=============================================================
 
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<ll> A(N); for(auto& in:A) cin >> in;
    map<ll,ll> mp;
    for(auto a:A) mp[a]++;
    
    ll sum = 0;
    for(auto p:mp){
        sum += p.second*(p.second-1)/2;
    }
    
    for(int k = 0; k < N;k++){
        
        ll num = mp[A[k]];
        
        ll dec = num*(num-1)/2;
        ll add = (num-1)*(num-2)/2;
        cout << sum - dec + add << endl;
    }
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    // cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 11136
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int nxt() {int x;scanf("%d", &x);return x;}


int main(){
    int n = nxt();
    map<int, ll> m;
    VI num(n);
    REP(i, n){
        num[i] = nxt();
        m[num[i]]++;
    }
    ll total = 0;
    for(auto x : m){
        total += (x.second) * (x.second - 1) / 2;
    }
    REP(i, n){
        int c = m[num[i]];
        printf("%lld\n", total - (c*(c-1)/2) + ((c-1)*(c-2)/2));
    }
    return 0;
}



Measured memory_bytes: 10240
#include <stdio.h>	//GCD=最大公約数、LCM=最小公倍数

int main(void){
	long long a,b;
	while(scanf("%lld %lld",&a,&b)!=EOF){
		long long temp_a,temp_b,c=1,LCM,GCD;
		if(a<=b){
			temp_a=b;
			temp_b=a;
		}
		else{
			temp_a=a;
			temp_b=b;
		}
		while(c!=0){
			c=temp_a%temp_b;
			if(c==0){
				temp_a=temp_b;
			}
			temp_a=temp_b;
			temp_b=c;
			}
		LCM=temp_a;
		GCD=(a*b)/LCM;
	printf("%lld %lld\n",LCM,GCD);
	}
	return 0;
}

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

int main() {
    int A; cin >> A;
    int B; cin >> B;
    int C; cin >> C;
    int D; cin >> D;
    while(true){
        C -= B;
        if(C <= 0){
            cout << "Yes" << endl;
            break;
        }
        A -= D;
        if(A <= 0){
            cout << "No" << endl;
            break;
        }
    }
}

Measured memory_bytes: 3624
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: usize = read();
    let b: usize = read();
    if a <= 5 {
        println!("{}", 0);
        return;
    }
    if a <= 12 {
        println!("{}", b / 2);
        return;
    }

    println!("{}", b);
}


Measured memory_bytes: 2124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int read(){
    int a=0,b=getchar(),c=1;
    while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
    while(isdigit(b))a=a*10+b-'0',b=getchar();
    return a*c;
}
void print(int x){
    char y=x%10+'0';
    if(x>=10)print(x/10);
    putchar(y);
}
int n,m,vis[100005];
vector<int> g[100005],ans[100005];
bool dfs(int x,int f){
	vis[x]=1;
	for(int i=0;i<g[x].size();i++)
		if(!vis[g[x][i]]){
			if(dfs(g[x][i],x))ans[g[x][i]].push_back(x);
			else ans[x].push_back(g[x][i]);
		}
		else if(g[x][i]!=f and vis[g[x][i]]==1)ans[x].push_back(g[x][i]);
	vis[x]=2;
	return ans[x].size()%2;
}
int main(){
	n=read(),m=read();
	for(int i=0;i<m;i++){
		int x=read(),y=read();
		g[x].push_back(y);
		g[y].push_back(x);
	}
	if(m%2){
		puts("-1");
		return 0;
	}
	dfs(1,0);
	for(int i=1;i<=n;i++)
		for(int j=0;j<ans[i].size();j++)
			print(i),putchar(' '),print(ans[i][j]),puts("");
	return 0;
}

Measured memory_bytes: 15872
import java.util.Arrays;
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[] x = new int[n];
		int[] x2 = new int[n];

		for(int i=0;i<x.length;i++) {
			x[i] = sc.nextInt();
			x2[i] = x[i];
		}
		Arrays.sort(x2);

		int left = x2[x2.length/2-1];
		int right =x2[x2.length/2];



		for(int i=0;i<x.length;i++) {
			if(x[i] <= left) {
				System.out.println(right);
			} else {
				System.out.println(left);
			}

		}

	}

}

Measured memory_bytes: 94284
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
# debug = lambda *a, **kw: print(*a, **kw, file=sys.stderr)

N = ini()
adj = [[] for _ in range(N)]

for i in range(N - 1):
    a, b = [x - 1 for x in inm()]
    adj[a].append(b)
    adj[b].append(a)

depth = [(0, 0) for _ in range(N)]


def solve():
    stk = [(0, -1, False)]
    while stk:
        node, p, agg = stk.pop()
        if not agg:
            stk.append((node, p, True))
        md1, md2 = 0, 0
        for x in adj[node]:
            if x == p:
                continue
            if agg:
                dx, _ = depth[x]
                dx += 1
                if md1 < dx:
                    md2 = md1
                    md1 = dx
                elif md2 < dx:
                    md2 = dx
            else:
                stk.append((x, node, False))
        if agg:
            depth[node] = (md1, md2)

    stk = [(0, -1)]
    max_len = 0
    while stk:
        node, p = stk.pop()
        d1, d2 = depth[node]
        if p >= 0:
            pd1, pd2 = depth[p]
            if pd1 == 1 + d1:
                pd1 = pd2
            if d2 < pd1 + 1:
                d2 = pd1 + 1
        if max_len < d1 + d2 + 1:
            max_len = d1 + d2 + 1
        for x in adj[node]:
            if x != p:
                stk.append((x, node))

    if max_len == 1:
        return True
    if max_len == 2:
        return False
    return (max_len + 1) % 3 != 0


print("First" if solve() else "Second")


Measured memory_bytes: 69652
#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 ans=0;
  if(N%2==1){
    ans=N/2+1;
  }else{
    ans=N/2;
  }
  cout<<ans<<endl;
}

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

#define loop(i,n) for(int i=1;i<=n;i++)
int uc[102][102];
int d[102];
bool used[102];

int dij(int n, int a, int b){
	loop(i,n)d[i]=-1;
	loop(i,n)used[i]=0;
	d[a]=0;
	while(1){
		int v=-1;
		loop(i,n){
			if(d[i]==-1)continue;
			if(!used[i]&&(v==-1||d[i]<d[v]))v=i;
		}
		if(v==-1)break;
		used[v]=1;
		loop(i,n){
			if(uc[v][i]==-1)continue;
			if(d[i]==-1){
				d[i]=d[v]+uc[v][i];
			}else{
				d[i]=min(d[i],d[v]+uc[v][i]);
			}
		}
		if(v==b)return d[b];
	}
	return -1;
}

int main(){
	int n, k, f, a, b, c, d, e;
	while (cin >> n >> k, n){
		loop(i, n)loop(j, n)uc[i][j] = -1;
		loop(i, k){
			cin >> f;
			if (f == 0){
				cin >> a >> b;
				cout << dij(n, a, b) << endl;
			}
			else{
				cin >> c >> d >> e;
				if(uc[c][d]==-1){
					uc[c][d] = uc[d][c] = e;
				}else{
					uc[c][d] = uc[d][c] = min(uc[c][d], e);
				}
			}
		}
	}
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<ll(n); i++)
#define REPR(i, n) for(ll i=n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=m; i<ll(n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) ll(x.size()) 
using P = pair<int, int>;
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; }
const int INF = 2e9;
const ll LINF = (1LL<<60);

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,k,q;
  cin >> n >> k >> q;
  vector<int> cnt(n, 0);
  REP(qq,q){
    int a; cin >> a;
    a--;
    cnt[a]++;
  }

  REP(i,n){
    cout << (k-(q-cnt[i])>0 ? "Yes\n" : "No\n");
  }

  return 0;
}


Measured memory_bytes: 3696
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <math.h>

using namespace std;

int main ()
{
  int count, len;
  vector<string>r;
  cin >> count;
  cin >> len;
  for (int i = 0; i < count; i++) {
    string in;
    cin >> in;
    r.push_back(in);
  }
  std::sort(r.begin(), r.end());
  for (int i = 0; i < count; i++) {
    cout << r[i];
  }
}


Measured memory_bytes: 384
n=int(input())
vlis=[int(i) for i in input().split()]
odd=vlis[0::2]
even=vlis[1::2]
import collections 
odd_=collections.Counter(odd).most_common(2)
even_=collections.Counter(even).most_common(2)

if odd_[0][0]==even_[0][0]:
    if len(odd_)==1 and len(even_)==1:
        print(int(len(vlis)/2))
    elif len(even_)==1:
        print(len(vlis)-even_[0][1]-odd_[1][1])
    elif len(odd_)==1:
        print(len(vlis)-odd_[0][1]-even_[1][1])
    else:
        if odd_[0][1]+even_[1][1]>=odd_[1][1]+even_[0][1]:
            print(len(vlis)-odd_[0][1]-even_[1][1])
        else:
            print(len(vlis)-odd_[1][1]-even_[0][1])
else:
    print(len(vlis)-odd_[0][1]-even_[0][1])

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

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

    map<int, int> mp;
    int a;
    rep(i, N) {
        cin >> a;
        if (mp.count(a)) mp[a]++;
        else mp[a] = 1;
    }

    int ans = 0;
    for (auto itr=mp.begin(); itr != mp.end(); itr++) {
        if (itr->second >= itr->first) ans += itr->second - itr->first;
        else ans += itr->second;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4736
def get_caps(a):
  dic = dict()

  for ai in a:
    dic.setdefault(ai, 0)
    dic[ai] += 1

  return dic


def is_match(caps):
  global N

  if 0 in caps.keys():
    if caps[0] == N:
      return True
  
  if N % 3 == 0:
    if 0 in caps.keys() and len(caps) == 2:
      if caps[0] == N//3:
        return True
    elif len(caps) == 3:
      x, y, z = caps.keys()
    
      if x ^ y ^ z == 0:
        if caps[x] == caps[y] == caps[z] == N//3:
          return True


# A - XOR Circle
N = int(input())
a = list(map(int, input().split()))

# 帽子の情報をdictに入れる
caps = get_caps(a)

if is_match(caps):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 20472
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//inline int in() { int x; scanf("%d",&x); return x;}
template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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 main () {
  int n = in();
  map<string,int> mp;
  rep(i,n) {
    string s = in<string>();
    mp[s]++;
  }
  int mx = 0;
  for (auto p : mp) mx = max(mx, p.se);
  for (auto p : mp) {
    if (p.se != mx) continue;
    cout << p.fi << '\n';
  }
  return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    long double W,H,x,y;
    cin >> W >> H >> x >> y;
    int res;
    if(x == W/2 && y == H/2) { res = 1; cout << W * H/2 << endl;}
    else  {res = 0; cout << W * H / 2 << endl;}

    cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
  string a;
  getline(cin,a);
  for(int i = 0; i < a.size(); i++) {
    if(a[i] >= 'a' && a[i] <= 'z') a[i] = a[i] - 'a' + 'A';
    else if(a[i] >= 'A' && a[i] <= 'Z') a[i] = a[i] - 'A' + 'a';
  }
  cout << a << endl;
  return 0;
}



Measured memory_bytes: 3148
#include <stdio.h>

int main(void){

    int mountain[10] = {0};
    int i=0;
    int j=0;
    int count=0;
    int m1=0;
    int m2=0;
    
    for(i=0; i<10; i++){
        scanf("%d", &j);
        mountain[i] = j;
    }
    
    do{
      count = 0;
      for(i=0; i<9; i++){
         m1 = mountain[i];
         m2 = mountain[i+1];
         
         if(m1 < m2){
            mountain[i] = m2;
            mountain[i+1] = m1;
            count++;
         }
      
      }
    }while(count != 0);
    
    printf("%d\n", mountain[0]);
    printf("%d\n", mountain[1]);
    printf("%d\n", mountain[2]);
    
    return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(){
    int cup[3] = {1};
    char x, y;
    while (scanf(" %c", &x) != EOF)
    {
        scanf(",%c", &y);
        swap(cup[x - 'A'], cup[y - 'A']);
    }
    for (int i = 0; i < 3; i++)
    {
        if (cup[i] > 0)
        {
            printf("%c\n", 'A' + i);
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1136
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N, L;
  cin >> N >> L;
  vector<string> S(N);
  rep (i, N) cin >> S[i];
  sort(S.begin(), S.end());
  for (auto it: S) cout << it;
  cout << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

using namespace std;
using ll = long long;

int main() {
	ll a, b, k;
	cin >> a >> b >> k;

	while (k > 0) {
		a /= 2;
		b += a;
		--k;
		if (k <= 0) { break; }
		b /= 2;
		a += b;
		--k;
	}
	cout << a << " " << b << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
    int A, B, D, K, k = 0;
    std::cin >> A >> B >> K;
    D = std::min(A, B) + 1;
    while (k < K) {
        --D;
        if ( A%D == 0 && B%D == 0 ) {
            ++k;
        }
    }
    std::cout << D << std::endl;
    return 0;
}

Measured memory_bytes: 256
import itertools as its
A,B,C,D = input()
for p in its.product(['-','+'], repeat=3):
    ans = eval(A+p[0]+B+p[1]+C+p[2]+D)
    if ans == 7:
        print(A+p[0]+B+p[1]+C+p[2]+D+'=7')
        break

Measured memory_bytes: 3060
t0, t1 = map(int, input().split())
a0, a1 = map(int, input().split())
b0, b1 = map(int, input().split())
d0 = (a0 - b0) * t0
d1 = (a1 - b1) * t1
if d0 < 0:
    d0, d1 = -d0, -d1
if d0 + d1 == 0:
    print('infinity')
    exit()
if d0 + d1 > 0:
    print(0)
    exit()
d = -(d0 + d1)
q, r = d0 // d, d0 % d
print(2 * q + min(r, 1))


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<climits>
using namespace std;

int main(){
	int N,W;
	cin >> N >> W ;
	vector<int> value(N);
	vector<int> weight(N);
	for (int i=0;i<N;i++){
		cin >> value[i] >> weight[i];
	}
	
	int table[W+1][N];
	for (int i=0;i<W+1;i++){
		if(i==0){
			table[i][0]=0;
		}else if(i==weight[0]){
			table[i][0]=value[0];
		}else{
			table[i][0]=-1;
		}
	}
	for (int j=1;j<N;j++){
		table[0][j]=0;
		for (int i=1;i<W+1;i++){
			if(i-weight[j]<0){
				table[i][j]=table[i][j-1];
				continue;
			}
			if(table[i-weight[j]][j]==-1){
				table[i][j]=table[i][j-1];
			}else{
				table[i][j]=max(table[i][j-1],table[i-weight[j]][j-1]+value[j]);
			}
		}
	}
	
	int res=0;
	for (int i=0;i<W+1;i++){
		if(res<table[i][N-1]){
			res=table[i][N-1];
		}
	}
	cout << res <<endl;
	return 0;
}

Measured memory_bytes: 5100