akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
using P = pair<int,int>;
using vi = vector<int>;
using vii = vector<vi>;
using ll = long long;
const int dx4[4] = {1,0,-1,0};
const int dy4[4] = {0,1,0,-1};
const int dx8[8] = {-1,0,1,1,1,0,-1,-1};
const int dy8[8] = {1,1,1,0,-1,-1,-1,0};
const int mod = 1e9+7;

ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}

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

  int n;
  cin >> n;
  vector<vector<char>> v(n, vector<char>(10));
  rep(i,n){
    rep(j,10){
      cin >> v[i][j];
    }
    sort(all(v[i]));
  }
  sort(all(v));
  //rep(i,n){
    //rep(j,10){
      //cout << v[i][j];
    //}
    //cout << endl;
  //}
  ll ans = 0;
  ll cnt = 1;
  REP(i,n){
    if(v[i] == v[i-1]) cnt++;
    else{
      ans += com(cnt, 2);
      cnt = 1;
    }
  }
  ans += com(cnt, 2);
  cout << ans << endl;
}

Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N, M;
  cin >> N >> M;

  vector<vector<int>> A(N, vector<int>(M));
  REP(i, N) REP(j, M){
    cin >> A[i][j];
    A[i][j]--;
  }

  int ans = N;
  vector<int> cnt(N, 0);
  vector<int> ng;

  while((int)ng.size() < M-1){
    vector<int> num(M, 0);
    REP(i, N){
      num[A[i][cnt[i]]]++;
    }

    int ret = 0;
    REP(i, M) if(num[i] != 0) chmax(ret, num[i]);
    chmin(ans, ret);


    pair<int, int> p(0, 0);
    REP(i, M){
      if(p.first < num[i]){
        p.first = num[i];
        p.second = i;
      }
    }
    ng.emplace_back(p.second);

    REP(i, N){
      REP(j, ng.size()){
        if(A[i][cnt[i]] == ng[j]){
          cnt[i]++;
          j = -1;
        }
      }
    }
  }

  cout << ans << endl;
  

  return 0;
}

Measured memory_bytes: 1024
n=int(input())

ans=0

odd_list=[]
for i in range(1,n+1,2):
    odd_list.append(i)

for k in range(1,n+1,2):
    num=[]
    for i in odd_list:
        if k%i==0:
            num.append(i)
    if len(num)==8:
        ans+=1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n*3];
    long long l[n+1]={},r[n+1]={};
    priority_queue<int>rq;
    priority_queue<int,vector<int>,greater<int>>lq;
    for(int i=0;i<n*3;i++){
        cin>>a[i];
        if(i<n){
            l[0]+=a[i];
            lq.push(a[i]);
        }
        if(i>=n*2){
            r[0]+=a[i];
            rq.push(a[i]);
        }
    }
    for(int i=n;i<n*2;i++){
        lq.push(a[i]);
        l[i-n+1]=l[i-n]+a[i]-lq.top();
        rq.push(a[3*n-i-1]);
        r[i-n+1]=r[i-n]+a[3*n-i-1]-rq.top();
        lq.pop(),rq.pop();
    }
    long long m=-1000000000000000000;
    //for(int i=0;i<=n;i++)cout<<l[i]<<" "<<r[i]<<endl;
    for(int i=0;i<=n;i++)m=max(m,l[i]-r[n-i]);
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 6952
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      int M = nextInt();
      myout(24 + (24 - M));
	}
	//Method addition frame start



	//Method addition frame end
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

int64 Solve() {
  int n;
  cin >> n;
  vector<int64> xs(n + 1);
  for (int i = 0; i <= n; i++) {
    cin >> xs[i];
  }
  vector<int64> ys(n + 1);
  ys[n] = xs[n];
  for (int i = n - 1; i >= 0; i--) {
    ys[i] = ys[i + 1] + xs[i];
  }

  if (ys[0] == 0) return -1;

  int64 sum = 0;
  int64 r = 1;
  for (int i = 0; i <= n; i++) {
    sum += r;
    if (r < xs[i]) return -1;
    r -= xs[i];
    if (i < n) {
      r *= 2;
      if (r > ys[i + 1]) {
        r = ys[i + 1];
      }
    }
  }
  return sum;
}

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

  cout << Solve() << endl;
}

Measured memory_bytes: 4784
#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
#include <functional>
#include <vector>
#include <math.h>
#include <typeinfo>
using namespace std;

