akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <limits>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

using ll = long long;

constexpr int MAX_N = 100000, mod = 1000000007;
constexpr ll INF = 1e17;

using P = std::pair<ll, int>;

struct edge
{ ll to, dist; };

int N, M;
int S, T;
std::vector<edge> G[MAX_N];
ll d1[MAX_N], d2[MAX_N];
ll dp1[MAX_N], dp2[MAX_N];
ll ans;

void dijkstra( int s, ll *ds, ll *dp )
{
  std::priority_queue<P, std::vector<P>, std::greater<P>> pque;
  pque.push( P( 0, s ) );
  std::fill( (ll*)ds, (ll*)(ds+N), INF );
  ds[s] = 0;
  dp[s] = 1;

  while( !pque.empty() )
  {
    P p = pque.top(); pque.pop();
    ll dist = p.first, v = p.second;

    if( ds[v] < dist )
      continue;

    for( auto &e : G[v] )
    {
      if( ds[e.to] > ds[v]+e.dist )
      {
        dp[e.to] = dp[v];
        ds[e.to] = ds[v]+e.dist;
        pque.push( P( ds[e.to], e.to ) );
      }
      else if( ds[e.to] == ds[v]+e.dist )
        dp[e.to] = (dp[e.to] + dp[v]) % mod;
    }
  }

  return;
}

int sqr( ll x )
{ return x%mod*x%mod; }

