akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		BufferedReader br =
				new BufferedReader( new InputStreamReader(System.in) );
		int n = Integer.parseInt(br.readLine());

		String[] data = br.readLine().split(" ");
		int[] S = new int[n];
		for (int i=0; i < n; i++) {
			S[i] = Integer.parseInt(data[i]);
		}

		int count = mergeSort(S, 0, n);
		System.out.print(S[0]);
		for (int i=1; i < n; i++) {
			System.out.print(" " + S[i]);
		}
		System.out.println();
		System.out.println(count);
	}

	/**
	 * A???????´?????????????l <= index < r ??¨????????¨???????????????
	 * l??\???m???????????¨???L??¨???m??\???r???????????¨???R????????§??????????????´?????????????????¨??????
	 * ????????????????????????????????????????????????????????´??????????????????????????????
	 * L???????°????????´???¨???R???????°????????´??????????????°?????????????
	 * L??¨R????????§????°????????´???¨?????????
	 */
	static int merge(int[] A, int l, int m, int r) { // l:left, m:mid, r:right
		int n1 = m - l;
		int n2 = r - m;

		int max = A[l]; //bannpei
		// L = {A[l], A[l+1], A[l+2], ... , A[m-2], A[m-1], bannpei}
		int[] L = new int[n1+1];
		for (int i=0; i < n1; i++) {
			L[i] = A[l+i];
			if (max < L[i]) {
				max = L[i];
			}
		}

		// R = {A[m], A[m+1], ... , A[r-1], bannpei}
		int[] R = new int[n2+1];
		for (int i=0; i < n2; i++) {
			R[i] = A[m+i];
			if (max < R[i]) {
				max = R[i];
			}
		}

		// bannpei?¨????
		max += 1;
		L[n1] = max;
		R[n2] = max;

		int i = 0;
		int j = 0;
		int count = 0;
		for (int k = l; k < r; k++) {
			count++;
			if ( L[i] <= R[j] ) {
				A[k] = L[i];
				i++;
			} else {
				A[k] = R[j];
				j++;
			}
		}
		return count;
	}

	/**
	 * A????????????l <= index < r??¨????????¨?????????????????´????????????
	 */
	static int mergeSort(int[] A, int l, int r) {
		int count = 0;
		if ( l+1 < r ) {
			int m = (l+r) / 2;
			count += mergeSort(A, l, m);
			count += mergeSort(A, m, r);
			count += merge(A, l, m, r);
		}
		return count;
	}
}

