akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#include <cstring>
#include <iterator>

using namespace std;

int main()
{
    int n; cin >> n;
    int cnt = 0;
    vector <int> v1(n);
    vector <int> v2(n);
    for (int i = 0; i < n; ++i) {
        cin >> v1[i] >> v2[i];
    }
    for (int i = 0; i < n; ++i) {
        if (v1[i] == v2[i])cnt++;
        if (cnt == 3) {
            cout << "Yes";
            return 0;
        }
        if (v1[i] != v2[i])cnt = 0;
    }
    cout << "No";
}


Measured memory_bytes: 3628
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
 
using namespace std;
 
typedef long long ll;
 
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define for1(i, n) for (int i = 1; i <= (int)n; i++)
#define forq(i, s, t) for (int i = s; i <= (int)t; i++)
#define ford(i, s, t) for (int i = s; i >= (int)t; i--)
#define all(v) v.begin(), v.end()
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
 
const double EPS = 1e-15;
const double PI = acos(-1.0);
const int MAXN = (int)1000 + 7;
const int INF = (int)1e9 + 7;
const int MOD = (int)1e9 + 7;
const ll P = 239017;
 
#define TASK "cave"
 
int solve();
 
int main()
{
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("test.txt", "w", stderr);
    double tstart = TIME;
#else
 //   freopen(TASK".in", "r", stdin), freopen(TASK".out", "w", stdout);
#endif
    solve();
#ifdef _DEBUG
    double tend = TIME;
    cerr << tend - tstart << " s.\n";
#endif
    return 0;
}
 
int cnt[(int)1e5 + 123];
 
int solve() {
 	int n, x;
 	cin >> n;
 	int ans = 0;
 	for (int i = 0; i < n; i++) {
 		cin >> x;
 		x++;
 		cnt[x-1]++, cnt[x]++, cnt[x+1]++;
 		ans = max(ans, max(cnt[x-1], max(cnt[x], cnt[x + 1])));
 	}
 	cout << ans;
 	return 0;
 }

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

using namespace std;

const int MOD = 1E9 + 7;
const int MAXN = 1000;
int fac[MAXN + 1][MAXN + 1];
int invFac[MAXN + 1][MAXN + 1];
int dp[MAXN + 1][MAXN + 1];

int modPow(int b, int e)
{
    int ans = 1;
    while (e > 0)
    {
        if (e & 1)
        {
            ans = (int) (((long long) ans * b) % MOD);
        }
        b = (int) (((long long) b * b) % MOD);
        e >>= 1;
    }
    return ans;
}

int modInv(int x)
{
    return modPow(x, MOD - 2);
}

int main()
{
    fill(fac[0], fac[0] + MAXN + 1, 1);
    fill(invFac[0], invFac[0] + MAXN + 1, 1);
    fac[1][0] = invFac[1][0] = 1;
    for (int i = 1; i <= MAXN; i++)
    {
        fac[1][i] = (int) (((long long) fac[1][i - 1] * i) % MOD);
        invFac[1][i] = modInv(fac[1][i]);
    }
    for (int i = 2; i <= MAXN; i++)
    {
        for (int j = 1; j <= MAXN; j++)
        {
            fac[i][j] = (int) (((long long) fac[i - 1][j] * fac[1][j]) % MOD);
            invFac[i][j] = modInv(fac[i][j]);
        }
    }
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    fill(dp[0], dp[0] + n + 1, 1);
    for (int i = 1; i <= n; i++)
    {
        for (int j = a; j <= b; j++)
        {
            dp[i][j] = dp[i][j - 1];
            for (int k = c; k <= d && k * j <= i; k++)
            {
                // temp = num ways to set the last k groups
                int temp = (int) (((long long) fac[1][i] * invFac[1][i - k * j]) % MOD);
                temp = (int) (((long long) temp * invFac[k][j]) % MOD);
                temp = (int) (((long long) temp * invFac[1][k]) % MOD);
                temp = (int) (((long long) temp * dp[i - k * j][j - 1]) % MOD);
                dp[i][j] = dp[i][j] + temp;
                if (dp[i][j] >= MOD)
                    dp[i][j] -= MOD;
            }
            //cout << i << " " << j << " " << dp[i][j] << endl;
        }
    }
    cout << dp[n][b] << endl;
    return 0;
}


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

#define REP(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ALL(c) c.begin(), c.end()
#define SZ(c) (int) c.size()
#define DBG1(x) cout<<#x<<" = "<<x<<"\n"
#if USE_CP_REDIR
#define CP \
    freopen("input.txt","r", stdin); \
    freopen("output.txt","w", stdout);
#endif

using ll = long long;
const ll MOD = 1'000'000'007;
const int MN = 1'000'000;

ll mod_add(ll a, ll b)
{
    return (((a % MOD) + (b % MOD)) % MOD);
}

ll mod_mul(ll a, ll b){
    return (((a % MOD) * (b % MOD)) % MOD);
}

