akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

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

		int N = scan.nextInt();
		int K = scan.nextInt();
		int Q = scan.nextInt();
		
		Integer[] score = new Integer[N];
		
        for(int i = 0; i < N; ++i) {
        	score[i] = K - Q;
        }
		
        for(int j = 0; j < Q; ++j) {
        	
        	int ans = scan.nextInt();
        	
        	score[ans - 1] += 1;
        }
		
        for(int i = 0; i < N; ++i) {
        	if(score[i] > 0) {
        		System.out.println("Yes");
        	} else {
        		System.out.println("No");
        	}
        }
		
		scan.close();
	}

}

Measured memory_bytes: 82824
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;

const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main(){
    long long N; cin >> N;
    long long n = sqrt(N);
    long long ans;
    for(int i=n;i>0;i--){
        
        if(N%i == 0) {ans = i; break;}
    }

    cout << ans + (N/ans) - 2 << endl;
}




Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            //var p = Console.ReadLine().Split().Select(int.Parse).ToArray();
            //var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = int.Parse(Console.ReadLine());
            var v = Console.ReadLine().Split().Select(double.Parse).ToArray();

            Array.Sort(v);

            double ans = v[0];
            for(var i = 1; i < N; i++)
            {
                ans = (ans + v[i]) / 2;
            }

            Console.WriteLine(ans);

            //Console.Out.Flush();

        }
    }

    //010100

    public class Calculation
    {

    }

    public class Graph
    {

    }
}




Measured memory_bytes: 13396
#include<stdio.h>
//小さい順にソート
long long c[100002];
void merge(int i,int j,long long *s){
  if(i!=j){
    merge(i,(i+j)/2,s);
    merge((i+j)/2+1,j,s);
    int a=i,b=(i+j)/2+1;
    int d;
    for(d=i;d<=j;d++){
      if((i+j)/2<a){
        c[d]=s[b];
        b++;
      }
      else if(j<b){
        c[d]=s[a];
        a++;
      }
      else if(s[a]<s[b]){
        c[d]=s[a];
        a++;
      }
      else{
        c[d]=s[b];
        b++;
      }
    }
    for(d=i;d<=j;d++)
      s[d]=c[d];
  }
}

int main(){
  int n,i;
  long long num=1;
  scanf("%d",&n);
  long long a[n+1];
  for(i=0;i<n;i++)
    scanf("%lld",&a[i]);
  merge(0,n-1,a);
  if(a[0]==0){
    puts("0");
    return 0;
  }
  for(i=0;i<n;i++){
    if(1000000000000000000/num<a[i]){
      printf("-1\n");
      return 0;
    }
    num*=a[i];
  }
  printf("%lld\n",num);
  return 0;
}


Measured memory_bytes: 3232
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <utility>
using namespace std;
using ll = long long int;

int main() {
    int n,a,b;
    cin >> n >> a >> b;
    int x=0,y=0,z=0;
    
    for(int i=0;i<n;i++){
        int s;cin >> s;
        if(s<=a){
            x++;
        }else if(s>b){
            z++;
        }else{
            y++;
        }
    }
    
    cout << min(x,min(y,z));
    return 0;
}

Measured memory_bytes: 256
n = int(input())
sp = []
for _ in range(n):
  s, i = input().split()
  sp.append([s, int(i)])
ans = sorted(range(1, n+1), key=lambda x: sp[x-1][1], reverse=True)
ans.sort(key=lambda x: sp[x-1][0])
print(*ans, sep='\n')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const int N = 200005 ;
ll n , ans , l ,  a[N] , sum[N] , Xor[N] ;
int main ( ) {
    scanf ( "%lld",&n ) ;
    for ( int i=0;i<=n;++i ) {
        scanf ( "%lld",&a[i] ) ;
        if ( i==0 ) sum[i] = a[i] , Xor[i] = a[i] ;
        else sum[i] = sum[i-1] + a[i] , Xor[i] = Xor[i-1] ^ a[i] ;
    }
    for ( int r=0;r<n;++r ) {
        while ( (sum[r]-sum[l-1])!=(Xor[r]^Xor[l-1]) ) l++ ;
        ans += r - l + 1 ;
    }
    printf ( "%lld\n",ans ) ;
    return 0 ;
}
/*
A xor B <= sum
*/

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

int main(void) {

  int n;

  char img[1000][1000];

  char buf[1100];

  int max,length;
  int flag;

  int i,j,k,l,x;


  while(1) {

    scanf("%d",&n);

    if(n==0) break;

    getchar();

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

      fgets(buf,sizeof(buf),stdin);

      buf[strlen(buf)-1]='\0';

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

	img[i][j]=buf[j];

      }

    }

    max=0;

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

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

	length=0;

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

	  flag=1;

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

	    for(l=0;l<=x;l++) {

	      if(i+k>=n || j+l>=n) goto Compare;

	      if(img[i+k][j+l]=='*') {

		flag=0;
		goto Compare;

	      }

	    }

	  }

	  length++;
	  //printf("%d ",length);

	}

      Compare:

	if(max<length) max=length;

      }

    }


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

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

	printf("%c",img[i][j]);

      }

      puts("");

      }*/

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

  }

  return 0;

}

Measured memory_bytes: 1536
from collections import deque

def Graph(ab):
    G = [[] for i in range(n)]
    for a,b in ab:
        G[a-1].append(b)
        G[b-1].append(a)
    return G

