akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>

using namespace std;

typedef long long ll;
typedef long double ld;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep1(i,n) for(int i=1; i<=(int)(n); i++)
#define all(c) c.begin(),c.end()
#define psb push_back
#define ppb pop_back

const int I_INF = 1001001001;
const ll LL_INF = 1001001001001001001;
const ld EPS = 0.001;

int main() {
    int X,Y;
    cin >> X >> Y;

    int s = 4*X;
    int s2 = 2*X;
    if ((Y <= s && Y >= s2) && Y%2 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3620
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Integer> x = new ArrayList<>();
        ArrayList<Integer> xx = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int tmp = sc.nextInt();
            x.add(tmp);
            xx.add(tmp);
        }
        Collections.sort(xx);
        int r = xx.get(n / 2 - 1);
        int l = xx.get(n / 2);
        for (int i = 0; i < n; i++) {
            int ans = 0;
            int tmp = x.get(i);
            if(tmp <= r) {
                ans = l;
            } else {
                ans = r;
            }
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 71468
#include <stdio.h>
#include <string>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;

static const int MAX = 100000;

int r;
char S[MAX];
string s;

int count(string s) {
    int cnt01 = 0, cnt10 = 0;

    for ( int i = 0; i < s.size(); i++ ) {
        if ( atoi(s.substr(i, 1).c_str()) % 2 == i % 2 ) {
            cnt01++;
        } else {
            cnt10++;
        }
    }
    
    return min(cnt01, cnt10);
}

int main() {
    scanf("%s", S);
    s = S;
    r = count(s);
    printf("%d\n", r);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}

signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    cin >> A;
    int x = 0;
    rep(i, N) {
        if (i % 2) x -= A[i];
        else x += A[i];
    }
    vector<int> ans(N);
    ans[0] = x / 2;
    rep(i, N - 1) {
        ans[i + 1] = A[i] - ans[i];
    }
    rep(i, N) printf("%lld%c", ans[i] * 2, i == N - 1 ? '\n' : ' ');
}



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

int main(){
    int n,k;
    cin>>n>>k;
    int a[n];
    const long long INF=1LL<<60;
    long long dp[n];
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)dp[i]=INF;
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=1;j<=k;j++){
            if(i+j>=n)continue;
            dp[i+j]=min(dp[i+j],dp[i]+abs(a[i]-a[i+j]));
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

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

const int MaxN = 8 + 2;
const int INF = 0x7F7F7F7F;

int N, k1, k2, k3;
int ans;
int A[MaxN];
bool have[MaxN];
int bel[MaxN];

void init() {
  scanf("%d", &N);
  scanf("%d %d %d", &k1, &k2, &k3);
  for (int i = 1; i <= N; ++i) scanf("%d", &A[i]);
  ans = INF;
}

inline void getsum(int a1, int a2, int a3) {
  int cost = 0;
  for (int i = 1; i <= N; ++i) {
    if (have[i] == true) continue;
    if (bel[i] == 1) a1 += A[i];
    if (bel[i] == 2) a2 += A[i];
    if (bel[i] == 3) a3 += A[i];
    if (bel[i] != 0) cost += 10;
  }
  cost += abs(a1 - k1) + abs(a2 - k2) + abs(a3 - k3);
  ans = min(ans, cost);
}

void dfs(int u, int a1, int a2, int a3) {
  if (u > N) {
    getsum(a1, a2, a3);
    return;
  }
  if (have[u] == true) dfs(u + 1, a1, a2, a3);
  for (int i = 0; i <= 3; ++i) {
    bel[u] = i;
    dfs(u + 1, a1, a2, a3);
    bel[u] = 0;
  }
}

void calc(int x, int y, int z) {
  memset(have, false, sizeof have);
  have[x] = have[y] = have[z] = true;
  dfs(1, A[x], A[y], A[z]);
}

void solve() {
  for (int i = 1; i <= N; ++i) for (int j = 1; j <= N; ++j) for (int k = 1; k <= N; ++k) {
    if (i == j || j == k || i == k) continue;
    calc(i, j, k);
  }
  cout << ans << endl;
}

int main() {
  init();
  solve();
  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++)
typedef long long ll;
/////////////////////////////////
int main()
{
    int n, d;
    cin >> n >> d;
    vector<vector<int>> x(n, vector<int>(d));
    rep(i, n) rep(j, d) cin >> x[i][j];
    int ans = 0;
    for (int i = 0; i < n - 1; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            int dis = 0;
            int cnt = 1;
            for (int k = 0; k < d; k++)
            {
                dis += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            while (dis >= cnt * cnt)
            {
                if (dis == cnt * cnt)
                    ans++;
                cnt++;
            }
        }
    }
    cout << ans << endl;
}

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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0);

signed main () {
  cin.tie(0);
  cout << setprecision(10);

  string s, t; cin >> s >> t;

  map<char, char> a;
  map<char, char> b;

  REP(i, s.size()) {
    a[s[i]] = t[i];
    b[t[i]] = s[i];
  }

  REP(i, s.size()) {
    if(a[s[i]] != t[i] || b[t[i]] != s[i]) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  
}


Measured memory_bytes: 776
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int a;
		int sum = 0, square = 0;
		for (int i = 0; i < N; i++) {
			a = sc.nextInt();
			sum += a;
			square += a * a;
		}

		int min = Integer.MAX_VALUE;
		for (int i = -100; i <= 100; i++) {
			if (min > square + N * i * i - 2 * sum * i) {
				min = square + N * i * i - 2 * sum * i;
			}
		}

		System.out.println(min);

		sc.close();

	}
}


Measured memory_bytes: 21844
import Data.List

