akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

class unionFind{
public:
	unionFind(int n);
	int root(int x);
	bool same(int x, int y);
	void unite(int x, int y);

	vector<int> par;
};

unionFind::unionFind(int n){
	for (int i = 0; i < n; i++){
		par.push_back(i);
	}
}

int unionFind::root(int x)
{
	if (par[x] == x){
		return x;
	}
	else{
		return par[x] = root(par[x]);
	}
}

bool unionFind::same(int x, int y)
{
	return root(x) == root(y);
}

void unionFind::unite(int x, int y)
{
	x = root(x);
	y = root(y);
	if (x == y)
		return;
	par[x] = y;
}

int main(void)
{
	int N, M;

	cin >> N >> M;

	vector<int> vp(N);
	for (int i = 0; i < N; i++){
		cin >> vp[i];
	}
	unionFind *uf = new unionFind(N);


	for (int i = 0; i < M; i++){
		int x, y;
		cin >> x >> y;
		uf->unite(x-1, y-1);
	}
	int cnt = 0;
	for (int i = 0; i < N; i++){
		if (uf->same(i, vp[i]-1)){
			cnt++;
		}
	}
	cout << cnt << endl;
}



Measured memory_bytes: 1276
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int a[3];
	for (int i = 0; i < 3; i++) cin >> a[i];
	sort(a, a + 3);
	if (a[0] + a[1] == a[2]) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int main()
{
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> ab(n,make_pair(0,0)),cd(m,make_pair(0,0));
    for(int i = 0; i < n; i++){
        cin >> ab[i].first >> ab[i].second;
    }
    for(int i = 0; i < m; i++){
        cin >> cd[i].first >> cd[i].second;
    }
    int ans;
    int distance;
    for(int i = 0; i < n; i++){
        int mi = 400000001;
        for(int j = 0; j < m; j++){
            distance = abs(ab[i].first-cd[j].first) + abs(ab[i].second-cd[j].second);
            if(distance < mi){
                mi = distance;
                ans = j+1;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int total = 0;
		int num = 0;
		int n = 0;
		while (sc.hasNext()) {
			String[] temp = sc.next().split(",");
			total += Integer.parseInt(temp[0])*Integer.parseInt(temp[1]);
			num += Integer.parseInt(temp[1]);
			n++;
		}
		out.println(total);
		double d1 = num;
		double d2 = n;
		out.println(Math.round(d1/d2));
	}
}


Measured memory_bytes: 26052
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    cin>>n;
    string s;
    while(n>0)
    {
        n-=1;
        int k=n%26;
        s+=(char)(k+97);
        n/=26;
    }
    reverse(s.begin(),s.end());
    cout<<s;
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
#define For1(i,n) for(ll i=1;i<(n);i++)
#define MOD 1000000007

ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
int main(){
    ll n,a,b;cin>>n>>a>>b;
    cout<<min(n*a,b)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

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

    int mx = max({a, b, c});
    int ans = 0;
    if ((3 * mx) % 2 == (a + b + c) % 2) {
        ans = (3 * mx - (a + b + c)) / 2;
    } else {
        ans = (3 * (mx + 1) - (a + b + c)) / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


const int NM = 100000;


void solve() {
    string  S;
    cin >> S;

    bool isOK = true;


        //    for (int i = 3; i < S.length()/2; i++) {
        string substr1 = S.substr(0, (S.length() - 1) / 2);
        string substr2 = S.substr((S.length()+3)/2-1, S.length());
        if (substr1 != substr2) {
            isOK = false;
        }

    if (isOK) {
        cout << "Yes";
    }
    else {
        cout << "No";

    }
}



int main() {
    solve();
    return 0;
}







Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;
int a[300006];
int rv[300005];
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> a[i];
	sort(a, a + n);
	vector<int>V;
	int now = a[0];
	int cnt = 0;
	rep(i, n + 1) {
		if (now != a[i]) {
			V.push_back(cnt);
			cnt = 1; now = a[i];
		}
		else cnt++;
	}
	sort(V.begin(), V.end());
	int m = V.size();
	rep(i, m)rv[i + 1] = V[i];
	rep(i, m)rv[i + 1] += rv[i];
	for (int K = 1; K <= n; K++) {
		if (K == 1)cout << n << endl;
		else {
			int lb = -1, ub = n / K + 1;
			while (ub - lb > 1) {
				int mi = (ub + lb) / 2;
				int sum = 0;
				int itr = upper_bound(V.begin(), V.end(), mi) - V.begin();
				sum = rv[itr] + (m - itr)*mi;
				if (sum < mi*K)ub = mi;
				else lb = mi;

			}
				cout << lb << endl;
		}
	}
}


Measured memory_bytes: 8044
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    string s;
    cin >> s;

    string t = "";
    for(int i=s.size()-1; i>=0; i--){
        t = s[i] + t;

        if(t=="dream"){
            t = "";
        }else if(t=="dreamer"){
            t = "";
        }else if(t=="erase"){
            t = "";
        }else if(t=="eraser"){
            t = "";
        }
    }

    if(t.size()==0){
        p_yes();
    }else{
        p_no();
    }

    return 0;
}

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

string S;

int main(){
    
    bool result = true;

    cin >> S;

    for (int i=0; i<S.length();i++){
        if (i % 2 == 0){
            if (S[i] == 'R' || S[i] == 'U' || S[i] == 'D'){
                continue;
            }
            else{
                result = false;
            }
        }
        else {
            if (S[i] == 'L' || S[i] == 'U' || S[i] == 'D'){
                continue;
            }
            else{
                result = false;
            }

        }
    }

    if (result == true){
        cout << "Yes\n";
    }   else cout << "No\n";

    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))


int main(){
    int n;  cin >> n;
    vector<ll> x(n), y(n), v;
    REP(i, n)   cin >> x[i] >> y[i];

    REP(i, n)   v.push_back(i);
    //sort(ALL(v));
    double res=0;
    int cnt=0;
    do{
        REP(j, n-1){
            double dx = pow(x[v[j]]-x[v[j+1]], 2.0);
            double dy = pow(y[v[j]]-y[v[j+1]], 2.0);
            res += pow(dx+dy, 0.5);
        }
        cnt += 1;
    }while(next_permutation(ALL(v)));    
    cout << fixed << setprecision(20) << res/cnt << endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n, 0), b(n);
    for (int i = 0; i < n - 1; i++) cin >> b[i];

    a[0] = b[0];
    for (int i = 0; i < n - 1; i++) a[i + 1] = b[i];

    for (int i = 0; i < n - 1; i++) {
        if (b[i] < a[i]) a[i] = b[i];
        if (b[i] < a[i + 1]) a[i + 1] = b[i];
    }

    long long sum = 0;
    for (int i = 0; i < n; i++) sum += a[i];

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n,m,c,i,j,tot=0;
	long long sum=0;
	scanf("%d%d%d",&n,&m,&c);
	int b[m];
	for(i=0;i<m;++i)
		scanf("%d",&b[i]);
	int a[m];
	for(i=0;i<n;++i){
		for(j=0;j<m;++j)
			scanf("%d",&a[j]);
		for(j=0;j<m;++j)
			sum+=a[j]*b[j];
		if(sum+c>0)
			++tot;
		sum=0;
	}
	printf("%d",tot);
	return 0;
}

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