def dfs(G, a, b):
    #(a, b)は除外する辺
    q = deque()
    q.append((1,-1))
    log = [0] * n
    log[0] = 1
    while q:
        V, P = q.pop()
        for new_v in G[V-1]:
            if {a, b} == {new_v, V}:#除外する辺であれば
                continue
            if new_v == P:#戻らない
                continue
            if log[new_v - 1]:#過去に行った頃がある点に行かない。
                continue
            log[new_v - 1] = 1
            q.append((new_v,V))
    return sum(log) != n

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(m)]
G = Graph(ab)

ans = 0
for a, b in ab:
    if dfs(G, a, b):
        ans += 1
print(ans)

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

int num[4];
int main(){
	string s;
	while(cin >> s){
		if(cin.eof()) break;
		string in=s.substr(s.size()-2,2);
		if(in==",A")
			num[0]++;
		else if(in==",B")
			num[1]++;
		else if(in=="AB")
			num[2]++;
		else
			num[3]++;
	}
	rep(i,4) cout << num[i] << endl;
	return 0;
}

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

typedef long long ll;
const ll mod = 1e9 + 7;
const ll inf = 184467440737095516;

ll n, w, sumval;

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

	cin >> n >> w;
	vector<ll> weight(n), value(n);
	for (ll i = 0; i < n; i++){
		cin >> weight[i] >> value[i];
		sumval += value[i];
	}
	vector<ll> dp(sumval + 1, inf);
	dp[0] = 0;
	for (ll j = 0; j < n; j++){
		for (ll i = sumval; i >= 0; i--){
			if (value[j] <= i){
				dp[i] = min(dp[i], dp[i - value[j]] + weight[j]);
				// cout << dp[i] << " " << j << " " << i << '\n';
			} 
		}
	}
	ll val;
	for (ll i = 0; i <= sumval; i++){
		if (dp[i] <= w){
			val = i;
		}
	}
	cout << val << '\n';	
}
  

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

int main(void)
{
	char b; 
	scanf("%c",&b);
	if(b == 'A')printf("T\n");
	else if(b == 'T')printf("A\n");
	else if(b == 'C')printf("G\n");
	else printf("C\n");
	return 0;
}

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


 const int MAX = 1001;
const int MOD = 1000000007;



signed main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    int ans=1,cou=0,t=0;
    sort(a,a+n);
    for(int i=1;i<n;i++){
        if(a[i-1]==a[i])cou++;
        else{
            ans++;
            if(cou%2==1)t++;
            cou=0;
        }
    }
    if(cou%2==1)t++;
    if(t%2==1)cout<<ans-1;
    else cout<<ans;
    

   return 0;
}

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc=new Scanner(System.in);

		int n=sc.nextInt();
	    int a=n/100;	//100の位
		int b=(n/10)%10;	//10の位
		int c=n%10;			//1の位
		
		if(a==7||b==7||c==7) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		sc.close();
	}

}


Measured memory_bytes: 27068
n=map(int , input())
arr=list(map(int , input().split()))
p=1000000000000000000
f=0
res=1
arr.sort()
for i in arr:
	res=res*i
	if res==0:
		break
	if res>p:
		f=1
		break
if res==0:
	print(res)
elif f:
	print(-1)
else:
	print(res)	

Measured memory_bytes: 84668
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long x = sc.nextLong();
        long a[] = new long[N];
        for(int i=0;i<N;i++){
            a[i]=sc.nextLong();
        }
        long ans=0;
        if(a[0]>x){
            ans+=a[0]-x;
            a[0]=x;
        }
        for(int i=0;i<N-1;i++){
            if(a[i]+a[i+1]>x){
                ans+=a[i]+a[i+1]-x;
                a[i+1]=x-a[i];
            }
        }
        System.out.println(ans);
        

    }
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
typedef long long ll;

int main()
{
    ll i,j;
    ll n,m;
    cin >> n >> m;
    vector<pair<ll,ll>> c;
    for(i = 0;i < m;++i){
        ll a,b;
        cin >> a >> b;
        c.emplace_back(a,b);
    }
    sort(all(c));
    vector<pair<ll,ll>> d;
    auto e = c.at(0);
    for(i = 1;i < m;++i){
        if(c.at(i).first == e.first){
            continue;
        }else{
            d.emplace_back(e);
            e = c.at(i);
        }
    }
    d.emplace_back(e);
    vector<pair<ll,ll>> ans;
    ans.emplace_back(d.at(0));
    for(i = 1;i < d.size();++i){
        bool flag = true;
        for(j = 0;j < ans.size();++j){
            auto f = ans.at(j);
            if(d.at(i).first >= f.second){
                continue;
            }else{
                flag = false;
                f.first = max(f.first, d.at(i).first);
                f.second = min(f.second, d.at(i).second);
                ans.at(j) = f;
                break;
            }
        }
        if(flag){
            ans.emplace_back(d.at(i));
        }
    }
    cout << ans.size() << endl;
    return 0;
}

Measured memory_bytes: 4848
S = input()

S = S.split()

S = list(map(int, S))

A = S[0]
B = S[1]
K = S[2]

list = []

if A >= B:
  C = B
else:
  C = A

for i in range(1, C+1, 1):
  if ((A % i)==0) and ((B % i) == 0):
    list.append(i)