/* Iterative Function to calculate (x^y)%p  
in O(log y) */
long long mod_exp(long long x, long long y) 
{ 
    long long res = 1; // Initialize result 
  
    x = x % MOD; // Update x if it is more than or 
    // equal to p 
  
    while (y > 0) { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res * x) % MOD; 
  
        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % MOD; 
    } 
    return res; 
} 

ll A(ll n, ll k)
{
    ll res = 1LL;
    for(ll i = n; i > n - k; i--){
        res = mod_mul(res, i);
    }
    return res;
}

int main()
{
ios::sync_with_stdio(false);
#ifdef CP
    CP;
#endif
    int n;
    cin >> n;
    if(n == 1){
        cout << 0 << endl;
        return 0;
    }
    
    // Inclusion-Exclusion principle.
    ll all = mod_exp(10, n); 
    ll seq_without_9 = mod_exp(9, n);
    ll seq_without_0 = seq_without_9;
    ll seq_without_9_and_0 = mod_exp(8, n);
    ll ans = (all - seq_without_9 - seq_without_0 + seq_without_9_and_0) % MOD;
    cout << (ans + MOD) % MOD << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const ll INF=1e9;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    stack<char> stk;
    rep(i,s.length()){
        stk.push(s[i]);
    }
    ll ans=0;
    ll cnt = 0;
    rep(i,s.length()){
        char &now = stk.top();
        if(now=='W'){
            cnt ++;
        }else{
            ans += cnt;
        }
        stk.pop();
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 720
package main

import "fmt"

func main() {
	var n, z, w int
	fmt.Scan(&n, &z, &w)
	as := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&as[i])
	}
	if n == 1 {
		fmt.Println(abs(as[0] - w))
		return
	}

	ans := max(
		abs(as[n-1]-w),
		abs(as[n-2]-as[n-1]),
	)
	fmt.Println(ans)
}

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

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 2020
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
/* ------------------------------------------------ */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ------------------------------------------------ */
int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> a(26);
    rep(i, n) {
        a[s[i] - 'a']++;
    }
    ll ans = 1;
    ll mod = 1000000007;
    rep(i, 26) {
        ans *= a[i]+1;
        ans %= mod;
    }
    cout << ans - 1 << endl;
    return 0;
}

Measured memory_bytes: 3764
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split("").map(&:to_i)
end
s_list = gets_i_list
n = s_list.size

diffs = []

0.upto(n - 3)do |i|
  diffs.push ([s_list[i], s_list[i+1], s_list[i+2]].join.to_i - 753).abs
end
puts diffs.min


Measured memory_bytes: 2044
using System;
using System.Collections.Generic;
using System.Linq;

class abc123_C
{
    // ボトルネック通過前/通過後の個数 + 通過中の速度
    static void Main(string[] args)
    {    
        var QN = readLong();
        var trans = Enumerable.Range(0, 5).Select(x => readLong()).ToArray();

        var bottleneck = trans.Min();
        var ans = (long)Math.Ceiling((double)QN/bottleneck) + 4;
        Console.WriteLine(ans);
    }

    static long readLong() {
        return long.Parse(Console.ReadLine());
    }
}

Measured memory_bytes: 13396
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    int[] inf = new int[N+1];
    int now = 0;
    int paint = 1;
    int[] ans = new int[N-1];
    int max = 0;
    int[][] val = new int[N-1][4];
    for(int i = 0; i < N-1; i++){
      String[] S = sc.nextLine().split(" ");
      val[i][0] = Integer.parseInt(S[0]);
      val[i][1] = Integer.parseInt(S[1]);
      val[i][2] = i;
    }
    Arrays.sort(val, (a,b)->Integer.compare(a[0],b[0]));
    
    for(int i = 0; i < N-1; i++){
      int a = val[i][0];
      int b = val[i][1];
      if(a == now){
        paint++;
      }else{
        now = a;
        paint = 1;
      }
      if(inf[a] == paint){
        paint++;
      }
      val[i][3] = inf[b] = paint;
      max = max < paint ? paint : max;
    }
    
    Arrays.sort(val, (a,b)->Integer.compare(a[2],b[2]));
    System.out.println(max);
    for(int[] n : val){
      System.out.println(n[3]);
    }
  }
}

Measured memory_bytes: 137780
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iterator>
#include <set>
#include <functional>

using namespace std;

#define DT long long
#define forn(i,n)for(i=0;i<n;i++)
#define forc(i,c,n)for(i=c;i<=n;i++)
typedef vector<DT> vec;
typedef list<DT> li;

