akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	ll x, n;cin >> x >> n;
	vector<ll> v(n);REP(i, n)cin >> v[i];

	ll ans;
	ll mi = INF;
	REP(i, 1000){
		bool flag = true;
		REP(j, n)if(i == v[j])flag = false;
		if(!flag)continue;
		if(abs(x - i) < mi){
			mi = abs(x - i);
			ans = i;
		}
	}

	cout << ans << endl;

	return 0;
}


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

#define endl "\n"
#define ll long long
#define ar array

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

	int t=1;
	//cin >> t;
	while(t--) {
		int a, b;
		cin >> a >> b;
		for(int i=1; i<1e4; ++i) {
			int a2=(i*8)/100, b2=(i*10)/100;
			if(a2==a&&b2==b) {
				cout << i;
				return 0;
			}
		}
		cout << -1;
	}

	return 0 ;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
using ll = int_fast64_t;
using ull = uint_fast64_t;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vull = vector<ull>;
#define rep(i, n) for (ull i = 0; i < n; ++i)
#define rep1(i, n) for (ull i = 1; i < n; ++i)
#define iter(it, v) for (auto it = v.begin(); it != v.end(); ++it)
#define pb push_back
#define fi first
#define se second
#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }
template <typename T> void vecout(const T &v) {
  for (auto it = v.begin(); it != v.end();
       ++it, cout << (it != v.end() ? " " : "\n")) {
    cout << *it;
  }
}

vull factorization(ull n){
  vull v;
  ull MAX=sqrt(n)+1;
  for(ull i=2;i<MAX;++i) while(n%i==0) {
      v.pb(i);
      n/=i;
  }
  if(n!=1) v.pb(n);
  return v;
}

void solve() {
  // main coding
  ull a,b; cin>>a>>b;
  ull g=gcd(a,b);
  vull v=factorization(g);
  v.erase(unique(v.begin(),v.end()),v.end());
  cout<<v.size()+1<<endl;
}

int main() {
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


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

typedef long long int64;
#define REP(i,n) for(int64 i=0;i<(int64)(n);i++)
#define REPD(i,n) for(int64 i=(int64)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int64 i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((int64)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define GSORT(x) sort(ALL(x), greater<int64>());
#define SUM(x) accumulate(ALL(A), 0);
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; }

using namespace std;

void Main()
{
	int64 N;
	cin>>N;
	int64 result=0;
	for(int64 i=1;i<=N;i++){
		if(i%3==0||i%5==0)
			result+=0;
		else{
			result+=i;
		}

	}
	cout<<result<<endl;

	return;
}

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


Measured memory_bytes: 3660
#include <iostream>
using namespace std;
char f[12][7];

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

void remove(int x, int y, char a){
  if( x<0 || x>=12 ) return;
  if( y<0 || y>=6 ) return;
  if( f[x][y] != a ) return;

  f[x][y] = '.';
  for( int d=0;d<4;d++ ){
    int nx = x+dx[d];
    int ny=y+dy[d];
    if( f[nx][ny] == 'O' ){
      f[nx][ny] = '.';
    }else
      remove(x+dx[d], y+dy[d], a);
  }
}

int count(int x, int y, char a){
  if( x<0 || x>=12 ) return 0;
  if( y<0 || y>=6 ) return 0;
  if( f[x][y] != a ) return 0;

  f[x][y] = 'C';
  int rtn=1;
  for( int d=0;d<4;d++ )
    rtn += count(x+dx[d], y+dy[d], a);

  f[x][y] = a;
  return rtn;
}


bool is_remove(){
  bool rtn = false;
  for( int i=0;i<12;i++ ){
    for( int j=0;j<6;j++ ){
      if( f[i][j] != '.' && f[i][j] != 'O' ){
	int c = count(i, j, f[i][j] );
	if( c >= 4 ){
	  rtn = true;
	  remove(i, j, f[i][j]);
	}
      }
    }
  }
  if( rtn ){
    // ティツ青ステ、ツクツ凝・ツ?ヲテァツ青?
    for( int j=0;j<6;j++ ){
      for( int i=12;i>=0;i-- ){
	if( f[i][j] == '.' ){
	  for( int k=i-1;k>=0;k-- ){
	    if( f[k][j] != '.' ){
	      f[i][j] = f[k][j];
	      f[k][j] = '.';
	      break;
	    }
	  }
	}
      }
    }
  }

  return rtn;
}

void pr(){
  for( int i=0;i<12;i++ )
    cout << f[i] << endl;
}