print(list[len(list)-K])
  
  
  
  
  

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int main()
{

         ll n;
         cin>>n;
         if(n%1000)
            cout<<1000-n%1000<<endl;
         else
            cout<<"0"<<endl;

}


Measured memory_bytes: 3468
n,m=map(int,input().split())
lr=[[int(i) for i in input().split()] for i in range(m)]
l=lr[0][0]
r=lr[0][1]
ans=0
for i in range(1,m):
    l=max(l,lr[i][0])
    r=min(r,lr[i][1])
ans=r-l+1
if r<l:
    ans=0
print(ans)

Measured memory_bytes: 21156
import sys

a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
for _ in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j] == b:
                a[i][j] = None
for i in range(3):
    if a[i][0] == a[i][1] == a[i][2] == None or a[0][i] == a[1][i] == a[2][i]:
        print("Yes")
        sys.exit(0)
if a[0][0] == a[1][1] == a[2][2] == None or a[2][0] == a[1][1] == a[0][2] == None:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>

#define rep(i, initial_value, max_value) for (uint64_t i{initial_value}; i < max_value; ++i)
#define fore(i, a) for(auto &i:a)
#define each(i, c) \
    for( \
        __typeof((c).begin()) i{(c).begin()}, __typeof((c).end()) end{(c).end()}; \
        i != end; \
        ++i \
    )
#define dbg(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()

using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
using i64 = int64_t; using i32 = int32_t; using u64 = unsigned long long; using u32 = unsigned long;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<class T>bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }

// ===

void _main() {
  u32 n;
  u32 m;

  cin >> n >> m;

  u32 L[m];
  u32 R[m];

  rep(i, 0, m) cin >> L[i] >> R[i];

  sort(L, L + m, greater<u32>());
  sort(R, R + m);

  u32 r = R[0];
  chmin(r, n);

  u32 ans = (r < L[0]) ? 0 : r - L[0] + 1;

  cout << ans << endl;
}

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

using namespace std;

struct BIT {
  vector<vector<int>> data;
  int h, w;
  BIT(int h, int w):data(h+1, vector<int>(w+1)), h(h), w(w){}
  void add(int y, int x, int a) {
    for(int i = y; i <= h; i += i & -i) {
      for(int j = x; j <= w; j += j & -j) {
	data[i][j] += a;
      }
    }
  }
  int sum(int y, int x) {
    int res = 0;
    for(int i = y; i > 0; i -= i & -i) {
      for(int j = x; j > 0; j -= j & -j) {
	res += data[i][j];
      }
    }
    return res;
  }
  int sum(int sy, int sx, int ty, int tx) {
    return sum(ty, tx) - sum(sy-1, tx) - sum(ty, sx-1) + sum(sy-1, sx-1);
  }
};

using Tapris = tuple<int, int, int, int, int, int>;

int H, W, T, Q;

int main() {
  cin >> H >> W >> T >> Q;
  priority_queue<Tapris, vector<Tapris>, greater<Tapris>> que;
  for(int i = 0; i < Q; i++) {
    int t, c, h, w;
    cin >> t >> c >> h >> w;
    if(c == 2) {
      int hh, ww;
      cin >> hh >> ww;
      que.emplace(t, c, h, w, hh, ww);
    } else {
      que.emplace(t, c, h, w, -1, -1);
      if(c == 0) que.emplace(t+T, -1, h, w, -1, -1);
    }
  }
  BIT ing(H, W), ed(H, W);
  while(!que.empty()) {
    Tapris tap = que.top(); que.pop();
    int t, c, sy, sx, ty, tx;
    tie(t, c, sy, sx, ty, tx) = tap;
    if(c == 0) {
      ing.add(sy, sx, 1);
    } else if(c == 1) {
      if(ed.sum(sy, sx, sy, sx)) ed.add(sy, sx, -1);
    } else if(c == 2) {
      cout << ed.sum(sy, sx, ty, tx) << " " << ing.sum(sy, sx, ty, tx) << endl;
    } else if(c == -1) {
      ing.add(sy, sx, -1);
      ed.add(sy, sx, 1);
    }
  }

  return 0;
}

Measured memory_bytes: 38812
import java.util.Scanner;

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

        for (int i = 0; i <= 25; i++) {
            for (int j = 0; j <= 14; j++) {
                if (i * 4 + j * 7 == n) {
                    System.out.println("Yes");
                    return;
                }
            }
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 21844
H, N = map(int, input().split())
A_list = list(map(int, input().split()))
sorted_A_list = sorted(A_list, reverse=True)
m_H = H
for A in sorted_A_list:
    m_H -= A
    if m_H <= 0:
        print("Yes")
        exit()
else:
    print("No")

Measured memory_bytes: 13964
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

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

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    int ac = 0, wa = 0;
    vector<bool> a(n, false);
    vector<int> w(n, 0);
    rep(i, m) {
        int p; string s;
        cin >> p >> s;
        p--;
        if(a[p]) continue;
        else {
            if(s == "AC") ac++, wa += w[p], a[p] = true;
            else {
                w[p]++;
            }
        }
    }
    cout << ac << " " << wa << endl;
}

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

