akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

template<class T>inline bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    ll n, m;
    cin >> n >> m;
    if (2*n >= m) {
        cout << m / 2 << '\n';
    } else {
        cout << n + (m - 2*n) / 4 << '\n';
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 3652
n = int(input())
a = list(map(int, input().split()))


zero_included = (0 in set(a))
negative_count = sum([item < 0 for item in a])
a_abs = sorted([abs(item) for item in a])

if zero_included or negative_count % 2 == 0:
    print(sum(a_abs))
else:
    print(sum(a_abs[1:]) - a_abs[0])


Measured memory_bytes: 67536
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
	int n,k;
	cin>>n>>k;
	if(k%2==1) {
		cout<<(n/k)*(n/k)*(n/k);
	} else {
		int ans=0;
//		int w=k/2;
//		for(int i=k;i<=n;i+=k)
//			for(int j=i;j<=n;j+=k)
//				for(int kk=j;kk<=n;kk+=k){
////					cout<<i<<" "<<j<<" "<<kk<<'\n';
//					if(i==j&&j!=kk) ans+=3;
//					else if(j==kk&&i!=j) ans+=3;
//					else if(i==kk&&j!=kk) ans+=3;
//					else if(i!=j&&j!=kk&&i!=kk) ans+=6;
//					else ans++;
////					cout<<"ans="<<ans<<'\n';
//				}
//		for(int i=k/2;i<=n;i+=k)
//			for(int j=i;j<=n;j+=k)
//				for(int kk=j;kk<=n;kk+=k){
////					cout<<i<<" "<<j<<" "<<kk<<'\n';
//					if(i==j&&j!=kk) ans+=3;
//					else if(j==kk&&i!=j) ans+=3;
//					else if(i==kk&&j!=kk) ans+=3;
//					else if(i!=j&&j!=kk&&i!=kk) ans+=6;
//					else ans++;
////					cout<<"ans="<<ans<<'\n';
//				}



//		cout<<ans;
		int w=k/2;
		if((n/w)%2==1) {
			cout<<(n/(w*2))*(n/(w*2))*(n/(w*2))+(n/(w*2)+1)*(n/(w*2)+1)*(n/(w*2)+1);
		} else cout<<(n/(w*2))*(n/(w*2))*(n/(w*2))*2;
		


	}
	return 0;
}

Measured memory_bytes: 256
/* Simplicity and Goodness */

#include <bits/stdc++.h>
#define ll long long
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",n)
#define prin(n) printf("%d\n",n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<int(n);i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf INT_MAX
#define ninf INT_MIN
using namespace std;
const ll mod = 998244353;
const int N = 2e5+2; 

int main()
{
    int a, b, m;
    scn(a); scn(b); scn(m);

    int ref[a], mic[b], ans = inf;

    rep(i, 0, a)
    {
        scn(ref[i]);

        ans = min(ans, ref[i]);
    }

    int mn = inf;

    rep(i, 0, b)
    {
        scn(mic[i]);

        mn = min(ans, mic[i]);
    }

    ans += mn;

    while(m --)
    {
        int x, y, c;
        scn(x); scn(y); scn(c);

        ans = min(ans, ref[x-1]+mic[y-1]-c);
    }

    prin(ans);    
    return 0;
}

Measured memory_bytes: 1024
using System;
class Program
{
	static void Main(string[] args)
    {
		// スペース区切りの整数の入力
		string S = Console.ReadLine();
      		string T = Console.ReadLine();
		int anser = 0;
		for(int i  = 0;i< S.Length;i++){
        	if ( S[i] == T[i]){
            	anser++;
            }
        }
		//出力
		Console.WriteLine(anser);
	}
}


Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<set>
#include <functional>
#include <limits>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

//https://atcoder.jp/contests/agc023/tasks/agc023_a


signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, K;
	int res = 0;
	vector<int> a, sum, sum2, v, con;
	
	cin>>N>>K;
	
	a.resize(N);
	sum.resize(N+1);
	sum2.resize(N+1);
	
	for(int i = 0; i < N; i++){
		cin>>a[i];
		a[i] = (a[i] - 1 + K)%K;
	}
	
	for(int i = 0; i < N; i++){
		sum[i+1] += (sum[i] + a[i])%K;
		v.push_back(sum[i+1]);
	}
	
	v.push_back(0);
	
	sort(v.begin(), v.end());
	
	v.erase(unique(v.begin(), v.end()), v.end());
	
	con.resize(v.size());
	
	for(int i = 0; i <= N; i++){
		sum2[i] = lower_bound(v.begin(), v.end(), sum[i]) - v.begin();
	}
	
	for(int i = 0; i <= N; i++){
		res += con[sum2[i]];
		con[sum2[i]]++;
		if(i - K + 1 >= 0) con[sum2[i - K + 1]]--;
		
	}
	cout<<res<<endl;
	
	
	return 0;
}

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

#define int long long

const int max_n = 1 << 17;

int data[2 * max_n - 1];
int n, q;

void init(int _n)
{
  n = 1;
  while (n < _n) n *= 2;

  for (int i = 0; i < n * 2 - 1; i++){
    data[i] = INT_MAX;
  }
}

void update(int k, int x)
{
  k += n - 1;
  data[k] = x;
  while (k > 0) {
    k = (k - 1) / 2;
    data[k] = min(data[2 * k + 1], data[2 * k + 2]);
  }
}