int main(){
  int datasetn;

  cin >> datasetn;
  while( datasetn-- ){
    for( int i=0;i<12;i++ ){
      cin >> f[i];
      //      cout << f[i] << endl;
    }


    int ans=0;
    //    pr();//
    while( is_remove() ){
      ans++;
      //      pr();//
    }
    cout << ans << endl;

    //    break;
  }
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int N, K; cin >> N >> K;
    if (0 <= K && K <= (N-1)*(N-2)/2) {
        vector<pair<int, int>> ans;
        for (int i = 1; i <= N; i++) {
            for (int j = i+1; j <= N; j++) {
                ans.emplace_back(i, j);
            }
        }
        while (K) ans.pop_back(), K--;
        cout << ans.size() << '\n';
        for (auto p : ans) cout << p.first << ' ' << p.second << '\n';
    } else {
        cout << -1 << '\n';
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<long long int> vint;
typedef vector<vector<long long int>> vvint;
typedef vector<string> vstr;
typedef long long int llint;

llint gcd(llint x, llint y) {
	while (y != 0) {
		if (x > y) {
			llint r = x % y;
			x = y;
			y = r;
		}
		else {
			llint r = y % x;
			y = r;
		}
	}
	return x;
}

int main(void) {
	int a, b, N, ans = 0;
	cin >> a >> b >> N;
	vector<pair<int, int>> time(N);
	for (int i = 0; i < N; i++)cin >> time[i].first >> time[i].second;
	for (int i = 0; i < N; i++) {
		if (time[i].first >= b || time[i].second <= a);
		else ans = 1;
		
	}
	cout << ans << endl;
}



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


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

    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    double ans = v[0];
    for(int i= 1; i < n; ++i) ans = (ans+v[i])/2;
    printf("%.10f\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 #include <math.h>
 #include <string>
 using namespace std;
 
 int main(){
    int tmp,i;
    int a[1000000];
    int ans = 1;
    cin >> tmp;

    for (i=0; i<1000000; i++) a[i]=0;
    a[tmp]++;

    while(1){
        if(tmp%2==0)
            tmp = tmp/2;
        else
            tmp = tmp*3+1;

        a[tmp]++;
        ans++;
        if (a[tmp]>1)
            break;
    }

    cout << ans << endl;

    return 0;
 }
 


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

int main(void) {
    int n, d, lo, hi;
    long sum = 0;
    lo = 987654321;
    hi = -987654321;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> d;
        sum += d;
        lo = min(lo, d);
        hi = max(hi, d);
    }
    cout << lo << ' ' << hi << ' ' << sum << endl;
    return 0;
}

Measured memory_bytes: 1160
N = int(input())
A = sorted(list(map(int, input().split())))
ai = max(A)
ai_idx = A.index(ai)
half_maxA = ai // 2 if ai % 2 == 0 else ai // 2 + 1
for idx, a in enumerate(A):
    if ai_idx == idx:
        continue
    if idx == 0:
        aj = a
    else:
        if abs(a - half_maxA) < abs(aj - half_maxA):
            aj = a
print(ai, aj)


Measured memory_bytes: 62704
N,M=map(int,input().split())
H=list(map(int,input().split()))
T=[0]*N
ans=0
li=[list(map(int,input().split())) for _ in range(M)]
for l in li:
  if H[l[0]-1]>H[l[1]-1]:
    T[l[0]-1]+=1
    T[l[1]-1]-=10**5
  if H[l[0]-1]<H[l[1]-1]:
    T[l[0]-1]-=10**5
    T[l[1]-1]+=1
  if H[l[0]-1]==H[l[1]-1]:
    T[l[0]-1]=T[l[1]-1]=-(10**5)
for t in T:
  if t>=0:
    ans+=1
print(ans)

Measured memory_bytes: 33852
import java.util.Scanner;

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


Measured memory_bytes: 26284
#include<bits/stdc++.h>
using namespace std;
#define rep(_,a,b) for(int _=a;_<b;_++)
#define per(_,a,b) for(int _=b-1;_>=a;_--)
#define pii pair<ll,ll>
#define fi first
#define se second
#define pb push_back
typedef long long ll;

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


Measured memory_bytes: 3644
unittest
{
	assert( [ "3", "1", "2 1", "1", "1 1", "1", "2 0" ].parse.expand.solve == 2 );
	assert( [ "3", "2", "2 1", "3 0", "2", "3 1", "1 0", "2", "1 1", "2 0" ].parse.expand.solve == 0 );
	assert( [ "2", "1", "2 0", "1", "1 0" ].parse.expand.solve == 1 );
}



import core.bitop;
import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto xyss = new long[ 2 ][][ n ];
	foreach( ref xys; xyss )
	{
		input.popFront;
		auto a = input.front.to!( long );
		xys.length = a;
		foreach( ref xy; xys )
		{
			input.popFront;
			xy = input.front.split.to!( long[] );
			xy[ 0 ]--;
		}
	}
	return tuple( xyss );
}

auto solve( long[ 2 ][][] xyss )
{
	// 正直者と不親切な人のパターンを全検索
	auto ans = 0L;
	LOOP: for( auto b = 0L; b < ( 1L << xyss.length ); b++ )
	{
		foreach( i, xys; xyss )
		{
			// 不親切な人と仮定したの証言はスキップ
			if( ( b & ( 1L << i ) ) == 0 ) continue;
			
			// 証言が正しいか判定
			foreach( xy; xys )
			{
				if( xy[ 1 ] == 0 )
				{
					if( ( b & ( 1L << xy[ 0 ] ) ) != 0 ) continue LOOP;
				}
				else
				{
					if( ( b & ( 1L << xy[ 0 ] ) ) == 0 ) continue LOOP;
				}
			}
		}
		
		// 証言が一致したので答えを更新
		ans = max( ans, b._popcnt );
	}
	return ans;
}


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

int main(){
	int n;
	string s;
	cin >> s >> n;
	for(int i=0;i<s.size();i++){
		if(s[i]=='a') continue;
		if('z'-s[i]<n){
			n-=int('z'-s[i]+1);
			s[i]='a';
		}
	}
	s[s.size()-1]=(((s[s.size()-1]-'a')+n)%26)+'a';
	cout << s << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int mod =1000000007;
int dp[1005][1005];
char a[1005][1005];
int main()
{
    int n,m,i,x,y;
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++)
    scanf("%s",&a[i]);
    dp[1][1] = 1;
    for(i=2;i<=m;i++)
    if(a[1][i-1]=='#')break;
    else dp[1][i] = 1;
    for(i=2;i<=n;i++)
    if(a[i][0]=='#')break;
    else dp[i][1] = 1;
    
    int j;
    for(i=2;i<=n;i++)
    {
        for(j=2;j<=m;j++)
        {
            if(a[i][j-1]=='.')
            {
                dp[i][j] = dp[i][j-1] +  dp[i-1][j];
                if(dp[i][j]>=mod)dp[i][j]-=mod;
            }
        }
    }
    printf("%d\n",dp[n][m]);
}


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

int main()
{
        int N;
        cin >> N;
        string tmp_S;
        map<string, int> S;

        for(int i = 0; i < N; i++)
        {
                cin >> tmp_S;
                S[tmp_S] = 1;
        }

        cout << S.size() << endl;
        return 0;
}


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

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            //

            var N = GetInt();
            var V = GetIntArray();
            var C = GetIntArray();
            var ans = 0;
            for(int i = 0; i < N; i++)
            {
                ans += Math.Max(V[i] - C[i], 0);
            }

            Console.WriteLine(ans);

            //
            Console.Out.Flush();
            Console.ReadKey();
        }

        static void Solve()
        {

        }


        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Split(' ').Select(char.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c, out V d)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<V>(ar[3]);
        }
    }
}