int main(void) {
	
	int A, B, C, X;
	cin >> A >> B >> C >> X;

	int cnt = 0;
	for (int i = 0; i <= A; i++)
	{
		for (int j = 0; j <= B; j++)
		{
			for (int k = 0; k <= C; k++)
			{
				if (i * 500 + j * 100 + k * 50 == X)
				{
					cnt++;
				}

			}
		}
	}

	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
//#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))

using namespace std;

int main(void)
{
	int N, M; cin >> N >> M;
	vector<int> k(M), p(M);
	vector<vector<int>> s(M);
	rep(i, 0, M) {
		cin >> k[i];
		s[i].resize(k[i]);
		rep(j, 0, k[i]) {
			int tmp;  cin >> tmp;
			s[i][j] = tmp - 1;
		}
	}
	rep(i, 0, M)cin >> p[i];

	int ans = 0;
	for (int bit = 0; bit < (1 << N); bit++) {
		bool judge = true;
		rep(i, 0, M) {
			int sum = 0;
			rep(j, 0, k[i]) {
				if (bit & (1 << s[i][j]))sum++;
			}
			if (sum % 2 != p[i])judge = false;
		}
		if (judge)ans++;
	}

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    
    long n = s.nextLong();
    long dMin = Long.MAX_VALUE;
    for (int i = 0; i < 5; i++) {
      long d = s.nextLong();
      dMin = Math.min(dMin, d);
    }
    long count = (n / dMin) + (n % dMin > 0 ? 1 : 0);
    System.out.println(4 + count);
  }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin >> s;
    bool flg = true;
    int count=0
    ;
    if(s.size()%2==1){
        for(int i=0;i<(s.size()-1)/2;i++){
            if(s[i]!=s[s.size()-1-i]) count++;
        }
    } else {
        for(int i=0;i<s.size()/2;i++){
            if(s[i]!=s[s.size()-1-i]) count++;
        }
    }
    
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define LENGTH 20

int main(){
  int p[LENGTH];
  int n;
  int result;
  int i;
  scanf("%d",&n);
  
  for(i=0; i<n; i++){
    scanf("%d",&p[i]);
  }
  for(i=0; i<n-2; i++){
    if((p[i+1] < p[i] && p[i+1]> p[i+2]) ||(p[i+1] > p[i] && p[i+1]<p[i+2]))
      result ++;
  }
  printf("%d", result);
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  2019/06/22  Problem: ABC 131 A / Link: http://abc131.contest.atcoder.jp/tasks/abc131_a  ----- */


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

	string s; cin >> s;
	bool bad = 0;
	FOR(i, 1, s.size()) {
		if (s[i - 1] == s[i])bad = 1;
	}
	cout << (bad ? "Bad" : "Good") << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n, a, b, ans;
	scanf("%lld%lld%lld", &n, &a, &b);
	if(a + b){
		ans = n / (a + b) * a;
		if(n % (a + b)) ans += min(a, n % (a + b));
	}else ans = 0;
	printf("%lld\n", ans);
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

ll mod = 998244353;


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

  string s;
  cin >> s;
  int n = s.length();
  int ret = 0;
  rep(i,n/2){
    if(s[i] != s[n-1-i])ret++;
  }
  cout << ret << endl;
}


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

int main(){
    int n;
    string str[10010];
    cin >> n;

    int ans = 0, a_end=0, b_start=0, atob = 0;
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        int len = (int)(s.length());
        bool prev_a = false;
        for(int j=0;j<len;j++){
            if (prev_a && s[j] == 'B'){
                ans++;
            }
            prev_a = false;
            if (s[j] == 'A') prev_a = true;
        }
        if (prev_a) a_end++;
        if (s[0]=='B') {
            b_start++;
            if(prev_a) atob++;
        }
    }
    // cout << ans << a_end << b_start << atob << endl;
    if(atob == a_end && atob == b_start && atob > 0) ans--;
    cout << ans + min(a_end, b_start) << endl;
    return 0;
}




Measured memory_bytes: 384
/*'''''''''''''''
 ----------------
 Md. Tarek Hossain Tusher
  Cumilla University
  Dept. of CSE

 ----------------
 ''''''''''''''''
 */
#include<stdio.h>
int main()
{
    int ara[3],sum;
    int i,j;
    for(i=0;i<3;i++)scanf("%d",&ara[i]);
    for(i=0,j=i+1;i<3 && j<3;){
        if(ara[i]>ara[j]){
            int temp=ara[i];
            ara[i]=ara[j];
            ara[j]=temp;
            i=0;
            j=i+1;
            }
        else {
            i++;
            j++;
        }
    }
    printf("%d\n",ara[0]+ara[1]);
return 0;
}


Measured memory_bytes: 128
import sys
range = xrange
input = raw_input

n = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

DP = [0]*(n+1)
DP[n] = n
for j in range(3):
    sell = A[j]
    extra = B[j] - sell
    if extra > 0:
        for i in reversed(range(sell,len(DP))):
            if DP[i] + extra > DP[i - sell]:
                DP[i-sell] = DP[i] + extra
n = max(DP)
A,B = B,A
 
DP = [0]*(n+1)
DP[n] = n
for j in range(3):
    sell = A[j]
    extra = B[j] - sell
    if extra > 0:
        for i in reversed(range(sell,len(DP))):
            if DP[i] + extra > DP[i - sell]:
                DP[i-sell] = DP[i] + extra
 
print(max(DP))

