akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, sum = 0;
    cin >> n;
    
    int a[n];
    for(int i = 0; i < n; ++i)
    {
        cin >> a[i];
        sum += a[i];
    }
    
    sort(a, a+n);
    
    if(sum % 10 != 0)
    {
        cout << sum << endl;
    }
    else
    {
        for(int i = 0; i < n; ++i)
        {
            sum -= a[i];
            if(sum % 10 != 0)
            {
                cout << sum << endl;
                return 0;
            }
            else
            {
                sum += a[i];
            }
        }
        
        sum = 0;
        cout << sum << endl;
    }
    return 0;
}




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

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

  string w;
  cin >> w;

  map<char, int> cnt;
  for (char &c : w) cnt[c]++;

  string ans = "Yes";
  for (auto &cv : cnt) {
    if (cv.second & 1) {
      ans = "No";
      break; 
    }
  }
  cout << ans << '\n';
  return 0;
  
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import groupby, accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
a = LIST()
a.sort()
b = a[N:][::2]
print(sum(b))


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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














string S;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> S;
	sort(all(S));

	if (S[0] != S[2]) cout << "Yes" << endl;
	else cout << "No" << endl;
}







Measured memory_bytes: 256
N,M,C=list(map(int, input().split()))
B=list(map(int, input().split()))
A=[list(map(int, input().split())) for _ in range(N)]
ct=0
for i in range(N):
  s=0
  a=A[i]
  for j in range(M):
    s+=a[j]*B[j]
  if s+C>0:
    ct+=1
print(ct)

Measured memory_bytes: 62292
#include <iostream>

using namespace std;

int main(void) {
	int sx, sy, gx, gy, i;
	scanf("%d%d%d%d", &sx, &sy, &gx, &gy);
	for (i = sy; i < gy; i++)
		printf("U");
	for (i = sx; i < gx; i++)
		printf("R");
	for (i = sy; i < gy; i++)
		printf("D");
	for (i = sx; i <= gx; i++)
		printf("L");
	for (i = sy; i <= gy; i++)
		printf("U");
	for (i = sx; i <= gx; i++)
		printf("R");
	printf("DR");
	for (i = sy; i <= gy; i++)
		printf("D");
	for (i = sx; i <= gx; i++)
		printf("L");
	printf("U\n");
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vll = vector<vector<ll> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using the = pair<int, int>;
using lthe = pair<ll, ll>;

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; }

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };


priority_queue<the> p[200000];
const int MAXP = 2 * 1e5;

int main()
{
	int a[3];
	cin >> a[0] >> a[1] >> a[2];

	rep(i, 3) {
		if (a[i] % 2) {
			cout << 0 << endl;
			return 0;
		}
	}

	if (a[0] == a[1] && a[1] == a[2]) {
		cout << -1 << endl;
		return 0;
	}


	int ans = 0;
	rep(i, 40) {
		rep(j, 3) {
			if (a[j] % 2) {
				cout << ans << endl;
				return 0;
			}
		}
		int b[3];
		rep(j, 3) b[j] = a[j];
		a[0] = (b[1] + b[2]) / 2;
		a[1] = (b[0] + b[2]) / 2;
		a[2] = (b[0] + b[1]) / 2;
		ans++;
	}


}


Measured memory_bytes: 6528
S=list(input())
T=list(input())
A=[]
for i in range(len(S)-len(T)+1):
    is_ok=1
    for j in range(i, i+len(T)):
        if S[j]!=T[j-i] and S[j]!='?':
            is_ok=0
    if is_ok:
        tmp=S[:]
        is_con=1
        for j in range(i, i+len(T)):
            tmp[j]=T[j-i]
        A.append(tmp)
if len(A)==0:
    print("UNRESTORABLE")
    exit(0)
B=[]
for a in A:
    for i in range(len(a)):
        if a[i]=='?':
            a[i]='a'
    B.append(''.join(a))
B.sort()
print(B[0])


Measured memory_bytes: 3064
#include<stdio.h>
#include<string>
#include<iostream>
using namespace std;
int main()
{
int N;
string K;
int NN=0;
cin>>N;
for(int ii=0;ii<N;ii++){
cin>>K;

char ch;
int NUM[11]={};
for(int i=0;i<(int)K.size();i++){
	ch=K[i];int t=ch-'0';NUM[t]++;}
	long H=10000000, h=0;
	long P=10000000,p=0;
	for(int i=9;i>=0;i--){
	NN=NUM[i];
for(int j=NUM[i];j>0;j--){
	h+=H*i;H=H/10;//printf("%lf\n",h);
}}
	for(int i=0;i<=9;i++){
	NN=NUM[i];
for(int j=NUM[i];j>0;j--){
	p+=P*i;P=P/10;
	

//	cout<<" "<<NUM[i]<<" "<<i<<endl;
	
}
}
	printf("%ld\n",h-p);
	
}
/*
for(int i=0;i<10;i++){
	cout<<NUM[i]<<" "<<i<<endl;}
cout<<K<<endl;
*/


return 0;
}

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