int main() {
  long long int d, n;
  cin >> d >> n;
  long long int handred = 1;
  for (int k = 0; k < d; k++) {
    handred *= 100;
  }
  long long int ans = handred * n;
  if (n == 100 && d == 0) cout << ans + 1 << endl;
  else if (n == 100 && d == 1) cout << ans + 100 << endl;
  else if (n == 100 && d == 2) cout << ans + 10000 << endl;
  else cout << ans << endl;
}

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

using namespace std;

int dp[205][205];

int gcd(int a, int b) {
    if (a < b) return gcd(b, a);
    if (dp[a][b] > 0) {
        return dp[a][b];
    }
    if (a % b == 0) {
        return dp[a][b] = b;
    }
    return gcd(b, a % b);
}

int gcd3(int a, int b, int c) {
    return gcd(a, gcd(b, c));
}

int main() {
    int k;
    cin >> k;
    int ans = 0;
    for (int i = 0; i < 205; i++) {
        for (int j = 0; j < 205; j++) {
            dp[i][j] = 0;
        }
    }
    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= k; j++) {
            for (int l = 1; l <= k; l++) {
                ans += gcd3(i, j, l);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3804
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int a[4],b[2];
    for(int i=0;i<4;i++)cin>>a[i];
    for(int i=0;i<2;i++)cin>>b[i];
    sort(a,a+4);
    sort(b,b+2);
    cout<<a[1]+a[2]+a[3]+b[1]<<endl;
    return 0;
}

Measured memory_bytes: 1180
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author toshif
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyReader in = new MyReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, MyReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            if (a <= c && c <= b) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }

    }

    static class MyReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public MyReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
using namespace std;
namespace {

	void chmin(long long& x, long long y)
	{
		if (x > y || x < 0)
			x = y;
	}

	void chmax(long long& x, long long y)
	{
		if (x < y)
			x = y;
	}

	void core()
	{
		long N;
		cin >> N;

		long W;
		cin >> W;


		std::vector<long long> w(N + 1, 0);
		std::vector<long long> v(N + 1, 0);

		for (long i = 1; i <= N; ++i)
		{
			cin >> w[i];
			cin >> v[i];
		}

		vector<vector<long long>> dp(N + 1);
		dp[0].resize(1, 0);
		long long sumV = 0;
		for (long i = 1; i <= N; ++i)
		{
			sumV += v[i];
			dp[i].resize(size_t(sumV+1), -1);
		}

		for (long i = 1; i <= N; ++i)
		{
			auto this_value = v[i];
			for (long j = 0; j < dp[i].size(); ++j)
			{
				if (j - this_value >= 0)
					chmin(dp[i][j], dp[i - 1][j - this_value] + w[i]);
				else
					chmin(dp[i][j], dp[i - 1][0] + w[i]);

				if (j < dp[i-1].size() )
					chmin(dp[i][j], dp[i - 1][j]);
			}
		}

		long long maxV = -1;
		for (long i = 0; i < dp[N].size(); i++)
		{
			if (dp[N][i] <= W)
				chmax(maxV, i);
		}

		cout << maxV;
	}
}