int main() {
	ifstream fin("Text.txt");
	int i, j , q;
	DT k,s,n, m, a, b, c,ans=0;
	string st;
	cin >> k >> s;
	forn(i, k + 1) {
		forn(j, k + 1) {
			if (i + j <= s && s-(i+j)<=k)
				ans++;
		}
	}
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 256
S = input()
LL,RR = int(S[:2]), int(S[2:])

def v_month(x):
    return  1<=x and x<=12

def v_year(x):
    return 0<=x

m1 = v_month(LL)
y1 = v_year(LL)

m2 = v_month(RR)
y2 = v_year(RR)

if (m1 and y1) and (m2 and y2):
    print("AMBIGUOUS")
elif m1 and y2:
    print("MMYY")
elif y1 and m2:
    print("YYMM")
else:
    print("NA") 

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=210,mod=998244353;
int inc(int x,int y){x+=y;return x>=mod?x-mod:x;}
int dec(int x,int y){x-=y;return x<0?x+mod:x;}
int mul(int x,int y){return (ll)x*y%mod;}
int power(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=mul(x,x))
		if (y&1) ans=mul(ans,x);
	return ans;
}
int calc(int n){
	return dec(power(2,n),n*(n+1)/2+1);
}
typedef pair<int,int> pii;
pii operator - (pii a,pii b){
	return pii(a.first-b.first,a.second-b.second);
}
int operator * (pii a,pii b){
	return a.first*b.second-a.second*b.first;
}
int n,q[N],size;pii p[N];
bool use[N][N];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d%d",&p[i].first,&p[i].second);
	int ans=calc(n);
	for (int i=1;i<=n;i++)
	for (int j=1;j<i;j++)
	if (!use[i][j]){
		pii vec=p[i]-p[j];size=0;
		for (int k=1;k<=n;k++)
			if ((p[k]-p[j])*vec==0) q[++size]=k;
		ans=dec(ans,calc(size));
		for (int a=1;a<=size;a++)
		for (int b=1;b<=size;b++)
			use[q[a]][q[b]]=1;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;

using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    int ans = 0;
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        int tmp= min(x,(k-x));
        ans += 2*tmp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define i64 long long
#define maxn (int)(1e5)
#define pii pair<int,int>
#define L first 
#define R second
#define all(x) x.begin(),x.end()
using namespace std;
bool cmp(int val1, int val2){
	return val1>val2;
}

int main(){
	int n;
	cin>>n;
	int a[n+1];
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	printf("%d\n", abs(a[n-1]-a[0]));
	return 0;
}

Measured memory_bytes: 256
class UnionFind(object):

    def __init__(self, N):
        self.tree = [i for i in range(N)]
        self.rank = [0] * (N + 1)

    def find(self, x):
        if self.tree[x] == x:
            return x
        else:
            self.tree[x] = self.find(self.tree[x])  # 経路圧縮
            return self.tree[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        # ランクを考慮しない場合はどちらが親になっても良い
        if self.rank[x] < self.rank[y]:
            self.tree[x] = y
        else:
            self.tree[y] = x

        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1

    def has_same_parent(self, x, y):
        return self.find(x) == self.find(y)


N, M = map(int, input().split())
P = list(map(int, input().split()))

uf = UnionFind(N + 1)
for _ in range(M):
    x, y = map(int, input().split())
    uf.unite(x, y)

ans = 0
for i in range(1, N + 1):
    ans += uf.has_same_parent(i, P[i - 1])
print(ans)

Measured memory_bytes: 14452
#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 A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A), b(B);
    rep(i, A) cin >> a[i];
    rep(i, B) cin >> b[i];
    int a_min = *min_element(a.begin(), a.end());
    int b_min = *min_element(b.begin(), b.end());
    int sum = a_min+b_min;
    int tmp;
    rep(i, M) {
        int x, y, c;
        cin >> x >> y >> c;
        tmp = a[x-1]+b[y-1]-c;
        if (tmp < sum) sum = tmp;
    }
    cout << sum << endl;
    return 0;
}


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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
#define rep2(i, startValue, N) for (int i = (int)(startValue); i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double

// ARC080 C - 4-adjacent
int main(){
  int n;
  cin >> n;
  vector<ll> a(n,0);
  int cnt4 = 0;
  int cnt2 = 0;
  rep(i, n) {
    cin >> a[i];
    if (a[i] % 4 == 0) {
      ++cnt4;
    } else if (a[i] % 2 == 0) {
      ++cnt2;
    }
  }

  if (cnt4 >= n / 2) {
    cout << "Yes" << endl;
    return 0;
  } else if (cnt4 * 2 + cnt2 >= n) {
    cout << "Yes" << endl;
    return 0;
  } else {
    cout << "No" << endl;
    return 0;
  }

  return 0;
}


Measured memory_bytes: 3936
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lint N;
    cin >> N;
    lint ans = 0;
    REP(i, N) ans += (i+1) * (N-i);
    REP(i, N-1) {
        lint u, v;
        cin >> u >> v;
        if(u > v) swap(u, v);
        ans -= u * (N+1-v);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int A[110];
int main()
{
	int M, N;
	cin >> N >> M;
	int num = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		num += A[i];
	}
	sort(A, A + N,greater<int>());
	for (int i = 0; i < M; i++) {
	//	cout << num << endl;
		if (A[i] * 4 * M < num) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

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

using namespace std;

int main(){
    int N;
    cin >> N;
    priority_queue<int> que;
    for(int i = 0; i < N; i++){
        int temp;
        cin >> temp;
        que.push(temp);
    }
    
    int A_sum = 0, B_sum = 0;
    
    bool flag = true;
    while(!que.empty()){
        if(flag){
            A_sum += que.top();
            que.pop();
            flag = false;
        }
        else{
            B_sum += que.top();
            que.pop();
            flag = true;
        }
    }
    
    cout << A_sum - B_sum << endl;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
int main ()
{
    string s;
	cin>>s;
	int minx=1000;
	int ans;
	for (int i=0;i<=s.length()-3;++i)
	   {
	     int m=100*(s[i]-'0')+10*(s[i+1]-'0')+(s[i+2]-'0');
	     if (abs(m-753)<minx)
		      minx=abs(m-753);
	   }
	 printf ("%d",minx);	
	return 0;
} 

Measured memory_bytes: 256
def main(N, a):
    m = getlcm(N, a) - 1
    f = 0
    for i in range(N):
        f += m % a[i]
    print(f)

def getlcm(N, a):
    l = 1
    for i in range(N):
        l = l * a[i] // gcd_(l, a[i])
    return l

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

if __name__ == '__main__':
    N = int(input())
    a = [int(i) for i in input().split()]

    main(N, a)


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


ab=[[int(x) for x in input().split()]for j in range(n)]
ab.sort(key=lambda x:(x[1],x[0]))

c=0
for i in range(n):
  c+=ab[i][0]
  if c>ab[i][1]:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 53852
a,b=map(int,input().split())
s=input()
def dig(s):
    if "0"<=s<="9":
        return True
    else: return False

def dig2(s,a,b):
    for i in s[:a]:
        if not dig(i):
            return False
    if s[a]!='-':
        return False

    for i in s[a+1:]:
        if not dig(i):
            return False
    return True

print(["No","Yes"][dig2(s,a,b)])

Measured memory_bytes: 3064
x=int(input())


if x==2 or x==3:
    print(x)
else:
    i=x
    flag=True
    while i<=100003 and flag==True:
        flag=False
        for j in range(2,int(i**(1/2)//1+1)):
            if i%j==0:
                flag=True
                break
        i+=1
    print(i-1)

Measured memory_bytes: 38896
import java.util.Scanner;

public class Main{
    public static void main(String args[]){

        Scanner scan = new Scanner(System.in);
        Integer N = Integer.parseInt(scan.next());
        Integer X = Integer.parseInt(scan.next());

        Integer L[] = new Integer[N];

        for(int i=0;i<N;i++)
            L[i] = Integer.parseInt(scan.next());

        int counter = 0;
        int sum = 0;
        for(int i=0;i<N;i++){
            if((sum += L[i]) > X)
                break;
            counter++;
        }

        System.out.println(counter+1);
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <string>
#include <map>
int main(){
  std::string S, T;
  std::cin >> S >> T;
  std::map<char, char> m, m2;
  for(int i = 0; i < S.size(); i++){
    if(!m.count(T[i])) m[T[i]] = S[i];
    else{
      if(m[T[i]] != S[i]){
        std::cout << "No" << std::endl;
        return 0;
      }
    }
	if(!m2.count(S[i])) m2[S[i]] = T[i];
    else{
      if(m2[S[i]] != T[i]){
        std::cout << "No" << std::endl;
        return 0;
      }
    }
  }
  std::cout << "Yes" << std::endl;
}

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

int main(void){
    int n;
    string s;
    cin >> n >> s;
    int sum = 0;
    for(int i = 0;i < n-2;i++){
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')sum++;
    }
    cout << sum;
}

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

int main() {
    int n;
    cin >> n;
    int a[n];
    int count = 0;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        if((i+1)%2 == 1 && a[i]%2 == 1)
        {
            count++;
        }
    }
    cout << count << endl;
	return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
int main()
{
  int h,w;
  char a[1005][1005] = {};
  int dp[1005][1005] = {};

  cin >> h >> w;

  for(int i=1; i<=h; i++){
    for(int j=1; j<=w; j++){
      cin >> a[i][j];
    }
  }

  dp[1][1] = 1;

  for(int i=1; i<=h; i++){
    for(int j=1; j<=w; j++){
      if(a[i][j] != '#'){
	dp[i][j] += dp[i][j-1] % MOD + dp[i-1][j] % MOD;
      }
    }
  }

  cout << dp[h][w] % MOD << endl;
  return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;


int main(void) {
	int n, i, a[300003] = {}, t;
	ll asmax[100005] = {}, asmin[100005] = {}, ans = -1e18;
	priority_queue<int, vector<int>, greater<int>> pq1;
	priority_queue<int> pq2;

	cin >> n;
	for (i = 0; i < n * 3; i++) {
		cin >> a[i];
	}

	for (i = 0; i < n; i++) {
		asmax[0] += a[i];
		pq1.push(a[i]);
	}

	for (i = n; i < n * 2; i++) {
		pq1.push(a[i]);
		t = pq1.top();
		pq1.pop();
		asmax[i - n + 1] = asmax[i - n] + a[i] - t;
	}

	for (i = n * 2; i < n * 3; i++) {
		asmin[n] += a[i];
		pq2.push(a[i]);
	}

	for (i = n * 2 - 1; i >= n; i--) {
		pq2.push(a[i]);
		t = pq2.top();
		pq2.pop();
		asmin[i - n] = asmin[i - n + 1] + a[i] - t;
	}

	for (i = 0; i <= n; i++) {
		ans = max(ans, asmax[i] - asmin[i]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4088
#include<bits/stdc++.h>
#define clr(a,b) memset(a,b,sizeof(a))
using namespace std;

typedef long long ll;

const int maxn=2010;
int a, b, c;

int main(){
    cin >> a >> b >> c;
    cout << max(0, b + c - a) << endl;
}

Measured memory_bytes: 256
def ok(p, ws, n, k):
    track = 1
    now = 0
    for i in range(n):
        if ws[i] > p:
            return False
        if now + ws[i] > p:
            track += 1
            now = ws[i]
        else:
            now += ws[i]
    if track > k:
        return False
    else:
        return True


nk = input().split()
n = int(nk[0])
k = int(nk[1])
ws = []
for _ in range(n):
    ws.append(int(input()))

p_min = 0
p_max = int(1e+10)
while p_min < p_max:
    p = (p_min + p_max) // 2
    if ok(p, ws, n, k):
        p_max = p
    else:
        p_min = p + 1
print(p_max)


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

int main(){
    int n; cin >> n;
    string s; cin >> s;
    int q; cin >> q;
    vector<set<int>> character(26);
    character.assign(26, set<int>({1 << 30}));

    //それぞれのアルファベットが何番目にあるかを挿入
    rep(i,n) character[s[i] - 'a'].insert(i);

    rep(i,q){
        int kind; cin >> kind;

        if(kind == 1){
            int iq; char cq; cin >> iq >> cq; iq--;
            character[s[iq] - 'a'].erase(iq);
            s[iq] = cq;
            character[s[iq] - 'a'].insert(iq);
        }

        if(kind == 2){
            int l, r; cin >> l >> r; l--;

            int ans = 0;

            rep(i,26){
                if(character[i].empty()) continue;
                int lnum = *character[i].lower_bound(l);
                int rnum = *character[i].lower_bound(r);
                if(rnum > lnum) ans++;
            }

            dunk(ans);
        }


    }

}





Measured memory_bytes: 24196
while 1:
    try:
        ab, c = list(input().split("="))
    except EOFError:
        break

    a, b = list(ab.split("+"))
    start = 0
    if (a[0] == "X" and len(a) > 1) or (b[0] == "X" and len(b) > 1) or (c[0] == "X" and len(c) > 1):
        start = 1

    for i in range(start, 10):
        na = a.replace("X", str(i))
        nb = b.replace("X", str(i))
        nc = c.replace("X", str(i))

        if int(na) + int(nb) == int(nc):
            print(i)
            break
    else:
        print("NA")


Measured memory_bytes: 5600
def sep():
    return map(int,input().strip().split(" "))
def lis():
    return list(sep())

n,a,b=sep()
k=n//(a+b)
ans=(k*a)
k2=n%(a+b)
if k2<=a:
    ans+=k2
else:
    ans+=a
print(ans)

Measured memory_bytes: 61892
using System;
using System.Linq;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] XN = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            if(XN[1] == 0)
            {
                System.Console.WriteLine(XN[0]);
                return;
            }
            int[] Ps = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int answer = 0;
            int i = 0;
            while(true)
            {
                if(!Ps.Contains(XN[0] - i))
                {
                    answer = XN[0] - i;
                    break;
                }
                if(!Ps.Contains(XN[0] + i))
                {
                    answer = XN[0] + i;
                    break;
                }
                i++;
            }
            Console.WriteLine(answer);
        }
    }
}

Measured memory_bytes: 28288
#include <stdio.h>

int main(void)
{
	int met[10],i,j,tmp;
	
	for(i=0;i<10;i++)
		scanf("%d",&met[i]);
	for(i=0;i<10;i++)
	{
		for(j=i+1;j<10;j++)
		{
			if(met[i]<met[j])
			{
				tmp=met[i];
				met[i]=met[j];
				met[j]=tmp;
			}
		}
	}
	
	for(i=0;i<3;i++)
		printf("%d\n",met[i]);
	
	return 0;
}

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

using namespace std;

typedef long long LL;
const LL MAXN=128;
const LL MAXK=100000+100;
const LL MOD=1e9+7;
LL a[MAXN],dp[MAXN][MAXK],sum[MAXK];
LL n,k;

int main(){
	cin>>n>>k;
	for(LL i=1;i<=n;i++){
		cin>>a[i];
	}
	dp[0][0]=1;
	for(LL i=0;i<=k;i++){
		sum[i]=1;
	}
	for(LL i=1;i<=n;i++){
		for(LL j=0;j<=k;j++){
			dp[i][j]=(sum[j]+MOD-(j-a[i]-1<0?0:sum[j-a[i]-1]))%MOD;
		}
		sum[0]=dp[i][0];
		for(LL j=1;j<=k;j++){
			sum[j]=(sum[j-1]+dp[i][j])%MOD;
		}
	}

	cout<<dp[n][k]<<endl;
	return 0;
}


Measured memory_bytes: 79360
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    string str;
    cin >> str;
    int red = 0;
    for (auto& x : str) {
        if (x == 'R')
            red++;
    }
    int ans = 0;
    for (int i(0); i < red; ++i) {
        if (str[i] == 'W')
            ans++;
    }
    cout << ans << endl;
}

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

int main(){
  int x,y;
  int tmp;
  while(true){
    cin>>x>>y;
    if(x==0&&y==0) break;
    if(x>y){
      tmp = x;
      x = y;
      y = tmp;
    }
    cout<<x<<' '<<y<<endl;
  }

  return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

struct Segmenttree{
    int n;
    vector<long long> node;

    Segmenttree(vector<long long> v){
        n = (int)(v.size());
        node.resize(2*n);
        for(int i=0;i<n;i++) node[i+n] = v[i];
        for(int i=n-1;i>=0;i--) node[i] = min(node[i<<1],node[i<<1|1]);
    }
    //i番目の要素をxに変更する
    void update(int i,long long x){
        i += n;
        node[i] = x;
        while(i>1){
            i >>= 1;
            node[i] = min(node[i<<1],node[i<<1|1]);
        }
    }
    //[l,r)の要素の和を求める
    long long query(int l,int r){
        long long res = LINF;
        l += n; r += n;
        while(l<r){
            if(l&1) res = min(res,node[l++]);
            if(r&1) res = min(res,node[--r]);
            l >>= 1; r >>= 1;
        }
        return res;
    }
    //i番目の要素にアクセス
    long long getval(int i){
        return node[i+n];
    }
};

int main(){
    int n,q;
    cin >> n >> q;
    Segmenttree seg(vector<ll>(n,INT_MAX));
    while(q--){
        int t,x,y;
        cin >> t >> x >> y;
        if(t==0){
            seg.update(x,y);
        }else{
            cout << seg.query(x,y+1) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 5140
/*

                                  In the name of Allah, Most Gracious, Most Merciful


*/
#include<bits/stdc++.h>
#include<numeric>
using namespace std;

//*** constant value ***
const long double PI = 3.141592653589793238;
const double EPS = 1e-6 ;
//*** constant value ***

//****** define ********
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define dd double
#define vll vector<ll>
#define vs vector<string>
#define fn(i,n) for(ll i = 0; i<n; i++)
#define f(i,a,b) for(i=a;i<b;i++)
#define f1(i,a,b) for(i=b-1;i>=a;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pls pair<ll,string>
#define vpl vector<pll>
#define pb push_back
#define mk make_pair
#define x first
#define y second
#define tt cout<<"Came here"<<endl;
//****** define ********
void solve()
{


}

int main()
{
    IOS;
    ll n,i,ans = 0;
    cin>>n;
    vll v(n);
    fn(i,n)
    cin>>v[i];

     f(i,1,n)
     {
         if(v[i]<v[i-1])
         {
             ans += v[i-1] - v[i];
             v[i] += (v[i-1] - v[i]);
         }
     }

     cout<<ans<<endl;


return 0;
}



Measured memory_bytes: 4652
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))
X, N = mi()
A = li()

flag = [0] * (205)

for num in A:
    flag[num] = 1

if not flag[X]:
    print(X)
    exit()

i = 1
while True:
    if not flag[X - i]:
        print(X-i)
        exit()
    elif not flag[X + i]:
        print(X+i)
        exit()
    i += 1

Measured memory_bytes: 62064
#include <iostream>
#include <cmath>
#include <string>

using namespace std;

int main() {
	int n;
	string tama[10] = {"* = ****", "* =* ***", "* =** **", "* =*** *", "* =**** ",
					   " *= ****", " *=* ***", " *=** **", " *=*** *", " *=**** "};
	bool hantei2 = false;
	while (cin >> n) {
		if (hantei2) {
			cout << endl;
		}
		int a[5];
		for (int i = 4; i >= 0; i--) {
			a[4-i] = n / (int)pow(10, i);
			n = n % (int)pow(10, i);
		}
		for (int i = 0; i < 8; i++) {
			for (int j = 0; j < 5; j++) {
				/*if (tama[a[j]][i] == ' ') {
					bool hantei = false;
					for (int k = j+1; k < 5; k++) {
						if (tama[a[k]][i] != ' ') {
							hantei = true;
							break;
						}
					}
					if (hantei) {
						cout << tama[a[j]][i];
					} else {
						break;
					}
				} else {*/
					cout << tama[a[j]][i];
				//}
			}
			cout << endl;
		}
		hantei2 = true;
	}
	return 0;
}

Measured memory_bytes: 1244
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  ll n;
  cin >> n;

  ll ans = 1e15;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ll j = n / i;
      ans = min(ans, i + j);
    }
  }
  cout << ans - 2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

int i,s;

char x[1001];

while(scanf("%s\n",&x),x[0]!='0'){

    s=0;

    for(i=0;x[i]!='\0';i++){

        s+=x[i]-'0';

    }

    printf("%d\n",s);

}

return 0;

}


Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
 
const int INF = 10000000;
const int mod = 1e9 + 7;
const double EPS = 1e-9;
 

int main(){
	int n;
	cin>>n;
	vll v(n, vl(n, 0LL));

	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			cin>>v[i][j];
		}
	}

	vll s(n + 1, vl(n + 1, 0LL));
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(j == 1) s[i][j] = v[i-1][j-1];
			else s[i][j] = s[i][j-1] + v[i-1][j-1];
		}
	}

	for(int i = 2; i <= n; i++){
		for(int j = 1; j <= n; j++){
			s[i][j] = s[i][j] + s[i-1][j];
		}
	}

	ll ans = s[1][1];
	for(int y1 = 1; y1 <= n; y1++){
		for(int x1 = 1; x1 <= n; x1++){
			for(int y2 = 0; y2 < y1; y2++){
				for(int x2 = 0; x2 < x1; x2++){
					ans = max(ans,s[y1][x1]-s[y1][x2]-s[y2][x1]+s[y2][x2]);
				}
			}
		}
	}

	cout<<ans<<endl;
}

Measured memory_bytes: 1376
A = input()
B = input()

if A == '1':
  if B == '2':
    print('3')
  else:
    print('2')
elif A == '2':
  if B == '1':
    print('3')
  else:
    print('1')
else:
  if B == '1':
    print('2')
  else:
    print('1')


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	ll N, ans=0;
	ll A[200005];

	cin >> N;
	rep(i,N) cin >> A[i];

	auto check = [&](ll b){
		ll sum = 0;
		rep(i,N) sum += abs(A[i] - b - i);
		return sum;
	};

	ll l = -1e9, r = 1e9;
	while(r-l > 2){
		//cout << l << " " << r << endl;
		ll m1 = (l+l+r) / 3;
		ll m2 = (l+r+r) / 3;
		if( check(m1) < check(m2) ){
			r = m2;
		}else{
			l = m1;
		}
	}
	ans = min({check(l), check(l+1), check(r)});

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
K = int(input())
s = input()
A = int(s.split(" ")[0])
B = int(s.split(" ")[1])
i = 1
mul = 1
while mul <= B:
    mul = i * K
    if A <= mul <= B:
        print("OK")
        break
    i = i + 1
else :
    print("NG")

Measured memory_bytes: 8916
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

using ll = long long;

int main() {
    int N, M;
    std::cin >> N >> M;
    std::vector<int> a(N);
    for (int i = 0; i < M; i++) {
        int k;
        std::cin >> k;

        for (int j = 0; j < k; j++) {
            int s;
            std::cin >> s;
            s--;
            a[s] |= 1 << i;
        }
    }

    int p = 0;
    for (int i = 0; i < M; i++) {
        int n;
        std::cin >> n;
        p |= n << i;
    }

    int ans = 0;
    for (int s = 0; s < (1 << N); s++) {
        int t = 0;
        for (int i = 0; i < N; i++) {
            if (s >> i & 1) {
                t ^= a[i];
            }
        }
        if (t == p)ans++;
    }

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


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    for(int a4 = 0; a4 * 4 <= 100; a4 ++){
      for(int a7 = 0; a4 * 4 + a7 * 7 <= 100; a7 ++){
        if(a4*4+a7*7 == N){
          System.out.println("Yes");
          return;
        }
      }
    }
    System.out.println("No");
    return;
  }
}

Measured memory_bytes: 21972
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline LL read(){
    LL x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-10;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 1e3+10;
const int MAXM = (int) 1e6+10;
const int sigma_size = (int) 26;

///--------------------START-------------------------
int m,n;
int a[MAXN][MAXN];
struct NODE{
    int aa,bb,cc,dd;
};
vector<NODE> ans;

void work(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
         for(int j=1;j<=m;j++)
            scanf("%d",&a[i][j]);
    }
    NODE t;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(a[i][j]%2==0) continue;
            if(i<n){
                t.aa=i,t.bb=j,t.cc=i+1,t.dd=j;
                ans.push_back(t);
                a[i][j]--;
                a[i+1][j]++;
            }
            else if(j<m){
                t.aa=i,t.bb=j,t.cc=i,t.dd=j+1;
                ans.push_back(t);
                a[i][j]--;
                a[i][j+1]++;
            }
        }
    }
    printf("%d\n",ans.size());
    for(int i=0;i<ans.size();i++){
        printf("%d %d %d %d\n",ans[i].aa,ans[i].bb,ans[i].cc,ans[i].dd);
    }
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}