factorize :: Integral a => a -> [(a, Int)]
factorize n = [(x, length xs) | xs@(x : _) <- group $ factorize' n]

factorize' :: Integral a => a -> [a]
factorize' 1 = []
factorize' n = loop n divs
  where
    divs = 2 : 3 : (concat [[x, x + 2] | x <- [5, 11 ..]])
    loop n ps@(p : ps')
      | p * p > n    = [n]
      | rem n p == 0 = p : loop (div n p) ps
      | otherwise    = loop n ps'

phi :: Integral a => a -> a
phi n = product [p^(i - 1) * (p - 1) | (p, i) <- factorize n]

main :: IO ()
main = do
  n <- getLine
  print $ phi (read n)



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

// #define set unordered_set
// #define map unordered_map

using namespace std;

class UnionFind {
private:
	int size;
	int parent[40000];
	int rank[40000];

public:
	UnionFind() {}
	UnionFind(int sz) {
		init(sz);
	}
	void init(int sz) {
		size = sz;
		fill(rank, rank+sz, 0);
		for (int i = 0; i < sz; ++i) {
			parent[i] = i;
		}
	}
	int root(int n) {
		if (parent[n] == n) return n;
		return parent[n] = root(parent[n]);
	}
	void unite(int n, int m) {
		int x = root(n);
		int y = root(m);
		if (x == y) return;

		if (rank[x] < rank[y]) {
			parent[x] = y;
		}
		else if (rank[x] > rank[y]) {
			parent[y] = x;
		}
		else {
			parent[x] = y;
			++rank[y];
		}
	}
	bool isUnited(int n, int m) {
		return root(n) == root(m);
	}
};


typedef pair<int, int> P;

struct Query {
	int type, u, v;
};

typedef vector< set<int> > Graph;

const int bucket = 50;

map<int, int> make_table(set<P>& use) {
	map<int, int> res;
	set<int> s;
	for (P p : use) {
		s.insert(p.first);
		s.insert(p.second);
	}
	int n = 0;
	for (int v : s) {
		res[v] = n++;
	}
	return res;
}
Graph trim(Graph& G, set<P>& use, map<int, int>& tbl) {
	tbl = make_table(use);

	int i = 0;
	Graph res(tbl.size());
	UnionFind uf(G.size());
	for (int i = 0; i < G.size(); ++i) {
		for (int v : G[i]) {
			if ( !use.count( P(i, v) ) ) {
				uf.unite(i, v);
			}
		}
	}
	for (P p1 : tbl) {
		for (P p2 : tbl) {
			int a = p1.first, b = p2.first;
			if ( uf.isUnited(a, b) ) {
				tbl[a] = tbl[b];
			}
		}
	}
	for (P p1 : tbl) {
		for (P p2 : tbl) {
			int a = p1.first, b = p2.first;
			if ( G[b].count(a) ) {
				res[tbl[b]].insert(tbl[a]);
			}
		}
	}
	return res;
}
void unite(Graph& G, int u, int v) {
	G[u].insert(v);
	G[v].insert(u);
}
void remove(Graph& G, int u, int v) {
	G[u].erase(v);
	G[v].erase(u);
}
bool judge(Graph& G, int v, int t, vector<bool>& reached) {
	if (v == t) return true;
	reached[v] = true;
	for (int to : G[v]) {
		if ( !reached[to] ) {
			if ( judge(G, to, t, reached) ) return true;
		}
	}
	return false;
}
bool judge(Graph& G, int s, int t) {
	vector<bool> reached(G.size(), false);
	return judge(G, s, t, reached);
}

set<P> Use[40000/bucket+1];
int main() {
	int N, M; cin >> N >> M;
	Query Q[40000];
	for (int i = 0; i < M; ++i) {
		int t, u, v; scanf("%d%d%d", &t, &u, &v);
		Q[i] = (Query){t, u, v};
	}
	for (int i = 0; i < M; ++i) {
		int type = Q[i].type, u = Q[i].u, v = Q[i].v;
		Use[i/bucket].insert( P(u, v) );
		Use[i/bucket].insert( P(v, u) );
	}
	Graph G(N);
	Graph g;
	map<int, int> tbl;
	for (int i = 0; i < M; ++i) {
		int type = Q[i].type, u = Q[i].u, v = Q[i].v;
		if (i % bucket == 0) {
			g = trim(G, Use[i/bucket], tbl);
		}
		switch (type) {
		case 1: // unite
			unite(G, u, v);
			unite(g, tbl[u], tbl[v]);
			break;
		case 2: // remove
			remove(G, u, v);
			remove(g, tbl[u], tbl[v]);
			break;
		case 3: // judge
			if ( judge(g, tbl[u], tbl[v]) ) {
				cout << "YES" << endl;
			}
			else {
				cout << "NO" << endl;
			}
			break;
		}
	}
}

Measured memory_bytes: 11812
#include <cstdio>

#define MAXN 100000

int v[MAXN+1];

int main(){
    int n, l;
    scanf("%d%d", &n, &l);

    for(int i=1; i<=n; i++)
        scanf("%d", &v[i]);

    int p=0;
    for(int i=1; i<n; i++)
        if(v[i]+v[i+1]>=l)
            p=i;

    if(p==0) printf("Impossible\n");
    else{
        printf("Possible\n");
        for(int i=1; i<p; i++)
            printf("%d\n", i);
        for(int i=n-1; i>=p; i--)
            printf("%d\n", i);
    }

    return 0;
}


Measured memory_bytes: 1152
def binarysearch(A,key):
    left=0
    right=n
    while left<right:
        mid=(left+right)//2
        if A[mid]==key:
            return mid
        elif key<A[mid]:
            right=mid
        else:
            left=mid+1
    return None

n=int(input())
S = list(map(int, input().split()))
q=int(input())
T = list(map(int, input().split()))

ans=0
for t in T:
    # print(binarysearch(S,t))
    if type(binarysearch(S,t))==int:
        ans+=1
    
print(ans)


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

int main(){
  ll n,m,ans,wa,i,b;
  cin >> n >> m;
  ll w[n];
  wa=0;
  ans=0;
  for(i=0;i<=n;i++){
    w[i]=0;
  }
  string c;
  for(i=0;i<m;i++){
    cin >> b >> c;
    if(w[b]!=-1){
      if(c=="WA"){
        w[b]+=1;
      }
      if(c=="AC"){
        wa+=w[b];
        w[b]=-1;
        ans+=1;
      }
    }
  }
  cout << ans << " " << wa;
}

Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Security.Cryptography.X509Certificates;

namespace _0815
{
    class Program
    {
        static long[] a;
        static long n, q;
        static void Main(string[] args)
        {
            n = long.Parse(Console.ReadLine());
            a = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            q = long.Parse(Console.ReadLine());

            Solution();
            //Console.WriteLine(result);
        }

        static void Solution()
        {
            long[] table = new long[100001];
            long[] ans = new long[q];
            foreach(long num in a)
            {
                table[num]++;
            }
            long sum = a.Sum();

            for (int i = 0; i< q; i++) {
                var bc = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
                sum += (bc[1] - bc[0]) * table[bc[0]];
                table[bc[1]] += table[bc[0]];
                table[bc[0]] = 0;
                ans[i] = sum;
            }

            foreach(long res in ans){
                Console.WriteLine(res);
            }
        }
    }
}


Measured memory_bytes: 51188
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define mod 100000000
#define Fi(n) for(ll i=0;i<n;i++)
#define Fj(n) for(ll j=0;j<n;j++)
#define Fiab(a,b) for(ll i=a;i<b;i++)
#define Fjab(a,b) for(ll j=a;j<b;j++)
#define sexy ios_base::sync_with_stdio(false);cin.tie(NULL);
#define txti freopen("input.txt", "r", stdin);
#define txto freopen("output.txt", "w", stdout);

bool sortmahstyle(const pair<int,int> &a,  const pair<int,int> &b) 
{ 
   
    if(a.second<b.second)
        return true;
        
    return false;
    
} 

//ll x[5001],y[26];
int main() {
sexy    
//txti
//txto
        //ll t =1;
        
        
        ll a,b,c,k;
        cin>>a>>b>>c>>k;
        if(a>=k){
            cout<<k;
            return 0;
        }
        ll ans = a;
        k -= a;
        if(b>=k){
            cout<<ans;
            return 0;
        }

        k -= b;
        if(c>=k){
            cout<<ans - k;
            return 0;
        }
        cout<<ans-c;
        
        
    return 0;
}

Measured memory_bytes: 3600
from fractions import gcd
P = 10**9 + 7
N = 1000001 #使う最大値+1以上にする、値に注意3*10^5とかにしとくと安心
inv = [0] + [1] # 1/x
for i in range(2,N):
  inv += [inv[P % i] * (P - int(P / i)) % P]
n=int(input())
a=list(map(int,input().split()))
lcm=a[0]
mod=10**9+7
for i in range(1,n):
  lcm=(lcm//gcd(lcm,a[i]))*a[i]
ans=0
lcm%=mod
for i in range(n):
  ans=(ans+lcm*inv[a[i]])%mod
print(ans%mod)

Measured memory_bytes: 45752
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
typedef long double ld;
typedef pair<int,int> P;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007;
#define INF 10*60;
#define EPS 1e-9;

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int N;cin>>N; 
  int ans=(N/11)*2;
  N%=11;
  if(N==0){
    print(ans)
    return 0;
  }else{
    ans++;;
    N-=6;
    if(N<=0){
      print(ans)
    }else
    {
      print((++ans))
    }
  }

  
  

}


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

int main() {
	int N; cin >> N;
	bool YYMM = false, MMYY = false;
	if( N <= 1299 && N >= 100 ) MMYY = true;
	if( N%100 <= 12 && N%100 >= 1 ) YYMM = true;
	
	if(YYMM && MMYY) cout << "AMBIGUOUS" << endl;
	else if(YYMM) cout << "YYMM" << endl;
	else if(MMYY) cout << "MMYY" << endl;
	else cout << "NA" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define cps CLOCKS_PER_SEC
#define tests(t) int t; cin >> t; while(t--)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define ll long long
#define ld double
#define eb emplace_back
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define fi first
#define se second
#define bitcount(x) __builtin_popcount(x)
#define PI acos(-1.0)
#define EPS 1e-9
#define mod 1000000007

#define par pair<int, int>
#define maxn 200005

using namespace std;
///All indexing is 0-based
using namespace __gnu_pbds;
template<class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
///methods: find_by_order(k); & order_of_key(k);
///To make it an ordered_multiset, use pairs of (value, time_of_insertion)
///to distinguish values which are similar

ll a,b[1000],sol,N;


int main()
{
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> N;

    for(int i=1;i<=N;i++){
       cin >> a;
       for(int j=0;j<=60;j++)
            if((1LL << j) & a)
                b[j]++;
    }

    for(int j=0;j<=60;j++)
        sol = (sol + (1LL << j)%mod * b[j]%mod*(N-b[j])%mod) %mod;

    cout << sol;



}


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

struct num
{
  int v;
  int h;
};

int main()
{
  int h, w;
  cin >> h >> w;
  vector<vector<num>> data(h, vector<num>(w));
  vector<string> board(h);
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      data.at(i).at(j).h = -1;
      data.at(i).at(j).v = -1;
    }
  }
  for (int i = 0; i < h; i++)
  {
    int cnt = 0;
    int from = -1, to = -1;
    for (int j = 0; j < w; j++)
    {
      char c;
      cin >> c;
      board.at(i).push_back(c);
      if (c == '.')
      {
        if (from < 0)
          from = j;
        cnt++;
      }
      else
      {
        to = j;
        if (from >= 0)
        {
          for (int k = from; k < to; k++)
          {
            data.at(i).at(k).h = cnt;
          }
        }
        cnt = 0;
        from = -1;
      }
    }
    if (from >= 0)
    {
      for (int k = from; k < w; k++)
      {
        data.at(i).at(k).h = cnt;
      }
    }
  }
  for (int i = 0; i < w; i++)
  {
    int cnt = 0;
    int from = -1, to = -1;
    for (int j = 0; j < h; j++)
    {
      if (board.at(j).at(i) == '.')
      {
        if (from < 0)
          from = j;
        cnt++;
      }
      else
      {
        if(from>=0){
          to = j;
          for (int k = from; k < to;k++){
            data.at(k).at(i).v = cnt;
          }
          cnt = 0;
          from = -1;
        }
      }
    }
    if(from>=0){
      for (int k = from; k < h;k++){
        data.at(k).at(i).v = cnt;
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < h;i++){
    for (int j = 0; j < w;j++){
      ans = max(ans, data.at(i).at(j).h + data.at(i).at(j).v);
    }
  }
  ans--;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 35712
#include<stdio.h>
int main()
{
	int a,b,i;
	scanf("%d %d",&a,&b);
	if(a>=b){for(i=0;i<a;i++) printf("%d",b);}
	else{for(i=0;i<b;i++) printf("%d",a);}
	return 0;
}

Measured memory_bytes: 1704
#include <bits/stdc++.h>	
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)
#define int long long
 
// random_device rd; mt19937 g(rd());    
                                        	
using namespace std;
using namespace __gnu_pbds;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}
 
template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; 
 
const int mod = (int)1e9 + 7;
const int N = (int)2e5 + 123;
const long long NN = (int)1e18 + 13;
 
int n, d, a;
int x[N], h[N];
pair <int, int> b[N];
int t[N * 40], add[N * 40];
long long L[N * 40], R[N * 40];
int sz = 1;
 
inline void push(int tl, int tr, int v)
{
	if(add[v] == 0) return;
	if(tl != tr)
	{
		add[L[v]] += add[v];
		add[R[v]] += add[v]; 
	}
	t[v] += add[v];
	add[v] = 0;
}
 
void Update(int pos, int val, int tl = -NN, int tr = NN, int v = 1)
{
	push(tl, tr, v);
	if(tl == tr)
	{
		t[v] = val;
		return;
	}	
	int tm = (tl + tr) / 2;
	if(pos <= tm)
	{
		if(!L[v]) L[v] = ++sz;
		Update(pos, val, tl, tm, L[v]);
	}
	else 
	{
		if(!R[v]) R[v] = ++sz;
		Update(pos, val, tm + 1, tr, R[v]);
	}
	t[v] = max(t[L[v]], t[R[v]]);
}
 
int Get(int l, int r, int tl = -NN, int tr = NN, int v = 1)
{
	if(!v || tl > r || l > tr || l > r || tl > tr) return -mod;
	push(tl, tr, v);
	if(l <= tl && tr <= r) return t[v];
	int tm = (tl + tr) / 2;
	return max(Get(l, r, tl, tm, L[v]), Get(l, r, tm + 1, tr, R[v]));
} 
 
void Update_Segment(int l, int r, int val, int tl = -NN, int tr = NN, int v = 1)
{
	push(tl, tr, v);	
	if(l > tr || tl > r) return;
	if(l <= tl && r >= tr)
	{
		add[v] += val;
		push(tl, tr, v);
		return;
	}
	int tm = (tl + tr) / 2;
	Update_Segment(l, r, val, tl, tm, L[v]);
	Update_Segment(l, r, val, tm + 1, tr, R[v]);
	t[v] = max(t[L[v]], t[R[v]]);
}
 
main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif		
	Fast_Read_Out();
	Random();   
	cin >> n >> d >> a;
	for(int i = 1; i <= n; i++) cin >> x[i] >> h[i], Update(x[i], h[i]);
	for(int i = 1; i <= n; i++) b[i] = mp(x[i], h[i]);
	sort(b + 1, b + n + 1);
	int ans = 0;
	for(int i = 1; i <= n; i++)
	{
		int l = b[i].F;
		int r = l + d + d;
		if(Get(l, r) <= 0) continue;
		int must = Get(l, l);
		if(must <= 0) continue;
		ans += must / a + (must % a > 0);
		Update_Segment(l, r, -((must + a - 1) / a * a));
	}
	cout << ans;
}   

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

int main() {
  
  int a, b, c;
  cin >> a >> b >> c;
  
  int ans = 3;
  if (b == a) ans--;
  if (c == a || c == b) ans--;
  
  cout << ans << endl;

}

Measured memory_bytes: 256
def main():
    N,M = map(int,input().split())
    a = [int(input())-1 for _ in N*[0]]
    sum = [N*[0] for _ in 20*[0]]
    cnt = 20*[0]
    ans_bit = 0
    for i in range(N):
        ans_bit = ans_bit | (1<<a[i])
        cnt[a[i]] += 1
        sum[a[i]][i] += 1
        if i-1 >= 0:
            for j in range(20):
                sum[j][i] += sum[j][i-1]
    dp = [10**9]*(1<<20)
    dp[0] = 0
    for bit in range(1<<20):
        if( dp[bit] == 10**9 ):
            continue
        v = 0
        for used in range(20):
            if( (bit>>used) & 1 ):
                v += cnt[used]
        for use in range(20):
            if( cnt[use] == 0 ):
                continue
            if( (bit>>use) & 1 ):
                continue
            w = v + cnt[use]
            not_move = sum[use][w-1]
            if( v-1 >= 0 ):
                not_move -= sum[use][v-1]
            move = cnt[use] - not_move
            dp[bit|(1<<use)] = min(dp[bit|(1<<use)],
                                   dp[bit]+move)
    print(dp[ans_bit])
            

if __name__ == "__main__":
    main()

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

int main() {
  int N;
  cin >> N;
  
  vector<int> players(3 * N, 0);
    
  for (int i = 0; i < 3 * N; i++) cin >> players.at(i);
  
  sort(players.begin(), players.end());
  reverse(players.begin(), players.end());
  
  long long answer = 0;
  
  for (int i = 0; i < 2 * N; i += 2) {
    answer += players.at(i + 1);
  }
  
  cout << answer << endl;
  
  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <set>
using namespace std;


#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }




int N;
vector<int> x;

using pint = pair<int,int>;
vector<int> po; // その場所に制約があるなら、そこに置かれる数、なければ 0
vector<int> con; // con[i] := i 番目の checkpoint についての数

int main() {
    int N; cin >> N;
    x.resize(N); for (int i = 0; i < N; ++i) cin >> x[i], --x[i];
    po.resize(N*N, 0);
    for (int i = 0; i < N; ++i) po[x[i]] = i + 1;
    con.clear();
    for (int i = 0; i < N*N; ++i) if (po[i]) con.push_back(po[i]);
    
    int iter = 0;
    vector<int> num(N+2, 0); // num[i] := 数 i を何個使ったか
    vector<int> res(N*N, 0);
    set<int> alr;
    bool ok = true;
    for (int i = 0; i < N*N; ++i) {
        if (!ok) break;
        if (po[i]) {
            if (num[po[i]] < po[i]-1) { ok = false; break; }
            res[i] = po[i];
            ++num[po[i]];
            alr.insert(po[i]);
        }
        else {
            while (iter < N && num[con[iter]] >= con[iter]-1) ++iter;
            if (iter == N) {
                int canuse = 1;
                while (canuse <= N && (!alr.count(canuse) || num[canuse] == N)) ++canuse;
                if (canuse == N + 1) { ok = false; break; }
                res[i] = canuse;
                ++num[canuse];
            }
            else {
                res[i] = con[iter];
                ++num[con[iter]];
            }
        }
        
        /*
        cout << "-----------------------" << endl;
        COUT(i);
        COUT(res);
        COUT(iter);
        COUT(con[iter]);
        COUT(num);
         */
    }
    
    if (!ok) puts("No");
    else {
        puts("Yes");
        for (int i = 0; i < N*N; ++i) cout << res[i] << " ";
        cout << endl;
    }
}

Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;

LL a[N];
LL sum[N];

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	for (int i = 1; i <= n; ++i) sum[i] = sum[i - 1] + a[i];

	LL minx = 1LL << 60;
	for (int i = 1; i < n; ++i) {
		LL tmp = abs(sum[i] - sum[n] + sum[i]);
		minx = min(minx, tmp);
	}

	cout << minx << endl;
}

Measured memory_bytes: 3328
use proconio::{input, fastout};
use proconio::marker::Chars;
use permutohedron::LexicalPermutation;

#[fastout]
fn main() {
    input! {
        mut s: Chars,
    }

    if s.len() == 26 {
        let mut ok = false;
        for (i, c) in (b'a'..=b'z').rev().map(|c| c as char).enumerate() {
            if s[i] != c {
                ok = true;
                break;
            }
        }
        if !ok {
            println!("-1");
            return;
        }
    }
    if s.len() < 26 {
        let unused = (b'a'..=b'z').map(char::from).filter(|c| !s.contains(c)).collect::<Vec<_>>();
        let add = unused[0];
        
        s.push(add);
        let ans = s.iter().collect::<String>();
        println!("{}", ans);
        return;
    }

    let mut next_s = s.clone();
    let has_next = next_s.next_permutation();

    let mut ans = vec![];

    for (n, o) in next_s.iter().zip(s.iter()) {
        ans.push(n);
        if n != o {
            break;
        }
    }
    let ans = ans.into_iter().collect::<String>();
    println!("{}", ans);
}

Measured memory_bytes: 2184
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] H = new int[N];
		int T = sc.nextInt();
		int A = sc.nextInt();
		int difference = Integer.MAX_VALUE;
		int index = 0;
		for (int i = 0; i < H.length; i++) {
			int input = sc.nextInt();
			int ave = T * 1000 - input * 6;
			H[i] = Math.abs(A * 1000 - ave);
			if (difference > H[i]) {
				difference = H[i];
				index = i + 1;
			}
		}
		System.out.println(index);
		sc.close();
	}
}