int main()
{
	core();

	return 0;
}


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


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

	
	if (A.size() > B.size()) {
		cout << "GREATER" << endl;
	}
	else if (A.size() < B.size()) {
		cout << "LESS" << endl;
	}
	else {

		for (int i = 0; i <= A.size(); i++) {
			if (A[i] > B[i]) {
				cout << "GREATER" << endl;
				return(0);
			}
			else if (A[i] < B[i]) {
				cout << "LESS" << endl;
				return(0);
			}
		}
		cout << "EQUAL" << endl;
	}
}

Measured memory_bytes: 256
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const [N,Y] = nextIntArray()
    let na = 0
    let nb = 0
    let nc = 0
    const isMatched = (a,b,c) => {
        return a+b+c == N && 10000*a + 5000*b+ 1000*c == Y
    }
    let aMax = Math.ceil(Y/10000)
    let bMax = Math.ceil(Y/5000)
    let cMax = Math.ceil(Y/1000)
    for(let na = 0; na<=aMax;na++){
        for(let nb = 0;nb<=bMax;nb++){
            let nc = N-na-nb
            if(nc<0) continue
            if(isMatched(na,nb,nc)){
                console.log(na, nb,nc)
                return
            }
        }
    }
    console.log(-1,-1,-1)
}
Main()

Measured memory_bytes: 31748
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		int[] d = new int[n];
		for (int i = 0; i < n; i++)
			d[i] = scanner.nextInt();
		Arrays.sort(d);
		int ans = c / a;
		for (int i = n - 1; i >= 0; i--) {
			c += d[i];
			a += b;
			ans = Math.max(ans, c / a);
		}
		System.out.println(ans);

	}
}

Measured memory_bytes: 18120
<?php
  $stdin = fopen('php://stdin', "r");

  while(true) {
      fscanf($stdin, "%d %d", $inH, $inW);
      if($inH === 0 && $inW === 0) {
          break;
      }

      for ($i=0; $i<$inH; $i++) {
        echo '#';
        for ($j=1; $j<$inW-1; $j++ ) {
          if ($i == 0 || $i == $inH-1) {
            echo '#';
          } else {
            echo '.';
          }
        }
        echo '#'.PHP_EOL;
      }
      echo PHP_EOL;
  }



Measured memory_bytes: 9220
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int i = Integer.parseInt(sc.next());

        // 主処理
        int result = n - i + 1;

        // 出力
        System.out.println(result);
        sc.close();
    }
}


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

int b[20],a[20][20];
int main(void){
	int n, m, c, ans=0;
	cin >> n >> m >> c;
	for(int i=0; i<m; i++) cin >> b[i];
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			cin >> a[i][j];
		}
	}
	for(int i=0; i<n; i++){
		int k=c;
		for(int j=0; j<m; j++) k += a[i][j]*b[j];
		if(k>0) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint Q;
llint a[305];
bool prime[305];
llint b[] = {8, 5, 3, 3, 2, 2, 2};
vector<llint> pvec;

llint dfs(int p, llint mul)
{
	if(p < 7){
		llint ret = 0;
		for(int i = 0; i <= b[p]; i++){
			ret = max(ret, dfs(p+1, mul));
			mul *= pvec[p];
		}
		return ret;
	}
	
	llint ret = 0;
	for(int i = 2; i <= 300; i++){
		if(mul % i == 0) ret += a[i];
	}
	for(int i = 7; i < pvec.size(); i++){
		llint p = pvec[i], sum = 0;
		for(int j = 1; j*p <= 300; j++){
			if(mul % j == 0) sum += a[j*p];
		}
		if(sum > 0) ret += sum;
	}
	
	return ret;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> Q;
	llint m, x;
	for(int i = 1; i <= Q; i++){
		cin >> m >> x;
		a[m] += x;
	}
	
	for(int i = 2; i < 305; i++){
		if(prime[i]) continue;
		for(int j = 2*i; j < 305; j+=i) prime[j] = true;
		pvec.push_back(i);
	}
	
	cout << dfs(0, 1) << endl;
	
	return 0;
}

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

#define ll long long int

using namespace std;

int main() {
    ll n;
    cin >> n;
    map<ll,ll> A;
    ll sum = 0;
    for (ll i = 0; i < n; ++i) {
        ll a;
        cin >> a;
        ++A[a];
        sum += a;
    }
    ll q;
    cin >> q;
    for (ll i = 0; i < q; ++i) {
        ll b, c;
        cin >> b >> c;
        ll t = A[b];
        sum = sum - (b * t) + (c * t);
        A[b] = 0;
        A[c] += t;
        cout << sum << endl;
    }
}


Measured memory_bytes: 9572
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==(b+c) || b==(a+c) || c==(a+b))cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main() {
  int n, m;
  VI a, b, sum;

  cin >> n >> m;  
  REP(i, n) {
    int x;
    cin >> x;
    a.PB(x);
    sum.PB(0);
  }
 
 REP(i, m) {
    int x;
    cin >> x;
    b.PB(x);
  } 

 REP(i, m) {
   REP(j, n) {
     if(a[j] <= b[i]) {
       sum[j]++;
       break;
     }
   }
 }
 
 int max = 0, num;
 REP(i, n) {
   if(max < sum[i]) {
     max = sum[i];
     num = i;
   }
 }

 cout << num+1 << endl;
}

