akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int bingo[3][3];
  rep(i,3) rep(j,3) cin >> bingo[i][j];
  int N;cin >> N;
  rep(i,N){
    int x;cin >> x;
    rep(i,3)rep(j,3) if(bingo[i][j] == x) bingo[i][j] = 0;
  }
  bool sat = false;
  rep(i,3){
    bool check = true;
    rep(j,3) if(bingo[i][j] != 0) check=false;
    if(check) sat = true;
  }
  rep(j,3){
    bool check = true;
    rep(i,3) if(bingo[i][j] != 0) check=false;
    if(check) sat = true;
  }
  bool check = true;
  rep(i,3) if(bingo[i][i] != 0) check = false;
  if(check) sat = true;

  check = true;
  rep(i,3) if(bingo[i][2-i] != 0) check = false;
  if(check) sat = true;

  YesNo(sat);
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner();
		int n = sc.nextInt();
		long x = sc.nextLong();

		System.out.println(calc(n, x));
	}


	static long calc(int n, long x){
		if(n == 0)
			return 1;
		long sum = 0;
		x--;
		long length = length(n-1);
		long p = p(n-1);
		if(x > 0){
			if(length <= x)
				sum += p;
			else
				sum += calc(n-1, x);
			x -= length;
		}
		if(x > 0){
			x--;
			sum++;
		}
		if(x > 0){
			if(length <= x)
				sum += p;
			else
				sum += calc(n-1, x);
		}

		return sum;
	}

	static long length(int n){
		return 1 + 4 * ((long)Math.pow(2, n) -1);
	}

	static long p(int n){
		return 1 +2 * ((long)Math.pow(2, n) -1);
	}
}