Measured memory_bytes: 6128
def eratos(n):
    isPrime = [True]*(n+1)
    isPrime[0] = isPrime[1] = False
    for i in range(3,n+1,2):
        if isPrime[i]:
            j = i+i
            while j <= n:
                isPrime[j] = False
                j += i
    for i in range(4,n+1,2): isPrime[i] = False
    return isPrime

def isLikeNum(x):
    if x%2 == 0: return False
    if isPrime[x] and isPrime[(x+1)//2]: return True
    else: return False

q = int(input())
l = [0]*q
r = [0]*q
for i in range(q):
    x,y = map(int,input().split())
    l[i] = x
    r[i] = y
m = max(r)
isPrime = eratos(m)
cnt = [0]*(m+1)
for i in range(3,m+1):
    cnt[i] = cnt[i-1]
    if isLikeNum(i): cnt[i] += 1
for i in range(q): print(cnt[r[i]]-cnt[l[i]-1])

Measured memory_bytes: 13332
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
#define ll long long
#define INFTY 1 << 21

int main() {
  int N;
  cin >> N;
  vector<ll> x, y;
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    x.push_back(a);
    y.push_back(b);
  }

  //コスト0の点の数
  int cost;
  int answer = 0;
  int p, q;

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cost = 0;
      p = (x.at(j) - x.at(i));
      q = (y.at(j) - y.at(i));

      for (int k = 0; k < N; k++) {
        if (p == 0 && q == 0) break;

        for (int l = 0; l < N; l++) {
          if (y.at(l) - y.at(k) == q && x.at(l) - x.at(k) == p) {
            //コスト0の点の数
            cost++;
          }
        }
        answer = max(cost, answer);
        
      }
    }
  }

  cout << N - answer << endl;
}