Measured memory_bytes: 24148
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int m;
    cin >> m;
    cout << 24 - m + 24;
}


Measured memory_bytes: 3580
import scala.io.StdIn._
object Main extends App{


  val n = readLine.trim.toInt
  val reviews = Array.tabulate(n){i ⇒
    val Array(s, p) = readLine.trim.split(' ')
    (i, s, p.toInt)
  }.sortWith{(a, b) ⇒ if (a._2 == b._2) a._3 > b._3 else a._2 < b._2}

  for ((i, _, _) ← reviews) {
    println(i + 1)
  }
}

Measured memory_bytes: 27076
N = int(input())
r = [[0, 0] for i in range(N)]
b = [[0, 0] for i in range(N)]
for i in range(N):
    r[i][0], r[i][1] = map(int, input().split())
for i in range(N):
    b[i][0], b[i][1] = map(int, input().split())

r.sort(key=lambda x: (x[1]), reverse=True)
b.sort(key=lambda x: (x[0]))
r_flag = [False] * N
b_flag = [False] * N
count = 0

for i in range(N):
    for j in range(N):
        if r[j][0] < b[i][0] and r[j][1] < b[i][1] and not r_flag[j]:
            r_flag[j] = True
            count += 1
            break

print(count)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int sza, szb; cin >> sza >> szb;
  int q; cin >> q;
  vector<ll> a(sza), b(szb);
  for(int i=0;i<sza;++i) {
    cin >> a[i];
  }
  for(int i=0;i<szb;++i) {
    cin >> b[i];
  }
  while(q > 0) {
    q--;
    ll x; cin >> x;
    auto ita = upper_bound(a.begin(), a.end(), x);
    int posa = distance(a.begin(), ita);
    auto itb = upper_bound(b.begin(), b.end(), x);
    int posb = distance(b.begin(), itb);
    ll mi = LINF;
    if(posa != 0 && posb != 0) {
      mi = min(mi, max(x - a[posa-1], x - b[posb-1]));
    }
    if(posa != 0 && posb != szb) {
      mi = min(mi, b[posb] - a[posa-1] + min(x - a[posa-1], b[posb] - x));
    }
    if(posa != sza && posb != 0) {
      mi = min(mi, a[posa] - b[posb-1] + min(a[posa] - x, x - b[posb-1]));
    }
    if(posa != sza && posb != szb) {
      mi = min(mi, max(a[posa] - x, b[posb] - x));
    }
    cout << mi << endl;
  }
}


Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;
static const long long INF = 1<<31;