Measured memory_bytes: 1232
#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 >;

bool used[30];

int main() {
    string s;
    cin >> s;
    rep(i, s.size()) {
        if (used[s[i]-'a']) {
            cout << "no" << endl;
            return false;
        }
        used[s[i]-'a'] = 1;
    }
    cout << "yes" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
  int N, num[200];
  scanf("%d", &N);
  for(int i=0;i<N;i++){
    scanf("%d", &num[i]);
  }
  int count=-1;
  int flag=0;
  while(flag==0){
    for(int i=0;i<N;i++){
      if(num[i]%2 != 0){
        flag = 1;
        break;
      }
      num[i]/=2;
    }
    count ++;
  }
  printf("%d", count);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main()
{
    int a;
    cin>>a;
    switch(a)
    {
        case 22:cout<<"Christmas Eve Eve Eve"<<endl;break;
        case 23:cout<<"Christmas Eve Eve"<<endl;break;
        case 24:cout<<"Christmas Eve"<<endl;break;
        case 25:cout<<"Christmas"<<endl;break;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
string a;
  int c=0;
  cin>>a;
  for(int i=0;i<3;i++){
  if(a.at(i)==a.at(i+1)){
  c++;
  }
  }
  if(c>=2&a.at(1)==a.at(2)){
  cout<<"Yes"<<endl;
  }
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <algorithm> //STLͨ���㷨
#include <cmath> //������ѧ����
#include <cstdio> //��������/�������
#include <iostream> //����������/���
#include <cstring> //�ַ�������
#include <string> //�ַ�����
#include <ctime> //�������ʱ��ĺ���
#define itn int
#define fro for
#define ll long long
#define reg register
#define inf 1234567890
#define rep(i,a,b,c) for (int i=a;i<=b;i+=c)
#define pi 3.1415926535897932384626433832795
/*#include <bitset> //STLλ������
#include <cstype> //�ַ�����
#include <cerrno> //���������
#include <complex> //������
#include <clocale> //���屾�ػ�����
#include <cstdlib> //������������ڴ���亯��
#include <deque> //STL˫�˶�������
#include <exception> //�쳣������
#include <fstream> //�ļ�����/���
#include <functional> //STL�������㺯��(���������)
#include <limits> //�����������������ֵ����
#include <list> //STL�����б�����
#include <map> //STLӳ������
#include <iomanip> //����������/���
#include <ios> //��������/���֧��
#include <iosfwd> //����/���ϵͳʹ�õ�ǰ������
#include <istream> //����������
#include <ostream> //���������
#include <queue> //STL��������
#include <set> //STL��������
#include <sstream> //�����ַ�������
#include <stack> //STL��ջ����
#include <stdexcept> //��׼�쳣��
#include <streambuf> //�ײ�����/���֧��
#include <utility> //STLͨ��ģ����
#include <vector> //STL��̬��������
#include <cwchar.h>//���ַ�����������/���
#include <cwctype.h> //���ַ�����*/

using namespace std;

int ans;

int max(int x,int y){return x>y?x:y;}

int min(int x,int y){return x<y?x:y;}

int abs(int x){return x>0?x:-x;}

int gcd(int x,int y){return (!y)?x:gcd(y,x%y);}

void exgcd(int a,int b,int &d,int &x,int &y){if (!b){d=a,x=1,y=0;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}

int quick_power(ll a,int b){ll r=1;for (;b;b>>=1,a=a*a)if (b&1) r=r*a;return r;}

inline char read() {
	static const int IN_LEN = 1000000;
	static char buf[IN_LEN], *s, *t;
	return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++);
}
template<class T>
inline void read(T &x) {
	static bool iosig;
	static char c;
	for (iosig = false, c = read(); !isdigit(c); c = read()) {
		if (c == '-') iosig = true;
		if (c == -1) return;
	}
	for (x = 0; isdigit(c); c = read()) x = x * 10 + (c ^ '0');
	if (iosig) x = -x;
}

char sr[10000000],z[20];int C=-1,Z=0;
void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(int x){
	if (x<0) sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
//int find(int x){return fa[x]=fa[x]==x?x:find(fa[x]);}

//void add(int x,int y,int z){to[++cnt]=y;v[cnt]=z;Next[cnt]=head[x];head[x]=cnt;}

int a,b,x;
void solve1()
{
	printf("%.10lf",90.0-atan(2.0*x/a/b/b)*180/pi);
}

void solve2()
{
	printf("%.10lf",90.0-atan(1.0*a*a*a/(2*a*a*b-2*x))*180/pi);
}

int main()
{
	read(a);read(b);read(x);
	if (2*x<=a*a*b) solve1();
	else solve2();
	return 0;
}









Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=1000005,mod=1e9+7,i3=(mod+1)/3;
int inv[N],n,ans,s;

int main(){
	read(n);
	inv[1]=1;
	rep(i,2,n)
		inv[i]=(ll)(mod-mod/i)*inv[mod%i]%mod;
	s=inv[n];
	REP(i,n){
		s=(ll)s*i3%mod;
		ans=(ans+(ll)s*inv[n-i])%mod;
	}
	cout<<ans<<endl;
	return 0;
}

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

const int MAX_N = 306;
int N;
int a[MAX_N];
double dp[MAX_N][MAX_N][MAX_N];

double go(int x, int y, int z)
{
	if(!x && !y && !z) return 0;
	double& res = dp[x][y][z];
	if(res > 0) return res;
	const double p1 = 1.0*x/N, p2 = 1.0*y/N, p3 = 1.0*z/N, p4 = 1.0*(N-x-y-z)/N;
	double tmp = 1.0;
	if(x) {
		tmp += p1*go(x-1, y, z);
	}
	if(y){
	    tmp += p2*go(x+1,y-1,z);
	}
	if(z){
	    tmp += p3*go(x,y+1,z-1);
	}
	res =tmp/(1.0-p4);
	return res;
}

void solve()
{
    array<int,4> b = {0};
    for(int i=1;i<=N;++i) b[a[i]]++;
	memset(dp,-1,sizeof(dp));
	double ans = go(b[1],b[2],b[3]);
	printf("%.12lf\n", ans);
}

int main()
{
	cin >> N;
	for(int i=1;i<=N;++i) cin >> a[i];
	solve();
	return 0;
}

Measured memory_bytes: 224128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <queue>
#include <functional>

#define out(t) cout << (t) << "\n"

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int uint;

int popcount(uint x) {
    x -= x >> 1 & 0x55555555;
    x = (x & 0x33333333) + (x >> 2 & 0x33333333);
    x = x + (x >> 4) & 0x0F0F0F0F;
    return x * 0x01010101 >> 24;
}

int tzcnt(uint x) {
    return popcount(~x & x - 1);
}

struct Point {
    int x, y;

    Point(int p, int q) : x(p), y(q) {}
};

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

    int a, b;
    cin >> a >> b;

    out(b >= a ? a : (a - 1));

    int aaa;
    cin >> aaa;
}

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

using namespace std;

using ll = long long;

#define clr(a) (a.clear())
#define sz(x) (int)x.size()
#define mem(a,b) memset(a, b, sizeof(a))
#define Unique(store) store.resize(unique(store.begin(),store.end())-store.begin())
#define pb push_back
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);

#define X first
#define Y second

using pii = pair <int, int>;
using pll = pair <ll, ll>;

const ll inf = 1;
const ll mod = 1E9;


#define SZ 100010



int main() {
#if defined JESI
//        freopen("1.txt", "r", stdin);
//        freopen("2.txt", "w", stdout);
#endif

    ios::sync_with_stdio(false);

    int r, g, b;
    cin >> r >> g >> b;
    cout << (((100 * r + 10 * g + b) % 4 == 0)? "YES": "NO") << endl;

    return 0;
}






Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static char[] p = {'r', 's', 'p'};

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int x = sc.nextInt();

		String ans = (k*500 >= x) ? "Yes" : "No";

		System.out.println(ans);

        return;
    }


}



Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
#define mod 1000000007
#define mmod 998244353
#define all(v) v.begin(), v.end()
#define INF LLONG_MAX/3
using namespace std;
int mypow(int a, int b, int c) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1, c)*a%c;
	int z = mypow(a, b / 2, c);
	return z * z%c;
}
int dp[3010][3010];
int c[3010];
signed main() {
	int a, b;
	cin >> a >> b;
	f(i, a)cin >> c[i];
	dp[0][0] = 1;
	f(i, a) {
		f(j, b+1) {
			if (j == 0)dp[i + 1][0] = (dp[i][0] + 1)%mmod;
			else if (j >= c[i]) {
				dp[i + 1][j] = (dp[i][j] + dp[i][j - c[i]])%mmod;
			}
			else dp[i + 1][j] = dp[i][j];
		}
	}
	int ans = 0;
	f(i, a) {
		ans += dp[i + 1][b];
	}
	cout << ans%mmod << endl;
}

