akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
#include <time.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 1147483600;
const ll infl = 1e18 + 5;
const char ENDL = '\n';
//cout << fixed << setprecision(17) << res << endl;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    int mn = 26;
    string t = s;
    reverse(all(t));
    string ss;
    ss = s + t;
    vector<string> sei;
    rep(i,n+1){
        mn = min(mn, ss[i] - 'a');
        string now;
        rep(j, n) now += ss[i + j];
        sei.eb(now);
    }
    sort(all(sei));
    if (k==1){
        cout << sei[0] << ENDL;
        return 0;
    }
    if (k>20 || (n<(1ll<<(k-1)))){
        string ans;
        rep(i, n) ans += (char)(mn + 'a');
        cout << ans << ENDL;
        return 0;
    }
    s = sei[0];
    reverse(all(s));
    //貪欲に見ていく。一回ごり押ししてみる。
    rep(i,k-2){
        vector<string> sei_now;
        t = s;
        reverse(all(t));
        ss = s + t;
        rep(i, n + 1)
        {
            string now;
            rep(j, n) now += ss[i + j];
            sei_now.eb(now);
        }
        sort(all(sei_now));
        s = sei_now[0];
        reverse(all(s));
    }
    vector<string> sei_now;
    t = s;
    reverse(all(t));
    ss = s + t;
    rep(i, n + 1)
    {
        string now;
        rep(j, n) now += ss[i + j];
        sei_now.eb(now);
    }
    sort(all(sei_now));
    cout << sei_now[0] << ENDL;
}


Measured memory_bytes: 80080
//https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/all/DSL_2_B
#include <bits/stdc++.h>
using namespace std;
template<typename T>
vector<T> build_segtree(function<T(T,T)>f,T unit,const vector<T> &v){
    long n=1;
    while(n<v.size()){n<<=1;}
    vector<T> tree(n<<1,unit);
    for(size_t i=0;i<v.size();++i)tree[n+i]=v[i];
    if(n>0)for(size_t i=n-1;i;--i){
        tree[i]=f(tree[i*2],tree[i*2+1]);
    }
    return tree;
}
template <typename T>
class segtree{
    using F = function<T(T,T)>;
    long n;
    F f;
    T unit;
    vector<T> tree;
    public:
    segtree(F f,T unit,const vector<T> &v):f(f),unit(unit),tree(){
        tree=build_segtree(f,unit,v);
        n = tree.size()/2;
    }
    segtree(F f,T unit,size_t n_):segtree(f,unit,vector<T>(n_,unit)){
    }
    void build(const vector<T> &v){
        for(size_t i=0;i<v.size();++i)tree[n+i]=v[i];
        if(n>0)for(size_t i=n-1;i;--i){
            tree[i]=f(tree[i*2],tree[i*2+1]);
        }
    }
    void set_val(size_t k,T x){
        if(k>n){
            cerr<<"out of size"<<endl;
            exit(1);
        }
        tree[k+=n]=x;
        while(k>>=1){
            tree[k]=f(tree[k*2],tree[k*2+1]);
        }
    }
    void add_val(size_t k,T x){
        if(k>n){
            cerr<<"out of size"<<endl;
            exit(1);
        }
        k+=n;
        tree[k]=f(tree[k],x);
        while(k>>=1){
            tree[k]=f(tree[k*2],tree[k*2+1]);
        }
    }
    T query(size_t a,size_t b){
        T vl=unit,vr=unit;
        for(int l=a+n,r=b+n;l<r;l/=2,r/=2){
            if(l&1)vl=f(vl,tree[l++]);
            if(r&1)vr=f(tree[--r],vr);
        }
        return f(vl,vr);
    }
};