Measured memory_bytes: 256
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
//auto itr=lower_bound(ALL(a),key) a[itr-a.begin()]
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;


signed main(){
    int d,n; cin >> d >> n;
    if(d==2){
        if(n==100) cout << 1010000 << endl;
        else cout << 10000*n << endl;
        return 0;
    }
    else{
        int res=0;
        rep(i,10010010){
            if(d==0&&i%100!=0)res++;
            if(d==1&&i%100==0&&i%10000!=0) res++;
            if(res==n){
                cout << i << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
'''
Accepted    　:No
difficult   　: 
ペナルティ　  　:5分
実際の回答時間  :分
WAの回数　     :回
合計時間　　  　:分
解説AC
解法：基本的な動的計画法(DP)
'''
import itertools


def myAnswer(N:int,M:int,A:list) -> int:
   safe_stairs =[True] * (N + 1)
   mod = 10**9 + 7
   for a in A:
      safe_stairs[a] = False

   DP = [0] * (N+1)
   DP[0] = 1
   if safe_stairs[1]:DP[1] = 1

   for n in range(2,N + 1):
      if safe_stairs[n - 1]:
         DP[n] += DP[n - 1]
      if safe_stairs[n - 2]:
         DP[n] += DP[n - 2]
      DP[n] %= mod

   return DP[N]
      



def modelAnswer():
   return
def main():
   N,M = map(int,input().split())
   A = [int(input()) for _ in range(M)]
   print(myAnswer(N,M,A))

if __name__ == '__main__':
   main()



Measured memory_bytes: 9604
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
int main() {
  double r;
  double pi=3.141592653589793;
  cin >> r;
  cout << fixed << setprecision(10) << r*r*pi << " " << 2*r*pi << endl;
}


Measured memory_bytes: 3288
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    if(n>=30)
    cout<<"Yes";
    else
    cout<<"No";
    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;int M=10001,i,j,c;vector<int>s(1,0),p(M);main(){for(i=1;++i<M;)for(j=i+i;j<M;j+=i)p[j]=1;for(i=1;++i<M;)if(!p[i])s.push_back(i+s.back());for(;cin>>j,j;cout<<c<<endl){vector<int>::iterator t=s.begin();for(c=0;t!=s.end();t++)c+=binary_search(t,s.end(),*t+j);}}

Measured memory_bytes: 1272
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <int, ii> iii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
#ifdef VC
#define scanf scanf_s
#endif
#define iINF (1<<30)
#define INF (1LL<<59)
#define forn(i) for(int i = 0;i < n; ++i)
#define form(i,n) for(int i = 0 ;i < n; ++i)
#define NIL -1

const ll mod = 998244353;
int n;

int main() {
	cin >> n;
	if (n < 1000) {
		cout << "ABC" << endl;
	}
	else {
		cout << "ABD" << endl;
	}
	return 0;
}

Measured memory_bytes: 256