akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//18:45-
int reset(int x[5], int y[6]) {
	int i;
	x[4] = 9;
	for(i = 3; i >= 0; i -= 1) {
		x[i] = x[i + 1] * 9;
	}
	y[5] = 6;
	for(i = 4; i >= 0; i -= 1) {
		y[i] = y[i + 1] * 6;
	}
	return 0;
}

int main(void) {
	int i;
	int N, n, remain;
	int tot_x, tot_x_min;
	int x[5], y[6];
	char buf[128], *ch;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	N = atoi(ch);

	reset(x, y);
	tot_x_min = N;
	for(n = 0; n <= N; n += 1) {
		tot_x = 0;
		remain = n;
		for(i = 0; i < 6; i += 1) {
			while(remain >= y[i]) {
				remain -= y[i];
				tot_x += 1;
			}
		}
		//tot_x += remain;

		remain += N - n;
		for(i = 0; i < 5; i += 1) {
			while(remain >= x[i]) {
				remain -= x[i];
				tot_x += 1;
			}
		}
		tot_x += remain;
		if(tot_x < tot_x_min) {
			tot_x_min = tot_x;
		}
	}
	printf("%d\n", tot_x_min);

	return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;

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

  string S;
  cin >> S;

  if(S == "Sunny") {
    cout << "Cloudy" << endl;
  }

  if (S == "Cloudy") {
    cout << "Rainy" << endl;
  }

  if (S == "Rainy") {
    cout << "Sunny" << endl;
  }
  return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, n) for (int i = 1; i < (int)(n+1); i++)
#define rep4(i, s, n) for (int i = (s); i < (int)(n+1); i++)
#define repr(i,n) for (int i = (n-1); i>=0;i--)
#define repr2(i,s,n) for (int i = (n-1); i>=(int)(s);i--)
#define repr3(i,n) for(int i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Grid = vector<vector<int>>;
const ll INF = 10011032323450010;
const ld PI = 3.14159265358979323846;



long long gcd(long long a, long long b) { // 2つの場合の最大公約数
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}
 
long long gcd_vec(vector<long long> const &A) { // N個の要素に対する最大公約数
    int size = (int)A.size();
    long long ret = A[0];
    for (int i = 1; i < size; i++) {
        ret = gcd(ret, A[i]);
    }
    return ret;
}

int main() {
    int N;
    cin>>N;
    vector<ll> A(N);
    rep(i,N){
        cin>>A[i];
    }
    
cout<<gcd_vec(A)<<endl;


return 0;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(n, m);

    vi dp(n+1, 0);

    vector<int> data(m);
    for (int i = 0; i < m; i++) {
        cin >> data[i];
        dp[data[i]] = -1;
    }
 
    dp[0] = 1;
    rep(i, n) {
        if (dp[i] != -1) {
            if (in(i+1, 0, n+1) && dp[i+1] != -1) {
                dp[i+1] = (dp[i+1] + dp[i]) % MOD;
            }
            if (in(i+2, 0, n+1) && dp[i+2] != -1) {
                dp[i+2] = (dp[i+2] + dp[i]) % MOD;
            }
        }
    }

    std::cout << dp[n] << std::endl;

    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(void)
{
	int i,j,k[101],jun[300],n,a,b,c,d,temp,min=10000,max=-1;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		k[i]=0;
	}
	for(i=0;i<n*(n-1)/2;i++){
		scanf("%d %d %d %d",&a,&b,&c,&d);
		if(c>d){
			k[a-1]+=3;
		}
		if(c<d){
			k[b-1]+=3;
		}
		if(c==d){
			k[a-1]+=1;
			k[b-1]+=1;
		}
	}
	for(i=0;i<n;i++){
		if(max<k[i]){
			max=k[i];
		}
		if(min>k[i]){
			min=k[i];
		}
	}
	for(i=min;i<=max;i++){
		jun[i]=0;
	}
	for(i=0;i<n;i++){
		jun[k[i]]++;
	}
	jun[max+1]=1;
	for(i=max;i>=min;i--){
		jun[i]=jun[i]+jun[i+1];
	}
	for(i=0;i<n;i++){
		printf("%d\n",jun[k[i]+1]);
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>
#include <regex>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define P pair<int, int>

using namespace std;
using ll = int64_t;

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

void solve(){
    int N, W;
    cin >> N >> W;
    int v[N], w[N];
    rep(i, N) cin >> v[i] >> w[i];

    int dp[N+1][W+1];
    memset(dp, 0, sizeof(dp));

    for(int i = 0; i < N; i++){
        for(int j = 0; j <= W; j++){
            if(j >= w[i]) dp[i+1][j] = max(dp[i][j-w[i]] + v[i], dp[i][j]);
            else dp[i+1][j] = dp[i][j];
        }
    }

    cout << dp[N][W] << endl;
}

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


Measured memory_bytes: 7044
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD =1e9+7;
using ll=long long;
int n, cnt;
string s, t;
int main(){
  cin >> n >> s >> t;
  for(int i = 1; i <= min(s.size(), t.size()); i++){
    string sa = s.substr(s.size() - i, i);
    string ta = t.substr(0, i);
    if(sa == ta) cnt = i;
  }
  if(s == t) cout << s.size() << endl;
  else cout << s.size() + t.size() - cnt << endl; 
}


Measured memory_bytes: 256
(function (input) {
    var inputs = input.replace(/\r/g, '').split("\n"),
        data = [],
        n, line, max_index, a, b;

    n = parseInt(inputs.shift());

    max_index = 101;
    max_value = -1;
    while ( n-- ) {
        line = inputs.shift().split(' ');
        a = parseInt(line[0]);
        b = parseInt(line[1]);

        if ( b > max_value || b === max_value && a < max_index ) {
            max_index = a;
            max_value = b;
        }
    }
    console.log(max_index+" "+max_value);

})(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    int ary[n];
    rep(i, n) cin >> ary[i];

    int ary2[n];
    // copy(ary.begin(), ary.end(), ary2.begin());
    rep(i,n) ary2[i] = ary[i];
    sort(ary2, ary2+n);
    int first_num = ary2[n-1];
    int second_num = ary2[n-2];

    rep(i,n) {
        if (ary[i] == first_num) {
            cout << second_num << endl;
        }
        else
        {
            cout << first_num << endl;
        }
        
    }
}


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

int main() {
    int n, m;
    cin >> n >> m;
    int town[n];
    for (int i = 0; i < n; i++) {
        town[i] = 0;
    }
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        town[--a]++;
        town[--b]++;
    }
    for (int i = 0; i < n; i++) {
        cout << town[i] << endl;
    }
}

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

using namespace std;
int a,b,c,x;
float f[301][301][301];

int n;

float F(int a,int b,int c)
{
  //  cerr<<a<<b<<c<<endl;
    if(a+b+c==0) return 0;
    if(f[a][b][c]!=0) return f[a][b][c];

    f[a][b][c]=n*1.0/(a+b+c);

    float res;


    if(a>0) f[a][b][c]+=a*1.0/(a+b+c)*F(a-1,b,c);
    if(b>0) f[a][b][c]+=b*1.0/(a+b+c)*F(a+1,b-1,c);
    if(c>0) f[a][b][c]+=c*1.0/(a+b+c)*F(a,b+1,c-1);

   // f[a][b][c]-=res;
   // cerr<<res<<endl;
    return f[a][b][c];
}

int main()
{

    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        if(x==1) a++;
        if(x==2) b++;
        if(x==3) c++;
    }
    //cerr<<f[1][1][0]<<endl;
    cout<<setprecision(14)<<F(a,b,c);
    //cout<<f[2][1][0]<<endl;
}


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

