akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
	long long mod=(1e+9)+7;
	long long n,m;
	scanf("%lld %lld",&n,&m);
	static long long sum_x,sum_y;
	vector<long long> x(n+10),y(m+10);
	for(ll i=1;i<=n;i++)scanf("%lld",&x[i]);
	for(ll i=1;i<=m;i++)scanf("%lld",&y[i]);
	for(ll i=1;i<=n;i++){
		sum_x+=(i+i-n-1)*x[i];
		sum_x%=mod;
	}
	for(ll i=1;i<=m;i++){
		sum_y+=(i+i-m-1)*y[i];
		sum_y%=mod;
	}
	printf("%lld\n",(sum_x*sum_y)%mod);
}


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

int main(){
  int k;
  cin>>k;
  priority_queue<long long,vector<long long>,greater<long long>>pq;
  for(long long i=1;i<10;i++){
    pq.push(i);
  }
  long long ans;
  while(k--){
    ans=pq.top();
    pq.pop();
    int z=ans%10;
    if(z==0){
      pq.push(ans*10+z);
      pq.push(ans*10+z+1);
    }else{
      pq.push(ans*10+z-1);
      pq.push(ans*10+z);
      if(z!=9){
        pq.push(ans*10+z+1);
      }
    }
  }
  cout<<ans;


}


Measured memory_bytes: 2420
#include <cstdio>
#include <vector>
#include <algorithm>

int main() {
  size_t N, M;
  scanf("%zu %zu", &N, &M);

  int INF = 1e9;
  std::vector<std::vector<int>> g(N, std::vector<int>(N, INF));
  for (size_t i = 0; i < N; ++i)
    g[i][i] = 0;

  for (size_t i = 0; i < M; ++i) {
    size_t a, b;
    int c;
    scanf("%zu %zu %d", &a, &b, &c);
    --a;
    --b;
    g[a][b] = g[b][a] = c;
  }

  std::vector<std::vector<int>> d = g;
  for (size_t k = 0; k < N; ++k)
    for (size_t i = 0; i < N; ++i)
      for (size_t j = 0; j < N; ++j)
        d[i][j] = std::min(d[i][j], d[i][k]+d[k][j]);

  int res = 0;
  for (size_t i = 0; i < N; ++i)
    for (size_t j = 0; j < i; ++j)
      if (g[i][j] < INF && d[i][j] != g[i][j])
        ++res;

  printf("%d\n", res);
}


Measured memory_bytes: 384
import java.io.*;
import java.util.*;
class Main
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static FastScanner sc=new FastScanner(br);
    static PrintWriter out=new PrintWriter(System.out);
	static Random rnd=new Random();
	
    public static void main(String args[]) throws Exception
    {
		int k=sc.nextInt(),s=sc.nextInt(),ans=0;
		for(int i=0;i<=k;i++)
		{
			for(int j=0;j<=k;j++)
			{
				int curr=s-i-j;
				if(curr>=0 && curr<=k)
				{
					ans++;
				}
			}
		}
		out.println(ans);out.close();
    }
}
class FastScanner
{
    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in) {
        this.in = in;
    }
	
    public String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
	
	public String next() throws Exception {
		return nextToken().toString();
	}
	
    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}

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

const int N = 1e4 + 100, D = 110, MOD = 1000 * 1000 * 1000 + 7;

int d, dp[2][N][D];// type, len, mod
string s;

int sum(int a, int b) {
	a += b;
	if(a < 0)
		a += MOD;
	else if(a >= MOD)
		a -= MOD;
	return a;
}

void _sum(int &a, int b) {
	a = sum(a, b);
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> s >> d;
	s = "#" + s;
	dp[1][0][0] = 1;
	for (int i = 0; i < s.length() - 1; i++)
		for (int j = 0; j < d; j++)
			for (int k = 0; k <= 9; k++) {
				int digit = s[i + 1] - '0', mod = (j + k) % d;
				_sum(dp[0][i + 1][mod], dp[0][i][j]);
				if(k < digit)
					_sum(dp[0][i + 1][mod], dp[1][i][j]);
				else if(k == digit)
					_sum(dp[1][i + 1][mod], dp[1][i][j]);
			}
	cout << sum(dp[0][s.length() - 1][0], dp[1][s.length() - 1][0] - 1);
	return 0;
}

Measured memory_bytes: 8960
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <utility>
#include <math.h>
#include <stdexcept>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string.h>
#include <cassert>
#include <string.h>
#include <tuple>

using namespace std;
#define  rep(i,n) for(int i=0;i<n;i++)
#define  rrep(i,n) for(int i=n-1;i>=0;i--)///n-1番目からn回
#define  REP(i,a,b) for(int i=a;i<=b;i++) ///a番目からb回
#define  RREP(i,a,b) for(int i=a;i<b;i--)
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pair_t;
#define MOD 1000000007

//int arr[N]
////sort(arr,arr +N)

