akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	string s;
	int ans=0;
	cin >>s;
	rep(i, s.size()) { ans |= (s[i] == 'C');
		if (ans != 0) {
			ans |= (s[i] == 'F') << 1;
		}
	}
	cout<<solve(ans==3)<<endl;
}

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

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

	// freopen("input.txt","r",stdin);
	
	int n;
	cin >> n;

	bool flag = false;

	for (int i = 0; i < 30; ++i)
	{
		for (int j = 0; j < 30; ++j)
		{
			if (4*i + 7*j == n)
			{
				flag = true;
				break;
			}
		}
		if (flag) break;
	}
	if (flag) cout << "Yes";
	else cout << "No";

	return 0;
}

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

#define F first
#define S second
#define pb push_back
#define ld  double
#define ll long long
#define int long long


using namespace std;

const int MAXN = 101 * 1001 , MOD = 1e9 + 7  ;

int a[MAXN] , dp[MAXN] ;

int32_t main()
{
   ios::sync_with_stdio(0);cin.tie(0);
   int n , x ;
   cin >> n >> x;
   for(int i = 0 ; i < n ; i ++ )
    cin >> a[i] , dp[i] = a[i];
   int ans = 1e18 ;
   for(int i = 0 ; i < n ; i ++ )
   {
       int k = i * x ;
        for(int j = 0 ; j < n ; j ++ )
            dp[j] = min(dp[j],a[(j-i+n)%n]),k+=dp[j];
       ans = min(ans,k);
   }
   cout<<ans;


}


Measured memory_bytes: 256
import java.util.Scanner;
import java.text.DecimalFormat;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    double r = s.nextDouble();
    s.close();
    double a = Math.PI * (r * r);
    double c = 2 * Math.PI * r;
    DecimalFormat df = new DecimalFormat("#.00000");
    df.setRoundingMode(RoundingMode.HALF_UP);
    System.out.println(df.format(a) + " " + df.format(c));
  }
}



Measured memory_bytes: 28028
import java.util.*

private fun readStrings() = readLine()!!.split(" ")
private fun readInts() = readStrings().map { it.toInt() }

const val BLOCK_WIDTH = 100
const val BLOCK_HEIGHT = 50

class Grid: ArrayList<MutableList<Boolean>>() {

    private var currentInvertTarget = Pair(1, 1)

    init {
        for (i in (0 until BLOCK_HEIGHT)) {
            this.add((0 until BLOCK_WIDTH).map { false }.toMutableList())
        }
    }

    fun invert() {
        val (targetX, targetY) = currentInvertTarget
        this[targetY][targetX] = true

        val (newX, newY) = when {
            targetX >= BLOCK_WIDTH - 3 -> 1 to targetY + 2
            else -> targetX + 2 to targetY
        }

        currentInvertTarget = newX to newY
    }

    fun invert(times: Int): Grid {
        for (i in (0 until times)) invert()
        return this
    }

    fun toString(base: Char, inverted: Char) = this.joinToString("\n") {
        String(it.map { if (it) inverted else base }.toCharArray())
    }

}

fun main(args: Array<String>) {
    val (A, B) = readInts()

    println("${BLOCK_HEIGHT * 2} $BLOCK_WIDTH")
    println(Grid().invert(B - 1).toString('.', '#'))
    println(Grid().invert(A - 1).toString('#', '.'))
}

Measured memory_bytes: 37932
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll s,p=1e18,q=999999999999000000;
	cin>>s;
	ll x=sqrt(s);
	if(s==p){
		cout<<0<<' '<<0<<' '<<x<<' '<<0<<' '<<0<<' '<<x<<endl;
	}else if(s>=q){
		ll num=1000000000;
		cout<<0<<' '<<0<<' '<<num<<' '<<p-s<<' '<<1<<' '<<num<<endl;
	}else cout<<0<<' '<<0<<' '<<x+1<<' '<<(x+1)*(x+1)-s<<' '<<1<<' '<<x+1<<endl;
	return 0;
}


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

int main () {
    int n; cin >> n;

    int ans = 0;
    for (int i = 0; i < n; i++) {
        int temp;
        cin >> temp;

        if ((i % 2 == 0) && (temp % 2 == 1)) ans++;
    }

    cout << ans;
}

Measured memory_bytes: 3528
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<VL> VVL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

ll Max=-1000000000,Min=1e9+1;
       