int main()
{
  scanf( "%d%d%d%d", &N, &M, &S, &T );
  --S; --T;
  rep( i, M )
  {
    ll U, V, D;
    scanf( "%lld%lld%lld", &U, &V, &D );
    --U; --V;
    G[U].push_back( (edge){ V, D } );
    G[V].push_back( (edge){ U, D } );
  }

  dijkstra( S, d1, dp1 );
  dijkstra( T, d2, dp2 );

  ans = dp1[T]*dp1[T] % mod;

  rep( i, N ) if( d1[i] == d2[i] && d1[i]+d2[i] == d1[T] )
    ans = (ans - sqr( dp1[i]%mod*dp2[i]%mod ) + mod) % mod;

  rep( i, N ) for( auto &e : G[i] )
  {
    int U = i, V = e.to, D = e.dist;

    //if( 2*d1[U[i]] > d1[T] )
      //std::swap( U[i], V[i] );

    //if( 2*d1[U[i]] < d1[T] && 2*d1[V[i]] > d1[T] && d1[U[i]]+D[i] == d1[V[i]] )
    if( 2*std::max( d1[U], d2[V] ) < d1[T] && d1[U]+D+d2[V] == d1[T] )
      ans = (ans - sqr( dp1[U]%mod*dp2[V]%mod ) + mod) % mod;
  }

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

  return 0;
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  string o, e;
  cin >> o >> e;
  for (int i = 0; i < min(o.size(), e.size()); i++) {
    cout << o[i] << e[i];
  }
  if (o.size() > e.size()) cout << o.back();
  if (e.size() > o.size()) cout << e.back();
  cout << '\n';
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

int p,q,a,n;

int gcd(int x,int y){
    if(y==0) return x;
    return gcd(y,x%y);
}

int dfs(int denom,int numer,int prev,int product,int num){
    {
        int tmp1=denom*prev,tmp2=numer*prev+denom*num;
        if((double)tmp2/tmp1+eps<(double)p/q) return 0;
    }
    if((double)numer/denom-eps>(double)p/q) return 0;

    int res=0;
    if((double)p/q-eps<=(double)numer/denom  and (double)numer/denom<=(double)p/q+eps) ++res;
    if(num==0) return res;

    int x=prev;
    while(true){
        if(product*x>a) break;
        res+=dfs(denom*x,numer*x+denom,x,product*x,num-1);
        ++x;
    }
    return res;
}

void solve(){
    while(cin >> p >> q >> a >> n){
        if(p==0 and q==0 and a==0 and n==0) break;
        cout << dfs(1,0,1,1,n) << endl;
    }
}

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

Measured memory_bytes: 3116
N, M = map(int, input().split())
broken_lst = [1]*(N+1)
for _ in range(M):
    broken_lst[int(input())] = 0

counter_arr = [0]*(N+1)
counter_arr[0] = 1


for i in range(0, N-1):
    counter_arr[i+1] += counter_arr[i] * broken_lst[i+1]
    counter_arr[i+1] %= 10**9 + 7
    counter_arr[i+2] += counter_arr[i] * broken_lst[i+2]
    counter_arr[i+2] %= 10**9 + 7

counter_arr[-1] += counter_arr[-2] * broken_lst[-1]
counter_arr[-1] %= 10**9 + 7

print(counter_arr[-1])


Measured memory_bytes: 7780
# SegmentTree reference: https://atcoder.jp/contests/abc125/submissions/7376879
# セグ木 ビットOR
class SegmentTree
  # 配列（もしくは配列のサイズ）、初期値、function
  def initialize(n, unity, &func)
    raise ArgumentError if !n || !unity || !block_given?
    @size_r = 1
    @n = (n.is_a?(Array) ? n.size : n)
    while @size_r < @n
      @size_r <<= 2
    end
    @func = func
    # 初期値
    @unity = unity
    @data = Array.new(@size_r * 2, @unity)
    # 配列が渡された場合、初期値をセットして辺を張る
    if n.is_a?(Array)
      @n.times { |i| @data[i + @size_r] = n[i] }
      self.build()
    end
  end

  # 0-indexed
  def set(index, value)
    raise IndexError if index >= @n
    @data[index + @size_r] = value
  end

  # 辺を張る
  def build
    (@size_r - 1).downto(1) do |k|
      @data[k] = @func.call(@data[k * 2], @data[k * 2 + 1])
    end
  end

  # 0-indexed
  def update(index, value)
    raise IndexError if index >= @n
    index += @size_r
    @data[index] = value
    index >>= 1
    while index > 0
      @data[index] = @func.call(@data[index * 2], @data[index * 2 + 1])
      index >>= 1
    end
    true
  end

  # 0-indexed b を含まず
  def get(a, b)
    raise IndexError if a > @n || b > @n || a > b
    vleft = vright = @unity
    left = a + @size_r
    right = b + @size_r
    while (left < right)
      if left.odd?
        vleft = @func.call(vleft, @data[left])
        left += 1
      end
      if right.odd?
        right -= 1
        vright = @func.call(@data[right], vright)
      end
      left >>= 1
      right >>= 1
    end
    @func.call(vleft, vright)
  end

  def [](k)
    @data[@size_r + k]
  end
end

A_ORDER = 97
alphabet_bit = [1]
25.times { |i| alphabet_bit[i + 1] = alphabet_bit[i] * 2 }
n = gets.to_i
s = gets.chomp.split("").map { |alphabet| alphabet_bit[alphabet.ord - A_ORDER] }
q = gets.to_i
queries = []
q.times do
  tmp = gets.chomp.split
  tmp[0] = tmp[0].to_i
  tmp[1] = tmp[1].to_i
  tmp[2] = tmp[2].to_i if tmp[0] == 2
  queries << tmp
end
seg = SegmentTree.new(s, 0) { |x, y| x | y }
queries.each do |a, b, c|
  if a == 1
    seg.update(b - 1, alphabet_bit[c.ord - A_ORDER])
  else
    puts seg.get(b - 1, c).to_s(2).count("1")
  end
end


Measured memory_bytes: 47596
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
using namespace std;
int main(void){
    string s;
    int k;
    cin>>s>>k;
    int n=s.size();
    vector<string>vec;
    for(int i=0;i<n;i++){
        for(int j=1;j<6;j++){
            vec.push_back(s.substr(i,j));
        }
    }
    sort(vec.begin(),vec.end());
    vec.erase(unique(vec.begin(),vec.end()),vec.end());
    cout<<vec[k-1]<<endl;
}

Measured memory_bytes: 1660
//#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define FIXED cout << fixed << setprecision(12)
#define RANDOM srand(94385)
#define all(a) a.begin(), a.end()
#define shuffle(a) \
    for (int i = 0; i < sz(a); ++i) \
        swap(a[i], a[rand() % sz(a)]);
#define enter putchar('\n')
#define space putchar(' ')
#define Mem(a, x) memset(a, x, sizeof(a))
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

void debug_out() { cerr << '\n'; }
template<typename T, typename ...R>void debug_out(const T &f, const R &...r) {cerr << f << " ";debug_out(r...);}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__);
inline ll read() {ll x = 0;int f = 0;char ch = getchar();while (ch < '0' || ch > '9') f |= (ch == '-'), ch = getchar();while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar();return x = f ? -x : x;}
inline void write(ll x) {if (x == 0) {putchar('0');return;}if (x < 0) {putchar('-');x = -x;}static char s[23];int l = 0;while (x != 0)s[l++] = x % 10 + 48, x /= 10;while (l)putchar(s[--l]);}
int lowbit(int x) { return x & (-x); }
template<class T>T big(const T &a1, const T &a2) { return a1 > a2 ? a1 : a2; }
template<typename T, typename ...R>T big(const T &f, const R &...r) { return big(f, big(r...)); }
template<class T>T sml(const T &a1, const T &a2) { return a1 < a2 ? a1 : a2; }
template<typename T, typename ...R>T sml(const T &f, const R &...r) { return sml(f, sml(r...)); }
template<class T, class U>inline void checkMin(T &x, U y) { if (y < x) x = y; }
template<class T, class U>inline void checkMax(T &x, U y) { if (y > x) x = y; }
template<class T, class U>inline bool ifMax(T &x, U y) {if (y > x) return x = y, true;return false;}
template<class T, class U>inline bool ifMin(T &x, U y) {if (y < x) return x = y, true;return false;}

const int M = 212345;// 2e5+5
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1000000007;// 1e9+7

// HAVE FREE OPEN IN MAIN FUNCTION

int n;
int a[M];
int b[M];


void init() {
    n=read();
    for (int i = 1; i <= n-1; ++i) {
        int tmp=read();
        b[i]=tmp;
        checkMax(a[i],tmp);
        checkMax(a[i+1],tmp);
    }
    for (int i = 1; i <= n-1; ++i) {
        checkMin(a[i],b[i]);
        checkMin(a[i+1],b[i]);
    }
    int ans=0;
    for (int j = 1; j <= n; ++j) {
        ans+=a[j];
    }
    write(ans),enter;
}

void solve() {

}