//vector <int> hoge
////sort(hoge.begin(),hoge.end());
///*min_element(hoge.begin(),hoge.end();　最小値　　　最大値はmax_element();
///(10-(n%10))%10  10-(1桁目)取得 12->8 20->0

#define Ru(n)  ( ((n)+9)/10*10  ) //切りあげ
#define Rd(n)  ( ((n)-10)/10*10 +10 )	切り捨て


int gcd(int a,int b);
size_t length(const std::string& str) {
	return str.length();
}
bool comp(const pair_t &a, const pair_t &b) {
	return a.first < b.first;
}

int main() {
	int a,b,ans;
	cin>>a>>b;
	ans=(b-1)/(a-1);
	if((b-1)%(a-1)!=0)
		ans++;
	cout<<ans<<endl;
	return 0;

}


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


Measured memory_bytes: 256
Sa = str(input())
Sb = str(input())
Sc = str(input())
S = [[ord(i)-97 for i in Sa], [ord(i)-97 for i in Sb], [ord(i)-97 for i in Sc]]

flag = True
who = 0
while flag:
  if S[who] != []:
    tmp = S[who][0]
    S[who].pop(0)
    who = tmp
  else:
    if who == 0:
      ans = 'A'
    elif who == 1:
      ans = 'B'
    else:
      ans = 'C'
    break
print(ans)

Measured memory_bytes: 9104
#include "bits/stdc++.h"

using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ll long long
#define li long int

#define pb push_back
#define m <i> map<int>
#define v <i> vector<int>

const int MX = 1e6;
const int MOD = 1e9 + 7;
const string ALPHA = "abcdefghijklmnopqrstuvwxyz";
const double PI = 3.1415926535;

#define rep(i, n) for(int i=0; i<n; i++)

int main()
{
  IOS;
  string s;
  cin >> s;
  int n=s.length();
  int t=0;
  for (int i=0; i<n; i++)
    {
      t+=(s[i]-'0');
    }
  if (t%9==0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3744
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long h = in.nextLong();
        long w = in.nextLong();

        long hw = h*w;
        long hw2 = h*w/2;

        System.out.println((w==1 || h==1) ? 1 : (hw2 + hw % 2));
    }
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var swr = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(swr);
            int n = int.Parse(Console.ReadLine());
            var nums = Enumerable.Range(100, 6).ToArray();
            int ans = Solver(n);
            Console.WriteLine(ans);
            Console.Out.Flush();
        }
        static int Solver(int x)
        {
            int max = x / 100;
            for (int a = 0; a <= max; a++)
            {
                for (int b = 0; b <= max; b++)
                {
                    for (int c = 0; c <= max; c++)
                    {
                        for (int d = 0; d <= max; d++)
                        {
                            for (int e = 0; e <= max; e++)
                            {
                                for (int f = 0; f <= max; f++)
                                {
                                    if (((a * 100) + (b * 101) + (c * 102) + (d * 103) + (e * 104) + (f * 105)) == x)
                                    {
                                        return 1;
                                    }
                                }
                            }

                        }
                    }
                }
            }
            return 0;
        }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define itn int