int ans, n, uu, vv;
int t[100005], a[100005];
vector<int> g[100005];

void bfs(int s, int *p) {
  queue<int> q;
  rep(i, 1, n+1) p[i] = INF; 
  p[s] = 0;
  q.push(s);
  while (!q.empty()) {
    int u = q.front(); q.pop();
    for (int v : g[u]) {
      if (p[v]==INF) {
        p[v] = p[u] + 1;
        q.push(v);
      }
    }
  }

}
 
int main(void) {
    cin >> n >> uu >> vv;
    rep(i, 0, n-1) {
      int a, b;
      scanf("%d %d", &a, &b);
      g[a].pb(b);
      g[b].pb(a);
    }
    
    bfs(uu, t);
    bfs(vv, a);
    
    //int x = -1, mxa = -1;
    int mxa = -1;
    rep(i, 1, n+1) {
      if (t[i]<a[i] && a[i]>mxa) {
        //x = i;
        mxa = a[i];
      }
    }
    
    //ans = t[x] + (a[x] - t[x]) -1;
    ans = mxa - 1;
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6656
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <functional>

bool solve() {
    int n, k;
    std::cin >> n >> k;
    if (n == 0) return false;

    std::vector<std::string> ss(n);
    for (auto& s : ss) std::cin >> s;

    std::set<std::string> ans;
    std::function<void(int, int, std::string)>
        dfs = [&](int rem, int b, std::string s) -> void {
        if (rem == 0) {
            ans.insert(s);
            return;
        }

        for (int i = 0; i < n; ++i) {
            if ((b >> i) & 1) continue;
            dfs(rem - 1, b | (1 << i), s + ss[i]);
        }
    };
    dfs(k, 0, "");

    std::cout << ans.size() << "\n";
    return true;
}

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

    while (solve()) {}

    return 0;
}