int query(int a, int b, int k, int l, int r)
{
  if (r <= a || b <= l) return INT_MAX;
  if (a <= l && r <= b) return data[k];
  int vl = query(a, b, 2 * k + 1, l, (l + r) / 2),
      vr = query(a, b, 2 * k + 2, (l + r) / 2, r);

  return min(vl, vr);
}

main()
{
  cin >> n >> q;
  init(n);

  for (int i = 0; i < q; i++){
    int f, x, y;
    cin >> f >> x >> y;
    if (f){
      cout << query(x, y + 1, 0, 0, n) << endl;
    } else {
      update(x, y);
    }
  }
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  const lli mod = 1e9 + 7;

  int n, m;
  while (cin >> n >> m) {
    vector<lli> a(n);
    vector<lli> b(m);
    cin >> a >> b;

    lli sum = 0;

    lli x = 0;
    for (int i = 0; i + 1 < n; ++i) {
      x += (a[i + 1] * (i + 1) * (n - i - 1)) % mod;
      x = (mod + x - a[i] * (i + 1) * (n - i - 1)) % mod;
    }

    lli y = 0;
    for (int j = 0; j + 1 < m; ++j) {
      y += (b[j + 1] * (j + 1) * (m - j - 1)) % mod;
      y = (mod + y - b[j] * (j + 1) * (m - j - 1)) % mod;
    }

    cout << (x * y) % mod << endl;
    continue;
    
    for (int i = 0; i + 1 < n; ++i) {
      for (int j = 0; j + 1 < m; ++j) {
        lli x = a[i + 1] - a[i];
        lli y = b[j + 1] - b[j];
 
        lli z = (x * y) % mod;
        z *= (i + 1) * (n - i - 1) * (j + 1) * (m - j - 1);
        
        (sum += z % mod) %= mod;
      }
    }
    
    // lli p = (a.back() - a.front()) % mod;
    // lli q = (b.back() - b.front()) % mod;
    
    // lli r = (p * q) % mod;

    // r *= (n - 1) * (m - 1);
    // r %= mod;
    // cout << r << endl;
  }

  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi atan(1.0)*4
#define pb(x) push_back(x)
#define in(x) insert(x)
#define fl(x,y) for(ll i=x;i<y;i++)
#define vi vector<long long>
#define vs  vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
string en="\n";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define fi first
#define se second
#define clr clear()
#define sqr(a) (a*a)
#define mk make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
/*bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool palin(string a){for(int i=0;i<a.sz;i++){if(a.at(i)!=a.at(a.sz-i-1))return 0;} return 1;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
LL bpow(LL a,LL b){if(b==0)return 1;LL r=bpow(a,b/2);if(b%2)return r*r*a;else return r*r;}
LL binpow(LL a,LL b){LL r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
LL binpow(LL a,LL b,LL m){a%=m;LL r=1;while(b>0){if(b&1) r=r*a%m;a=a*a%m; b>>=1;}return r;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
*/
int main()
{
    ll a,b,c,t,n,k,p,q,r,sum,ct=0,flag=0;
    string s,s1,s2,s3;
    set<ll>st;
    map<ll,ll>mp;
    vector<ll>v;

      cin>>a>>b>>c;
      if((a+b+c==17) )
      cout<<Y<<endl;
      else
      cout<<N<<endl;

}





Measured memory_bytes: 3560
#include <bits/stdc++.h>
const int N=200;
using std::max;
using std::min;
int n,m,a[N][N],sum[N][N],dp[N][N][N][15];
char c[N][N];
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) scanf("%s",c[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			if (c[i][j]=='.') a[i][j]=1;
			else a[i][j]=0;
			sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+a[i][j];
		}
	for (int i=1;i<=n;i++)	
		for (int j=1;j<=m;j++)
			for (int k=j;k<=m;k++){
				int l=i,r=n,ans=i-1;
				while (l<=r){
					int mid=(l+r)>>1;
					int s=sum[mid][k]-sum[mid][j-1]-sum[i-1][k]+sum[i-1][j-1];
					if (s==0 || s==(mid-i+1)*(k-j+1))
						ans=mid,l=mid+1;
					else r=mid-1;
				}
				dp[i][j][k][0]=ans;
			}
	if (dp[1][1][m][0]==n) {
		puts("0");return 0;
	}
	int k=1;
	for (k=1;dp[1][1][m][k-1]<n;k++)
	for (int h=1;h<=m;h++)
		for (int i=1;i<=n;i++)
			for (int j1=1,j2=j1+h-1;j2<=m;j1++,j2++){
					if (dp[i][j1][j2][k-1]==n){
						dp[i][j1][j2][k]=n;
						continue;
					}
					dp[i][j1][j2][k]=dp[dp[i][j1][j2][k-1]+1][j1][j2][k-1];//横
					if(dp[i][j1][j2][k]==n) continue; 
					int l=j1,r=j2-1,ans=0;
					while (l<=r){
						int mid=(l+r)>>1;
						int x=dp[i][j1][mid][k-1],y=dp[i][mid+1][j2][k-1];
							if (k==1){
							//printf("%d %d %d %d %d %d\n",i,j1,j2,mid,x,y);
						}ans=max(ans,min(x,y));
						if (x<y) r=mid-1;
						else l=mid+1;
					}
					//printf("%d %d %d %d %d\n",i,j1,j2,k,ans);
					//if (k==1) printf("...%d...\n",ans);
					dp[i][j1][j2][k]=max(dp[i][j1][j2][k],ans);
				}
	printf("%d\n",k-1);
}