int main(void){
    int n;
    cin >> n;
    int h[n];
    for(int i = 0;i < n;i++)cin >> h[i];
    
    ll dp[n+10];
    for(int i = 0;i <= n;i++)dp[i] = 1e18;
    dp[0] = 0;
    
    for(int i = 0;i < n;i++){
        dp[i+1] = min(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
        dp[i+2] = min(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
    }
    cout << dp[n-1] << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16

ll n;
vector<ll> v;

int main(){
  cin>>n;
  rep(i,n){
    ll a;
    cin>>a;
    v.push_back(a);
  }
  ll nmin=v[0];
  ll res=-INF;
  repl(i,1,n){
    maxch(res,v[i]-nmin);
    minch(nmin,v[i]);
  }
  cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 4868
/*

 Remember, Hope is a good thing... May be the best of things... And No Good thing ever Dies !!!

 */
#include <bits/stdc++.h>
using namespace std;
#define m 100000
#define ll long long
#define IOS ios::sync_with_stdio(0); cout.tie(0);
#define endl "\n"
const ll inf=(1LL<<60)-1;
ll q,t,x,y,n,k,c,c1,l,r,i,j;
vector<int>a= {4,8,15,16,23,42};
int ans[4];
void solve()
{
    cin>>n;
    while(n--)
    {
        string s;
        cin>>s;
        if(s=="AC")
            x++;
        else if(s=="WA")
            y++;
        else if(s=="TLE")
            c++;
        else
            c1++;
    }
    cout<<"AC x "<<x<<endl;
    cout<<"WA x "<<y<<endl;
    cout<<"TLE x "<<c<<endl;
    cout<<"RE x "<<c1<<endl;

}
int main()
{
    IOS;
    //cin>>t;
    //while(t--)
    solve();
    return 0;
}
//33g5iazc


Measured memory_bytes: 3644
#include <algorithm>
#include <cstdio>
using namespace std;

using ll = long long;

int ans[128];

int main()
{
    ll N;
    scanf("%lld", &N);
    int i;
    for (i = 0; N; i++)
    {
        N--;
        ans[i] = N % 26;
        N /= 26;
    }
    while (i--)
    {
        printf("%c", ans[i] + 'a');
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 1644
object Main {
  def main(args: Array[String]): Unit = {
    val ab = io.StdIn.readLine().split(" ").map(_.toInt)
    val a = ab(0)
    val b = ab(1)
    def op(a: Int, b: Int): String = {
      if (a > b) ">"
      else if (a < b) "<"
      else "=="
    }
    println(s"a ${op(a, b)} b")
  }
}

Measured memory_bytes: 43812
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    ll h, w;
    cin >> h >> w;
    ll total = h * w;
    if(h == 1 || w == 1){
        cout << 1 << endl;
        return 0;
    }
    if(total % 2 == 0){
        cout << total / 2 << endl;
    } else {
        if(h == 1 || w == 1){
            cout << 1 << endl;
        } else {
            cout << total / 2 + 1 << endl;
        }
    }
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define st first
#define nd second
#define ll long long
#define ld long double
#define pb push_back
#define emp emplace_back
#define pii pair<int, int>
#define usg unsigned
#define sg signed
#define mp make_pair
 
using namespace std;
 
void setIO(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}
 
const ld PI = 4*atan((ld)1);
const int INF = 1e9+7;
const int mxN = 1e5+7;

//0 means good
//1 means bad

bool vt[mxN];
int a[mxN];

int main(){
    setIO();
    int n, k, sum=0;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=0;i<k;i++){
        int x, y;
        cin>>x>>y;
        if(a[x]<a[y]) vt[x]=1;
        else if(a[y]<a[x]) vt[y]=1;
        else vt[x]=vt[y]=1;
    }
    for(int i=1;i<=n;i++){
        if(!vt[i]) sum++;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 4132
s = input()

a = s[:5]

b = s[6:13]

c = s[14:]

print (a,b,c)

"""
インデックスが分からなくなることは慣れても頻繁にあります。
そんなときは一度紙に書いてみるとわかりやすくなりますよ！
"""


Measured memory_bytes: 2940
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if(a == b) System.out.println("Yes");
        else System.out.println("No");
        
    }
}

Measured memory_bytes: 23764
from itertools import groupby, islice

N = int(input())
D = []
c=[]
for i in range(0, N):
    D.append(list(map(int, input().split(" "))))
for i in D:
    if i[0]==i[1]:
        c.append(True)
    else:
        c.append(False)
answer = any(sum(1 for _ in islice(g, 3)) == 3 for k, g in groupby(c) if k)
if answer:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9192
import java.util.Scanner;
import java.io.PrintWriter;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());

        String op = "==";
        if( a < b ) op = "<";
        else if( a > b ) op = ">";

        PrintWriter pw = new PrintWriter(System.out);
        pw.println("a " + op + " b");
        pw.flush();
    }
}



Measured memory_bytes: 26328
n = int(input())
s = list(input())
# S = 1 W = -1
ss = [1,1]
sw = [1,-1]
ws = [-1,1]
ww = [-1,-1]
ans = []
for i in range(1,n):
  flag = 1
  if s[i] == "x":
    flag = -1
  if ss[i] == 1:
    ss.append(flag*ss[i-1])
  else:
    ss.append(flag*-ss[i-1])
  if sw[i] == 1:
    sw.append(flag*sw[i-1])
  else:
    sw.append(flag*-sw[i-1])
  if ws[i] == 1:
    ws.append(flag*ws[i-1])
  else:
    ws.append(flag*-ws[i-1])
  if ww[i] == 1:
    ww.append(flag*ww[i-1])
  else:
    ww.append(flag*-ww[i-1])
flag = 1
if s[0] == "x":
  flag = -1
if ss[0] == ss[-1] and ss[1] == ss[0]*flag*ss[-2]:
  ans = ss
elif sw[0] == sw[-1] and sw[1] == sw[0]*flag*sw[-2]:
  ans = sw
elif ws[0] == ws[-1] and ws[1] == ws[0]*flag*ws[-2]:
  ans = ws
elif ww[0] == ww[-1] and ww[1] == ww[0]*flag*ww[-2]:
  ans = ww
if ans == []:
  print(-1)
else:
  ans = ans[:n]
  ans = ["S" if i == 1 else "W" for i in ans]
  print("".join(ans))

Measured memory_bytes: 76940
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
template<typename T> void show(T e){ cout << e << endl; }
template<typename T> void show(const vector<T>& v){ for(const auto& e : v){ cout << e << " "; } cout << endl; }
template<typename T> void show(const vector<vector<T>>& vv){ for(const auto& v : vv){ show(v); } }
template<class Iter> void show(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
const ll DVSR = 10e9+7;

int main() {
  ll N, X, nex, mgcd;
  cin >> N >> X >> nex;
  mgcd = abs(X-nex);
  REP(i, N-1) {
    cin >> nex;
    mgcd = gcd(abs(nex-X), mgcd);
    X = nex;
  }
  show(mgcd);
  return 0;
}


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

int main() {
    int R,G,B,N;
    cin >> R >> G >> B >> N;
    int mx,my,mz;
    mx = N/R;
    my = N/G;
    mz = N/B;
    int cnt = 0;
    for(int i=0;i<=mx;i++){
        for(int j=0;j<=my;j++){
                int sum;
                sum = R*i+G*j;
                if((N-sum)%B==0 && N-sum>=0){
                    cnt+=1;
                }
                if(sum>=N)break;

            
        }
    }


    cout << cnt <<endl;
} 

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("2");
            WillReturn.Add("3 1");
            //2
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("3");
            WillReturn.Add("2 7 4");
            //5
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("4");
            WillReturn.Add("20 18 2 18");
            //18
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] AArr = InputList[1].Split(' ').Select(X => int.Parse(X)).ToArray();
        Array.Sort(AArr, (A, B) => B.CompareTo(A));

        int AliceScore = 0;
        int BobScore = 0;

        for (int I = 0; I <= AArr.GetUpperBound(0); I++) {
            if (I % 2 == 0) {
                AliceScore += AArr[I];
            }
            else {
                BobScore += AArr[I];
            }
        }
        Console.WriteLine(AliceScore - BobScore);
    }
}