Measured memory_bytes: 3388
def mod_pow(a, n, mod):
    """
    二分累乗法による a^n (mod m)の実装
    :param a: 累乗の底
    :param n: 累乗の指数
    :param mod: 法
    :return: a^n (mod m)
    """

    result = 1
    a_n = a
    while n > 0:
        if n & 1:
            result = result * a_n % mod
        a_n = a_n * a_n % mod
        n >>= 1
    return result


MOD = 1000000007

M, N = map(int, input().split(' '))

print(mod_pow(M, N, MOD))



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

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))

typedef long long ll;

int main() {
    int N;
    vector<int> nums, c_nums;
    
    cin1(N);
    
    int n;
    rep(i,N) {
        scnd1(n);
        nums.push_back(n);
        c_nums.push_back(n);
    }
    
    sort( c_nums.begin(), c_nums.end());
    int a = c_nums[N/2-1], b = c_nums[N/2];
    
    if ( a != b) {
        rep(i,N) {
            if ( nums[i] <= a ) {
                prtd1(b);
            } else {
                prtd1(a);
            }
        }
    } else {
        rep(i,N) {
            prtd1(a);
        }
    }
    
}

Measured memory_bytes: 3948
n,m = map(int,input().split())
lis = sorted([list(map(int,input().split())) for _ in range(n)])
su = 0
ans = 0
sa = 0
for i in lis:
    su += i[1]
    if su <= m:
        ans += i[0]*i[1]
        sa += i[1]
    else:
        ans += i[0] * (m-sa)
        break