Measured memory_bytes: 227820
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


        public static long gcd(long x, long y)
        {
            if (y < x) gcd(y, x);
            while (y != 0)
            {
                var z = x % y;
                x = y;
                y = z;
            }
            return x;
        }
        public static long keta(long x)
        {
            var z = 1;
            while (x > 0)
            {
                x /= 10;
                z++;
            }
            return z;
        }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var hw = Reads();
            var h = hw[0];
            var w = hw[1];
            var x = new int[] { 0, 0, -1, 1 };
            var y = new int[] { -1, 1, 0, 0 }; 
            var s = new char[h][];
            for (int i = 0; i < h; i++)
            {              
                s[i] = ReadLine().ToCharArray();
            }
            bool ans = true;
            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j < w; j++)
                {
                    bool ff = true;
                    if (s[i][j] == '#')
                    {
                        ff = false;
                        for (int k = 0; k < 4; k++)
                        {                          
                                bool f = i + y[k] >= 0 && i + y[k] < h && j + x[k] >= 0 && j + x[k] < w && s[i + y[k]][j + x[k]] == '#';
                                if (f) ff = true;                       
                        }
                    }
                    if (!ff) ans = false;
                }
            }
            WriteLine(ans ? "Yes" : "No");
            

            Console.Out.Flush();
        }
    }
}



Measured memory_bytes: 19016
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
	
int main(){
	ios::sync_with_stdio(0) ;
    cin.tie(0) ;
    cout.tie(0) ;	
    string s1, s2;
    cin>>s1;
    cin>>s2;
    int count = 0;
    for(int i=0; i<s1.size(); i++){
    	if(s1[i]!=s2[i]){
    		count++;
    	}
    }
    cout<<count<<"\n";
	return 0;
	}

Measured memory_bytes: 3800
INFTY = 10**5+1
P = [1 for _ in range(INFTY)]
P[0]=P[1]=0
for i in range(2,int(INFTY**0.5)+1):
    for j in range(i*i,INFTY,i):
        P[j] = 0