typedef double                 ld;
typedef long long                   ll;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<string , string>       pss;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define F                           first
#define S                           second
#define sep                         ' '
#define endl                        '\n'
#define file_io                     freopen("input.txt" , "r+" , stdin) ; freopen("output.txt" , "w+" , stdout);
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(x)                    cerr << "$$$ " << x << '\n';
#define error2(x,y)                 cerr << "#F : " << x << "      #S : " << y << '\n';
#define kill(x)                     return cout << x << endl , 0;
#define pb                          push_back

const ll MXN = 3e3 + 10;
const ll MXM = 5e2 + 10;
const ll MX5 = 1e5 + 10;
const ll MX6 = 1e6 + 10;
const ll INF = 8e18;
const ld eps = 1e-9;
const ll MOD = 1e9 + 7; //998244353;

ll power(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));
}
ll bmm(ll a,ll b){
    return (a%b==0 ? b : bmm(b,a%b));
}
string base2(ll n){
    string a="";while(n>=2){a+=(char)(n%2+'0');n/=2;}a+=(char)(n+'0');reverse(all(a));return a;
}

vector<string> v;

int main(){
    fast_io
    //file_io
    string s;
    cin >> s;
    if(s == "FRI"){
        kill(2);
    }
    if(s == "SAT"){
        kill(1);
    }
    if(s == "SUN"){
        kill(7);
    }
    if(s == "MON"){
        kill(6);
    }
    if(s == "TUE"){
        kill(5);
    }
    if(s == "WED"){
        kill(4);
    }
    if(s == "THU"){
        kill(3);
    }
    return 0;
}

//! N.N


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	FastScanner sc;

	void run() {
		sc = new FastScanner();
		int a = sc.nextInt();
		int b = sc.nextInt();

		String ans = "";
		if (a == 0 || b == 0) {
			// どちらかが0
			ans = "Zero";
		} else if (a < 0 && 0 < b) {
			// 負から正をまたぐ
			ans = "Zero";
		} else if (0 < a && 0 < b) {
			// 両方とも正
			ans = "Positive";
		} else {
			int dist = b - a + 1;
			if (dist % 2 == 0) {
				ans = "Positive";
			} else {
				ans = "Negative";
			}
		}
		
		System.out.println(ans);
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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

Measured memory_bytes: 7892
#include <stdio.h>
int main(){

  int n,score[200][3],result[200][3],sum[200]={0},i,j,k;

  scanf("%d",&n);

  for(i = 0; i < n; i++){

    for(j = 0; j < 3; j++){

      scanf("%d",&score[i][j]);
      result[i][j]=score[i][j];

    }

  }

 
  for(j = 0; j < 3; j++){
      
    for(i = 0; i < n; i++){

      for(k = i+1; k < n; k++){

	if(score[i][j] == score[k][j]){

	  result[i][j]=0;
	  result[k][j]=0;

	}

      }

    }

  }

  for(i = 0; i < n; i++){

    for(j = 0; j < 3; j++){

      sum[i] += result[i][j];

    }

    printf("%d\n",sum[i]);

  }

  return 0;

}
  

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		int a = 0, b = 0;
		a = stdin.nextInt();
		b = stdin.nextInt();
		if (a + b >= 10) {
			System.out.println("error");
		} else {
			System.out.println(a + b);
		}
	}

}


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