print(ans)

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

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

  if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
    cout << 0 << endl;
  } else {
    cout << min({a * b, b * c, c * a}) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		int n=scn.nextInt();
		double []arr=new double [n];
		double x=1;
		double sum=0;
		for(int i=0;i<n;i++) {
			arr[i]=scn.nextInt();
			arr[i]=(double)(x/arr[i]);
			sum+=arr[i];
		}
		System.out.println(x/sum);
	}

}


Measured memory_bytes: 21844
S = input().strip()
K = int(input().strip())

unigram = sorted(set(S))

for u in unigram:
  now_subset = set()
  for i,c in enumerate(S):
    if c != u: continue
    for j in range(1,min(K,len(S)-i)+1):
      now_subset.add(S[i:i+j])
  if len(now_subset) < K:
    K -= len(now_subset)
  else:
    print(sorted(now_subset)[K-1])
    exit()
    


Measured memory_bytes: 39536
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
using namespace std;

int r,c;                       //r行c列   1<=r<=10,1<=c<=10000
int a[12][10010];
int b[12][10010];
string s;
int m = 0;

void solve(int i)
{
	if(i == r)
	{
		//cout<<s<<endl;
		int ans = 0;
		for(int i = 1;i <= r;i++)
		{
			if(s[i-1] == '1')
			{
				for(int j = 1;j <= c;j++)
				    b[i][j] = -a[i][j];
			}
			else
			{
				for(int j = 1;j <= c;j++)
				    b[i][j] = a[i][j];
			}
		}
		/*for(int i = 1;i <= r;i++)
		{
			for(int j = 1;j <= c;j++)
			{
				cout<<b[i][j]<<" "; 
			}
			cout<<endl;
		}*/
		for(int i = 1;i <= c;i++)
		{
			int res = 0;
			for(int j = 1;j <= r;j++)
			{
				if(b[j][i] == 1)
				    res++;
			}
			ans = ans + max(res,r - res);
		}
		m = max(m,ans);
		return;
	}
	s.push_back('1');
	solve(i+1);
	s = s.substr(0, s.length() - 1);
    s.push_back('0');
	solve(i+1); 
	s = s.substr(0, s.length() - 1);
}

