akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



const int MAX = 10001000;
bool IsPrime[MAX];
vector<int> Era(int n = MAX) {
    vector<int> res;
	IsPrime[0] = false; IsPrime[1] = false; 
	for (int i = 2; i < n; ++i) IsPrime[i] = true;
	for (int i = 2; i < n; ++i) {
		if (IsPrime[i]) {
            res.push_back(i);
			for (int j = i*2; j < n; j += i) IsPrime[j] = false;
		}
	}
    return res;
}




int Q;
int Is[MAX];
int sum[MAX];

int main() {
  Era();

  memset(Is, 0, sizeof(Is));
  for (int i = 0; i < 210000; ++i) {
	if (i % 2 == 0) continue;
	if (IsPrime[i] && IsPrime[ (i+1)/2 ]) Is[i] = 1;
  }
  for (int i = 0; i < 210000; ++i) {
	sum[i+1] = sum[i] + Is[i];
  }

  cin >> Q;
  for (int i = 0; i < Q; ++i) {
	int l, r;
	cin >> l >> r;
	int tmp = sum[r + 1] - sum[l];
	cout << tmp << endl;
  }
	
}






Measured memory_bytes: 50628
import java.util.Scanner

import scala.annotation.tailrec

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)

    val a, b, c = sc.nextInt()
    val ans = math.min(b / a, c)

    println(ans)
  }

  def debug(args: Any*): Unit = {
    Console.err.println(args.mkString(" "))
  }

  def printExecTime(process: => Unit): Unit = {
    val start = System.currentTimeMillis
    process
    debug("処理時間： " + (System.currentTimeMillis - start) + " ミリ秒")
  }

  def bitSearch[T](n: Int, choice: Vector[T]): Vector[Vector[T]] = {
    @tailrec
    def bitSearchLogic(n: Int,
                       choice: Vector[T],
                       acc: Vector[Vector[T]]): Vector[Vector[T]] = {
      if (n == 0) acc
      else {
        val newAcc =
          acc.flatMap(vec => {
            choice.map(c => vec :+ c)
          })
        bitSearchLogic(n - 1, choice, newAcc)
      }
    }

    val firstAcc = choice.map(i => Vector(i))
    bitSearchLogic(n - 1, choice, firstAcc)
  }
}


Measured memory_bytes: 27712
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define pb push_back
#define size(v)  (int) v.size()
#define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
ll inv(ll a){return power_mod(a,mod-2);}    
ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}

int main() {

 int n,k;
 cin >> n >> k;
 int p[n+1];
 for(int i = 1; i <= n; i++) cin >> p[i];
 sort(p+1,p+n+1);
 int sum = 0;
 for(int i = 1; i <= k; i++) sum += p[i];
 cout << sum << endl;
}

Measured memory_bytes: 3524
K=int(input())
li=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(li[K-1])

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

using namespace std;

int main() {
    int n = 0;
    int k = 0;
    cin >> n >> k;
    vector<int>a(n);
    for (int i = 0; i < n; i++)
    {
      cin >> a.at(i);
    }
    for (int i = 0; i < n - k; i++)
    {
      if (a.at(k + i + 0) > a.at(i)) {
        cout << "Yes" << endl;
      }
      else {
        cout << "No" << endl;
      }
    }
    return 0;
}