int main(int argc, char const *argv[])
{
    long n,q;
    cin>>n>>q;
    function<long(long,long)> f = [](long a,long b){return a+b;};
    segtree<long> st(f,0L,n);
    for (size_t i = 0; i < q; i++)
    {
        long com,x,y;
        cin>>com>>x>>y;
        if(com==0){
            --x;
            st.add_val(x,y);
        }else{
            --x;
            cout<<st.query(x,y)<<endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 5736
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;



int main(void) {
	ll k, n;
	cin >> k >> n;
	vector<ll> a(n);
	rep (i, n) cin >> a[i];

	
	ll m = -1;
	rep (i, n - 1) {
		chmax(m, a[i + 1] - a[i]);
	}

	chmax(m, a[0] + k - a[n - 1]);

	cout << k - m << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(ll i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<< endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(ll, N, A, B, C, D, E);
  print(5 + (N - 1) / min({A, B, C, D, E}));
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <queue>
#include <map>

int main(){
  int N;
  scanf("%d", &N);
  for (int i=1; i<=9; i++){
    if(N%i==0){
      if (N/i>=1 && N/i<10){
        printf("Yes\n");
        return 0;
      }
    }
  }
  printf("No\n");
  return 0;
}

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

int main() {
    int n, d, x;
    cin >> n >> d >> x;
    vector<vector<int> > p(15, vector<int>(15, 0));
    vector<int> dp(100005, 0);
    for (int i = 0; i < d; i++) {
        for (int j = 0; j < n; j++) {
            cin >> p[i][j];
        }
    }
    int ans = x;
    for (int day = 0; day < d - 1; day++) {
        fill(dp.begin(), dp.end(), 0);
        for (int i = 0; i <= ans; i++) dp[i] = i;
        int tmp = ans;
        for (int i = 0; i < n; i++) {
            for (int j = p[day][i]; j <= ans; j++) {
                dp[j] = max(dp[j], dp[j - p[day][i]] + p[day + 1][i]);
                tmp = max(tmp, dp[j]);
            }
        }
        ans = tmp;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3424
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
typedef vector<vector<ll> > matrix;
const int mod = 1e9+7;
ll gcd(ll a,ll b){
	if(b==0)return a;return gcd(b,a%b);
}
ll expo(ll base,ll pow){
    ll ans = 1;
    while(pow!=0){
        if(pow&1==1){ans = ans*base;ans = ans%mod;}
        base *= base;base%=mod;pow/=2;}return ans;
}
ll inv(ll x){return expo(x,mod-2);}

double pi = 3.141592653589793238462643;
double error = 0.0000001;
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};
/* -------Template ends here-------- */

const int M = 210001;

vector<int> vec[M];
int vis[M];

void dfs(int u){
    vis[u] = 1;
    for(int i = 0 ; i < vec[u].size() ; i++){
        int v = vec[u][i];
        if(vis[v]) continue;
        dfs(v);
    }
}
map<pair<int , int> , int> mp;
int main(){
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);


    int n , m;
    si(n);  si(m);

    for(int i = 1 ; i <= m ; i++){
        int u , v;
        si(u);  si(v);
        mp[make_pair(u , v)] = 1;
        mp[make_pair(v , u)] = 1;
    }

    for(int i = 2;  i < n ; i++){
        if(mp.count(make_pair(1 , i)) && mp.count(make_pair(i , n))){
            cout<<"POSSIBLE";
            return 0;
        }
    }
    cout<<"IMPOSSIBLE";

















}














Measured memory_bytes: 30208
s = input()
t = input()
flag = False
tq = '?'*len(t)
start = []
for i in range(len(s)-len(t)+1):
    flag = True
    for j in range(len(t)):
        if s[i+j] == t[j] or s[i+j] == '?':
            continue
        else:
            flag = False
            break
    if flag:
        start.append(i)
    
stal = []
if start:
    for i in start:
        stal.append(s[:i].replace('?','a') + t + s[i+len(t):].replace('?','a'))
    stal.sort()
    print(stal[0])
else:
    print('UNRESTORABLE')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int N = 2000 + 10;
const int P = 924844033;
int n, k, dp[N << 1][N][2], a[N << 1], num, fac[N];
int main() {
    scanf("%d%d", &n, &k);
    for (int i = fac[0] = 1; i <= n; i++) fac[i] = 1ll * fac[i - 1] * i % P;
    for (int i = 1; i <= k; i++) {
        for (int j = i; j <= n; j += k) a[++num] = j;
        for (int j = i; j <= n; j += k) a[++num] = j;
    }
    dp[1][0][0] = 1;
    for (int i = 2; i <= (n << 1); i++) {
        for (int j = 0; j <= (i / 2); j++) {
            dp[i][j][0] = (dp[i - 1][j][0] + dp[i - 1][j][1]) % P;
            if (j && a[i] - a[i - 1] == k) dp[i][j][1] = dp[i - 1][j - 1][0];
        }
    }
    int ans = 0;
    for (int i = 0; i <= n; i++) {
        int g = (dp[n << 1][i][0] + dp[n << 1][i][1]) % P;
        if (i & 1)
            ans = (ans - 1ll * fac[n - i] * g % P + P) % P;
        else
            ans = (ans + 1ll * fac[n - i] * g) % P;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 61568
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>
#include <cmath>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SZ = 3e5, INF = 1e9 * 1e9 + 10;

ll dsu[SZ], sm[SZ];

ll par(int v) {
	if (dsu[v] == v) return v;
	else return dsu[v] = par(dsu[v]);
}

void uni(int v, int u) {
	u = par(u);
	v = par(v);
	if (u != v) {
		dsu[u] = v;
		sm[v] += sm[u];
		sm[v] %= 26;
	}
}
int main()
{
	fastInp;

	string s;
	cin >> s;

	vector<ll> vec;
	s.insert(s.begin(), 'a');
	s.push_back('a');
	for (int i = 1; i < s.size(); i++) {
		vec.push_back((s[i] - s[i - 1] + 26) % 26);
	}
	for (int i = 0; i < vec.size(); i++) {
		dsu[i] = i;
		sm[i] = vec[i];
		
	}

	ll q;
	cin >> q;

	for (int i = 0; i < vec.size(); i++) uni(i, vec.size() - i - 1);
	while (q--) {
		ll l, r;
		cin >> l >> r;
		uni(l - 1, r);
	}

	for (int i = 0; i < vec.size(); i++) {
		ll k = par(i);
		if (sm[k] != 0) {
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";

	return 0;
}

/*
aaaaaaaaa
10
3 6
4 8
5 5
1 3
1 5
5 7
2 6
2 8
3 9
1 9
*/

Measured memory_bytes: 5796
L,R=map(int,input().split())

if R<L+2019:
  end=R
else:
  end=L+2018

ans=2020*2020
for l in range(L,end):
  for r in range(l+1,end+1):
    if ans>(l*r)%2019:
      ans=(l*r)%2019
    if ans==0:
      break
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define     ll          long long
#define     MOD         10e9+7
#define     pb          push_back
#define     vll         vector<long long>
#define     vi          vector<int>
#define     vl          vector<long>
#define     pii         pair<int, int>
#define     all(a)      (a).begin(),(a).end()
#define     rep(i,a,b)  for(int i=a;i<b;i++)
#define     MAX         100002 
#define     ios	      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int main() {
   
    ios
    ll k;
    string s;
    cin >> k >>s;
    ll len=s.length();
    if(len<=k)cout << s;
    else{
        ll i=0;
        while(i<k){
            cout << s[i];
            i++;
        }
        cout <<"...";
    }
   
    return 0;
  
}

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

int main(){
  int d,t,s;
  cin>>d>>t>>s;
  if(s*t>=d) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int a[n + 1];
	for (auto &i : a) i = ri();
	int64_t sum[n + 1];
	sum[n] = 0;
	for (int i = n; i; i--) sum[i - 1] = sum[i] + a[i];
	int64_t cur = 1;
	int64_t res = 0;
	for (int i = 0; i <= n; i++) {
		res += cur;
		cur -= a[i];
		if (cur < 0) {
			res = -1;
			break;
		}
		cur *= 2;
		cur = std::min(cur, sum[i]);
	}
	printf("%" PRId64 "\n", res);
	return 0;
}


Measured memory_bytes: 4964
using System;
class Program{
  static void Main(string[] args){
    int n = int.Parse(Console.ReadLine());
    string[] tmp = Console.ReadLine().Split(' ');
    int[] a = new int[n];
    int positive = 0;
    int min = 1000000000;
    long sum=0;
    for(int i=0;i<n;i++){
      a[i]=int.Parse(tmp[i]);
      if(a[i]>0){positive++;}
      if(abs(a[i])<min){min=abs(a[i]);}
      sum+=abs(a[i]);
    }
    if((n-positive)%2==1){sum-=min*2;}
    Console.WriteLine(sum);
  }
  static int abs(int n){
    return (n>0)?n:-n;
  }
}


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

int main() {
    int N; cin >> N;
    int X[200010], Y[200010];
    for(int i=0; i<N; ++i){
        cin >> X[i];
        Y[i]=X[i];
    }
    sort(Y, Y+N);
    for(int i=0; i<N; ++i){
        if(X[i]>=Y[N/2]) cout << Y[N/2-1] << endl;
        else cout << Y[N/2] << endl;
    }
	return 0;
}


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

void bubble(int n, vector<string> &v) {
  bool flag = true;
  while (flag) {
    flag = false;
    for (int i = n - 1; i >= 1; i--) {
      if (v.at(i).at(1) < v.at(i - 1).at(1)) {
        swap(v.at(i), v.at(i - 1));
        flag = true;
      }
    }
  }
}

void selection(int n, vector<string> &v) {
  int minj;
  for (int i = 0; i < n; i++) {
    minj = i;
    for (int j = i; j < n; j++) {
      if (v.at(j).at(1) < v.at(minj).at(1))
      minj = j;
    }
    if (v.at(i).at(1) != v.at(minj).at(1)) {
      swap(v.at(i), v.at(minj));
    }
  }
}

void view(vector<string> &v) {
  for (int i = 0; i < v.size(); i++) {
    if (i == v.size() - 1)
    cout << v.at(i) << endl;
    else
    cout << v.at(i) << " ";
  }
}

int main() {
  int n; cin >> n;
  vector<string> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  vector<string> cv(v);
  bubble(n, v);
  selection(n, cv);

  view(v);
  cout << "Stable" << endl;
  view(cv);
  bool flag = true;
  for (int i = 0; i < n; i++) {
    if (v.at(i) != cv.at(i))
    flag = false;
  }
  if (flag)
  cout << "Stable" << endl;
  else
  cout << "Not stable" << endl;
}



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

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    ll ans=0;
    rep(i,n-1){
        if(a[i]>a[i+1]){
            ans+=a[i]-a[i+1];
            a[i+1]=a[i];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3968
import sys

def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)

def abs(a):
    if a<0:
        return -a
    else:
        return a

N,X=list(map(int,input().split()))

x=list(map(int,input().split()))

if N==1:
    print(abs(X-x[0]))
    sys.exit()

dist=[X-x[0]]
for i in range(N-1):
    dist.append(x[i+1]-x[i])

ans=gcd(dist[0],dist[1])
for i in range(2,N-1):
    ans=gcd(ans,dist[i])

print(abs(ans))

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

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

    vi A(N);
    REP(i,N)cin >> A[i];


    int max_dist = (K-A[N-1])+A[0];

    FOR(i,1,N){
        max_dist = max(max_dist,A[i]-A[i-1]);
    }

    cout << K-max_dist <<endl;

}



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

int main(){
    int n;
    cin >> n;
    int i = 1;
    while(i <= n){
        int x = i;
        if(x % 3 == 0){
            cout << " " << i;
        }
        else{
            while(x){
                if(x % 10 == 3){
                    cout << " " << i;
                    break;
                }
                else x /= 10;
            }
        }
        i++;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3100
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef long long LL;

#define d(x)  cout<<#x<<" = "<<(x)<<endl;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).rbegin()) i=(c).rbegin(); i!=(c).rend(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c,n) sort(c,c+n)
#define VSORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define DFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define DREP(i,n) DFOR(i,n,0)
#define INF 2000000000

const double EPS = 1e-10;
const double PI  = acos(-1.0);
////////////////////////////////////////////////
int a[100][100];
int main()
{
	int n;cin>>n;
	REP(i,n)
	{
		int m;cin>>m;
		int k;cin>>k;
		REP(j,k)
		{
			int l;cin>>l;
			a[m-1][l-1]=1;
		}
	}
	REP(i,n)
	{
		REP(j,n)
		{
			if(j)cout<<" ";
			cout<<a[i][j];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3136
#define _CRT_SECURE_NO_WARNINGS
#define forn(i, a, n) for(ll i = a; i < n; i ++)
#define pb push_back
#define mp make_pair

#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>


using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
const ll mod = 1e9 + 7;
const ll power = 49999;

struct fo 
{
	ll x1, y1, x2, y2;
	fo(ll q, ll w, ll e, ll r)
	{
		x1 = q;
		y1 = w;
		x2 = e;
		y2 = r;
	}
};
ll h, w, co;
queue<fo> ans;
ll table[507][507];

int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
/*
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
*/



	cin >> h >> w;
	forn(i, 0, h)
		forn(j, 0, w)
			cin >> table[i][j];
	
	forn(i, 0, h)
	{
		forn(j, 0, w-1)
		{
			if (table[i][j] % 2)
			{
				table[i][j]--;
				table[i][j + 1]++;
				fo add(i, j, i, j + 1);
				ans.emplace(add);
			}
		}
	}
	forn(i, 0, h-1)
	{
		if(table[i][w-1]%2)
		{
			table[i][w - 1]--;
			table[i + 1][w - 1]++;
			fo add(i, w - 1, i + 1, w - 1);
			ans.emplace(add);
		}
	}
	cout << ans.size() << endl;
	while (ans.size())
	{
		fo f = ans.front();
		cout << f.x1+1 << ' ' << f.y1+1 << ' ' << f.x2+1 << ' ' << f.y2+1 << endl;
		ans.pop();
	}
	return 0;
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

#define int long long

int N;
vector<int> dp;
// x円引き出すのに必要な操作の数
int solve(int x) {
  if(x < 0) { return 1e9; }
  if(x < 6) { return x; }
  if(dp[x] != -1) { return dp[x]; }
  int res = 1e9;
  for(int i = 1; pow(6, i) <= x; i++) {
    dp[x - pow(6, i)] = solve(x - pow(6, i));
    res = min(res, dp[x - pow(6, i)] + 1);
  }
  for(int i = 1; pow(9, i) <= x; i++) {
    dp[x - pow(9, i)] = solve(x - pow(9, i));
    res = min(res, dp[x - pow(9, i)] + 1);
  }
  return res;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  dp.assign(N + 1, -1);
  cout << solve(N) << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


int main() {
    int n; cin >> n;
    vector<ll> x(n);
    vector<ll> x_sort(n);
    rep(i, n) {
        cin >> x[i];
        x_sort[i] = x[i];
    }

    sort(x_sort.begin(), x_sort.end());
    ll a = x_sort[n/2];
    ll b = x_sort[(n/2)-1];

    rep(i, n) {
        if(x[i] <= b) {
            cout << a << endl;
        } else {
            cout << b << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 5376
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
signed main(){
  ll n,k,max_a=0,a_gcd;
  cin >> n >> k;
  ll a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(i==0){
      a_gcd=a[i];
    }else{
      a_gcd = gcd(a_gcd,a[i]);
    }
    max_a=max(max_a,a[i]);
  }
  if(max_a>=k&&k%a_gcd==0){
    cout <<"POSSIBLE\n";
  }else{
    cout <<"IMPOSSIBLE\n";
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <set>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;

// long long l[100];

int main() {
  int r,g; cin >> r >> g;
  double ans = 2*g - r;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
#define INF           1e9
#define INFL          static_cast<lint>(INF)
#define REP(i,n)      for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)     for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)     for(lint i=n-1;i>=0;--i)
#define REPR1(i,n)    for(lint i=n;i>0;--i)
#define REPI(i,ini,n) for(lint i=(ini),i##_len=(n);i<i##_len;++i)
#define REPC(i,obj)   for(auto i:obj)
#define R_UP(a,b)     (((a)+(b)-1)/(b))
#define ALL(obj)      (obj).begin(),(obj).end()
int main()
{
	int q = in();
	multiset<int>s;
	REP(i, q)
	{
		int n = in();
		int x, l, r;
		switch (n)
		{
		case 0:
			x = in();
			s.insert(x);
			cout << s.size() << endl;
			break;
		case 1:
			x = in();
			cout << distance(s.lower_bound(x), s.upper_bound(x)) << endl;
			break;
		case 2:
			x = in();
			s.erase(s.lower_bound(x), s.upper_bound(x));
			break;
		case 3:
			l = in();
			r = in();
			for (auto start = s.lower_bound(l), last = s.upper_bound(r); start != last; start++)cout << *start << endl;
			break;
		}
	}
}


Measured memory_bytes: 12308
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    int N, K;

    cin >> N >> K;

    if(N % 2 == 0){
        if(N/2 >= K){
            cout << "YES" << endl;
        }
        else{
            cout << "NO" << endl;
        }
    }

    else{
        if(N/2+1 >= K){
            cout << "YES" << endl;
        }
        else{
            cout << "NO" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"io"
	"os"
	"sort"
)

func fscanNums(r io.Reader, len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Fscan(r, &num)
		nums = append(nums, num)
	}
	return
}

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

func answer(r io.Reader, w io.Writer) {

	msSizes := []int{0, 2, 5, 5, 4, 5, 6, 3, 7, 6}

	var numMS int
	var numDigits int
	fmt.Fscan(r, &numMS)
	fmt.Fscan(r, &numDigits)
	nums := fscanNums(r, numDigits)
	sort.Sort(sort.Reverse(sort.IntSlice(nums)))

	dp := make([]int, numMS+1)
	dp[0] = 0
	for i := 1; i <= numMS; i++ {
		maxDigit := -1
		for j := 0; j < numDigits; j++ {
			index := i - msSizes[nums[j]]
			if index >= 0 && dp[index] >= 0 {
				maxDigit = max(maxDigit, dp[index]+1)
			}
		}
		dp[i] = maxDigit
	}

	remain := numMS
	for remain > 0 {
		maxDigit := -1
		for j := 0; j < numDigits; j++ {
			index := remain - msSizes[nums[j]]

			if index >= 0 && dp[index] == dp[remain]-1 {
				maxDigit = max(maxDigit, nums[j])
			}
		}
		remain = remain - msSizes[maxDigit]
		fmt.Fprintf(w, "%v", maxDigit)
	}
}

func main() {
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 640
const main = (lines: string) => {
  const data = lines.split("\n");
  const columns = data[1].split(" ").map(str => parseInt(str, 10));
  const maxValue = Math.max.apply(null, columns);
  let results = 0;

  columns.forEach(column => {
    let n = maxValue / column;
    results += maxValue / column;
  });

  console.log(maxValue / results);
};

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


Measured memory_bytes: 7372
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#include<chrono>
#include<random>
#include<iostream>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
#define VI vector<int>
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
template<typename T>inline void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T>inline void chkmax(T &x,T y){x=x>y?x:y;}
const int MAXN=505;
const int dx[4]={0,-1,0,1};
const int dy[4]={-1,0,1,0};
int f[MAXN][MAXN],p[MAXN*MAXN],n;
int vis[MAXN][MAXN],tim;
bool a[MAXN][MAXN];
bool in(int x,int y){return x>=1&&x<=n&&y>=1&&y<=n;}
deque<pii> li;
void rollback(int x,int y)
{
	++tim;
	a[x][y]=0;li.push_front(mp(x,y));
	while(!li.empty())
	{
		pii T=li.front();li.pop_front();
		int u=T.first,v=T.second;
		if(vis[u][v]==tim)continue;vis[u][v]=tim;
		for(int k=0;k<4;k++)if(in(u+dx[k],v+dy[k]))
		{
			int p=u+dx[k],q=v+dy[k];
			if(f[p][q]>f[u][v]+a[u][v])
			{
				f[p][q]=f[u][v]+a[u][v];
				if(!a[u][v])li.push_front(mp(p,q));
				else li.push_back(mp(p,q));
			}
		}
	}
}
int main()
{
	#ifdef Rose
		double BeginJudgeTime=clock();
	#endif
	memset(a,true,sizeof(a));
	n=read();LL ans=0;
	for(int i=1;i<=n*n;i++)p[i]=read();
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)
	{
		f[i][j]=i-1;chkmin(f[i][j],n-i);chkmin(f[i][j],j-1);chkmin(f[i][j],n-j);
	}
	for(int i=1;i<=n*n;i++)
	{
		int x=(p[i]-1)/n+1,y=(p[i]-1)%n+1;
		ans+=f[x][y];
		rollback(x,y);
	}
	pr2(ans);
	#ifdef Rose
		double EndJudgeTime=clock();
		cerr<<"JudgeTime is"<<" ";
		cerr<<(EndJudgeTime-BeginJudgeTime)/CLOCKS_PER_SEC<<endl;
	#endif
	return 0;
}


Measured memory_bytes: 7856
S = input()
count = 0
max = 0
for i in range(len(S)):
    if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
        count += 1
    else:
        if max < count:
            max = count
        count = 0
if max < count:
    max = count
print(max)


Measured memory_bytes: 61900
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}

////////////////////////////////////////


int main(){
    int n;cin>>n;
    int pos[n];
    rep(i,0,n-1){
        int x;cin>>x;x--;
        pos[x]=i;
    }
    bool a[n-1];
    rep(i,0,n-2){
        if(pos[i]<pos[i+1])a[i]=true;
        else a[i]=false;
    }
    int ma=0;
    int po=0;
    int cou=0;
    while(po<=n-2){
        if(a[po]){
            cou++;
            ma=max(ma,cou);
        }else{
            cou=0;
        }
        po++;
    }
    cout<<n-1-ma<<endl;
    
    
    return 0;
}


Measured memory_bytes: 1280
/*
    B - Minor Change
    https://atcoder.jp/contests/abc172/tasks/abc172_b
*/

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define ll long long // 10 ^ 18
#define forn(i, s, n) for (int i = s; i < n; i++)
#define whilen(val, n) while(n-- && cin >> val)
#define r_1(v) cin >> v
#define r_2(v1, v2) cin >> v1 >> v2

int main() {
    // ios::sync_with_stdio(0);
    // cin.tie(0);
    string s, t;
    r_1(s);
    r_1(t);
    int min = 0;
    forn(i, 0, s.length()) {
        if (s[i] != t[i]) min++;
    }
    cout << min;
    return 0;
}

Measured memory_bytes: 3884
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string n;
    cin >> n;
    int cnt = 0,k=n.size();
    for (size_t i = 0; i < n.size(); ++i) {
        if (n[i] == 'o')cnt++;
    }
    if (cnt >= 8 || (15 - k + cnt) >= 8) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    return 0;

}


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

int main() {
    int N;
    cin >> N;
    int ans[4] = {0};
    rep(i, N) {
        string S;
        cin >> S;
        if (S == "AC") {
            ans[0]++;
        } else if (S == "WA") {
            ans[1]++;
        } else if (S == "TLE") {
            ans[2]++;
        } else if (S == "RE") {
            ans[3]++;
        }
    }
    cout << "AC x " << ans[0] << endl;
    cout << "WA x " << ans[1] << endl;
    cout << "TLE x " << ans[2] << endl;
    cout << "RE x " << ans[3] << endl;
    
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, x, y;
    cin >> n >> x >> y;
    vector<int> res(n + 1);
    for (int i = 1; i < n; i++) {
        for (int j = i + 1; j <= n; j++) {
            int dis = j - i;
            dis = min(dis, abs(i - x) + abs(j - y) + 1);
            res[dis]++;
        }
    }
    for (int i = 1; i < n; i++) cout << res[i] << '\n';

    return 0;
}


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

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 1; i <= N; i++) {
        A[i] -= i;
    }

    //絶対値の和の最小化＝＞メジアンで最小！！
    //奇数の時も偶数の時もsortedのN/2+1番目の値が最小となる
    sort(A.begin(), A.end());
    ll x = A[N/2];

    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ans += abs(A[i]-x);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){

    int N;
    cin>> N;
    int a[N][3];
    for(int i=0; i<N; i++){
        for(int j=0; j<3; j++){
            cin>> a[i][j];
        }
    }

    int b[3][N];
    for(int i=0; i<N; i++){
        for(int j=0; j<3; j++){
            b[j][i]=a[i][j];
        }
    }

    int ans[N];
    fill(ans, ans+N, 0);
    for(int i=0; i<3; i++){
        for(int j=0; j<N; j++){
            if(count(b[i], b[i]+N, b[i][j])==1) ans[j]+=b[i][j];
        }
    }

    for(int k=0; k<N; k++){
        cout<< ans[k]<< endl;
    }

    return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); i++)
#define rrep(i, to) for (int i = (to) - 1; i >= 0; i--)
#define repf(i, from, to) for (int i = (from); i < (to); i++)
#define all(v) v.begin(), v.end()
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

int main() {
  int n;
  cin >> n;
  V<ll> a(n + 1), b(n);

  rep(i, n + 1) {
    cin >> a[i];
  }
  rep(i, n) {
    cin >> b[i];
  }


  ll prev_left = 0;
  ll count = 0;
  rep(i, n + 1) {
    ll monster_num = a[i];

    count += min(monster_num, prev_left);
    monster_num -= min(monster_num, prev_left);
    if(i < n) {
      count += min(monster_num , b[i]);
      prev_left = b[i] - min(monster_num , b[i]);
      monster_num -= min(monster_num , b[i]);
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 4848
S = input()
n = len(S)
rcount = 0
result = [0] * len(S)
for i in range(n-1):
    if S[i] == 'R' and S[i+1] == 'L':
        if rcount % 2 == 1:
            result[i+1] += rcount // 2 + 1 + 1
        else:
            result[i+1] += rcount // 2 + 1
        result[i] = rcount // 2 + 1 
        rcount = 0
    elif S[i] == 'R' and S[i+1] == 'R':
        rcount += 1
lcount = 0
#print (result)
for i in range(n-1, 0, -1):
    #print (S[i-1], S[i], lcount)
    if S[i] == 'L' and S[i-1] == 'R' and lcount > 0:
        if lcount % 2 == 1:
            result[i-1] += lcount // 2 + 1 
        else:
            result[i-1] += lcount // 2 
        result[i] += lcount // 2 
        lcount = 0
    elif S[i] == 'L' and S[i-1] == 'L':
        lcount += 1
print (" ".join(list(map(str, result))))

Measured memory_bytes: 17120
//-------------
//include
//-------------
#include <map>
#include <list>
#include <cmath>
#include <vector>
#include <string>
#include <cctype>
#include <random>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
//-------------
//typedef
//-------------
typedef long long LL;
typedef  vector<int> VI;
typedef  pair<int, int> PII;
typedef  vector<int, int> VII;
typedef  map<string, int> MSI;
//-------------
//utillty
//-------------
#define ALL(a)  (a).begin(),(a).end()
#define MK make_pair
#define PB push_back
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(a) cout<<a<<endl
//-------------
//repetition
//-------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//-------------
//debug
//-------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumpl(c) REP(i,SZ(c))cerr<<#c<<i<<"="<<(c[i])<<endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const int MOD = 1000000007;
int main()
{
	int a;
	cin >> a;
	cout << "ABC" << a << endl;
#ifdef _DEBUG
	while(1);
#endif // _DEBUG

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T>
inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main()
{
    ll x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << x2 - y2 + y1 << " " << y2 + x2 - x1 << " ";
    cout << x1 - y2 + y1 << " " << y1 + x2 - x1 << endl;
    return 0;
}

Measured memory_bytes: 3576
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		if(N % 2 == 0) {
			int ans = 0;
			for(int i = 1; i < N; i++) {
				ans += i;
			}
			System.out.println(ans - N / 2);
			for(int i = 1; i <= N; i++) {
				for(int j = i + 1; j <= N; j++) {
					if(i + j == N + 1) continue;
					System.out.print(i + " ");
					System.out.println(j);
				}
			}
		} else {
			int ans = 0;
			for(int i = 1; i < N; i++) {
				ans += i;
			}
			System.out.println(ans - (N - 1) / 2);
			for(int i = 1; i <= N; i++) {
				for(int j = i + 1; j <= N; j++) {
					if(i + j == N) continue;
					System.out.print(i + " ");
					System.out.println(j);
				}
			}
		}
	}
}


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


void solve(long long A, long long B, long long C){
  //どこかが1つ足りない
  //2箇所1足りない
  long long current;
  long long tarinai;
  if(A >= B && A >= C) {
    current = ((A-B)/2)+((A-C)/2);
    tarinai = ((A-B)%2)+((A-C)%2);
  }
  else if(B >= A && B >= C) {
    current = ((B-A)/2)+((B-C)/2);
    tarinai = ((B-A)%2)+((B-C)%2);
  }
  else if(C >= B && C >= A) {
    current = ((C-B)/2)+((C-A)/2);
    tarinai = ((C-B)%2)+((C-A)%2);
  }

  if(tarinai == 1){
    cout << current+2 << endl;
  }
  else if(tarinai == 2){
    cout << current+1 << endl;
  }
  else{
    cout << current << endl;
  }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  long long C;
  scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


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

class Player {
	public:
	string m_name;
	string cards;
	Player(string s, string name) : cards(s), m_name(name) {}
	
	string CutCard() {
		string card_h;
		card_h = cards[0];
		cards = cards.substr(1,cards.size()-1);
		return card_h;
	}
	
	bool IsEnd() {
		bool isEnd = false;
		if (cards.size() == 0) isEnd = true;
		return isEnd;
	}
	
	Player& operator= (const Player& p) {
		this->m_name = p.m_name;
		this->cards = p.cards;
		return *this;
	}
};


int main() {
	string sa, sb, sc;
	cin >> sa;
	cin >> sb;
	cin >> sc;
	
	auto p_a = Player(sa, "A");
	auto p_b = Player(sb, "B");
	auto p_c = Player(sc, "C");
	
	bool isOver = false;
	string winner;
	Player* nowPlayer = &p_a;
	 while(!isOver) {
	 	isOver = nowPlayer->IsEnd();
	 	if (!isOver) {
	 		string card = nowPlayer->CutCard();
	 		//cout << card << endl;
	 		if (card == "a") {
	 			nowPlayer = &p_a;
	 		} else if (card == "b") {
	 			nowPlayer = &p_b;
	 		} else if (card == "c") {
	 			nowPlayer = &p_c;
	 		} 
	 	}
	 }
	
	cout << nowPlayer->m_name << endl;
	return 0;
}

Measured memory_bytes: 256
<?php
$s = trim(fgets(STDIN));
$date = strtotime(date("Y/m/d", strtotime($s)));
$date_2 = strtotime("2019/04/30");
$ans = $date <= $date_2 ? 'Heisei' : 'TBD';
echo $ans . "\n";
?>

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

using ll  = long long;
using pii = pair<int,int>;
#define dbg(n) cout<<'\n'<<#n<<" is "<<n<<'\n';
#define pb push_back
#define all(v) v.begin(), v.end()
#define cs(i) cout<<"Case "<<i+1<<": \n"; 
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);

const int N   = 2e5+5;
const int INF = 0x7fffffff;

vector<int>v[N];

int main(){
	int n,t,hold=0;

	cin>>n;

	for(int i=1;i<n;i++){
		int in;
		cin>>in;
		v[in].pb(i);
	}
	for(int i=1;i<=n;i++)
		cout<<v[i].size()<<endl;
	
	return 0;
}

Measured memory_bytes: 14576
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
using namespace std;

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

	long long A, B;
	cin >> A >> B;

	cout << A*B << endl;
	return 0;

}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    int n,x;
    cin >> n >> x;
    int a[n];
    for(int i=0; i<n; i++) cin >> a[i];
    sort(a,a+n);
    int cnt=0;
    for(int i=0; i<n-1; i++){
        if(x>=a[i]){
            cnt++;
            x-=a[i];
        }else{
            break;
        }
    }
    if(x==a[n-1]) cnt++;
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int main(){
    int a;
    cin >> a;
    if(a%2==0){
        cout << a;
    }else{
        cout << 2*a;
    }
}

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

int main(){
    int N,X;
    cin >> N >> X;
    int m[N];
    int res=X;
    for (int i = 0; i < N; ++i){
        cin >> m[i];
        res -= m[i];
    }
    sort(m,m+N);
    int count = N;
    int nokori;
    nokori = res / m[0];
    count += nokori;
    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int n, q;
    string s;
    cin >> n >> q >> s;
    vector<ll> csum(n, 0);
    csum[0] = 0;
    rrep(i, n - 1) {
        csum[i] += csum[i - 1];
        if(s[i - 1] == 'A' && s[i] == 'C') csum[i]++;
    }
    
    vector<ll> ans(q);
    rep(i, q) {
        int l, r;
        cin >> l >> r;
        l--; r--;
        ans[i] = csum[r] - csum[l];
    }
    for(auto x : ans) cout << x << endl;
    
    return 0;
}

Measured memory_bytes: 2688
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n;
    cin >> n;
    for (int k = 2; k <= 2 * n; ++k) {
        if ((k - 1) * k > 2 * n)
            break;

        if ((k - 1) * k == 2 * n) {
            vector<vector<int>> s(k);
            int num = 1;
            for (int i = 0; i < k; ++i) {
                for (int j = i + 1; j < k; ++j) {
                    s[i].push_back(num);
                    s[j].push_back(num);
                    ++num;
                }
            }

            cout << "Yes" << endl;
            cout << k << endl;
            for (const auto &arr : s) {
                cout << arr.size();
                for (int i = 0; i < arr.size(); ++i) {
                    cout << ' ' << arr[i];
                }
                cout << endl;
            }
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
using namespace std;

int  main()
{
  ios::sync_with_stdio(false);

  long long N,K;
  cin>>N>>K;
  vector<vector<long long>>dp(2,vector<long long >(K+1,-1));
  vector<long long  >a(N+1);
  for(long long i=0;i<N;i++)
  {
    cin>>a[i+1];
  }
  for(long long i=0;i<K+1;i++)
  {
    if(a[1]>=i)dp[1][i]=i+1;
    else  dp[1][i]=a[1]+1;
  }
  for(long long i=2;i<N+1;i++)
  {
    dp[i%2][0]=1;
    for(long long j=1;j<K+1;j++)
    {
      if(j>a[i])dp[i%2][j]=dp[i%2][j-1]+dp[(i+1)%2][j]-dp[(i+1)%2][j-a[i]-1];
      else dp[i%2][j]=dp[i%2][j-1]+dp[(i+1)%2][j];
      dp[i%2][j]%=1000000007;
    }
  }
  if(dp[N%2][K]<0){dp[N%2][K]+=(long long)10*1000000007;}
  dp[N%2][K]%=1000000007;
  long long res=dp[N%2][K]-dp[N%2][K-1];
  if(res<0){res+=(long long)10*1000000007;}
  res%=1000000007;
  if(K>0){cout<<res;return 0;}
  cout<<dp[N%2][K];
  cout<<endl;

}


Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int a,b,k;cin>>a>>b>>k;
  for(int i=min(a,b);i>=1;--i){
	if(a%i==0&&b%i==0){
	  --k;
	  if(!k){
		cout<<i<<endl;
		return 0;
	  }
	}
  }
  return 0;
}


Measured memory_bytes: 256