int main() {
    init();

    solve();

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)); //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template<class T> inline vector<T> convert_to_binary_number(T x) { vector<T> binary_num; while (x != 1) { binary_num.push_back(x % 2); x /= 2; } binary_num.push_back(1); return binary_num; }
template<class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl; }
const LL MOD = 1e9 + 7;
const LL INF = 1LL << 60;


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

	vector<double> P(N);
	rep(i,N) cin >> P[i];

	//すべて一回ずつ投げた

	vector<vector<double> > dp(N + 1, vector<double>(N + 1));
	dp[0][0] = 1.0;

	//dp[j][i]:i枚目まで投げて表がj枚の確率
	for (LL i = 0; i < N; i++) {
		for (LL j = 0; j < i + 1; j++) {
			dp[j + 1][i + 1] += dp[j][i] * P[i];
			dp[j][i + 1] += dp[j][i] * (1 - P[i]);
		}
	}

	
	double ans = 0;
	for (LL i = N; i >= 0; i--) {
		if (LL(ceil(double(N)/2)) > i) {
			break;
		}
		ans += dp[i][N];
	}
	printf("%.9lf\n", ans);
	return 0;
}

Measured memory_bytes: 70656
import java.util.Scanner;

public class Main {
	public static Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		//A
		String[] s = new String[3];
		s[0] = sc.next();
		s[1] = sc.next();
		s[2] = sc.next();
		System.out.println(s[0].charAt(0)+""+s[1].charAt(1)+""+s[2].charAt(2));
	}
}


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

using namespace std;

int n, x, a, ans=0;
int as[101];

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

    sort(as, as+n);

    for(int i = 0; i < n; ++i)
    {
        x -= as[i];
        if(0 <= x)
        {
            ans++;
        }
        else
            break;
    }
    if(ans == n && x)
        ans--;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pii>
#define read(FILE)  freopen(FILE, "r", stdin);
#define out(FILE) freopen(FILE, "w", stdout);
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(),x.end()
#define rep(i,m,n) for(ll i=m ; i<n ; i++)
#define forr(i,m,n) for(ll i=m ; i<=n ; i++)
#define endl '\n'
#define pb push_back
#define re return
const int N =1e5+5;
using namespace std;
int main()
{
    IO;
    ll n,a[105],sum=LLONG_MAX,mn=105,mx=0;
    cin>>n;
    rep(i,0,n) {
    cin>>a[i];
    mn=min(mn,a[i]); mx=max(mx,a[i]);
    }

    forr(i,mn,mx){
        ll cur=0;
        rep(j,0,n){
        cur+=powl(a[j]-i,2);
        }
        sum=min(cur,sum);
    }

    cout<<sum;




}




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

int main() {
  int X;
  cin >> X;
  
  if (360%X == 0) {
    cout << 360 / X << endl;
  }
  
  else {
  	int A = std::lcm(360, X);
    int B = std::gcd(360, X);
    cout << A/X << endl;
  }
}


Measured memory_bytes: 3556
/**                                                     **\
 *    created by:   Divianshu Bansal                     *
 *    e-mail id:    god_coder@icloud.com                 *
*                                                        */

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>


using namespace std;
using namespace __gnu_pbds;


typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>new_data_set;
#define MOD 1000000007
#define int long long
#define BIG 998244353
#define pf push_front
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589


int power(int x,int y){
    int r=1,z=x;
    while(y){
        if(y & 1)r*=z;
        z*=z;y=y>>1;}
    return r;}
int powerm(int x,int y,int p){
    int r=1;
    while(y){
        if(y & 1)r=(r*x)%p;
        y=y>>1;
        x=(x*x)%p;}
    return r%p;}
int modinv(int x,int m){
    return powerm(x,m-2,m);}
int logarithm(int a,int b){
    int x=0;
    while(a>1){
        x++;
        a/=b;}
    return x;}
int max3(int a,int b,int c){
    return max(a,max(b,c));
}
int min3(int a,int b,int c){
    return min(a,min(b,c));
}


int32_t main(){
    fast;
    int n;
    cin>>n;
    cout<<power(n,3);
    return 0;
}

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