int main()
{
	while(cin>>r>>c)
	{
		m = 0,s.clear();
		if(r == 0&&c == 0)
		{
			return 0;
		}
		for(int i = 1;i <= r;i++)
		{
			for(int j = 1;j <= c;j++)
			{
				cin>>a[i][j];
				if(a[i][j] == 0)
				    a[i][j] = -1;
			}
		}
		solve(0);
		cout<<m<<endl;
	}
} 


Measured memory_bytes: 3976
#include <iostream>
#include <algorithm>
#define REP(i, a, n) for(int i = a; i < n; i++)
using namespace std;


int n, m;
pair<int, int> cnt[100];
int ans;

bool compare(pair<int, int> a, pair<int, int> b) {
  if(a.second == b.second) {
    return a.first < b.first;
  }
  return a.second > b.second;
}

int main(void) {
  while(cin >> n >> m, !(n == 0 && m == 0)) {
    REP(i, 0, m) {
      cnt[i].first = i;
      cnt[i].second = 0;
    }

    REP(i, 0, n) {
      REP(i, 0, m) {
        cin >> ans;
        if(ans == 1) cnt[i].second++;
      }
    }

    sort(cnt, cnt + m, compare);

    REP(i, 0, m) {
      cout << cnt[i].first + 1;
      if(i + 1 != m) cout << " ";
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1164
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		String s = sc.next();
		
      	if(a >= 3200){
           System.out.println(s);   
        }else{
     	   System.out.println("red");   
        }
    }
}

Measured memory_bytes: 35676
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
      	Scanner sc = new Scanner(System.in);
    	int w = Integer.parseInt(sc.next());
      	int a = Integer.parseInt(sc.next());
      	int b = Integer.parseInt(sc.next());
      	
		int dis = Math.abs(a - b);
      	if (dis >= w) {
        	System.out.println(dis - w);
        } else {
        	System.out.println(0);
        }
    }
}

Measured memory_bytes: 23764
#include<stdio.h>
#include<stdlib.h>
int main(){
  int n,i;
  int *x;
  int minv=0,maxv;

scanf("%d",&n);
if(n<2||n>200000)return 0;

x = (int *)malloc(sizeof(int) * n);

for(i = 0;i<n;i++){
scanf("%d",&x[i]);
if(x[i]<1||x[i]>1000000001)return 0;
}


minv = x[0];
maxv=x[1]-x[0];
for(i=1;i<n;i++) {
  if(maxv<x[i]-minv){
  maxv = x[i]-minv;
}
  if(x[i]<minv){
  minv = x[i];
}
}

printf("%d\n",maxv);

return 0;
}



Measured memory_bytes: 2568
/*     ####   ####  #               ####  #        ##   #    # #    # ###### #####
		  #      #    # #              #      #       #  #  ##  ## ##  ## #      #    #
		   ####  #    # #               ####  #      #    # # ## # # ## # #####  #    #
			   # #  # # #                   # #      ###### #    # #    # #      #####
		  #    # #   #  #              #    # #      #    # #    # #    # #      #   #
		   ####   ### # ###### #######  ####  ###### #    # #    # #    # ###### #    #
	*/
	 
	#include<bits/stdc++.h>
	using namespace std;
	 
	typedef long long LL;
	typedef vector<LL> VLL;
	typedef vector<string> VS;
	typedef vector<pair<LL, LL> > VP;
	 
	 
	#define For(in) for (LL i = 0; i < (n); i++)
	#define FOR(in) for(LL i=1; i <= (n); i++)
	#define pb push_back
	#define sr(v) sort(v.begin(), v.end())
	#define rev(v) reverse(v.begin(), v.end())
	#define uniq(v) v.erase(unique(v.begin(), v.end()), v.end());
	#define exit(); return 0;
	#define no "NO"
	#define yes "YES"
	#define con continue;
	 
	 
	LL concate(LL a, LL b)
	{
		ostringstream os;
		os <<a <<b;
		istringstream is(os.str());
		LL c;
		is>> c;
		return c;
	}
	 
	 
	LL check(char c)
	{
		return c=='a' || c=='e' || c=='i' || c=='o' || c=='u';
	}
	LL mod = 1e9+7;
	 
	 
	int main()
	{
		LL q,t;
		//cin>>t;
		//while(t--)
		//{
		   LL a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,r=0,u=0,w=0,x=0,y=0,z=0;
			LL aa[1000];
			LL flag=0, flag1=0, co=0, co1=0, co2=0, co3=0, x1=0, x2=0, y1=0, y2=0, z1=0, z2=0;
			LL ma=0, mi=100000000;
			LL mid=0, temp=0, stop=0, start=0;
			double pi= 3.141592653589793;
			double d1=0.0, d2, d3, d4;
			VLL v,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10;
			VS vs, vs1, vs2, vs3, vs4;
			VP vp, vp1,vp2;
			char ch, ch1, ch2[1001];
			string str, str1, str2, str3, str4, str5;
			pair<LL, LL> pa;
			list<LL> li, li1;
			map<LL, LL> mp, mp1;
			set<LL> st;
			map<LL ,LL> :: iterator imll;
			VLL :: iterator ivll;
			set<LL> :: iterator isll;
			VP :: iterator ivp;
	 
			
			cin>>w>>a>>b;
			if((b>=a && b<=a+w) || (b+w>=a && b+w<=a+w) )cout<<0<<endl;
			else if(b+w<a)cout<<a-(b+w)<<endl;
			else 
			cout<<b-(a+w)<<endl;
		 //}
	 
		exit()
	 
	 
	}