Measured memory_bytes: 13396
//C
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <cstdlib>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <random>
#include <time.h>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while(true)
int main(){
    
    int N,K;
    cin >> N >> K;

    long long ans = 0;
    
    if(K % 2 == 0){
        long long tmp = N / K;
        ans = tmp * tmp * tmp;
        if(tmp * K + (K / 2) <= N) tmp++;
        ans += tmp * tmp * tmp;
    }
    else{
        long long tmp = N / K;
        ans = tmp * tmp * tmp;
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;
using ll = long long ;
const int INF = 1001001001;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int gcd(int x,int y){
    return x%y ?  gcd(y, x % y) : y ;
}

int lcm(int x, int y) {
    return x / gcd(x, y) * y;//先に割り算をして掛けられる数を小さくして掛け算を行う
}

int main() {

    int n,k;
    cin >> n >> k  ;
    int x[n];

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

    int ans = abs(x[0]-k);
    for(int i=1;i<n;i++){
        int diff = abs(x[i]-k);
        ans = gcd(ans,diff); 
    }

    cout << ans << endl ;

    return 0 ;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cerr << #x << " = " << x << endl;
int gcd(int a, int b)
{
  if (a % b == 0)
    return b;
  return gcd(b, a % b);
}

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
    cin >> A[i];
  sort(A.begin(), A.end());
  int Max = A.back();
  int G = A[0];
  for (int i = 1; i < N; i++)
    G = gcd(G, A[i]);
  dump(G);
  if (K <= Max && K % G == 0)
    cout << "POSSIBLE" << endl;
  else
    cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>

using namespace std;

int main()
{
    string c1, c2, c;
    cin >> c1 >> c2;
    int a,b;
    cin >> a >> b;
    cin >> c;

    if(c==c1) {
        cout << a-1 << " " << b << endl;
    }
    else {
        cout << a << " " << b-1 << endl;
    }
    return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)

const ull mod = (ull)1e9 + 7;


class Primes {
private:
	vector<int> Prime_Number;
	vector<bool> is_prime_;
public:
	Primes(int N) {
		is_prime_.resize(N + 1, true);
		is_prime_[0] = is_prime_[1] = false;
		for (int i = 0; i < N + 1; i++) {
			if (is_prime_[i]) {
				Prime_Number.push_back(i);
				for (int j = 2 * i; j <= N; j += i) is_prime_[j] = false;
			}
		}
	}
	int operator[](int i) { return Prime_Number[i]; }
	int size() { return Prime_Number.size(); }
	int back() { return Prime_Number.back(); }
	bool isPrime(int q) { return is_prime_[q]; }
};

class Divisor {
private:
	vector<pair<ll, ll>> pfactorize;
public:
	vector<ll> F;

	Divisor(ll N) {
		for (ll i = 1; i * i <= N; i++) {
			if (N % i == 0) {
				F.push_back(i);
				if (i * i != N) F.push_back(N / i);
			}
		}
		sort(begin(F), end(F));
		Primes p((ll)sqrt(N) + 1);
		for (int i = 0; i < p.size(); i++) {
			pfactorize.emplace_back(p[i], 0);
			while (N % p[i] == 0) {
				N /= p[i];
				pfactorize.back().second++;
			}
			if (pfactorize.back().second == 0) pfactorize.pop_back();
		}
		if (N > 1) pfactorize.emplace_back(N, 1);
	}
	int size() { return F.size(); }
	const vector<pair<ll, ll>>& pfac() { return pfactorize; } const
		ll operator[](int k) { return F[k]; }
};

int main(void)
{
	ll n, m;
	cin >> n >> m;
	Divisor d(m);
	auto p = lower_bound(d.F.begin(), d.F.end(), n);
	cout << m / *p << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int N = sc.nextInt();
		long sum = 0;
		for (int i = 0; i < N; i++) {
			sum += sc.nextInt();
		}
		if (sum >= H) {
			System.out.print("Yes");
		} else {
			System.out.print("No");
		}
	}
}

Measured memory_bytes: 48372
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: u64 = read();
    let a: u64 = read();
    let b: u64 = read();

    println!(
        "{}",
        if a > b || (n == 1 && a != b) {
            0
        } else if n == 1 {
            1
        } else {
            (b - a) * (n - 2) + 1
        }
    );
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	c := 0
	for i := 0; i < n; i++ {
		sc.Scan()
		x, _ := strconv.Atoi(sc.Text())
		if x%2 == 1 {
			c++
		}
	}
	if c%2 == 0 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 2176
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;

int main()
{
    int n;
	int x;
	int ans=0;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> x;
		for(int i=2;i*i<=x;i++){
			if(x%i==0)goto next;
		}
		ans++;
		next:;
	}
	cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1168
string_list = input().split()
num1 = int(string_list[0])
num2 = int(string_list[1])

inequality = ''

if num1 > num2:
    inequality = ' > '
elif num1 < num2:
    inequality = ' < '
else:
    inequality = ' == '

print('a' + inequality + 'b')


Measured memory_bytes: 5592
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define vec vector
#define fi first
#define se second
#define eb emplace_back
#define ef emplace_front
#define pof pop_front()
#define pob pop_back()
#define Rep(i,n) for(li i=0,nn=(li)(n);i!=nn;++i)
#define Rep1(i,n) for(li i=1,nn=(li)(n)+1;i!=nn;++i)
#define Size(v) (li)(v.size())
#define SortA(v) sort(v.begin(),v.end())
#define SortD(v) sort(v.rbegin(),v.rend())
#define All(a) (a).begin(),(a).end()
#define Input(a) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii);}
#define Input2(a,b) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii)>>(b).at(ii);}
#define mp make_pair
#define mt make_tuple
using li = int64_t;
using intl = int64_t;
using vi = vec<li>;
using vb = vec<bool>;
using vvi = vec<vi>;
using qi = deque<li>;
using pi = pair<li,li>;
using vpi = vec<pi>;
using si = set<li>;
using vsi = vec<si>;
using mii = map<li,li>;
using vmii = vec<mii>;
vec<li> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<li> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr li INF = 9223372036854775807;



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

  li N,R;
  cin >>N>>R;

  if(N<10){
  	cout <<R+100*(10-N);
  }
  else{
  	cout <<R;
  }

}

Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>

void swap(int& x, int& y){
	x ^= y;
	y ^= x;
	x ^= y;
}

int main(){
	int n, m;
	std::cin >> n >> m;
	for(;m--;){
		int x, y;
		std::cin >> x >> y;
		x--, y--;//(0,0)を起点とする
		
		//つくった図形は点対称なので反転とかy=xに関して対象移動したりできる
		if(x > n/2){//真ん中より右なら反転する
			x = n-1 - x;
		}
		if(y > n/2){//真ん中より下なら反転する
			y = n-1 - y;
		}
		if(y > x){//y=xより下ならばy=xに関して対称移動する
			swap(x, y);
		}
		x = y;

		printf("%d\n", x%3+1);
	}
}

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

int main(){
    double x1, y1, x2, y2;
    std::cin >> x1 >> y1 >> x2 >> y2;
    printf("%10.8f\n",std::sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
}


Measured memory_bytes: 3288
import * as fs from 'fs';

export class Reader {
    lines: string[];
    currentLine: number;

    constructor() {
        this.lines = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        this.currentLine = 0;
    }

    readLine(): string {
        return this.lines[this.currentLine++];
    }

    readInt(): number {
        return Number(this.readLine());
    }

    readInts(): number[] {
        return this.readLine().split(" ").map(Number);
    }
}

function getTable(H: number, W: number): number[][] {
	let table: number[][] = [];
	for(let i=0; i<H; i++) {
		table.push(new Array(W).fill(null).map(() => 0));
	}
	return table;
}

function solve(): number {
	let reader = new Reader();
	let table: string[][] = [];
	let [H, W] = reader.readInts();
	for(let i=0; i<H; i++) {
		let row = reader.readLine();
		table.push(new Array(W).fill(null).map((value, index) => row.charAt(index)));
	}
	let fromLeft = getTable(H, W);
	let fromTop = getTable(H, W);
	for(let i=0; i<H; i++) {
		for(let j=0; j<W; j++) {
			if (table[i][j] == '.') {
				fromLeft[i][j] = 1;
				fromTop[i][j] = 1;
				if (j > 0)
					fromLeft[i][j] += fromLeft[i][j-1];
				if (i > 0)
					fromTop[i][j] += fromTop[i-1][j];
			}
		}
	}

	let fromRight = getTable(H, W);
	let fromBottom = getTable(H, W);
	for(let i=H-1; i>=0; i--) {
		for(let j=W-1; j>=0; j--) {
			if (table[i][j] == '.') {
				fromRight[i][j] = 1;
				fromBottom[i][j] = 1;
				if (i < H-1)
					fromBottom[i][j] += fromBottom[i+1][j];
				if (j < W-1)
					fromRight[i][j] += fromRight[i][j+1];
			}
		}
	}
	let maximumLight = 0;
	for(let i=0; i<H; i++) {
		for(let j=0; j<W; j++) {
			if (table[i][j] == '.') {
				maximumLight = Math.max(maximumLight, fromLeft[i][j]+fromTop[i][j]+fromRight[i][j]+fromBottom[i][j]-3);
			}
		}
	}
	return maximumLight;
}

console.log(solve());


Measured memory_bytes: 221140
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vectors<decltype(inner)>(x, inner); }
template<class T> void show_with_brank(T a){ int cnt = 0; for(auto itr :a){ if(cnt++ != 0) cout << " "; cout << itr;} }
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
#define int ll
signed main(){
    string s; cin >> s;
    int n; cin >> n;
    vector<string>res;
    map<string,int>mem;
    for(int i = 0;i<s.size();i++){
        string temp;
        for(int l = 0; l+i<s.size();l++){
            temp+=s[i+l];
            if(temp.size()>100)continue;
            if(mem[temp] == 0){
                res.push_back(temp);
                mem[temp]++;
            }
        }
    }
    sort(all(res));
    cout << res[--n] << endl;
}




Measured memory_bytes: 89964
/*選択ソートでは、最前列から決定していく。*/
#include<stdio.h>

signed main(){

int sum=0,b=0,c=0,i=0,m[10000]={},min=0,j=0,n=0,a=0;

scanf("%d %d",&n,&c);



for(i=0;i<n;i++){
    scanf("%d",&m[i]);
}

for(i=0;i<n;i++){
min=i;
    for(j=i+1;j<n;j++){
        if(m[j]<m[min]){
            min=j;
        }
    }
    if(min!=i){
    a=m[i];
    m[i]=m[min];
    m[min]=a;

    }
}

for(i=0;i<c;i++){
    sum+=m[i];
}
printf("%d\n",sum);
return (0);


}

Measured memory_bytes: 1768
#include<cstdio>
#include<cmath>
int main(){
	register int n,a,o=0;
	scanf("%d",&n);
	for(int i=0;i<n;++i){
		scanf("%d",&a);
		if(a%2==0) o++;
	}
	printf("%d",(int)pow(3,n)-(int)pow(2,o));
	return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <string>

#define ll long long
#define repeat(i, x) for(register ll i = 0; i < x; i++)

using namespace std;

int main()
{
  ll ans = 0;

  ll N; cin >> N;

  if(N % 2 == 0) {
    cout << -1 << endl;
    return 0;
  }

  for(register ll i = 1; i <= N; i++) {
    ans = (ans * 10 + 7) % N;

    if(ans == 0) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define MAX 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define zoom ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define precise cout.precision(8); cout << fixed;
#define seed srand(chrono::steady_clock::now().time_since_epoch().count());
const double PI = acos(-1);
using namespace std;

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

ll solve(ll a, ll b, ll c) {
    vector<ll> A{a, b, c};
    sort(A.begin(), A.end());
    return gcd(gcd(a, b), c);
}

int main() {

    zoom;    
    ll K; cin >> K;
    ll ans = 0;
    for(ll i = 1; i <= K; i += 1) {
        for(ll j = 1; j <= K; j += 1) {
            for(ll k = 1; k <= K; k += 1)
                ans += solve(i, j, k);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main()
{
    char s[100000]={};
    int c=0,c1=0,c2=0;
    scanf("%s",s);
    int n=strlen(s);
    for(int i=0;i<n;i++)
    {
        if(s[n-1]=='3')
        {
            c++;
        }

        else if(s[n-1]=='0'||s[n-1]=='1'||s[n-1]=='6'||s[n-1]=='8')
        {
            c1++;
        }

        else if(s[n-1]=='2'||s[n-1]=='4'||s[n-1]=='5'||s[n-1]=='7'||s[n-1]=='9')
        {
            c2++;
        }
    }
    if(c>0)
        cout<<"bon"<<endl;
    if(c1>0)
        cout<<"pon"<<endl;
    if(c2>0)
        cout<<"hon"<<endl;

}

Measured memory_bytes: 3856
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

typedef double Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight < f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;


struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
};


pair<Weight, Edges> minimumSpanningForest(const Graph &g) {
  int n = g.size();
  UnionFind uf(n);
  priority_queue<Edge> Q;
  REP(u, n) FOR(e, g[u]) if (u < e->dst) Q.push(*e);

  Weight total = 0;
  Edges F;
  while (F.size() < n-1 && !Q.empty()) {
    Edge e = Q.top(); Q.pop();
    if (uf.unionSet(e.src, e.dst)) {
      F.push_back(e);
      total += e.weight;
    }
  }
  return pair<Weight, Edges>(total, F);
}

typedef complex<double> P;
P p[10000];

int main() {
  int n,m;
  while(cin>>n>>m) {
    REP(i,n) {
      cin >> p[i].real() >> p[i].imag();
    }
    Graph g(n);
    double ans = 0;
    REP(i,m) {
      int a, b;
      cin >> a >> b;
      a--; b--;
      g[a].push_back(Edge(a,b,abs(p[a]-p[b])));
      //cout << a << " " << b << "!" << abs(p[a]-p[b]) << endl;
      ans += abs(p[a]-p[b]);
      g[b].push_back(Edge(b,a,abs(p[a]-p[b])));
    }
    ans -= minimumSpanningForest(g).first;
    printf("%.8f\n", ans);
  }
}

Measured memory_bytes: 3524
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()

    val ans =
      if (a == b && a != c ||
          a == c && a != b ||
          b == c && a != b) {
        "Yes"
      } else {
        "No"
      }

    println(ans)
  }
}


Measured memory_bytes: 27312
import sys

table = [0] * 26
input_str = sys.stdin.read()
letters ="abcdefghijklmnopqrstuvwxyz"

for A in input_str:
    index = 0
    for B in letters:
        if A == B or A == B.upper():
            table[index] += 1
            break
        index += 1

for i in range(len(letters)):
    print("%s : %d"%(letters[i],table[i]))


Measured memory_bytes: 5564
#include <iostream>
using namespace std;
int main(void){
    string code[] = {
        "", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz",
    };
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string input;
        cin >> input;
        int len = input.length();
        int index = 0, j = 0;
        while (j < len) {
            char c = input[j];
            if (c == '0') {
                ++j;
                continue;
            }
            while (++j < len && c == input[j]) ++index;
            string button = code[c - '0'];
            cout << button[index % button.length()];
            index = 0;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <cstdio>
#include <set>
using namespace std;

int main() {
  int N;
  scanf("%d",&N);
  int x;
  set<int> d;
  while (N--) {
    scanf("%d",&x);
    d.insert(x);
  }
  printf("%d\n",d.size());
  return 0;
}


Measured memory_bytes: 256
function main(input) {
  input=input.trim();
  var n=input.split("")
  var sum  = function(arr) {
    var sum = 0;
    for (var i=0,len=arr.length; i<len; ++i) {
        sum += Number(arr[i]);
    };
    return sum;
  };
  if(Number(input)%sum(n)==0){
    console.log("Yes");
  }else{
    console.log("No");
  }
}



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

Measured memory_bytes: 7372
n = int(input())
cnt = 0
l = []
for i in range(1, n+1):
    if i % 2 == 1:
        for d in range(1, i+1):
            if i % d == 0:
                l.append(d)
                if len(l) == 8:
                    cnt += 1
        l = []
print(cnt)

Measured memory_bytes: 3060
def main():
    H, W = map(int, input().split())
    A = [input() for _ in range(H)]
    cnt = 0
    for i in range(H):
        for j in range(W):
            if A[i][j] == "#":
                cnt += 1
    if cnt == H+W-1:
        print("Possible")
    else:
        print("Impossible")


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
#include <cstdio>
#include <cstring>
#include <algorithm>

const int MAXN = 2e5 + 5;
const int mod = 998244353;

int n, ans;
int pow[MAXN];
int res[MAXN], BIT[MAXN];

struct num {
    int key, place;
    num(int kk = 0, int pp = 0) {
        key = kk;
        place = pp;
    }
    
    bool operator < (const num &another) {
        return key < another.key;
    }
}arr[MAXN];

struct node {
    int x, y;
    node (int xx = 0, int yy = 0) {
        x = xx;
        y = yy;
    }
    
    bool operator < (const node &another) const {
        if (x == another.x)
            return y < another.y;
        else
            return x < another.x;
    }
}point[MAXN];

struct BITree {
    int BIT[MAXN];

    void clear() {
        memset(BIT, 0, sizeof(BIT));
    }

    int lowbit(int key) {
        return key & (-key);
    }

    void modify(int place, int key) {
        for (; place <= n; place += lowbit(place)) {
            BIT[place] += key;
        }
    }

    int query(int place) {
        int tmp = 0;
        for (; place; place -= lowbit(place)) {
            tmp += BIT[place];
        }
        return tmp;
    }
}root;

void discretizate() {
    int counter = 1;
    std::sort(arr + 1, arr + n + 1);
    for (int i = 1; i <= n; ++i) {
        res[arr[i].place] = i;
    }
    for (int i = 1; i <= n; ++i) {
        point[i].y = res[i];
    }
}

int main() {
    pow[0] = 1;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d%d", &point[i].x, &point[i].y);
        arr[i] = num(point[i].y, i);
        pow[i] = (pow[i - 1] << 1) % mod;
    }
    ans = 1ll * n * (pow[n] - 1) % mod;
    for (int i = 1; i <= n; ++i) {
        ans = (ans - (pow[i - 1] - 1) + mod) % mod;
        ans = (ans - (pow[n - i] - 1) + mod) % mod;
        ans = (ans - (pow[i - 1] - 1) + mod) % mod;
        ans = (ans - (pow[n - i] - 1) + mod) % mod;
    }
    discretizate();
    std::sort(point + 1, point + n + 1);
    for (int i = 1; i <= n; ++i) {
        int tmp = root.query(point[i].y);
        ans = (ans + (pow[tmp] - 1)) % mod;
        ans = (ans + (pow[i - 1 - tmp] - 1)) % mod;
        root.modify(point[i].y, 1);
    }
    root.clear();
    for (int i = n; i; --i) {
        int tmp = root.query(n + 1 - point[i].y);
        ans = (ans + (pow[tmp] - 1)) % mod;
        ans = (ans + (pow[n - i - tmp] - 1)) % mod;
        root.modify(n + 1 - point[i].y, 1);
    }
    printf("%d", ans % mod);
    return 0;
}

Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int a,b,c,d,e,f,g,h;
    int arr[3];
    for(int i=0;i<3;i++)cin>>arr[i];
    sort(arr,arr+3);
    if(arr[1]-arr[0]==arr[2]-arr[1])cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 764
read X

if [ $X -le 599 ]
then
  echo 8
elif [ $X -le 799 ]
then
  echo 7
elif [ $X -le 999 ]
then
  echo 6
elif [ $X -le 1199 ]
then
  echo 5
elif [  $X -le 1399 ]
then
  echo 4
elif [ $X -le 1599 ]
then
  echo 3
elif [ $X -le 1799 ]
then
  echo 2
elif [ $X -le 1999 ]
then
  echo 1
fi


Measured memory_bytes: 3812
#include<bits/stdc++.h>
#include<cmath>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) cout << (x) << endl;
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};


const int dx[4] = {1, 0, -1, 0}; // const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[4] = {0, 1, 0, -1}; // const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

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


const int mod = 1e9 + 7;

typedef pair<int, int> P;
 
char maze[20][21]; // 迷路を表す文字列の配列
int h,w;
int sx,sy; // スタートの座標
int gx,gy; // ゴールの座標
 
int d[20][20]; // 各点までの最短距離の配列
 
// (sx,sy)から(gx,gy)への最短距離を求める
// たどり着けないとINF
int bfs(int sx, int sy, int gx, int gy){
  queue<P> que;
  // 全ての点をINFで初期化
  for (int i = 0; i < h; ++i)
    for (int j = 0; j < w; ++j) d[i][j] = INF;
  // スタート地点をキューに入れ、その点の距離を0にする。
  que.push(P(sx,sy));
  d[sx][sy] = 0;
  
  // キューが空になるまでループ
  while(que.size()){
    // キューの先頭を取り出す
    P p = que.front(); que.pop();
    // 取り出してきた状態がゴールなら探索をやめる
    if (p.first == gx && p.second == gy) break;
    // 移動4方向をループ
    for (int i = 0; i < 4; ++i){
      int nx = p.first + dx[i], ny = p.second + dy[i];
      // 移動が可能かの判定とすでに訪れたことがあるかの判定(d[nx][ny] != INFなら訪れたことがある)
      if (0 <= nx && nx < h && 0 <= ny && ny < w && maze[nx][ny] != '#' && d[nx][ny] == INF){
        // 移動できるならキューに入れ、その点の距離をpからの距離+1で確定する
        que.push(P(nx,ny));
        d[nx][ny] = d[p.first][p.second] + 1;
      }
    }
  }

  return d[gx][gy];
}


int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    cin >> h >> w;
    int ans = 0;
    rep(i,h)
      rep(j,w)
      	cin >> maze[i][j];
    rep(sx,h){
      rep(sy,w){
        if(maze[sx][sy] == '#') continue;
        rep(gx,h){
          rep(gy,w){
            if(maze[gx][gy] == '#') continue;
            chmax(ans, bfs(sx,sy,gx,gy));
          }
        }
      }
    }
    print(ans);

}

Measured memory_bytes: 256
from collections import defaultdict
import sys
n = int(input())
v = list(map(int, input().split()))

dd_even = defaultdict(int)
dd_odd  = defaultdict(int)

# 偶数番目のヒストグラムを作る
for i in range(0, n, 2):
    dd_even[v[i]] += 1

l_even = list(dd_even.items())
l_even.sort(key= lambda x:x[1])
top_even = l_even[-1][0]
#print(l_even)

# 奇数番目のヒストグラムを作る
for i in range(1, n, 2):
    dd_odd[v[i]] += 1

l_odd = list(dd_odd.items())
l_odd.sort(key= lambda x:x[1])
#print(l_odd)
top_odd = l_odd[-1][0]

if top_even == top_odd:
    if len(l_odd) == 1: # つまり全部同じ数字のとき
        res = int(n / 2)
        print(res)
        sys.exit()
    else:
        # 2パターン試す
        l_odd_1 = [l for l in l_odd if l[0] != l_odd[-2][0]]
        sum_odd_1 = sum(l[1] for l in l_odd_1)
        l_even_1 = [l for l in l_even if l[0] != top_even]
        sum_even_1 = sum(l[1] for l in l_even_1)
        sum_1 = sum_odd_1 + sum_even_1

        l_odd_2 = [l for l in l_odd if l[0] != top_odd]
        sum_odd_2 = sum(l[1] for l in l_odd_2)
        l_even_2 = [l for l in l_even if l[0] != l_even[-2][0]]
        sum_even_2 = sum(l[1] for l in l_even_2)
        sum_2 = sum_odd_2 + sum_even_2

        if sum_1 < sum_2:
            print(sum_1)
        else:
            print(sum_2)
        sys.exit()
else:
    l_odd = [l for l in l_odd if l[0] != top_odd]

sum_odd = sum(l[1] for l in l_odd)
#print(l_odd, sum_odd)

l_even = [l for l in l_even if l[0] != top_even]
sum_even = sum(l[1] for l in l_even)
#print(l_even, sum_even)

res = sum_odd + sum_even
print(res)


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

    int a,b,c;
    
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    
    if(a>b){
        printf("0");
    }
    else{

   if(a*c<=b){
            printf("%d",c);
        }
   else if(a*c>b){
            printf("%d",b/a);
        }
    }
}


Measured memory_bytes: 128
#include"bits/stdc++.h"
#include<cassert>
#define fr first
#define sc second
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 998244353;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P> PP;
int p[200006];

struct RmQ {
	int n;
	int dat[580000];
	void init(int n_) {
		n = 1;
		while (n < n_)n *= 2;
		rep(i, 2 * n - 1)dat[i] = inf;
	}
	void update(int k, int a) {
		k += n - 1;
		dat[k] = a;
		while (k > 0) {
			k = (k - 1) / 2;
			dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
		}
	}
	int query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l)return inf;
		if (a <= l&&r <= b)return dat[k];
		else {
			int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
			int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
			return min(vl, vr);
		}
	}
	int getmin(int a, int b) {
		return query(a, b, 0, 0, n);
	}
};
struct RMQ {
	int n;
	int dat[580000];
	void init(int n_) {
		n = 1;
		while (n < n_)n *= 2;
		rep(i, 2 * n - 1)dat[i] = -inf;
	}
	void update(int k, int a) {
		k += n - 1;
		dat[k] = a;
		while (k > 0) {
			k = (k - 1) / 2;
			dat[k] = max(dat[k * 2 + 1], dat[k * 2 + 2]);
		}
	}
	int query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l)return -inf;
		if (a <= l&&r <= b)return dat[k];
		else {
			int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
			int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
			return max(vl, vr);
		}
	}
	int getmax(int a, int b) {
		return query(a, b, 0, 0, n);
	}
};
RmQ seg;
RMQ seg2;
int sorted[200005];