Measured memory_bytes: 436608
S=int(input())
a=int(S/15)
b=S%15
c=int(b/3)
d=int(b/5)
alls=(1+S)*S/2
print(int(alls-(60*a)-(105*a*(a-1)/2)-((1+c)*c*3/2)-((1+d)*d*5/2)-(c+d)*15*a))

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

int main(int argc, char** argv){
  int n;
  cin >> n;
  int p[n];
  
  for(int cnt0=0; cnt0<n; cnt0++){
    cin >> p[cnt0];
  }
  
  int ans = 0;
  /*
  for(int cnt0=0; cnt0<n; cnt0++) cout << p[cnt0] << endl;
  return 0;
  */
  for(int cnt0=1; cnt0<n-1; cnt0++){
    if((p[cnt0-1] < p[cnt0] && p[cnt0] < p[cnt0+1]) || (p[cnt0-1] > p[cnt0] && p[cnt0] > p[cnt0+1])) ans++;
  }
  
  printf("%d\n", ans);
  return 0;
}

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

int main()
{
    int k;
    char str[100];
    int length;
    int i = 0;
    scanf("%d", &k);
    scanf("%s", &str);
    length = strlen(str);

    if (length <= k)
    {
        printf("%s", str);
    }
    else
    {
        for (i = 0; i < k; i++)
        {
            printf("%c", str[i]);
        }
        printf("...");
    }

    return 0;
}

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

int main(){
	int n;
	cin>>n;
  int a[n];
  rep(i,n) cin>>a[i];
	
	sort(a,a+n);
  reverse(a,a+n);
	int A=0;
	int B=0;
	rep(i,n){
		if(i%2==0) A+=a[i];
		else B+=a[i];
	}
	cout << A-B << endl;
}

Measured memory_bytes: 256
<?php

$arr = [];
while ($line = fgets(STDIN)){
    array_push($arr,$line);
};

$x = intval($arr[0]);
$y = intval($arr[1]);
$z = intval($arr[2]);

if ($x > $y) {
    $ans = ceil($z / $x);
} else {
   $ans = ceil($z / $y); 
}

echo $ans;




?>

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

namespace ARC081D {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            string S1 = Console.ReadLine();
            string S2 = Console.ReadLine();
            long ans = 1;
            int updowndiff = -1;
            for (int i = 0; i < N; i++) {
                if (i != N - 1 && S1.Substring(i, 1) == S1.Substring(i + 1, 1)) {
                    if(updowndiff == -1) {
                        ans = (ans * 6) % mod;
                    }else if(updowndiff == 0) {
                        ans = (ans * 2) % mod;
                    } else {
                        ans = (ans * 3) % mod;
                    }
                    updowndiff = 1;
                    i++;
                } else {
                    if(updowndiff == -1) {
                        ans = (ans * 3) % mod;
                    }else if(updowndiff == 0) {
                        ans = (ans * 2) % mod;
                    } else {
                    }
                    updowndiff = 0;
                }
            }
            Console.WriteLine(ans);
        }

        //定数です
        const long mod = 1000000007;
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 102;
const ll MOD = 1000000007;
const int iNF = 0x3f3f3f3f;
/*
s = 0
row = [1, n]
col = [n+1, n+m]
t = n+m+1
*/

int n, m, head[MAXN*2], s, t;
struct Edge {
    int t, flow, cap, nxt;
} edge[MAXN * MAXN * 4];
int edge_cnt;

void add_edge (int f, int T, int cap) {
    edge[edge_cnt++] = {T, 0, cap, head[f]};
    head[f] = edge_cnt - 1;
    edge[edge_cnt++] = {f, 0, 0, head[T]};
    head[T] = edge_cnt - 1;
}

int lev[MAXN*2];
int dfs (int nd, int lim) {
    if (nd == t || lim == 0) {
        return lim;
    }

    for (int i=head[nd]; i!=-1; i=edge[i].nxt) {
        int x = edge[i].t;
        if (lev[x] == lev[nd]+1 && edge[i].cap > edge[i].flow) {
            int df = 0;
            if (df = dfs(x, min(lim, edge[i].cap - edge[i].flow))) {
                edge[i].flow += df;
                edge[i^1].flow -= df;
                return df;
            }
        }
    }

    return 0;
}

bool bfs () {
    memset(lev, -1, (n+m+2) * sizeof(int));
    lev[s] = true;
    queue<int> que;
    que.emplace(s);

    while (SZ(que)) {
        int cur = que.front();
        que.pop();

        for (int i=head[cur]; i!=-1; i=edge[i].nxt) {
            int x = edge[i].t;
            if (lev[x] == -1 && edge[i].cap > edge[i].flow) {
                lev[x] = lev[cur] + 1;
                que.emplace(x);
            }
        }
    }

    return lev[t] != -1;
}