void Main() {
  int K, A, B;
  cin >> K >> A >> B;
  if (B / K > A / K || (B % K) == 0 || (A % K) == 0) cout << "OK" << endl;
  else cout << "NG" << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 3616
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int,int>;
using PLL = pair<LL, LL>;
const int INF = 1e9;
const int MXN = 0;
const int MXV = 0;
#define MP  make_pair
#define PB push_back
#define F first
#define S second
#define FOR(i, L, R) for(int i = L; i != (int)R; ++i)
#define FORD(i, L, R) for(int i = L; i != (int)R; --i)
#define IOS cin.tie(nullptr); cout.tie(nullptr); ios_base::sync_with_stdio(false);

int main()
{
    IOS;
    int n, m;
    cin >> n >> m;
    for(int i = 0, x; i < m; ++i)
    {
        cin >> x;
        n -= x;
    }
    cout << ((n <= 0) ? "Yes\n" : "No\n");
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	xs := scanIntSlice(n)

	acc := 0
	for _, x := range xs {
		acc += x
	}
	avg := acc / n

	sumA := 0
	sumB := 0
	for _, x := range xs {
		sumA += (x - avg) * (x - avg)
		sumB += (x - avg - 1) * (x - avg - 1)
	}
	if sumA < sumB {
		fmt.Printf("%d", sumA)
	} else {
		fmt.Printf("%d", sumB)
	}
}

func scanIntSlice(size int) []int {
	input := []int{}
	for i := 0; i < size; i++ {
		var in int
		fmt.Scanf("%d", &in)
		input = append(input, in)
	}
	return input
}


Measured memory_bytes: 512
#include <iostream>
#include<string>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c[10000],ans,min;
    cin>>a>>b;
    for(int i=0;i<a;i++){
        cin>>c[i];
        b=b-c[i];
        ans++;
        if(c[i]<min){
            min=c[i];
        }
    }
    ans=ans+b/min;
    cout<<ans<<endl;
    
    
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    int n, m, start;
    ArrayList<ArrayList<Edge>> es;

    public static void main(String[] args) {
        Main prob = new Main();
        prob.read();
        prob.solve();
    }

    void read() {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        start = sc.nextInt();
        es = new ArrayList<ArrayList<Edge>>(n);
        for (int i = 0; i < n; i++) {
            es.add(new ArrayList<Edge>());
        }
        for (int i = 0; i < m; i++) {
            int f = sc.nextInt();
            int t = sc.nextInt();
            int c = sc.nextInt();
            es.get(f).add(new Edge(t, c));
        }
    }

    void solve() {
        boolean[] used = new boolean[n];
        int[] dist = new int[n];
        Arrays.fill(dist, Integer.MAX_VALUE);
        int count = 0;
        dist[start] = 0;
        for (int j = 0; j < n; j++) {
            for (int i = 0 ; i < n; i++) {
                for (Edge e: es.get(i)) {
                    if (dist[i] != Integer.MAX_VALUE
                            && dist[e.to] > dist[i] + e.cost) {
                        dist[e.to] = dist[i] + e.cost;
                        if (j == n - 1) {
                            System.out.println("NEGATIVE CYCLE");
                            return;
                        }
                    }
                }
            }
        }

        for (int d: dist) {
            if (d == Integer.MAX_VALUE)
                System.out.println("INF");
            else
                System.out.println(d);
        }
    }

    private class Edge {
        int to, cost;
        Edge(int t, int c) {
            to = t; cost = c;
        }
    }
}

Measured memory_bytes: 64220
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <queue>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;



int main(){
    queue<string> q;
    vector<string> l = {"1","2","3","4","5","6","7","8","9"};
    for(auto t : l) q.push(t);
    int n;
    cin >> n;
    int count=1;
    bool flag = true;
    string s="0";
    while(true){
        s= q.front();
        int last = s.size()-1;
        if(count==n) break;
        q.pop();
        count++;

        if(flag){
            if(s[last] == '9'){
                s.push_back(s[last]-1);
                q.push(s);
                s.pop_back();
                s.push_back(s[last]);
                q.push(s);
            }else if(s[last] == '0'){
                s.push_back(s[last]);
                q.push(s);
                s.pop_back();
                s.push_back(s[last]+1);
                q.push(s);

                if(s.size() >= 11) flag = false;

            }else{
                for(int i = -1;i<2;i++){
                    s.push_back(s[last]+i);
                    q.push(s);
                    s.pop_back();
                }
            }
        }
    }
    char ch = '9' + n;
    cout << s << endl;
}




Measured memory_bytes: 7400
n = int(input())
s = list(input() for _ in range(n))
d = {}
for i in range(n):
    if s[i] in d:
        d[s[i]] += 1
    else:
        d[s[i]] = 1
m = max(d.values())
for s in sorted(k for k in d if d[k] == m):
    print(s)

Measured memory_bytes: 38420
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;