using namespace std;
typedef long long int lli;
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
typedef pair<lli, lli> pii;
#define ff first
#define ss second
#define MOD 1000000007
#define pb push_back
#define EPS 1e-6
const lli MAX = 1e9 + 7;

int main()
{
    fast;
    int t = 1;
    while (t--)
    {
        lli n;
        cin >> n;
        vector<lli> a(n);
        lli ans = 0;
        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
            if (i > 0 && a[i - 1] > a[i])
            {
                ans += (a[i - 1] - a[i]);
                a[i] = a[i - 1];
            }
            //cout << a[i] << " ";
        }
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 4768
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(ll (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

class unionfind {
    VI par, rank;
public:
    void init(int N) {
        par.clear();
        rank.clear();
        for (int i = 0; i < N; i++) par.push_back(i);
        for (int i = 0; i < N; i++) rank.push_back(1);
    }
    int root(int x) {
        if (par[x] == x)return x;
        return par[x] = root(par[x]);
    }
    int size(int x) {
        if (par[x] == x)return rank[x];
        return size(par[x]);
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)return;
        if (rank[rx] < rank[ry]) {
            par[rx] = ry;
            rank[ry] += rank[rx];
        }
        else {
            par[ry] = rx;
            rank[rx] += rank[ry];
        }
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
};

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

    int n, m;
    cin >> n >> m;

    map<int, int> p;
    int in;
    FOR(i, 0, n) {
        cin >> in;
        p[--in] = i;
    }

    unionfind uf;
    uf.init(n);
    int x, y;
    FOR(i, 0, m) {
        cin >> x >> y;
        uf.unite(--x, --y);
    }

    int ans = 0;
    FOR(i, 0, n)if (uf.same(i, p[i]))ans++;
    cout << ans << "\n";
}

Measured memory_bytes: 6140
n=list(input())
nset=set(n)
if len(n)==1:
    if nset.issubset(set("24579")):
        print('hon')
    if nset.issubset(set("0168")):
        print("pon")
    if nset.issubset(set("3")):
        print("bon")

if len(n)==2:
    nset=set(n[1])
    if nset.issubset(set("24579")):
        print('hon')
    if nset.issubset(set("0168")):
        print("pon")
    if nset.issubset(set("3")):
        print("bon")

if len(n)==3:
    nset=set(n[2])
    if nset.issubset(set("24579")):
        print('hon')
    if nset.issubset(set("0168")):
        print("pon")
    if nset.issubset(set("3")):
        print("bon")

Measured memory_bytes: 9140
#include<bits/stdc++.h>
using namespace std;
const int INF=1001001001;
int N;
int t[10000];

int dp[2][5010][2];

int main(){
    cin>>N;
    for(int i=0;i<N-1;i++)cin>>t[i];

    fill_n(**dp,2*5010*2,INF);
    dp[0][0][0]=dp[0][1][1]=0;

    for(int i=0;i<N-1;i++){
        for(int j=0;j<=N/2;j++){
            dp[(i+1)&1][j][0]=min(dp[i&1][j][0],dp[i&1][j][1]+t[i]);
            if(j)dp[(i+1)&1][j][1]=min(dp[i&1][j-1][0]+t[i],dp[i&1][j-1][1]);
        }
        for(int j=0;j<=N/2;j++){
            dp[i&1][j][0]=dp[i&1][j][1]=INF;
        }
    }

    cout<<min(dp[(N-1)&1][N/2][0],dp[(N-1)&1][N/2][1])<<endl;
    return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define hi cout<<'h'<<'i'<<'\n' 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;

    string s;
    cin>>s;
    vi v;
    if(s[0]=='<') v.pb(-1);
    else v.pb(1);
    n=s.size();
    rep(i,1,n)
    {
        if(s[i]=='<')
        {
            if(v.back()<0)v.back()--;
            else v.pb(-1);
        }
        else
        {
            if(v.back()>0)v.back()++;
            else v.pb(1);
        }
    }
    //print(v);
    vi ans;
    int last=0;

    for(auto z:v)
    {
        if(z<0)
        {
            z=-z;
            int c=0;
            while(z--)
            {
                ans.pb(c++);
            }
            last=c;
        }
        else
        {
            ans.pb(max(last,z));
            while(z-- && z>0)
            {
                ans.pb(z);
            }
        }
    }
    //print(ans);
    ll sum=0;
    for(auto z:ans)sum+=z;
    if(s.back()=='<')sum+=last;
    cout<<sum;

    return 0;
}



Measured memory_bytes: 3864
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

using G = vector<vector<int>>;
G graph;
vector<int> distf, dists;

void dfs(int from, vector<int>& v, int p = -1){
    for(int to : graph[from]){
        if(to == p) continue;
        v[to] = v[from] + 1;
        dfs(to, v, from);
    }
}

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

    int n;
    cin >> n;
    graph.resize(n);
    distf.resize(n);
    dists.resize(n);
    for(int i = 0; i < n - 1; ++i){
        int a, b;
        cin >> a >> b;
        --a, --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    distf[0] = 0;
    dfs(0, distf);
    dists[n - 1] = 0;
    dfs(n - 1, dists);
    int cntf = 0, cnts = 0;
    for(int i = 0; i < n; ++i){
        if(distf[i] <= dists[i])    ++cntf;
        else    ++cnts;
    }
    if(cntf > cnts) cout << "Fennec\n";
    else    cout << "Snuke\n";
}

Measured memory_bytes: 12800
#include <iostream>
#include <string>
#include <math.h> 
#include <algorithm>
using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  
  if (A+B==3) cout << 3 << endl;
  if (A+B==4) cout << 2 << endl;
  if (A+B==5) cout << 1 << endl;

  return 0;
}


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);