int dinic (int x, int y) {
    s = x, t = y;
    int ret = 0;
    while (bfs()) {
        int df = 0;
        while (df = dfs(s, iNF)) {
            ret += df;
        }
    }
    return ret;
}

/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> n >> m;
    memset(head, -1, (n+m+2) * sizeof(int));

    REP1 (i, n) {
        REP1 (j, m) {
            char c;
            cin >> c;
            if (c == 'o') {
                add_edge(i, n+j, 1);
                add_edge(n+j, i, 1);
            } else if (c == 'S') {
                add_edge(0, i, iNF);
                add_edge(0, n+j, iNF);
            } else if (c == 'T') {
                add_edge(i, n+m+1, iNF);
                add_edge(n+j, n+m+1, iNF);
            } else {
                assert(c == '.');
            }
        }
    }

    int ans = dinic(0, n+m+1);
    cout << (ans >= iNF ? -1 : ans) << endl;

    return 0;
}


Measured memory_bytes: 896
S = input()
count = 0
sentence = []
for i in range(len(S)):
    sentence.append(S[i])
for i in range(0,len(sentence)):
    # print(S[i], S[-1-i])
    if sentence[i] != sentence[-1-i]:
        sentence[i] = sentence[-1-i]
        count += 1

print(count)

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

using namespace std;
typedef pair<int, int> P;

void solve()
{
	int N, M;
	cin >> N >> M;
	vector<P> student(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> student[i].first >> student[i].second;
	}
	vector<P> checkPoint(M);
	for (int i = 0; i < M; ++i)
	{
		cin >> checkPoint[i].first >> checkPoint[i].second;
	}
	for (int i = 0; i < N; ++i)
	{
		int minDist = 1e9;
		int index = 0;
		for (int j = 0; j < M; ++j)
		{
			int dist = 0;
			dist += abs(student[i].first - checkPoint[j].first);
			dist += abs(student[i].second - checkPoint[j].second);
			if (minDist > dist)
			{
				minDist = dist;
				index = j + 1;
			}
		}
		cout << index << endl;
	}
}

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

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

int main(void){
    string s;
    cin >> s;
    
    int ans[10];
    int idx = 0;
    int i;
    for(i = 0; i < s.length(); i++){
        switch(s[i]){
            case '0': ans[idx] = 0; idx++; break;
            case '1': ans[idx] = 1; idx++; break;
            case 'B': if(idx != 0){idx--;} break;
        }
    }
    
    for(i = 0; i < idx; i++){
        cout << ans[i];
    }
    
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i=0; i<N; i++) {
			A[i] = sc.nextInt();
		}

		int count = 0;
		for (int i=0; i<N; i++) {
			int minj = i;
			for (int j=i; j<N; j++) {
				if (A[j]<A[minj]) {
					minj = j;
				}
			}
			if (i!=minj) {
				count++;
				int tmp = A[i];
				A[i] = A[minj];
				A[minj] = tmp;
			}
		}
		for (int i=0; i<N; i++) {
			if (i!=0) {
				System.out.print(" ");
			}
			System.out.print(A[i]);
		}
		System.out.println();
		System.out.println(count);

		sc.close();
	}

}

Measured memory_bytes: 26244
import java.util.Scanner;