int main() {
	int n;
	cin >> n;
	vector<int> x(n);
	for (int i = 0; i < n;i++) {
		cin >> x[i];
	}

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

	int ans = BIG_INT;
	for (int p = x[0]; p <= x[n - 1];p++) {
		int sum = 0;
		for (int i = 0; i < n;i++) {
			sum += (x[i] - p)*(x[i] - p);
		}
		ans = min(ans, sum);
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
k = int(input())
ans = 0
now = 7
if k == 1 or k == 7:
    now = 0
while True:
    if ans > k:
        print(-1)
        break
    elif now == 0:
        print(ans+1)
        break
    else:
        now = (now*10 + 7) % k
        ans += 1

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

int main(){
  int l, r;
  cin >> l >> r;
  if(r-l >= 2019){
    cout << 0 << endl;
    return 0;
  }
  l %= 2019;
  r %= 2019;
  if(l==0 || l-r >=0) cout << 0 << endl;
  else{
    vector<int> vec;
    for(int i=l; i<r; ++i){
      for(int j=i+1; j<=r; ++j){
        vec.push_back(i*j%2019);
      }
    }
    sort(vec.begin(),vec.end());
    cout << vec[0] << endl;
  }
}

Measured memory_bytes: 8684
#include<iostream>
#include<cstdio>
#include<ctype.h>
#include<cstdlib>
using namespace std;
inline void Yeah(){puts("Yes");exit(0);}
int main(){ 
    int n,m,k;
    cin>>n>>m>>k;
    for(int i=1;i<=n;++i){
        int kk=(k-i*m),a=n-i-i;
        if(!kk || a && (kk>>31&1)==(a>>31&1) && kk%a==0 && kk/a<=m)Yeah();
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

#include <cstdio>

using namespace std;



typedef long long ll;

ll n, c;

int main()

{

    ll i, t;


    cin >> n;

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

        t = n / i;

        if (t * i == n) t--;

        c += t;

    }

    cout << c << endl;

    return 0;

}


Measured memory_bytes: 3632
import numpy as np

N = int(input())

ans = 0
for i in range(1, int(np.sqrt(N)) + 1):
    if N % i != 0:
        continue
    m = N//i - 1
    if m <= i:
        continue
    if N % m == 0:
        continue
    ans += m
print(ans)

Measured memory_bytes: 12420
/*
                    Author: Ankit Kaul
    **********************Code Belongs to Respective Author Only************************************
    */
    /*#pragma GCC optimize("O3")
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
    #include <bits/stdc++.h>
    #define endl       '\n'
    #define PI          3.141592653589
    #define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    #define M           1000000007
    #define int         long long int
    #define inf         INT_MAX
    #define pb          emplace_back
    #define pf          emplace_front
    #define pii         pair<int,int>
    #define vi          vector<int>
    #define vii         vector<pii>
    #define mi          map<int,int>
    #define mii         map<pii,int>
    #define all(a)      (a).begin(),(a).end()
    #define rall(a)     (a).rbegin(),(a).rend()
    using namespace std;
    int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
    int power(int x,int n){
        int result=1;
        while(n>0)
        {   if(n % 2 ==1)
            result=(result * x) % M;
            x=(x*x)% M;
            n=n/2;
        }
    return result % M;
    }      
    bool isPrime(int n) 
    { 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
    } 
    signed main()
    {   jaldi
        int n;
        cin>>n;
        int a[n],i;
        for(i=0;i<n;i++)
        cin>>a[i]; 
        sort(a,a+n);
        int sum=0,p=1e9;
        for(i=a[0];i<=a[n-1];i++)
        {   for(int j=0;j<n;j++)
            sum=sum+pow(i-a[j],2);   
            p=min(sum,p);
            sum=0;
        }     
        cout<<p;
    }   


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

string s;
string y;

int main(){
	cin >> s;
	y = "";
	for(int i=0;i<s.size();i++){
		if(s[i]=='B'){
			if(y!=""){
				y.pop_back();
			}
		} else {
			y.push_back(s[i]);
		}
	}
	cout << y << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<math.h>
#include<cstring>
using namespace std;
string s[200000];
bool cmp(string a,string b)
{
    return a.compare(b)<0;
}
int main()
{
    int n;
    int i;
    cin>>n;
    for(i=0;i<n;i++)
        cin>>s[i];
    sort(s,s+n,cmp);
    int con=1;
    int y=1;
    for(i=1;i<n;i++)
    {
        if(s[i].compare(s[i-1])==0)
            con++;
        else
            con=1;
        y=max(con,y);
    }
    con=1;
    if(y==1)cout<<s[0]<<endl;
    for(i=1;i<n;i++)
    {
        if(s[i].compare(s[i-1])==0)
            con++;
        else
            con=1;
        if(con==y)
        cout<<s[i]<<endl;
    }
    return 0;
}



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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && a == c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <queue>
#include <math.h>
#include <string>

#define ll long long
#define vll vector<ll>
#define vvll vector<vll>
#define vb vector<bool>
#define vvb vector<vb>
#define vstr vector<string>
#define pll pair<ll, ll>
#define pb pair<bool, bool>
#define vpll vector<pll>
#define vpb vector<pb>
#define ld long double
using namespace std;

int main()
{
	ld a, b;
	cin >> a >> b;
	cout << (ll)(a * b) << endl;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
int a , b , c , tot;
int main(){
	cin >> a >> b >> c;
	if(b >= c){
		cout << b + c << endl;
	}
	else if(a + b >= c){
		cout << b + c << endl;
	}
	else if(a + b < c){
		cout << (2*b) + a + 1 << endl;
	}
}

Measured memory_bytes: 3576
#![allow(unused)]

use std::{cmp, collections, fmt, io, iter, ops, str};
use cmp::Ordering::{Equal, Greater, Less};
use collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
use io::{Read, Write};

#[cfg(feature = "debug")]
macro_rules! debug {
    ($fmt: expr) => { eprintln!($fmt) };
    ($fmt: expr, $($arg: tt)*) => { eprintln!($fmt, $($arg)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! debug {
    ($fmt: expr) => {};
    ($fmt: expr, $($arg: tt)*) => {};
}

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned()
}

fn read_word() -> String {
    const CAPACITY: usize = 16;

    let mut stdin = io::stdin();
    let mut byte: [u8; 1] = [0];

    loop {
        let mut buf = Vec::with_capacity(CAPACITY);

        loop {
            let res = stdin.read(&mut byte);

            if res.unwrap_or(0) == 0 || byte[0] <= b' ' {
                break;
            } else {
                buf.push(byte[0]);
            }
        }

        if buf.len() > 0 {
            return String::from_utf8(buf).unwrap();
        }
    }
}

fn parse_line<T: str::FromStr>() -> T {
    read_line().parse().ok().unwrap()
}

fn parse_word<T: str::FromStr>() -> T {
    read_word().parse().ok().unwrap()
}

fn parse_vec<T: str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn flush() {
    io::stdout().flush();
}

fn main() {
    let n = parse_word::<usize>();
    let mut remain_ingreds = parse_word::<i32>();

    let mut min_ingred = 1000;
    for _ in 0..n {
        let ingred = parse_line::<i32>();
        min_ingred = cmp::min(min_ingred, ingred);
        remain_ingreds -= ingred;
    }

    let donut_cnt = n + (remain_ingreds / min_ingred) as usize;
    println!("{}", donut_cnt);
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        //
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
vector<vector<int> >adjlist;
vector<vector<int> >dp;

/*
4
3 1 4 2
10 20 30 40
*/

vector<int>h;
vector<int>b;
map<int,long long>m;
void solve(){
    int n;cin>>n;
    h.resize(n);
    b.resize(n);
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    for(int i=0;i<n;i++){

        int x = h[i];
        long long val = b[i];
        auto itr = m.upper_bound(x);
        if(itr!=m.begin()){
            itr--;
            val += itr->second;
        }
        m[x] = val;
        itr = m.upper_bound(x);
        while(itr != m.end() && itr->second <=val){
            auto temp = itr;
            temp++;
            m.erase(itr);
            itr = temp;
        }
    }
    auto it = m.end();
    it--;
    long long ans  = it->second;
    cout << ans <<"\n";
}

int main(){
    cin.tie(0);
    cout.tie(0);
    cin.sync_with_stdio(0);
    cout.sync_with_stdio(0);

    cout.precision(10);
    int t=1;//cin>>t;
    while(t--){

        solve();
    }
    return 0;
}


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

using namespace std;

const int mod = 1e9 + 7, P = 1e9 + 7;
int n, a[323456];

long long fact[3123456], tcaf[3123456], ans;
long long deg(long long x, long long d) {
    d %= P - 1;
    if (d < 0) d += P - 1;
    long long y = 1;
    while (d) {
        if (d & 1) y *= x, y %= P;
        x *= x, x %= P;
        d /= 2;
    }
    return y;
}
long long cnk(int a, int b) {
    return fact[a] * tcaf[b] % P * tcaf[a - b] % P;
}
 
int main() {

	fact[0] = tcaf[0] = 1;
	for(int i = 1; i <= 2e6; i++) fact[i] = i * fact[i - 1] % P, tcaf[i] = deg(fact[i], -1);
	int x, y;
	cin >> x >> y;

	for(int i = 0; i <= x; i++) {
		int f = i * 2;
		int s = i;
		if(x >= f && y >= s) {
			int col = x - f;
			if(col * 2 == y - s)
				ans += cnk(i + col, i);
				ans %= mod;
		}
	}
	cout << ans;
}


Measured memory_bytes: 35200
#include <iostream>
#include <cstdio>
using namespace std;
#define N 50

const int dx[]={-1,-1,-1,0,0,1,1,1};
const int dy[]={-1,0,1,-1,1,-1,0,1};
int w,h;
int map[N][N];

void rec(int y,int x){
	map[y][x]=0;
	for(int i=0;i<8;i++){
		int nextx = x + dx[i];
		int nexty = y + dy[i];
		if(nextx>=0&&nexty>=0&&nextx<w&&nexty<h){
			if(map[nexty][nextx]==1){
				rec(nexty,nextx);
			}
		}
	}

}
	

int main(){

	while(cin >> w >> h){
		if(w==0&&h==0) break;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				scanf("%d",&map[i][j]);
			}
		}
	
		int count=0;
	
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(map[i][j]==1){
					rec(i,j);
					count++;
				}
			}
		}
		cout<<count<<endl;
	}

	return 0;
}