int main(){
    ll x=0,y=0,z=0,n,m,h,l,k=0,w,sum=0,sum2=0,ans=0;
    string s,t;
    bool f=true;
    cin >> n >> x;
    while(n>0){
        n -= 2*x+1;
        ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
/*

// Sample code to perform I/O:

#include <iostream>

using namespace std;

int main() {
	int num;
	cin >> num;										// Reading input from STDIN
	cout << "Input number is " << num << endl;		// Writing output to STDOUT
	return 0;
}

*/

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail

// Write your code here
#include <bits/stdc++.h>

using namespace std;
long long power(long long x, 
                         long long y, long long p) 
{ 
    unsigned long long res = 1; // Initialize result 
  
    x = x % p; // 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) % p; 
  
        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % p; 
    } 
    return res; 
}

int main()
{
	long long n;
	cin>>n;
	if(n == 1)
		cout<<0<<endl;
	else if(n == 2)
		cout<<2<<endl;
	else
	{
		long long mod=1000000007;
		long long ans=(power(10,n,mod)-(2*power(9,n,mod))%mod+power(8,n,mod))%mod;
		if(ans>0)
			cout<<ans<<endl;
		else
			cout<<(ans+mod)%mod<<endl;
	}
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL INF=1e18;
const int MAX=100010;
int n,m;
char s[110];
int f(int x)
{
    printf("%d\n",x);
    fflush(stdout);
    scanf("%s",s);
    if(s[0]=='V')
        return -1;
    if(s[0]=='M')
        return 1;
    else
        return 0;
}
//int b[MAX];
int main()
{
    int i,j,k,t;
    scanf("%d",&n);

    int l=0,r=n;
    int now=f(l);
    if(now==-1)
        return 0;
    while(l<r)
    {
        int mid=(l+r)/2;
        int next=f(mid);
        if(next==-1)
            return 0;
//        int len=(mid-l+1)%2;
//        int flag=(now==next?1:0);
//            printf("%d %d\n",len,flag);
        bool f1=((mid-l)%2==1);
        bool same=((now==next)^f1);
        if(same)
        {
            l=mid;
            now=next;
        }
        else
            r=mid;
    }

    return 0;
}


Measured memory_bytes: 852
s = list(input())

alpha = [[0 for i in range(2)] for j in range(26)]

def conv(t):
    if t == 'a':
        return 0
    elif t == 'b':
        return 1
    elif t == 'c':
        return 2
    elif t == 'd':
        return 3
    elif t == 'e':
        return 4
    elif t == 'f':
        return 5
    elif t == 'g':
        return 6
    elif t == 'h':
        return 7
    elif t == 'i':
        return 8
    elif t == 'j':
        return 9
    elif t == 'k':
        return 10
    elif t == 'l':
        return 11
    elif t == 'm':
        return 12
    elif t == 'n':
        return 13
    elif t == 'o':
        return 14
    elif t == 'p':
        return 15
    elif t == 'q':
        return 16
    elif t == 'r':
        return 17
    elif t == 's':
        return 18
    elif t == 't':
        return 19
    elif t == 'u':
        return 20
    elif t == 'v':
        return 21
    elif t == 'w':
        return 22
    elif t == 'x':
        return 23
    elif t == 'y':
        return 24
    elif t == 'z':
        return 25
index = 0
for i in s:
#    print(str(index)+i)
    if alpha[conv(i)][0] == 0:
        alpha[conv(i)][0] = 1
        alpha[conv(i)][1] = index
    else:
        alpha[conv(i)][0] += 1
        if index-alpha[conv(i)][1]+1 < 2*alpha[conv(i)][0]:
            print(alpha[conv(i)][1]+1,index+1)
            exit()
        else:
            alpha[conv(i)][0] = 1
            alpha[conv(i)][1] = index
    index += 1
#    print(alpha)

print(-1,-1)

Measured memory_bytes: 4084
using System;
class Program
{
    static int n;
    static char[][] s;
    static bool Check(int a, int b)
    {
        bool f = true;
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= n; j++)
                f = f && s[Mod(i + a - 1)][Mod(j + b - 1)] == s[Mod(j + a - 1)][Mod(i + b - 1)];
        return f;
    }
    static int Mod(int m) { return m % n; }
    static void Main()
    {
        n = int.Parse(Console.ReadLine());
        s = new char[n][];
        for (int i = 0; i < n; i++)
            s[i] = Console.ReadLine().ToCharArray();
        int ans = 0;
        for (int i = 0; i < n; i++)
            if (Check(0, i))
                ans++;
        Console.WriteLine(ans * n);
    }
}

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

int main(){
    
    int x;
    cin>>x;
    
    int ans;
    
    if(599>=x && 400<=x) ans = 8;
    else if(799>=x && 600<=x) ans = 7;
    else if(999>=x && 800<=x) ans = 6;
    else if(1199>=x && 1000<=x) ans = 5;
    else if(1399>=x && 1200<=x) ans = 4;
    else if(1599>=x && 1400<=x) ans = 3;
    else if(1799>=x && 1600<=x) ans = 2;
    else if(1999>=x && 1800<=x) ans = 1;
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3648
/**
  *  Worg
  */
#include <cstdio>

//FILE *fin = freopen("main.in", "r", stdin); FILE *fout = freopen("main.out", "w", stdout);

int N, M;
char a[200];
int count[26];


int main() {
    scanf("%d%d", &N, &M);
    for(int i = 1; i <= N; i++) {
        scanf("%s", a + 1);
        for(int j = 1; j <= M; j++) {
            count[a[j] - 'a'] ++;
        }
    }

    if(N % 2 == 0 && M % 2 == 0) {
        for(int i = 0; i < 26; i++) {
            if(count[i] % 4 != 0) {
                printf("No\n"); return 0;
            }
        }
        printf("Yes\n"); return 0;
    } else if((N + M) % 2 == 0) {
        int wanted = (N - 1) * (M - 1);
        for(int i = 0; i < 26; i++) {
            while(wanted > 0 && count[i] != 0 && count[i] >= 4) {
                wanted -= 4; count[i] -= 4;
            }
        }

        if(wanted > 0) {
            printf("No\n"); return 0;
        }

        int x = 0;
        for(int i = 0; i < 26; i++) {
            if(count[i] % 2 == 1) {
                x ++;
            }
        }

        if(x != 1) {
            printf("No\n"); return 0;
        }

        printf("Yes\n");
    } else if(N % 2 == 0) {
        int wanted = N * (M - 1);
        for(int i = 0; i < 26; i++) {
            while(wanted > 0 && count[i] != 0 && count[i] >= 4) {
                wanted -= 4; count[i] -= 4;
            }
        }

        if(wanted > 0) {
            printf("No\n"); return 0;
        }

        int x = 0;
        for(int i = 0; i < 26; i++) {
            if(count[i] % 2 == 1) {
                x ++;
            }
        }

        if(x != 0) {
            printf("No\n"); return 0;
        }

        printf("Yes\n");
    } else if(M % 2 == 0){
        int wanted = (N - 1) * M;
        for(int i = 0; i < 26; i++) {
            while(wanted > 0 && count[i] != 0 && count[i] >= 4) {
                wanted -= 4; count[i] -= 4;
            }
        }

        if(wanted > 0) {
            printf("No\n"); return 0;
        }

        int x = 0;
        for(int i = 0; i < 26; i++) {
            if(count[i] % 2 == 1) {
                x ++;
            }
        }

        if(x != 0) {
            printf("No\n"); return 0;
        }
        printf("Yes\n");
    }

	return 0;
}


Measured memory_bytes: 128
import sys
from collections import deque
input = sys.stdin.readline


def inv_gcd(a, b):
    a = (a + b) % b
    if a == 0:
        return (b, 0)
    s, t = b, a
    m0, m1 = 0, 1

    while t:
        u = s // t
        s -= t * u
        m0 -= m1 * u

        tmp = s
        s = t
        t = tmp
        tmp = m0
        m0 = m1
        m1 = tmp
    
    if m0 < 0:
        m0 += b // s
    return (s, m0)


def crt(r, m):
    n = len(r)
    r0, m0 = 0, 1

    for i in range(n):
        r1, m1 = (r[i] + m[i]) % m[i], m[i]

        if m0 < m1:
            m0, m1 = m1, m0
            r0, r1 = r1, r0
        
        if m0 % m1 == 0:
            if r0 % m1 != r1:
                return (0, 0)
            continue
        
        g, im = inv_gcd(m0, m1)

        u1 = m1 // g
        if (r1 - r0) % g:
            return (0, 0)
        
        x = (r1 - r0) // g % u1 * im % u1

        r0 += x * m0
        m0 *= u1
        if (r0 < 0):
            r0 += m0
        
    return (r0, m0)


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors


def main():
    n = int(input())
    divisors = make_divisors(2 * n)

    ans = n-1 if n%2 else 2*n-1
    for x in divisors:
        y = n * 2 // x
        if y == 1:
            continue
        r = [0, y-1]
        m = [x, y]
        rem, mod = crt(r, m)
        if rem == mod == 0:
            continue
        ans = min(ans, rem)

    
    print(ans if n-1 else 1)

    
if __name__ == "__main__":
    main()



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

using namespace std;

const int MAX_N = 100, INF = MAX_N;

int n, minA, a[MAX_N + 1], invA[2 * MAX_N + 1];

bool exist;

int main() {
    cin >> n;

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

    for (int i = 1; i <= n; i++) {
        invA[i] = 0;
    }

    for (int i = 1; i <= n; i++) {
        invA[a[i]]++;
    }

    minA = INF;
    for (int i = 1; i <= n; i++) {
        minA = min(minA, a[i]);
    }

    exist = true;

    if (invA[minA] == 1) {
        for (int i = minA + 1; i <= 2 * minA; i++) {
            if (invA[i] < 2) {
                exist = false;
            }
        }

        for (int i = 2 * minA + 1; i < n; i++) {
            if (invA[i] > 0) {
                exist = false;
            }
        }
    }

    if (invA[minA] == 2) {
        for (int i = minA + 1; i < 2 * minA; i++) {
            if (invA[i] < 2) {
                exist = false;
            }
        }

        for (int i = 2 * minA; i < n; i++) {
            if (invA[i] > 0) {
                exist = false;
            }
        }
    }

    if (invA[minA] > 2) {
        exist = false;
    }

    if (exist) {
        cout << "Possible" << '\n';
    } else {
        cout << "Impossible" << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();
        int res = 0;
        for(int i=0; i<n; i++) {
            int h = sc.nextInt();
            if(h >= k) res++;
        }



        System.out.println(res);

    }


}


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

int gcd(int a, int b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

    vector<int> l(N + 1), r(N + 1);
    l[0] = 0, r[N] = 0;
    for (int i = 0; i < N; i++)
        l[i + 1] = gcd(l[i], A[i]);
    for (int i = N - 1; i >= 0; i--) {
        r[i] = gcd(r[i + 1], A[i]);
    }

    int res = 0;
    for (int i = 0; i < N; i++) {
        int left = l[i];
        int right = r[i + 1];

        res = max(res, gcd(left, right));
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin >> N;
  double x[N];
  char u[N][4];
  for (int i=0;i<N;i++){
    cin >> x[i];
    cin >> u[i];
  }
  double ans=0;
  for (int i=0;i<N;i++){
    if (u[i][0]=='B')ans+=x[i]*380000;
    else if (u[i][0]=='J') ans+=x[i];
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int a[16][10], s, b, c, d, e;
	scanf("%d", &s);
	for (int x = 0; x<16; x++) {
		for (int y = 0; y<10; y++) {
			a[x][y] = 0;
		}
	}
	for (int i = 0; i<s; i++) {
		scanf("%d %d %d %d", &b, &c, &d, &e);
		a[(b - 1) * 3 + c - 1][d - 1] += e;
	}
	for (int x = 0; x<4; x++) {
		for (int y = 0; y<3; y++) {
			for (int z = 0; z<10; z++) {
				printf(" %d", a[x * 3 + y][z]);
			}
			printf("\n");
		}
		if (x<3)printf("####################\n");
	}
}

Measured memory_bytes: 1040
#include<stdio.h>
int main(){
	int a,b,c,k;
	int maximum=0;
	int hasil=0;
	scanf("%d %d %d %d",&a,&b,&c,&k);
	
	if(maximum<a){
		maximum=a;
	}
	if(maximum<b){
		maximum=b;
	}
	if(maximum<c){
		maximum=c;
	}
	if(maximum==a){
		hasil=b+c;
	}
	if(maximum==b){
		hasil=a+c;
	}
	else{
		hasil=a+b;
	}
	
	for(int i=1;i<=k;i++){
		maximum*=2;
	}
	
	printf("%d\n",hasil+maximum);
	
	return 0;
}

Measured memory_bytes: 128
/*
 ________  ___   ___  ________
|\   __  \|\  \ |\  \|\   __  \
\ \  \_\ /\ \  \\_\  \ \  \|\  \
 \ \   __\_\ \______  \ \  \\\  \
  \ \  \_\  \|_____|\  \ \  \\\  \
   \ \______/|     \ \__\ \_______\
    \|______|/      \|__|\|_______|

*/
#include<bits/stdc++.h>

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

#define fe(i,a,b) for(int i=a;i<=b;i++)
#define fne(i,a,b) for(int i=a;i<b;i++)

#define all(x) x.begin(),x.end()
#define pb push_back
#define lowbit(x) x&-x
#define lc rt<<1
#define rc rt<<1|1
#define ls lc,l,m
#define rs rc,m+1,r

#define dbg(x) cout<<' '<<#x<<" = "<<x<<endl;
#define dbg2(x,y) {cout<<' '<<#x<<" = "<<x<<',';dbg(y)}
#define dbg3(x,y,z) {cout<<' '<<#x<<" = "<<x<<',';dbg2(y,z)}

int read(int &x){return scanf("%d",&x);}
int read(ll &x){return scanf("%lld",&x);}
int read(double &x){return scanf("%lf",&x);}

int read(int &x,int &y){return scanf("%d%d",&x,&y);}
int read(ll &x,ll &y){return scanf("%lld%lld",&x,&y);}
int read(double &x,double &y){return scanf("%lf%lf",&x,&y);}

int read(int &x,int &y,int &z){return scanf("%d%d%d",&x,&y,&z);}
int read(ll &x,ll &y,ll &z){return scanf("%lld%lld%lld",&x,&y,&z);}
int read(double &x,double &y,double &z){return scanf("%lf%lf%lf",&x,&y,&z);}

ll qpow(ll a,ll b,ll mod){if(a==0)return 0;ll ans=1;a%=mod;while(b){if(b&1)ans=ans*a%mod;a=a*a%mod;b>>=1;}return ans%mod;}
ll inv(ll x,ll mod){return qpow(x,mod-2,mod);}


int dir[4][2]={0,1,0,-1,1,0,-1,0};
int mon[13]={ 0,31,28,31,30,31,30,31,31,30,31,30,31};

const int INF =0x3f3f3f3f;
const int mod = 1e9+7;
const int N = 5e5+5;

struct DSU{
	int f[N];
	void init(int n){fe(i,0,n)f[i] = i;}//remember initial
	int fa(int x){return f[x]==x?x:f[x]=fa(f[x]);}
	void join(int x,int y){x=fa(x);y=fa(y);if(x!=y)f[x]=y;}
};
struct CombMath{
	int C[2005][2005];
    void init(int n){
		fe(i,1,n)
			fe(j,1,n)
                C[i][j] = (C[i-1][j] + C[i-1][j-1])%mod;
    }
};

char s[N];
//ll a[N];

signed main(){
//	freopen("in1.txt","r",stdin);
//	freopen("in2.txt","r",stdin);
//	freopen("in3.txt","r",stdin);
//	freopen("in4.txt","r",stdin);
//	freopen("in5.txt","r",stdin);
//	freopen("BZW.txt","r",stdin);


	int a,b;
	read(a,b);
	printf("%d\n",max(a-b*2,0));




    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define LL long long
using namespace std;

int main () {
    //clock_t start = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans =0 ;
    for (int i=0;i<s.size()-2;i++) {
        if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ans++;
    }
    cout << ans << endl;
    //cerr << fixed << setprecision(3) << (clock()-start)*1./CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

fn solve(n: i64, k: i64) -> i64 {
    use std::cmp::max;

    (k+1..n+1).fold(0, |sum, b| sum + {
        let p = n / b;
        let r = n % b;
        let v = p * (b-k) + max(0, r - k + 1)
            - if k == 0 { 1 } else { 0 };
        v
    })
}

fn main() {
    let (n, k) = parse_line!(i64, i64);
    println!("{}", solve(n, k));
}

#[test]
fn solve_test() {
    assert_eq!(solve(5,2), 7);
    assert_eq!(solve(10, 0), 100);
    assert_eq!(solve(31415, 9265), 287927211);
}


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

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXMLT = 300;
const int MAXN = 299;

int n;
int mlt[MAXN], val[MAXN];

vector<int> p;
vector<int> cnt;

int ans;
void rec(int at) {
	if (at < SZ(p)) {
		int mlt = 1;
		for (cnt[at] = 0; mlt <= MAXMLT; ++cnt[at], mlt *= p[at]) rec(at + 1);
	} else {
		int cur = 0;
		map<int, int> extra;
		REP(i, n) {
			int x = mlt[i]; bool ok = true;
			REPSZ(j, p) { int now = 0; while (x%p[j] == 0) x /= p[j], ++now; if (now > cnt[j]) ok = false; }
			if (!ok) continue;
			if (x == 1)  cur += val[i]; else extra[x] += val[i];
		}
		for (auto it = extra.begin(); it != extra.end(); ++it) if (it->second > 0) cur += it->second;
		if (cur > ans) ans = cur;
	}
}

void run() {
	scanf("%d", &n); REP(i, n) scanf("%d%d", &mlt[i], &val[i]);

	p.clear(); for (int i = 2; i*i <= MAXMLT; ++i) { bool ok = true; for (int j = 2; j*j <= i; ++j) if (i%j == 0) ok = false; if (ok) p.PB(i); }
	//printf("p:"); REPSZ(i, p) printf(" %d", p[i]);

	cnt = vector<int>(SZ(p)); ans = INT_MIN;
	rec(0);
	printf("%d\n", ans);
}

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


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

const int COM_MAX = 550000;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}

long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

long long pow_mod(long long n,long long k,long long m){
    if (k == 0){
        return 1;
    } else if (k % 2 == 1){
        return pow_mod(n,k-1,m)*n % m;
    } else {
        long long t = pow_mod(n,k/2,m);
        return t*t % m;
    }
}

int main(){
    int N; cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++){
        cin >> A[i];
    }
    long long sum = 0,xr = 0,right = 0;
    long long ans = 0;
    for (int left = 0; left < N; left++){
        while (right < N && (sum + A[right] == (xr^A[right]))){
            ans += (right - left + 1);
            sum += A[right], xr ^= A[right];
            right++;
        }
        if (right == left) right++;
        else {
            sum -= A[left];
            xr ^= A[left];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    int a, b;
    cin>>a>>b;
    int cost = MAX3( 2*a -1 , 2*b - 1, a+b);
    cout<<cost;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;
const lli mod = 1e9 +7;
const lli inf = 1e9;

int main(){
    int n,w;
    cin >> n >> w;
    vector<lli> weight(n+1, inf);
    for(int i=0; i<n; i++) cin >> weight[i];
    sort(weight.begin(), weight.end(), greater<lli>());
    
    vector<vector<lli> > dp(n+1, vector<lli>(w+1, 0));
    dp[0][0] = 1;
    for(int r=1; r<=n; r++){
        vector<vector<lli> > ndp(n+1, vector<lli>(w+1, 0));
        for(int i=0; i<=n; i++){
            for(int j=w; j>=0; j--){
                if(dp[i][j] == 0) continue;
                ndp[r][j] = (ndp[r][j] +dp[i][j])%mod;
                if(j+weight[r] <= w){
                    ndp[i][j+weight[r]] = (ndp[i][j+weight[r]] +dp[i][j])%mod;
                }
            }
        }
        dp = ndp;
    }
    lli ans = 0;
    for(int i=0; i<=n; i++){
        for(int j=0; j<=w; j++){
            if(j+weight[i] > w){
                ans = (ans +dp[i][j])%mod;
            }
        }
    }
    cout << ans << endl;
    return 0;
}



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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int64 N;
vector<int64> a;
vector<int64> G[212345];
vector<int64> res;
stack<PLL> undo;
vector<int64> lis;

void dfs(int64 v, int64 p) {
  int64 idx = lower_bound(all(lis), a[v]) - lis.begin();
  undo.emplace(idx, lis[idx]);
  lis[idx] = a[v];
  res[v] = lower_bound(all(lis), INF_LL) - lis.begin();

  for (auto& u: G[v]) {
    if (u == p) continue;
    dfs(u, v);
  }

  lis[undo.top().fs] = undo.top().sc;
  undo.pop();
}

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

  int64 N, M, Q;
  cin >> N >> M >> Q;
  vector<int> comb(M+N-1, 0);
  REP(i, N) comb[M+N-1-i-1] = 1;
  vector<int64> a(Q), b(Q), c(Q), d(Q);
  REP(i, Q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  int64 res = 0;
  do {
    vector<int64> A;
    int64 cnt = 0;
    REP(i, comb.size()) {
      if (comb[i]) A.push_back(cnt+1);
      else cnt++;
    }
    int64 sum = 0;
    REP(i, Q) {
      if (A[b[i]-1] - A[a[i]-1] == c[i]) sum += d[i];
    }
    chmax(res, sum);
  } while(next_permutation(all(comb)));
  cout << res << endl;
}



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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<int, int> P;

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

int main(){
    int n, m, ans = 0;
    cin >> n >> m;

    vector<vector<int> > vec(m);
    vector<int> p(m);

    REP(i, m) {
        int k;
        cin >> k;
        vec[i].resize(k);
        REP(j, k) {
            cin >> vec[i][j];
            vec[i][j]--;
        }
    }
    REP(i, m) cin >> p[i];

    REP(i, (1 << n)) {
        bool isON = true;
        REP(j, m) {
            int cnt = 0;
            REP(k, vec[j].size()) if((i >> vec[j][k]) & 1) cnt++;
            if((cnt % 2) != p[j]) isON = false; 
        }
        if(isON) ans++;        
    } 

    cout << ans << endl;

    return 0;
}


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

using namespace std;

class range {
private:
  struct Iterator {
    int val, inc;
    int operator*() {return val;}
    bool operator!=(Iterator& itr) {return val != itr.val;}
    void operator++() {val += inc;}
  };
  Iterator i, n;
public:
  range(int n) : i({0, 1}), n({n, 1}) {}
  range(int i, int n) : i({i, 1}), n({n, 1}) {}
  range(int i, int inc, int n) : i({i, inc}), n({n, inc}) {}
  Iterator& begin() {return i;}
  Iterator& end() {return n;}
};

template<class T> inline T at(const vector<T> &v, int i) {return v[(i % (int)v.size() + v.size()) % v.size()];}

template<class T> inline bool is_max(T &a, const T &b) {return a < b ? a = b, true : false;}
template<class T> inline bool is_min(T &a, const T &b) {return a > b ? a = b, true : false;}

int main() {
  for (int i : range(1, 10)) for (int j : range(1, 10)) cout << i << "x" << j << "=" << i * j << endl;
}

Measured memory_bytes: 1112
import math
N=int(input())-1
c,s,f=[],[],[]
for i in range(N):
    a=list(map(int,input().split()))
    c.append(a[0])
    s.append(a[1])
    f.append(a[2])
for j in range(N):
    t=c[j]+s[j]
    for k in range(1,N-j):
        if s[j+k]>=t:
            t=s[j+k]+c[j+k]
        else:
            t=math.ceil((t-s[j+k])/f[j+k])*f[j+k]+s[j+k]+c[j+k]
    print(t)
print("0")    

Measured memory_bytes: 3188
N = int(input())
heights = list(map(int, input().split(" ")))
diffs = [a - b for a, b in zip(heights[:-1], heights[1:])]

max = 0
count = 0
for d in diffs:
  if d >= 0:
    count += 1
  else:
    if max < count:
      max = count
    count = 0
if max < count:
  max = count
print(max)

Measured memory_bytes: 14224
package main

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

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	var s string
	fmt.Scan(&s)
	rs := []rune(s)
	n := len(rs)

	children := make([]int, n)

	cntR := 0
	for i := 0; i < n; i++ {
		switch {
		case rs[i] == 'R':
			cntR++
		case rs[i] == 'L':
			children[i] += cntR / 2
			children[i-1] += (cntR + 1) / 2
			cntR = 0
		}
	}

	cntL := 0
	for i := n - 1; i >= 0; i-- {
		switch {
		case rs[i] == 'L':
			cntL++
		case rs[i] == 'R':
			children[i] += cntL / 2
			children[i+1] += (cntL + 1) / 2
			cntL = 0
		}
	}

	for i := 0; i < n-1; i++ {
		fmt.Print(children[i])
		fmt.Print(" ")
	}
	fmt.Println(children[n-1])
}


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

typedef long long ll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define endl '\n'
#define mod 1000000007
#define PI 3.1415926535897932384626

#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(),x.end()

void io() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}

const ll lim=1e18;

void solve() {
	int n;
	cin>>n;
	vector<ll> v(n);
	bool zero=false;
	for(int i=0;i<n;i++) {
		cin>>v[i];
		if(v[i]==0) {
			zero=true;
			break;
		}
	}
	if(zero) {
		cout<<0;
		return;
	}
	ll prod=1;
	for(int i=0;i<n;i++) {
		if(v[i]<=lim/prod) {
			prod*=v[i];
		}
		else {
			cout<<-1;
			return;
		}
	}
	cout<<prod;
	return;
}

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

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

int main(){

    int N;
    string S;
    cin >> N;
    cin >> S;


    int ans = 0;

    for( int i = 1; i < N-1; i++ ){ // 0~i-1, i~N-1で文字列を切る
        int species = 0;
        string str;
        for( int j = 0; j < i; j++ ){ // 切った文字列の左側
            for( int k = i; k < N; k++ ){ // 切った文字列の右側
                if( S[j] == S[k] ){
                    bool match = false;
                    for( int l = 0; l < str.size(); l++ ){
                        if( str[l] == S[j] ) match = true;
                    }
                    if( ! match ){
                        species++;
                        str.push_back( S[j] );
                    }
                }
            }
        }
        ans = max( ans, species );
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 256
s = input()
t = input()
ls = len(s)
lt = len(t)
ans = "z"*ls

for i in range(ls-lt+1):
    for j in range(lt):
        if s[i+j] != t[j] and s[i+j] != "?":
            break
    else:
        tmp = (s[:i]+t+s[i+lt:]).replace("?","a")
        if ans > tmp:
            ans = tmp
else:
    if ans == "z"*ls:
        ans = "UNRESTORABLE"

print(ans)

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

int main() {
  int n,cnt=0; cin >> n;
  vector<ll> a(n);
  ll sum=0;
  rep(i,n){
    cin >> a[i];
    sum+=abs(a[i]);
   if(a[i]<0)cnt++;
   a[i]=abs(a[i]);
  }

  if(cnt%2==0){
    cout << sum << endl;
  }
  else{
    sort(a.begin(),a.end());
    sum-=2*a[0];
    cout << sum << endl;
  }


}


Measured memory_bytes: 1024
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size))scanf("%d",&(name)[i])
#define MOD 1000000007

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=n;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    GI2(H,W);
    vector<vector<int>> a(H,vector<int>(W));
    FOR(i,H){
        FOR(j,W){
            cin>>a[i][j];
        }
    }
    int N=0;
    vector<string> ans;
    FOR(i,H){
        FOR(j,W){
            if(a[i][j]%2==1){
                if(j!=W-1){
                    ans.push_back(to_string(i+1)+" "+to_string(j+1)+" "+to_string(i+1)+" "+to_string(j+2));
                    a[i][j+1]++;
                    N++;
                }else if(i!=H-1){
                    ans.push_back(to_string(i+1)+" "+to_string(j+1)+" "+to_string(i+2)+" "+to_string(j+1));
                    a[i+1][j]++;
                    N++;
                }
            }
        }
    }
    print(N);
    for(string s:ans)print(s);
    return 0;
}

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

using namespace std;

const int MAX_N = 1e5;
const int MOD = 1e9+7;

int N;
bool visited[MAX_N];
vector<vector<int> > G; 
long long dp_black[MAX_N], dp_white[MAX_N];

void dfs(int v) {
	visited[v] = true;
	int s = G[v].size();
	for(int i = 0; i < s; i++) {
		int u = G[v][i];
		if(!visited[u]) {
			dfs(u);
			dp_black[v] = (dp_black[v] * dp_white[u]) % MOD;
			dp_white[v] = (dp_white[v] * (dp_white[u] + dp_black[u])) % MOD;
		} 
	}
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> N;
	fill(dp_white, dp_white+N, 1);
	fill(dp_black, dp_black+N, 1);
	G.assign(N, vector<int>());
	for(int i = 1; i < N; i++) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		G[x].push_back(y);
		G[y].push_back(x);
	} 
	dfs(0); 
	cout << ((dp_white[0] % MOD) + (dp_black[0] % MOD)) % MOD;
}

Measured memory_bytes: 12928
/*
No i'm not down, No I'm not out
*/
#include <bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll  long long
#define f(i,a,b) for(int i=a; i<b; i++)
#define pb push_back
#define MP make_pair
#define vi vector<int>
#define vll vector<long long>
#define M map<int,int>
#define F     first
#define S    second
#define nl "\n"
#define lb lower_bound
#define ub upper_bound
#define max(a, b) (a < b ? b : a)
#define min(a, b) (a > b ? b : a)
#define mem(a,n)  memset(a, n, sizeof(a))
#define all(v) v.begin(), v.end()
int dx[8] ={0, 0, 1, 1, 1, -1, -1, -1};
int dy[8] ={1, -1, -1, 0, 1, -1, 0, 1};
#define mod 10000007
#define N 100005

using namespace std;

int main()
{
    fast();
    int n, w;
    cin >> n >> w;
    ll weight[n], cost[n], sum = 0;
    f(i, 0, n)cin >> weight[i] >> cost[i], sum += cost[i];
    // cout << sum << nl;
    ll dp[sum + 5] = {}, curr[sum + 5];
    f(i, 0, sum + 1)dp[i] = INT_MAX;
    dp[0] = 0;
    f(i, 0, n)
    {
        f(j, 1, sum+1)
        {
            // cout<< j << " " << dp[j] <<" " << dp[j-weight] << "\n";
            if(j < cost[i])curr[j] = dp[j];
            else curr[j] = min(
                (dp[j-cost[i]] + weight[i]), dp[j]);
        }
        f(j, 1, sum+1)dp[j] = curr[j] ;
        // cout << "\n";
    }
    ll ans = 0;
    f(i, 1, sum+1)
    {
        if(dp[i] <= w)
            ans = i;
    }
    cout<< ans ;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define ic_a int a;cin>>a;
#define ic_b int b;cin>>b;
#define ic_s string s;cin>>s;
#define Rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {
	Rapid_pleaseAC_fast;

	llint n, a, b;
	cin >> n >> a >> b;
	llint ans = n / (a + b) * a;

	if (n % (a + b) > a) {
		ans += a;
	}
	else {
		ans += n % (a + b);
	}
	cout << ans << rt;

	please AC;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
r = sum(b)
for i in range(n - 1):
    if a[i + 1] == a[i] + 1:
        r += c[a[i] - 1]
print(r)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793
 
   
int main(){
  string s;
  cin >> s;
    int n=s.size();
    rep(i,n){
        cout << s.at(i);
        if(i==3){
            cout << " ";
        }
    }
    cout << endl;
} 

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<int,int> pii;
typedef vector<lli> vi;
typedef vector<vi> vvi;

int main(){__
	int n;
	cin >> n;
	vi a(n),b(n);
	for(int i=0; i <n; i++){
		cin >> a[i] >> b[i];
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	lli l = 0, r = 0;
	lli ans =0;
	if(n&1){
		r = b[n/2];
		l = a[n/2];
		ans = r-l+1;
	}
	else{
		l = a[n/2] + a[(n/2)-1];
		r = b[n/2] + b[(n/2)-1];
		if(l == r){
			cout << 1 << endl;
			return 0;
		}
		if(l&1){
			ans++;
			l/=2;
			l++;
		}
		else l/=2;
		
		if(r&1){
			ans++;
			r/=2;
		}
		else r/=2;
		if(r >= l){
			lli tam= r-l+1;
			ans+= tam + tam-1;
		}
	}
	cout << ans<< endl;
	return 0;
}
				


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


int main(){
  int x, y, z, d;
  
  cin>>x>>y>>z>>d;
  if(d<x){
      cout<<d<<endl;
  }
  if(x<=d && d<=x+y){
      cout<<x<<endl;
  }
  if(d>x+y){
      cout<<x+(d-x-y)*-1<<endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() {
	int x[3000], y[3000],i=0,c,temp;
	while (1){
		scanf("%d %d", &x[i], &y[i]);
		if (0 == x[i] && 0 == y[i]) {
			c = i;
			break;
		}
		if (x[i] > y[i]) {
			temp = x[i];
			x[i] = y[i];
			y[i] = temp;
		}
		i++;
	}
	for ( i = 0; i < c; i++){
		printf("%d %d\n", x[i], y[i]);

	}
}

Measured memory_bytes: 2728