int segsort(int a, int b) {//[a,b]
	return sorted[b] - sorted[a];
}

signed main() {
	int n, k; cin >> n >> k;
	rep(i, n)cin >> p[i];
	seg.init(n);
	seg2.init(n);
	rep(i, n) {
		seg.update(i, p[i]);
		seg2.update(i, p[i]);
	}
	rep(i, n - 1) {
		if (p[i] > p[i + 1])sorted[i + 1]++;
	}
	rep(i, n)sorted[i + 1] += sorted[i];

	int ans = n-k+1;
	rep(i, n - k) {
		if (seg.getmin(i, i + k) == p[i] && seg2.getmax(i + 1, i + k + 1) == p[i + k])ans--;
		if (segsort(i, i + k - 1) == 0 && segsort(i + 1, i + k) == 0)ans++;
	}
	int cnt2 = 0;
	rep(i, n - k + 1)if (segsort(i, i + k - 1) == 0)cnt2++;
	if (cnt2)cnt2--;
	ans -= cnt2;
	cout << ans << endl;
}

Measured memory_bytes: 12032
#include <algorithm>
#include <iostream>
#include "vector"
#include "stack"
#include "utility"
#include "bits/stdc++.h"

using namespace std;
//vector<long long> factors;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x0f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

ll mod(ll a, ll m) { return (a + (abs(a) / m) * m + m) % m; }

