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

using namespace std;

const int N = 305;
int n, m, cnt[3 * N][3 * N], ans;
char c[3 * N][3 * N], cc[3 * N][3 * N];

bool valid (int x, int y) { return x > 0 && y > 0 && x <= n && y <= m; }

void rotation () {
    for (int i = 0; i < 3 * N; ++i) {
        for (int j = 0; j < 3 * N; ++j) {
            cc[i][j] = '.';
        }
    }
    for (int i = 1; i <= m; ++i) {
        for (int j = 1; j <= n; ++j) {
            cc[i + m][j + n] = c[j + n][m + 1 - i + m];
        }
    }
    swap(n, m);
    for (int i = 0; i < 3 * N; ++i) {
        for (int j = 0; j < 3 * N; ++j) {
            c[i][j] = '.';
        }
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            c[i + n][j + m] = cc[i + n][j + m];
        }
    }
}

void solve () {
    memset(cnt, 0, sizeof cnt);
    for (int i = 1; i <= 3 * n; ++i) {
        for (int j = 1; j <= 3 * m; ++j) {
            cnt[i][j] = cnt[i - 1][j + 1] + (c[i][j] == '#');
        }
    }
    for (int x = 1; x <= n; ++x) {
        for (int y = 1; y <= m; ++y) {
            for (int d = 1; d <= n; ++d) {
                int X = x - d, Y = y + d;
                if (!valid(X, Y) || c[x + n][y + m] == '.' || c[X + n][Y + m] == '.') continue ;
                ans += cnt[x - d + n][y - d + m] - cnt[x - 2 * d + n][y + m];
            }
        }
    }
}

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            cin >> c[i + n][j + m];
        }
    }

    for (int _ = 0; _ < 4; ++_) {
        solve();
        rotation();
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 5120
using System;

	class MainClass
	{
		public static void Main ()
		{

		while (true)
		{
			string str = Console.ReadLine ();
			string[] spStr = str.Split (' ');

			int h = int.Parse (spStr [0]);
			int m = int.Parse (spStr [1]);

			if (h == 0 && m == 0) {break;}

			for (int i = 0; i < h; i++) {
				for (int j = 0; j < m; j++) {
					Console.Write ("#");
					if (j == m - 1) {
						Console.WriteLine ("");
					}
				}
			}
			Console.WriteLine ("");
		}
	}
}

Measured memory_bytes: 9052
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Main{
    static int[] memo;
    static int[] val;
    static int n;
    public static void main(String[] args) throws IOException {
        scanner sc = new scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        n = sc.nextInt();
        val = new int[n];

        for (int i = 0; i < n; i++)
            val[i] = sc.nextInt();

        memo = new int[n];
        Arrays.fill(memo,-1);


        out.println(dp(0));
        out.flush();
    }

    static int dp(int i){
        if (i == n-1)
            return 0;

        if (memo[i] != -1)
            return  memo[i];

        int one = Integer.MAX_VALUE-1;
        int two = Integer.MAX_VALUE-1;
        if (i+1 < n)
            one = dp(i+1) + Math.abs(val[i]-val[i+1]);
        if (i+2 < n)
            two = dp(i+2) + Math.abs(val[i]-val[i+2]);

        return memo[i] = Math.min(one,two);
    }

}
class scanner{
    StringTokenizer st;
    BufferedReader br;
    public scanner(InputStream s){
        br = new BufferedReader(new InputStreamReader(s));
    }
    public scanner (String s) throws FileNotFoundException { br = new BufferedReader(new FileReader(s));}

    public String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    public long nextLong() throws IOException {
        return  Long.parseLong(next());
    }

    public String nextLine() throws IOException {
        return br.readLine();
    }

    public boolean ready() throws IOException {
        return br.ready();
    }
}

Measured memory_bytes: 44984
#include <iostream>

using namespace std;


int main(){
    int K, S, count;

    cin >> K >> S;

    for (int X = 0; X <= K; X++) {
        for (int Y = 0; Y <= K; Y++) {
            int Z = S - X - Y;
            if(Z >= 0 && Z <= K) count++;
            }
        }


    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int x = c - a;
	int y = d - b;
	cout << c - y << ' ' << d + x << ' ' << c - y - x << ' ' << d + x - y << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		// ABC11X_A();
		ABC11X_B();
		// ABC11X_C();
		// ABC11X_D();
	}

	private static void ABC11X_A() {
		Scanner scanner = null;
		int amountX = 0;
		int amountY = 0;

		try {
			scanner = new Scanner(System.in);
			amountX = scanner.nextInt();
			amountY = scanner.nextInt();

			int total = amountX + (amountY / 2);

			System.out.println(total);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private static void ABC11X_B() {
		Scanner scanner = null;
		int numN = 0;
		double numT = 0;
		double numA = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();
			numT = scanner.nextInt();
			numA = scanner.nextInt();

			int[] wkTemparture = new int[numN];

			double minA = Double.MAX_VALUE;
			int targetN = Integer.MAX_VALUE;
			for (int i = 0; i < wkTemparture.length; i++) {
				wkTemparture[i] = scanner.nextInt();
				double wkTemp = Math.abs(numA - (numT - wkTemparture[i] * 0.006));
				if (minA > wkTemp) {
					minA = wkTemp;
					targetN = i;
				}
			}

			System.out.println(targetN + 1);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private static void ABC11X_C() {
		Scanner scanner = null;
		int lineAB = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println();

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private static void ABC11X_D() {
		Scanner scanner = null;
		int lineAB = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println();

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 24020
package main

import "fmt"

func main() {
	var n, x int
	fmt.Scan(&n, &x)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	ans := 0
	if d := a[0] - x; d > 0 {
		a[0] -= d
		ans += d
	}

	for i := 1; i < n; i++ {
		if d := (a[i-1] + a[i]) - x; d > 0 {
			a[i] -= d
			ans += d
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 5504
sec  = int(input())

hh = 0
mm = 0
ss = 0
 
while sec >= 3600:
    hh += 1
    sec -= 3600
    
while sec >= 60:
    mm += 1
    sec -= 60
    
ss = sec

print(hh, ':',mm, ':', ss, sep='')         


Measured memory_bytes: 5592
#include<bits/stdc++.h>
#define int long long
//#pragma gcc optimize("Ofast, unroll-loops")
//#pragma gcc target("sse, sse2, sse3, ssse3, sse4, popcnt, abm, mmx, avx, avx2, tune = native")

using namespace std;

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

    int n, k, t;
    vector<int> v;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> t, v.push_back(t);
    sort(v.begin(), v.end());

    for (int i = 1; i < n; i++)
        if (v[i] == v[i - 1])
            cout << "NO\n", exit(0);
    cout << "YES\n";

    return 0;
}

//      *   *  *****  *   *  *   *
//     *   *  *      **  *  *   *
//    *****  *****  * * *  *   *
//   *   *      *  *  **  *   *
//  *   *  *****  *   *   ***

//      ***** ***** *   * *     ***** *   * ***** *****
//        *  *   * *   * *       *   **  *   *   *   *
//       *  *   * ***** *       *   * * *   *   *****
//   *  *  *   *   *   *       *   *  **   *   *
//  ****  *****   *   ***** ***** *   *   *   *


Measured memory_bytes: 2420
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
using namespace std;
int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  inputV(a, n);
  int ans = 1e9;
  for(int i=0; i+k-1<n; i++){
    ans = min(ans, a[i+k-1]-a[i] + min(abs(0-a[i]), abs(0-a[i+k-1])));
  }
  cout << ans << endl;
  return 0;
}




//


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

void freqApp (vector <int> s, vector <int>& p )
{
	int size = s.size();
	map <int, int> count;
	int i;

	for (i = 0; i < size; ++i){
		++count[s[i]];
	} // end for

	for (i = 0; i < size; ++i){
		p[i] = count[s[i]];
	} // end for
}

bool isfixpoint (vector <int> s, vector <int> p )
{
	int size = s.size();
	int i;

	for (i = 0; i < size; ++i){
		if (s[i] == p[i] ){
			continue;
		}else{
			return false;
		} // end if
	} // end for

	return true;
}

void disp_array (vector <int> a )
{
	int size = a.size();
	int i;

	for (i = 0; i < size; ++i){
		cout << a[i];
		if (i != size - 1){
			cout << ' ';
		} // end if
	} // end for
	cout << endl;
}

int main()
{
//	cut here before submit 
//	freopen("testcase.ofa", "r", stdin);
	string str = "";

	while (getline (cin, str ) ){
		int n;
		stringstream ssn(str);
		ssn >> n;
		
		if (n == 0 ){
			break;
		} // end if
		
		vector <int> s (n, 0 );
		vector <int> p (n, 0 );
		int count = 0;
		int i;

		getline (cin, str );
		stringstream ss (str );

		for (i = 0; i < n; ++i){
			ss >> s[i];
		} // end for

		while (1){
			freqApp (s, p ); 
//			cout << "s: "; disp_array (s );
//			cout << "p: "; disp_array (p );

			if (isfixpoint (s, p ) ){
				break;
			} // end if
			++count;
			s = p;
		} // end while
		
		cout << count << endl;
		for (i = 0; i < p.size(); ++i){
			cout << p[i];
			if (i != p.size() - 1){
				cout << ' ';
			} // end if
		} // end for
		cout << endl;
	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
char a[55];
int b;
int main()
{

	gets(a);
	b=strlen(a);
	int c;
	c=b-8;
	for (int i=0;i<c;i++)
	cout<<a[i];
	cout<<endl;
return 0;
}

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

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define PI (acos(-1))

int main(){
  int n;
  cin >> n;
  int h[n];
  rep(i,n){
    cin >> h[i];
  }

  int cnt = 0;
  rep(i,n){
    bool ok = 1;
    rep(j,i){
      if(h[j] > h[i]){
        ok = 0;
        break;
      }
    }
    if(ok)cnt++;
  }

  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
int main(){
    string s; 
    cin >> s;
    vector<long long> a(s.size()+1);
    for(int i=0; i<s.size(); i++){
        if (s[i] == '<'){
            chmax(a[i+1], a[i]+1);
        }
    }
    for(int i = s.size()-1; i >= 0; i--){
        if (s[i] == '>'){
            chmax(a[i], a[i+1]+1);
        }
    }
    long long ans = 0;
    for(int i=0; i<s.size()+1; i++) ans += a[i];
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  int X, Y; cin >> X >> Y;
  REP(x,X+1) {
    int y = X-x;
    if (Y == 2*x + 4*y) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


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

  std::cout << std::fixed << std::setprecision(6);

  int N, C[555], S[555], F[555];

  std::cin >> N;

  for (int i = 0; i < N - 1; i ++)
    std::cin >> C[i] >> S[i] >> F[i];

  C[N - 1] = S[N - 1] = 0;
  F[N - 1] = 1;

  for (int i = 0; i < N; i ++) {
    int x = 0;
    
    for (int j = i; j < N; j ++) {
      x = std::max(x, S[j]);

      x = ((x + F[j] - 1) / F[j]) * F[j] + C[j];
    }

    std::cout << x << std::endl;
  }

  return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll n,m;cin >>n>>m;
    vector<ll>x(n);
    vector<ll>y(m);
    for (int i = 0; i < n; ++i) {
        cin  >>x[i];
    }
    for (int j = 0; j < m; ++j) {
        cin >>y[j];
    }
    ll dx=0;
    for (int i = 0; i < n; ++i) {
        dx+=(x[i]*i)%mod;
        dx%=mod;
    }
    reverse(all(x));
    for (int i = 0; i < n; ++i) {
        dx-=(x[i]*i)%mod;
        dx%=mod;
    }
    if(dx<0)dx+=mod;
    ll dy=0;
    for (int i = 0; i < m; ++i) {
        dy+=(y[i]*i)%mod;
        dy%=mod;
    }
    reverse(all(y));
    for (int i = 0; i < m; ++i) {
        dy-=(y[i]*i)%mod;
        dy%=mod;
    }
    if(dy<0)dy+=mod;
//    cout<<dx<<" "<<dy <<endl;
    ll ans=(dx*dy)%mod;
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 1792
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
    tmp = input[0].split(" ");
    var S = tmp[0]

    if(S[0] === S[1] || S[1] === S[2] || S[2] === S[3])
    {
        console.log("Bad")
    }else{
        console.log("Good")
    }

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
program main
	implicit none
    integer::a,b,c
    read(*,*) a,b,c
    if(a<c .and. c<b)then
    	write(*,*) 'Yes'
    else if(b<c .and. c<a)then
    	write(*,*) 'Yes'
    else
    	write(*,*) 'No'
    end if
    stop
end program main

Measured memory_bytes: 2816
import java.util.*;
import java.lang.*;
import java.io.*;
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int L = sc.nextInt();
		int[] flavour = new int[N];
		int count = 0;
		int zero = 0;
		int flagZero = 0;
		int negative = 0;
		int flagnegative = 0;
		int firstPositiveIndex = 0;
		int flagfirstPositiveIndex = 0;
		int allNegative = 0;
		for(int i = 0; i <N; i++)
		{
		    flavour[i] = L + i;
		    if(flavour[i] > 0 && flagfirstPositiveIndex == 0)
		    {
		        firstPositiveIndex = i;
		        flagfirstPositiveIndex = 1;
		    }
		    if(flavour[i] == 0 && flagZero == 0)
		    {
		        zero = 1;
		        flagZero = 1;
		    }
		    if(flavour[i] < 0)
		    {
		        allNegative = 1; 
		    }
		    if(flavour[i] < 0 && flagnegative == 0)
		    {
		        negative = 1;
		        flagnegative = 1;
		    }
		    
		}
		int sum = 0;
		if(zero == 1)
		{
		    for(int i = 0; i <N; i++)
	    	{
		        sum = sum + flavour[i];
		    }
		    System.out.println(sum);
		}
		else if(negative == 0)
		{
		    for(int i = 1; i <N; i++)
	    	{
		        sum = sum + flavour[i];
		    }
		    System.out.println(sum);
		}
		else if(allNegative == 1)
		{
		    for(int i = 0; i <N-1; i++)
	    	{
		        sum = sum + flavour[i];
		    }
		    System.out.println(sum);
		}
		else
		{
		    for(int i = 0; i <N; i++)
	    	{
	    	    if(i != firstPositiveIndex - 1)
	    	    {
		            sum = sum + flavour[i];
	    	    }
		    }
		    System.out.println(sum);
		}
	}
}


Measured memory_bytes: 25556
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=500000+19;

char s[N];
int A[N];
int n,K,isA,x;

int main(){
	n=IN(),K=IN();
	scanf("%s",s+1);
	if (s[1]=='A'){
		s[1]='B';
		if (--K==0) return puts(s+1),0;
	}
	if (s[n]=='B'){
		for (int l=1,r;l<=n;l=r+1){
			for (r=l;r+1<=n&&s[r+1]==s[l];r++);
			For(i,l,r) s[i]=(s[i]=='A'?'B':'A');
		}
		s[n]='A';
		if (--K==0) return puts(s+1),0;
	}
	For(i,1,n+1) A[i]=(s[i]!=s[i+1]);
	For(i,n+1,2*n+1) A[i]=1;
	isA=(s[1]=='A');
	x=1;
	while (K){
		if (isA){
			A[x]^=1;
			isA^=1;
		} else{
			if (A[x++]==0) isA^=1;
		}
		if (--K==0) break;
		if (x==n+1){
			if (n%2==0) break;
			K%=2;
		}
	}
	For(i,1,n+1){
		putchar(isA?'A':'B');
		if (A[x++]==1) isA^=1;
	}
}

Measured memory_bytes: 2176
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
 
using ull = unsigned long long int;
using ll = long long int;
using du = double;
using ld = long du;
using vi = vector<int>;
using vll = vector<ll>;
using vld = vector<ld>;
using vdu = vector<du>;
using vs = vector<string>;
using vc = vector<char>;
using si = set<int>;
using sll = set<ll>;
using sdu = set<du>;
using sld = set<ld>;
using pii = pair<int, int>;
using pll = pair<ll,ll>;
using pdu = pair<du,du>;
using pld = pair<ld,ld>;
using pis = pair<int,string>;
 
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define sp(x) setprecision(x)<<fixed
#define loop(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pi acos(-1)
#define meme(a,x) memset(a,x,sizeof(a))
#define all(a) a.begin(),a.end()
 
//debugger
 
#ifdef KAIZER
#include "debug.h"
#else
#define debug(x...)
#endif
//debugger
 
//functions
bool check_pow(ll a)
{
    if((a&(a-1))==0) return true;
    else return false;
}
ld my_pow(ld a,int b)
{
    ld ans=1;
    for(int i=0;i<b;i++) ans*=a;
    return ans;
}
ll digits(ll a)
{
    string line=to_string(a);
    return line.size();
}
bool prime_check(ll a)
{
    bool flag=true;
    for(ll i=2;i<=sqrt(a);i++)
    {
        if(a%i==0) {flag=false; break;}
    }
    return flag;
}
bool comp(const pair<int,int> &a , const pair<int,int> &b)
{
    if(a.ff!=b.ff) return a.ff>b.ff;
    else return a.ss<b.ss;
}
bool comp2(const ll &a, const ll &b)
{
     return a>b;
}
 
//functions

int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    FASTIO;
    ll n,m,c,y,ans=0;
    cin>>n>>m>>c;
    ll b[m];
    loop(i,m) cin>>b[i];
    loop(i,n) {
        y=0;
        loop(j,m+1)
        {
            if(j==m) y+=c;
            else
            {
                ll p;
                cin>>p;
                y+=(p*b[j]);   
            }
        }
        if(y>0) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int N;
    cin >> N;
    int ans = 0;
    for(int i=1;i<=N;i+=2){
        int cnt = 0;
        for(int j=1;j<=N;j++){
            if(i%j==0) cnt++;
        }
        if(cnt==8){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())
ans = 0
temp = t[:]
desirable = t[:]
for i in range(0, n):
  if t[i] == 'r':
    desirable[i] = 'p'
  elif t[i] == 's':
    desirable[i] = 'r'
  elif t[i] == 'p':
    desirable[i] = 's'
for i in range(0, k):
  if t[i] == 'r':
    temp[i] = 'p'
    ans += p
  elif t[i] == 's':
    temp[i] = 'r'
    ans += r
  elif t[i] == 'p':
    temp[i] = 's'
    ans += s
for i in range(k, n):
  if t[i] == 'r' and temp[i - k] != 'p':
    ans += p
    temp[i] = 'p'
  elif t[i] == 'r' and temp[i - k] == 'p':
    if i + k < n:
      if desirable[i + k] == 's':
        temp[i] = 'r'
      elif desirable[i + k] == 'r':
        temp[i] = 's'
      else:
        temp[i] = 's'
  if t[i] == 's' and temp[i - k] != 'r':
    ans += r
    temp[i] = 'r'
  elif t[i] == 's' and temp[i - k] == 'r':
    if i + k < n:
      if desirable[i + k] == 's':
        temp[i] = 'p'
      elif desirable[i + k] == 'p':
        temp[i] = 's'
      else:
        temp[i] = 's'
  if t[i] == 'p' and temp[i - k] != 's':
    ans += s
    temp[i] = 's'
  elif t[i] == 'p' and temp[i - k] == 's':
    if i + k < n:
      if desirable[i + k] == 'r':
        temp[i] = 'p'
      elif desirable[i + k] == 'p':
        temp[i] = 'r'
      else:
        temp[i] = 'r'
print(ans)

Measured memory_bytes: 5688
n, a, b = map(int, input().split())
count = 0

for i in range(1,n+1):
    i = str(i)
    List = []
    for j in range(len(i)):
        List.append(i[j])
    List = list(map(int,List))
    
    if sum(List) >= a and sum(List) <= b:
        count += int(i)

print(str(count))
    

Measured memory_bytes: 9060
#include <iostream>
#include <vector>
#include <stack>

using namespace std;

class UnionFind {
    vector<int > par;
    vector<int > tree_count;

public:
    UnionFind(int  N) : par(N), tree_count(N) {
        for(int  i = 0; i < N; i++) {
            par[i] = i;
            tree_count[i] = 1;
        }
    }

    int  size(int  x) {
        return tree_count[root(x)];
    }

    int  root(int  x) {
        if(par[x] == x) return x;
        //親を探すときに経路上のノードを親にくっつける
        return par[x] = root(par[x]);
    }

    void unite(int  x, int  y) {
        int  rx = root(x);
        int  ry = root(y);
        if(rx == ry) return;
        //ryに所属するグループの頂点数を格納(親でなくなった頂点は-1)
        tree_count[ry] += tree_count[rx];
        tree_count[rx] = -1;
        //xの親をyの親の下にくっつける
        par[rx] = ry;
    }

    bool same(int  x, int  y) {
        int  rx = root(x);
        int  ry = root(y);
        return rx == ry;
    }
};


int main() {
    long long N, M;
    cin >> N >> M;

    vector<long long> A(M, 0);
    vector<long long> B(M, 0);
    for(long long i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
    }

    vector<long long> ret(M, 0);
    UnionFind uf(N);
    long long change = 0;
    ret[M-1] = (long long)((N*(N-1))/2);
    for(long long i = M - 2; i >= 0; i--) {
        if (!uf.same(A[i+1] - 1, B[i+1] - 1)) 
            change =  (uf.size(A[i+1]-1) * uf.size(B[i+1]-1));
        else 
            change = 0;

        //cout << "change:" << change   << endl;
        
        uf.unite(A[i+1]-1, B[i+1]-1);
        ret[i] = ret[i+1] - change;
        //cout << (uf.size(A[i]-1)) << "," << (uf.size(B[i]-1)) <<endl;

    }
    
    for(long long i = 0; i < M; i++) {
        cout << ret[i] << endl;
    }
}

Measured memory_bytes: 4480
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  rep(i, N) { cin >> a[i]; }
  sort(a.begin(), a.end());
  int result = 0;
  rep(i, K) { result += a[i]; }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3576
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int ans =0;
    for (int i=0; i<4; i++) {
      if (S.charAt(i) == '+') {
        ans++;
      } else if (S.charAt(i) == '-') {
        ans--;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 22868
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
ll data[3][3];
  rep(i,3) {
    rep(j,3) {
      cin >>data[i][j];
    }
  }
  
  bool ans=true;
 ll a1=data[0][1]-data[0][0];
  ll a2=data[0][2]-data[0][1];
  ll b1=data[1][0]-data[0][0];
  ll b2=data[2][0]-data[1][0];
  if((data[0][1]+b1!=data[1][0]+a1) ||(data[1][1]!=data[0][1]+b1)) {
    ans=false;
  }
  
    if((data[0][2]+b1!=data[1][1]+a2)||(data[1][2]!=data[0][2]+b1)) {
    ans=false;
  }  
      
     if((data[1][1]+b2!=data[2][0]+a1)||(data[2][1]!=data[1][1]+b2)) {
    ans=false;
  }
  
  if((data[1][2]+b2!=data[2][1]+a2) ||(data[2][2]!=data[1][2]+b2)) {
    ans=false;
  }
      
      if(ans) {
        cout<<"Yes"<<endl;
      }
else {
  cout<<"No"<<endl;
}
  
  
}
    
  


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

int main() {
	int a, b, c, d, e;
	while (cin >> a >> b >> c >> d >> e){
		if (a == 0){
			cout << "1" << endl;
		}else if (b == 0){
			cout << "2" << endl;
		}else if (c == 0){
			cout << "3" << endl;
		}else if (d == 0){
			cout << "4" << endl;
		}else if (e == 0){
			cout << "5" << endl;
		} 
	}
	return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

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

        while(true){
            s = sc.next();

            if(s.charAt(0)=='-')break;

            m = sc.nextInt();

            for(i = 0;i < m;i++){
                c = c + sc.nextInt();
            }

            for(i = 0;i < s.length();i++){
                System.out.print(s.charAt((c+i)%s.length()));
            }

            System.out.println();

            c = 0;
       }
    }   
}



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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            var N = NM[0];
            var M = NM[1];
            var ns = new List<double[]>();
            var ms = new List<double[]>();
            var anss = new int[N];
            for (var i = 0; i < N; i++)
            {
                ns.Add(Console.ReadLine().Split().Select(s => double.Parse(s)).ToArray());
            }
            for (var i = 0; i < M; i++)
            {
                ms.Add(Console.ReadLine().Split().Select(s => double.Parse(s)).ToArray());
            }
            for(var i = 0; i < N; i++)
            {
                var min = double.MaxValue;
                for(var j=0;j<M;j++)
                {
                    var tmp = Math.Abs(ns[i][0] - ms[j][0]) + Math.Abs(ns[i][1] - ms[j][1]);
                    if (tmp < min)
                    {
                        min = tmp;
                        anss[i] = j + 1;
                    }
                }
            }
            for(var i=0;i<N;i++)
            {
                Console.WriteLine(anss[i]);
            }
        }
    }
}

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

int main(void){
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    for (int i=0; i<n; i++) cin >> a[i];
    for (int i=0; i<n; i++) b[i] = a[i];
    
    b[n-1] = a[n-1];
    for (int i=n-2; i>=0; i--) b[i] = (a[i] + b[i+1]) % MOD;
    
    ll ans = 0, tmp;
    for (int i=0; i<n-1; i++) {
        tmp = a[i] * b[i+1] % MOD;
        ans = (ans + tmp) % MOD;
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 6372
import sys
def input(): return sys.stdin.readline().strip()

def main():
    mod = 998244353
    N, K = map(int, input().split())
    jump = []
    for _ in range(K):
        l, r = map(int, input().split())
        jump.append((l, r))

    dp = [0] * (N + 2)
    dp[0] = 1
    for i in range(N - 1):
        for l, r in jump:
            if i + l <= N:
                dp[i + l] = (dp[i + l] + dp[i]) % mod
            if i + r + 1 <= N:
                dp[i + r + 1] = (dp[i + r + 1] - dp[i]) % mod
        if i != 0:
            dp[i + 1] = (dp[i + 1] + dp[i]) % mod
        #print("i={}, dp={}".format(i, dp))
    print(dp[N - 1] % mod)


if __name__ == "__main__":
    main()


Measured memory_bytes: 69536
#include <iostream>
#include <math.h>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;
static const ll MAX_L = (ll)1 << 62;

static const ll FACT_SIZE = 1000000;
ll fact[FACT_SIZE] = {};

ll Pow(ll n, ll p) {
	if (p == 0)return 1;
	if (p == 1)return n;
	ll t = Pow(n, p / 2);
	if (p & 1) return (t * t % MOD) * n % MOD;
	else return t * t % MOD;
}
void factorial(ll f) {
	fact[0] = fact[1] = 1;
	rep(i, 1, FACT_SIZE) fact[i] = fact[i - 1] * i % MOD;
}

ll nCr(ll n, ll r) {
	if (fact[0] == 0)	factorial(FACT_SIZE);
	return ((fact[n] * (Pow(fact[r], MOD - 2) % MOD)) % MOD * Pow(fact[n - r], MOD - 2)) % MOD;
}

static const ll prime_max = 100001;
bool prime_check[prime_max] = {};
ll prime[prime_max] = {};
ll primeNum = 0;

//void eratosthenes() {
//	rep(i, 2, prime_max) prime_check[i] = true;
//	rep(i, 2, prime_max) {
//		if (prime_check[i]) {
//			prime[primeNum++] = i;
//			rep(j, 2, prime_max) {
//				if (j*i >= prime_max)break;
//				prime_check[j*i] = false;
//			}
//		}
//	}
//}

map<ll, ll> factor;
//void factorization(ll x) {
//	ll n = x;
//	repe(i, 0, primeNum) {
//		while (prime[i] && n != 0 && !(n % prime[i])) {
//			n /= prime[i];
//			factor[prime[i]]++;
//		};
//	}
//}

void factorization(ll m) {
	ll t = m;
	for (int i = 2; t != 1; i++) {
		while (!(t % i)) {
			factor[i]++;
			t /= i;
		}
	}
}
int main() {
	ll n, m; cin >> n >> m;

	//eratosthenes();
	factorization(m);

	ll ans = 1;
	for (map<ll, ll>::iterator it = factor.begin(); it != factor.end(); it++) {
		ans = (ans* nCr(it->second + n - 1, it->second) % MOD);
	}

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

Measured memory_bytes: 8064
import java.util.*;
public class Main{

	public static void main (String[]args){
    Scanner sc=new Scanner(System.in);
      int a=sc.nextInt(),ar[]=new int[a];
      for(int i=0;i<a-1;i++){
      	int p=sc.nextInt();
        ar[p-1]++;
      }
      for(int i=0;i<a;i++){
      System.out.println(ar[i]);
      }
    
    
    }


}

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

using namespace std;

typedef long long ll;
typedef double long dl;
typedef pair < int , int > pii;
typedef pair < pii, pii > p2i;
const int maxn = (int) 3e5 + 1;
const int mod = (int) 1e9 + 7;
const ll inf = (ll)1e18;

#define fi first
#define se second
#define acel ios_base :: sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define next continue


ll n, m;
int main(){
    cin >> n >> m;
    if(n == 1 && m == 1){
        cout << 1;
        return 0;
    } 
    if(n == m && n == 2){
        cout << 0;
        return 0;
    }
    if(n == 1){
        cout << m - 2;
        return 0;
    }
    if(m == 1){
        cout << n - 2;
        return 0;
    }
    cout << ((n * m) - (n + n + m + m)) + 4;
}


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

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

  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];

  int ans = 0;
  rep(i, n) if (h[i] >= k) ans++;
  cout << ans << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;

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

    priority_queue<int> pq;
    for (int i = 0; i < n; i++) {
        int h;
        cin >> h;
        pq.push(h);


    }

    for (int i = 0; i < k && !pq.empty(); i++)
    {
        pq.pop();
    }

    ll cnt = 0;
    while (!pq.empty()) {
        cnt += pq.top();
        pq.pop();
    }


    cout << cnt << endl;


}



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

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

int main() {
  ll a,b,n;
  cin >> a >> b >>n;
  cout << a*min(b-1,n)/b << endl;
  
}

Measured memory_bytes: 3588
def solve():    
    n = int(input())
    a = list(map(int,input().split()))
    b = [0]*n
    ans = []    
    for i in range(n-1, -1, -1):
        if sum(b[i::i+1])%2 != a[i]:
            b[i] = 1
            ans.append(i+1)
    print(len(ans))
    if len(ans):
        print(*ans)
        
if __name__ == '__main__':
    solve()

Measured memory_bytes: 18352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	char a,b;cin >> a >> b;
	cout << (a == b ? 'H' : 'D') << endl;
}


Measured memory_bytes: 256
A, B, C, D = map(int, input().split())
a = C / B
b = A / D
# print(a, b)
if a % 1 != 0: a = int(a) + 1
if b % 1 != 0: b = int(b) + 1
# print(a, b)
if a > b:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9188
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const int inf=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;


int main(){
  ll k;cin>>k;
  if(k%2==0){
    cout<<-1<<endl;return 0;
  }
  string s=to_string(k);
  ll n=s.size();
  ll tmp=0,ans=0;
  rep(i,0,n){
    tmp*=10;
    tmp+=7;
    ans++;
  }
  tmp%=k;
  if(tmp==0){
    cout<<ans<<endl;return 0;
  }
  rep(i,0,5000000){
    ans++;
    tmp=(tmp*10+7)%k;
    if(tmp==0){
      cout<<ans<<endl;return 0;
    }
  }
  
  cout<<-1<<endl;
}



Measured memory_bytes: 3684
/*
ID: Aman Raj
LANG: C++
TASK: preface
*/
#include<iostream>
#include <stdio.h>
//#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include<math.h>
typedef  long long int ll;
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
//#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define flush fflush(stdout)
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <fstream>
// find_by_order()  // order_of_key
typedef tree<
	int,
	null_type,
	less<int>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;

	   //vector<ll > vten(7),vfive(7),vfifty(7),vhundred(7),vfivehundred(7),vthousand(7);

int main()
{
      ifstream fin("preface.in");
      ofstream fout("preface.out");
      string s;
       cin>>s;
        ll a=0;
         for(ll i=0;i<s.size();i++)
         {
             if(s[i]=='o')a++;
         }
         if(a+(15-s.size())>=8)cout<<"YES";else cout<<"NO" ;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

auto gcd (unsigned a , unsigned b) -> unsigned
{
    return b ? gcd (b , a % b) : a;
}

auto lcm (unsigned a , unsigned b) -> unsigned
{
    return a / gcd (a , b) * b;
}

auto main () -> int
{
    unsigned int a , b;
    while (std::cin >> a >> b)
    {
        std::cout << gcd (a , b) << ' ' << lcm (a , b) << std::endl;
    }
}

Measured memory_bytes: 2996
#include "bits/stdc++.h"

using namespace std;
int main() {
	int X;
	cin >> X;
	for (int i = 1; i <= 1000000; ++i) {
		int min = i * 100;
		int max = i * 105;
		if ((min <= X) && (max >= X)) {
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 3628
#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() {
    vector<vector<char>> c(2, vector<char>(3));

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

    if (c[0][0]==c[1][2] && c[0][1]==c[1][1] && c[0][2]==c[1][0]) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    return 0;
}


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

int n , m , a , d[10];

bool check(int x){
	while(x) if(d[x % 10]) return false; else x /= 10;
	return true;
}

int main(){
	scanf("%d %d" , &n , &m);
	while(m--) scanf("%d" , &a) , d[a] = 1;
	for(int i = n; ; i++) if(check(i)) return printf("%d" , i) , 0;
}

Measured memory_bytes: 3808
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
static const int MAX=100;
struct node{int x,y,h;} A[MAX];
int main(void)
{
	int N;
		cin >> N;
	int t;
	for(int i=0;i<N;i++){
		cin >> A[i].x >> A[i].y >> A[i].h;
		if(A[i].h)
			t=i;
	}
	
	for(int cx=0;cx<=100;cx++){
		for(int cy=0;cy<=100;cy++){
			bool K=true;
			int H=abs(A[t].x-cx)+abs(A[t].y-cy)+A[t].h;
			for(int i=0;i<N;i++){
				int g=max(H-abs(A[i].x-cx)-abs(A[i].y-cy),0);
				if(g!=A[i].h){
					K=false;
					break;
				}
			}
			
			if(K){
				cout << cx << " " << cy << " " << H << endl;
				return 0;
			}
		}
	}
	return 0;
}


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

using namespace std;
#define INT_MIN     (-2147483647 - 1) /* minimum (signed) int value */
#define INT_MAX       2147483647    /* maximum (signed) int value */


static const int N = 100;
static const int NEW = 0;
static const int VISITING = 1;
static const int OLD = 2;

int n, m[N][N] = {0}, t;
int color[N] = { 0 }, t1[N] = { 0 }, t2[N] = {0};

void getMatrix()
{
	int u, v, k;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> u >> k;
		for (int j = 0; j < k; ++j)
		{
			cin >> v;
			m[u-1][v-1] = 1;
		}
	}
}

int nxt(int idx)
{
	for (int i = 0; i < n; ++i)
	{
		if (1 == m[idx][i] && color[i] == NEW)
			return i;
	}
	return -1;
}

void dfs_visit(int idx)
{
	stack<int> s;
	s.push(idx);
	color[idx] = VISITING;
	t1[idx] = t++;


	while (!s.empty())
	{
		int u = s.top();
		int v = nxt(u);
		if (-1 != v)
		{
			color[v] = VISITING;
			t1[v] = t++;
			s.push(v);
		}
		else
		{
			s.pop();
			color[u] = OLD;
			t2[u] = t++;
		}
	}
}

void dfs()
{
	t = 1;

	for (int i = 0; i < n; ++i)
		color[i] = NEW;

	for (int i = 0; i < n; ++i)
	{
		if (color[i] == NEW)
			dfs_visit(i);
	}

	for (int i = 0; i < n; ++i)
	{
		cout << i + 1 << " " << t1[i] << " " << t2[i] << endl;
	}
}

int dist[N];

void bfs(int idx)
{
	queue<int> q;
	q.push(idx);

	for (int i = 0; i < n; ++i)
		dist[i] = INT_MAX;
	dist[idx] = 0;

	int u;
	while (!q.empty())
	{
		u = q.front(); q.pop();
		for (int i = 0; i < n; ++i)
		{
			if (m[u][i] == 0) continue;
			if (dist[i] != INT_MAX) continue;
			dist[i] = dist[u] + 1;
			q.push(i);
		}
	}
	for (int i = 0; i < n; ++i)
	{
		cout << i + 1 << " " <<( (dist[i] == INT_MAX) ? (-1) : dist[i]) << endl;
	}
}


int main()
{
	getMatrix();
	bfs(0);
}

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

int main() {
	int n , m; cin >> n >> m ;
	int a[m],sum=0;
	for(int i=0;i<m;i++){
	    cin >> a[i];
	    sum += a[i];
	}
	if(n-sum >=0) std::cout <<  n-sum ;
	else cout <<"-1";
	return 0;
}


Measured memory_bytes: 3680
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
   
 #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
 #endif
 
// -------------------------------------Code starts here---------------------------------------------------------------------     

   int x,y,a,b,c;
   cin>>x>>y>>a>>b>>c;
   int p[a+1]={0};
   for(int i=1;i<=a;i++)
   {
      cin>>p[i];
   }
   int q[b+1]={0};
   for(int i=1;i<=b;i++)
   {
      cin>>q[i];
   }
   int t[c+1]={0};
   for(int i=1;i<=c;i++)
      cin>>t[i];
   sort(p+1,p+a+1,greater<>());
   sort(q+1,q+b+1,greater<>());
   sort(t+1,t+c+1,greater<>());
   vector<int>ans;
   int sum=0;
   for(int i=1;i<=x;i++)
   {
      sum+=p[i];
      ans.push_back(p[i]);
   }
   for(int i=1;i<=y;i++)
   {
      sum+=q[i];
      ans.push_back(q[i]);
   }
   sort(ans.begin(),ans.end(),greater<>());
   int ini=1;
   for(int i=x+y-1;i>=0&&ini<=c;i--)
   {
      if(ans[i]<t[ini])
      {
         sum+=t[ini]-ans[i];
         ini++;
      }
      else
      {
         break;
      }      
   }
   cout<<sum;

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }
 

Measured memory_bytes: 4852
n,k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
inf = 10**10
dp = [inf]*n
dp[0] = 0
 
for i in range(1,n):
    dp[i] = min(dp[i-j]+abs(h[i]-h[i-j]) for j in range(min(i,k)+1))
 
print(dp[n-1])

Measured memory_bytes: 53216
N = int(input())
plan = [[int(i) for i in input().split()] for j in range(N)]

pre = [0, 0, 0]
can = True
for i in range(N):
    dist = abs(plan[i][1] - pre[1]) + abs(plan[i][2] - pre[2])
    dt = plan[i][0] - pre[0]
    
    if dt < dist:
        can = False
    if dt % 2 != dist % 2:
        can = False
        break
    pre = plan[i]
        
if can:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 21108
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n,a,b;
    scanf("%d%d%d", &n, &a, &b);
    if(a>b) {
        printf("0\n");
    }
    else if(n==1) {
        if(a!=b) printf("0\n");
        else printf("1\n");
    }
    else {
        printf("%lld\n", ((ll)b*(n-1)+a)-((ll)a*(n-1)+b)+1);
    }

    return 0;
}


Measured memory_bytes: 128