Measured memory_bytes: 70784
#include<bits/stdc++.h>
#define loop(vals,times) for(vals=0;vals<times;vals++)
#define reg(time) for(int val=0;val<time;val++)
#define space <<" "<<
using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<pair<int,int> > loc(n);
    
    reg(n)cin>>loc.at(val).first>>loc.at(val).second;
    sort(loc.begin(),loc.end());

    reg(n)cout<<loc.at(val).first space loc.at(val).second<<endl;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
    using namespace std;
    int main()
    {
    	std::ios::sync_with_stdio(false);
        long long int n,mw,w,v;
        cin>>n>>mw;
        long long int dp[mw+1]={};
        while(n--)
        {
            cin>>w>>v;
            for(int j=mw;j>=w;j--)
            {
                dp[j]=max(dp[j],dp[j-w]+v);
            }
        }
        cout<<dp[mw];
    }


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
using namespace std;
const int N=1800005;
int n,rt,cnt,ind,pw[N],ch[N][3],tg[N],val[N],ans[N];char s[N];
void bud(int&k1,int k2,int k3){
	k1=++cnt;
	if(k2==n){val[k1]=k3;return;}
	rep(i,0,2)bud(ch[k1][i],k2+1,k3+pw[k2]*i);
}
void pst(int k1){
	if(!ch[k1][0])return;
	swap(ch[k1][1],ch[k1][2]);
	tg[k1]^=1;
}
void psd(int k1){
	if(!ch[k1][0])return;
	if(tg[k1]){
		pst(ch[k1][0]);
		pst(ch[k1][1]);
		pst(ch[k1][2]);
		tg[k1]^=1;
	}
}
void go(int k1){
	if(!ch[k1][0])return;
	psd(k1);
	int t=ch[k1][2];ch[k1][2]=ch[k1][1],ch[k1][1]=ch[k1][0],ch[k1][0]=t;
	go(ch[k1][0]);
}
void dfs(int k1,int k2,int k3){
	if(k2==n){ans[val[k1]]=k3;return;}
	psd(k1);
	rep(i,0,2)dfs(ch[k1][i],k2+1,k3+pw[k2]*i);
}
int main(){
	scanf("%d%s",&n,s);
	pw[0]=1;rep(i,1,n)pw[i]=pw[i-1]*3;
	bud(rt,0,0);
	for(int i=0;s[i];++i){
		if(s[i]=='S')pst(rt);
		else go(rt);
	}
	dfs(rt,0,0);
	rep(i,0,pw[n]-1)printf("%d ",ans[i]);
	return 0;
}