public class Main{
    public static void main(String[]args){
        Scanner scan = new Scanner(System.in);
        int x,y;
        while(true){
            x=scan.nextInt(); y=scan.nextInt();
            if(x==0 && y==0){
                break;
            }
            for(int i=0; i<x;i++){
                for(int j=0; j<y; j++){
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


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

int main(){
  string s;
  bool ans = true;
  cin >> s;
  int dest = s.size();

  if(dest%2==1){
    cout << "No" <<endl;
    return 0;
  }
else{

  for(int i = 0;i < dest;i++){
if(i%2==0&&s[i]!='h'){
ans = false;
  }
  if(i%2==1&&s[i]!='i'){
ans = false;
  }
}
}

if(ans == false){
  cout << "No" << endl;
}
else{
  cout <<"Yes" << endl;
}
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

void fail() {
    cout << "NO\n";
    exit(0);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    vector<ll> a(n);
    forn(i, 0, n) cin >> a[i];
    ll sum = 0;
    forn(i,0, n) sum += a[i];
    ll step = n * (n + 1) / 2;
    if (sum % step ) fail();
    ll steps = sum / step;
    a.eb(a[0]);
    ll need = 0;
    forn(i, 0, n) {
        ll d = a[i + 1] - a[i] - steps;
        if (d > 0) fail();
        if (d % n) fail();
        need -= d / n;
    }
    if (need != steps) fail();
    cout << "YES\n";
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
struct UnionFind{
    vector<int> d;
    UnionFind(int n) : d(n,-1) {}
    //根なら、-サイズを格納それ以外は、親を格納
    int find(int x){
        if(d[x] < 0) return x;
        return d[x] = find(d[x]); //経路縮約
    }
    bool unite(int x,int y){
        //二つ頂点を持ってくる
        x = find(x);
        y = find(y);
        if(x == y) return false;//根が一致するなら何もしない
        if(d[x] > d[y]) swap(x,y);
        //ex:d[x]=-5,d[y]=-2
        //小さい方が、大きい方に引っ付く
        d[x] += d[y];//この場合、yがxにくっつく
        d[y] = x;
        return true;
    }
    bool same(int x,int y) {return find(x) == find(y);}
    int size(int x) {return -d[find(x)];}
};
int main(){
    cout << fixed << setprecision(10);
    int n,m;
    vector<pair<int,pair<int,int>>> v;
    cin >> n >> m;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--; b--;
        v.push_back(make_pair(i,make_pair(a,b)));
    }
    int cnt = 0;
    rep(i,m){
        UnionFind uf(n);
        rep(j,m){
            if(i == j) continue;
            uf.unite(v[j].second.first, v[j].second.second);
        }
        if(uf.size(0) != n) cnt ++;
    }
    cout << cnt << endl;
    return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    int N, M;
    cin >> N >> M;
    //! 犬を0番目に
    ll d = 1;
    ll n = N, m = M;
    REP(i, N + M)
    {
        if (i % 2 == 0)
            d *= n--;
        else
            d *= m--;
        d %= MOD;
    }
    //! 猿を0番目に
    n = N;
    m = M;
    ll s = 1;
    REP(i, N + M)
    {
        if (i % 2 == 0)
            s *= m--;
        else
            s *= n--;
        s %= MOD;
    }

    cout << (d + s) % MOD << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int n;
char a[1001];

int s[1001][8]; // 001: J, 010: O, 100 I 

int main() {
	
	scanf("%d", &n);
	
	scanf("%s", a);
	
	for(int i=0;i<8;i++) {
		s[0][i] = 0;
	}
	s[0][1] = 1;
	
	for(int i=1;i<=n;i++) {
		for(int j=0;j<8;j++) {
			s[i][j] = 0;
			if((a[i-1]=='J' && j&1) || (a[i-1]=='O' && (j>>1)&1) || (a[i-1]=='I' && (j>>2)&1)) {
				for(int k=0;k<8;k++) {
					if( (j&1 && k&1) || ((j>>1)&1 && (k>>1)&1) || ((j>>2)&1 && (k>>2)&1) )s[i][j] += s[i-1][k];
				}
				s[i][j] %= 10007;
			}
		}
	}
	
	int sum;
	for(int i=0;i<8;i++) {
		sum  += s[n][i];
	}
	sum %= 10007;
	
	printf("%d\n", sum);
	
	return 0;
}

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

//#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
/* }}} */
signed main() 
{
  int w,a,b;
  cin>>w>>a>>b;
  if(a+w<b) print(b-a-w);
  else if(b+w<a) print(a-b-w);
  else print(0);

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
using namespace std;

typedef long long ll;

typedef pair< ll, ll > P;

struct edge
{
  ll to, cap, cost, rev;
};

const int INF = 1 << 29;
const int INF2 = 400000;
const int MAX_N = 1100;
const int MAX_V = 10010;

int V = MAX_V;
vector< edge > G[MAX_V];
ll h[MAX_V];
ll dist[MAX_V];
ll prevv[MAX_V], preve[MAX_V];

void add_edge(int from, int to, int cap, int cost)
{
  G[from].push_back((edge){to, cap, cost, G[to].size()});
  G[to].push_back((edge){from, 0, -cost, G[from].size() - 1});
}

ll min_cost_flow(int s, int t, ll f)
{
  ll res = 0;
  fill(h, h + V, 0);

  while (f > 0)
  {
    priority_queue< P, vector< P >, greater< P > > que;
    fill(dist, dist + V, INF);
    dist[s] = 0;
    que.push(P(0, s));

    while (!que.empty())
    {
      P p = que.top();
      que.pop();

      int v = p.second;

      if (dist[v] < p.first)
        continue;

      for (int i = 0; i < (int)G[v].size(); i++)
      {
        edge &e = G[v][i];

        if (e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to])
        {
          dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
          prevv[e.to] = v;
          preve[e.to] = i;
          que.push(P(dist[e.to], e.to));
        }
      }
    }

    if (dist[t] == INF)
      return -1;

    for (int v = 0; v < V; v++)
      h[v] += dist[v];

    ll d = f;
    for (int v = t; v != s; v = prevv[v])
      d = min(d, G[prevv[v]][preve[v]].cap);

    f -= d;
    res += d * h[t];

    for (int v = t; v != s; v = prevv[v])
    {
      edge &e = G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap += d;
    }
  }

  return res;
}

int f[MAX_N][MAX_N];

int main()
{
  int n, m;
  scanf("%d%d", &n, &m);

  const int s = 0, t = n;

  for (int i = 0; i < n; i++)
    fill(f[i], f[i] + n, INF);

  for (int i = 0; i < m; i++)
  {
    int x, y, c;
    scanf("%d%d%d", &x, &y, &c);

    f[x][y] = -c;
    add_edge(x, y, INF, -c);
    add_edge(x, y, 1, -c - INF2);
  }

  for (int k = 0; k < n; k++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        f[i][j] = min(f[i][j], f[i][k] + f[k][j]);

  add_edge(n - 1, t, INF, -f[0][n - 1]);

  printf("%lld\n", min_cost_flow(s, t, INF2) + INF2 * m);

  return 0;
}



Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long a_I, long long a_O, long long a_T, long long a_J, long long a_L, long long a_S, long long a_Z){
	ll res = a_I/2*2+a_O+a_J/2*2+a_L/2*2;
	if (a_I > 0 && a_J > 0 && a_L > 0) res = max(res, (a_I-1)/2*2+a_O+(a_J-1)/2*2+(a_L-1)/2*2+3);
	cout << res << endl;
}

int main(){	
	long long a_Z;
	long long a_S;
	long long a_L;
	long long a_J;
	long long a_T;
	long long a_O;
	long long a_I;
	scanf("%lld",&a_I);
	scanf("%lld",&a_O);
	scanf("%lld",&a_T);
	scanf("%lld",&a_J);
	scanf("%lld",&a_L);
	scanf("%lld",&a_S);
	scanf("%lld",&a_Z);
	solve(a_I, a_O, a_T, a_J, a_L, a_S, a_Z);
	return 0;
}



Measured memory_bytes: 256
using static System.Math;
using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var c = new int[n, n + 1];
            for (int i = 0; i < n; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                for (int j = 0; j < n + 1; j++)
                    c[i, j] = int.Parse(line[j]);
            }
            getAns(n, c);
        }
    }
    static void getAns(int n, int[,] c)
    {
        var imax = 1 << n;
        var dp = new int[imax];
        for (int i = 0; i < imax; i++) dp[i] = int.MaxValue;
        dp[0] = 0;
        for (int i = 0; i < imax; i++)
        {
            var bon = new List<int>();
            var boff = new List<int>();
            for (int j = 0; j < n; j++)
            {
                if (((i >> j) & 1) == 1) bon.Add(j);
                else boff.Add(j);
            }
            foreach (var x in boff)
            {
                var ptime = c[x, 0];
                foreach (var y in bon) ptime = Min(ptime, c[x, y+1]);
                var targ = i | (1 << x);
                dp[targ] = Min(dp[targ], dp[i] + ptime);
            }
        }
        Console.WriteLine(dp[imax -1]);
    }
}



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

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

set<string> ans;
string s;

int n;
void dfs(int d, int m) {
    if (d == n) {
        cout << s << endl;
        return;
    }
    for (int i = 0; i <= m; ++i) {
        s[d] = 'a' + i;
        dfs(d + 1, max(i + 1, m));
    }
}

int main() {
    cin >> n;
    s = string(n, 'a');
    dfs(0, 0);

    return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

ll a[100005],b[100005];

int main()
{ios_base::sync_with_stdio(false);
int n;
cin>>n;
rep(i,0,n)cin>>a[i];
rep(i,0,n-1)cin>>b[i];

ll ans=0;

ans+=min(a[0],b[0]);
b[0]-=min(a[0],b[0]);

rep(i,1,n-1)
{
	ans+=min(b[i-1],a[i]);
	a[i]-=min(b[i-1],a[i]);
	ans+=min(b[i],a[i]);
	b[i]-=min(b[i],a[i]);
}

ans+=min(b[n-1],a[n]);

ol(ans);

return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
void cxxio() {
    ios::sync_with_stdio(false);
    cin.tie(0);
}
#define forn(i,n) for (int i=0; i<int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back

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

const int K=30000;

vi solve(int n) {
    if (n==3) return {2,3,25};
    vi ans{2,4,3,9};
    int k=ans.size();
    for (int x=10; x<=K && k+2<=n; x+=6) {
        ans.pb(x-2);
        ans.pb(x);
        k+=2;
    }
    for (int x=21; x<=K && k+2<=n; x+=12) {
        ans.pb(x-6);
        ans.pb(x);
        k+=2;
    }
    for (int x=6; x<=K && k+1<=n; x+=6) {
        ans.pb(x);
        k+=1;
    }
    return ans;
}

bool check(int n, const vi& xs) {
    if (n!=(int)xs.size()) return false;
    ll hi=*max_element(all(xs));
    if (hi>K) return false;
    ll d=0;
    for (int x:xs) d=gcd(d, x);
    if (d!=1) return false;
    ll sum=accumulate(all(xs), 0ll);
    for (int x:xs)
        if (gcd(x, sum-x)<=1) return false;
    return true;
}

int main() {
    cxxio();
    for (int i=3; 0&&i<=20000; i++) {
        cout<<"i="<<i<<'\n';
        cout.flush();
        assert(check(i, solve(i)));
    }
    int n;
    cin>>n;
    vi xs=solve(n);
    forn(i, n)
        cout << xs[i] << " \n"[i+1==n];
}


Measured memory_bytes: 640
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int v1, v2;
		int n;
		HashMap<Integer, Integer> map;
		boolean flag;

		while (sc.hasNext()) {
			map  = new HashMap<Integer, Integer>();
			flag = true;
			n = 0;
			v1 = sc.nextInt();
			v2 = sc.nextInt();
			while (v1 + v2 != 0) {
				if (map.get(v1) == null) {
					map.put(v1, 1);
					n++;
				} else {
					map.put(v1, map.get(v1) + 1);
				}
				if (map.get(v2) == null) {
					map.put(v2, 1);
					n++;
				} else {
					map.put(v2, map.get(v2) + 1);
				}

				v1 = sc.nextInt();
				v2 = sc.nextInt();
			}
			if (map.get(1) % 2 != 1 || map.get(2) % 2 != 1) {
				flag = false;
			}
			for (int i = 3; i <= n; i++) {
				if (map.get(i) % 2 != 0) {
					flag = false;
				}
			}

			System.out.println(flag ? "OK" : "NG");
		}
	}
}

Measured memory_bytes: 12000
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;


int main(){
  ll dp[10][1001];
  memset(dp,0,sizeof(dp));
  dp[0][0] = 1;
  for(int num=0;num<=100;num++){
    for(int i=9;i>0;i--){
      for(int to=1000;to-num>=0;to--){
	dp[i][to] += dp[i-1][to-num];
      }
    }
  }

  int n,s;
  while(~scanf("%d %d",&n,&s)){
    if(n==0 && s==0) break;
    printf("%lld\n",dp[n][s]);
  }
}

Measured memory_bytes: 1276
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

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

using namespace std;

int main(){
    int A, B;
    int tmp;
    cin >> A >> B;

    tmp = (A+B) / 2;
    
    if (abs(A-tmp) == abs(B-tmp)){
        cout << tmp << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}



Measured memory_bytes: 256
a = input().split(" ")
a =[int(i) for i in a]
H = a[0]
N = a[1]

b = input().split(" ")
b =[int(i) for i in b]

for i in b:
    H = H - i

if H<=0:
    print("Yes")
else:
    print("No")
    

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n,a,b;
    cin >> n >> a >> b;
    if((a - b) % 2 == 0){
        ANS(abs(a-b)/2);
    }else{
        ANS(min((a+b-1)/2,(2*n-a-b+1)/2));
    }
    return 0;
}

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

using namespace std;

int main()
{
    int a, b, c, d;
    cin >>a>>b>>c>>d;
    while(1){
        c -= b;
        if(c<= 0){
            cout << "Yes" << endl;
            break;
        }
        a-=d;
        if(a<=0){
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}


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

#define all(x)        (x).begin(),(x).end()
#define eb            emplace_back
#define mp            make_pair
#define pb            push_back
#define fi            first
#define se            second
#define sz(x)         ((int)(x).size())
#define rep(x,y,z)    for(int x=y;x<z;x++)
#define per(x,z,y)    for(int x=z-1;x>=y;x--)
#define trav(y,x)     for(auto& y:x)
#define pii           pair<int, int>
#define pll           pair<ll, ll>
#define vi            vector<int>
#define vpi           vector<pii>

int dbg = 0;
#define cri           if(0)
#define shame         cri cerr<<(++dbg)<<"\n\n";

// aaaaaaaaaaaaaaaa
const int N = 2e5 + 1;
const int lg = 20;
const ll mod = 0xfffff;

void solve() {
  int n, m;
  scanf("%d%d", &n, &m);
  int cnt = 0, sm = 0;
  vi a(n);
  rep(i, 0, n) {
    scanf("%d", &a[i]);
    sm += a[i];
  }
  rep(i, 0, n)
    if ((4 * m * a[i]) >= sm)
      cnt++;
  printf("%s\n", cnt >= m ? "Yes" : "No");
}

int main() {
  // int _; scanf("%d", &_) while (_--)
  solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) begin(x),end(x)
#define F(i,n) for (int i = 0; i < n; ++i)
#define F1(i,n) for (int i = 1; i <= n; ++i)
#define dbg(x) cerr << #x << " = " << x << endl
#define dbgg(x) cerr << #x << " = " << x << ' '
#define T(x) x[pool]
#define mineq(x,y) { if ((x) > (y)) (x) = (y); }
#define maxeq(x,y) { if ((x) < (y)) (x) = (y); }
#define MEOW cout << "meowwwww" << '\n'; system("pause");
#define int long long
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;

template<typename T>
ostream& operator <<(ostream &s, const vector<T> &c)
{
	s << "[ "; for (auto it : c) s << it << " "; s << "\b]\n";
	return s;
}

template<typename T>
ostream& operator <<(ostream &s, const pair<int, T> &c)
{
	s << "[ "; cout << c.fi << " , " << c.se << " ] ";
	return s;
}

const int maxn = 234567;
int n;
long double a[maxn], A[maxn];
long double b[maxn], B[maxn];
int l[maxn];
int r[maxn];
bool isb[maxn];

void input()
{
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	F1 (i, n) cin >> A[i];
	F1 (i, n) cin >> B[i];
}

void solve()
{
	pair<long double, int> pos = mp(0, 0);
	F1 (i, n) pos = max(pos, mp(A[i], i));
	F1 (i, n) a[(i - pos.se + n) % n] = A[i];
	F1 (i, n) b[(i - pos.se + n) % n] = B[i];
	
	long double mx = pos.fi;
	a[n] = a[0], b[n] = b[0];
	for (int i = n; i >= 1; --i) a[i] -= a[i - 1];
	a[0] = 0;
	for (int i = n; i >= 1; --i) a[i] -= a[i - 1];
//F1 (i, n) dbgg(a[i]);
//dbg("");
	queue<int> q;
	F1 (i, n) if (a[i] >= b[i - 1] * 2) q.push(i);
	F1 (i, n) l[i] = i - 1; 
	F1 (i, n) r[i] = i + 1;

	while (!q.empty())
	{
		int cur = q.front();
//dbg(cur);
		q.pop();
		if (isb[cur]) continue;
		isb[cur] = true;
		int x = l[cur], y = r[cur];
		// a[cur] - b[cur - 1] * 2 = k + t
		// k * (cur - x) = t * (y - cur)
		if (x >= 1)
		{
			a[x] += (a[cur] - b[cur - 1] * 2) * (y - cur) / (y - x);
			if (a[x] >= b[x - 1] * 2) q.push(x);
		}
		if (y <= n)
		{
			a[y] += (a[cur] - b[cur - 1] * 2) * (cur - x) / (y - x);
			if (a[y] >= b[y - 1] * 2) q.push(y);
		}
		a[cur] = b[cur - 1] * 2;
		r[l[cur]] = r[cur];
		l[r[cur]] = l[cur];
	}
//dbg(mx);
	F1 (i, n) a[i] += a[i - 1];
	a[0] = mx;
	F1 (i, n) a[i] += a[i - 1];
//F1 (i, n) dbgg(a[i]);
//dbg("");
	F1 (i, n) a[i] += a[i - 1];
	cout << setprecision(20) << a[n - 1] / n << '\n';
}

main()
{
	input();
	solve();
}


Measured memory_bytes: 20372
// #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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
#define gcd(a,b) __gcd(a,b)
#define ll long long int
#define ld unsigned long long int
#define pi pair<ll,ll>
#define pb push_back
#define pf push_front
#define pu push
#define po pop
#define fi first
#define se second
#define mk make_pair
#define ve vector
#define lr(n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define be begin
#define sz(a) (ll)a.size()
#define INF 1e18
 
typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
 
// ll mod=998244353;
// ll gcd(ll a, ll b){
//     if(a<b) swap(a,b);
//     if(b==0) return a;
//     return gcd(b,a%b);
// }
 
// ll fun(ll x, ll y){
//     ll rem=1;
//     while(y!=0){
//         if(y%2==1){
//             rem=(rem*x)%mod;
//         }
//         x=(x*x)%mod;
//         y/=2;
//     }
//     return rem;
// }

ll n,m;
ve<ve<ll>>ar(100001);
ll dp[100001];

void dfs(ll x){
	if(dp[x]!=-1) return;
	dp[x]=0;
	for(auto i:ar[x]){
		if(dp[i]==-1)
			dfs(i);
		dp[x]=max(dp[x],dp[i]+1);
	}
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	for(ll i=0,u,v;i<m;i++){
		cin>>u>>v;
		ar[u].pb(v);
	}
	for(ll i=1;i<=n;i++) dp[i]=-1;
	ll ans=0;
	for(ll i=1;i<=n;i++){
		dfs(i);
		ans=max(ans,dp[i]);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 8576
def list_eq(get_num, first):
    if first == 1:
        return False
    for i in range(len(get_num)-1):
        if get_num[0] != get_num[i+1]:
            return False
    return True

a_raw = input().split(' ')
b_raw = input().split(' ')
a = [int(n) for n in a_raw]
b = [int(n) for n in b_raw]


get_num = [0 for _ in range(a[0])]
first=1
next_num=0
res=0

while list_eq(get_num, first) == False:
    first=0
    weight = []
    for i in range(a[1]):
        weight.append(b[next_num])
        get_num[next_num] += 1
        next_num+=1
        if next_num > a[0]-1:
            next_num = 0
    res+=max(weight)-min(weight)
print(res)


Measured memory_bytes: 5636
import java.util.Scanner;

public class Main {

	static void show(boolean b){
		if(b) System.out.println("Yes");
		else System.out.println("No");
	}

	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        boolean result = false;

        //Number of total amounts
        int n = sc.nextInt();

        if(n % 4 == 0 || n % 7 == 0){
        	result = true;
        }
        else{
        	int x = 1;
        	while(4*x < n){
        		if((n - 4*x) % 7 == 0){
        			result = true;
        			break;
        		}
        		x++;
        	}
        }

        show(result);
	}
}

Measured memory_bytes: 23380
//#include "grader.h"
#include <bits/stdc++.h>  

using namespace std;
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define re return
#define fi first
#define mp make_pair
#define se second
#define sz(a) (int)a.size()
#define prev previ
#define tm tmmm
#define div divv
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const ll mod = ll(1e9) + 9LL, pr = 239, mod2 = ll(1e9) + 7;

ll n, a, b, c, d, gr[1000000];
vector<int> e[1000000];

void dfs(int nu, int p) {
	gr[nu] = 0;
	for (int v : e[nu])
		if (v != p) {
			dfs(v, nu);
			gr[nu] ^= (gr[v] + 1);
		}
}
int main() {
	iostream::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	forn (i, n- 1) {
		cin >> a >> b;
		a--;
		b--;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	dfs(0, -1);
	if (gr[0]) cout << "Alice";
	else
		cout << "Bob";
}

Measured memory_bytes: 34176
import bisect
 
n = int(input())
a = list(map(int,input().split()))
a.sort()

ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        index = bisect.bisect_left(a,a[i]+a[j])
        ans += index-j-1
        
print(ans) 
            

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


int main()
{
	int l, m[12], n[12];
	while (cin >> l && l != 0)
	{
		for (int i = 0; i < 12; i++)
			cin >> m[i] >> n[i];
		for (int i = 0; i < 12; i++)
		{
			l -= (m[i] - n[i]);
			if (l <= 0)
			{
				cout << i + 1 << endl;
				break;
			}
			if (i == 11)
				cout << "NA" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3076