Measured memory_bytes: 13396
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<functional>
#include<vector>
#include<math.h>
using namespace std;

int main(){
  int N;
  cin>>N;
  string blue[N];
  for(int i=0;i<N;i++) cin>>blue[i];
  
  int M;
  cin>>M;
  string red[M];
  for(int i=0;i<M;i++) cin>>red[i];
  
  int cnt_b,cnt_r;
  int ans=0;
  int tmp;
  for(string s:blue){
    cnt_b=0;
    cnt_r=0;
    tmp=0;
    for(string t:blue) if(s==t) cnt_b++;
    for(string u:red) if(s==u) cnt_r++;
    tmp=cnt_b-cnt_r;
    if(tmp<=0) continue;
    ans=max(ans,tmp);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include <string>
#include<algorithm>
#include <set>
#include <cmath>
using namespace std;

int main(void){
	ios::sync_with_stdio(false);
	int N,H,W,i,j;
	cin >> N >> H >> W;
	int A[N], B[N];
	for (i = 0; i < N; i++) cin >> A[i] >> B[i];
	j = 0;
	for (i = 0; i < N; i++) {
		if (A[i] >= H && B[i] >= W) j += 1;
	}
	cout << j;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
k = int(input())


ans = 100000001
for i in range(1<<n):
    tmp = 1
    
    for j in range(n):
        if (i>>j) & 1:
            tmp *= 2
        else:
            tmp += k
    
    ans = min(ans, tmp)

print(ans)

Measured memory_bytes: 9168
#include <cstdio>
#include <complex>
#include <vector>

using namespace std;

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

const double EPS = 1e-10;

double cross(P a, P b)
{
    return imag(conj(a) * b);
}

bool intersectLL(const L &l, const L &m)
{
    return fabs(cross(l[1]-l[0], m[1]-m[0])) > EPS;
}

int main()
{
    int n;

    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        P p[4];
        double x, y;

        scanf("%lf %lf", &x, &y);
        p[0] = P(x, y);
        scanf("%lf %lf", &x, &y);
        p[1] = P(x, y);
        scanf("%lf %lf", &x, &y);
        p[2] = P(x, y);
        scanf("%lf %lf", &x, &y);
        p[3] = P(x, y);

        puts(intersectLL(L(p[0], p[1]), L(p[2], p[3])) ? "NO" : "YES");
    }

    return 0;
}

Measured memory_bytes: 1052
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9+5;
const ll INF=1e18+5;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,l,a[100005]={},x,M=0;
  cin >> n >> l;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  for(int i=0; i<n-1; i++) {
    M=max(M,a[i]+a[i+1]);
    if(a[i]+a[i+1]>=l) {
      x=i+1;
    }
  }
  if(M<l) {
    cout << "Impossible" << "\n";
  }
  else {
    cout << "Possible" << "\n";
    for(int i=1; i<x; i++) {
      cout << i << "\n";
    }
    for(int i=n-1; i>=x; i--) {
      cout << i << "\n";
    }
  }
}

Measured memory_bytes: 1280
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

n = S()
if n[-1] in ['2', '4', '5', '7', '9']:
    print('hon')
elif n[-1] in ['0', '1', '6', '8']:
    print('pon')
else:
    print('bon')


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

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


Measured memory_bytes: 256
#![allow(unused_macros)]

// cf. [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita](https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8)
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        H: usize,
        W: usize,
        S: [chars; H],
    }
    let mut map = vec![vec!['#'; W]; H];

    for h in 0..H {
        for w in 0..W {
            if S[h][w] == '#' {
                map[h][w] = '#';
                continue;
            }
            let mut bombs = 0;
            if h > 0 && S[h - 1][w] == '#' {
                bombs += 1;
            }
            if h + 1 < H && S[h + 1][w] == '#' {
                bombs += 1;
            }
            if w > 0 && S[h][w - 1] == '#' {
                bombs += 1;
            }
            if w + 1 < W && S[h][w + 1] == '#' {
                bombs += 1;
            }
            if h > 0 && w > 0 && S[h - 1][w - 1] == '#' {
                bombs += 1;
            }
            if h > 0 && w + 1 < W && S[h - 1][w + 1] == '#' {
                bombs += 1;
            }
            if h + 1 < H && w > 0 && S[h + 1][w - 1] == '#' {
                bombs += 1;
            }
            if h + 1 < H && w + 1 < W && S[h + 1][w + 1] == '#' {
                bombs += 1;
            }
            map[h][w] = std::char::from_digit(bombs, 10).unwrap();
        }
    }
    for h in 0..H {
        let mut s = String::new();
        for w in 0..W {
            s.push(map[h][w]);
        }
        println!("{}", s);
    }
}