int main() {
  int n, m, k;
  cin >> n >> m >> k;

  mint ans = 0;
  mint col = m;
  rrep(i, n){
  	if(i<=k) ans += col * c(n-1, i);
  	col *= m-1;
  }

  // mint ans = 0;
  // mint col = m;
  // for (int x = n-1; x >= 0; --x) {
  //   mint now = col;
  //   now *= c(n-1,x);
  //   if (x <= k) ans += now;
  //   col *= m-1;
  // }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6228
s=input()

if s[:1]=="k" and s[len(s)-6:]=="eyence":
    print("YES")
elif s[:2]=="ke" and s[len(s)-5:]=="yence":
    print("YES")
elif s[:3]=="key" and s[len(s)-4:]=="ence":
    print("YES")
elif s[:4]=="keye" and s[len(s)-3:]=="nce":
    print("YES")
elif s[:5]=="keyen" and s[len(s)-2:]=="ce":
    print("YES")
elif s[:6]=="keyenc" and s[len(s)-1:]=="e":
    print("YES")
elif s[:7]=="keyence":
    print("YES")
elif s[len(s)-7:]=="keyence":
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int k=0,c=0;

	while(sc.hasNext()){
	    k = sc.nextInt();
	    if(k==0) break;

	    for(int i = 0;i<k*(k-1)/2;i++) c += sc.nextInt();
	    
	    System.out.println(c/(k-1));
	    c = 0;
	}
    }
}

Measured memory_bytes: 61884
try:
    a = int(input())
    # すべての桁の数が同じ数値の配列を作成
    nums = [111, 222, 333, 444 ,555 ,666, 777, 888, 999]
    # パラメータの数値より大きくて最小の値を出力
    print(min(list(filter(lambda x : x >= a, nums))))
except EOFError:
    pass


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

using namespace std;