Measured memory_bytes: 4024
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())

    if abs(n - m) >= 2:
        print(0)
        exit()

    fact = [1]
    for i in range(2, max(n, m) + 1):
        fact.append((fact[-1] * i) % mod)

    res = fact[n - 1] * fact[m - 1] % mod
    print(res if n != m else res * 2 % mod)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 7060
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    string s; cin>>s;
    ll k; cin>>k;
    ll n = s.size();

    set<int> st;
    for(int i=0; i<n; i++){
        st.emplace(s[i] - 'a');
    }

    ll ans = 0;
    if(st.size() == 1){
        if(n % 2 == 0){
            ans += n * k / 2;
        }
        else{
            ans += n * ((k + 1) / 2);
            if(k % 2 == 1){
                ans -= n / 2 + 1;
            }
        }
    }
    else{
        bool valid = false;
        if(s[0] == s[n-1]){
            ll head = 0;
            char h = s[0];
            for(int i=0; i<n; i++){
                if(h != s[i]) break;
                head++;
            }
            ll tail = 0;
            char t = s[n-1];
            for(int i=n-1; i>=0; i--){
                if(t != s[i]) break;
                tail++;
            }

            if(head % 2 && tail % 2){
                valid = true;
            }
        }

        ll cnt = 0;
        for(int i=1; i<n; i++){
            if(s[i-1] == s[i]){
                s[i] = '@';
                cnt++;
            }
        }

        ans += cnt * k;
        if(valid) ans += (k - 1);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/*

*/
#include<bits/stdc++.h>

using namespace std;
using ll=long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  string s,t;cin>>s>>t;
  bool flag=true;
  rep(i,s.size()){
	  if(s[i]!=t[i]){
	    flag=false;
	    break;
	  }
    //cout<<flag<<endl;
  }
  cout<<(flag ? "Yes":"No")<<endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define bit(n) 1 << n
using namespace std;
using cd = complex <double>;
 
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <pair <int, int> > vii;
typedef map <int, int> mii;
 
const int Inf = 1000000007;
//const int mod = 998244353;//1000000007;
const double Pi = acos(-1);
 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n, m, c = 0;
vector <int> Adj[100005];
int H[100005];

void Solve()
{	
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
	{
		cin >> H[i];
	}
	for(int i = 1; i <= m; i++)
	{
		int u, v;
		cin >> u >> v;
		Adj[u].eb(v);
		Adj[v].eb(u);
	}
	for(int i = 1; i <= n; i++)
	{
		c++;
		for(auto x : Adj[i])
		{
			if(H[i] <= H[x])
			{
				c--;
				break;
			}
		}
	}
	cout << c;
}
 
int main()
{
	Fastio();
	Solve();
}

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

int main () {
    int n;
    cin >> n;
    int cnt = 0;
    int maxnum = 0;
    for (int i = 1; i <= n; i++) {
        int temp = i;
        int tempcnt = 0;
        while (temp % 2 == 0) {
            tempcnt++;
            temp /= 2;
        }
        if (max(cnt, tempcnt) == tempcnt) {
            cnt = tempcnt;
            maxnum = i;
        }
    }
    cout << maxnum << endl;
}



Measured memory_bytes: 256
#include<iomanip>
#include <string>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
#define nin(n) int n; cin >> n;
#define kin(k) int k; cin >> k;
const int INF = 1001001001;
int main(){
  int n;cin >> n;
  vector<double> vec(n);
  bool ans=true;
  for(int i=0;i<n;i++){
    cin >> vec.at(i);
  }
  if(n==1){
    cout << "Yes";
  }
  else{
    for(int i=0;i<n-1;i++){
      if(vec.at(i+1)-vec.at(i)<-1){
        ans=false;
        break;
      }
      else if(vec.at(i+1)-vec.at(i)==-1){
        vec.at(i+1)++;
      }
    }
    if(ans) cout <<"Yes";
    else cout <<"No";
  }
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078
int main()
{
	int a,b;
	int h,m;
	scanf("%d%d%d%d",&a,&b,&h,&m);
	double hour[13];
	int i;
	for(i=0;i<13;i++){
		hour[i]=30*i/180.0*pi;
	}
	double min[61];
	for(i=0;i<61;i++){
		min[i]=6*i/180.0*pi;
	}
	double rad=fabs(hour[h]+0.5*m/180*pi-min[m]);
	double result;
	result=sqrt(a*a+b*b-2*a*b*cos(rad));
	printf("%.9f",result);
	return 0;
} 

Measured memory_bytes: 2552
#include <iostream>
#include <string>
#include <algorithm>
#include  <set>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,n) for(i=0;i<n;i++)

int main() {
	int a, b, c, d, e, f, g, h,i,j,n,m,l,sum=0;
	ll  aa, bb;
	char s[15];
	cin >> s ;
	c = 15;
	rep(i, c) {
		if (s[i] == 'x')sum++;
	}
	if(sum>=8)cout << "NO";
	else cout << "YES";


	return 0;
}

Measured memory_bytes: 256
N = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
#lst = prime_factorize(N)
lst = make_divisors(N)
lst.sort()
#print(lst)
if len(lst) == 2:
    print(lst[-1] - 1)
else:
    if len(lst) % 2 == 0:
        print(lst[len(lst)//2] + lst[len(lst) // 2 - 1] - 2)
    else:
        print(lst[len(lst) // 2] * 2 - 2)

Measured memory_bytes: 3268
import sys
sys.setrecursionlimit(10**8)

def sort(a):
	a.sort()

def rev(a):
	a.reverse()

def sd():
	return int(input())

def _sd():
	return map(int,input().split())


def ss():
	return input()

def sf():
	return float(input())

def dfs():
		# write dfs code here. And delete pass.
		pass

def bfs():
		# write bfs code here. And delete pass.
		pass
 
def main():
	f=bool(False)
	ans = int(0)
	N=sd()
	A=list(map(int,input().split()))
	while(1):
		for i in range(N):
			if A[i]%2:
				f=True
			else : 
				A[i]/=2
		if(not f):
			ans+=1
		else:
			break
	print(ans)

main()

Measured memory_bytes: 38640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        int[] x=cin.ArrayInt(4,0);
        string ans="Balanced";
        if(x[0]+x[1]>x[2]+x[3])ans="Left";
        else if(x[0]+x[1]<x[2]+x[3])ans="Right";
        Console.WriteLine(ans);
          
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
    public void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}

Measured memory_bytes: 11092
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline

def solve():
    n,y = list(map(int,input().split()))
    for i in range(n+1):
        #1万円がi枚
        for j in range(n+1-i):
            #5000円がj枚
            #1000円がn-i-j枚
            if y==10000*i+5000*j+1000*(n-i-j):
                return (i,j,n-i-j)
    return(-1,-1,-1)
print(" ".join(map(str,solve())))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <deque>
#include <queue>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#define INF 1000000000
#define MOD 1000000007
using namespace std;
using ll = long long;
int main() {
    int a,b,k;
    cin >> a >> b >> k;
    int cnt = 0;
    int num = 100;
    while(cnt!=k){
        if(a%num == 0 && b%num == 0){
            cnt++;
        }
        if(cnt==k){
            break;
        }
        num--;
    }
    cout << num << endl;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M,X;
  cin>>N>>M>>X;
  int a[M];
  for(int i=0;i<M;i++){
    cin>>a[i];
  }
  int g0=0,gN=0;
  
  for(int i=0;i<M;i++){
    if(a[i]<X){
      g0++;
    }
    else if(a[i]>X){
      gN++;
    }
  }
  cout<<min(g0,gN)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
using namespace std;
#define ll long long

string s;
int ans = 0;

int main() {
	cin >> s;

	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == '2') {
			ans++;
		}
	}
	cout << ans << endl;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define repr(i, n) for(int i = n;i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define MOD 1000000007

typedef long long ll;

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

    int n,ans = 0;
    cin >> n;
    int a[n + 1];

    rep(i,n){
        cin >> a[i + 1];
    }

    int tmp,b = 1;

    while(1){
        if(b == 2) break;
        if(a[b] == 0){
            cout << -1 << endl;
            return 0;
        }
        tmp = b;
        b = a[tmp];
        a[tmp] = 0;
        ans++;
    }

    cout << ans << endl;

	return 0;
}

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

const int inf = ( 1 << 28);

int dp[20001][256];
int solve(int n,int m,int *cbook,int *in){
  rep(i,n+1)rep(j,256)dp[i][j]=inf;
  dp[0][128]=0;

  rep(i,n){
    rep(j,256){
      if (dp[i][j] == inf)continue;
      rep(k,m){
	int next=j+cbook[k];
	if (next<0)next=0;
	else if (next>255)next=255;
	dp[i+1][next]=min(dp[i+1][next],dp[i][j]+(next-in[i])*(next-in[i]));
      }
    }
  }
  
  int ans = inf;
  rep(i,256)ans=min(ans,dp[n][i]);
  return ans;
}


main(){
  int n,m;
  int in[20000],cbook[200];
  while(scanf("%d%d",&n,&m) && n){
    rep(i,m)scanf("%d",&cbook[i]);
    rep(i,n)scanf("%d",&in[i]);
    cout << solve(n,m,cbook,in) << endl;
  }
}

Measured memory_bytes: 20000
#include <iostream>
#include <algorithm>

#define MAX_N 100
#define MAX_W 10000

int N, W, v[MAX_N], w[MAX_N];
int dp[MAX_N + 1][MAX_W + 1];

void solve();

int main(){
    std::cin >> N >> W;
    for(int i = 0; i < N; ++i)
        std::cin >> v[i] >> w[i];
    
    solve();
    
    return 0;
}

void solve(){
    for(int i = N - 1; i >= 0; --i){
        for(int j = 0; j <= W; ++j){
            if(j < w[i])
                dp[i][j] = dp[i + 1][j];
            else
                dp[i][j] = std::max(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i]);
        }
    }
    
    std::cout << dp[0][W] << std::endl;
    return;
}

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


int heights[128];

int calcoprs(int l, int r, int offset){
    if(l > r) return 0;
    if(l == r) return heights[l] - offset;

    int val = *min_element(heights+l,heights+r+1);
    int tot = val - offset;
    int cl = l;
    for(int i=l;i<=r;i++) if(heights[i] == val){
        tot += calcoprs(cl, i-1, val);
        cl = i+1;
    }

    tot += calcoprs(cl,r,val);
    return tot;
}
int main(){
    int N;cin>>N;
    for(int i=0;i<N;i++) cin>>heights[i];
    cout<<calcoprs(0,N-1,0)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
long long int gcd(long long int a, long long int b){
  long long int c;
  while( a != 0 ){
    c = a;
    a = b%a;
    b = c;
  }
  return b;
}
int main() {
  int n;
  cin >> n;
  vector<long long int> t(n);
  for(int i=0; i<n; i++) cin >> t[i];

  long long int ans = t[0];
  for(int i=1; i<n; i++){
    ans = ans/gcd(ans, t[i])*t[i];
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
n=int(input())
x=list(map(int,input().split()))
sorted_x=sorted(x)
min_m,max_m=sorted_x[n//2-1],sorted_x[n//2]

for i in range(n):
  if x[i]<=min_m:
    print(max_m)
  else:
    print(min_m)
    


Measured memory_bytes: 104788
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  bool f=true;
  int m=s.size();
  int n=(m-1)/2;
  for(int i=0;i<m;i++){
    if(s[i]!=s[m-i-1])
      f=false;
  }
  for(int i=0;i<n;i++){
    if(s[i]!=s[n-i-1])
      f=false;
  }
  if(f==false)
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
  return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;


int main(){
    int x,a,b;cin >>x>>a>>b;
    b-=a;
    if(b<=0)puts("delicious");
    else if(b<=x)puts("safe");
    else puts("dangerous");
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    vector<double> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    double sum=0;
    for(auto it:a)sum+=it;
    int res=0;
    double ok=sum/(4*m);
    for(auto it:a){
        if(it>=ok)res++;
    }
    if(res>=m)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
(defmacro rep (n &body body)
  `(loop repeat ,n do ,@body))
(defun repc (n c)
  (let ((x nil)) (rep n (setq x (cons c x))) x))
(defun solve (a b)
  (append (repc b #\U) (repc a #\R) (repc b #\D) (repc (1+ a) #\L)
          (repc (1+ b) #\U) (repc (1+ a) #\R) (repc 1 #\D) (repc 1 #\R)
          (repc (1+ b) #\D) (repc (1+ a) #\L) (repc 1 #\U)))
(let ((sx (read))
      (sy (read))
      (tx (read))
      (ty (read)))
  (format t "~{~A~}~%" (solve (- tx sx) (- ty sy))))

Measured memory_bytes: 6504
/*
 * 	Heart beats fast
 * 		Colors and promises
 * 			How to be brave
 * 				How can I love when I am afraid to fall...
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
// #include<boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define mod 1000000007
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<=n;i++)
#define fr(i,k,n) for(int i=k;i>=n;i--)
#define pb push_back
#define F first
#define S second
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
 
void solve()
{
  int h,w;
  cin >> h >> w;
  if(h==1 || w==1)
{
	cout << 1 ;return;
}
  cout << ((h+1)/2)*((w+1)/2) + (h/2)*(w/2);
  return;
}
signed main()
{
   FAST;
	int T=1;
	// cin >> T;
	while(T--)
	{
		solve();
	}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
		int n, m; cin >> n >> m;
		vector<pair<int, int>> S(n);
		rep (i, n) {
			int a, b; cin >> a >> b;
			S[i] = make_pair(a, b);
		}
		sort(all(S));
		int64 ans = 0;
		priority_queue<int> P;
		int id = 0;
		repn (i, m) {
			while (id < n && S[id].first <= i) {
				P.push(S[id++].second);
			}
			if (!P.empty()) {
				ans += P.top();
				P.pop();
			}
		}
		cout << ans << endl;
    return;
}

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



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

using namespace std;
using LL = long long int;



int main()
{
    int N; cin >> N;
    int ans = 1145141919;
    for(int i = 0; i < N; i++) {
        int a; cin >> a;
        int cnt = 0;
        while(a > 0) {
            if(a%2 == 0) {
                a /= 2;
                cnt++;
            } else {
                break;
            }
        }
        ans = min(ans, cnt);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int i;
    int a,b,c,d=0;
    scanf("%d %d %d",&a,&b,&c);
    for(i=1;i<=b;i++){
        if(a*i%b==c){
            printf("YES\n");
            d=1;
            break;
        }
    }
    if(d==0){
        printf("NO\n");
    }
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
#define fi(p) for(int i=0;i<(p);i++)
#define ce(d) cout<<d<<endl;
#define ll long long
#define sorts(c) sort((c).begin(),(c).end());

using namespace std;

void solve() {
	int a;
	cin >> a;
	int odd;
	if (a % 2 == 1) {
		odd = a / 2 + 1;
	}
	else {
		odd = a / 2;
	}

	float res = (float)odd / a;
	ce(res);
}



int main()
{

	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

Measured memory_bytes: 256
import sys
import math
import bisect

def solve(A):
    n = len(A)
    A.sort()
    l = (n - 1) // 2
    r = l + 1
    return A[r] - A[l]

def main():
    n = int(input())
    A = list(map(int, input().split()))
    print(solve(A))

if __name__ == "__main__":
    main()


Measured memory_bytes: 52684
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<int> gr;
  int ans = 0;
  int add = 1;
  rep2(i, 1, s.size()){
    if(s.at(i-1) != s.at(i)){
      gr.push_back(add);
      ans += add-1;
      add = 1;
    }else add++;
  }
  gr.push_back(add);
  ans += add-1;
  cerr << ans << " " << gr.size() << endl;
  ans = min(n-1, ans + 2*k);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4092
from collections import deque

n, m = map(int, input().split())
xyz = {i:[] for i in range(1, n+1)}
for _ in range(m):
    x, y, z = map(int, input().split())
    xyz[x].append((x, y, z))
    xyz[y].append((y, x, z))

connects = [0]*(n+1)
group = 1
for i in range(1, n+1):
    if connects[i] > 0:
        continue
    if len(xyz[i]) == 0:
        connects[i] = group
        group += 1
        continue

    que = deque(xyz[i])
    connects[i] = group
    while len(que) > 0:
        x, y, z = que.popleft()
        connects[y] = group
        for xn, yn, zn in xyz[y]:
            if connects[yn] > 0:
                pass
            else:
                que.append((xn, yn, zn))
    group += 1
    
# print(connects)
print(max(connects))


Measured memory_bytes: 92516
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n;
  cin >> n;
  int ans = 0;
  rrep(i,n){
    if(n%i==0)ans+=n/i-1;
    else ans += n/i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include <cmath>
#include <cstdio>

int main(){
    double x1, x2, y1, y2;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    printf("%lf\n", sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));
    return 0;
}


Measured memory_bytes: 2692
#include "bits/stdc++.h"
#define int long long int
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vvi vector<vector<int>>
#define vi vector<int>
#define f first
#define s second
using namespace std;
const int mod = 1e9 + 7;
vvi adj(3e6);
vi prime(3e6, 1);
/*

*/
int spf[1000001];
void sieve()
{
  for(int i = 1;i<=1000000;i++)
    spf[i] = i;
    for(int i = 2;i<=1000000;i++){
        if(spf[i] == i){
            for(int j = i*i;j<=1000000;j+=i){
                spf[j] = i;
            }
        }
    }
    for(int i = 2;i<=1000000;i++){
        int x = i;
        while(x>1){
            int fact = spf[x];
            int cnt  = 0;
            while(x%fact == 0){
                x = x/fact;
                cnt++;
            }
            if(cnt>0){
                adj[i].push_back(fact);
            }
        }
    }
}

int solve() {
  sieve();
 // for (auto it : adj[105]) cout << it << " ";
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++)
  {
    cin >> v[i];
  }
  map<int, int> mp;
  int flag = 0;
  for (int i = 0; i < n; i++)
  {
    int x = v[i];
    for (auto it : adj[x])
    {
      if (mp[it])
      {
        flag = 1;
        break;
      }
      else mp[it] = 1;
      //cout << it << " ";
    }
    //cout << '\n';
    if (flag == 1)
    {
      break;
    }
  }
  if (flag == 0)cout << "pairwise coprime";
  else
  {
    int gcd = v[0];
    for (int i = 1; i < n; i++)
    {
      gcd = __gcd(gcd, v[i]);
    }
    if (gcd == 1)cout << "setwise coprime";
    else cout << "not coprime";
  }
  return 0;
}
int32_t main() {
  fast;
  int t = 1;
  //cin >> t;
  while (t--)
  {
    solve();
  }
  return 0;
}

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

using namespace std;
typedef long long int lli;

lli x;
lli ans;

int main()
{
	scanf("%lld",&x);

	ans = x/11;
	x %= 11;

	ans *= 2; 
	if( x > 0 ) ans++;
	if( x > 6 ) ans++; 

	printf("%lld\n",ans);
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

int a[MAXN], b[MAXN], a1[MAXN], b1[MAXN];

vi g[MAXN];

vector<pii> pp;

int used[MAXN];
int cur_sz;

void dfs(int s){
	used[s] = 1;
	cur_sz++;
	REP(i, 0, SZ(g[s])){
		int to = g[s][i];
		if (!used[to]){
			dfs(to);
		}
	}
}

void solve(){
	int n, sa;
	scanf("%d", &n);
	REP(i, 0, n){
		scanf("%d", &a[i]);
		a1[i] = a[i];
		a1[n] ^= a[i];
	}
	REP(i, 0, n){
		scanf("%d", &b[i]);
		b1[i] = b[i];
		b1[n] ^= b[i];
	}
	sa = a1[n];
	sort(a1, a1 + n + 1);
	sort(b1, b1 + n + 1);
	REPN(i, 0, n){
		if (a1[i] != b1[i]){
			printf("-1\n");
			return;
		}
	}
	
	/*REP(i, 0, n){
		a1[i] = a[i];
		b1[i] = b[i];
	}
	sort(a1, a1 + n);
	sort(b1, b1 + n);
	bool has_dif = false;
	REP(i, 0, n){
		if (a1[i] != b1[i]){
			has_dif = true;
		}
	}
	if (!has_dif){
		
	}*/
	
	REP(i, 0, n){
		if (a[i] != b[i]){
			pp.pb(mp(a[i], i));
			pp.pb(mp(b[i], i));
		}
	}
	SORT(pp);
	REP(i, 0, SZ(pp) - 1){
		if (pp[i]._1 == pp[i + 1]._1){
			int s = pp[i]._2;
			int to = pp[i + 1]._2;
			g[s].pb(to);
			g[to].pb(s);
		}
	}
	
	int ans = 0;
	REP(i, 0, SZ(pp)){
		int s = pp[i]._2;
		if (!used[s]){
			cur_sz = 0;
			dfs(s);
			ans += cur_sz + 1;
		}
	}
	REP(i, 0, n){
		if (a[i] != b[i] && b[i] == sa){
			ans--;
			break;
		}
	}
	printf("%d\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 13936
n,l=int(input()),list(map(int,input().split()))
c=[0]*n
c[1]=abs(l[0]-l[1])
for i in range(2,n):
  c[i]=min(c[i-2]+abs(l[i]-l[i-2]),c[i-1]+abs(l[i]-l[i-1]))
print(c[-1])

Measured memory_bytes: 13928
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
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; }

bool check(string& s, string& t, int si){
    rep(i, t.size()){
        if(s[si+i] != t[i]){
            return false;
        }
    }
    return true;
}

string ans = "NO";
string t[4];

void dfs(string& s, int si){
    if(si == s.size()){
        ans = "YES";
        return;
    }

    rep(i, 4){
        if(check(s, t[i], si)) dfs(s, si+t[i].size());
    }
}

int main()
{
    string s; cin >> s;
    t[0] = "dream";
    t[1] = "dreamer";
    t[2] = "erase";
    t[3] = "eraser";
    dfs(s, 0);
    pr(ans);
    return 0;}

Measured memory_bytes: 4512
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

int digit(int x){
    int ret = 0;
    if(x == 0) return 1;
    while (x != 0)
    {
        x /= 10;
        ret ++;
    }
    return ret;
}

int head(int x, int n){
    for(int i = 0; i < n; i++){
        x /= 10;
    }
    return x % 10;
}


int main(){

    int n, m;
    cin >> n >> m;

    vector<int> v(n, -1);
    bool flag = true;

    vector<int> s(m);
    vector<int> c(m);
    for(int i = 0; i < m; i++){
        cin >> s[i];
        cin >> c[i];
        s[i] = n - s[i];
        /*
        int s, c;
        cin >> s >> c;
        s --;
        if( v[s] == -1 ) v[s] = c;
        else if( v[s] == c ) continue; 
        else flag = false;
        */
    }

    for(int i = 0; i <= 999; i++){
        if( digit(i) != n ) continue;

        bool flag = true;
        for(int j = 0; j < m; j++){
            if( head(i, s[j]) != c[j] ) {
                flag = false;
            }
        }
        if(flag) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    /*

    if( v[0] == 0 && n != 1 ) flag = false;

    if( !flag ){
        cout << -1 << endl;
        return 0;  
    } 


    for (size_t i = 0; i < n; i++){
        if( v[i] == -1 ){
            if(i == 0) cout << 1;
            else cout << 0;
        }
        else{
            cout << v[i];
        }
    }
    cout << endl;
    */

}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void){
    int a,b,t,res[101];
	cin >> t;
	for(a=0;a<t;a++){
		int n,b,nn,up=0,down=0;
		cin >> n;
		for(b=0;b<n;b++){
			cin >> res[b];
		}
		for(b=0;b<n-1;b++){
			if(res[b+1]-res[b]>0)up=max(up,res[b+1]-res[b]);
			if(res[b+1]-res[b]<0)down=max(down,res[b]-res[b+1]);
		}
		cout << up << " " << down << endl;
	}
    return 0;
}


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

int main()
{
	int x, y;
	char s[8001];
	scanf("%s", s);
	scanf("%d %d", &x, &y);
	
	int k, n, count[8001] = {};
	for (n = 0, k = 0; s[n] != 0; n++) {
		if (s[n] == 'F') count[k]++;
		else k++;
	}
	
	int i, j, l[2], dp[2][16001] = {}, pos[2][16001];
	for (i = 0, l[0] = 1, dp[0][n] = 1, pos[0][0] = n; i * 2 < k; i++) {
		l[1-i%2] = 0;
		for (j = 0; j < l[i%2]; j++) {
			if (pos[i%2][j] >= count[i*2+1] && dp[1-i%2][pos[i%2][j] - count[i*2+1]] == 0) {
				dp[1-i%2][pos[i%2][j] - count[i*2+1]] = 1;
				pos[1-i%2][l[1-i%2]++] = pos[i%2][j] - count[i*2+1];
			}
			if (pos[i%2][j] <= n * 2 - count[i*2+1] && dp[1-i%2][pos[i%2][j] + count[i*2+1]] == 0) {
				dp[1-i%2][pos[i%2][j] + count[i*2+1]] = 1;
				pos[1-i%2][l[1-i%2]++] = pos[i%2][j] + count[i*2+1];
			}
			dp[i%2][pos[i%2][j]] = 0;
		}
	}
	if (dp[i%2][n+y] == 0) {
		printf("No\n");
		fflush(stdout);
		return 0;
	}
	for (j = 0; j <= n * 2; j++) {
		dp[0][j] = 0;
		dp[1][j] = 0;
	}
	for (i = 1, l[1] = 1, dp[1][n+count[0]] = 1, pos[1][0] = n + count[0]; i * 2 <= k; i++) {
		l[1-i%2] = 0;
		for (j = 0; j < l[i%2]; j++) {
			if (pos[i%2][j] >= count[i*2] && dp[1-i%2][pos[i%2][j] - count[i*2]] == 0) {
				dp[1-i%2][pos[i%2][j] - count[i*2]] = 1;
				pos[1-i%2][l[1-i%2]++] = pos[i%2][j] - count[i*2];
			}
			if (pos[i%2][j] <= n * 2 - count[i*2] && dp[1-i%2][pos[i%2][j] + count[i*2]] == 0) {
				dp[1-i%2][pos[i%2][j] + count[i*2]] = 1;
				pos[1-i%2][l[1-i%2]++] = pos[i%2][j] + count[i*2];
			}
			dp[i%2][pos[i%2][j]] = 0;
		}
	}
	if (dp[i%2][n+x] == 0) printf("No\n");
	else printf("Yes\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 384
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var n,m,x int
    fmt.Scan(&n,&m,&x)
    mp := make(map[int]int)
    for i:=n; i<min32(n+x,m+1); i++{
        mp[i]++
    }
    for i:=m; i>max32(m-x,n-1); i--{
        mp[i]++
    }
    ans := make([]int, 0)
    for i,_ := range mp{
        ans = append(ans, i)
    }
    sort.Ints(ans)
    for i:=0; i<len(ans); i++{
        fmt.Println(ans[i])
    }
}





// Pairsort
type Pair struct {
    first,second int64
}

type By func(p1, p2 *Pair) bool

func (by By) Sort(pairs []Pair) {
    ps := &pairSorter{
            pairs : pairs,
            by: by,
    }
    sort.Sort(ps)
}

type pairSorter struct {
    pairs []Pair
    by func(p1, p2 *Pair) bool
}

func (s *pairSorter) Len() int {
    return len(s.pairs)
}

func (s *pairSorter) Swap(i, j int) {
    s.pairs[i], s.pairs[j] = s.pairs[j], s.pairs[i]
}

func (s *pairSorter) Less(i, j int) bool {
    return s.by(&s.pairs[i], &s.pairs[j])
}

func first (p1, p2 *Pair) bool {
        return p1.first < p2.first
}

func second (p1, p2 *Pair) bool {
        return p1.second < p2.second
}
// end



func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


Measured memory_bytes: 640
p = 10**9+7
def pow(x,m):
    if m==0:
        return 1
    if m==1:
        return x
    if m%2==0:
        return (pow(x,m//2)**2)%p
    else:
        return (x*(pow(x,(m-1)//2)**2)%p)%p
N = int(input())
A = list(map(int,input().split()))
a0 = ((sum(A)%p)*(sum(A)%p))%p
a1 = 0
for i in range(N):
    a1 = (a1+A[i]**2)%p
a = a0-a1
a = (pow(2,p-2)*a)%p
print(a)

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

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

  int n, m;
  cin >> n >> m;
  vector<int> cnt(n);
  int a, b;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    cnt[a-1]++;
    cnt[b-1]++;
  }
  for (int i = 0; i < n; i++) {cout << cnt[i] << '\n';}
  return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX_N 100000
int uft[MAX_N];

void init(int n)
{
	int i;
	for(i=0;i<n;i++)
		uft[i]=i;
}

int parent(int n)
{
	if(uft[n]==n)
		return n;
	else
		return uft[n]=parent(uft[n]);
}

void unit(int p,int q)
{
	uft[parent(p)]=parent(q);
}

int same(int p,int q)
{
	return parent(p)==parent(q);
}

int main()
{
	int n,q,i,a,b,c;
	scanf("%d%d",&n,&q);
	init(n);
	for(i=0;i<q;i++)
	{
		scanf("%d%d%d",&c,&a,&b);
		c?puts(same(a,b)?"1":"0"):unit(a,b);
	}
	return 0;
}

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

int main(){
  string k;
  cin >> k;
  sort(k.begin(),k.end());
  for(int i = 0; i < k.size()-1; i++){
    if(k.at(i) == k.at(i+1)){
      cout << "no" << endl;
      return 0;
    }
  }
  cout << "yes" << endl;
}

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

int main(){
  int fx, fy, tx, ty;
  cin >> fx >> fy >> tx >> ty;
  
  int xx = tx-fx;
  int yy = ty-fy;
  
  for (int i = 0; i<xx; i++){
  	cout << "R";
  }
  for (int i = 0; i<yy; i++){
    cout << "U";
  }
  for (int i = 0; i<xx; i++){
    cout << "L";
  }
  for (int i = 0; i<yy; i++){
    cout << "D";
  }
  cout << "D";
  for (int i = 0; i<xx+1; i++){
  	cout << "R";
  }
  for (int i = 0; i<yy+1; i++){
    cout << "U";
  }
  cout << "L";
  cout << "U";
  for (int i = 0; i<xx+1; i++){
    cout << "L";
  }
  for (int i = 0; i<yy+1; i++){
    cout << "D";
  }
  cout << "R" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <functional>
#include <deque>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
map<int,int> depth;
vector<vector<int>> e;
void dfs(int par,int now,int num){
   depth[now] = num;
   for(int next:e[now]){
       if(next != par)dfs(now,next,num+1);
   }
}
int main(){
    int n;
    cin >> n;

    e.resize(n);
    for(int i = 0;i < n-1;i++){
        int a,b;
        cin >> a >> b;
        a--,b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }

    vector<int> c(n);
    int m = 0;
    for(int i = 0;i < n;i++){
        cin >> c[i];//ある頂点を根とした根付き木を考えて,深さが小さい順から大きい値を入れていく.
        m += c[i];
    }
    sort(c.begin(),c.end(),greater<int>());

    m -= c[0];
    dfs(-1,0,0);
    vector<pair<int,int>> vdp(n);
    for(int i = 0;i < n;i++){
        vdp[i] = make_pair(depth[i],i);
    }

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

    map<int,int> v_val;
    for(int i = 0;i < n;i++){
        int v = vdp[i].second;
        v_val[v] = c[i];
    }

    cout << m << endl;
    for(int i = 0;i < n;i++){
        cout << v_val[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 2816
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

S = list(sys.stdin.readline().rstrip())

ans = 0
for i, c in enumerate(S):
    a = i % 2
    b = 'gp'.index(c)
    if a > b:
        ans += 1
    if a < b:
        ans -= 1
print(ans)


Measured memory_bytes: 14328
#include <iostream>

using namespace std;

int main (void)
{
    string s;

    cin >> s;
    bool unique = true;
    for (int i = 0; i < s.size() - 1; i++) {
        for (int j = i + 1; j < s.size(); j++) {
            if (s[i] == s[j]) {
                unique = false;
                break;
            }
        }
    }

    if (unique) {
        cout << "yes" << endl;
    } else {
        cout << "no" << endl;
    }

    return 0;
}

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

  #define vi vector<int>
  #define all(v) v.begin(),v.end()
  #define ll long long int
  #define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define D1(x) {cerr<<" [" <<#x<<": "<<x<<"]";cout << endl;}
  #define D2(x) {cerr<<" [" <<#x<<": ";for(auto it:x)cerr<<it<< " ";cerr<<"] ";cout << endl;}

  const ll MOD=1e9+7;

  void solve(){
     int n,m,k;
     cin >> n >> m >> k;
     
     int ans=0;
     char grid[n][m];
     for(int i=0;i<n;i++)
      for(int j=0;j<m;j++)
        cin >> grid[i][j];

     for(int i=0;i<(1<<n);i++){
       for(int j=0;j<(1<<m);j++){
         int cnt=0;
          for(int x=0;x<n;x++){
            for(int y=0;y<m;y++){
              if((i&(1<<x)) || (j&(1<<y)))continue;
              cnt += (grid[x][y]=='#');
            }
          }
          if(cnt==k)ans++;
       }
     }
     cout  << ans;
  }


  int main(){
    IOS
       solve();
       cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


Measured memory_bytes: 3752
#include <iostream>
    #include <algorithm>
    #define ll long long int
    using namespace std;
     
    int main(void)
    {
      ll n, k;
      cin >> k >> n;
      ll a[n + 1], mx = 0;
      cin >> a[0];
      for(int i = 1; i < n; i++)
      {
        cin >> a[i];
        mx = max(mx, a[i] - a[i - 1]);
      }
      if(n == 1)
        cout << "0" << endl;
      else
      {
        mx = max(mx, k - a[n - 1] + a[0]);
        cout << k - mx << endl;
      }
       
      
      
      return 0;
    }

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
  int d; cin >> d;
  string s;
  if(d == 22) s ="Christmas Eve Eve Eve";
  else if(d==23) s = "Christmas Eve Eve";
  else if(d== 24) s = "Christmas Eve";
  else s = "Christmas";
  cout << s << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
ab=[[int(j) for j in input().split()] for i in range(n)]
cd=[[int(j) for j in input().split()] for i in range(m)]
for a,b in ab:
    l=[abs(a-c)+abs(b-d) for c,d in cd]
    print(l.index(min(l))+1)

Measured memory_bytes: 3060