int main() {
    IOS
    ll n, t;
    cin >> n >> t;
    vector<pll > ab(n);
    for (int i = 0; i < n; ++i) {
        cin >> ab[i].first >> ab[i].second;
    }

    ll bag_size = t - 1;

    vector<vector<ll>> dp(3030, vector<ll>(3030, 0));

    for (ll w = 1; w <= bag_size; ++w) {
        for (ll i = 1; i <= n; ++i) {
            if (w - ab[i - 1].first >= 0)
                dp[i][w] = max(dp[i - 1][w], dp[i - 1][w - ab[i - 1].first] + ab[i - 1].second);
            else
                dp[i][w] = dp[i - 1][w];
        }
    }

    ll w = bag_size;
    ll i = n;
    set<ll> setik;
    while (i > 0 && w > 0) {
        if (dp[i][w] > dp[i - 1][w]) {
            setik.insert(i - 1);
            w = w - ab[i - 1].first;
        }
        --i;
    }
    ll mx = 0;
    for (int j = 0; j < n; ++j) {
        if (setik.count(j) == 0) {
            mx = max(mx, ab[j].second);
        }
    }

    cout << dp[n][bag_size] + mx;


    return 0;
}

Measured memory_bytes: 72320
from fractions import gcd

N, P = map(int, input().split())
S = input().strip()

if gcd(10, P) > 1:
    ans = 0
    for i in range(len(S)):
        s = int(S[i])
        if s % P == 0:
            ans += (i+1)
    print(ans)
else:
    p = [0]*P
    ans = 0
    s = 0
    for i in range(len(S)-1, -1, -1):
        s = (s + int(S[i])*pow(10, N-1-i, P)) % P
        if s == 0:
            p[s] += 1
            ans += p[s]
        else:
            ans += p[s]
            p[s] += 1

    print(ans)


Measured memory_bytes: 67052
n = int(input())

k, *list_b = map(int, input().split())

t = 0

for i in list_b:
    t += 2 ** i


for d in range(2 ** n):
    # all(m)
    if (d & t) != t:
        continue

    d_bin = "{:b}".format(d)

    list_e = []

    for cnt, bit in enumerate(reversed(d_bin)):
        if bit == "1":
            list_e.append(cnt)

    if list_e:
        print(f"{d}: ", end="")
        print(*list_e)
    else:
        print(f"{d}:")



Measured memory_bytes: 6196