Measured memory_bytes: 158980
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define ppb pop_back
#define mp  make_pair
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ll n,k;
	cin>>n>>k;
	priority_queue <long double> pq;
	for(ll i=0;i<n;++i){
		ll t;
		cin>>t;
		pq.push((long double)t);
	}
	while(k>0){
		ll t=pq.top();
		pq.pop();
		// cout<<t<<" ";
		t=t/2;
		pq.push(t);
		k--;
	}
	ll ans=0;
	while (!pq.empty()) 
    { 
        // cout << '\t' << g.top(); 
        ans+=(ll)round(pq.top());
        pq.pop(); 
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2420
a,b,t,i;
main(N){
    long long c;
    for(scanf("%d",&N);N--;c+=t,i++){
        scanf("%d",&t);
        //if(a>t)a=t;
        //if(b<t)b=t;
        a=i&&a<t?a:t;
        b=i&&b>t?b:t;
    }
    printf("%d %d %lld\n",a,b,c);
}

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

int main(void){
  long long N,A,B;
  cin >> N >> A >> B;

  long long ans;
  if((B-A)%2 == 0){
    ans = (B-A)/2;
  }else if(N-A > B-1){
    if(B-A == 1){
      ans = B-1;
    }else{
      ans = A + (B-A-1)/2;
    }
  }else{
    if(B-A == 1){
      ans = N-A;
    }else{
      ans = N-B+1 + (B-A-1)/2;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#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--)

int main(){
    int A,B;
    cin >> A >> B;

    if(A % 2 == 0 or B % 2 == 0)
        cout << "Even" << endl;
    else
    {
        cout << "Odd" << endl;
    }
    

    

    

}

Measured memory_bytes: 3576
import collections


n = int(input())
s = []
for i in range(n):
    s.append(input())

dic = collections.Counter(s)
k = dic.most_common()
m = k[0][1]
mx = m
i = 0
ans = []
while m == mx: 
    ans.append(k[i][0])
    i += 1
    if i > len(k)-1:
        break
    m = k[i][1]

ans = sorted(ans)
for i in ans:
    print(i)


Measured memory_bytes: 49240
// D - Integer Cards
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
	int N,M; cin>>N>>M;
	priority_queue<pair<ll,int>> que;
	for(int n=N; n; --n){
		ll a; cin>>a;
		que.push({a,1});
	}
	while(M--){
		int b; ll c; cin>>b>>c;
		que.push({c,b});
	}

	ll ans = 0;
	int end = que.size()-N-1;
	for(int i=end+N; i>=end && N>0; --i){
		auto e = que.top(); que.pop();
		int c = min(e.second, N);
		ans += e.first * c;
		N -= c;
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 6384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

vector<ll> divisors(ll N) {
  vector<ll> res;
  for (ll d = 1; d * d <= N; d++) {
    if (N % d == 0) {
      res.push_back(d);
      if (N / d != d) res.push_back(N / d);
    }
  }
  return res;
}

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  ll N;
  while (cin >> N) {
    set<ll> res;
    for (ll d : divisors(N)) {
      if (d == 1) continue;
      ll M = N;
      while (M % d == 0) M /= d;
      if (M % d == 1) res.insert(d);
    }
    for (ll d : divisors(N - 1)) {
      if (d == 1) continue;
      if (N % d != 0) res.insert(d);
    }
    cout << res.size() << endl;
  }
  return 0;
}


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

int main () {
  int N,M;
  cin >> N >> M;
  if (N == 1 && M == 0) {
  cout << 0 << endl;
  return 0;
  }
  vector<int> S(M);
  vector<int> C(M);
  for (int i = 0;i < M;i++) {
  cin >> S[i] >> C[i];
  }
  for (int a = 0 ;a < M;a++) {
  if(S[a] == 1 && C[a] == 0) {
    if (N == 1) {
    cout << 0;
    return 0;
    }
  cout << -1 << endl;
  return 0;
  }
  }
   for (int j = 0;j < M;j++) {
   	for (int k = 0;k < M;k++) {
    	if (S[j] == S[k]) {
        	if (C[j] != C[k]) {
            cout << -1 << endl;
            return 0;
            }
        }
    }
   }
  vector<int> ans(N,0);
  for (int l = 0;l < M;l++) {
  ans[S[l]-1] = C[l];
  }
  if (ans[0] == 0) {
  ans[0] = 1;
  }
  for (int m = 0;m < N;m++) {
  cout << ans[m];
  }
  cout << endl;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int d = sc.nextInt();
	    int t = sc.nextInt();
	    int s = sc.nextInt();

	    if ((double)d / (double)s <= t) {
	    	System.out.println("Yes");
	    } else {
	    	System.out.println("No");
	    }
	}
}

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

int gcd(long long a, long long b){
  long long M = max(a, b), m = min(a, b);
  while(m != 0){
  	long long r = M%m;
    M = m; m = r;
  }
  return M;
}

int digit_sum(long long n){
  long long ans;
  while(n != 0){
  	ans += n%10;
  	n /= 10;
  }
  return ans;
}

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for(int i = 0; i < n; i++) cin >> h.at(i);
  
  int ans = 0;
  for(int i = 0; i < n; i++){
  	if(h.at(i) >= k){
    	ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n,a,b,c,x;
    while(cin >> n >> a >> b >> c >> x, n){
        vector<int> y(n);
        for(int i = 0; i < n; i++)cin >> y[i];
        int ans = 0;
        int ind = 0;
        while(ans <= 10000){
            //cout << ind << " " << x << " " << ans << endl;
            if(x == y[ind]){
                ind++;
                if(ind == n)break;
            }
            ans++;
            x = (x * a + b) % c;
        }
        if(ans > 10000){
            cout << -1 << endl;
        }else{
            cout << ans << endl;
        }
    }
}



Measured memory_bytes: 3008
#include <bits/stdc++.h>
using namespace std;
#define INFTY (1<<30) 

int n,m;
vector<vector<int>> G(100005,vector<int>(0));
vector<int> c(200005,INFTY);
vector<int> color(200005,0);

void bfs(){
    queue<int> Q;
    color[1]=1;
    Q.push(1);
    int u;
    while(!Q.empty()){
        u=Q.front();
        Q.pop();
        int v;
        for(int i=0;i<G[u].size();i++){
            v=G[u][i];
            if(color[v]==0){
                color[v]=1;
                c[v]=u;
                Q.push(v);
            }
        
        }
        color[u]=2;
    }
    
    
    
}


int main() {
    cin>>n>>m;
    vector<int> a(200005);
    vector<int> b(200005);
    for(int i=1;i<m+1;i++){
        cin>>a[i]>>b[i];
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }

    bfs();
    bool ans=true;;
    for(int i=2;i<n+1;i++){
        if(c[i]==INFTY) ans=false;
    }
    if(!ans) cout<<"No"<<endl;
    else{
        cout<<"Yes"<<endl;
        for(int i=2;i<n+1;i++){
            cout<<c[i]<<endl;

        }
    }
}

Measured memory_bytes: 12936
import java.util.Scanner;
public class Main {
	//?????°
	public static int a,b;
	//????????????
	public static void solve(){
		Scanner sc = new Scanner(System.in);
		a=sc.nextInt();
		b=sc.nextInt();
		System.out.println(a*b +" "+(a+a+b+b));
	}
	public static void main(String[] args) {
	       solve();
	}

}

Measured memory_bytes: 26104
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 0;
ll a, b, ans=0;

int main(){
	IOS
	cin >> a >> b;
	ll g=__gcd(a, b);
	for(int i=2;i<=sqrt(g);i++){
		if(g%i==0){
			ans++;
		}
		while(g%i==0) g/=i;
	}
	if(g>1) ans++;
	cout << ans + 1 << '\n';
	return 0;
}


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

bool solve(int n){
    
    int a[10]={},x=0;
    
    while(n>0){
        a[x]=(n%10);
        n/=10;
        x++;
    }
    
    for(int i=0;i<x;i++){
        if(a[i]!=a[x-i-1])return false;
    }

    return true;
}
int main(void){
    int x,y;
    cin>>x>>y;
    int a[100010]={};
    for(int i=1;i<100000;i++){
        if(solve(i))a[i]=a[i-1]+1;
        else a[i]=a[i-1];
    }
    cout<<a[y]-a[x-1];
    return 0;
}


Measured memory_bytes: 640
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def print_matrix(mat):
    for i in range(len(mat)):
        print(*['IINF' if v == IINF else "{:0=4}".format(v) for v in mat[i]])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False
# show_flg = True


def main():
    D = 60
    N, K = MI()
    A = LI()
    edges = [[] for i in range(N)]
    to = [[0] * N for i in range(D)]

    for i in range(N):
        to[0][i] = A[i] - 1

    for i in range(D-1):
        for j in range(N):
            to[i+1][j] = to[i][to[i][j]]

    v = 0
    for i in range(D-1, -1, -1):
        l = 1 << i
        if l <= K:
            v = to[i][v]
            K -= l

    print(v+1)

if __name__ == '__main__':
    main()


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

int main(){
    ll n; cin >> n;
    vector<ll> a(n); rep(i,n) cin >> a[i];

    ll ans = 1e9;

    for(int i = -100; i < 101; i++){
        ll sum = 0;
        for(int j = 0; j < n; j++){
            sum += pow((a[j] - i),2);
        }
        ans = min(ans, sum);
    }

    put(ans);
}

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

const double EPS = 1e-10;
const double PI = acos(-1.0);

int sign(double x) {  //???????????°???????°???????????¢?
    return abs(x) < EPS ? 0 : x < 0 ? -1 : 1;
}

struct Point { //????????????
    double x, y;
    Point(double x=0.0, double y=0.0) : x(x), y(y) {}
    Point operator + (const Point &rhs) const {  //????????????
        return Point(x + rhs.x, y + rhs.y);
    }
    Point operator - (const Point &rhs) const {  //????????????
        return Point(x - rhs.x, y - rhs.y);
    }
    Point operator * (double p) const {  //???????????\??????
        return Point(x * p, y * p);
    }
    Point operator / (double p) const {  //???????????\??????
        return Point(x / p, y / p);
    }
    bool operator < (const Point &rhs) const {  //??????????????????
        return x < rhs.x || (x == rhs.x && y < rhs.y);
    }
    bool operator == (const Point &rhs) const {  //??????????????????
        return sign(x - rhs.x) == 0 && sign(y - rhs.y) == 0;
    }
    void read() {
        scanf("%lf%lf", &x, &y);
    }
    void print() {
        printf("(%.2f, %.2f)\n", x, y);
    }
};
typedef Point Vector;  //???????????????

double dot(Vector A, Vector B) {  //??????????§???????????????????????§??????????????§??????????????????????????????????????§????
    return A.x * B.x + A.y * B.y;
}
double cross(Vector A, Vector B) {  //??????????§??????????????????????????§???¢???????????¢?§????????????????????????????????????????
    return A.x * B.y - A.y * B.x;
}
double polar_angle(Vector A) {  //??????????§?
    return atan2(A.y, A.x);
}
double length(Vector A) {  //???????????????????§?
    return sqrt(dot(A, A));
}
double angle(Vector A, Vector B) {  //????????¬?§?????????¶??????????§?
    return acos(dot(A, B)/length(A)/length(B));
}
Vector rotate(Vector A, double rad) {  //???????????¬????????¶???
    return Vector(A.x*cos(rad)-A.y*sin(rad), A.x*sin(rad)+A.y*cos(rad));
    //????????´?????¬????????¶????????????????????¢??¬??????x'=xcos(theta)+ysin(theta), y'=ycos(theta)-xsin(theta)
}
Vector normal(Vector A) {  //?????????????????????????????????A????????¶??????
    double len = length(A);
    return Vector(-A.y/len, A.x/len);
}

Point point_line_proj(Point p, Point a, Point b) {  //?????¨??´??????????????±????????????
    Vector V = b - a;
    return a + V * (dot (V, p-a)/dot(V, V));  //???p??°??´???ab????????±
}

int main() {
    Point p1, p2;
    p1.read();
    p2.read();
    int q; scanf("%d", &q);
    while(q --) {
        Point x; 
        x.read();
        Point ans = point_line_proj(x, p1, p2);
        printf("%.9f %.9f\n", ans.x*2-x.x, ans.y*2-x.y);
    }
}

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

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

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


int main() {
    int N;
    cin >> N;
    vector<long double> a(N);

    long double sum = 0;
    rep(i, N) {
        cin >> a[i];
    }

    double x = 0, y = 0;
    x = a[0];
    rep(i, N) {
        x = lcm(x, a[i]);
    }

    rep(i, N) {
        y += x/a[i];
    }

    printf("%.10f\n", x/y);

}


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

int main() {
  int N, t;
  long m;
  m = 0;
  cin >> N;
  vector<int> c(N+2);
  vector<int> y(N+2);
  for (int i = 0; i < N+1; i++){
    cin >> c.at(i);
  }
  for (int i = 0; i < N; i++){
    cin >> y.at(i);
  }
  for (int i = 0; i < N+1; i++){
    if (c.at(i) > y.at(i)){
      m += y.at(i);
    }
    if (c.at(i) <= y.at(i)){
      m += c.at(i);
      t = c.at(i+1) - ( y.at(i) - c.at(i) );
      if (t < 0){
        m += c.at(i+1);
        c.at(i+1) = 0;
      }
      else {
        m += y.at(i) - c.at(i);
        c.at(i+1) = t;
      }
    }
  }
  cout << m << endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;
    vector<vector<int> > d(h, vector<int>(w));
    for(int y=0; y<h; ++y){
        for(int x=0; x<w; ++x){
            cin >> d[y][x];
        }
    }

    vector<vector<int> > a(h, vector<int>(w, 0));
    for(int y=1; y<h-1; ++y){
        for(int x=1; x<w-1; ++x){
            a[y][x] = d[y-1][x-1];
            for(int i=0; i<9; ++i)
                d[y-1+i/3][x-1+i%3] -= a[y][x];
        }
    }

    vector<int> ay, ax;
    for(int y=1; y<h-1; ++y){
        for(int x=1; x<w-1; ++x){
            if(a[y][x] == 0)
                continue;

            int cnt = -a[y][x];
            for(int i=0; i<9; ++i)
                cnt += a[y-1+i/3][x-1+i%3];

            if(cnt < 2){
                ay.push_back(y);
                ax.push_back(x);
            }
        }
    }

    if(ay.size() == 1)
        cout << ay[0] << ' ' << ax[0] << ' ' << ay[0] << ' ' << ax[0] << endl;
    else if(10000 * ay[0] + ax[0] <= 10000 * ay[1] + ax[1])
        cout << ay[1] << ' ' << ax[1] << ' ' << ay[0] << ' ' << ax[0] << endl;
    else
        cout << ay[0] << ' ' << ax[0] << ' ' << ay[1] << ' ' << ax[1] << endl;

    return 0;
}

Measured memory_bytes: 3108
import numpy as np

tmp = input().split(" ")
allItem, trendingItem = int(tmp[0]), int(tmp[1])

votes = input().split(" ")
votesInt = np.asarray([int(s) for s in votes])
votesTotal = np.sum(votesInt)

standard = votesTotal / (4 * trendingItem)

clearList = votesInt[votesInt >= standard]

result = 'Yes' if len(clearList) >= trendingItem else 'No'

print(result)

Measured memory_bytes: 12672
import java.util.*;

public class Main {
	private static String[] cards;

	private static String winner(int player) {
		if(cards[player].length() == 0) {
			switch(player) {
				case 0:
					return "A";
				case 1:
					return "B";
				default:
					return "C";
			}
		} else {
			int nextPlayer;
			switch(cards[player].charAt(0)) {
				case 'a':
					nextPlayer = 0;
					break;
				case 'b':
					nextPlayer = 1;
					break;
				default:
					nextPlayer = 2;
					break;
			}
			cards[player] = cards[player].substring(1, cards[player].length());
			return winner(nextPlayer);
		}
	}

	public static void main(String[] args) {
		cards = new String[3];
		Scanner sc = new Scanner(System.in);
		for(int i = 0; i < 3; i++)
			cards[i] = sc.next();
		System.out.println(winner(0));
	}
}

Measured memory_bytes: 9684
// Aizu Vol-2 0222: Prime Quadruplet
// 2017.8.7 bal4u@uu
// 2017.10.29 retry
//
// From Wekipedia (https://en.wikipedia.org/wiki/Prime_quadruplet)
// All prime quadruplets except {5, 7, 11, 13} are of the form
// {30n + 11, 30n + 13, 30n + 17, 30n + 19} for some integer n.

#include <stdio.h>
#include <stdlib.h>

#define MAX  10000000
#define SQRT 3162     // sqrt(MAX)
char prime[MAX+2], *pmax = prime+MAX, *p, *q;
char buf[15];

//int getid(int n) { return ((n-19)/30)*30+19; }
#define  getid(n) ((((n)-19)/30)*30+19)

int main()
{
	int n;
	int k;

	for (k = 3, p = prime + 3; k <= SQRT; k += 2, p += 2) {
		if (!*p) {
			for (q = p + k; q <= pmax; q += k) *q = 1;
		}
	}
	while (fgets(buf, 12, stdin) && *buf != '0') {
		n = atoi(buf);
		if (n < 19) { puts("13"); continue; }
		for (n = getid(n); ; n -= 30) {
			if (!prime[n] && !prime[n - 2] && !prime[n - 6] && !prime[n - 8]) {
				printf("%d\n", n);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 11488
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>
#include <set>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x)
#define PUT(x) printf("%d\n",x)
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

int main(void) {

	int n;

	cin >> n;

	cout << (n >= 1000 ? "ABD" : "ABC") << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
    */
int main(){
    string S ;
    cin >> S;
    if(S.substr(0,4) == "YAKI" && S.size() >= 4)cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

//------------------------- DEBUGGING -----------------------------------------------------------------------
#ifdef DEBUG
#define debug( args... ) { vector<string> _v = split( #args, ','); err( _v.begin(), args); cerr << '\n'; }
vector<string> split( const string& s, char c) {
    vector<string> v;
    stringstream ss( s);
    string x;
    while ( getline( ss, x, c))
        v.emplace_back( x);
    return move( v);
}
void err( vector<string>::iterator it) { }
template<typename T, typename... Args>
void err( vector<string>::iterator it, T a, Args... args) {
    cerr << it -> substr( ( *it)[0] == ' ', it -> length()) << " = " << a << '\t';
    err( ++it, args...);
}
#else
#define debug(...)
#endif
//------------------------ MACROS ----------------------------------------------------------------------------

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define fr(i,j,k) for(i = j; i < (k); i++)
#define bck(i,j,k) for(i = j; i > (k); i--)
#define all(x) x.begin(), x.end()
#define el '\n'

typedef long long int ll;
typedef long double DO;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
//---------------------------  TEMPLATE ENDS, MAKE CHANGES FROM HERE ----------------------------------------

const int mod = 1e9+7;
const ll inf = 2e18;
const DO eps = 1e-9;
const int NN = 1e5 + 2;

vvi adj;
int ar[NN];

void solve(){
    int i = 0, j = 0, k = 0, n = 0, m = 0;
    cin >>  n >> m;
    for(i = 1; (ll)i*i <= m; i++) {
        if(m%i == 0) {
            if(m/i >= n) {
                k = max(k, i);
            } 
            j = m/i;
            if(m/j >= n){
            	k = max(k, j);
            }
        }
    }
    
        cout << k << el;
    
}

int main(){
#ifndef DEBUG
    ios::sync_with_stdio(false); cin.tie(0); 
#endif
    int T = 1, tc;
    for(tc = 1; tc <= T; tc++){
        solve();
    }
    return 0;
}



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

using namespace std;

#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

// ???/????????????
struct Point {
  double x, y;
  Point(double x = 0.0, double y = 0.0):x(x), y(y){}

  Point operator + (Point p) { return Point(x + p.x, y + p.y); }
  Point operator - (Point p) { return Point(x - p.x, y - p.y); }
  Point operator * (double a) { return Point(x * a, y * a); }
  Point operator / (double a) { return Point(x / a, y / a); }

  double abs() { return sqrt(norm()); }
  double norm() { return x*x + y*y; }

  bool operator < (const Point& p) const {
    return x != p.x ? x < p.x : y < p.y;
  }
  bool operator == (const Point& p) const {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }
};
typedef Point Vector;

// ??????/??´???
struct Segment {
  Point p1, p2;
};
typedef Segment Line;

// ?????????????????????
double dot(Vector a, Vector b)
{
  return a.x*b.x + a.y*b.y;
}
// ??????????????????????????§??????
double cross(Vector a, Vector b)
{
  return a.x*b.y - a.y*b.x;
}
// ??´?????????
bool isOrthogonal(Vector a, Vector b)
{
  return equals(dot(a, b), 0.0);
}
bool isOrthogonal(Point a1, Point a2, Point b1, Point b2)
{
  return isOrthogonal(a1 - a2, b1 - b2);
}
bool isOrthogonal(Segment s1, Segment s2)
{
  return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}
// ????????????
bool isParallel(Vector a, Vector b)
{
  return equals(cross(a, b), 0.0);
}
bool isParallel(Point a1, Point a2, Point b1, Point b2)
{
  return isParallel(a1 - a2, b1 - b2);
}
bool isParallel(Segment s1, Segment s2)
{
  return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

int main()
{
  int q; cin >> q;
  while(q--) {
    Point p[4];
    for(int i = 0; i < 4; i++) cin >> p[i].x >> p[i].y;
    if(isParallel(p[0], p[1], p[2], p[3])) cout << 2 << endl;
    else if(isOrthogonal(p[0], p[1], p[2], p[3])) cout << 1 << endl;
    else cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define inf 1e9
#define maxn 200005
int n,cnt;
int p[maxn];
pair<int,int> best[maxn];
pair<int,int> tree[2][4*maxn];
vector<pair<int,int> > a[maxn];
map<int,map<int,int> > num;
struct node {
    int x,y;
    node(int _x = 0,int _y = 0) {
        x = _x; y = _y;
    }
    bool operator < (node a) const {
        return best[num[a.x][a.y]] < best[num[x][y]];
    }
};
priority_queue<node> heap;
void build(int num,int pos,int l,int r) {
    if(l>r) return ;
    if(l==r) {
        tree[num][pos] = {inf,0};
        return ;
    }
    int mid = (l+r)/2;
    build(num,pos<<1,l,mid); build(num,pos<<1|1,mid+1,r);
    tree[num][pos] = min(tree[num][pos<<1],tree[num][pos<<1|1]);
}
void update(int num,int pos,int l,int r,int x,int val) {
    if(l>r || l>x || r<x) return ;
    if(l==r) {
        tree[num][pos] = {val,x};
        return ;
    }
    int mid = (l+r)/2;
    update(num,pos<<1,l,mid,x,val); update(num,pos<<1|1,mid+1,r,x,val);
    tree[num][pos] = min(tree[num][pos<<1],tree[num][pos<<1|1]);
}
pair<int,int> query(int num,int pos,int l,int r,int x,int y) {
    if(l>r || r<x || y<l) return {inf,0};
    if(x<=l && r<=y) return tree[num][pos];
    int mid = (l+r)/2;
    return min(query(num,pos<<1,l,mid,x,y), query(num,pos<<1|1,mid+1,r,x,y));
}
void f(int l,int r) {
//    printf("F %d %d\n",l,r);
    int i,x,y;
    pair<int,int> t1,t2;
    t1 = query(l&1,1,1,n,l,r);
    x = t1.Y;
    t2 = query(!(l&1),1,1,n,x,r);
    y = t2.Y;
    num[l][r] = cnt++;
    best[num[l][r]] = {p[x],p[y]};
    if(l<=x-1) f(l,x-1), a[num[l][r]].push_back({l,x-1});
    if(y+1<=r) f(y+1,r), a[num[l][r]].push_back({y+1,r});
    if(x+1<=y-1) f(x+1,y-1), a[num[l][r]].push_back({x+1,y-1});
}
main() {
    int i,x,y,cur;
    scanf("%d",&n);
    build(0,1,1,n); build(1,1,1,n);
    for(i=1;i<=n;i++) scanf("%d",&p[i]), update(i&1,1,1,n,i,p[i]);
    f(1,n);
    heap.push(node(1,n));
    while(!heap.empty()) {
        x = heap.top().x; y = heap.top().y; heap.pop();
        cur = num[x][y];
        printf("%d %d ",best[cur].X,best[cur].Y);
        for(i=0;i<a[cur].size();i++) heap.push(node(a[cur][i].X,a[cur][i].Y));
    }
}


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

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

    char maze[n+1][m+1];
    int col[n+1][m+1], row[n+1][m+1];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> maze[i][j];
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (maze[i][j] == '#') continue;
            int start = j, end = j;
            for (int k = j + 1; k < m && maze[i][k] == '.'; k++) {
                end = k;
            }
            for (int k = start; k <= end; k++) {
                row[i][k] = (end - start + 1);
            }
            j = end;
        }
    }


    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
            if (maze[j][i] == '#') {
                continue;
            }
            int start = j, end = j;
            for (int k = j + 1; k < n && maze[k][i] == '.'; k++) {
                end = k;
            }
            for (int k = start; k <= end; k++) {
                col[k][i] = (end - start + 1);
            }
            j = end;
        }
    }


    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (maze[i][j] == '.') {
                ans = max(ans, row[i][j] + col[i][j] - 1);
            }
        }
    }
    cout << ans << endl;
}

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

int main(){
    int n;
    scanf("%d", &n);
    long ar[n];
    long sum=0;
    for(int i=0; i<n; i++) { scanf("%ld", &ar[i]); sum+=ar[i];}
    int m;
    scanf("%d", &m);
    long x, y;
    for(int i=0; i<m; i++){
        scanf("%ld %ld", &x, &y);
        printf("%ld\n", sum-ar[x-1]+y);
    }
    return 0;
}


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

const ll logx=30;
const ll N=4e5+5;
const ll M=3e5+5;
const ll mod=1e9+7;
const ll INF=1e18+5;
const double PI = 3.14159265358979323846;

#define ints(n) scanf("%d",&n)
#define intp(n) printf("%d\n",n)
#define longs(n) scanf("%intd",&n)
#define longp(n) printf("%intd\n",n)

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }

#define f first
#define s second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcount(x)
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define ms(dp,val) memset(dp,val,sizeof(dp))
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
template<typename T> T power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1ll;x=(x*x)%m;}return ans%m;}

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

int main()
{
  ll n;
  string s;
  cin>>s;
  n=s.length();
  ll cnt=0,cntx=0;
  for(ll i=0;i<n;i++)
  {
    if(i%2&&s[i]!='0'){cnt++;}
    if(i%2==0&&s[i]!='1'){cnt++;}
  }
  for(ll i=0;i<n;i++)
  {
    if(i%2&&s[i]!='1'){cntx++;}
    if(i%2==0&&s[i]!='0'){cntx++;}
  }
  cout<<min(cnt,cntx)<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define  rep(i,n) for(li i = 0; i < (n); ++i)
#define  red(i,n) for(li i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
using namespace std;
using li = long long;
using ul = unsigned long long;
using vi = vector<li>;
using vs = vector<string>;
inline ul gcd(ul a,ul b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;


int main()
{
    string s;
    cin>>s;
    if(s[1]==s[2] && (s[1]==s[0]||s[1]==s[3]) ) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    int h = n/100;
    if(h < 5) cout << "9";
    else cout << "1";
    n -= h*100;
    h = n/10;
    if(h < 5) cout << "9";
    else cout << "1";
    n -= h*10;
    h = n;
    if(h < 5) cout << "9";
    else cout << "1";
    cout << endl;
}

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

int main(){
	int n, a[101], m = 0;
	fill(a, a+101, 0);
	for(int i = 0;cin >> n;i++){
		if(!n)break;
		a[n]++;
		if(a[n] > m)m = a[n];
	}
	for(int i = 0;i < 101;i++)if(a[i] == m)cout << i << endl;
	return 0; 
}

Measured memory_bytes: 3068
#include <stdio.h>
#define FIELD(y, x) ((y) >= 0 && (x) >= 0 ? field[y][x] : 0)
#define SIZE 5

int field[SIZE][SIZE];

int main(void)
{
    int n, x, y, x2, y2, max, t1, t2;

    scanf("%d", &n);

    while(n--)
    {
        for(y = 0; y < SIZE; y++)
            for(x = 0; x < SIZE; x++)
                scanf("%d", &field[y][x]);

        /* top -> bottom */
        for(y = 1; y < SIZE; y++)
            for(x = 0; x < SIZE; x++)
                field[y][x] += field[y - 1][x];

        /* left -> right */
        for(x = 1; x < SIZE; x++)
            for(y = 0; y < SIZE; y++)
                field[y][x] += field[y][x - 1];

        /* search */
        max = 0;
        for(x = 0; x < SIZE; x++)
            for(y = 0; y < SIZE; y++)
                for(y2 = y; y2 < SIZE; y2++)
                    for(x2 = x; x2 < SIZE; x2++)
                    {
                        t1 = (x2 - x + 1) * (y2 - y + 1);
                        t2 = field[y2][x2]
                             - FIELD(y - 1, x2)
                             - FIELD(y2, x - 1)
                             + FIELD(y - 1, x - 1);
                        if(t2 == t1 && (max < t1)) max = t1;
                    }

        printf("%d\n", max);
    }

    return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
    int x = 0;
    while (scanf("%d", &x) == 1) {
        if (x >= 30) {
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    }
    return 0;
}

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

int main()
{
    string str;
    int flag = 0;
    cin >> str;
    for (int i = 0; i < str.size()-1;i++){
        for (int j = i + 1; j < str.size(); j++){
            if(str.at(i)==str.at(j)){
                flag=1;
                //cout << flag << endl;
            }

        }
    }
    if(flag==1){
        cout << "no" << endl;
    }
    else{
        cout << "yes" << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD=1000000007;
long long mod_pow(long long x,long long y){//x^yを返す//計算量は0(log(y))
  long long tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
int main(){
    string L;
    cin>>L;
    long long ans=0;
    int a=L.size();
    int last1=a,count=0;
    for(int i=0;i<a;i++){
        if(i==0){
            ans=mod_pow(3,a-i-1);
            last1=i;
            count++;
        }
        else{
            /*
            if(L.at(i)=='1' && last1==i-1){
                last1=i;
                ans*=3;
                ans%=MOD;
            }
            */
            if(L.at(i)=='1'){
                ans+=mod_pow(2,count)*mod_pow(3,a-i-1);
                ans%=MOD;
                last1=i;
                count++;
            }
        }
        //cout<<i<<" "<<ans<<endl;
    }
    ans+=mod_pow(2,count);
    ans%=MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 3736
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;


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

	cin >> N >> K;
	vector<vector<long long int>>box(N, vector<long long int>(N, MOD));
	for (auto &i : box[0])cin >> i;
	for (int i = 1; i < N; i++) {
		for (int j = 0; j < N; j++) {
			box[i][(j + i) % N] = min(box[i - 1][(j + i) % N], box[0][j]);
		}
	}
	long long int ans = MOD * MOD;
	for (int i = 0; i < N; i++) {
		ans = min(ans, accumulate(box[i].begin(), box[i].end(), 0LL) + K * i);
	}
	cout << ans << endl;
	return 0;
}

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

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

P f_l_num( int x ){
	int l = x % 10;
	int f = x / (pow( 10 , ( int )floor( log10( x ) ) ) );
	return P( f , l );
}

int main(){
	long long n;
	long long ans = 0;
	
	cin>>n;
	
	map < P , int > frq;
	
	for( int i = 1 ; i <= n ; i++ ){
		frq[ f_l_num( i ) ]++;
	}
	
	for( int i = 1 ; i <= n ; i++ ){
		P p = f_l_num( i );
		P q(p.second , p.first);
		ans += frq[ q ];
	}
	cout<<ans;
}



Measured memory_bytes: 640
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int compc(const void *a, const void *b){return *(char*)a-*(char*)b;}
int comps(const void *a, const void *b){return strcmp(a, b);}

int main(void){
	int n, i;
	char s[100000][11];
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%s", s[i]);
		qsort(s[i], 10, 1, compc);
	}
	qsort(s, n, 11, comps);
	long ans=0;
	int len=1;
	for(i=0; i<n-1; i++){
		if(strcmp(s[i], s[i+1])==0){
			len++;
		}else{
			ans+=((long)len)*(len-1)/2;
			len=1;
		}
	}
	ans+=((long)len)*(len-1)/2;
	printf("%ld\n", ans);
}


Measured memory_bytes: 2300
#include<stdio.h>
#include<algorithm>
using namespace std;
int a[4];
int main()
{
    int i,sum=0;
    for(i=0;i<3;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+3);
    sum=a[0]+a[1];
    printf("%d\n",sum);

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int s[n],t[n];
  int i;
  for(i=0;i<n;i++){
    cin >> s[i];
  }
  for(i=0;i<n;i++){
    cin >> t[i];
  }
  int sum=0;
  for(i=0;i<n;i++){
    if(s[i]>t[i]){
      sum+=s[i]-t[i];
    }
  }
  cout << sum;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int m = sc.nextInt();
        int l = sc.nextInt();
        
        long[][] a = new long[n][m];
        long[][] b = new long[m][l];
        long[][] c = new long[n][l];
        
        for(int i=0; i < n; i++){
            for(int j=0; j < m; j++){
                a[i][j] = sc.nextInt();
            }
        }
        
        for(int i=0; i < m; i++){
            for(int j=0; j < l; j++){
                b[i][j] = sc.nextInt();
            }
        }
        
        for(int k=0; k<m; k++){
           for(int i=0; i<n; i++){
               for(int j=0; j<l; j++){
                    c[i][j] += a[i][k] * b[k][j];
               }
            } 
        }
        
       for(int i=0; i<n; i++){
               for(int j=0; j<l; j++){
                    System.out.print(c[i][j]);
                    if(j != l-1) System.out.print(" ");
               }
               System.out.println();
            }
        
    }
}



Measured memory_bytes: 52900
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <string>
#include <utility>
#include <iomanip>
#include <queue>
#include <algorithm>
#include<set>
#include<unordered_set>
using namespace std;
int root(int a);
bool is_same_set(int a,int b);
void unite(int a,int b);
int P[100001];
int main()
{
    int n,m;
    cin >> n >> m;
    
    for(int i=0;i<n;i++){
        P[i]=i;
    }
    int x,y,z;
    for(int i=0;i<m;i++){
        cin >> x >> y >> z;
        x--;y--;
        unite(x,y);
    }
    unordered_set<int> shima;
    for(int i=0;i<n;i++){
        shima.insert(root(P[i]));
    }
    cout << shima.size() << endl;

}
int root(int a){
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a)==root(b);
}
void unite(int a,int b){
    if(!is_same_set(a,b)) P[root(a)]=root(b);
}

Measured memory_bytes: 7172
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
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;
}

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

signed main(){
    int n;cin>>n;
    int a[n+1];
    REP(i,n+1)cin>>a[i];
  	if(n==0&&a[0]==1){
      	cout<<1<<endl;
		return 0;
    }
    if((n==0&&a[0]!=1)||(n!=0&&a[0]!=0)){
        cout<<-1<<endl;
        return 0;
    }
    vector<int> lx(n+1,0),ly(n+1,0),rx(n+1,0),ry(n+1,0);
    lx[0]=1;
    ly[0]=1;
    REPS(i,n){
        lx[i]=ly[i-1]*2;
        if(lx[i]>1e16)lx[i]=INF;
        ly[i]=lx[i]-a[i];
        if(ly[i]<0){
            cout<<-1<<endl;
            return 0;
        }
    }
    rx[n]=a[n];
    ry[n]=0;
    for(int i=n-1;i>=0;i--){
        ry[i]=rx[i+1];
        rx[i]=ry[i]+a[i];
    }
    int ans=-1;
    for(int i=n-1;i>=0;i--){
        if(ly[i]<=rx[i+1]&&ly[i]*2>=rx[i+1]){
            int sum=0;
            REP(j,i+1) sum+=lx[j];
            for(int j=i+1;j<=n;j++)sum+=rx[j];   
            chmax(ans,sum);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 7144
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String ans="No";
		boolean f=false;
	//	List<String> S=new ArrayList<String>();
	//	List<String> T=new ArrayList<String>();
		
		String[] S= sc.nextLine().split("");
		String[] T =sc.nextLine().split("");
		
		for(int i=0;i<S.length;i++){
			for(int k=0;k<S.length;k++){
				int a=k+i;
				if(! (a<S.length)){
					a=k+i-S.length;
				}
				if(!((S[a].equals(T[k]))))break;
				if(k==S.length-1){
					ans="Yes";
					f=true;
					break;
				}
			}
			if(f)break;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;*/
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define S second
#define F first
#define vi vector<ll>
#define pii pair<ll,ll>
#define bc __builtin_popcountll
#define vvi vector<vi> 
#define vpii vector<pair<ll,ll>>
#define mll unordered_map<ll,ll>
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define fo(i,a,b) for(i=a;i<=b;i++)
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define fb1(i,n) for(ll i=n;i>0;i--)
#define endd cout<<'\n';
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define all(x) x.begin(), x.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
//*X.find_by_order()-->returns an iterator to the k-th largest element (counting from zero)
//X.order_of_key()-->the number of items in a set that are strictly smaller than our item.
struct cmp
{
	bool operator() (ll a,ll b){
		return (a>b);
	}
};
ll ceil(const ll &a, const ll &b)
{
    if(a%b == 0)
        return a/b;
    return a/b +1;
}
ll mod=1000000007;
const ll N=100005;
int main()
{
fast;
    ll n;
    cin>>n;
    ll c=0;
    ll ma=0;
    f(i,n)
    {
        ll x,y;
        cin>>x>>y;
        if(x==y)
        {
            c++;
        }
        else
        {
            ma=max(ma,c);
            c=0;
        }
    }
    ma=max(ma,c);
    if(ma>=3)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

Measured memory_bytes: 3632