Measured memory_bytes: 4352
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"

using namespace std;

int main()
{
  int n;
  cin >> n;
  int a[100100];
  bool check = false;
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
    if (a[i] % 2 != 0)
    {
      check = true;
    }
  }
  cout << (check ? "first" : "second") << "\n";
}

Measured memory_bytes: 640
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def solve():
    n = int(input())
    al = [int(i) for i in input().split()]
    a = n // 2
    s = sum(al)
    ans = [0] * n
    for j in range(a):
        s -= 2 * al[(0 - (1 + 2 * (j + 1)) + n) % n]
    ans[n - 1] = s
    for i in range(n - 2, -1, -1):
        ans[i] = 2 * al[i] - ans[i + 1]
    print(" ".join([str(i) for i in ans]))

if __name__=="__main__":
    solve()


Measured memory_bytes: 75364
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long  ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (int i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef long double lldb;
typedef pair<ll, ll>  ii;
typedef pair<lldb, lldb>  iidb;
typedef pair<ll, ii>  iii;
typedef vector<ll>     vi;
typedef vector<ll>      vll;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9+7;
const lldb PI = acos(-1);
#define initseg ll new_nodo=(nodo*2),mid=(iz+der)/2;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define tam 55
#define offset 200
#define ptr nodo*
const ll MOD=1e9+7;
#define lazy first
#define sum second
ll N,X;
ll v[tam];
int dp[tam][tam];
int solve(int pos,int sumini)
{
	if (sumini<0)
		return 0;
	if (pos==N)
		return sumini==0;

	if (dp[pos][sumini]!=-1)
		return dp[pos][sumini];
	ll xi;
	int res=0;
	forr(i,0,N)
	{
		xi=v[pos]-i+X;
		//cout<<xi<<" "<<pos<<" "<<sumini<<endl;
		if (xi>=0 && xi%(N+1)==0 && sumini>=i)
		{
			res|=solve(pos+1,sumini-i);
		}
	}
	return dp[pos][sumini]=res;
}
int main()
{
	cin>>N;
	ll total=0;
	forr(i,0,N)
	{
		cin>>v[i];
		total+=v[i];
	}
	ll minn=1e18;
	forr(sum,0,N*(N-1)+1)
	{
		X=total-sum;
		memset(dp,-1,sizeof dp);

		if (solve(0,sum)==1)
		{
			
			minn=min(minn,X);
		}
	}
	cout<<minn<<endl;
}

Measured memory_bytes: 3680
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();
        }
        int sum = 0;
        for (int i = 0 ; i < n ; i++) {
            sum += a[i] - 1;
        }
        System.out.println(sum);
    }

}

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

bool sumofdigit(int x, int a, int b){
    int s=0;
    while(x){

    s+=x%10;
    x/=10;
    }
    if(s>=a && s<=b){
        return true;
    }
    else{
        return false;
    }
}


int main()
{
    ll int jogfol=0;
    int n,a,b;
    cin>>n>>a>>b;

    for(int i=1; i<=n; i++){
        if(sumofdigit(i,a,b)){
            jogfol+=i;
        }
    }
    cout<<jogfol;
    return 0;
}


Measured memory_bytes: 256
#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.at(i);
  sort(a.begin(),a.end());
  
  int k=0;
  
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      
      for(int l=j+1;l<n;l++){
        if(a.at(l)<a.at(i)+a.at(j)){
          k++;
        }
      }
      
    }
  }
  cout << k << endl;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/dp/tasks/dp_f