Measured memory_bytes: 1324
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return [list(map(int, input().split())) for _ in range(n)]

def main():
    n=inp()
    ans=n
    for t in range(min(5,n//46656)+1):
        x1 = n-t*46656
        for s in range(min(5,x1//7776)+1):
            x2=x1-7776*s
            for r in range(min(5,x2//1296)+1):
                x3=x2-1296*r
                for q in range(min(5,x3//216)+1):
                    x4=x3-216*q
                    for p in range(min(5,x4//36)+1):
                        x5=x4-36*p
                        for o in range(min(5,x5//6)+1):
                            x6=x5-6*o
                            n1=x6//59049
                            x6-=59049*n1
                            n2=x6//6561
                            x6-=6561*n2
                            n3=x6//729
                            x6-=729*n3
                            n4=x6//81
                            x6-=81*n4
                            n5=x6//9
                            x6-=9*n5
                            ans=min(ans,o+p+q+r+s+t+n1+n2+n3+n4+n5+x6)
    print(ans)

if __name__ == "__main__":
    main()

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

int main(){
    string S; cin >> S;
    vector<string> koho = {"hi", "hihi", "hihihi", "hihihihi", "hihihihihi"};

    rep(i, 5){
        if(S == koho[i]){
            cout << "Yes" << endl; return 0;
        }
    }

    cout << "No" << endl;
}


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

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

using namespace std;

typedef long long LL;

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

const int MOD = 1000000007;

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

    int N;
    cin >> N;
    for (int n=1; n <= N; ++n) {
        int cnt = 0;
        for (int x=1; x*x + 2*x + 3 <= n; ++x) {
            int x2 = x*x;
            for (int y=1; y*y + (x+1)*y + x2+2 <= n; ++y) {
                int y2 = y*y;
                int xy = x*y;
                for (int z=1; z <= 100; ++z) {
                    int tmp = x2 + y2 + z*z + xy + y*z + z*x;
                    if (tmp == n) {
                        ++ cnt;
                    } else if (n < tmp) {
                        z = 1000;
                    }
                }
            }
        } 
        cout << cnt << '\n';
    }
    cout << endl;

    return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  int ab;
  if (b < 10) ab = 10 * a + b;
  else if (b < 100) ab = 100 * a + b;
  else ab = 1000 * a + b;
  bool is_square = false;
  rep(i, 1000) if (i * i == ab) is_square = true;
  if (is_square) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3568
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

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 * b / gcd(a, b);
}

ll box(double a) //doubleの切り捨て
{
	ll b = a;
	return b;
}

ll fff(double a) //doubleの四捨五入
{
	ll b = a + 0.5;
	return b;
}

ll sum(ll n) { //整数sまでの合計
	if (n == 0) {
		return 0;
	}

	int s = sum(n - 1);
	return s + n;
}

bool prime(ll num)//素数判定、primeならtrue,違うならfalse
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}

// ===============================================================

int main() {
	ll a;
	cin >> a;
	vl data(a+10, 1);
	for (int i = 2; i <= a; i++) {
		ll e = i;
		for (int j = 2; j * j <= i; j++) {
			ll count = 0;
			while (e % j == 0) {
				e /= j;
				count++;
			}
			data[j] += count;
		}
		if (e != 1) {
			data[e]++;
		}
	}
	ll ans = 1;
	for (int i = 1; i < a+5; i++) {
		ans *= data[i];
		ans %= 1000000007;
	}
	cout << ans << endl;
}

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

static const int N = 100;
static const int INFTY = (1 << 21);
static const int white = 0;
static const int gray = 1;
static const int black = 2;

int h, w;
int sy, sx, gy, gx;
int M[N][N];
int d[N][N];
int color[N][N];

void bfs(int sy, int sx){
    queue<pair<int, int> > Q;
    color[sy][sx] = gray;
    d[sy][sx] = 0;
    Q.push(make_pair(sy, sx));//全てはスタート地点をqueueに突っ込んでからは閉まる
    while(!Q.empty()){
        pair<int,int> u = Q.front();Q.pop();
        color[u.first][u.second] = black;//動いたら黒に
        if(u.first + 1 < h){//配列の参照範囲内であることを確認したら
            if(color[u.first + 1][u.second] == white){//まだ踏んでいないor可動範囲であることを確認して
                Q.push(make_pair(u.first+1,u.second));//queueに突っ込む
                color[u.first + 1][u.second] = gray;//突っ込んだらgray色にすることを忘れない
                d[u.first + 1][u.second] = d[u.first][u.second] + 1;//距離は元の場所から1足す
            }
        }//以下同様,今回は2次元迷路なので4方向確認している。
        if(u.first - 1 >= 0){
            if(color[u.first - 1][u.second] == white){
                Q.push(make_pair(u.first-1,u.second));
                color[u.first - 1][u.second] = gray;
                d[u.first - 1][u.second] = d[u.first][u.second] + 1;
            }
        }
        if(u.second + 1 < w){
            if(color[u.first][u.second+1] == white){
                Q.push(make_pair(u.first,u.second+1));
                color[u.first][u.second+1] = gray;
                d[u.first][u.second+1] = d[u.first][u.second] + 1;
            }
        }
        if(u.second - 1 >= 0){
            if(color[u.first][u.second-1] == white){
                Q.push(make_pair(u.first,u.second-1));
                color[u.first][u.second-1] = gray;
                d[u.first][u.second-1] = d[u.first][u.second] + 1;
            }
        }
        
    }
}
int main(){
    cin >> h >> w;
    int cnt = 0;
    rep(i, 0, h) rep(j, 0, w){
        char tmp; cin >> tmp;
        if(tmp == '.'){
            color[i][j] = white;
            cnt++;
        }
        else color[i][j] = black;
    }
    rep(i, 0, h) rep(j, 0, w) d[i][j] = INFTY;
    bfs(0,0);
    if(d[h-1][w-1] == INFTY) cout << -1 << endl;
    else{
        cout << cnt - (d[h-1][w-1] + 1) << endl;
    }
}

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


int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if ((C + B - 1) / B <= (A + D - 1) / D) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3588
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
using mpint = mp::cpp_int; // 多倍長整数（任意精度）

/*
 * 定数
 */
const long double PI = (acos(-1));
const long double EPS = 1e-10;
const long long INF = 1e18;

/*
 * データ変換 
 */
/* char -> int */
int ctoi(char c) { return (int)(c - '0'); }

/*
 * 数学的な計算
 */
/* 階乗 */
int factorial(int n){ int ret = 1; for(int i = 1; i < n + 1; ++i) { ret = ret * i; } return ret; }

/* 最大公約数 */
template <typename T>T gcd(T x, T y){ return x % y == 0 ? y : gcd(y, x % y); }

/* 最小公倍数 */
template <typename T>T lcm(T a, T b) { return a * b / gcd(a, b); }

/* n個の整数の最小公倍数 */
template <typename T>T lcm_n(vector<T> &numbers) { T l; l = numbers[0]; for(int i = 1; i < numbers.size(); ++i) { l = lcm(l, numbers[i]); } return l; }

/*
 * DP向け
 */
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; }

/*
 * グラフ
 */
class Graph {
   public:
    vector<vector<int>> G;
    vector<int> Trans;
    vector<int> inDeg;
    int numV;
 
    Graph(int numV) {
        this->numV = numV;
        inDeg.assign(numV, 0);
        Trans.assign(numV, 0);
        G.assign(numV, vector<int>());
    }
 
    int topologicalSort(int v, vector<int> &dp) {
        if (dp[v] != -1) {
            return dp[v];
        }
 
        int res = 0;
 
        for (auto to : G[v]) {
            chmax(res, topologicalSort(to, dp) + 1);
        }
 
        return dp[v] = res;
    }
};

#define layer_name(n) l ## n

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

  // 1こ前の層
  vector<string> l1(1, "a");
  vector<string> m1(1, "a");

  // ここは、"aa", "ab"がくる
  vector<string> l2(1, "a");
  vector<string> m2(1, "a");



  for(int i = 1; i < N; ++i){
    // l1にl2を格納する
    l1.resize(l2.size());
    m1.resize(m2.size());

    for(int l_index = 0; l_index < l2.size(); ++l_index){
      l1[l_index] = l2[l_index];
      m1[l_index] = m2[l_index];
    }
    l2.resize(0);
    m2.resize(0);
    // 新しいレイヤーの数を計算する
    // 前の層を全部見る
    for(int l1_index = 0; l1_index < l1.size(); ++l1_index){
      // 前の層のある値の最大文字からその層に伸びる数を計算する
      int d = m1[l1_index][0] - 'a';

      for(int j = 0; j < d+2; ++j){
        char tmp = 'a' + j;
        string c{tmp};
        l2.push_back(l1[l1_index] + c);

        if(m1[l1_index][0] < c[0]){
          m2.push_back(c);
        }else{
          m2.push_back(m1[l1_index]);
        }
      }
    }
  }

  for(auto v : l2){
    cout << v << endl;
  }


  return 0;
}


Measured memory_bytes: 16872
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n, i, c = 0;
	string a, b;
	cin >> a;
	cin >> n;
	for (i = 0; i < n; i++){
		cin >> b;
		b += b;
		if (b.find(a) != string::npos){
			c++;
		}
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 1212
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
 
int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> input(n,0);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> input.at(i);
  }
  
  int max = 0;
  for (int i = 0; i < n; i++) {
    if(i < m){
      sum += input[i];
    }else{
      sum = sum - input[i-m] + input[i];
    }
    if(sum > max) max = sum;
  }
  
  cout << (max + m)/2;
  
  if((max + m)%2 == 0)
    cout << ".0" << endl;
  else
    cout << ".5" << endl;
  
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
   int a,b,c;
cin>>a>>b>>c;
if (a<=b &&b<=c)
  cout<<a<<" "<<b<<" "<<c<<endl;
  else if (a<=c  && c<=b )
  cout <<  a  <<  " "  <<  c  <<  " "  <<    b    <<endl;
  else if(c<=a && a<=b)
  cout <<  c <<  " "  <<  a <<  " "  <<    b    <<endl;
  else if (c<=b && b<= a)
  cout <<  c <<  " "  <<  b <<  " "  <<    a <<endl;
  else if (b<=a  && a<=c )
  cout <<  b <<  " "  <<  a<<  " "  <<    c   <<endl;
  else if (b<=c  && c<= a )
  cout <<  b <<  " "  <<  c  <<  " "  <<    a <<endl;
}



Measured memory_bytes: 3104
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,a,b,i,c=0,x=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&a,&b);
		if(a==b){
			c++;
			if(x<c) x=c;
		}
		if(a!=b) c=0;
	}
	if(x>=3) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 1616
import itertools
n = int(input())
#x, y = [], []
xy = []

for i in range(n):
    # v1, v2 = map(int, input().split())
    # x.append(v1)
    # y.append(v2)
    xy.append(list(map(int, input().split())))

perm = list(itertools.permutations(xy))
cnt = len(perm)

# print(len(perm))
# print(perm)
ans = 0
dis = 0

for i in range(cnt):
    for j in range(1, n):
        prevX = perm[i][j-1][0]
        prevY = perm[i][j-1][1]
        x = perm[i][j][0]
        y = perm[i][j][1]
        dis += ((prevX-x)**2 + (prevY-y)**2)**0.5

print(dis/len(perm))


Measured memory_bytes: 47980