int main(){
   vector <int > a(0);
   int r,rr,rrr;cin>>r>>rr>>rrr;
   a.push_back(r);
   a.push_back(rr);
   a.push_back(rrr);
   sort(a.begin(),a.end());
   int ope=0;
   if(a[0]%2 != a[1]%2 ) {
       ope++;
       a[2]++;
       a[1]++;
   }

   if(a[2]%2 != 0){
       a[2]++;
       a[1]++;
       a[0]++;
   }

   if(a[0]%2 != 0){
       ope++;
       a[0]++;
       a[1]++;
   }

   ope += (a[2]-a[0])/2 + (a[2]-a[1])/2;

   cout<<ope<<endl;
   

    return 0;

    
    
}

 



Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	
	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		String S = fs.next();
		int len = S.length();
		long dp[][] = new long[len][3];
		int qcnt = 0;
		if(S.charAt(0)=='A') dp[0][0]=1;
		if(S.charAt(0)=='?') {
			dp[0][0] = 1;
			qcnt++;
		}
		for(int i=1;i<len;i++) {
			if(S.charAt(i)=='A') {
				dp[i][0]=dp[i-1][0] + modpow(3,qcnt);
				dp[i][0]%=mod;
				dp[i][1]=dp[i-1][1];
				dp[i][2]=dp[i-1][2];
				
			}
			if(S.charAt(i)=='B') {
				dp[i][1]=dp[i-1][1] + dp[i-1][0];
				dp[i][1]%=mod;
				dp[i][0]=dp[i-1][0];
				dp[i][2]=dp[i-1][2];

			}
			if(S.charAt(i)=='C') {
				dp[i][2]=dp[i-1][2] + dp[i-1][1];
				dp[i][2]%=mod;
				dp[i][0]=dp[i-1][0];
				dp[i][1]=dp[i-1][1];
			}
			if(S.charAt(i)=='?') {
				
				dp[i][0]=3 * dp[i-1][0] %mod + modpow(3,qcnt);
				dp[i][1]=3 * dp[i-1][1] %mod + dp[i-1][0];
				dp[i][2]=3 * dp[i-1][2] %mod + dp[i-1][1];	
				dp[i][0]%=mod;
				dp[i][1]%=mod;
				dp[i][2]%=mod;
				
				qcnt++;
			}
		}
		System.out.println(dp[len-1][2]);
	}

	//modの元での高速pow()
	static long modpow(long a, long p) {
		if (p == 0)
			return 1;
		if (p % 2 == 0) {
			long halfP = p / 2;
			long root = modpow(a, halfP);
			return root * root % mod;
		} else
			return a * modpow(a, p - 1) % mod;
	}

}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

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

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 27860
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define pi acos(-1.0)
using namespace std;
const int maxn = 1e5+5;