R = [0 for _ in range(INFTY)]
for i in range(INFTY):
    if i%2==1:
        if P[i]==1 and P[(i+1)//2]==1:
            R[i] = 1
A = [0 for _ in range(INFTY+1)]
for i in range(INFTY):
    A[i+1] = A[i]+R[i]
Q = int(input())
for _ in range(Q):
    l,r = map(int,input().split())
    print(A[r+1]-A[l])

Measured memory_bytes: 55108
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <string>
using namespace std;


int main(void)
{
	int i = 0;
	while (true) {
		unsigned long x = 0;
		cin >> x;
		i++;
		if (x != 0) {
			cout << "Case " << i << ": " << x<<"\n";
		}
		else {
			break;
		}

	}
	return 0;
}



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

int main(){
    int n, i, tmp1, tmp2;

    cin >> n;
    vector<int> v(n);

    for(i=0;i<n;i++){
        cin >> v[i];
    }
    
    tmp1 = v[0];
    tmp2 = tmp1;

    for(i=0;i<n;i++){
        if(tmp1<v[i]){
            tmp1 = v[i];
        }
        if(tmp2>v[i]){
            tmp2 = v[i];
        }
    }

    cout << tmp1-tmp2 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int maxn = 100100;
struct edge{
    int u, v, w;
    edge(){}
    edge(int a, int b, int c): u(a), v(b), w(c){}
};
int dad[maxn];
int find(int x){
    return (x == dad[x])?x:dad[x] = find(dad[x]);
}
int main(){
    for(int e = 0; e < maxn; e++) dad[e] = e;
    vector<edge> values;
    int n;
    scanf("%d", &n);
    vector<edge> solve;
    for(int e = 0; e < n; e++){
        int a, b;
        scanf("%d %d", &a, &b);
        // printf("%d %d\n", a, b);
        solve.push_back(edge(a, b, e));
    }
    sort(solve.begin(), solve.end(), [](edge a, edge b){
        return a.u < b.u;
    });
    for(int e = 0; e < n; e++){
        // printf("%d %d %d\n", solve[e].w, solve[e].u, solve[e].v);
        if(e)
        values.push_back(edge(solve[e].w, solve[e-1].w,
            min(abs(solve[e].u - solve[e-1].u), abs(solve[e].v - solve[e-1].v))));
        if(e + 1 < n)
        values.push_back(edge(solve[e].w, solve[e+1].w,
            min(abs(solve[e].u - solve[e+1].u), abs(solve[e].v - solve[e+1].v))));
    }
    sort(solve.begin(), solve.end(), [](edge a, edge b){
        return a.v < b.v;
    });
    for(int e = 0; e < n; e++){
        // printf("%d\n", solve[e].w);
        if(e)
        values.push_back(edge(solve[e].w, solve[e-1].w,
            min(abs(solve[e].u - solve[e-1].u), abs(solve[e].v - solve[e-1].v))));
        if(e + 1 < n)
        values.push_back(edge(solve[e].w, solve[e+1].w,
            min(abs(solve[e].u - solve[e+1].u), abs(solve[e].v - solve[e+1].v))));
    }
    sort(values.begin(), values.end(), [](edge a, edge b){
        return a.w < b.w;
    });
    long long cost = 0;
    for(int e = 0; e < values.size(); e++){
        edge a = values[e];
        if(find(a.u) != find(a.v)){
            // printf("%d %d %d\n", a.u, a.v, a.w);
            dad[find(a.u)] = find(a.v);
            cost += a.w;
        }

    }
    printf("%lld\n", cost);
    return 0;
}


Measured memory_bytes: 10096
n,d = gets.split(" ").map(&:to_i)
pos =[]
i = 0
while i < n do
  pos[i] = gets.split(" ").map(&:to_i)
  i += 1
end
i = 0
sum = 0
while i < n do
  if (pos[i][0]**2 + pos[i][1]**2) ** 0.5 <= d
    sum += 1
  end
  i += 1
end
puts sum

Measured memory_bytes: 29196
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<30;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
char c[30][30];
int dp[30][30];
int H, W;
int sx, sy, gx, gy;

int bfs() {
  queue<P> que;
  rep(i, H) rep(j, W) dp[i][j] = inf;
  que.push(P(sx, sy));
  dp[sy][sx] = 0;

  while(!que.empty()) {
    P p = que.front(); que.pop();
    if(p.first == gx && p.second == gy) break;
    rep(i, 4) {
      int nx = p.first + dx[i];
      int ny = p.second + dy[i];
      if(0 <= nx && nx < W && 0 <= ny && ny < H && c[ny][nx] != '#' && dp[ny][nx] == inf) {
        que.push(P(nx, ny));
        dp[ny][nx] = dp[p.second][p.first] + 1;
      }
    }
  }
  return dp[gy][gx];
}

int main() {
  cin >> H >> W;
  rep(i, H)rep(j, W) cin >> c[i][j];

  int res = 0;
  rep(i, H){
    rep(j, W) {
      rep(k, H) {
        rep(l, W) {
          sy = i, sx = j;
          gy = k, gx = l;
          if(c[sy][sx] == '#' || c[gy][gx] == '#') continue;
          res = max(res, bfs());
        }
      }
    }
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>

const int MaxN = 1e5;
using namespace std;

struct NODE {
	int l, r; 
	bool operator < (const NODE A) const {
		return r < A.r;
	}
}a[MaxN + 5];
int n, m;
int main() 
{
	while(~scanf("%d%d", &n, &m)) {
		for (int i = 1; i <= m; i++) {
			scanf("%d%d", &a[i].l, &a[i].r);
		}
		sort (a + 1, a + m + 1);
		int now = 0, ans = 0;
		for (int i = 1; i <= m; i++) {
			if(a[i].l < now) continue;
			ans++;
			now = a[i].r;
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 896
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
   int n;
   cin>>n;
   V<ll> a(n);
   for(int i=0;i<n;i++)cin>>a[i];
   ll ans=a[0]-1;
   ll now=2;
   for(int i=1;i<n;i++){
       if(now==a[i])now++;
       ans+=(a[i]-1)/now;
   }
   cout<<ans<<"\n";
}

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

string a,b,c;

int main(){
	
  	cin >> a >> b >> c;
	char diff = 'A'-'a';
  	printf("%c%c%c\n",a[0]+diff,b[0]+diff,c[0]+diff);
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    double ans=0,v[1000];
    for(int i=0;i<n;i++){
        scanf("%lf",&v[i]);
    }
    sort(v,v+n);
    ans=(v[0]+v[1])/2;
    for(int i=2;i<n;i++){
        ans=(ans+v[i])/2;
    }
    printf("%.6f\n",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <cmath>
#include <cstdarg>
#include <cstdlib>
#include <string>

#include <vector>
#include <tuple>
#include <queue>
#include <algorithm>
using namespace std;

int max(int a, int b) {
    return (a>b)?a:b;
}

int main(int argc, char const *argv[])
{
    int K;
    cin >> K;

    vector<long long> memo(10);
    memo[0] = 0;
    if (K < 10) {
        cout << K << endl;
        return 0;
    }
    for(int i = 1; i < 10; i ++) {
        memo[i] = i;
    }

    long long ans;
    K -= 9;

    int now, mod;
    now = 1;

    while (1) {
        mod = memo[now] % 10;
        for (int i = max(mod-1,0); i<10 && i<=mod+1; i ++) {
            ans = memo[now] * 10 + i;
            memo.push_back(ans);
            K --;

            if (!K) {
                cout << ans << endl;
                return 0;
            }
        }
        now ++;
    }
    return 0;
}

Measured memory_bytes: 4564
// C++(GCC 9.2.1)
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
int rCum[202020], wCum[202020];

int main(){
    
    // 1. 入力情報.
    int N;
    char c[202020];
    scanf("%d %s", &N, c);
    
    // 2. 一次元累積和.
    rep(i, N){
        rCum[i + 1] = rCum[i];
        wCum[i + 1] = wCum[i];
        if(c[i] == 'R') rCum[i + 1]++;
        else            wCum[i + 1]++;
    }
    
    // 3. 最小回数を計算.
    // ex.
    // N = 5 の 場合, 操作後は, 
    // WWWWW, RWWWW, RRWWW, RRRWW, RRRRW, RRRRR の 6通りのいずれかと一致するはず.
    int ans = 2020202020;
    rep(i, N + 1){
        // 3-1. 'R'で構成される左側に含まれる'W'の個数.
        int lw = wCum[i];
        
        // 3-2. 'W'で構成される右側に含まれる'R'の個数.
        int rR = rCum[N] - rCum[i];
        
        // 3-3. 操作回数.
        int o = max(lw, rR);
        
        // 3-4. 最小値更新.
        ans = min(ans, o);
    }
    
    // 4. 出力.
    printf("%d\n", ans);
    return 0;
    
}

Measured memory_bytes: 5472
import bisect
n = int(input())
L = list(map(int, input().split()))
L.sort()

ans = 0
for i in range(n - 2):
    l = L[i]
    for j in range(i + 1, n - 1):
        ll = l + L[j]

        ind = bisect.bisect_left(L, ll)
        ans += ind - j - 1

print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
  int l,w,h,m,n,r;
  for(;;){
    cin >> l >> w >> h;
    if(l==0 && w==0 && h==0) break;
    if(max(l,max(w,h)) == l) m = w*w + h*h;
    else if(max(l,max(w,h)) == w) m = l*l + h*h;
    else m = l*l + w*w;
    cin >> n;
    while(n--){
      cin >> r;
      if((2*r)*(2*r) > m) cout << "OK" << endl;
      else cout << "NA" << 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);
        String S = sc.next();
        int length = S.length();
        char c=' ';
        char d=' ';
        int cnt = 0;

        for(int i=0; i<length/2; i++) {
            c = S.charAt(i);
            d = S.charAt(length-1-i);
            if(c!=d) {
                cnt++;
            }
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int k,a,b;
  cin>>k>>a>>b;
  bool p=false;
  rep(i,a,b+1){
    if(i%k==0){
      p=true;
    }
  }
  if(p) cout<<"OK"<<endl;
  else cout<<"NG"<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main()
{
    int N, M;
    cin >> N >> M;
    int vt[N][N], a[M], b[M];
    memset(vt, 0, sizeof(vt));
    for(int i=0; i<M; i++){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        vt[a[i]][b[i]]=1;
        vt[b[i]][a[i]]=1;
    }
    int ans=0;
    for(int m=0; m<M; m++){
        vt[a[m]][b[m]]=0;
        vt[b[m]][a[m]]=0;
        int cnt=1;
        int flag[N];
        memset(flag, 0, sizeof(flag));
        int now=0;
        flag[0]=1;
        queue<int> que;
        que.push(now);
        while(que.size()!=0){
            int tmp=que.front(); que.pop();
            for(int i=0; i<N; i++){
                if(vt[tmp][i]==1 && flag[i]==0){
                    flag[i]=1;
                    que.push(i);
                    cnt++;
                }
            }
        }
        if(cnt!=N) ans++;

        vt[a[m]][b[m]]=1;
        vt[b[m]][a[m]]=1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

LL count(const vector<int>& x, const vector<int>& y, const vector<int>& z)
{
    LL c = 0;
    for (int ix: x) {
        for (auto ity = upper_bound(y.begin(), y.end(), ix); ity != y.end(); ++ity) {
            int iy = *ity;
            for (auto itz = upper_bound(z.begin(), z.end(), iy); itz != z.end(); ++itz) {
                int iz = *itz;
                if (iz-iy != iy-ix) ++c;
            }
        }
    }
    return c;
}

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

    string S;
    int N;
    cin >> N >> S;
    vector<int> r;
    vector<int> g;
    vector<int> b;
    rep(i, N) {
        if (S[i] == 'R') {
            r.push_back(i);
        } else if (S[i] == 'G') {
            g.push_back(i);
        } else {
            b.push_back(i);
        }
    }

    LL ans = count(r, g, b) + count(r, b, g) + count(g, r, b) + count(g, b, r) + count(b, r, g) + count(b, g, r);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
	using namespace std;
	 
	typedef long long ll; 
	typedef unsigned long long	llu;
	typedef long double			ld;
	typedef vector< int > 		vi;
	typedef pair<int, int> 		pii;
	 
	#define int ll
	#define pb push_back
	#define sq(a) a*a
	#define endl '\n'
	#define iyas_salah ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define all(n)	v.begin(),v.end()
	#define rall(n) n.rbegin(), n.rend()
	#define rep(i,s,n) for(int i=s;i<int(n);i++)
	#define debug(x) cout<<"[" << #x << " is: " << x << "] "<<endl;
	 
	const int MAXN = 1e9 + 3;
	int32_t main() 
	{	iyas_salah
		#ifndef ONLINE_JUDGE
		freopen("in.txt","r",stdin);
		#endif
		/* ---code--- */ 	    	
		string a, b;
		cin >> a >> b;
		int ans = 0;
		for (int i = 0 ; i < a.size(); i++) {
			if (a[i] != b[i]) ans++;
		}	
		cout << ans << endl;
		/* ---------- */
		return 0;		
	}

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

#define REP(i,n) for(decltype(n) i=0; i<(n); ++i)
#define ALL(c) (c).begin(), (c).end()
#define st first
#define nd second
#define pb push_back

typedef pair<int,int> pii;
typedef vector<int> vi;

void solve(){
    int t[3];
    cin>>t[0]>>t[1]>>t[2];
    sort(t,t+3);
    cout<<t[0]+t[2]-t[1]<<'\n';
}

int main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    solve();
    return 0;
}


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

string s[30][30];
int H, W;

int main() {
	cin >> H >> W;
	rep(i, H) {
		rep(j, W) {
			cin >> s[i][j];
			if (s[i][j] == "snuke") {
				printf("%c%d\n", j+'A', i+1);
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	lli cnt=0, cnk=0;
	string s;
	cin >> s;

	rep(i,s.size()){
		if(i%2 == 0){
			if(s[i] == '1') cnt++;
			else cnk++;
		}else{
			if(s[i] == '0') cnt++;
			else cnk++;
		}
	}
	lli ans = Min(cnt, cnk);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int n,m;cin>>n>>m;
    int count=0;
    for(int i=n;i<=m;i++)
    {
        if(i%10==i/10000)
        {
            //cout<<i;
            if((i%100)/10==(i/1000)%10)
            {
                //cout<<i;
                count++;
            }
        }
        
        
    }
    
    cout<<count<<"\n";
    
    return 0;
}


Measured memory_bytes: 256
N,A,B=map(int,input().split())
MOD=10**9+7
def comb(n,k):
    if n<k:
        return 0
    if n<0 or k<0:
        return 0
    k=min(n-k,k)
    ans=1
    inv=[1]*(k+1)
    if k>=1:
        ans*=(n-k+1)%MOD
    for i in range(2,k+1):
        inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
        ans=ans*(n-k+i)*inv[i]%MOD
    return ans
print((pow(2,N,MOD)-1-comb(N,A)-comb(N,B))%MOD)

Measured memory_bytes: 10932
#ABC099C
N=int(input())
i=0
t=0
ans=N
for i in range(N+1):
    nine = 0
    six = 0
    t=i
    while (t>0):
        nine+=t%9
        t//=9
    t=N-i
    while (t>0):
        six+=t%6
        t//=6
    if ans>nine+six:
        ans=nine+six
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int N=50005,M=100005,K=256;
int n,m,x[M],y[M],vis[N],to[N];
char ans[M];
void GG(){
	puts("-1"); exit(0);
}
int main(){
	
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	n=read(),m=read(); int T=read();
	double t=clock();
	if(T==1){
		static bitset<N> s[N];
		For(i,1,n)s[i][i]=1;
		For(i,1,m){
			x[i]=read(); y[i]=read();
			s[x[i]]=s[y[i]]=s[x[i]]|s[y[i]];
		}
		For(i,1,n)if(s[i].count()==n){
			vis[i]=1;
			Rep(j,m,1){
				//cout<<x[i]<<" "<<vis[x[i]]<<endl;
				if(vis[x[j]])ans[j]='^'; else ans[j]='v';
				vis[x[j]]=vis[y[j]]=vis[x[j]]|vis[y[j]];
			}
			cout<<(ans+1)<<endl; return 0;
		}	
	}else{
		static bitset<K+2> s[M][K+2];
		For(i,1,m){
			x[i]=read(); y[i]=read();
		}
		For(i,1,n)For(j,i+1,min(n,K))s[0][i][j]=s[0][j][i]=1;
		For(o,0,1000){
			int node=0;
			For(j,0,511)to[j]=0;
			For(j,0,min(255,n-1)){
				int t=rnd()%min(n,500)+1;
				while(to[t])t=rnd()%min(n,500)+1;
				to[t]=++node;
			}
			For(i,1,m){
				memcpy(s[i],s[i-1],sizeof(s[i]));
				int X=to[x[i]],Y=to[y[i]];
				if(X&&Y){
					s[i][Y]=s[i][X]=s[i][Y]|s[i][X];
					For(j,1,K)s[i][j][X]=s[i][j][Y]=s[i][j][X]|s[i][j][Y];
					s[i][X][Y]=s[i][Y][X]=s[i][X][X]=s[i][Y][Y]=0;
				}
			}
			For(X,1,n)For(Y,X+1,min(n,500))if(to[X]&&to[Y]&&s[m][to[X]][to[Y]]){
				Rep(i,m,1){
					if(s[i-1][to[X]][to[Y]]){
						if(X==x[i]||Y==x[i])ans[i]='^';
						else ans[i]='v';
					}else{
						if(X==x[i]||Y==x[i]){
							ans[i]='^';
							if(X==x[i])X=y[i]; else Y=y[i];
						}else{
							ans[i]='v';
							if(X==y[i])X=x[i]; else Y=x[i];
						}
					}
				}
				cout<<(ans+1)<<endl;
				exit(0);
			}
			if((clock()-t)/CLOCKS_PER_SEC>1.6)GG();
		}
	}
	GG();
}

Measured memory_bytes: 1009664
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1e5+5,M=2*N,inf=1e8;
int n,i,et,he[N],l[N],r[N];bool flag;
struct edge{int l,to;}e[M];
int read(){
	char c=getchar();int k=0;for (;c<48||c>57;c=getchar());
	for (;c>47&&c<58;c=getchar()) k=(k<<3)+(k<<1)+c-48;return k;
}
void put(int x){if (x>9) put(x/10);putchar(x%10+48);}
void write(int x){
	if (x<0) putchar('-'),x=-x;
	put(x);putchar('\n');
}
void dfs1(int x,int fa){
	for (int i=he[x];i;i=e[i].l){
		int y=e[i].to;if (y==fa) continue;
		dfs1(y,x);
		l[x]=max(l[x],l[y]-1);
		r[x]=min(r[x],r[y]+1);
	}
}
void dfs2(int x,int fa){
	for (int i=he[x];i;i=e[i].l){
		int y=e[i].to;if (y==fa) continue;
		l[y]=max(l[y],l[x]-1);
		r[y]=min(r[y],r[x]+1);
		if (l[x]==l[y]) flag=0;
		dfs2(y,x);
	}
}
int main(){
	for (n=read(),i=1;i<n;i++){
		int x=read(),y=read();
		e[++et].l=he[x];he[x]=et;e[et].to=y;
		e[++et].l=he[y];he[y]=et;e[et].to=x;
	}
	for (i=1;i<=n;i++) l[i]=-inf,r[i]=inf;
	for (i=read();i--;){
		int x=read();l[x]=r[x]=read();
	}
	dfs1(1,0);flag=1;dfs2(1,0);
	for (i=1;i<=n;i++) if (l[i]>r[i]) flag=0;
	if (!flag){puts("No");return 0;}
	for (puts("Yes"),i=1;i<=n;i++) write(l[i]);
}

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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n, k;
  cin >> n >> k;
  k += 1;

  vll a(n);
  vll b(n);
  rep(i, n) {
    cin >> a[i] >> b[i];
  }

  ll ans = 0;

  rep(bt, 32) {
    ll t = 1 << bt;
    if ((t & k) == 0)
      continue;

    ll mask = k - t;
    mask |= t - 1;

    ll s = 0;
    rep(i, n) {
      if ((mask | a[i]) > mask)
        continue;
      s += b[i];
    }
    chmax(ans, s);
  }

  cout << ans << endl;

  return 0;
}


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

#define ll long long
#define pb push_back
#define mp make_pair


int main() 
{
	 ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cin.tie(NULL);
     
		 int a,b,c,d,e;
		 cin>>a>>b>>c>>d>>e;
		 if(a==0)
		{ cout<<1;
		 return 0;}
		 if(b==0)
		 {cout<<2;
		 return 0;}
		 if(c==0)
		{ cout<<3;
		 return 0;}
		 if(d==0)
		{ cout<<4;
		 return 0;}
		 if(e==0)
		 {cout<<5;
		 return 0;}
	   
   }
		 
    
            



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

using namespace std;
using ll = long long;
int n, m, v, p;
const int maxn = 1e5+7;
vector<ll>a;
ll pre[maxn];
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	cin >> n >> m >> v >> p;
	a.resize(n);
	for(auto &u:a){
		cin >> u;
	}
	sort(a.begin(), a.end(), [&](int a, int b){
		return a > b;
	});
	for(int i=0; i<n; ++i){
		pre[i+1] = pre[i]+a[i];
	}
	ll ans = p;
	for(int i=p; i<n; ++i){
		if(a[i]+m<a[p-1])break;
		ll cur = v-(n-(i-p+1));//需要超过的人里的投票数 
		if(cur<=0){//全给不会产生影响的人投票 
			ans++;
			continue;
		}
		if(cur*m<=(i-p+1)*(a[i]+m)-(pre[i]-pre[p-1]))ans++;//需要超过的人里投票 
	}
	cout << ans; 
} 

Measured memory_bytes: 1792
// Problem : A - Takoyaki
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

void solve()
{
	int n,x,t;cin>>n>>x>>t;
	cout<<t*((n+x-1)/x);
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


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

int main(){
  int n,t;cin>>n;bool f=1;
  REP(i,n){
    cin>>t;
    if(!(t%2)){
      if((!(t%3))||(!(t%5))) f=1;
      else{
        f=0;
        break;
      }
    }
  }
 
  cout<<(f?"APPROVED":"DENIED");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    long long int a[n];
    for(int i=0;i<n;i++)cin >> a[i];
    sort(a,a+n);
    priority_queue<long long int> q;
    q.push(a[n-1]);
    long long int ans=0;
    for(int i=n-2;i>=0;i--){
        ans += q.top();
        q.pop();
        q.push(a[i]);
        q.push(a[i]);
    }
    cout << ans;
}

Measured memory_bytes: 6924
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>
#include <stack>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator<< (ostream &out, const vector<int> &b) {
    for (auto k : b) out << k << " ";
    return out;
}

istream& operator>> (istream& in, pii& b) {
    in >> b.first >> b.second;
    return in;
}

ostream& operator<< (ostream& out, const pii& b) {
    out << "{" << b.first << ", " << b.second << "}";
    return out;
}

template <typename T1, typename T2> inline bool chkmin(T1 &x, const T2 &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T1, typename T2> inline bool chkmax(T1 &x, const T2 &y) {if (x < y) {x = y; return 1;} return 0;}


#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
    // const int mod = 2600000069;
    // const int p = 10;
#else
    #define dbg(x) 57
    const int INF = 1e18;
    // const int mod = 2600000069;
    // const int p = 179;
#endif

const ld PI = acos(-1);

#define time clock() / (double) CLOCKS_PER_SEC

// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,sse3,sse4")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("fast-math")
// #pragma GCC target("avx2")  
// #pragma GCC optimize("section-anchors")
// #pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
// #pragma GCC optimize("vpt")
// #pragma GCC optimize("rename-registers")
// #pragma GCC optimize("move-loop-invariants")
// #pragma GCC optimize("unswitch-loops")
// #pragma GCC optimize("function-sections")
// #pragma GCC optimize("data-sections")

mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x, p;
    cin >> x >> p;
    cout << fixed << setprecision(8);
    if (x & 1) {
        cout << ((100.0 - p) / 100.0 * (ld)(x + 1) / (ld)p * 100.0 + (ld)p / 100.0 * (ld)(x - 1) / (ld)p * 100.0) / 2.0 + 1.0 << "\n";
    } else {
        cout << ((ld)x / (ld)p * 100.0) / 2.0 << "\n";
    }
}
/*

*/

Measured memory_bytes: 3796
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        int [] a = new int[n + 2];
        a[0] = 0;
        a[n + 1] = 0;
        for (int i = 1; i <= n; i++) {
            a[i] = cin.nextInt();
        }
        int x = 0;
        int pre_part_exp = 0;
        int end_part_exp = 0;
        for (int i = 2; i <= n + 1; i++) {
            end_part_exp += Math.abs(x - a[i]);
            x = a[i];
        }
        System.out.println(end_part_exp);
        for (int i = 2; i <= n; i++) {
            end_part_exp = end_part_exp
                           - Math.abs(a[i + 1] - a[i])
                           - Math.abs(a[i] - a[i - 2])
                           + Math.abs(a[i + 1] - a[i - 1]);
            pre_part_exp += Math.abs(a[i - 1] - a[i - 2]);
            System.out.println(pre_part_exp + end_part_exp);
        }
    }
}


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

int main()
{
  int N,K;
  cin >> N >> K;
  
  int d[K];
  int A[K][N];

  for (int k=0;k<K;k++)
  	for (int i=0;i<N;i++)
    	A[k][i] = 0;
  
  for (int k=0;k<K;k++) {
    cin >> d[k];
    for (int i=0; i<d[k]; i++) {
		cin >> A[k][i];
    }
  }
  
  bool holder[N];
  for (int i=0;i<N;i++)
    holder[i] = false;
  
  for (int k=0;k<K;k++){
    for (int i=0; i<d[k]; i++) {
      if (A[k][i] != 0)
       	holder[A[k][i]-1] = true;
    }
  }

  int cnt = 0;
  for (int i=0;i<N;i++) {
    if (holder[i])
      cnt++;
  }
  
  cout << N-cnt << endl;
}

Measured memory_bytes: 3664
import java.util.*;

public class Main {

    public static void main(String[] args) {
       Scanner scan=new Scanner(System.in);

        int n=scan.nextInt();
        int l=scan.nextInt();
        String []s=new String[n];

        for(int i=0;i<n;i++){
            s[i]=scan.next();
        }
        Arrays.sort(s);
        for(int i=0;i<n;i++){
            System.out.print(s[i]);
        }
        System.out.println();

    }
}

Measured memory_bytes: 9940
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int n,m,t[111];
  scanf("%d",&n);
  for(int i = 0; i < n; i++){
    scanf("%d",&m);
    for(int j = 0; j < m; j++){
      scanf("%d",t+j);
      if(j)t[j-1] -= t[j];
    }
    t[m-1] = 0;
    sort(t,t + m);
    printf("%d %d\n",-t[0],t[m-1]);
  }
}

Measured memory_bytes: 1204