Measured memory_bytes: 21852
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int,int> P;
const int INF=(int)1e9;
const int MOD=(int)1e9+7;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};



int main(){
  int N,M,m[100005],cont=0;
  vector<P>v;
  memset(m,0,sizeof(m));

  cin>>N>>M;
  for(int t=0;t<M;t++){
    int a,b;
    cin>>a>>b;
    v.push_back(P(b,a));
  }

  sort(v.begin(),v.end());

  for(auto itr=v.begin();itr!=v.end();itr++){
    bool flag=false;
    for(int i=(*itr).second;i<(*itr).first;i++){
      if(m[i]!=0){
        flag=true;
        break;
      }
      if(i==(*itr).first-1&&flag==false){
        m[i]=1;
        cont++;
      }
    }
  }

  cout<<cont<<endl;
  return 0;
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

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

    vector<int> A(3);
    rep(i,3) cin >> A[i];
    sort(A.begin(),A.end());
    int ans = 0;
    ans += A[2] - A[1];
    A[0] += ans;
    if ((A[2] - A[0])%2 == 0) {
        ans += (A[2] - A[0])/2;
    } else {
        ans += (A[2] - A[0])/2 + 2;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<=(n);++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const double Pi = acos(-1);
const ll mod=1e9+7;

int main(){
    int n,k;
    cin >>n>>k;
    int p[n];
    rep(i,n){
        cin >>p[i];
    }
    sort(p,p+n);
    int ans=0;
    rep(i,k){
        ans+=p[i];
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 3620
////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

int arr[55];
int vis[1<<24];

int n;

int calc(int x) {
	vector<int> dt;
	dt.PB(0);
	int c = 0;
	while(x) {
		if(x & 1) dt.PB(c);
		c++;
		x /= 2;
	}
	int mx = 24;
	int nw = dt.size();
	if(nw != n + 1) return 0;
	for(int i = 0;i < nw - 1;i++) {
		mx = min(mx, dt[i + 1] - dt[i]);
	}
	mx = min(mx, (dt[0] + 24 - dt[nw - 1]) % 24);
	return mx;
}

queue<int> q[2];

void hora(int tc) {
	cin>>n;
	for(int i = 0;i < n;i++) cin>>arr[i];
	memset(vis, -1, sizeof vis);
	q[0].push(0);
	int i = 0;
	int bm = 0;
	while(i != n) {
		int target = arr[i];
		int revtarget = (24 - arr[i]) % 24;
		while(!q[bm].empty()) {
			int val = q[bm].front();
			q[bm].pop();
			int nx = ((1<<target) | val);
			if(vis[nx] != i) q[1 - bm].push(nx);
			vis[nx] = i;
			int revnx = ((1<<revtarget) | val);
			if(vis[revnx] != i) {
				q[1 - bm].push(revnx);
			}
			vis[revnx] = i;
		}
		i++;
		bm ^= 1;
	}
	int dt = 0;
	while(!q[bm].empty()) {
		int val = q[bm].front();
		q[bm].pop();
		dt = max(dt, calc(val));
	}
	cout<<dt<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}




Measured memory_bytes: 66560
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n, a;
    cin >> n >> a;
    if (n % 500 <= a) {
        cout << "Yes" << endl;
        return 0;
    } else {
        cout << "No" << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <string>
#include <utility>

using namespace std;

struct Result {
	int p;
	complex<int> v;
};

int abs(int x){ return (x < 0) ? -x : x; }
const int LIMIT = 10000;

#define PARSER_DECL(name) \
	Result name (const std::string &s, int p)

PARSER_DECL(expr);
PARSER_DECL(term);
PARSER_DECL(factor);
PARSER_DECL(digits);
PARSER_DECL(imaginary);

PARSER_DECL(expr){
	Result r = term(s, p);
	while(s[r.p] == '+' || s[r.p] == '-'){
		Result q = term(s, r.p + 1);
		if(s[r.p] == '+'){
			r.v += q.v;
		}else{
			r.v -= q.v;
		}
		if(abs(r.v.real()) > LIMIT || abs(r.v.imag()) > LIMIT){ throw 0; }
		r.p = q.p;
	}
	return r;
}
PARSER_DECL(term){
	Result r = factor(s, p);
	while(s[r.p] == '*'){
		Result q = factor(s, r.p + 1);
		r.v *= q.v;
		if(abs(r.v.real()) > LIMIT || abs(r.v.imag()) > LIMIT){ throw 0; }
		r.p = q.p;
	}
	return r;
}
PARSER_DECL(factor){
	Result r;
	if(s[p] == '('){
		r = expr(s, p + 1);
		++r.p;
	}else if(isdigit(s[p])){
		r = digits(s, p);
	}else{
		r = imaginary(s, p);
	}
	return r;
}
PARSER_DECL(digits){
	int v = 0;
	while(isdigit(s[p])){
		v = (v * 10) + (s[p] - '0');
		if(v > LIMIT){ throw 0; }
		++p;
	}
	Result r;
	r.v = complex<int>(v, 0);
	r.p = p;
	return r;
}
PARSER_DECL(imaginary){
	Result r;
	r.v = complex<int>(0, 1);
	r.p = p + 1;
	return r;
}

int main(){
	string input;
	while(cin >> input){
		try {
			Result r = expr(input, 0);
			if(r.v.real() == 0 && r.v.imag() == 0){
				cout << 0 << endl;
			}else if(r.v.imag() == 0){
				cout << r.v.real() << endl;
			}else if(r.v.real() == 0){
				cout << r.v.imag() << "i" << endl;
			}else{
				cout << r.v.real();
				if(r.v.imag() >= 0){ cout << "+"; }
				cout << r.v.imag() << "i" << endl;
			}
		}catch(...){
			cout << "overflow" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
public class Main { 
public static void main(String args[]) { 
Scanner sc = new Scanner(System.in);
int w=sc.nextInt();
int h=sc.nextInt();
int x=sc.nextInt();
int y=sc.nextInt();
int r=sc.nextInt();
if(x+r>w || x-r<0 || y+r>h || y-r<0){
    System.out.println("No");
} else{
    System.out.println("Yes");
}
 } }


Measured memory_bytes: 26352
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

//gcd,lcm,べき,二進展開
//組み合わせ、mod計算
//最短路問題、bit、union find

///////////////////////////


	
int main() {
	ll N, C;
	cin >> N >> C;

	ll D[50][50];

	repn(i, C) repn(j, C) cin >> D[i][j];

	ll c[1000][1000];

	repn(i, N) repn(j, N) cin >> c[i][j];

	ll iwa[3][50] = {};

	repn(i, N) repn(j, N) {
		repn(k, C) {
			iwa[(i + j) % 3][k] += D[c[i][j]][k];
		}
	}

	ll ans = INF;

	repn(i, C)repn(j, C)repn(k, C) {
		if (i == j || j == k || k == i) { continue; }
		ans = min(ans, iwa[0][i] + iwa[1][j] + iwa[2][k]);
	}

	cout << ans;

	system("PAUSE");
}

Measured memory_bytes: 6400
#include <stdio.h>
int main(void){
    int a,b;
    double d,r,f,g,h;
    scanf("%d %d\n",&a,&b);
    g=a;
    h=b;
    d=a/b;
    r=a%b;
    f=g/h;
    printf("%.0lf %.0lf %.5lf\n",d,r,f);
    
    return 0;
    
}



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

int main(){
  string s;
  int k;
  cin >> s >> k;
  
  int l = s.size();
  set<string> sub;
  for(int i = 0; i < l; i++){
    for(int j = 1; j <= k; j++){
      string now = s.substr(i, j);
      sub.insert(now);
    }
  }
  
  vector<string> ans(0);
  for(auto now : sub){
    ans.push_back(now);
  }
  sort(ans.begin(), ans.end());
  
  cout << ans.at(k-1) << endl;
}

Measured memory_bytes: 1920
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main(){
	string s,t;
    
    cin >> s >>t;
    
    REP(i,s.size()){
        if(s[i]!=t[i]){
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    
    
    return 0;
}

Measured memory_bytes: 3576
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Integer[] a = new Integer[n];
        Arrays.setAll(a, i -> Integer.parseInt(sc.next()));
        sc.close();

        // 主処理
        int count2 = Arrays.stream(a).filter(i -> i % 4 != 0 && i % 2 == 0).toArray().length;
        int count4 = Arrays.stream(a).filter(i -> i % 4 == 0).toArray().length;
        boolean judge = (n - Math.max(0, count2 - 1)) / 2 <= count4;
        String result = judge ? "Yes" : "No";

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 48296
#include <bits/stdc++.h>
#define N 100005
using namespace std;
typedef long long ll;
struct P{
	int l,r,id;
}a[N],b[N];
int n;
ll ans=0;
bool cmpl(P a,P b){
	if(a.l!=b.l) return a.l>b.l;
	return a.r>b.r;
}
bool cmpr(P a,P b){
	if(a.r!=b.r) return a.r<b.r;
	return a.l<b.l;
}
bool cmp(P a,P b){
	if(a.l==b.l) return a.r<b.r;
	return a.l<b.l;
}
bool vis[N];
int Abs(int a){return a<0?-a:a;}
int trans(int &now,P x){
	if(now>=x.r){
		int w=now-x.r;
		now=x.r;
		return w;
	}
	if(now<=x.l){
		int w=x.l-now;
		now=x.l;
		return w;
	}
	return 0;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d%d",&a[i].l,&a[i].r),a[i].id=i,b[i]=a[i];
	sort(a+1,a+n+1,cmpl);
	sort(b+1,b+n+1,cmpr);
	int now=0;
	for(int i=1,p=1,j=1;i<=n;i++){
		while(p<=n&&vis[a[p].id]) p++;
		while(j<=n&&vis[b[j].id]) j++;
		if((i&1)&&p<=n) ans+=trans(now,a[p]),vis[a[p].id]=1,p++;
		else ans+=trans(now,b[j]),vis[b[j].id]=1,j++;
	}
	ans+=Abs(now);
	ll mx=ans;ans=0;
	now=0;
	memset(vis,0,sizeof(vis));
	for(int i=1,p=1,j=1;i<=n;i++){
		while(p<=n&&vis[a[p].id]) p++;
		while(j<=n&&vis[b[j].id]) j++;
		if(!(i&1)&&p<=n) ans+=trans(now,a[p]),vis[a[p].id]=1,p++;
		else ans+=trans(now,b[j]),vis[b[j].id]=1,j++;
	}
	ans+=Abs(now);
	mx=max(mx,ans);
	printf("%lld",mx);
	return 0;
}

Measured memory_bytes: 2688
#include<stdio.h>


int main(int argc, char const *argv[])
{
	long long int A,B,C,D,area1,area2;
	scanf("%lld %lld %lld %lld",&A,&B,&C,&D);
	area1=1;
	area2=1;
	area1=A*B;
	area2=C*D;
	printf("%lld",area1>area2?area1:area2 );
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

const double EPS = 1e-8;
const double INF = 1e12;
const double PI =3.14159265358979;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

typedef vector<P> G;

struct C {
  P p; double r;
  C(const P &p, double r) : p(p), r(r) { }
};

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

P crosspoint(const L &l, const L &m) {
  double A = cross(l[1] - l[0], m[1] - m[0]);
  double B = cross(l[1] - l[0], l[1] - m[0]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
  //if (abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
  return m[0] + B / A * (m[1] - m[0]);
}

G convex_cut(const G& g, const L& l) {
  G Q;
  REP(i, g.size()) {
    P A = g[i], B = g[(i+1)%g.size()];
    if (ccw(l[0], l[1], A) != -1) Q.push_back(A);
    if (ccw(l[0], l[1], A)*ccw(l[0], l[1], B) < 0)
      Q.push_back(crosspoint(L(A, B), l));
  }
  return Q;
}
L bisector(P a, P b) {
  P A = (a+b)*P(0.5,0);
  return L(A, A+(b-a)*P(0, PI/2));
}
G voronoi_cell(G g, vector<P> v, int s) {
  REP(i, v.size())
    if (i!=s)
      g = convex_cut(g, bisector(v[s], v[i]));
  return g;
}
double area(const G& g) {
  double A = 0;
  for (int i = 0; i < g.size(); ++i) {
    A += cross(g[i], g[(i+1)%g.size()]);
  }
  return A/2;
}


int main() {
  	int n ;
  	cin >> n;
  	vector<P> p;
  	for(int i=0;i<n;i++){
  		double x,y;
  		cin >> x >> y;
  		P p1(x,y);
  		p.push_back(p1);
  	}
  	for(int i=0;i<n;i++){
	    G g;
	   
	    for(int i=0;i<100;i++){
	    	g.push_back(P(INF*cos(2*i*PI/100),INF*sin(2*i*PI/100)));
	    }

	    for(int j=0;j<n;j++){
	    	if(i!=j){
		    	g = convex_cut(g, bisector(p[i],p[j]));
		    }
	    }
	   	cout << fixed << setprecision(20) << area(g) / (50.0*INF*INF*sin(2*PI/100)) << endl;
	}
	return 0;
}


Measured memory_bytes: 512
#include"bits/stdc++.h"
using namespace std;
long long int n,f;
char a[11],b[11];

int main(){
	cin>>n;
	for(int i=sqrt(n);i>=1;i--){
		if(n%i==0){
			int j=n/i;
			sprintf(a,"%d",i);
			sprintf(b,"%d",j);
			f=max(strlen(a),strlen(b));
			cout<<f<<endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256