class Scanner {
	private static final int SPACE = (int)' ';
	private static final int LINE_END_0 = 13;
	private static final int LINE_END_1 = 10;
	private static final int BEFORE = -1;
	private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	public String next(){
		StringBuilder sb = new StringBuilder();
		
		int length = BEFORE;
		readLoop: while(true) {
			try {
				int value = br.read();
				switch(value) {
				case LINE_END_1:
					if(length == BEFORE)
						break;
					
					if((int)sb.charAt(length) == LINE_END_0)
						sb.deleteCharAt(length);
				case SPACE:
					break readLoop;
				}
				sb.append((char)value);
				length++;

			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return sb.toString();
	}
	
	public String[] nextArray(int length) {
		String[] array = new String[length];
		for(int i = 0; i < length; i++)
			array[i] = next();
		return array;
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
	
	public double[] nextDoubleArray(int length) {
		double[] array = new double[length];
		for(int i = 0; i < length; i++)
			array[i] = nextDouble();
		return array;
	}
	
	public int nextInt() {
		return Integer.parseInt(next());
	}
	
	public int[] nextIntArray(int length) {
		int[] array = new int[length];
		for(int i = 0; i < length; i++)
			array[i] = nextInt();
		return array;
	}
	
	public long nextLong() {
		return Long.parseLong(next());
	}
	
	public long[] nextLongArray(int length) {
		long[] array = new long[length];
		for(int i = 0; i < length; i++)
			array[i] = nextLong();
		return array;
	}
	
	public boolean ready() {
		try {
			return br.ready();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}
}


Measured memory_bytes: 21204
#include <stdio.h>

int main(void)
{
	int a,b,c,i,k[100000],x=0;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++){
		k[i]=c%i;
		if(k[i]==0){
			x++;
		}
	}
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 1808
#include<stdio.h>
#include<string.h>

int main(void){
    
    int N,i;
    char S[10002],alpha_num;

    scanf("%d",&N);
    scanf("%s",S);

    for(i = 0;i < strlen(S);i++){
        alpha_num = S[i] + (char)N;
        if(alpha_num > 'Z'){
            alpha_num -= 26;
        }
        printf("%c",alpha_num);
    }

    printf("\n");
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>

int main()
{
  int len1, len2, i, j = 0, k;
  char str1[100];
  char str2[100];
  char str3[200];

  scanf("%s", str1);
  scanf("%s", str2);
  
  sprintf(str3,"%s%s\n",str1,str1);
    
  if(strstr(str3,str2) != NULL){
    printf("Yes\n");
  } else{
    printf("No\n");
    }
  return 0;
}

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

int main()
{
	int h,w;
	cin>>h>>w;
	
	set<pair<int,int> > s;
	multiset<int> ms;
	
	int l[h],r[h];
	
	for(int i=0;i<h;i++)
	{
		cin>>l[i]>>r[i];
	}	
	
	for(int i=1;i<=w;i++)
	{
		s.insert({i,i});
		ms.insert(0);
	}
	
	for(int i=0;i<h;i++)
	{
      	if(s.size()==0)
        {
          	cout<<-1<<endl;
          	continue;
        }
      
		auto itr=s.lower_bound({l[i],0});
		vector<pair<int,int> > del;
		
		if(r[i]==w)
		{
			while(itr!=s.end() && itr->first<=r[i])
			{
				del.push_back(*itr);				
				++itr;
			}
		}
		else
		{
			int max_start=0;
			
			while(itr!=s.end() && itr->first<=r[i])
			{
				del.push_back(*itr);
			
				max_start=max(max_start,itr->second);
				
				++itr;
			}
			
          	if(max_start!=0)
            {
				s.insert({r[i]+1,max_start});
				ms.insert(r[i]+1-max_start);
            }
		}
		
      	
		for(auto ele:del)
		{
			s.erase(ele);
			ms.erase(ms.find(ele.first-ele.second));
		}
      
		if(ms.size())
		{
			cout<<*ms.begin() + i+1 <<endl;
		}
		else
		{
			cout<<-1<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 24004
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPL(i,f,n) for(int i=f, i##_len=(n); i<i##_len; ++i)
typedef long long ll;

int func(int x) {
	if (x % 2 != 0)return 0;
	return 1 + func(x / 2);
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N,K,ans = 0;
	cin >> N >> K;
	ans = (N-2)/(K-1)+1;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

char *ans[10];
int n, p, i;
int main(){
    ans[0] = "1111110";
    ans[1] = "0110000";
    ans[2] = "1101101";
    ans[3] = "1111001";
    ans[4] = "0110011";
    ans[5] = "1011011";
    ans[6] = "1011111";
    ans[7] = "1110010";
    ans[8] = "1111111";
    ans[9] = "1111011";
    while(scanf("%d", &n),~n){
	char *now = "00000000";
	while(n--){
	    scanf("%d", &p);
	    for(i = 6;i >= 0;i--){
		printf("%d", !(ans[p][i] == now[i]));
	    }
	    puts("");
	    now = ans[p];
	}
    }
    return 0;
}

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

using namespace std;

const long long inf=(long long)2147483647;
const int maxn=1e5;

long long seg[4*maxn+7];
int n;


void change(int id, int idx, int l, int r, int val)
{
    if(l+1==r)
    {
        seg[id]=val;
        return;
    }

    int mid=(l+r)/2;

    long long x1=inf,x2=inf;
    if(idx<mid)
        change(id*2, idx, l, mid, val);
    else
        change(id*2+1, idx, mid, r, val);

    seg[id]=min(seg[id*2],seg[id*2+1]);
}

int ask(int id, int L, int R, int l, int r)
{
    //cout<<L<<" "<<R<<" "<<l<<" "<<r<<" "<<seg[id]<<endl;
    if(l<=L && R<=r)
        return seg[id];

    int mid=(L+R)/2;
    long long   x1=inf,x2=inf;
    if(l<mid)
        x1=ask(id*2, L, mid, l, min(mid,r));
    if(r>mid)
        x2=ask(id*2+1, mid, R, max(mid,l), r);

    return min(x1,x2);
}

int main()
{
    cin>>n;
    int q;
    cin>>q;

    for(int i=1;i<=4*maxn;i++)
        seg[i]=inf;

    while(q--)
    {
        int x,y,z;
        cin>>x>>y>>z;
        if(x==0)
            change(1,y+1,1,n+1,z);
        else
            cout<<ask(1,1,n+1,y+1,z+2)<<endl;

    }
}

Measured memory_bytes: 4284
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007


#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main(){
  ll h,w; 
  cin>>h>>w;
  if(h==1||w==1){
    cout << 1 << endl;
    return 0;
  }
  ll w1 = w/2+w%2;
  ll w2 = w/2;
  ll h1 = h/2;
  ll h2 = h%2;
  cout << h1*(w1+w2)+h2*w1 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.lang.*;
import java.io.*;
import java.util.*;


public class Main {
	
	public static void main(String[] args) throws java.lang.Exception {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(in, out);
		out.close();
	}
}

class TaskA {
	
	public void solve(InputReader in, PrintWriter out)  {
		int w = in.nextInt(), a = in.nextInt(), b = in.nextInt();
		
		if (b>=a && b<=a+w) {
			out.println("0");
		} else if (b+w>=a && b+w<=a+w) {
			out.println("0");
		} else {
			int x1 = Math.abs(a-b), x2 = Math.abs(a+w-b);
			int ans1 = Math.min(x1, x2);
			int y1 = Math.abs(a-b-w), y2 = Math.abs(a+w-b-w);
			int ans2 = Math.min(y1, y2);
			int ans = Math.min(ans1, ans2);
			out.println(ans);
		}
	}
}

class InputReader {
	public BufferedReader reader;
	public StringTokenizer tokenizer;
	
	public InputReader(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());
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
	
	public long nextLong() {
		return Long.parseLong(next());
	}
}

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main() {
    string s;
    cin >> s;
    int n = s.size();
    int cnt=0;
    rep(i, 0, n-1){
        if(s[i]=='B'&&s[i+1]=='W')cnt++;
        if(s[i]=='W'&&s[i+1]=='B')cnt++;
    }
    cout << cnt << endl;
}

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


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

	//primes_extend(10,100);
	//primes_extend(100,10000);

	vector<int64_t> f(n+1);
	f[1]=0;
	for (int i=2;i<=n;++i)
	{
		int j=i;
		while (j<=n)
		{
			++f[j];
			j+=i;
		}
	}

	int64_t sum=0;
	for (int i=1;i<=n;++i)
	{
		sum+=i*(f[i]+1);
		//fprintf(stderr,"%d %lld\n",i,f[i]+1);
	}
	cout << sum << endl;
}







Measured memory_bytes: 81400
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 1e3;
const lli INF = 1e18;
const lli MOD = 1e9+7;

vi m;
vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	m = vi(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

// ---- コーディングはここから！ ('-')7


int main(){_
	lli n; cin>>n;
	lli d,c=0; cin>>d;
	d = d*d;
	fore(i,0,n){
		lli a,b;cin>>a>>b;
		if(a*a + b*b<=d)c++;
	}
	cout<<c<<ENDL;

}


Measured memory_bytes: 3656
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int h, w; cin >> h >> w;
  vector<vector<char> > s(h, vector<char>(w)); REP(i, h) REP(j, w) cin >> s[i][j];
  REP(i, h) REP(j, w) if (s[i][j] == '#') {
    bool ng = true;
    REP(k, 4) {
      int y = i + dy[k], x = j + dx[k];
      if (0 <= y && y < h && 0 <= x && x < w && s[y][x] == '#') ng = false;
    }
    if (ng) {
      cout << "No" << '\n';
      return 0;
    }
  }
  cout << "Yes" << '\n';
  return 0;
}


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

int main()
{
	int n;
	int m,i;
	int a[4];
	int flag=0;
	int b,c;
	memset(a,-1,sizeof(a));
	scanf("%d%d",&n,&m);
	for(i=0;i<m;i++)
	{
		scanf("%d%d",&b,&c);
		if(a[b]==-1)
		{
			a[b]=c;
		}
		else
		{
			if(a[b]!=c)
			flag=1;
		}
	}
	int cnt=0;
	if(flag)
	printf("-1\n");
	else
	{
		if((a[1]==0)&&n!=1)
		printf("-1\n");
		else if(a[1]==-1&&n==1)
		printf("0\n");
		else
		{
			for(i=0;i<n;i++)
			{
				if(a[n-i]!=-1)
				cnt+=a[n-i]*pow(10,i);
				else
				{
					if(n-i==1)
					{
						if(n!=1)
						a[1]=1;
					}
					else
					a[n-i]=0;
					cnt+=a[n-i]*pow(10,i);
				}
			}
			printf("%d\n",cnt);
		}
	}
	return 0;
} 

Measured memory_bytes: 256
#define MAX 101

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

void initialize();

void push(int x);

int pop();

bool isEmpty();

bool isFull();

int top = 0;
int S[MAX] = {};

int main(void) {
	int a, b;
	char s[2];

	while (scanf("%s", s) != EOF) {
			if (s[0] == '+') {
				b = pop();
				a = pop();
				push(a + b);
			}
			else if (s[0] == '-') {
				b = pop();
				a = pop();
				push(a - b);
			}
			else if (s[0] == '*') {
				b = pop();
				a = pop();
				push(a * b);
			}
			else {
				push(atoi(s));
			}
	}

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

	return 0;
}

void initialize() {
	top = 0;
}

bool isEmpty() {
	if (top == 0)
		return 1;
	else
		return 0;
}

bool isFull() {
	if (top >= MAX - 1)
		return 1;
	else
		return 0;
}

void push(int x) {
	if (!isFull())
		S[++top] = x;
}

int pop() {
	if (!isEmpty())
		return S[top--];
}

Measured memory_bytes: 548
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    vector<pair<ll, ll>> v;
    rep(i,n){
        ll a, b;
        cin >> a >> b;
        v.emplace_back(a, b);
    }
    sort(v.begin(), v.end());
    rep(i,n){
        if(v[i].second >= k){
            cout << v[i].first << endl;
            return 0;
        }
        k -= v[i].second;
    }
    return 0;
}

Measured memory_bytes: 2420
//Average Length

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<int,int> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    int n;cin>>n;
    vector<p>a(n);
    rep(i,0,n)cin>>a[i].first>>a[i].second;
    double m=0;
    rep(i,0,n){
        rep(j,i+1,n){
            m+=sqrtl((a[i].first-a[j].first)*(a[i].first-a[j].first)+(a[i].second-a[j].second)*(a[i].second-a[j].second));
        }
    }
    printf("%.15f",m/n*2);
    return 0;
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
    
#define ll long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define pre(i , j , n) for(ll i = j ; i >= n ; i--)
#define all(x) x.begin(), x.end()
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<char>	vc;
typedef vector<bool>	vb;
typedef vector<double>	vd;
#define br "\n"
#define MAXIM 1000003

void solve(){
    ll x;
	cin >> x;
	ll r = 0;
	rep(i,1,MAXIM){
		r = ((r*10) + 7) % x;
		if(r == 0){
			cout << i;
			return;

		}
	}
	cout << -1;
}
 
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif  
	ll t = 1;
	// cin >> t;
	rep(i,0,t){
		solve();
	}
 
}

Measured memory_bytes: 3628
#include <cstdio>
int main()
{
	int a,b,c,d;
	while(~scanf("%d%d%d%d",&a,&b,&c,&d)){
		if(a+b==c+d)
			printf("Balanced\n");
			if(a+b<c+d)
				printf("Right\n");
				if(a+b>c+d)
					printf("Left\n");
	}
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;
 
int main() {
    int counter[26] = {};
    int num = 0;
    char d[26];
    char ch;
    while(cin >> ch){
        num = ch -'A';
        if(num > 26) num = ch-'a';
        counter[num]++;
    }

    for (int i = 0; i < 26; ++i)
    {
        int e = 'a' + i;
        d[i] = e;
    }

    for (int i = 0; i < 26; ++i)
    {
        cout << d[i] << " : " << counter[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 1140
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>

using namespace std;

#define LSB(i) ((i)&(-(i)))

const int MOD = 1e9 + 7;

struct BIT
{
    int n;
    vector<int> a;

    BIT(int _n) { n = _n; a.assign(n+1, 0); }
    void update(int x, int v) {
        while (x <= n) {
            a[x] = (a[x] + v) % MOD;
            x += LSB(x);
        }
    }
    int get(int x) {
        int ans = 0;
        while (x > 0) {
            ans = (ans + a[x]) % MOD;
            x -= LSB(x);
        }
        return ans;
    }
};

int main()
{
    int n, m; scanf("%d %d", &n, &m);
    vector<int> x(n), y(m);
    for (int i = 0; i < n; ++i) scanf("%d", &x[i]);
    for (int i = 0; i < m; ++i) scanf("%d", &y[i]);

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    // Initialize leftIdx + rightIdx
    vector<int> leftIdx(n), rightIdx(n);

    for (int i = 0; i < n; ++i) {
		leftIdx[i] = (i == 0) ? -1 : leftIdx[i-1];
        while (leftIdx[i]+1 < m && y[leftIdx[i]+1] < x[i]) ++leftIdx[i];
    }
    for (int i = n-1; i >= 0; --i) {
        rightIdx[i] = (i == n-1) ? m : rightIdx[i+1];
        while (rightIdx[i]-1 >= 0 && y[rightIdx[i]-1] > x[i]) --rightIdx[i];
    }

    // dists <- distance to left, right
    vector< pair<int, int> > dists;
    dists.reserve(n);
    for (int i = 0; i < n; ++i) {
        if (leftIdx[i] == -1 || rightIdx[i] == m) continue;
        dists.push_back({x[i] - y[leftIdx[i]], y[rightIdx[i]] - x[i]});
//        cerr << x[i] - y[leftIdx[i]] << ' ' << y[rightIdx[i]] - x[i] << endl;
    }
//    cerr << endl;
    sort(dists.begin(), dists.end());

    map<int, int> indexed;
    map<int, vector<int> > queries;

    indexed[-1] = 1;
    for (pair<int, int> p : dists) {
        indexed[p.second] = 1;
    }
    int tmp = 1;
    for (map<int, int>::iterator it = indexed.begin(); it != indexed.end(); ++it) {
        it->second = tmp++;
    }

    for (pair<int, int> p : dists) {
        queries[p.first].push_back(indexed[p.second]);
    }

    BIT bit(tmp);
    bit.update(1, 1);
    for (pair< int, vector<int> > p : queries) {
        vector<int> v = p.second;
        sort(v.begin(), v.end());
        v.erase(unique(v.begin(), v.end()), v.end());
//        for (int i : v) cerr << i << ' '; cerr << endl;
        for (int i = v.size() - 1; i >= 0; --i) {
            bit.update(v[i], bit.get(v[i]-1));
        }
//		for (int i = 1; i <= tmp; ++i) cerr << bit.get(i) - bit.get(i-1) << ' '; cerr << endl;
//		for (int i : v) bit.update(i, bit.get(i-1));
//        cerr << "ans: " << bit.get(tmp) << endl;
    }

    cout << bit.get(tmp) << endl;
}


Measured memory_bytes: 18048
#include <iostream>
#include <vector>
#define YES(condition) if(condition) cout << "YES" << endl; else cout << "NO" << endl
#define Yes(condition) if(condition) cout << "Yes" << endl; else cout << "No" << endl

using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    vector< vector<bool> > board(h + 2, vector<bool>(w + 2));
    for (int i = 1; i <= h; ++i) for (int j = 1; j <= w; ++j) {
        char buf;
        cin >> buf;
        board.at(i).at(j) = (buf == '#');
    }
    bool flag = true;
    for (int i = 1; i <= h; ++i) for (int j = 1; j <= w; ++j) {
        if (!board.at(i).at(j) || board.at(i).at(j - 1) || board.at(i).at(j + 1) || board.at(i - 1).at(j) || board.at(i + 1).at(j)) continue;
        flag = false;
        break;
    }
    Yes(flag);
    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n, t;
    cin >> n >> t;

    vector<P> ab(n);
    rep(i, n) cin >> ab[i].first >> ab[i].second;

    vector<vector<ll>> dp(n + 1, vector<ll>(t + (*max_element(all(ab))).first + 1));
    ll ans = 0;
    sort(all(ab));
    rep(i, n) {
        rep(j, t) {
            ll nxt = j + ab[i].first;
            dp[i + 1][j] = max(dp[i][j], dp[i + 1][j]);
            dp[i + 1][nxt] = max(dp[i + 1][nxt], dp[i][j] + ab[i].second);
            ans = max(ans, dp[i + 1][nxt]);
        }
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 144080
a,b,c = map(int, input().split())
if a == max(a,b,c):
    res = a*10 + b + c
if b == max(a,b,c):
    res = b*10 + a + c
if c == max(a,b,c):
    res = c*10 + a + b
print(res)


Measured memory_bytes: 38492
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Numerics;




namespace contest
{

    class contest
    {


        static void Main(string[] args)
        {


      


            string s = Console.ReadLine();

            var cp = s.Reverse().ToArray();

            bool ok = true;
            for(int i =0; i<s.Length; i++)
            {
                if(!check(cp[i], s[i]))
                {
                    ok = false;
                    break;
                }
            }

            if (ok) Console.WriteLine("Yes");
            else Console.WriteLine("No");



        }

		public static bool check(char a, char b)
        {
            if (a == 'b' && b == 'd') return true;
            if (a == 'd' && b == 'b') return true;
            if (a == 'p' && b == 'q') return true;
            if (a == 'q' && b == 'p') return true;
            
            return false;
        }
        

    }


   

    
}


Measured memory_bytes: 4440
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int a, b, c; cin >> a >> b >> c;
	println(a*b/2);
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <cstdio>

#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

int main() {
  long a, b;
  long x, y;
  long gcd, lcm;

  while( std::cin >> a >> b ) {
    x = a;
    y = b;

    if( x < y ) std::swap(x, y);

    while( y != 0 ) {
      x %= y;
      std::swap(x, y);
    }

    gcd = x;
    lcm = (a / gcd) * b;

    std::cout << gcd << " " << lcm << std::endl;
  }  

  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> pii;

inline bool valid(int x, int n) {
    return 0 <= x && x < n;
}

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

template <typename T>
inline T pop(queue<T>& q) {
    T front = q.front();
    q.pop();
    return front;
}

template <typename T>
inline T gcd(T a, T b) {
    for (; b; a %= b, swap(a, b));
    return a; 
}

template <typename T>
tuple<T, T, T> xgcd(T a, T b) {
    if (b == 0) return {1, 0, a};
    T x, y, g;
    tie(x, y, g) = xgcd(b, a%b);
    return {y, x-(a/b)*y, g};
}

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

    int N, M; cin >> N >> M;
    ll A = 0;
    while (M--) {
        ll a; cin >> a;
        A += a;
    }

    if (A > N) cout << -1;
    else cout << N-A;
}

Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {
	static char[][] grid;
	static long[][] dp;
	static int h, w;

	public static void main(String[] args) throws IOException {
		PrintWriter pw= new PrintWriter(System.out);
		Scanner sc = new Scanner(System.in);
 int mod=(int)1e9+7;
		h = sc.nextInt();
		w = sc.nextInt();
		grid = new char[h][w];
		for (int i = 0; i < grid.length; i++) {
			grid[i] = sc.next().toCharArray();
		}
		dp = new long[h][w];

		for (int i = 0; i < h; i++) {
			if (grid[i][0] == '#')
				break;
			dp[i][0] = 1;
		}

		for (int i = 0; i < w; i++) {
			if (grid[0][i] == '#')
				break;
			dp[0][i] = 1;
		}

		for (int i = 1; i < h; i++) {
			for (int j = 1; j < w; j++) {
				if (grid[i][j] != '#') {
					dp[i][j] = (dp[i - 1][j] + dp[i][j - 1])%mod;
				}
			}
		}
		pw.println(dp[h-1][w-1]);
		pw.close();
	}
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
		public int[] nextIntArr(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = Integer.parseInt(next());
			}
			return arr;
		}
	}
}


Measured memory_bytes: 42344
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;

    vector<ll> a(n, 1);
    for(ll i=2;i<=n;++i){
        ll k = i;
        while(k != 1){
            for(ll j=2;j<=k;++j){
                if(k % j == 0){
                    k /= j;
                    a[j-1]++;
                    break;
                }
            }
        }
    }

    ll ans = 1;
    for(ll i=0;i<n;++i){
        ans *= a[i];
        ans %= mod;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
//Bokann ga bokka--nn!!
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
int main(){
	int n,kk;
	vector<int>xx,yy,zz;
	int x[55][2],y[55][2],z[55][2];

	cin >> n >> kk;

	for(int i=0;i<n;i++)
	{
		cin >> x[i][0] >> y[i][0] >> z[i][0]
		>> x[i][1] >> y[i][1] >> z[i][1];
		xx.pb(x[i][0]);
		xx.pb(x[i][1]);
		yy.pb(y[i][0]);
		yy.pb(y[i][1]);
		zz.pb(z[i][0]);
		zz.pb(z[i][1]);
	}

	sort(xx.begin(),xx.end());
	sort(yy.begin(),yy.end());
	sort(zz.begin(),zz.end());
	xx.erase(unique(xx.begin(),xx.end()),xx.end());
	yy.erase(unique(yy.begin(),yy.end()),yy.end());
	zz.erase(unique(zz.begin(),zz.end()),zz.end());

	long long val=0;

	for(int i=0;i<xx.size()-1;i++)
	{
		for(int j=0;j<yy.size()-1;j++)
		{
			for(int k=0;k<zz.size()-1;k++)
			{
				int check=0;

				for(int a=0;a<n;a++)
				{
					if( (x[a][0]<=xx[i] && xx[i+1]<=x[a][1]) && (y[a][0]<=yy[j] && yy[j+1]<=y[a][1]) && (z[a][0]<=zz[k] && zz[k+1]<=z[a][1]))
					{
						check++;
					}
				}
				
				if(check>=kk) val+=1LL*(xx[i+1]-xx[i])*(yy[j+1]-yy[j])*(zz[k+1]-zz[k]);
			}
		}
	}
	
	cout << val << endl;
}

Measured memory_bytes: 1216
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <string>
#include <unordered_map>
#include <iomanip>
#include <deque>
#include <unordered_set>

using namespace std;

int main() {
	int n;
	cin >> n;
	int x, y, t;
	int x0 = 0;
	int y0 = 0;
	while(n--){
		cin >> t;
		cin >> x;
		cin >> y;
		int df = abs(x0 - x) + abs(y0 - y) - t;
		if (df > 0 || abs(df) % 2) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	system ("pause");
}

Measured memory_bytes: 504
#include<iostream>

signed main(){
    // this is comment style launguage
    // @Memory_limit 1000 MB
    // @Time_limit 2 sec
    // @query solve Problem B
    // @out
    // @end func main
}












__attribute__((constructor))
void solver() {
    int n; std::cin >> n;
    int ans = 0;
    for(int i = 1; i <=n; i += 2){
        int cnt = 0;
        for(int j = 1; j <= i; ++j){
            if(i % j == 0)++cnt;
        }
        ans += (cnt == 8);
    }
    std:: cout << ans << std:: endl;
}




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


int main() {
    int n,res=1;
    string s;
    
    cin >> n;
    cin >> s;
	
	for (int i=1;i<n;i++){
	    if (s[i] != s[i-1]){
	        res++;
	    }
	}
	
	cout << res << endl;
	
	return 0;
}



Measured memory_bytes: 512
/*
  Author: Alokit Kumar
  */
 #include<bits/stdc++.h>
 using namespace std;
 #define int long long
 int32_t main()
 {
   int t,n,i,j,k,l;
  cin>>n>>k;
  int a[n];
  for(i=0;i<n;i++) cin>>a[i];
  sort(a,a+n);
  int s=0;
  for(i=0;i<k;i++)
   s+=a[i];
   cout<<s;
 }

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct po{int to,cost;};
int c[1001];
bool visited[1001];
vector <po> v[1001];

int saiki(int ima,int mincost,int flg){
  if(visited[ima]==1) return 0;
  if(flg == 1&&c[ima] !=0) return mincost;
  visited[ima]=1;
  int sum=0;
  for(int i=0;i<v[ima].size();i++)
    if(c[ima]==0)sum+= saiki(v[ima][i].to,v[ima][i].cost,1);
    else sum+=saiki(v[ima][i].to,v[ima][i].cost,0);
  return min(sum,mincost);
}

int main() {
  int n;
  cin >> n;
  for(int i=1;i<n;i++)cin >> c[i];
  for(int i=0;i<n-1;i++){
    int a,b,d;
    cin >> a >> b>> d;
    v[a].push_back(po{b,d});
    v[b].push_back(po{a,d});
  }
  cout << saiki(0,1000000000,0)<<endl;;
  return 0;
}

Measured memory_bytes: 1276
//類題ABC065D
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define INF ((1LL<<62)-(1LL<<31))

int a[100010];
int idx[100010];
int c(const void*p,const void*q){
	if(a[*(int*)p]<a[*(int*)q])return -1;
	if(a[*(int*)p]>a[*(int*)q])return 1;
	if(*(int*)p<*(int*)q)return -1;
	return 1;
}

//辺の情報を個別に持つタイプ
typedef struct edge{ll s,g,c;}E;
typedef struct graph{
	int vcnt,ecnt;
	E  e[400010];//適宜変える(ecnt)
	int id[100010];//適宜変える(vcnt)
}G;
G g;

int esort(const void*a,const void*b){
	E*p=(E*)a,*q=(E*)b;
	if((*p).s<(*q).s)return -1;
	if((*p).s>(*q).s)return  1;
	if((*p).g<(*q).g)return -1;
	return 1;
}
void readgraph(){
	//適宜変える
	ll n;
	scanf("%lld",&n);
	rep(k,0,2){
		rep(i,0,n){
			scanf("%d",a+i);
			idx[i]=i;
		}
		qsort(idx,n,sizeof(int),c);
		rep(i,0,n-1){
			g.e[k*(2*n-2)+2*i].s=idx[i];
			g.e[k*(2*n-2)+2*i].g=idx[i+1];
			g.e[k*(2*n-2)+2*i].c=a[idx[i+1]]-a[idx[i]];
			g.e[k*(2*n-2)+2*i+1].s=idx[i+1];
			g.e[k*(2*n-2)+2*i+1].g=idx[i];
			g.e[k*(2*n-2)+2*i+1].c=a[idx[i+1]]-a[idx[i]];
		}
	}
	g.vcnt=n;
	g.ecnt=4*n-4;
	qsort(g.e,g.ecnt,sizeof(E),esort);

	int p=0;
	rep(i,0,g.vcnt){
		while(p<g.ecnt&&g.e[p].s<i)p++;
		g.id[i]=p;
	}
	g.id[g.vcnt]=g.ecnt;//番兵
}


//プラキュー（二分ヒープ）（優先度変更ありバージョン）
ll heapN,heap[1<<20],heapinv[1<<20];
int PQhikaku(int i,int j);//jの方が優先度が高いならtrueを返す
void PQchange(int n);
void heap_utod(int n){
	if(2*n>heapN)return;
	int rflag=(2*n+1<=heapN)&&(PQhikaku(2*n,2*n+1));
	if(PQhikaku(n,2*n+rflag)){
		ll temp=heap[2*n+rflag];
		heap[2*n+rflag]=heap[n];
		heap[n]=temp;
		heapinv[heap[n]]=n;
		heapinv[heap[2*n+rflag]]=2*n+rflag;	
		heap_utod(2*n+rflag);
	}
}
void heap_dtou(int n){
	if(n==1||PQhikaku(n,n/2))return;
	ll temp=heap[n];
	heap[n]=heap[n/2];
	heap[n/2]=temp;
	heapinv[heap[n]]=n;
	heapinv[heap[n/2]]=n/2;
	heap_dtou(n/2);
}
ll PQpop(){
	ll rr=heap[1];
	heapinv[heap[1]]=0;
	heap[1]=heap[heapN--];
	heapinv[heap[1]]=1;
	heap_utod(1);
	return rr;
}
void PQpush(ll n){
	heap[++heapN]=n;
	heapinv[heap[heapN]]=heapN;
	heap_dtou(heapN);
}

//早い方のダイクストラ
//グラフと始点を引いて各点への最短距離・最短経路を返す
//プラキューが必要
//O((E+V)logV)
ll daikusutorappp[1<<21];
void daikusutora2(ll s){
	rep(i,0,g.vcnt)daikusutorappp[i]=i==s?0:INF;
	rep(i,0,g.vcnt)PQpush(i);
	while(heapN){
		ll mv=PQpop();
		for(ll t=g.id[mv];t<g.ecnt&&g.e[t].s==mv;t++){
			if(daikusutorappp[g.e[t].g]>daikusutorappp[mv]+g.e[t].c){
				daikusutorappp[g.e[t].g]=daikusutorappp[mv]+g.e[t].c;
				//daikusutorappp[n+g.e[t].g]=mv;//最短経路がいる場合はこれ
				PQchange(g.e[t].g);
			}
		}
	}
}
int PQhikaku(int i,int j){return daikusutorappp[heap[i]]>daikusutorappp[heap[j]];}
void PQchange(int n){if(heapinv[n])heap_dtou(heapinv[n]);}


int main(){
	readgraph();
	daikusutora2(0);
	rep(i,0,g.vcnt)printf("%d\n",daikusutorappp[i]);
}


Measured memory_bytes: 21512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class EDP_C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long happiness[][] = new long[100010][4];
            int a[][] = new int[n + 10][4];


            for (int i = 1; i <= n; i++) {
                a[i][1] = in.nextInt();
                a[i][2] = in.nextInt();
                a[i][3] = in.nextInt();
            }

            for (int i = 1; i <= n; i++) {
                happiness[i][1] = Math.max(happiness[i - 1][2], happiness[i - 1][3]) + a[i][1];
                happiness[i][2] = Math.max(happiness[i - 1][1], happiness[i - 1][3]) + a[i][2];
                happiness[i][3] = Math.max(happiness[i - 1][1], happiness[i - 1][2]) + a[i][3];
            }


            out.print(Math.max(Math.max(happiness[n][1], happiness[n][2]), happiness[n][3]));

        }

    }
}



Measured memory_bytes: 107044
import javax.swing.text.html.HTMLDocument;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.nio.Buffer;
import java.util.*;

class Main {
    public static void main(String[] args){
        try {
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            String[] ss=br.readLine().split(" ");
            int s=Integer.parseInt(ss[0]);
            int w=Integer.parseInt(ss[1]);
            if(w>=s){
                System.out.println("unsafe");
            }else{
                System.out.println("safe");
            }
        } catch (Exception e) {
            System.out.println("kkkk "+ e.getMessage());
        }
    }
    static void shuffle(int[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            int temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }
}

Measured memory_bytes: 32544
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define debug(...)                                                             \
    { cerr << "# " << __VA_ARGS__ << "\n"; }
#else
#define debug(...)
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
  public:
    i64 c[3333];
    void solve() {
        int n;
        string s;
        cin >> s;
        n = s.length();
        i64 a = 0;
        c[0] = 1;
        i64 d = 1, ans = 0;
        for (int i = n - 1; i >= 0; --i) {
            a = (a + (s[i] - '0') * d % 2019) % 2019;
            ans += c[a];
            c[a]++;
            d = d * 10 % 2019;
        }
        cout << ans << '\n';
    }
} NSPACE;
int main() {
    FPEN;
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    NSPACE.solve();
}

Measured memory_bytes: 3720
import sys
N=list(input())
A=N[0]
B=N[1]
C=N[2]
D=N[3]
op='+-'
for op1 in op:
  for op2 in op:
    for op3 in op:
      ans=A+op1+B+op2+C+op3+D
      if eval(ans)==7:
        print('{}=7'.format(ans))
        sys.exit()
      else:
        pass

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
using namespace std;
int gi(){
	int x=0,w=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')w=0,ch=getchar();
	while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return w?x:-x;
}
const int N=2e5+5;
const int mod=1e9+7;
int n,p[N],q[N],pre[N],suf[N],bit[N],ans;pair<int,int>a[N],b[N];
bool cmp(int x,int y){return a[x].second<a[y].second;}
void Inc(int &x,int y){x+=y;x>=mod?x-=mod:x;}
void modify(int x,int v){
	while(x<=n+1)Inc(bit[x],v),x+=x&-x;
}
int query(int x){
	int res=0;
	while(x)Inc(res,bit[x]),x^=x&-x;
	return res;
}
int main(){
	n=gi();
	for(int i=1;i<=n;++i)a[i]=make_pair(gi(),gi()),p[i]=i;
	sort(a+1,a+n+1);sort(p+1,p+n+1,cmp);
	for(int i=1;i<=n;++i)q[p[i]]=i;swap(p,q);
	pre[1]=p[1];for(int i=2;i<=n;++i)pre[i]=max(pre[i-1],p[i]);
	suf[n]=p[n];for(int i=n-1;i;--i)suf[i]=min(suf[i+1],p[i]);
	for(int i=1,l,r,res_l,res_r;i<=n;++i){
		l=1;r=q[i]-1;res_l=q[i];
		while(l<=r){
			int mid=l+r>>1;
			if(pre[mid]>i)res_l=mid,r=mid-1;
			else l=mid+1;
		}
		l=q[i]+1;r=n;res_r=q[i];
		while(l<=r){
			int mid=l+r>>1;
			if(suf[mid]<i)res_r=mid,l=mid+1;
			else r=mid-1;
		}
		b[i]=make_pair(res_l,res_r);
	}
	sort(b+1,b+n+1);
	for(int i=1;i<=n;++i){
		int v=query(n-b[i].first+2)+(b[i].first==1);
		if(b[i].second==n)Inc(ans,v);
		modify(n-b[i].second+1,v);
	}
	printf("%d\n",ans);return 0;
}


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

#include <cstring>
#include <queue>


int get_minstep(int start, int end, int n, int x, int y)
{
    int straight_steps = end - start;
    int xy_steps = 1 + abs(start - x) + abs(end - y);
    return min(straight_steps, xy_steps);
}

int main()
{
    int n, x, y;
    cin >> n >> x >> y;

    int min_steps[2000];
    memset(min_steps, 0, sizeof(min_steps));
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            min_steps[get_minstep(i, j, n, x - 1, y - 1) - 1]++;
        }
    }

    for (int i = 0; i < n - 1; ++i)
        cout << min_steps[i] << endl;

    return 0;
}



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

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

    vector<long> A(N);
    for(int i = 0; i < N; i++){
       cin >> A[i];
    }

    sort(A.begin(), A.end());
   
    int key = 0;
    while(1){
        for(int i = 1; i < A.size(); i++){
            if(A[i] % A[0] == 0){
                A.erase(A.begin() + i);
            }else{
                A[i] = A[i] % A[0];
            }
        }
        sort(A.begin(), A.end());
        if(A.size() == 1)break;
    }

    cout << A[0] << endl;

	return 0;
}

Measured memory_bytes: 1152
loop{
	n = gets.to_i()
	if n == 0 then
		break
	end
	
	s,t,b = gets.split
	room_path = {	"A"=>["B","D"],		"B"=>["A","C","E"],		"C"=>["B","F"],
					"D"=>["A","E","G"],	"E"=>["D","B","F","H"],	"F"=>["E","C","I"],
					"G"=>["H","D"],		"H"=>["E","G","I"],		"I"=>["F","H"]}
					
	room_path[b].each{|r|
		room_path[r].select!{|item| item != b}
	}
	
	room = Hash.new(0.0)
	room[s] = 1.0
	
	
	n.times do
		troom = Hash.new(0.0)
		room_path.each_key{|key|
			troom[key] = room[key]
		}
		
		room_path.each{|key,path|
			room[key] = ((4.0-path.size())/4) * troom[key]
			path.each{|r|
				room[key] += troom[r]/4
			}
		}
	end
	p room[t]
	
}

Measured memory_bytes: 6284
def main():
    A = int(input())
    B = int(input())
    C = int(input())
    X = int(input())

    count = 0
    for i in range(A+1):
        for j in range(B+1):
            for k in range(C+1):
                total = 500 * i + 100 * j + 50 * k
                if total == X:
                    count += 1

    print(count)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
def main():
    import sys
    readline = sys.stdin.buffer.readline

    n = int(readline())
    s = readline().rstrip().decode('utf-8')

    l = ''
    ans = 0
    for i in s:
        if i != l:
            l = i
            ans += 1 
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9320
#include <stdio.h>

typedef struct {
	char b;
	char a;
} CHANGE;

int main(void)
{
	int i, j, n, num;
	char b, a;
	CHANGE change[2048];
	
	while (scanf("%d%*c", &num), num != 0){
		for (i = 0; i < num; i++){
			scanf("%c%*c%c%*c", &b, &a);
			
			change[i].b = b;
			change[i].a = a;
		}
		
		scanf("%d%*c", &n);
		
		for (i = 0; i < n; i++){
			scanf("%c%*c", &b);
			
			for (j = 0; j < num; j++){
				if (b == change[j].b){
					printf("%c", change[j].a);
					break;
				}
			}
			
			if (j == num){
				printf("%c", b);
			}
		}
		
		puts("");
	}
	
	return (0);
}

Measured memory_bytes: 588