Measured memory_bytes: 3536
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

// const int64_t kMod = 1000000007LL;
const int64_t kMod = 998244353LL;
struct Mint {
  int64_t value;
  Mint(int64_t value = 0LL) : value((value % kMod + kMod) % kMod) {}
  Mint operator-() const {
    return Mint(-value);
  }
  Mint &operator+=(const Mint rhs) {
    if ((value += rhs.value) >= kMod) {
      value -= kMod;
    }
    return *this;
  }
  Mint &operator-=(const Mint rhs) {
    if ((value += kMod - rhs.value) >= kMod) {
      value -= kMod;
    }
    return *this;
  }
  Mint &operator*=(const Mint rhs) {
    (value *= rhs.value) %= kMod;
    return *this;
  }
  Mint operator+(const Mint rhs) const {
    return Mint(*this) += rhs;
  }
  Mint operator-(const Mint rhs) const {
    return Mint(*this) -= rhs;
  }
  Mint operator*(const Mint rhs) const {
    return Mint(*this) *= rhs;
  }
  Mint Pow(int64_t p) const {
    if (p == 0LL) {
      return 1LL;
    } else if (p < 0LL) {
      return Pow(-p).Pow(kMod - 2LL);
    }
    Mint temp = Pow(p >> 1LL);
    temp *= temp;
    if (p & 1LL) {
      temp *= (*this);
    }
    return temp;
  }
  Mint Inv() const {
    return Pow(kMod - 2LL);
  }
  Mint &operator/=(const Mint a) {
    return *this *= a.Inv();
  }
  Mint operator/(const Mint a) const {
    return Mint(*this) /= a;
  }
};
std::ostream &operator<<(std::ostream &os, const Mint &a) {
  os << a.value;
  return os;
}

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

  int64_t N;
  cin >> N;
  // const int64_t L = static_cast<int64_t>(T.length());
  vector<int64_t> counts(N, 0);
  int64_t max_depth = 0;
  for (int64_t i = 0; i < N; ++i) {
    int64_t d;
    cin >> d;
    if (i == 0 && d != 0) {
      cout << 0 << endl;
      return 0;
    }
    ++counts[d];
    max_depth = max(max_depth, d);
  }
  bool is_okay = true;
  is_okay = (counts[0] == 1);
  for (int64_t i = 1; i <= max_depth; ++i) {
    if (counts[i] == 0) {
      is_okay = false;
    }
  }
  if (is_okay) {
    Mint result = 1;
    for (int64_t i = 1; i <= max_depth; ++i) {
      result *= Mint(counts[i - 1]).Pow(counts[i]);
    }
    cout << result.value << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}


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

int main() {
  long long A[3][3];
  int N;
  int b[N];

  cin >> A[0][0] >> A[0][1] >> A[0][2];
  cin >> A[1][0] >> A[1][1] >> A[1][2];
  cin >> A[2][0] >> A[2][1] >> A[2][2];

  cin >> N;
  for(int i=0;i<N;i++){
    cin >> b[i];
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(A[j][k] == b[i]){
          A[j][k] = 0;
        }
      }
    }
  }

  int result = 0;
  for(int i=0;i<3;i++){
    if(A[0][i] ==0 && A[1][i] == 0 && A[2][i] == 0){
      result = 1;
    }

    if(A[i][0] == 0 && A[i][1] == 0 && A[i][2] == 0){
      result = 1;
    }
  }

  if(A[0][0] ==0 && A[1][1] ==0 && A[2][2] == 0){
    result = 1;
  }
  if(A[2][0] ==0 && A[1][1] ==0 && A[0][2] == 0){
    result = 1;
  }

  if(result == 1){
    cout << "Yes";
  }else{
    cout << "No";
  }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    long int n, a[100000], ans=0;
    long int cnt[100001]={0}, i, max=-1;
    scanf("%ld", &n);
    for(i=0;i<n;i++){
        scanf("%ld", &a[i]);
        if(max<a[i]) max=a[i];
    }

    for(i=0;i<n;i++){
            if(a[i]<=100000)  cnt[a[i]]++;
            else ans++;
    }
    for(i=0;i<=100000;i++){
        if(cnt[i]-i>0) ans=ans+cnt[i]-i;
        else if(cnt[i]<i) ans=ans+cnt[i];
    }
    printf("%ld\n", ans);
    return 0;
}


Measured memory_bytes: 1664