int main(){
	ll k; cin >> k;
	ll n = 100, cnt = 0;
	while(n < k){
		n += n / 100;
		cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3584
#include <stdio.h>

int main()
{
	int i, j, H, W, a[502][502] = {};
	scanf("%d %d", &H, &W);
	for (i = 1; i <= H; i++) {
		for (j = 1; j <= W; j++) scanf("%d", &(a[i][j]));
	}
	
	int k = 0, b[250001], N = 0, x[2][250001], y[2][250001];
	for (i = 1; i <= H; i++) {
		if (i % 2 == 1) for (j = 1; j <= W; j++) b[k++] = a[i][j] % 2;
		else for (j = W; j >= 1; j--) b[k++] = a[i][j] % 2;
	}
	for (i = 0; i < H * W; i++) {
		if (b[i] == 0) continue;
		for (j = i + 1; j < H * W; j++) {
			if (b[j] == 0) continue;
			for (k = i; k < j; k++) {
				y[0][N] = k / W + 1;
				y[1][N] = (k + 1) / W + 1;
				x[0][N] = (y[0][N] % 2 == 1)? k % W + 1: W - k % W;
				x[1][N] = (y[1][N] % 2 == 1)? (k + 1) % W + 1: W - (k + 1) % W;
				N++;
			}
			i = j;
			break;
		}
	}
	
	printf("%d\n", N);
	for (i = 0; i < N; i++) printf("%d %d %d %d\n", y[0][i], x[0][i], y[1][i], x[1][i]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 7808
#include<iostream>

using namespace std;

int main()
{
	int D,T,S;

	cin >> D >> T >> S;

	double time = (double)D/(double)S;

	if(time <= (double)T)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>

#define MAX 100000
#define NIL -1

void print(int);
int rec(int,int);

struct node{

  int p;
  int l;
  int r;
  
  

};
  


  struct node T[MAX];
    int n;
    int D[MAX];


  int main()
  {
    int i,j,d,v,c,l,r;
    scanf("%d",&n);
    for(i=0;i<n;i++)
      {
	T[i].p=T[i].l=T[i].r=NIL;
	
      }
    for(i=0;i<n;i++)
      {
	scanf("%d",&v);
	scanf("%d",&d);
	for(j=0;j<d;j++)
	  {
	    scanf("%d",&c);
	    if(j==0)T[v].l=c;
	    else T[l].r=c;
	    l=c;
	    T[c].p=v;
	  }
	
      }

    for(i=0;i<n;i++)
      {
	if(T[i].p==NIL)r=i;
      }
    rec(r,0);

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

    return 0;
  }


void print(int u)
{
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if(T[u].p==NIL) printf("root, ");
  else if(T[u].l==NIL)printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for(i=0,c=T[u].l;c!=NIL;i++,c=T[c].r)
    {
      if(i) printf(", ");
      printf("%d",c);
    }
  printf("]\n");
  
}

int rec(int u,int p)
{
  D[u]=p;
  if(T[u].r!=NIL)rec(T[u].r,p);
  if(T[u].l!=NIL)rec(T[u].l,p+1);
}




Measured memory_bytes: 6484
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int a,b,c,d,e,f;
	cin >>a>>b>>c>>d>>e>>f;


	double con = 0.0;
	int water = 0,sugar = 0;
	// for(int w = 0; w <=30; w++){
	// 	for(int x = 0; x <= 30; x++){
	// 		for(int y = 0; y <= 100; y++){
	// 			for(int z = 0; z <= 100; z++){
	// 				int water_weight = a*w+b*x, sugar_weight = c*y+d*z;
	// 				int total = 100*water_weight + sugar_weight;
	// 				if(total <= f && sugar_weight <= water_weight*e){
	// 					if(con < (double)sugar_weight/total){
	// 						con = (double)sugar_weight/total;
	// 						water = 100*water_weight;
	// 						sugar = sugar_weight;
	// 					}
	// 				}
	// 			}
	// 		}
	// 	}
	// }

	vector<int> w,s;
	for(int i = 0; i <= 3000; i++){
		for(int j = 0; j <= 3000; j++){
			if(100*(i*a+j*b) <= f) w.push_back(100*(i*a+j*b));
		}
	}
	for(int i = 0; i <= 3000; i++){
		for(int j = 0; j <= 3000; j++){
			if(c*i+d*j <= f) s.push_back(c*i+d*j);
		}
	}

	for(int i = 0; i < w.size(); i++){
		for(int j = 0; j < s.size(); j++){
			if(w[i]+s[j]<= f && s[j] <= e*(w[i]/100) && con <= s[j]/((double)w[i]+s[j])){
				con = s[j]/((double)w[i]+s[j]);
				water = w[i];
				sugar = s[j];
			}
		}
	}

	if(con == 0) water = 100*a;

	cout << water+sugar << " " << sugar << endl;

	return 0;
}

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

int main(){
	while(1){
		string s1,s2;
		cin >> s1;
		if(s1==".")break;
		cin >> s2;

		if(s1==s2){
			cout << "IDENTICAL" << endl;
			continue;
		}

		string t1,t2;
		t1 = s1;t2 = s2;
		while(1){
			size_t d1b = t1.find('\"');
			if(d1b==string::npos)break;
			t1.replace(d1b,1,"@");
		
			size_t d1e = t1.find('\"');
			t1.replace(d1e,1,"@");
		
			size_t d2b = t2.find('\"');
			if(d2b==string::npos)break;
			t2.replace(d2b,1,"@");
		
			size_t d2e = t2.find('\"');
			t2.replace(d2e,1,"@");

			string u1 = s1;
			u1.replace(d1b+1,d1e-d1b-1,"");
			string u2 = s2;
			u2.replace(d2b+1,d2e-d2b-1,"");
	
			if(u1==u2){
				t1 = u1;
				t2 = u2;
				break;
			}
		}
		if(t1==t2){
			cout << "CLOSE" << endl;
		}else{
			cout << "DIFFERENT" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3188
#include <iostream>

#include <map>
#include <unordered_map>
#include <algorithm>
#include <vector>

using namespace std;
//const char a[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
const int maxN=50;
int dp[maxN+1][maxN+1][maxN*maxN+1];

void solver() {

    string a,b,c;
    cin>>a>>b>>c;

    char n = a[0];
    a.erase(0,1);

    while(1){

        if(n == 'a'){
            if(a.size() == 0){
                cout<<"A"<<endl;
                return; }
            n = a[0];
            a.erase(0,1);
        }else if(n == 'b'){
            if(b.size() == 0){
                cout<<"B"<<endl;
                return;
            }
            n = b[0];
            b.erase(0,1);
        }
        else if(n == 'c'){
            if(c.size() == 0){
                cout<<"C"<<endl;
                return;
            }
            n = c[0];
            c.erase(0,1);
        }
    }


    return;
}


int main() {
    int n=1;
    //cin>>n;
    while(n--)
    {
        solver();
    }
}


Measured memory_bytes: 3100
//#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>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll x,now=100,ans=0;cin>>x;
  while(now<x){
    ++ans;
    now+=(now/100);
  }
  cout<<ans<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 3656
#include <iostream>
#include <vector>

using namespace std;

// 約数を求める
long gcd_func(long a, long b)
{
	if (a % b == 0)
	{
		return b;
	}
	else {
		return gcd_func(b, a % b);
	}
}

int main()
{
	// 入力
	int N;
	long X;
	cin >> N >> X;
	vector<long>x(N);
	vector<long>distance(N);
	for (int i = 0; i < N; i++)
	{
		cin >> x[i];
		// 先頭地点からの距離を算出し、距離の配列に代入する
		distance[i] = X - x[i];
	}
	
	
	// 答え用の変数に最初の距離の絶対値を代入する
	long answer = abs(distance[0]);
	for (int i = 0; i < N; i++)
	{
		// 約数の計算を行う
		answer = gcd_func(answer, abs(distance[i]));
	}
	
	// 出力
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
//#include <tuple>
#include <string>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define pb push_back
using namespace std;

int n;
string w[105];
int ch;

int main() {
	cin >> n;

	rep(i, n) {
		cin >> w[i];		
	}

	bool flag = 1;

	rep(i, n-1) {
		for (int j = i+1; j < n;j++) {
			if (w[i] == w[j]) {flag = 0;ch=1;}
			if (!flag) break;
		}
		if (w[i].back() != w[i + 1][0]) flag = 0;
		if (!flag) {break;ch=2;}
	}

	


	if (flag) cout << "Yes\n";
	else cout << "No\n";

	
	
	

	return 0;
}


Measured memory_bytes: 256
INF = 1 << 31
def main():
    S = input()
    T = input()
    N = len(S)
    M = len(T)
    dp = [[INF] * (M + 1) for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0] = i
    for i in range(M + 1):
        dp[0][i] = i
    for i in range(N):
        for j in range(M):
            if S[i] == T[j]:
                dp[i + 1][j + 1] = min(dp[i][j],dp[i + 1][j] + 1,dp[i][j + 1] + 1)
            else:
                dp[i + 1][j + 1] = min(dp[i + 1][j] + 1,dp[i][j + 1] + 1,dp[i][j] + 1)
    print(dp[-1][-1])
if __name__ == '__main__':
    main()



Measured memory_bytes: 41964
//#pragma GCC optimize("O3")

#include <bits/stdc++.h>

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 500100, MAXK = 23;
const ll MOD = 998244353;
const int INF = 1e9+10;
const ld PI = asin(1) * 2;

void setIO () {
    FAST_IO;
}

void setIO (string s) {
    setIO();
 	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

int n, q;
map<ll, ll> cnt;
ll sum = 0;

int main() {
	setIO();

    cin >> n;
    REP(n) {
        ll x; cin >> x;
        cnt[x]++;
        sum += x;
    }

    cin >> q;
    REP(q) {
        ll b, c; cin >> b >> c;
        sum -= cnt[b]*b;
        sum += cnt[b]*c;
        cnt[c] += cnt[b];
        cnt[b] = 0;

        cout << sum << "\n";
    }

    return 0;
}


Measured memory_bytes: 9380
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) (v).begin(), (v).end()



int main() {
	ll N, M;
	cin >> N >> M;
	vll A(N), B(N);
	rep(i, N) cin >> A[i] >> B[i];

	vector <pair<ll, ll>> AB;
	rep(i, N) AB.push_back(pair<ll, ll>(A[i], B[i]));
	sort(all(AB), [](pair<ll, ll>x, pair<ll, ll> y) { return x.first < y.first; });

	ll val = M, ans = 0;
	rep(i, 100000) {
		ans += AB[i].first * min(AB[i].second, val);
		val -= min(AB[i].second, val);
		if (val == 0) break;
	}
	cout << ans << endl;


}

Measured memory_bytes: 3956
#include<iostream>
#include<string>
#include<string.h> 
using namespace std;
char a[200005],b[200005],s[200005];
int main()
{
	int n,i,j,k,flag=0,p,h,g,a1=0,b1=0;
	scanf("%s",&s);
	scanf("%d",&n);
	char c;
	for(i=0;i<n;i++)
	{
		scanf("%d",&k);
		if(k==1)flag=!flag;
		else
		{
			scanf("%d %c",&p,&c);
			if(p==1&&flag==0)
			{
				a[a1++]=c;
			}
			else if(p==1&&flag==1)
			{
				b[b1++]=c;
			}
			else if(p==2&&flag==0)
			{
				b[b1++]=c;
			}
			else if(p==2&&flag==1)
			{
				a[a1++]=c; 
			}
		}
	}
	if(flag==0)
	{
		for(i=a1-1;i>=0;i--)
		{
			printf("%c",a[i]);
		}
		printf("%s",s);
		for(i=0;i<b1;i++)
		{
			printf("%c",b[i]);
		}
	}
	else
	{
		for(i=b1-1;i>=0;i--)
		{
			printf("%c",b[i]);
		}
		for(i=strlen(s)-1;i>=0;i--)
		{
			printf("%c",s[i]);
		}
		for(i=0;i<a1;i++)
		{
			printf("%c",a[i]);
		}
	}
}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double x1 = sc.nextDouble();
		double y1 = sc.nextDouble();
		double x2 = sc.nextDouble();
		double y2 = sc.nextDouble();

		double sum = Math.abs(x2 - x1) * Math.abs(x2 - x1) + Math.abs(y2 - y1) * Math.abs(y2 - y1);
		double ans = Math.sqrt(sum);
		System.out.println(ans);
	}

}

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

int main(){
  int A,tap,sum,B; cin >> A >> B;
  sum=1; tap=0;
  for(int i=0;;i++){
    if(sum<B){
      sum=sum-1+A;
      tap++;
    }
    else{
      break;
    }
  }
  cout << tap << endl;
}

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

using namespace std;
typedef long long Int;
Int x, y;
int main(){
	cin >> x >> y;
	if(x % y == 0){
		cout << -1 << endl;
		return 0;
	}
	Int i = 0;
	for(;(i*x)%y==0;i++);
	cout << i * x << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll a,b;
    cin>>a>>b;
    if(a+b==15) cout<<"+"<<endl;
    else if(a*b==15) cout<<"*"<<endl;
    else cout<<"x"<<endl;
    return 0;
}

Measured memory_bytes: 256
from sys import stdin


def main() -> int:
    ans = "NO"
    a = next_int()
    b, c = map(int, input().split())

    x = a
    for i in range(b + 1):
        if x % b == c:
            ans = "YES"
            break
        x += a
    print(ans)
    return 0


def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

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

typedef long long ll;

static const ll INF = 1ll<<60;
static const int MOD = 1e9+7;

int main(){
    int N;
    cin>>N;
    int tmp = 1000;

    while(tmp < N){
        tmp += 1000;
    }

    cout<<(tmp - N)<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <numeric>
#include <tuple>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = j; i < (int)n; ++i)

constexpr ll INF = 1LL << 60;

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

    int n, m, s; cin >> n >> m >> s;
    vector<ll> c(n), d(n);
    vector<vector<tuple<int, ll, ll>>> g(n);
    rep(i, 0, m) {
        int u, v, a, b; cin >> u >> v >> a >> b;
        --u, --v;
        g[u].emplace_back(v, a, b);
        g[v].emplace_back(u, a, b);
    }
    rep(i, 0, n) cin >> c[i] >> d[i];


    const int MAXS = 50 * 50;
    vector<vector<ll>> dp(n + 1, vector<ll>(MAXS, INF));
    // 無向グラフ上でDPしたいのでダイクストラを使う
  
    s = min(s, MAXS);
    dp[0][s] = 0;
    priority_queue<tuple<ll, int, ll>, vector<tuple<ll, int, ll>>, greater<tuple<ll, int, ll>>> pq;
    pq.emplace(0, 0, s);
    while(pq.size()) {
        ll dist, coin;
        int v;
        tie(dist, v, coin) = pq.top();
        pq.pop();
        if (dp[v][coin] != dist) continue; 
        // 最小距離確定はpqに入れる直前
        // dp[v][coin] != distとは、この要素が入った後にdp[v][coin]が更新された場合
      
        // 移動
        int nv, a, b;
        for(auto t : g[v]) {
            tie(nv, a, b) = t;
            if (coin - a >= 0 && dp[nv][coin - a] > dist + b) {
                dp[nv][coin - a] = dist + b;
                pq.emplace(dp[nv][coin - a], nv, coin - a);
            }
        }
        // コイン生産
        rep(i, 1, MAXS) {
            if (coin + c[v] * i < MAXS && dp[v][coin + c[v] * i] > dp[v][coin] + d[v] * i) {
                dp[v][coin + c[v] * i] = dp[v][coin] + d[v] * i;
                pq.emplace(dp[v][coin + c[v] * i], v, coin + c[v] * i);
            } else break;
        }
    }

    rep(i, 1, n) {
        ll ans = INF;
        rep(j, 0, MAXS) ans = min(ans, dp[i][j]);
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 101700
import sys
N,C=map(int,input().split())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
mod=10**9+7
table=[[ pow(j,i,mod) for j in range(405)] for i in range(405)]
ntable=[[0]*405 for i in range(405)]
for i in range(405):
    t=0
    for j in range(1,405):
        t+=table[i][j]
        t%=mod
        ntable[i][j]=t
dp=[[0]*(C+1) for i in range(N)]
for i in range(C+1):
    dp[0][i]=((ntable[i][B[0]]-ntable[i][A[0]-1]))%mod
for i in range(1,N):
    for k in range(C+1):
        for l in range(k+1):
            dp[i][k]+=dp[i-1][l]*(ntable[k-l][B[i]]-ntable[k-l][A[i]-1])
            dp[i][k]%=mod
print(dp[N-1][C])



Measured memory_bytes: 45420
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

//++時計回り --反時計回り
// int dx[4] = {1, 0, -1, 0};
// int dy[4] = {0, 1, 0, -1};

int main() {
  string S;
  cin >> S;
  int N = S.size();
  char id = 'R';
  vector<int> v;
  vector<int> u;
  REP(i, N) {
    if (S[i] != id) {
      if (id == 'R')
        v.PB(i);
      else
        u.PB(i);
      id = S[i];
    }
  }
  u.PB(N);
  int k = 0;
  int ans[N] = {};
  REP(i, N) {
    if (i == u[k])
      k++;
    if (abs(i - v[k]) % 2 == 0) {
      ans[v[k]]++;
    } else {
      ans[v[k] - 1]++;
    }
  }
  REP(i, N) cout << ans[i] << (i < N - 1 ? ' ' : '\n');
}


Measured memory_bytes: 1532
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    int N, H, W;
    cin >> N >> H >> W;
    cout << (N-H+1) * (N-W+1)  << endl;
}


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

int main()
{
   ll n,m;
   cin>>n>>m;
   priority_queue<ll> q;
   for(int i=0;i<n;i++)
   {
       ll temp;
       cin>>temp;
       q.push(temp);
   }
   while( m--)
   {
       ll top = q.top();
       q.pop();
       top = top/2;
       q.push(top);
   }
   ll ans =0;
   while( !q.empty() )
   {
       ans += q.top();
       q.pop();
   }
   cout<<ans;
}

Measured memory_bytes: 4312
H, W, M = map(int, input().split())
hw = set()
sum_h = [0] * W
sum_w = [0] * H
for _ in range(M):
    h, w = map(int, input().split())
    hw.add((h, w))
    h -= 1
    w -= 1
    sum_h[w] += 1
    sum_w[h] += 1


max_h = max(sum_h)
max_w = max(sum_w)

new_H = [h for h in range(H) if sum_w[h] == max_w]
new_W = [w for w in range(W) if sum_h[w] == max_h]

max_num = max_h + max_w - 1
for i in new_H:
    for j in new_W:
        if (i + 1, j + 1) not in hw:
            print(max_h + max_w)
            exit()
        else:
            continue
        break

print(max_num)


Measured memory_bytes: 83456
#include<stdio.h>
#include<stdlib.h>
 
int insertionSort(int *A, int n, int g) {
  int i, j, v;
  int cnt = 0;
 
  for(i = g; i < n; i++) {
    v = A[i];
    j = i-g;
    while(j >=0 && A[j] > v) {
      A[j+g] = A[j];
      j = j-g;
      cnt++;
    }
    A[j+g] = v;
  }
  return cnt;
}
 
int shellSort(int *A, int n, int m, int *G) {
  int i;
  int cnt = 0;
 
  for(i = 0; i < m; i++) {
    cnt += insertionSort(A, n, G[i]);
  }
  return cnt;
}
 
int main() {
  int n, m, i;
  int cnt = 0;
  int *A;
  int G[100], *H;
 
  scanf("%d", &n);
  A = malloc(n*sizeof(int));
  for(i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }
 
  G[0] = 1;
  for(i = 1; i < 100; i++) {
    G[i] = 3*G[i-1]+1;
  }
 
  m = 1;
  while(G[m] < n && m < 100) {
    m++;
  }
 
  H = malloc(m*sizeof(int));
  for(i = m; i >= 0; i--) {
    H[m-i] = G[i-1];
  }
 
  cnt = shellSort(A, n, m, H);
 
  printf("%d\n", m);
  for(i = 0; i < m; i++) {
    printf("%d", H[i]);
    if(i != m-1) {
      printf(" ");
    }
  }
  printf("\n");
 
  printf("%d\n", cnt);
 
  for(i = 0; i < n; i++) {
    printf("%d\n", A[i]);
  }
 
  return 0;
}

Measured memory_bytes: 4512
package main

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

func main() {
	scanner := makeScanner(1024)
	a := eGetInt(scanner)
	b := eGetInt(scanner)
	c := eGetInt(scanner)
	x := eGetInt(scanner)
	count := 0
	for i := 0; i <= a; i++ {
		sum := i * 500
		if sum >= x {
			if sum == x {
				count++
			}
			continue
		}
		for j := 0; j <= b; j++ {
			sum := i*500 + j*100
			if sum >= x {
				if sum == x {
					count++
				}
				continue
			}
			for k := 0; k <= c; k++ {
				sum := i*500 + j*100 + k*50
				if sum >= x {
					if sum == x {
						count++
					}
					continue
				}
			}
		}
	}
	fmt.Println(count)
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}

func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    vector<ll>a(n),b(n);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    b[0]=a[0];
    for(int i=1; i<n; ++i){
        b[i]=b[i-1]+a[i];
    }
    int ans=1;
    sort(a.rbegin(),a.rend());
    sort(b.rbegin(),b.rend());
    for(int i=0; i<n-1; ++i){
        if(a[i]<=b[i+1]*2)ans++;
        else break;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int ans = 0;
		if (A >= B) {
			ans = 10;
		}

		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 23252
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
 
static const int MAX =100;
static const int long long INF = (1LL << 32);

int g;
long long A[MAX][MAX];

void floyd() {
	for (int k= 0;k<g; k++) { 
		for (int i = 0; i<g ; i++) { 
	    if (A[i][k] == INF) continue;
				for (int j = 0; j<g ;j++) {
				    if(A[k][j] == INF) continue;
					A[i][j] = min(A[i][j], A[i][k] + A[k][j]);
				}
		}
	}
}



int main() {
    int v;
	cin >> g >> v;

	//初期化
	for (int i = 0; i< g ; i++) {
		for (int j = 0; j<g ;j++) {
		  if (i == j) A[i][j] = 0;
		  else A[i][j] = INF;
		}
	}

	//入力でわかったおもみを入れる
	for (int k = 0; k<v;k++) {
		int n, m, d;
		cin >> n >> m >> d;

		A[n][m] = d;
	}
	
	floyd();
	

    for (int l =0;l <g;l++) {
        if (A[l][l] <0 ){
            cout << "NEGATIVE CYCLE" << endl; 
            exit(0);
        }
    }

	for (int i = 0; i< g; i++) {
		for (int j = 0; j<g ;j++) {
		    if(j) cout << " ";
		    if(A[i][j] == INF) cout <<"INF";
			else cout << A[i][j];
		}
		cout << endl;
	}
	return 0;
}




Measured memory_bytes: 3180
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, X, Y = MAP()
graph = [[] for i in range(N)]

for i in range(N-1):
    graph[i].append(i+1)
    graph[i+1].append(i)

graph[X-1].append(Y-1)
graph[Y-1].append(X-1)

dic = defaultdict(int)

for i in range(N):
    q = deque()
    q.append(i)
    dist = [INF] * N
    dist[i] = 0
    while q:
        n = q.popleft()
        for node in graph[n]:
            if dist[node] == INF:
                dist[node] = dist[n] + 1
                q.append(node)
        
    for d in dist:
        dic[d] += 1

for k in range(1, N):
    print(dic[k] // 2)


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

int main(){

    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    int q;
    cin >> q;
    for(int i = 0; i < q; ++i){
        int k;
        cin >> k;
        auto lower_it = lower_bound(a.begin(), a.end(), k);
        int low;
        if(lower_it == a.end()){
            low = n;
        }
        else{
            low = lower_it - a.begin();
        } 

        auto upper_it = upper_bound(a.begin(), a.end(), k);
        int upp;
        if(upper_it == a.end()){
            upp = n;
        }
        else{
            upp = upper_it - a.begin();
        }

        cout << low << " " << upp << endl;
    }

    return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,i,min=0,c=0;
cin>>n;
    int a[n];

    for(i=0;i<n;i++)
    {
    cin>>a[i];
        if(min>a[i] || i==0)
        {
        c++;
        min=a[i];
        }
    }
    cout<<c;
return 0;
}


Measured memory_bytes: 1024