#include<bits/stdc++.h>
using namespace std;

void print(vector<vector<int>>& b, string s, int i, int j) {
	if ((i == 0) || (j == 0)) {
		return;
	}
	if (b[i][j] == 2) {
		print(b, s, i-1, j-1);
		cout << s[i-1];
	} else if (b[i][j] == 1) {
		print(b, s, i-1, j);
	} else {
		print(b, s, i, j-1);
	}
}

int main(int argc, char* argv[]) {
	string s, t, ans;
	cin >> s >> t;
	vector<vector<int>> c (s.size()+1, vector<int> (t.size()+1));
	vector<vector<int>> b (s.size()+1, vector<int> (t.size()+1));
	for (int i = 1; i <= (int)s.size(); i++) {
		for (int j = 1; j <= (int)t.size(); j++) {
			if (s[i-1] == t[j-1]) {
				c[i][j] = c[i-1][j-1]+1;
				b[i][j] = 2;
			} else if (c[i-1][j] >= c[i][j-1]) {
				c[i][j] = c[i-1][j];
				b[i][j] = 1;
			} else {
				c[i][j] = c[i][j-1];
				b[i][j] = 0;
			}
		}
	}
	print(b, s, s.size(), t.size());
	cout << endl;
	return 0;
}

Measured memory_bytes: 71040
#include "bits/stdc++.h"
using namespace std;

#define f first
#define s second
#define pb push_back
#define all(c) c.begin(),c.end()

#define gi(x) scanf("%d", &x)
#define pi(x) printf("%d", x)
#define gl(x) scanf("%lld", &x)
#define pl(x) printf("%lld", x)
#define sp printf(" ")
#define nl printf("\n")

typedef long long int lld;
typedef long double ldb;

main(){
    lld n, q,h,s,d;
    cin >> q >> h >> s >> d >> n;
    lld mm = min(min(q*4, h*2), s);
    lld tp = min(mm*2, d);
    if(n%2 == 0){
        cout << tp*(n/2) << endl;
    }
    else{
        cout << tp*(n/2) + mm << endl;
    }
}


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

using namespace std;
int N,M , n , m ;
int A[500][500];
typedef long long ll ;
int main()
{
    cin >>N >>M>> n >> m ;
    ll to  = 0 ;
     for(int i = 0 ; i<N ; i++){
        for(int j = 0 ; j<M ; j++){
            if((i+1)%n==0 && (j+1)%m==0)A[i][j]=-1000000000;
            else A[i][j]=(999999999)/(n*m-1);
            to+= A[i][j];
        }
    }
    if(to>=0ll){
        cout << "Yes"<<endl;
        for(int i = 0 ; i<N ; i++){
        for(int j = 0 ; j<M ; j++){
            cout << A[i][j]<< ' ';
        }
        cout<<endl;
    }
    }
    else cout <<"No";
    return 0;
}


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

int main() {
    int n, k;
    int ans = 0;
    int count = 0;
    cin >> n >> k;
    count = k;
    vector<int> L(n);

    for(int i = 0; i < n; i++){
        cin >> L[i];
    } 
    
    sort(L.begin(), L.end());
    
    for(int i = (n-k); i < n; i++){
        ans = ans + L[i];
    } 

    

    //while (count >= n-k){
    //    ans = ans + L[count];
    //    //cout << L[count];
    //    count--;
    //} 
    
    cout << ans << endl;
    return 0;
}
    


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

int main(){
    int N , K ;
    cin >> N >> K ;
    int ans = 1e9 + 7 ;
    rep(i,N){
        int A , B ;
        cin >> A >> B ;
        if( B <= K ) ans = min(ans,A) ;
    }
    if(ans != 1e9+7 )cout << ans << endl;
    else cout << "TLE" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;

int main()
{
    ll n,m;
    cin>>n>>m;
    ll mi=0;
    ll k=m/2-n;
    if(k<=0){
        cout<<min(n,m/2)<<endl;
        return 0;
    }
    for(ll i=max(0ll,k-2);i<min(m+1,k+2);i++){
        mi=max(mi,min(n+k/2,(m-k)/2));
    }
    cout<<mi<<endl;
    return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int L;
vector<pair<int,int>> E[21];

vector<int> cand[21];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>L;
	L--;
	
	for(i=2;i<=19;i++) {
		E[i].push_back({i+1,0});
		E[i].push_back({i+1,1<<(19-i)});
	}
	
	FOR(i,18) if(L&(1<<i)) if(i!=19) E[1].push_back({20-i,L&~((2<<i)-1) });
	FOR(i,L>>18) E[1].push_back({2,i<<18});
	
	E[1].push_back({20,L});
	
	int N=20,M=0;
	FOR(i,20) M+=E[i].size();
	cout<<N<<" "<<M<<endl;
	FOR(i,20) FORR(e,E[i]) cout<<i<<" "<<e.first<<" "<<e.second<<endl;
	
	cand[1].push_back(0);
	for(i=1;i<20;i++) {
		FORR(c,cand[i]) FORR(e,E[i]) cand[e.first].push_back(c+e.second);
	}
	
	sort(ALL(cand[20]));
	assert(cand[20].size()==L+1);
	cand[20].erase(unique(ALL(cand[20])),cand[20].end());
	assert(cand[20].size()==L+1);
	assert(cand[20][0]==0);
	assert(cand[20].back()==L);
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 9840
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		int tmp;
		
		Scanner scan = new Scanner(System.in);
		
		int a = scan.nextInt();
		
		int b = scan.nextInt();
		
		int c = scan.nextInt();
		
		if(a > b) {
			tmp = a;
			a = b;
			b = tmp;
		}
		
		if(b > c) {
			tmp = b;
			b = c;
			c = tmp;
		}
		
		if(a > b) {
			tmp = a;
			a = b;
			b = tmp;
		}
		
		System.out.println(a + " " + b + " " + c);
		
	}

}