int main() {
    int N, M;
    cin >> N >> M;
    priority_queue<ll> A;
    int price;
    for(int i = 0; i < N; i++) {
        cin >> price;
        A.push(price);
    }

    for(int i = 0; i < M; i++) {
        int p = A.top();
        A.pop();
        A.push(p / 2);
    }

    ll ans = 0;
    while(!A.empty()) {
        ans += A.top();
        A.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    int prev = a[0];
    long long c1, c2, c3, cnt;
    c1 = c2 = 0;
    cnt = 1;
    c3 = 1;
    for (int i = 1; i < n; i++) {
        if (prev == a[i]) {
            c3++;
        } else if (prev + 1 == a[i]) {
            prev = a[i];
            c1 = c2;
            c2 = c3;
            c3 = 1;
        } else if (prev + 2 == a[i]) {
            prev = a[i];
            c1 = c3;
            c2 = c3 = 0;
            c3++;
        } else {
            prev = a[i];
            c1 = c2 = c3 = 0;
            c3++;
        }
        if (cnt < c1 + c2 + c3) {
            cnt = c1 + c2 + c3;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 640
///not today

#include<bits/stdc++.h>
using namespace std;

#define SZ(x) (int)(x).size()
#define pb push_back
#define ll long long
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<long long, long long>
#define int long long
#define pipii pair<int, pair<int, int> >

const int maxn = 3000* 100 + 5;
int a[maxn];

int32_t main(){
    int n;
    cin >>n;
    for(int i = 0; i < 3 *n; i ++)
        cin >>a[i];
    sort(a, a + 3* n);
    int ans = 0;
    for(int i = 3 *n - 2; i >= (3* n) - (2* n); i -= 2){
        ans += a[i];
    }
    cout <<ans <<endl;
    return false;
}


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

string s;

int main(void){
	cin >> s;
	bool ans = true;
	if(s[0] != 'A') ans = false;
	int c = 0;
	for(int i = 2; i < s.size()-1; i++){
		if(s[i] == 'C') c++;
	}
	if(c != 1) ans = false;
	rep(i, s.size()){
		if(s[i] == 'A' || s[i] == 'C') continue;
		if(isupper(s[i])) ans = false;
	}
	if(ans) cout << "AC" << endl;
	else cout << "WA" << endl;
	return 0;
}


Measured memory_bytes: 3616
//Moh_K_Imar .......
//24/08/2020  ... 5,55.
//Ya Rab....
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    string a;
    cin>>a;
    if(a=="SAT")cout<<"1"<<endl;
    else if(a=="SUN")cout<<"7"<<endl;
    else if(a=="MON")cout<<"6"<<endl;
    else if(a=="TUE")cout<<"5"<<endl;
    else if(a=="WED")cout<<"4"<<endl;
    else if(a=="THU")cout<<"3"<<endl;
    else if(a=="FRI")cout<<"2"<<endl;

    return 0;
}



Measured memory_bytes: 3576
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const [n, m]: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    const a: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    a.sort((i1, i2) => i2 - i1);
    let sum = 0;
    for (let i = 0; i < n; i++) {
      sum += a[i];
    }
    let limit = sum / (4 * m);
    return `${a[m - 1] < limit ? "No" : "Yes"}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


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

const int MOD = 1000000007;
const int INF = 1e9;

void QueueOut(priority_queue<tuple<int, int, int>, vector<tuple<int, int, int>>, greater<tuple<int, int, int>>> todo){
  while(!todo.empty()){
    cout << get<0>(todo.top()) << "," << get<1>(todo.top()) << "," << get<2>(todo.top()) << endl;
    todo.pop();
  }
  cout << "output end" << endl;
  return;
}

int main(){
  int h,w;
  int sx, sy;
  int ex, ey;
  char s[1001][1001];

  cin >> h >> w;
  cin >> sx >> sy;
  cin >> ex >> ey;
  sx --;
  sy --;
  ex --;
  ey --;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> s[i][j];
    }
  }

  // tuple : cnt_warp, x, y
  priority_queue<tuple<int, int, int>, vector<tuple<int, int, int>>, greater<tuple<int, int, int>>> todo;
  vector<vector<int>> warp(1001, vector<int>(1001, INF));
  warp[sx][sy] = 0;
  todo.push(make_tuple(0, sx, sy));

  // QueueOut(todo);

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

  vector<int> dwx;
  vector<int> dwy;
  for(int i = -2; i <= 2; i++){
    for(int j = -2; j <= 2; j++){
      if(i == 0 && j == 0) continue;
      if(i == 1 && j == 0) continue;
      if(i == -1 && j == 0) continue;
      if(i == 0 && j == 1) continue;
      if(i == 0 && j == -1) continue;
      dwx.push_back(i);
      dwy.push_back(j);
    }
  }

  while(!todo.empty()){
    can_flag = 0;
    int x = get<1>(todo.top());
    int y = get<2>(todo.top());
    int nx = 0;
    int ny = 0;
    todo.pop();

    for(int i = 0; i < 4; i++){
      nx = x + dx[i];
      ny = y + dy[i];
      if(nx >= h || ny >=  w || nx < 0 || ny < 0) continue;
      if(s[nx][ny] == '#') continue;
      if(warp[nx][ny] <= warp[x][y]) continue;
      warp[nx][ny] = warp[x][y];
      todo.push(make_tuple(warp[nx][ny], nx, ny));
    }
    for(int i = 0; i < 20; i++){
      nx = x + dwx[i];
      ny = y + dwy[i];
      if(nx >= h || ny >=  w || nx < 0 || ny < 0) continue;
      if(s[nx][ny] == '#') continue;
      if(warp[nx][ny] != INF) continue;
      warp[nx][ny] = warp[x][y] + 1;
      todo.push(make_tuple(warp[nx][ny], nx, ny));
    }
    // if(warp[ex][ey] != INF) break;
  }

  // for(int i = 0; i < h; i++){
  //   for(int j = 0; j < w; j++){
  //     cout << warp[i][j];
  //   }
  //   cout << endl;
  // }

  if(warp[ex][ey] != INF) cout << warp[ex][ey] << endl;
  else cout << -1 << endl;

  return 0;
}

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

int main(){
  int N,L; cin >> N >> L;
  
  int sum_L = 0;
  for(int i = 1; i <= N; i++){
      sum_L += L + i - 1;
  }
  
  int ans = 0;
  int amin = 99999;
  for(int i = 1; i <= N; i++){
      if(abs(sum_L - (sum_L - (L+i-1))) < amin){
          amin = abs(sum_L - (sum_L - (L+i-1)));
          ans = sum_L - (L+i-1);
      }
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{ll to,cost;};
const int inf = 1<<27;
const ll INF = 1LL<<60;
const int COMBMAX = 1001001;
const ll MOD = 1000000007;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for(const auto& e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (ll)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (ll)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
ll mpow(ll a, ll n, ll mod = MOD){ll res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void YesNo(bool j){cout << (j ? "Yes" : "No") << endl; return;}
void yesno(bool j){cout << (j ? "yes" : "no") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> ll bcount(T1 v, T2 a){return upper_index(v, a) - lower_index(v, a);} 
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> void sortTwoVecter(vector<T1> &f, vector<T2> &s, bool isReverse = false){
    vector<pair<T1, T2>> p;
    rep(i, f.size()) p.emplace_back(make_pair(f[i], s[i]));
    if (!isReverse) sort(p.begin(), p.end());
    else sort(p.rbegin(), p.rend());
    rep(i, f.size()) tie(f[i], s[i]) = p[i];
    return;
}

int main(){
    ll N, M; cin >> N >> M;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    ll cnt = 0;
    ll sum = accumulate(all(a), 0LL);
    rep(i, N){
        if (sum <= 4*M*a[i]) cnt++;
    }
    YesNo(M <=cnt);
    return 0;
}


Measured memory_bytes: 256
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let w: usize = iter.next().unwrap().parse().unwrap();
    let h: usize = iter.next().unwrap().parse().unwrap();
    let x: usize = iter.next().unwrap().parse().unwrap();
    let y: usize = iter.next().unwrap().parse().unwrap();

    if x*2 == w && y*2 == h {
        println!("{} {}", (w as f64) * (h as f64) / 2.0f64, 1);
    }
    else {
        println!("{} {}", (w as f64) * (h as f64) / 2.0f64, 0);
    }
}

Measured memory_bytes: 4352
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  
  int points[m];
  for(int i=0;i<m;i++)
  {
    cin>>points[i];
    
  }
  sort(points,points+m);
 
  int difference[m-1];
   for(int i=0;i<m-1;i++)
  {
    difference[i]=points[i+1]-points[i];
  }
  
  sort(difference,difference+m-1);
  long long total=0;
   for(int i=0;i<m-n;i++)
  {
    total+=difference[i];
  }
  cout<<total;
  return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
import math
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return [LIST() for _ in range(n)]
def NSTR(n): return [input() for _ in range(n)]


INF = float("inf")
MOD = 10**9 + 7


def main():
    N, K = MAP()
    A = LIST()

    if K == 0:
        print(max(A))
        return

    # X決め打ち二分探索
    left = 0
    right = 10**9+7
    while right - left > 1.0e-6:
        mid = (right + left) / 2
        count = 0
        for a in A:
            count += int(math.ceil(a / mid))-1
        # print(mid, count)
        if count <= K:
            right = mid
        else:
            left = mid
    # print(left, right)
    print(int(math.ceil(left)))

    # mid = int(math.ceil(left))
    # count = 0
    # for a in A:
    #     count += int(math.ceil(a/mid)-1)
    # print(count <= K)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 94084
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define IOS std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define FRE freopen("in.txt", "r", stdin);
#define endl "\n"
#define PI acos(-1.0)
typedef long long LL;
typedef pair<int, int> PII;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int N = 1e5 + 10, M = 510;

bool flag;
char s[N][4];
int pre[N];
int n;

void dfs(int x, int a, int b, int c) {
	if(x > n) {
		flag = 1;
		return;
	}
	if(flag) return;
	char ch1 = s[x][0], ch2 = s[x][1];
	if(!strcmp(s[x], "AB")) {
		if(flag) return;
		if(b - 1 >= 0) {
			dfs(x + 1, a + 1, b - 1, c);
			pre[x] = 0;
		}
		if(flag) return;
		if(a - 1 >= 0) {
			dfs(x + 1, a - 1, b + 1, c);
			pre[x] = 1;
		}
	}
	if(!strcmp(s[x], "AC")) {
		if(flag) return;
		if(c - 1 >= 0) {
			dfs(x + 1, a + 1, b, c - 1);
			pre[x] = 0;
		}
		if(flag) return;
		if(a - 1 >= 0) {
			dfs(x + 1, a - 1, b, c + 1);
			pre[x] = 1;
		}
	}
	if(!strcmp(s[x], "BC")) {
		if(flag) return;
		if(c - 1 >= 0) {
			dfs(x + 1, a, b + 1, c - 1);
			pre[x] = 0;
		}
		if(flag) return;
		if(b - 1 >= 0) {
			dfs(x + 1, a, b - 1, c + 1);
			pre[x] = 1;
		}
	}
}

void solve() {
	int a, b, c;
	scanf("%d%d%d%d", &n, &a, &b, &c);
	for(int i = 1; i <= n; i++) scanf("%s", s[i]);
	dfs(1, a, b, c);
	if(flag) {
		puts("Yes");
		for(int i = 1; i <= n; i++) printf("%c\n", s[i][pre[i]]);
	} else puts("No");
}


int main() {
	//FRE;
	//LL t; cin >> t; while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 10864
'use strict'


function main(input){
  const lines = input.split('\n');
  const N = parseInt(lines[0].split(' ')[0]);
  const K = parseInt(lines[0].split(' ')[1]);
  var hs = [];
  for(var i=0;i<N;i++){
    hs.push(parseInt(lines[i+1]));
  }
  const sorted_hs = hs.sort(function(a,b){return a-b;})
  var part_hs = []
  for(var i=0;i<K;i++){part_hs.push(sorted_hs[i])}
  var result = part_hs[part_hs.length-1] - part_hs[0];

  for(var i=1;i<N-K+1;i++){
    part_hs.shift();
    part_hs.push(sorted_hs[i+K-1]);

    var current_diff = part_hs[part_hs.length-1] - part_hs[0];
    result = Math.min(result, current_diff)
  }

  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29060
#include<iostream>
using namespace std;
int N,K;
int R,S,P;
string s;
bool exs[1<<17];
main()
{
	cin>>N>>K>>R>>S>>P>>s;
	int ans=0;
	for(int i=0;i<N;i++)
	{
		if(i<K||s[i-K]!=s[i]||!exs[i-K])
		{
			ans+=s[i]=='r'?P:s[i]=='s'?R:S;
			exs[i]=true;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int train = Math.min(sc.nextInt(), sc.nextInt());
		int bus = Math.min(sc.nextInt(), sc.nextInt());
		sc.close();
		System.out.println(train + bus);
	}
}

Measured memory_bytes: 22612
#include <stdio.h>
#include <stdlib.h>

int main()
{
  int n, q, i, count = 0, k, left = 0, right, mid, key; 
  int *S, *T;

  scanf("%d", &n);
  S = (int *)malloc(n * sizeof(int));
  for(i = 0; i < n; i++)
    scanf("%d", &S[i]);

  scanf("%d", &q);
  T = (int *)malloc(q * sizeof(int));
  for(i = 0; i < q; i++)
    scanf("%d", &T[i]);

  /*確認のprintf*/
  /*
    printf("n = %d\n", n);
    for(i = 0; i < n; i++)
    printf("%d ", S[i]);
   
    printf("\n");
    printf("q = %d\n", q);
    for(i = 0; i < q; i++)
    printf("%d ", T[i]);
   
    printf("\n");
  */

  for(k = 0;  k < q; k++){

    left = 0;
    right = n;

    key = T[k];
    while(left < right){
      mid = (left + right) / 2;
      if(S[mid] == key){
	count++;
	break;
      }
      else if(key < S[mid])
	right = mid;
      else
	left = mid + 1;
    }
  }
  printf("%d\n", count);

  return 0;
}




Measured memory_bytes: 2312
n,p=gets.split
n=n.to_i
p=p.to_i

arr=gets.split.map(&:to_i)
kisuu=arr.count{|i| i%2==1}
guusu=arr.count{ |i| i%2==0}

def tanaka(s,t)
    aa=1
    bb=s
    ans=1
    
    t.times{
        ans=ans*bb/aa
        aa+=1
        bb-=1
        
    }
    return ans
end


ans3=0
jj=0
(kisuu/2+1).times{
    ans3+=tanaka(kisuu,jj)
    jj+=2
    
}

ans4=2**(kisuu)-ans3
kk=2**(guusu)

if p==0
    puts kk*ans3  
    
else 
   puts  kk*ans4
    
end



Measured memory_bytes: 3836
using System;
class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        double[,] a = new double[n,2];
        double[] b = new double[2];
        for (int i = 0; i < n; i++)
        {
            b = Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
            a[i, 0] = b[0];
            a[i, 1] = b[1];
        }

        int N = 0;
        double[] length = new double[2];
        double sum = 0;
        for (int i = 0; i < n - 1; i++)
        {
            for (int j = i + 1; j < n; j++)
            {
                length[0] = a[i, 0] - a[j, 0];
                length[1] = a[i, 1] - a[j, 1];
                sum += Math.Sqrt(length[0] * length[0] + length[1] * length[1]);
                N += 1;
            }
        }
        Console.WriteLine(sum*(1+1/n)*2/n);
    }   
}

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

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

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int a,b,c;
	scanf("%d",&a);
	c=a;
	while(a!=0){
		b+=a%10;
		a=a/10;
	}
	if(c%b==0){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    int c=0;
    for(int i=0;i<3;i++){
        if(s[i]=='o') c++;
    }
    cout << 700+c*100 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ww while
#define loop(i,l,r) for(int i=l;i<r;i++)
#define ci cin>>
#define co cout<<
#define ll long long
using namespace std;
//ll int dp[1000001][101]={};
ll int max(ll int a,ll int b ){
  if(a>b)
  return a;
  else
  return b;
}
ll int min(ll int a,ll int b ){
  if(a<b)
  return a;
  else
  return b;
}
const int inf = 1e9+7;
int main()
 {    ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      ll int n,cap;
      cin>>n>>cap;
      ll int ind=0;
    ll int w[n],v[n];
      loop(i,0,n){
    ll int a,b;
      cin>>a>>b;
      ind+=b;
      w[i]=a,v[i]=b;
      }
      ll int ans=0;
       vector<ll int>dp(ind+1,inf);
       dp[0]=0;
    for(int i=0;i<n;i++){
        for(ll int k=ind-v[i];k>=0;k--){
            dp[v[i]+k]=min(dp[v[i]+k],w[i]+dp[k]);
             //if(dp[w[i]+k]!=inf )
              //ans = max(ans,dp[w[i]+k]);
        }
    }
      loop(i,1,ind+1){
      //cout<<dp[i]<<' ';
      if(dp[i]<=cap){
        ans=max(ans,i);
      }
    }
      //co "\n\n\n\n\n";
     cout<<ans;
  }


Measured memory_bytes: 1024
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
T[] Reads(T)() { return readln.split.to!(T[]); }
alias reads = Reads!int;
void scan(Args...)(ref Args args) {
    string[] ss = readln.split;
    foreach (i, ref arg ; args) arg = ss[i].parse!int;
}

void main() {
    int n,m; scan(n,m);
    int[] a = reads();
    long tot = a.sum();
    auto cnt = a.filter!(i => i >= 1.0 * tot / 4 / m)
                .array
                .length;
    writeln(cnt >= m ? "Yes" : "No");
}



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

int main() {
 int n,d=1; cin>>n;
  int h[n];for(int i=0;i<n;i++) cin>>h[i];
  
  for(int i=n-1;i>0;i--){
    if(h[i]+1==h[i-1]) h[i-1]--;
    else if(h[i]+1<h[i-1]) d=0;
  }
    if(d) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int n;
  cin>>n;
  vector <int> v(n);
  int i,j;
 
  for (i=0;i<n;i++)
  {
    cin>>v[i];
  }
  vector <int> ans(n,0);
  ans[0]=0;
  ans[1]=abs(v[1]-v[0]);
  for (i=2;i<n;i++)
  {
    ans[i]=min(ans[i-1]+abs(v[i]-v[i-1]),ans[i-2]+abs(v[i]-v[i-2]));
  }
  cout<<ans[n-1];
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){
	int map[10][10],ink,x,y,max=0,count=0;
	int dx[] = { 0, 0,-1, 1,-1,-1, 1, 1, 0, 0,-2, 2};
	int dy[] = {-1, 1, 0, 0,-1, 1,-1, 1,-2, 2, 0, 0};

	for(int i=0 ; i<10 ; i++){
		for(int j=0 ; j<10 ; j++){
			map[i][j] = 0;
		}
	}
	while( scanf("%d,%d,%d", &x, &y, &ink) != EOF ){
		map[y][x]++;
		for(int i=0 ; i<ink*4 ; i++){
			int mx = x + dx[i];
			int my = y + dy[i];
			if(mx>=0 && mx<10 && my>=0 && my<10){
				map[my][mx]++;
			}
		}
	}
	for(int y=0 ; y<10 ; y++){
		for(int x=0 ; x<10 ; x++){
			if(map[y][x]==0){
				count++;
			}
			if(map[y][x]>max){
				max = map[y][x];
			}
		}
	}
	printf("%d\n%d\n", count , max);
}

Measured memory_bytes: 0
import sys
class DSU:
    def __init__(self, n):
        self._n = n
        self.parent_or_size = [-1] * n

    def merge(self, a, b):
        assert 0 <= a < self._n
        assert 0 <= b < self._n
        x, y = self.leader(a), self.leader(b)
        if x == y: return x
        if -self.parent_or_size[x] < -self.parent_or_size[y]: x, y = y, x
        self.parent_or_size[x] += self.parent_or_size[y]
        self.parent_or_size[y] = x
        return x

    def same(self, a, b):
        assert 0 <= a < self._n
        assert 0 <= b < self._n
        return self.leader(a) == self.leader(b)

    def leader(self, a):
        assert 0 <= a < self._n
        if self.parent_or_size[a] < 0: return a
        self.parent_or_size[a] = self.leader(self.parent_or_size[a])
        return self.parent_or_size[a]

    def size(self, a):
        assert 0 <= a < self._n
        return -self.parent_or_size[self.leader(a)]

    def groups(self):
        leader_buf = [self.leader(i) for i in range(self._n)]
        result = [[] for _ in range(self._n)]
        for i in range(self._n): result[leader_buf[i]].append(i)
        return [r for r in result if r != []]

N , M = map(int,input().split())
d = DSU(N)
for i in range(M):
  a,b = map(int,input().split())
  d.merge(a-1,b-1)
print(len(d.groups()) - 1)  

Measured memory_bytes: 25028
n, mod = map(int, input().split())
S = input()

total = 0
if mod == 2 or mod == 5:
	for i, q in enumerate(S):
		if int(q)%mod == 0:
			total += i+1
else:
	counts = [0]*mod
	counts[0] = 1
	h = 0
	
	d = 1
	for s in reversed(S):
		m = int(s)*d%mod
		h = (h+m)%mod
		total += counts[h]
		counts[h] += 1
		d = (d*10)%mod

print(total)

Measured memory_bytes: 3500
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int N;
long ans;
map<string,int>M;
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		string s;cin>>s;
		sort(s.begin(),s.end());
		ans+=M[s]++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 11136
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
//#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int n, k;
	cin >> n >> k;
	map<int, int>a;
	rep(i, n) {
		int tmp;
		cin >> tmp;
		a[tmp]++;
	}
	vector<int>b;
	for (auto itr = a.begin(); itr != a.end(); ++itr) {
		int value = itr->second;
	//	print(value);
		b.push_back(value);
	}
	sort(b.begin(), b.end());
	int ret = 0;
	if (b.size() - k <= 0) {
		print("0");
		return 0;
	}
	int size = b.size() - k;
	rep(i, size) {
		ret += b[i];
	}
	print(ret);
}

Measured memory_bytes: 13592
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Set as ST
import qualified Data.Map.Strict as MPS
import Data.List
import Data.Tuple
import Control.Monad

type Graph = MPS.Map Int [(Int, Int)]
type Distance = VUM.IOVector Int
type Queue = ST.Set (Int, Int)

makeGraph :: [(Int, [(Int, Int)])] -> Graph
makeGraph xs = MPS.fromListWith (++) xs

dijkstra :: Int -> Int -> Graph -> IO Distance
dijkstra vertex from graph = do
  distance <- VUM.replicate (vertex+1) (10^9) :: IO Distance
  VUM.write distance from 0 
  trav graph distance (ST.singleton (0, from))
  where
    trav :: Graph -> Distance -> Queue -> IO Distance
    trav graph distance queue
      | ST.null queue = return distance
      | otherwise = do
          tmp <- VUM.read distance from
          if acc <= tmp
            then update >>= trav graph distance
            else trav graph distance queue'
        where
          ((acc, from), queue') = ST.deleteFindMin queue

          update :: IO Queue
          update = 
            case MPS.lookup from graph of
              Just xs -> update' xs queue'
              Nothing -> return queue'
            where
              update' :: [(Int, Int)] -> Queue -> IO Queue
              update' [] q = return q
              update' ((to, cost):xs) q = do
                tmp <- VUM.read distance to
                let acc' = acc + cost
                case compare acc' tmp of
                   LT -> do
                      VUM.write distance to acc'
                      update' xs (ST.insert (acc', to) q)
                   _ ->
                      update' xs q
        
main = do
  [n,a,b] <- map read . words <$> getLine :: IO [Int]
  let vs = let xs = zip [1..n] [2..n] in (map swap xs) ++ xs :: [(Int, Int)]
  let vs' = [(a,[(b,1)]), (b,[(a,1)])] ++ map (\(f,t) -> (f,[(t,1)])) vs :: [(Int, [(Int, Int)])]
  let graph = makeGraph vs'

  table <- VUM.replicate n 0 :: IO (VUM.IOVector Int)

  forM_ [1..n] $ \i -> do
    dist <- dijkstra n i graph
    dist' <- VU.tail . VU.zip (VU.fromList [0..n]) <$> VU.unsafeFreeze dist
    VU.forM_ dist' $ \(j,d) ->
      when (d /= 10^9 && j > i) $  
        VUM.modify table (+1) (d-1)

  table' <- VU.init <$> VU.unsafeFreeze table
  VU.mapM_ print table' 

Measured memory_bytes: 2428
X,N = map(int,input().split())

if N==0:
  print(X)
else:
  P = list(map(int,input().split()))
  Q = [n for n in range(-1000,1000) if n not in P]
  a = 10000
  d1 = 10000
  
  for q in Q:
    d2 = abs(q-X)
    if d2<d1:
      d1 = d2
      a = q
  
  print(a)


Measured memory_bytes: 9220
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
typedef long long ll;

ll sqr(ll a)
{
	return (a * a * a * a * a);
}

int main()
{
	ll x;
	scanf("%lld", &x);
	ll a = 0,b ;
	while (a <= (ll)sqrt(x))
	{
		b = -1 * a;
		while (b < a)
		{
			if (sqr(a) - sqr(b) == x)
			{
				printf("%lld %lld", a,b);
				return 0;
			}
			b++;
		}
		a++;
	}
	return (0);
}



Measured memory_bytes: 2132
#include <iostream>
#include <vector>
#include<algorithm>
//#include <string>
//#include <cassert>
//#include <cmath>
//#include <limits>
using namespace std;

int N, K;
int D;
vector<int> A;

int solve() {


    return 1;
}

int main() {

    cin >> N >> K;

    for (int i = 0; i < K; i++) {

        cin >> D;
        vector<int> Atemp(D);
        for (int j = 0; j < D; j++) {

            cin >> Atemp[j];
        }

        for (int k = 0; k < D; k++) {
            A.push_back(Atemp[k]);
        }

    }

    int num = 0;
    for (int i = 1; i <= N; i++) {

        bool exist = false;
        for (int j = 0; j < A.size(); j++) {

            if (i == A[j]) {

                exist = true;
                break;
            }

        }

        if (!exist)num++;

    }

    cout << num << endl;


    return 0;
}

Measured memory_bytes: 3704
#include<bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> p;
int main(){
  int n,gr[2][3000];
  cin>>n;
  vector<p> t[2];
  char d[3000];
  for(int x,y,i=0;i<n;i++){
    cin>>x>>y>>d[i];
    t[0].push_back(p(P(x,y),i));
    t[1].push_back(p(P(y,x),i));
  }
  sort(t[0].begin(),t[0].end());
  sort(t[1].begin(),t[1].end());  
  for(int i=0;i<n;i++)
    gr[0][t[0][i].s]=i,gr[1][t[1][i].s]=i;
  int ans=0;
 
  for(int i=0;i<n;i++){
    bool used[3000]={};
    int ss=i,k=0;
     while(1){
       k++;
       bool f=0;
       used[ss]=1;
 
       if(d[ss]=='v'){
     int g=gr[0][ss];
     int a=t[0][g].f.f;
     while(used[ss]){
       if(++g==n){f=1;break;}
       ss=t[0][g].s;
     }
     if(f||t[0][gr[0][ss]].f.f!=a)break;
       }
 
       if(d[ss]=='^'){
     int g=gr[0][ss];
     int a=t[0][g].f.f;
     while(used[ss]){
       if(!g){f=1;break;}
       ss=t[0][--g].s;
     }
     if(f||t[0][gr[0][ss]].f.f!=a)break;
       }
 
 
       if(d[ss]=='>'){
     int g=gr[1][ss];
     int a=t[1][g].f.f;
     while(used[ss]){
       if(++g==n){f=1;break;}     
       ss=t[1][g].s;
     }
     if(f||t[1][gr[1][ss]].f.f!=a)break;
       }
 
 
      if(d[ss]=='<'){
    int g=gr[1][ss];
    int a=t[1][g].f.f;
     while(used[ss]){
       if(!g){f=1;break;}     
       ss=t[1][--g].s;
     }
     if(f||t[1][gr[1][ss]].f.f!=a)break;
      }
     }
     ans=max(ans,k);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1344
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
#include <numeric>
int main() {
    ll n, m;
    cin >> n >> m;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    // sort(a.begin(), a.end());
    priority_queue<ll> que;
    for(int i = 0; i < n; i++) {
        que.push(a[i]);
    }   

    for (int i = 0; i < m; i++) {
        ll itemPrice = que.top();
        que.pop();
        ll discountedPrice = itemPrice / 2;
        que.push(discountedPrice);
    }
    ll price = 0;
    for(int i = 0; i < n; i++) {
        price += que.top();
        que.pop();
    }

    cout << price << endl;
    return 0;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

int main()
{
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    vector<pll> p(N);
    rep(i, N)
    {
        cin >> p[i].second >> p[i].first;
    }

    sort(ALL(p));

    ll t = 0;

    rep(i, N)
    {
        t += p[i].second;
        if (t > p[i].first) {
            cout << "No" << endl;
            return 0;
        }
    }


    cout << "Yes" << endl;
}


Measured memory_bytes: 3456
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
if n==1:
    print(1)
else:
    dp=[1]*n
    cor=[1]*n
    for i in range(m):
        cor[int(input())]=0
    if cor[0]==0:
        dp[0]=0
    if cor[1]==0:
        dp[1]=0
    for i in range(2,n):
        if cor[i]==0:
            dp[i]=0
        else:
            dp[i]=(dp[i-1]+dp[i-2])%1000000007
    print((dp[n-1]+dp[n-2])%1000000007)

Measured memory_bytes: 41708
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<58;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
vvl a;

int main(){
	cin>>n;
	a=vvl(n,vl(n));
	for(int i=0;i<n;i++) for(int j=0;j<n;j++){
		cin>>a[i][j];
		if(i!=j&&!a[i][j]) a[i][j]=INF;
	}
	for(int k=0;k<n;k++) for(int i=0;i<n;i++) for(int j=0;j<n;j++) if(a[i][j]>a[i][k]+a[k][j]){
		cout<<-1<<endl;
		return 0;
	}
	for(int k=0;k<n;k++) for(int i=0;i<n;i++) for(int j=0;j<n;j++) if(i!=j&&i!=k&&j!=k&&a[i][j]==a[i][k]+a[k][j]){
		a[i][j]=INF;
	}
	ll res=0;
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) if(a[i][j]!=INF) res+=a[i][j];
	cout<<res/2<<endl;
}

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

al = list(map(int,input().split()))

front_gcd = []

a_init = al[0]
for a in al:
    a_init = fractions.gcd(a, a_init)
    front_gcd.append(a_init)
    
back_gcd = []

b_init = al[-1]
for b in al[::-1]:
    b_init = fractions.gcd(b, b_init)
    back_gcd.append(b_init)
    
back_gcd = back_gcd[::-1]

ans = 1
for i in range(n):
    if i == 0:
        x = back_gcd[1]
    elif i == n-1:
        x = front_gcd[-2]
    else:
        x = fractions.gcd(front_gcd[i-1], back_gcd[i+1])
    if x > ans:
        ans = x

print(ans)



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

int main(){
    int n;
    cin >> n;
    vector <int> a(n + 10);
    for (int i=2, x; i<=n; i++) cin >> x, a[x]++;
    for (int i=1; i<=n; i++) cout << a[i] << '\n';
    return 0;
}


Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
using ll = long long;
const int MAX = 300000;
const int mod = 998244353;

int main(){
  int k, a, b;
  cin >> k >> a >> b;
    
  if( b/k-a/k==0 && b%k!=0 && a%k!=0 ) cout << "NG" << endl;
  else cout << "OK" << endl;
  
  return 0;
}

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

int main()
{
	string S; cin >> S;
	for (int i = 1; i <= S.size(); i++) {
		if (i % 2 == 1 && S[i-1] == 'L') {
			cout << "No" << endl;
			return 0;
		}
		else if (i % 2 == 0 && S[i-1] == 'R') {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

//ここから
vector<int>dis,dis2;
vector<bool>visited,visited2;

void dfs(int v,vector<vector<int>> &g,int d){
  visited[v]=true;
  dis[v]=d;
  for(auto x:g[v]){
    if(!visited[x])dfs(x,g,d+1);
  }
}
void dfs2(int v,vector<vector<int>> &g,int d){
  visited2[v]=true;
  dis2[v]=d;
  for(auto x:g[v]){
    if(!visited2[x])dfs2(x,g,d+1);
  }
}
void solve(){
  int n;
  cin>>n;
  vector<vector<int>>g(n);
  dis.resize(n);
  dis2.resize(n);
  visited.resize(n);
  visited2.resize(n);
  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    g[a].pb(b);
    g[b].pb(a);
  }
  dfs(0,g,0);
  dfs2(n-1,g,0);
  int f=0,s=0;
  rep(i,n){
    if(dis[i]<=dis2[i])++f;
    else ++s;
  }
  if(f>s)cout<<"Fennec";
  else cout<<"Snuke";
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 11264