int main()
{
    set <int> m;
    int q;
    cin>>q;
    while(q--)
    {
        int a;
        cin>>a;
        if(a==0)
        {
            int x;
            cin>>x;
            m.emplace(x);
            cout<<m.size()<<endl;
        }
        else if(a==1)
        {
            int x;
            cin>>x;
            cout<<m.count(x)<<endl;
        }
        else if(a==2)
        {
            int x;
            cin>>x;
            m.erase(x);
        }
        else
        {
            int l,r;
            cin>>l>>r;
            auto p=m.lower_bound(l);
            while(p!=m.end()&&*p<=r)
            {
                cout<<*p<<endl;
                p++;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 12356
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define	pii pair<int,int>
#define vi vector<int>
#define all(x) x.begin(),x.end()
#define len(a) (int)a.length()

int main()
{
	string s,t;	cin>>s>>t;
	int n = len(s), m=len(t);
	int dp[n+1][m+1];
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++)
			if(i==0 || j==0)	dp[i][j] = 0;
			else if(s[i-1]==t[j-1])	dp[i][j] = 1+ dp[i-1][j-1];
			else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
	}
	string st="";
	int i=n,j=m;
	while(i>0 && j>0)
	{
		if(s[i-1]==t[j-1])
		{
			st+=s[i-1];
			i--,j--;
		}
		else if(dp[i-1][j]>dp[i][j-1])	i--;
		else j--;
	}
	reverse(all(st));
	cout<<st<<endl;
	return 0;
}

Measured memory_bytes: 35456
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll N; cin >> N;
    vector<ll> X(N); for(auto& in:X) cin >> in;
    vector<ll> T = X;
    sort(X.begin(),X.end());
    ll l = N/2 - 1;
    for(int i = 0; i < N;i++){
        if(T[i] <= X[l]){
            cout << X[l+1] << endl;
        }else{
            cout << X[l] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 5376
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_1_D&lang=jp
# Vector II

from collections import deque
import sys
input = sys.stdin.readline

def loop_proc():
    (n1,n2) = map(int,input().split())
    wl =[]
    for i in range(n1):
        wl.append(deque())
    for i in range(n2):
        l = list(map(int,input().split()))  
        if (l[0] == 0 ):
            wl[l[1]].append(l[2])
        elif (l[0] == 1 ):
            if ( len(wl[l[1]]) == 0 ):
                print ("")
            else:
                print (" ".join(map(str,wl[l[1]])))
        elif (l[0] == 2 ):
            wl[l[1]] = deque()
 

loop_proc()





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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    string r, g, b;
    cin >> r >> g >> b;
    string rgb = r + g + b;
    cout << (stoi(rgb) % 4 == 0 ? "YES" : "NO") << '\n';
}

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


Measured memory_bytes: 256
#include <algorithm>
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
int main()
{
    ll n,a,b,ma,mi;
    cin>>n>>a>>b;
    a--,b--,n--;
    if(a>b)swap(a,b);
    if((b-a)%2==0)
        cout<<(b-a)/2;
    else {
        if(n-b<a)
            a=n-a,b=n-b,swap(a,b);
      cout<<a+(b-a+1)/2;
    }

}


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

int main(){
  int n,s=0,p=1;
  cin>>n;
  int m=n;
  
  for(int i=8;i>0;i--){
    p=1;
    for(int j=0;j<i;j++)
      p*=10;
    s+=n/p;
    n-=(n/p)*p;
  }
  
  if(m%(s+n)==0)
    cout << "Yes"<<endl;
  else
    cout << "No"<<endl;
}
    

Measured memory_bytes: 256
open Batteries
let n = read_int ()
let a = read_line () |> String.split_on_char ' ' |> List.map int_of_string
let all = List.fold_left (fun a b -> a lxor b) 0 a
let rec loop lst =
  match lst with
  | [] -> print_string "\n"
  | first :: rest ->
    Printf.printf "%d " (all lxor first); loop rest
let _ = loop a

Measured memory_bytes: 26256
list1=["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"]
list2=["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"]

list3=[0]*26
while True:
    try:
        S=input()
        for i in range(len(S)):
            for j in range(26):
                if S[i]==list1[j]:
                    list3[j]+=1
                if S[i]==list2[j]:
                    list3[j]+=1
        #print(list3)
    except EOFError:
        break
for k in range(26):
    print(list1[k]+" : "+str(list3[k]))
    


Measured memory_bytes: 5568
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n)i++)
typedef long long ll;
using namespace std;
int main(){
  string s;
  auto flag  = false;
  cin >> s;
  for(int i=0;i<2;i++){
    if(s.at(i) == s.at(i+1) && s.at(i+1) == s.at(i+2))
    { flag = true;break;}
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" <<endl;

}


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

int main() {
  int n;
  cin>>n;
  string t;
  cin>>t;
  char s[n];
  for (int i=0; i<n; i++) s[i] = t[i];
  int q;
  cin>>q;
  set<int> m[26];
  for (int i=0; i<n; i++) {
    m[s[i]-'a'].insert(i);
  }
  for (int _=0; _<q; _++) {
    int type;
    cin>>type;
    if (type == 1) {
      int i; char c;
      cin>>i>>c;
      --i;
      char prev = s[i];
      m[prev-'a'].erase(i);
      m[c-'a'].insert(i);
      s[i] = c;
      continue;
    }
    int l, r;
    cin>>l>>r;
    --l; --r;
    int cnt = 0;
    for (int i=0; i<26; i++) {
      char c = 'a' + i;
      auto it = m[c-'a'].lower_bound(l);
      if (it != m[c-'a'].end()) {
        if (*it <= r) {
          ++cnt;
        }
      }
    }
    cout<<cnt<<endl;
  }
}

Measured memory_bytes: 24708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
ll gcd(ll a,ll b){while(b){ll tmp = a % b;a = b;b = tmp;}return a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define split_str(str, sp_word) istringstream stream(str); string res; for(int cnt = 0; getline(stream,res,sp_word); cnt++)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define digit(x) ((int)log10((double)(x)) + 1)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define out(x) for(auto i : x) cout << i << " "; cout << endl;
#define outln(x) for(auto i : x) cout << i << " " << endl;
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define MOD = 1000000007; 
#define DEBUG true

int main(){
  int n, q, k, x, y;
  cin >> n;

  vector<int> w[n + 1];
  long long d[n + 1];
  int a[n + 1], b[n + 1], c[n + 1];

  REP(i,1,n){
    cin >> a[i] >> b[i] >> c[i];
    w[a[i]].pb(i);
    w[b[i]].pb(i);
  }

  function<void(int,int)> dfs = [&](int x, int p){
    rep(i,w[x].size()){
      int u = w[x][i];
      if(a[u] == p || b[u] == p) continue;
      if(a[u] == x) {
        d[b[u]] = d[x] + c[u];
        dfs(b[u], x);
      }else{
        d[a[u]] = d[x] + c[u];
        dfs(a[u], x);
      }
    }
  }; 

  cin >> q >> k;
  d[k] = 0;
  dfs(k, 0);

  while(q--){
    cin >> x >> y;
    cout << d[x] + d[y] << endl;
  }
}

Measured memory_bytes: 18560
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func intMin(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	io := NewIo()
	defer io.Flush()
	N := io.NextInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = io.NextInt()
	}
	ans := 1000000000000000000
	c := 0
	S := 0
	for i := 0; i < N; i++ {
		S += A[i]
		if i % 2 == 0 {
			if S <= 0 {
				c += -S + 1
				S = 1
			}
		} else {
			if S >= 0 {
				c += S + 1
				S = -1
			}
		}
	}
	//Log("c", c)
	ans = intMin(ans, c)
	c = 0
	S = 0
	for i := 0; i < N; i++ {
		S += A[i]
		if i % 2 == 1 {
			if S <= 0 {
				c += -S + 1
				S = 1
			}
		} else {
			if S >= 0 {
				c += S + 1
				S = -1
			}
		}
	}
	//Log("c", c)
	ans = intMin(ans, c)
	io.PrintLn(ans)
}


Measured memory_bytes: 6912
//Single Source Shortest Path 1

#include<stdio.h>
#define N 100
#define FIR 0
#define SEC 1
#define FIN 2
#define INF 1000000

int arr[N][N],state[N],point[N];
int n,i,j,l,remain,b,weight,min;

void worktime()
{
  //initialize number
  for(i = 0; i < n; i++)
    {
      point[i] = INF;
      state[i] = FIR;
    }
  point[0] = 0;
  state[0] = SEC;

  while(1)
    {
      //initialize min
      min = INF;
      l = -1;

      //prepare for work
      for(i = 0; i < n; i++)
	{
	  if(min > point[i] && state[i] != FIN)
	    {
	      l = i;
	      min = point[i];
	    }
	}

      if(l == -1) break;
      state[l] = FIN;

      //main work
      for(b = 0; b < n; b++)
	{
	  if(state[b] != FIN && arr[l][b] != INF && point[b] > point[l] + arr[l][b])
	    {
	      point[b] = point[l] + arr[l][b];
	      state[b] = SEC;
	    }
	}
    }

  //output data
  for(i = 0; i < n; i++)
    {
      if(point[i] != INF) printf("%d %d\n",i,point[i]);
    }
}

int main()
{
  //input data
  scanf("%d",&n);
  for(i = 0; i < n; i++)
    {
      for(j = 0; j < n; j++)
	{
	  arr[i][j] = INF;
	}
    }
  for(i = 0; i < n; i++)
    {
      scanf("%d %d",&l,&remain);

      for(j = 0; j < remain; j++)
	{
	  scanf("%d %d",&b,&weight);
	  arr[l][b] = weight;
	}
    }

  worktime();
  
  return 0;
}



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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_W 100
#define MAX_H 100

ll A, B;
char Ans[MAX_H][MAX_W] = {};

signed main()
{
    cin >> A >> B;

    REP(i, MAX_H) {
        REP(j, MAX_W) {
            if(j < MAX_W / 2) { Ans[i][j] = '.'; }
            else { Ans[i][j] = '#'; }
        }
    }

    ll c_a = 1;
    ll c_b = 1;
    ll x = MAX_W / 2 +1;
    ll y = 0;
    while(c_a != A) {
        Ans[y][x] = '.';
        c_a++;
        y += 2;
        if(y >= MAX_H) { y = 0; x += 2; }
    }
    x = 0;
    y = 0;
    while(c_b != B) {
        Ans[y][x] = '#';
        c_b++;
        y += 2;
        if(y >= MAX_H) { y = 0; x += 2; }
    }

    printf("%d %d\n", MAX_W, MAX_H);
    REP(i, MAX_H) {
        REP(j, MAX_W) {
            printf("%c", Ans[i][j]);
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define NB 3000
double DP[NB];
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	cin>>n;
	double x;
	cin>>x;
	DP[0] = 1. - x;
	DP[1] = x;
	for(int i = 1; i < n; ++i) {
		cin>>x;
		for(int j = n; j>=1; j--) {
			DP[j] += DP[j - 1] * x;
			DP[j - 1] = DP[j - 1] * (1. - x);
		}
	}
	double sum = 0;
	for(int i = n/2 + 1; i <= n; i++) {
		sum += DP[i];
	}
	
	printf("%.10f\n",sum);
	return 0;
}


Measured memory_bytes: 3828
#include<stdio.h>
int main()
{
   int a,b,i,j;
   while(1){
   scanf("%d%d",&a,&b);
   if(a==0 && b==0)
    break;
   for(i=0;i<a;i++)
   {
       for(j=0;j<b;j++)
       {

        printf("#");
       }
       printf("\n");
   }
   printf("\n");

   }



}




Measured memory_bytes: 2120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vi2 = vector<vector<ll>>;
const int INF = 1e9+4;
#define REP(i,n) for(int i = 0; i < (n); i++)
#define REPS(i,n) for(int i = 1; i <= (n); i++)
template<typename T> bool chmin(T& a,const T& b){if(a>b){a=b;return true;}return false;}
template<typename T> bool chmax(T& a,const T& b){if(a<b){a=b;return true;}return false;}

int main(){
    int n,m;
    cin >> n >> m;
    vi v(n);
    vi w(n);
    int s = 0;
    REP(i,n){
        cin >> w[i] >> v[i];
        s += v[i];
    }
    vi2 dp(n+1,vi(s+1,INF));
    REP(i,n+1){
        dp[i][0] = 0;
    }
    REPS(i,n){
        REPS(j,s){
            if (v[i-1]<=j)
            {
                dp[i][j] = min(dp[i-1][j],dp[i-1][j-v[i-1]]+w[i-1]);
            }else
            {
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    for (int i = s; i >=0; i--)
    {
        if (dp[n][i]<=m && dp[n][i]!=0)
        {
            cout << i << endl;
            return 0;
        }   
    }
}

Measured memory_bytes: 83236
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

int n, K;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n >> K;

	int lim = (n-1)*(n-2) / 2;

	if (K > lim) {
		cout << -1 << endl;
		return 0;
	}

	int m = n - 1 + lim - K;
	cout << m << endl;

	for (int i = 2; i <= n; ++i)
		cout << "1 " << i << endl;
	
	m -= n-1;

	int u = 1;
	while (m > 0) {
		++u;
		for (int v = u+1; v <= n && m > 0; ++v) {
			cout << u << " " << v << endl;
			--m;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <vector>
#include <algorithm>

using namespace std;

int lis(const vector<int>& arr){
  const int inf = 1000000001;
  const int l = arr.size();
  vector<int> tail(l, inf);
  vector<int> id(l);
  for(int i=0; i<l; ++i){
    id[i] = distance(tail.begin(), lower_bound(tail.begin(), tail.end(), arr[i]));
    tail[id[i]] = arr[i];
  }
  int m = *max_element(id.begin(), id.end());
  vector<int> b(m+1);
  for(int i=l-1; i>=0; --i){
    if(id[i] == m){
      b[m--] = arr[i];
    }
  }
  return b.size();
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n, 0);
  for(int i=0; i<n; ++i){
    cin >> a[i];
  }
  cout << lis(a) << endl;
}


Measured memory_bytes: 4284
//Problem: ABC114 D
//Progress:
#include <iostream>
#include <vector>
#include <map>
#include <iterator>
#include <algorithm>
#include <cstring>
typedef long long int ll;
using namespace std;

const ll maxN = 101;

vector<ll> vlp;
bool is_prime[maxN];
vector<ll> spf(maxN);

map<ll, ll> mpl;

vector<ll> vans;

void sieve(){
    memset(is_prime, true, sizeof(is_prime));
    is_prime[0] = is_prime[1] = false;
    for(ll i=2; i<maxN; i++){
        if(is_prime[i]){
            vlp.push_back(i);
            spf[i] = i;
        }
        for(ll j=0; j<(ll)vlp.size() && i*vlp[j] <= maxN && vlp[j] <= spf[i]; j++){
            is_prime[i*vlp[j]] = false;
            spf[i*vlp[j]] = vlp[j];
        }
    }
}

void solve(ll n){
    sieve();
    for(ll i=2; i<=n; i++){
        ll cop_i = i, j=0;
        while(cop_i != 1){
            while(cop_i%vlp[j] == 0){
                mpl[vlp[j]] += 1;
                cop_i /= vlp[j];
            }
            j++;
        }
    }
    for(map<ll, ll>::iterator it = mpl.begin(); it != mpl.end(); ++it){
        if(it->second >= 2)
            vans.push_back(it->second);
    }
    ll ans = 0;
    for(ll i=0; i<(ll)vans.size(); i++){
        for(ll j=i+1; j<(ll)vans.size(); j++){
            for(ll k=j+1; k<(ll)vans.size(); k++){
                if(vans[i] >= 4 && vans[j] >= 4 && vans[k] >= 2)
                    ans++;
                if(vans[i] >= 4 && vans[j] >= 2 && vans[k] >= 4)
                    ans++;
                if(vans[i] >= 2 && vans[j] >= 4 && vans[k] >= 4)
                    ans++;
            }
        }
    }
    for(ll i=0; i<(ll)vans.size(); i++){
        for(ll j=i+1; j<(ll)vans.size(); j++){
            if(vans[i] >= 24 && vans[j] >= 2)
                ans++;
            if(vans[i] >= 2 && vans[j] >= 24)
                ans++;
            if(vans[i] >= 14 && vans[j] >= 4)
                ans++;
            if(vans[i] >= 4 && vans[j] >= 14)
                ans++;
        }
    }
    for(ll i=0; i<(ll)vans.size(); i++){
        if(vans[i] >= 74)
            ans++;
    }
    cout << ans;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    sieve();
    ll t;
    cin >> t;
    solve(t);
    return 0;
}

Measured memory_bytes: 384
def puts_move(m)
  puts "#{m[0]+1} #{m[1]+1} #{m[2]+1} #{m[3]+1}"
end

def main
  h, w = gets.split.map(&:to_i)
  grid = []

  h.times do |r|
     grid << gets.split.map(&:to_i)
  end

  moves = []

  # すべてのrowを右に見ていって奇数を右にずらしていく
  h.times do |r|
    row = grid[r]
    0.upto(w-2) do |c|
      if row[c].odd?
        row[c+1] += 1
        moves << [r, c, r, c+1]
      end
    end
  end

  # 一番右の列を上から見て、奇数を下にずらしていく
  0.upto(h-2) do |r|
    if grid[r][w-1].odd?
      grid[r+1][w-1] += 1
      moves << [r, w-1, r+1, w-1]
    end
  end

  puts moves.length
  moves.each do |m|
    puts_move(m)
  end
end

if __FILE__ == $0
  main
end


Measured memory_bytes: 23804
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n, d;
    cin >> n >> d;
    int hito = 2*d + 1;
    if(n % hito == 0){
        cout << n / hito << endl;
    } else {
        cout << n / hito + 1 << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int n,a[N];
int main()
{
    string s1,s2;
    int a,b;
    cin>>s1>>s2;
    cin>>a>>b;
    string s;
    cin>>s;
    if(s==s1) a--;
    if(s==s2) b--;
    cout<<a<<' '<<b<<endl;
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;
using T = tuple<int, int, int>;

int main(){
    int a, b, m;
    cin >> a >> b >> m;
    vector<int> reizou(a+1);
    vector<int> drange(b+1);
    vector<T> discount;
    for(int i = 1; i <= a; i++) cin >> reizou[i];
    for(int i = 1; i <= b; i++) cin >> drange[i];
    for(int i = 0; i < m; i++){
        int x, y, c;
        cin >> x >> y >> c;
        discount.push_back(make_tuple(x, y, c));
    }
    
    int min0 = 100100100;
    for(int i = 0; i < m; i++){
        if(reizou[get<0>(discount[i])] + drange[get<1>(discount[i])] - get<2>(discount[i]) < min0){
            min0 = reizou[get<0>(discount[i])] + drange[get<1>(discount[i])] - get<2>(discount[i]);
        }
    }
    
    int min1 = 100100100, min2 = 100100100;
    
    for(int i = 1; i <= a; i++){
        if(reizou[i] < min1) min1 = reizou[i];
    }
    
    for(int i = 1; i <= b; i++){
        if(drange[i] < min2) min2 = drange[i];
    }
    
    cout << min(min0, min1+min2) << endl;
    
    return 0;
}
    

Measured memory_bytes: 2680
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long long int n;
  cin>>n;
  vector<long long int> v(n);
  for(long long int i=0; i<n; i++){
    cin>>v.at(i);
  }
  vector<long long int> c(n);
  for(long long int i=0; i<n; i++){
    cin>>c.at(i);
  }
  long long int ans=0;
  for(long long int i=0; i<n; i++){
    if(v.at(i)>c.at(i)){
      ans+=v.at(i)-c.at(i);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3600
#include <iostream>
#define MAX_N 10000
using namespace std;

int par[MAX_N];
int rank[MAX_N];

int find(int x) {
  if (par[x] == x) return x;
  return find(par[x]);
}

bool same(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return true;
  return false;
}

void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;

  if (rank[x] < rank[y]) {
    par[x] = y;
  } else {
    par[y] = x;
  }

  if (rank[x] == rank[y]) rank[x]++;
}

void init(int n) {
  for (int i = 0; i < n; i++) {
    par[i] = i;
    rank[i] = 0;
  }
}

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

  for (int i = 0; i < q; i++) {
    int com, x, y;
    cin >> com >> x >> y;
    if (com == 0) {
      unite(x, y);
    } else {
      if (same(x, y)) cout << 1 << endl;
      else cout << 0 << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3164
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;


template<class T> class HWBFS {

   public:
      typedef std::pair<int, int> ipair;
      vector< vector<T> > d;
      queue<ipair> q;
      int dx[4] = {1, 0, -1, 0};
      int dy[4] = {0, 1, 0, -1};
      int H = 0, W = 0;      
      // HxW grid, start from c (many)
      void init(vector<string> &f, char c) {
         H = (int)f.size();
         W = (int)f[0].size();
         
         d.resize(H);
         for (int h = 0; h < H; h++) {
            d[h].resize(W);
            for (int w = 0; w < W; w++) {
               d[h][w] = -1;
            }
         }
         
         for (int h = 0; h < H; h++) {
            for (int w = 0; w < W; w++) {
               if (f[h][w] == c) {
                  d[h][w] = 0;
                  q.push(ipair(h, w));
               }
            }
         }
      }

      void bfs() {
         while (!q.empty()) {
            auto cur = q.front();
            q.pop();
            for (int dir = 0; dir < 4; dir++) {
               int nx = cur.first + dx[dir];
               int ny = cur.second + dy[dir];
               if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
               if (d[nx][ny] == -1) {
                  d[nx][ny] = d[cur.first][cur.second] + 1;
                  q.push(ipair(nx, ny));
               }
            }
         }
      }
      T getmax() {
         T ret = 0;
         for (int h = 0; h < H; h++) {
            for (int w = 0; w < W; w++) {
               if (ret < d[h][w]) ret = d[h][w];
            }
         }
         return ret;
      }
};

int main() {
   int H, W;
   cin >> H >> W;
   vector<string> f;
   f.resize(H);
   for (int i = 0; i < H; i++) cin >> f[i];
   HWBFS<int> hwbfs;
   hwbfs.init(f, '#');
   hwbfs.bfs();
   cout << hwbfs.getmax() << endl;
   return 0;
}


Measured memory_bytes: 13456
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 area = a * b;
		int length = (a + b) * 2;
		System.out.println(area + " " + length);
		sc.close();
	}
}


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

const int MAXN = 10010;
const int MAXP = 1000010;
const int MAXE = MAXP * 10;
int head[MAXP], nxt[MAXE], to[MAXE], tot;
void addedge(int b, int e) {
	nxt[++tot] = head[b]; to[head[b] = tot] = e;
}
int dfn[MAXP], st[MAXP], top, ins[MAXP], low[MAXP], bel[MAXP], t0t, txt;
void tarjan(int u) {
	dfn[u] = low[u] = ++txt;
	ins[st[++top] = u] = true;
	for (int i = head[u]; i; i = nxt[i])
		if (!dfn[to[i]]) {
			tarjan(to[i]);
			low[u] = std::min(low[u], low[to[i]]);
		} else if (ins[to[i]]) low[u] = std::min(low[u], dfn[to[i]]);
	if (low[u] == dfn[u]) {
		int v; ++t0t;
		do ins[v = st[top--]] = false, bel[v] = t0t; while (v != u);
	}
}
int idx, vs[2][MAXN];
int map[MAXN][2];
int n;
struct seg {
	int in[MAXN << 2], out[MAXN << 2];
	void build(int * rk1, int * rk2, int u = 1, int l = 1, int r = n) {
		in[u] = ++idx, out[u] = ++idx;
		if (l == r) return addedge(in[u], rk1[l]), addedge(rk2[l], out[u]);
		int mid = l + r >> 1;
		build(rk1, rk2, u << 1, l, mid); build(rk1, rk2, u << 1 | 1, mid + 1, r);
		addedge(in[u], in[u << 1]); addedge(in[u], in[u << 1 | 1]);
		addedge(out[u << 1], out[u]); addedge(out[u << 1 | 1], out[u]);
	}
	void mdf(int L, int R, int t, int b, int u = 1, int l = 1, int r = n) {
		if (L <= l && r <= R)
			return b ? addedge(out[u], t) : addedge(t, in[u]);
		if (L > R) return ;
		int mid = l + r >> 1;
		if (L <= mid) mdf(L, R, t, b, u << 1, l, mid);
		if (mid < R) mdf(L, R, t, b, u << 1 | 1, mid + 1, r);
	}
} sg, si;
int rk[MAXN], tmp1[MAXN], tmp2[MAXN], fin[MAXN];
int at[MAXN];
bool solve(int lim) {
	memset(dfn, 0, idx + 1 << 2);
	memset(head, 0, idx + 1 << 2);
	txt = t0t = tot = idx = 0;
	for (int i = 1; i <= n; ++i)
		for (int j = 0; j < 2; ++j)
			map[i][j] = ++idx;
	for (int X = 0; X < 2; ++X)
	for (int Y = 0; Y < 2; ++Y) {
		int * vl = vs[Y];
		for (int i = 1; i <= n; ++i) rk[i] = i;
		std::sort(rk + 1, rk + 1 + n, [vl] (int a, int b) { return vl[a] < vl[b]; });
		for (int i = 1; i <= n; ++i) fin[i] = vl[rk[i]], at[rk[i]] = i;
		for (int i = 1; i <= n; ++i) tmp1[i] = map[rk[i]][Y ^ 1], tmp2[i] = map[rk[i]][Y];
		sg.build(tmp1, tmp2);
		for (int i = 1; i <= n; ++i) {
			int V = vs[X][i], u = at[i];
			int l = std::lower_bound(fin + 1, fin + 1 + n, V - lim + 1) - fin;
			int r = std::upper_bound(fin + 1, fin + 1 + n, V + lim - 1) - fin - 1;
			if (l > r) continue;
			l = std::max(l, 1); r = std::min(r, n);
			if (l <= u && u <= r) {
				sg.mdf(l, u - 1, map[i][X], 0); sg.mdf(l, u - 1, map[i][X ^ 1], 1);
				sg.mdf(u + 1, r, map[i][X], 0); sg.mdf(u + 1, r, map[i][X ^ 1], 1);
			} else {
				sg.mdf(l, r, map[i][X], 0); sg.mdf(l, r, map[i][X ^ 1], 1);
			}
		}
	}
	for (int i = 1; i <= idx; ++i) if (!dfn[i]) tarjan(i);
	for (int i = 1; i <= n; ++i) if (bel[map[i][0]] == bel[map[i][1]])
		return false;
	return true;
}
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n;
	for (int i = 1; i <= n; ++i) std::cin >> vs[0][i] >> vs[1][i];
	int l = 0, r = 1e9, ans = 0;
	while (l <= r) {
		int mid = l + r >> 1;
		if (solve(mid)) l = mid + 1, ans = mid; else r = mid - 1;
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 34560
#include <stdio.h>
#include <math.h>
#include <iostream>

int main(void) {
    long playerAmount;
    long points;
    long correctAnswers;
    std::cin >> playerAmount >> points >> correctAnswers;

    int answers[playerAmount];
    for (int i = 0; i < playerAmount; i++){
        answers[i] = 0;
    }
    int tmp;
    for (long i = 0; i < correctAnswers; i++){
        std::cin >> tmp;
        answers[tmp - 1]++;
    }

    for (int i = 0; i < playerAmount; i++){
        if ( 0 >= points - (correctAnswers - answers[i])){
            std::cout << "No" << std::endl;
        } else {
            std::cout << "Yes" << std::endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1024