Measured memory_bytes: 25808
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{

    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

//----------------------------------------------------------------

int main()
{
    ll h, w;
    cin >> h >> w;
    vector<vector<char>> a(h + 2, vector<char>(w + 2));
    for (int i = 0; i < h + 2; i++)
    {
        for (int j = 0; j < w + 2; j++)
        {
            if (i == 0 || i == h + 1)
            {
                a[i][j] = '.';
            }
            else if (j == 0 || j == w + 1)
            {
                a[i][j] = '.';
            }
            else
            {
                cin >> a[i][j];
            }
        }
    }
    bool flag = false;
    for (int i = 1; i < h + 1; i++)
    {
        for (int j = 1; j < w + 1; j++)
        {
            if (a[i][j] == '#' && a[i + 1][j] == '.' && a[i - 1][j] == '.' && a[i][j + 1] == '.' && a[i][j - 1] == '.')
            {
                flag = true;
            }
        }
    }
    if (flag)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位


int main(void){
    ll n;
    cin >> n;
    ll a[7] = {1, 2, 4, 8, 16, 32, 64};
    for(ll i = 6; i >= 0; i--){
        if(a[i]<=n){
            cout << a[i] << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
n,x,m=map(int,input().split())
s=x
t={x}
u=[x]
for i in range(1,n):
    if(x:=pow(x,2,m))in t:
        j=u.index(x)
        s=sum(u[:j])
        u=u[j:]
        s+=(n-j)//len(u)*sum(u)
        s+=sum(u[:(n-j)%len(u)])
        break
    s+=x
    t|={x}
    u+=x,
print(s)

Measured memory_bytes: 13424
/*
No matter how long a night, dawn will always break.

Simular saying ... The darkest hour is just before the dawn.
 ***************************************   ************************8   **********************************
*/
#include <bits/stdc++.h>
using namespace std;

 
#define int         long long
#define double      long double
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define sz(x)	    (int)(x).size()
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
#define _init(b)     memset(b,-1,sizeof(b))
#define _init0(b)     memset(b,0,sizeof(b))
#define MOD         1000000007
#define hell        998244353
#define output(x) cout << (x ? "YES" : "NO")<<endl;
 
 
 
 
 
int gcd(int a, int b) {if(a>b)swap(a,b) ;  if (a == 0)  return b; return gcd(b % a, a); }  
bool mod(double a,double b) {return a/b - floor(a/b);}
 
const int N=1e5+5;
vi graph[N];

 
 
 
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n,m,i,j,x,t;
   cin>>n>>m;
   vi v(n+1);
   fo(i,0,n){
   	cin>>x;
   	v[i+1]=x;
   }
   int ans=0;
   fo(i,0,m){
   	int a,b;
   	cin>>a>>b;
   	graph[a].pb(b);
   	graph[b].pb(a);
   }
   fo(i,1,n+1){
   	bool ok=true;
   		for(int aa:graph[i]){
   			if(v[aa]>=v[i])ok=false;
   		}
   		if(ok)ans++;
   }
   cout<<ans;
   
   
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

int main(){
    int n, m;
    cin >> n >> m;
    priority_queue<ll> que;
    ll res = 0;
    ll a;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        res += a;
        que.push(a);
    }
    for (int i = 0; i < m; ++i) {
        ll p = que.top();
        que.pop();
        res -= (p + 1) / 2;
        que.push(p/2);
    }
    cout << res << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define N 100001
vector<int> adj[N];
bool vis[N];
stack<int> st;

void dfs(int s){
	vis[s] = true;
	for(int u: adj[s])
		if(!vis[u])
			dfs(u);
	st.push(s);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	int n, m;
	cin>>n>>m;
	for(int i=0; i<m; i++){
		int x,y;
		cin>>x>>y;
		--x; --y;
		adj[x].push_back(y);
	}
	
	for(int i=0; i<n; i++)
		if(!vis[i]) dfs(i);
	
	vector<int> topo;
	while(!st.empty()){
		topo.push_back(st.top());
		st.pop();
	}
	
	int ans = -1;
	vector<int> dp(n, 0);
	for(int i = n-1; i>=0; i--){
		int u = topo[i];
		for(int v: adj[u])
			dp[u] = max(dp[u], 1 + dp[v]);
		ans = max(ans, dp[u]);
		// cout<<u<<' '<<dp[u]<<endl;
	}
	
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 9004
#include <stdio.h>

int main(){
    int n, i, tmp;

    scanf("%d", &n);

    for(i = n; i > 0; i--){
        tmp = i;
        while(tmp % 2 == 0){
            tmp = tmp / 2;
        }
        if(tmp == 1){
            break;
        }
    }
    
    printf("%d\n", i);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#define f first
#define s second
#define INF (1e9)
using namespace std;
struct edge{int to,cap,rev;};
vector <edge> V[101];
int v,e;
bool visited[101];

int flow(int node,int mcap){
  visited[node] = 1;
  if(node == v-1) return mcap;

  for(int i=0;i<(int)V[node].size();i++) {
    edge &w=V[node][i];

    if(visited[w.to]==true|| w.cap == 0) continue;
    int res = flow(w.to ,min( w.cap,mcap));
    if(res <=0)continue;
    w.cap -= res;
    V[w.to][w.rev].cap += res;
    return res;
  }
  return 0;
}

int solve(){
  int sum=0,f;
  while(1) {
    memset(visited,0,sizeof(visited));
    f = flow(0,INF);
    if(f==0) return sum;
    sum+= f;
  }
  return sum;
}

int main(){
  cin >> v >> e;
  for(int i=0;i<e;i++) {
    int a,b,c;
    cin >> a >> b >> c;
    V[a].push_back((edge){b,c,(int)V[b].size()}); 
    V[b].push_back((edge){a,0,(int)V[a].size()-1});
  }
  cout << solve()<<endl;
  return 0;
}

Measured memory_bytes: 1264
////////////////////////////////////
//          ,.                    //
//         (_|,.                  //
//        ,' /, )_______   _      //
//     __j o``-'        `.'-)'    //
//    (")                 \'      //
//     `-j                |       //
//        `-._(           /       //
//           |_\  |--^.  /        //
//          /_]'|_| /_)_/         //
//             /_]'  /_]'         //
//                                //
//           PIGMEISTER™          //
//                                //
////////////////////////////////////

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

#define ll long long
#define ull unsigned long long
#define mod (ll)1000000007
#define sidha(i, x, n) for(ll i=(ll)(x);i<(ll)(n);i++)
#define ulta(i, x, n) for(ll i=(ll)(x);i>=(ll)(n);i--)
#define mii map<ll, ll>
#define vi vector<ll>
#define pii pair<ll, ll>
#define pb push_back
#define mp make_pair
#define modInv(x) powah(x, mod-2)
#define test ll t;cin>>t;while(t--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
ll powah(ll, ll);

int main()
{
    jaldi;
    
    ll h, n, a, sum = 0;
    cin >> h >> n;
    sidha (i, 0, n) {
        cin >> a;
        sum += a;
    }
    if (h <= sum) cout << "Yes";
    else cout << "No";
    
    return 0;
}

ll powah(ll x, ll y) { 
    ll res = 1;
    x = x % mod;
    while (y > 0) { 
        if (y & 1) 
            res = (res*x) % mod; 
        y = y>>1;
        x = (x*x) % mod; 
    } 
    return res; 
}

Measured memory_bytes: 256
from collections import deque

def main():
  n = int(input())
  graph=[[] for _ in range(n+1)]
  for i in range(1,n):
    a,b = map(int, input().split())
    d1 = {"id":i,"to":b}
    d2 = {"id":i,"to":a}
    graph[a].append(d1)
    graph[b].append(d2)
  
  k = 0
  root = 1
  for i in range(1, n+1):
    if k < len(graph[i]):
      root = i
      k = max(k, len(graph[i]))
  print(k)
  q=deque([root])
  color=[[] for _ in range(n+1)]
  reached=[False]*(n+1)
  ans=[0]*(n)
  while q:
    current = q.popleft()
    reached[current] = True
    temp = 1
    for dic in graph[current]:
      id = dic["id"]
      next = dic["to"]
      if reached[next]:
        continue
      while temp in color[current]:
        temp += 1
      color[next].append(temp)
      ans[id] = temp
      temp += 1
      q.append(next)
  for i in ans[1:]:
    print(i)
      
if __name__ == '__main__':
  main()

Measured memory_bytes: 89392
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
ans=0

for _ in range(N):
    A=list(map(int,input().split()))
    correctness=C
    for i in range(M):
        correctness+=A[i]*B[i]
    if correctness>0:
        ans+=1
    
print(ans)


Measured memory_bytes: 3060