akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	fsc := NewFastScanner()
	R := fsc.NextInt()
	G := fsc.NextInt()
	fmt.Println(2*G - R)
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

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

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


Measured memory_bytes: 640
#include <stdio.h>

int Partition(int p,int r);
void QuickSort(int p, int r);

// 0:Mark 1:Number
int Anum[100000];
char Amark[100000];
int AnumOld[100000];
char AmarkOld[100000];

int n;

int main(){
  int isStable = -1;
  int i,p, j;
  char tmp[10];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s %d",tmp,&Anum[i]);
    Amark[i] = tmp[0];

    AnumOld[i] = Anum[i];
    AmarkOld[i] = tmp[0];
  }

  QuickSort(0,n-1);

  // stable?

  for(i=1;i<n;i++){
    if(Anum[i-1] == Anum[i]){
      for(j=0; j<n; j++){
	// first pair?	
	if(AmarkOld[j] == Amark[i]
	   && AnumOld[j] == Anum[i]){
	  isStable = 0;
	  break;
	}else if(AmarkOld[j] == Amark[i-1]
	   && AnumOld[j] == Anum[i-1]){
	  break;
	}
      }
    }
    if(isStable==0) break;
  }
  if(isStable==-1) isStable = 1;

  if(isStable) printf("Stable\n");
  else printf("Not stable\n");

  for(i=0;i<n;i++){
    printf("%c %d\n",Amark[i],Anum[i]);
  }

  return 0;
}

int Partition(int p, int r){

  int x, i,j, tmp;

  x = Anum[r];
  i = p-1;
  for(j=p; j<=r-1; j++){

    if(Anum[j] <= x){
      i++;
      //swap
      tmp = Anum[i];
      Anum[i] = Anum[j];
      Anum[j] = tmp;
      tmp = Amark[i];
      Amark[i] = Amark[j];
      Amark[j] = tmp;
    }

  }
  //swap
  tmp = Anum[i+1];
  Anum[i+1] = Anum[r];
  Anum[r] = tmp;
  tmp = Amark[i+1];
  Amark[i+1] = Amark[r];
  Amark[r] = tmp;

  return i+1;

}

void QuickSort(int p, int r){

  int q;
  if(p < r){

    q = Partition(p,r);
    QuickSort(p,q-1);
    QuickSort(q+1,r);

  }

}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;

#define rep(i,x) for(ll i = 0 ; i < x ; i ++)
#define rep1(i,x) for(ll i = 1 ; i <= x ; i ++)
#define rrep(i,x) for(ll i = x-1 ; i >= 0 ; i --)
#define rrep1(i,x) for(ll i = x ; i > 0 ; i --)
#define sor(vec) sort(vec.begin(),vec.end())
#define rev(vec) reverse(vec.begin(),vec.end())
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define min_3(a,b,c) min(min(a,b),c)
#define max_3(a,b,c) max(max(a,b),c)
#define mp1(a,b,c) P1(a,P(b,c))
#define fr first
#define sc second
#define pb push_back

const int INF = 1000000000;
const int dir_4[4][2] = { {1,0} , {0,1} , {-1,0} , {0,-1} };

int n;
int x[100010],y[100010];
int z[100010],w[100010];
int l[2],r[2],d[2];
int cnt[2][400010];
int min0[2][400010];
int max0[2][400010];
int mind[2][400010];
int maxd[2][400010];

int t = 0;
int f(int a){
	if(a < 0)return false;
	if(r[1-t]-a-1 >= 0 && l[1-t]+a < 400010 && cnt[1-t][r[1-t]-a-1]-cnt[1-t][l[1-t]+a] > 0)return false;
	if(a >= d[t])return true;
	if(r[t]-a-1 >= 0 && l[t]+a < 400010 && cnt[t][r[t]-a-1]-cnt[t][l[t]+a] > 0)return false;
	if(max0[1-t][r[1-t]-a-1] <= l[t]+a && mind[1-t][l[1-t]+a+1] >= r[t]-a)return true;
	if(min0[1-t][r[1-t]-a-1] >= r[t]-a && maxd[1-t][l[1-t]+a+1] <= l[t]+a)return true;
	return false;
}

int main(){
	scanf("%d",&n);
	rep(i,n){
		scanf("%d%d",&x[i],&y[i]);
	}
	
	rep(i,2){
		rep(j,400010){
			min0[i][j] = INF;
			mind[i][j] = INF;
		}
	}
	
	rep(i,n){
		z[i] = x[i]-y[i]+200000;
		w[i] = x[i]+y[i]+200000;
		cnt[0][z[i]] ++;
		cnt[1][w[i]] ++;
		min0[0][z[i]] = min ( min0[0][z[i]] , w[i] );
		min0[1][w[i]] = min ( min0[1][w[i]] , z[i] );
		max0[0][z[i]] = max ( max0[0][z[i]] , w[i] );
		max0[1][w[i]] = max ( max0[1][w[i]] , z[i] );
	}
	
	rep(i,2){
		rep(j,400010){
			mind[i][j] = min0[i][j];
			maxd[i][j] = max0[i][j];
		}
	}
	
	rep(i,2){
		rep1(j,400009){
			cnt[i][j] += cnt[i][j-1];
			min0[i][j] = min ( min0[i][j] , min0[i][j-1] );
			max0[i][j] = max ( max0[i][j] , max0[i][j-1] );
		}
		rrep(j,400009){
			mind[i][j] = min ( mind[i][j] , mind[i][j+1] );
			maxd[i][j] = max ( maxd[i][j] , maxd[i][j+1] );
		}
	}
	
	rep(i,2){
		l[i] = 0; r[i] = 0;
		rep(j,400010){
			if(cnt[i][j] == 0)l[i] = j;
			if(j > 0 && cnt[i][j] != cnt[i][j-1])r[i] = j;
		}
		l[i] ++;
		d[i] = r[i]-l[i];
	}
	
	/*rep(k,2){
		printf("%d:\n",k);
		for(int i = 200000-3; i<= 200000+1 ; i ++){
			printf("%d %d %d %d %d\n",cnt[k][i],min0[k][i],max0[k][i],mind[k][i],maxd[k][i]);
		}
		printf("%d %d %d\n",l[k],r[k],d[k]);
	}*/
	
	if(d[0] > d[1])t = 1;
	
	int L = 0,R = 400000;
	while(L < R){
		int M = (L+R)/2;
		if(f(M))R = M;
		else L = M+1;
	}
	
	printf("%d\n",L);
}
	

Measured memory_bytes: 18360
#include <stdio.h>
int main()
{
    struct cards{
        char suit;
        int value;
    } C1[100], C2[100], f;

    int i, j, n, mini, x=0;
    char ch;
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        ch = getchar();
        C1[i].suit = getchar();
        scanf("%d", &C1[i].value);
        C2[i] = C1[i];
    }
    for(i = 0; i < n; i++){
        for(j = (n - 1); j > i; j--){
            if(C1[j].value < C1[j - 1].value){
                f = C1[j];
                C1[j] = C1[j - 1];
                C1[j - 1] = f;
            }
        }
    }
    for(i = 0; i < n; i++){
        mini = i;
        for(j = i; j < n; j++){
            if(C2[j].value < C2[mini].value){
                mini = j;
            }
        }
        f = C2[i];
        C2[i] = C2[mini];
        C2[mini] = f;
    }
    for(i = 0; i < n; i++){
        if(i == n-1){
            printf("%c%d\n", C1[i].suit, C1[i].value);
            printf("Stable\n");
        } else {
            printf("%c%d ", C1[i].suit, C1[i].value);
        }
    }
    for(i = 0; i < n; i++){
        if(C1[i].suit != C2[i].suit) x = 1;
        if(i == n-1){
            printf("%c%d\n", C2[i].suit, C2[i].value);
            if(x == 1){
                printf("Not stable\n");
            } else {
                printf("Stable\n");
            } 
        } else {
            printf("%c%d ", C2[i].suit, C2[i].value);
        }
    }
    return 0;
}

Measured memory_bytes: 616
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_STR_MAX		200005									// 最大文字列長

// 内部構造体 - 文字情報
typedef struct Char {
	char mcChar;												// 文字
	int miCnt;													// 文字数
} Char;

// 内部変数
static FILE *szpFpI;											// 入力
static char sc1Str[D_STR_MAX];									// 文字列
static Char sz1Char[D_STR_MAX];									// 文字情報
static int siCCnt;												// 文字情報数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 文字情報 - 追加
int
fAdd(
	char pcChar					// <I> 追加文字
)
{
	// 加算
	if (siCCnt > 0) {
		if (sz1Char[siCCnt - 1].mcChar == pcChar) {
			sz1Char[siCCnt - 1].miCnt++;
			return 0;
		}
	}

	// 新規
	sz1Char[siCCnt].mcChar = pcChar;
	sz1Char[siCCnt].miCnt = 1;
	siCCnt++;

	return 0;
}

// 文字情報 - 削除
int
fDel(
	char pcChar					// <I> 削除文字
)
{
	// 文字有無
	if (siCCnt < 1) {
		return -1;
	}
	if (sz1Char[siCCnt - 1].mcChar != pcChar) {
		return -1;
	}

	// 削除
	if (sz1Char[siCCnt - 1].miCnt > 1) {
		sz1Char[siCCnt - 1].miCnt--;
	}
	else {
		siCCnt--;
	}

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i, liRet;

	// 文字列 - 取得
	fgets(sc1Str, sizeof(sc1Str), szpFpI);

	// 各文字 - チェック
	for (i = 0; ; i++) {
		if (sc1Str[i] == 'S') {
			fAdd('S');
		}
		else if (sc1Str[i] == 'T') {

			// 削除
			liRet = fDel('S');

			// 追加
			if (liRet != 0) {
				fAdd('T');
			}
		}
		else {
			break;
		}
	}

	// 文字数合計 - 取得
	int liSum = 0;
	for (i = 0; i < siCCnt; i++) {
		liSum += sz1Char[i].miCnt;
	}

	return liSum;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// データ - 初期化
	siCCnt = 0;													// 文字情報数

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// １行出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



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

int main(){
  int n,x; cin >> n;
  
  vector<int> a(8,0);
  int superhaka = 0;
  
  for(int i=0; i<n; i++){
    cin >> x;
    if(x >= 3200)
      superhaka++;
    else if(x >= 2800)
      a[7] = 1;
    else if(x >= 2400)
      a[6] = 1;
    else if(x >= 2000)
      a[5] = 1;
    else if(x >= 1600)
      a[4] = 1;
    else if(x >= 1200)
      a[3] = 1;
    else if(x >= 800)
      a[2] = 1;
    else if(x >= 400)
      a[1] = 1;
    else
      a[0] = 1;
  }
  int clr_min = 0;
  for(int y: a)
    clr_min += y;
  
  cout << max(1,clr_min) << " " << clr_min + superhaka << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int n,m,k;
int a[15],b[15];

int idx[4];
ll ans = 0;
void dfs(int num)
{
    if(num==k)
    {
        vector<pair<int,int>> v;
        rep(i,k) v.pb({a[idx[i]],b[idx[i]]});
        sort(all(v));
        reverse(all(v));

        int rem = m;
        ll t = 0;
        rep(i,k)
        {
            int A = v[i].fi, B = v[i].se;

            t += A*min(B,rem);
            rem -= min(B,rem);
        }
        t += rem;

        ans = max(ans,t);
        return;
    }

    rep(i,n)
    {
        bool ok = true;
        rep(j,num) ok &= (idx[j]!=i);

        if(ok)
        {
            idx[num] = i;
            dfs(num+1);
            idx[num] = -1;
        }
    }
}

int main()
{
    cin >>n >>m >>k;
    rep(i,n) cin >>a[i];
    rep(i,n) cin >>b[i];

    memset(idx,-1,sizeof(idx));
    dfs(0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3100
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

int main() {
	int i, j, k;
	int N;
	char ch[105];

	cin >> N;

	int flagP = 0, flagW = 0, flagG=0, flagY=0;

	for (i = 0; i < N; i++) {
		cin >> ch[i];
		if (ch[i] == 'P') {
			flagP = 1;
		}
		else if (ch[i] == 'W') {

			flagW = 1;
		}
		else if (ch[i] == 'G') {
			flagG = 1;
		}
		else if (ch[i] == 'Y') {

			flagY = 1;
		}
	}

	int sum = 0;

	sum = flagG + flagP + flagW + flagY;

	if (sum == 3) {
		cout << "Three" << endl;
	}
	else {
		cout << "Four" << endl;
	}












	getchar();
	getchar();
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n, i, ans=1, max;
    scanf("%d", &n);

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

    int h[n];

    for(i=0; i<n; i++) {
        scanf("%d", &h[i]);
    }

    max = h[0];

    // for(i=0; i<n; i++) {
    //     printf("%d ", h[i]);
    // }
    // printf("\n");


    for(i=1; i<n; i++) {
        if(h[i]>=max) {
            ans += 1;
            max = h[i];
        }
    }


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

    return 0;
}

Measured memory_bytes: 128
N=int(input())
D=[int(s) for s in input().split()]

D=sorted(D)
sum=[]
count=0
for i in reversed(range(len(D))):
    sum.append(D.pop(i))
    if len(sum) == len(D):
        Ans=len(sum)
        break
for i in range(D[Ans-1],sum[Ans-1],1):
    count+=1
print(count)

Measured memory_bytes: 14428
#include <iostream>
#include <vector>

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

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

int main()
{
    int N;
    cin >> N;
    vi a(N);
    for (int i = 0; i < N; i++)
       scanf("%d", &a[i]);

    int all = 0;
    for (int i = 0; i < N; i++)
        all ^= a[i];

    for (int i = 0; i < N; i++)
    {
        int ans = a[i] ^ all;
        printf("%d\n", ans);
    }
}

Measured memory_bytes: 3980
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;cin>>a>>b;
    int ans=0;
    int noans=max(a,b);
    for(int i=0;i<max(a,b);i++){
        ans+=pow(10,i)*min(a,b);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int>arr(n);
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	int count=0;
	for(int i=1;i<n-1;i++){
		if((arr[i-1]<arr[i] && arr[i]<arr[i+1]) || (arr[i-1]>arr[i] && arr[i]>arr[i+1])){
			count++;
		}
	}
	cout<<count;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define llrp(i,n) for(long long i=0;i<n;i++)
#define llrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define vcin(a); rp(i,a.size()){cin>>a[i];}
#define vcout(a); rp(i,a.size()){cout<<a[i]<<endl;}
#define allchar(c) for(char c='a';c<='z';c++)

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef long long ll;
typedef string S;
typedef pair<int,int> P;
typedef queue<int> qi;

const int mod=1e9+7;

ll modpow(ll a,ll b,ll p){
    if(b==0){
        return 1;
    }elif(b%2==0){
        return modpow((a*a)%p,b/2,p);
    }else{
        return (a*modpow(a,b-1,p))%p;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double t,a;
    int n;
    cin >> n >> t >> a;
    vector<double> h(n);
    vcin(h);
    int ans=0;
    double min=INT_MAX;
    rp(i,n){
        double H;
        H=t-0.006*h[i];
        if(min>abs(H-a)){
            ans=i+1;
            min=abs(H-a);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int x = sc.nextInt();
		int n = 2 * k - 1;
		int m = x;
		int[] arr = new int[n];
		for(int i = 0; i < n; i++){
			arr[i] = x - (k - 1);
			x++;
		}
		for(int i : arr){
			System.out.print(i + " ");
		}
		
	}
	
	
	}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
void fl(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
int n, m;
 
int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	cin >> n >> m;
	if (n >= 10) cout << m << endl;
	else cout << m + 100 * (10 - n) << endl;
	return 0;
}




Measured memory_bytes: 256
#include <vector>
#include <string>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
using namespace std;

int n;
bool grid[200][200];

bool dfs(int u, bool c, vector<int> & state)
{
    state[u] = c;
    
    for (int v = 0; v != n; ++v)
    {
        if (grid[u][v])
        {
            if (state[v] == -1)
            {
                if (dfs(v, c ^ 1, state))
                    return 1;
            }
            else if (state[v] == c)
                    return 1;
        }
    }
    
    return 0;
}

struct DSU
{
    vector<int> parent;
    
    DSU(int n = 0) : parent(n)
    {
        for (int i = 0; i != n; ++i)
            parent[i] = i;
    }
    
    int find(int a)
    {
        if (a == parent[a])
            return a;
        return parent[a] = find(parent[a]);
    }
    
    void join(int a, int b)
    {
        parent[find(a)] = find(b);
    }
};

vector<int> ma;
void bfs(int s)
{
    vector<bool> visited(n);
    vector<int> arr(n);
    queue<int> q;
    visited[s] = 1;
    arr[s] = 1;
    q.push(s);
    
    int tmp = 1;
    
    while (!q.empty())
    {
        int u = q.front();
        q.pop();
        
        for (int v = 0; v != n; ++v)
        {
            if (grid[u][v] && !visited[v])
            {
                visited[v] = 1;
                arr[v] = arr[u] + 1;
                tmp = max(tmp, arr[v]);
                q.push(v);
            }
        }
    }
    
    ma[s] = tmp;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    cin >> n;
    for (int i = 0; i != n; ++i)
    {
        string s;
        cin >> s;
        for (int j = 0; j != n; ++j)
            grid[i][j] = s[j] - '0';
    }
    
    vector<int> state(n, -1);
    for (int i = 0; i != n; ++i)
        if (state[i] == -1 && dfs(i, 0, state))
        {
            cout << -1 << '\n';
            return 0;
        }
    
    DSU uf(n);
    for (int i = 0; i != n; ++i)
        for (int j = i + 1; j != n; ++j)
            if (grid[i][j])
                uf.join(i, j);
    
    ma.resize(n);
    for (int i = 0; i != n; ++i)
        bfs(i);
    
    vector<int> tmp(n);
    for (int i = 0; i != n; ++i)
        tmp[uf.find(i)] = max(tmp[uf.find(i)], ma[i]);
    
    int ans = 0;
    for (int i = 0; i != n; ++i)
        ans += tmp[i];
    
    cout << ans << '\n';
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	int n;cin >> n;
	int x;cin >> x;
	vector<int> a(n);
	rep(i,n)cin >> a[i];
	int ans = abs(x-a[0]);
	for(int i=0;i<n-1;i++)
	{
		
		int foo = abs(a[i]-a[i+1]); 
		if(ans>foo)swap(ans,foo);
		if(foo%ans!=0)ans=foo%ans;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;
class Main{
    public static void main(String args[]){
	try{
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    String str;
	    String strary[] = new String[8];
	    double x[] = new double[3];
	    double y[] = new double[3];
	    double xp,yp;
	    double A,B,C;
	    while(null != (str = br.readLine())){
		strary = str.split(" ");
		int j = 0;
		for (int i = 0; i < 6; i+=2) {
		    x[j] = Double.parseDouble(strary[i]);
		    y[j] = Double.parseDouble(strary[i+1]);
		    j++;
		}
		xp = Double.parseDouble(strary[6]);
		yp = Double.parseDouble(strary[7]);
		A=(x[1]-x[0])*(yp-y[0])-(y[1]-y[0])*(xp-x[0]);
		B=(x[2]-x[1])*(yp-y[1])-(y[2]-y[1])*(xp-x[1]);
		C=(x[0]-x[2])*(yp-y[2])-(y[0]-y[2])*(xp-x[2]);
		if((A<0 && B<0 && C<0) || (A>0 && B>0 && C>0))
		    System.out.println("YES");
		else
		    System.out.println("NO");
	    }
	}
	catch(Exception e){
	    System.out.println("error");
	    System.exit(0);
	}
    }
}

Measured memory_bytes: 17904
from collections import defaultdict

n = int(input())
ch = ["A", "C", "G", "T"]
dic = {}
for i in range(4):
    for j in range(4):
        for k in range(4):
            dic[ch[i]+ch[j]+ch[k]] = 1
dic["AGC"] = 0
dic["GAC"] = 0
dic["ACG"] = 0

err = ["AGAC", "AGCC", "AGGC", "AGTC", "AAGC", "ACGC", "AGGC", "ATGC", ]

l = [dic]
for i in range(n-3):
    _dic = defaultdict(lambda: 0)
    for k, v in l[i].items():
        for j in range(4):
            s = k+ch[j]
            if s not in err:
                _dic[k[1:]+ch[j]] = (_dic[k[1:]+ch[j]]+v)%(10**9+7)
    _dic["AGC"] = 0
    _dic["GAC"] = 0
    _dic["ACG"] = 0
    l.append(_dic)

ans = 0
for v in l[n-3].values():
    ans = (ans+v)%(10**9+7)

print(ans)

Measured memory_bytes: 40944
N, M = map(int, input().split())
graph = dict(zip(
    list (range(1, N+1)),
    [set() for i in range(N)]
))
height=list(map(int, input().split()))

for i in range(M):
    src, dest = map(int, input().split())
    graph[src].add(dest)
    graph[dest].add(src)


count = 0
for currNode in graph:
    flag = True
    for node in graph[currNode]:
        if height[currNode-1] <= height[node-1]:
            flag = False
    
    if flag:
        count += 1


print(count)

Measured memory_bytes: 54176
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  cout << a[N-1] - a[0] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <bitset>

using namespace std;

int main() {
	long long x;
	cin >> x;
	bitset<32> b(x);

	cout << b << endl;
	cout << ~b << endl;
	cout << (b << 1) << endl;
	cout << (b >> 1) << endl;
}


Measured memory_bytes: 3168
/* ABC151 D - Maze Master */
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(x)					(x).begin(),(x).end()
#define REP(i, n)				for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF						(int)2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef pair<int, int>			P;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
const int step[4][2] = {
	{1, 0},
	{-1, 0},
	{0, 1},
	{0, -1},
};

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int H, W;
char HW[20 + 1][20 + 1];

// bfs
int bfs(int sx, int sy)
{
	vector<vector<int>> dist(H, vector<int>(W, INF));

	// 開始位置で初期化
	queue<P> que;
	que.push(P{sx, sy});
	dist[sx][sy] = 0;

	// 全てへの距離
	while (que.size()) {
		P now = que.front();
		que.pop();
		// if ((now.first == gx)&&(now.second == gy)) {
		// 	break;
		// }
		for (int i = 0; i < 4; i++) {
			int xNext = now.first + step[i][0];
			int yNext = now.second + step[i][1];
			if (!((0 <= xNext && xNext < H) && (0 <= yNext && yNext < W))) {
				continue;
			}
			char nextPos = HW[xNext][yNext];
			if ((dist[xNext][yNext] == INF) && (HW[xNext][yNext] != '#')) {
				dist[xNext][yNext] = dist[now.first][now.second] + 1;
				que.push(P{xNext, yNext});
			}
		}
	}

	// 一番遠い距離
	int res = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (dist[i][j] != INF) {
				res = max(res, dist[i][j]);
			}
		}
	}

	return res;
}

// メイン
int main()
{
	// 入力
	cin >> H >> W;
	REP(i, H) REP(j, W) cin >> HW[i][j];

	// dfs
	int ans = 0;
	REP(i, H) {
		REP(j, W) {
			if (HW[i][j] == '.') {
				int res = bfs(i, j);
				if (res != INF) {
					ans = max(ans, res);
				}
			}
		}
	}

	// 結果
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <iomanip>
#include <cstdlib>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<pair<long long, long long> > v(n); 
    for (int i = 0; i < n; i++) {
        cin >> v[i].second >> v[i].first;
    }

    sort(v.begin(), v.end());
    /*
    for (int i = 0; i < n; i++) {
        cout << v[i].first << " " << v[i].second << endl;
    }
    */

    long long sum = 0;
    for (int i = 0; i < n; i++) {
        sum += v[i].second;
        if (sum > v[i].first) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <iostream> 
using namespace std;

pair<int, int> P[200005];

int p, r, t;

int ned[305][305];
int num[305];

int grid[305][305];
int used[305];
int bo[305];

int check(int t) {
    memset(used, 0, sizeof(used));
    memset(grid, 0, sizeof(grid));
    memset(bo, 0, sizeof(bo));
    for (int i = 1; i <= t; ++i) {
        ++used[P[i].second];
        ++grid[P[i].first][P[i].second];
    }
    int tot = 0;
    for (int i = 1; i <= p; ++i) {
        int mark = 0;
        for (int j = 1; j <= r; ++j)
            if (grid[i][j] < ned[i][j]) {
                mark = 1;
                break;
            }
        if (mark == 0) {
            bo[i] = 1;
            ++tot;
            for (int j = 1; j <= r; ++j)
                used[j] -= grid[i][j];
        }
    }
    while (1) {
        int flag = 0;
        for (int i = 1; i <= p; ++i)
            if (!bo[i]) {
                int mark = 0;
                for (int j = 1; j <= r; ++j)
                    if (grid[i][j] + num[j] - used[j] < ned[i][j]) {
                        mark = 1;
                        break;
                    }
                if (mark == 0) {
                    flag = i;
                    break;
                }
            }
        if (flag == 0) break;
        bo[flag] = 1;
        ++tot;
        for (int j = 1; j <= r; ++j)
            used[j] -= grid[flag][j];
    }
    return tot == p;
}

int main() {
    scanf("%d%d%d", &p, &r, &t);
    for (int i = 1; i <= r; ++i) {
        scanf("%d", &num[i]);
    }
    for (int i = 1; i <= p; ++i)
        for (int j = 1; j <= r; ++j)
            scanf("%d", &ned[i][j]);
    for (int i = 1; i <= t; ++i) {
        scanf("%d%d", &P[i].first, &P[i].second);
    }
    // cout << check(0) << endl;
    if (check(t)) {
        puts("-1");
    }
    else {
        int head = 0, tail = t;
        while (head < tail - 1) {
            int mid = (head + tail) >> 1;
            if (check(mid)) head = mid;
            else tail = mid;
        }
        cout << tail << endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}
#define int ll
int n;
string s;


void read() {
	cin >> n >> s;
}

int calc(int pos) {
	vector<int> cntR(2, 0);
	vector<int> cntG(2, 0);
	vector<int> cntB(2, 0);
	for (int i = 0; i < pos; i++) {
		if (s[i] == 'R') cntR[0]++;
		else if (s[i] == 'G') cntG[0]++;
		else cntB[0]++;
	}
	for (int i = pos + 1; i < n; i++) {
		if (s[i] == 'R') cntR[1]++;
		else if (s[i] == 'G') cntG[1]++;
		else cntB[1]++;
	}
	int ans = 0;
	if (s[pos] == 'R') {
		ans += cntG[0] * cntB[1];
		ans += cntB[0] * cntG[1];
		for (int i = 1; pos + i < n && pos - i >= 0; i++) {
			if (s[pos - i] == 'R') continue;
			if (s[i + pos] == 'R') continue;
			if (s[pos - i] == s[i + pos]) continue;
			ans--;
		}
	} else if (s[pos] == 'G') {
		ans += cntR[0] * cntB[1];
		ans += cntB[0] * cntR[1];
		for (int i = 1; pos + i < n && pos - i >= 0; i++) {
			if (s[pos - i] == 'G') continue;
			if (s[i + pos] == 'G') continue;
			if (s[pos - i] == s[i + pos]) continue;
			ans--;
		}
	} else {
		ans += cntG[0] * cntR[1];
		ans += cntR[0] * cntG[1];
		//cout << ans << endl;
		for (int i = 1; pos + i < n && pos - i >= 0; i++) {
			if (s[pos - i] == 'B') continue;
			if (s[i + pos] == 'B') continue;
			if (s[pos - i] == s[i + pos]) continue;
			ans--;
		}
	}
	return ans;
}

ll ans;

void run() {
	ans = 0;
	//cout << calc(2) << endl;
	//exit(0);
	for (int i = 1; i + 1 < n; i++) {
		ans += calc(i);
	}
}

void write() {
	cout << ans << endl;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	read();
	run();
	write();
	return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;

	cout << ((a + b) + 1) / 2 << endl;

	return 0;
}

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

ll mod = 1000000007;

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

    vector<int> a(n);
    vector<ll> s(n+1,0);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        s[i + 1] = s[i] + a[i];
    }

    ll ans = 0;
    for(int i = 0; i < n; i++){
        ll sum = (s[n] - s[i + 1])%mod;
        ans += a[i]*sum;
        ans %= mod;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5524
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define ss second
#define ff first
#define INF 300000000000001
#define ll_max 9000000000000000000
#define mod 998244353
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define db(args...) {string _ss = #args; replace(_ss.begin(), _ss.end(), ',' , ' '); stringstream ___s(_ss) ; debug(___s, args);}
using namespace std;
typedef vector<pair<ll,ll> > vll;
typedef vector<pair<int,int> > vii ;
typedef pair<ll,ll> pll;
const ll N = 100001;
const ll M = 21;
struct point {
    ll x, y, sol;
    bool operator == (point b)
    {
        if(this -> x == b.x && this -> y == b.y) return 1;
        return 0;
    }
    bool operator != (point b)
    {
        return !(*this == b);
    }
};

void debug(stringstream &s){}
template <typename T, typename... Args>
void debug(stringstream &s, T a, Args... args)
{
    string word;
    s >> word;
    cout << word << " = " << a << endl;
    debug(s, args...);
}

ll fast_exp(ll x, ll n)
{
    if(n == 0) return 1;
    ll ans;
    if(n % 2 == 0)
    {
         ans = fast_exp(x, n / 2);
         ans = ans * ans % mod;
    }
    else ans = fast_exp(x, n - 1) * x % mod;
    return ans;
}

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    while(_--)
    {
        ll n, m, x = 1, y = 1, ans = 1, k;
        cin >> x >> y;
        if(y % 2)
            ans = 0;
        ll b = y / 2 - x;
        ll a = x - b;
        if(b < 0 || a < 0)
            ans = 0;
        if(ans)
            cout << "Yes\n";
        else cout << "No\n";
     }
     return 0;
}


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

using namespace std;

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

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, t, a;
	cin>>n;
	ll anst=1, ansa=1;
	REP(i, n){
		cin>>t>>a;
		anst=t*max((anst-1)/t+1, (ansa-1)/a+1);
		ansa=a*max((anst-1)/t+1, (ansa-1)/a+1);
	}
	cout<<anst+ansa<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,x,i1,i2,i3,counter=0;
	while(1){	
		cin >> n >> x;
		if(n==0 && x==0)break;
		for(i1=1 ; i1<=n-2 ; i1++){
			for(i2=i1+1 ; i2<=n-1 ; i2++){
				for(i3=i2+1 ; i3<=n ; i3++){
					if(i1+i2+i3 == x)counter += 1;
				}
			}
		}
		cout << counter << endl;
		counter = 0;
	}
	return 0;
}

Measured memory_bytes: 1160
result = 0
min = 10
for i in range(5):
    time = int(input())
    result = result+time if time%10 == 0 else result + time + 10-(time%10)
    if time % 10 < min and time % 10 !=0:
        min = time % 10
print(result - (10-min))


Measured memory_bytes: 2940
#include <stdio.h>

int main(void) {

	int n;
	int min, max;
	int i, j, k, l;
	int cnt;
	
	while (scanf("%d", &n) != EOF) {

		cnt = 0;
		if (n < 37) {
			for (i = 0; i < 10; ++i) {
				if (i > n) break;
				if (n - i > 9 * 3) continue;
				for (j = 0; j < 10; ++j) {
					if ((i + j > n)) break;
					if (n - i - j > 9 * 2) continue;
					for (k = 0; k < 10; ++k) {
						if ((i + j + k > n)) break;
						if (n - i - j - k > 9) continue;
						cnt++;
						/* for (l = 0; l < 10; ++l) { */
						/* 	if (i + j + k + l == n) { */
						/* 		++cnt; */
						/* 		break; */
						/* 	} */
						/* } */
					}
				}
			}
		}
		printf("%d\n", cnt);
	}
	return 0;
}

Measured memory_bytes: 596
//****** @mdazmat9 **********
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define EB emplace_back
#define PB push_back
#define endl "\n"
#define MOD 1000000007
#define MOD2 998244353
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)


void solve() {
    int n,k;cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int dp[n];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++){
        int cnt=0;
        dp[i]=INT_MAX;
        for(int j=i-1;j>=0 && cnt<k ;j--,cnt++) {
            dp[i] = min(dp[i], abs(a[i] - a[j]) + dp[j]);
        }
    }
    cout<<dp[n-1]<<endl;

}
int32_t main() {
    IOS;
    int test = 1;
//    cin >> test;
    for(int i=1;i<=test;i++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;
class Main {
  public static void main (String[] args) throws Exception {
    
    Scanner sc = new Scanner(System.in);
    
    int n=sc.nextInt();
    Long h=sc.nextLong();
    Long w=sc.nextLong();
    
    int ans =0;
    
    for(int i=0; i<n; i++){
      long hi = sc.nextLong();
      long wi = sc.nextLong();
      if(hi>=h){
        if(wi>=w){
          ans++;
          }
        }
      }
      
    System.out.println(ans);

  }
}

Measured memory_bytes: 25044
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
ll a[maxn],b[maxn];
ll gcd(ll x,ll y)
{
	return y?gcd(y,x%y):x;
}
int main()
{
	ll n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		b[i]=a[i]/2;
	}
	//ll ans=a[1],bans=b[1];
	ll lcm,blcm;
	lcm=a[1];
	blcm=b[1];   
	for(int i=2;i<=n;i++)
	{
		lcm=lcm*a[i]/gcd(lcm,a[i]);
		//ans=lcm;
		blcm=blcm*b[i]/gcd(blcm,b[i]);
		if(blcm>m)
		{
			cout<<0<<"\n";
			return 0;
		}
	}
	for(int i=1;i<=n;i++)
	{
		ll cnt=blcm/b[i];
		if(cnt%2==0)
		{
			cout<<0<<"\n";
			return 0;
		}
	}
	//ll ans=m/blcm;
	//if(ans&1) ans=ans/2+1;
	//else ans=ans/2;
	if(blcm>m) cout<<0<<"\n";
	else cout<<(m-blcm)/lcm+1<<"\n";
	//cout<<ans<<"\n";
	return 0; 
}

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

N,M=map(int,input().split())
TATE=[tuple(map(int,input().split())) for i in range(N)]
YOKO=[tuple(map(int,input().split())) for i in range(M)]


T=[-1<<63,(-1<<63)+1,0,1<<63,(1<<63)+1]
Y=[-1<<63,(-1<<63)+1,0,1<<63,(1<<63)+1]

for a,b,c in TATE:
    T.append(a)
    T.append(b)
    Y.append(c)

for d,e,f in YOKO:
    T.append(d)
    Y.append(e)
    Y.append(f)

T=sorted(set(T))
Y=sorted(set(Y))

BT=[T[0]]
BY=[Y[0]]

for i in range(1,len(T)):
    BT.append(T[i]-T[i-1])
    BT.append(T[i])

for i in range(1,len(Y)):
    BY.append(Y[i]-Y[i-1])
    BY.append(Y[i])

TDICT=dict()
YDICT=dict()

LBT=len(BT)
LBY=len(BY)

for i in range(LBT):
    if i%2==0:
        TDICT[BT[i]]=i

for i in range(LBY):
    if i%2==0:
        YDICT[BY[i]]=i

MAP=[[0]*(LBY+1) for i in range(LBT+1)]

for a,b,c in TATE:
    t0=TDICT[a]
    t1=TDICT[b]
    y=YDICT[c]

    MAP[t0][y]+=1
    MAP[t0][y+1]-=1
    MAP[t1+1][y]-=1
    MAP[t1+1][y+1]+=1

for d,e,f in YOKO:
    t=TDICT[d]
    y0=YDICT[e]
    y1=YDICT[f]

    MAP[t][y0]+=1
    MAP[t+1][y0]-=1
    MAP[t][y1+1]-=1
    MAP[t+1][y1+1]+=1

for i in range(LBT):
    for j in range(1,LBY):
        MAP[i][j]+=MAP[i][j-1]

for i in range(LBY):
    for j in range(1,LBT):
        MAP[j][i]+=MAP[j-1][i]

#for m in MAP:
#    print(*m)

Q=deque()
x,y=TDICT[0],YDICT[0]
Q.append((x-1,y-1))
Q.append((x+1,y-1))
Q.append((x-1,y+1))
Q.append((x+1,y+1))
MAP[x-1][y-1]=MAP[x+1][y-1]=MAP[x-1][y+1]=MAP[x+1][y+1]=1
ANS=BT[x-1]*BY[y-1]+BT[x+1]*BY[y-1]+BT[x-1]*BY[y+1]+BT[x+1]*BY[y+1]

while Q:
    x,y=Q.pop()

    if MAP[x+1][y]==0 and MAP[x+2][y]==0:
        MAP[x+2][y]=1
        Q.append((x+2,y))
        ANS+=BT[x+2]*BY[y]

    if MAP[x-1][y]==0 and MAP[x-2][y]==0:
        MAP[x-2][y]=1
        Q.append((x-2,y))
        ANS+=BT[x-2]*BY[y]

    if MAP[x][y+1]==0 and MAP[x][y+2]==0:
        MAP[x][y+2]=1
        Q.append((x,y+2))
        ANS+=BT[x]*BY[y+2]

    if MAP[x][y-1]==0 and MAP[x][y-2]==0:
        MAP[x][y-2]=1
        Q.append((x,y-2))
        ANS+=BT[x]*BY[y-2]


    if ANS>=1<<62:
        print("INF")
        sys.exit()

print(ANS)

Measured memory_bytes: 477824
#include <cstdio>
#include <string>
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <stdlib.h>
#include <vector>
#include <map>
#include <math.h>
using namespace std;

int main() {
    int a, b;
    scanf("%d %d", &a, &b);
    printf("%d\n", (a+b)%24);
}


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

int INF = 1e9;

int main(){
    int n, m;
    cin >> n >> m;
    int p = (1 << n);
    vector<int> price(p, INF);
    int a, b, c, tmp;
    vector<int> pows(n + 1);
    for (int i = 0; i <= n; i++) pows[i] = pow(2, i);
    for (int i = 0; i < m; i++){
        cin >> a >> b;
        tmp = 0;
        for (int j = 0; j < b; j++){
            cin >> c; c--;
            tmp += pows[c];
        }
        price[tmp] = min(price[tmp], a);
    }
    vector<pair<int, int>> id;
    vector<vector<bool>> array(p, vector<bool>(n, false));
    for (int i = 0; i < p; i++){
        int cnt = 0;
        for (int j = 0; j < n; j++) if ((i >> j) & 1) cnt++, array[i][j] = true;
        id.push_back({cnt, i});
    }
    sort(id.begin(), id.end());
    for (int i = 0; i < p; i++){
        if (price[id[i].second] == INF) continue;
        for (int j = 0; j < i; j++){
            if (price[id[j].second] == INF) continue;
            tmp = 0;
            for (int k = 0; k < n; k++) if (array[id[i].second][k] || array[id[j].second][k]) tmp += pows[k];
            price[tmp] = min(price[tmp], price[id[i].second] + price[id[j].second]);
        }
    }
    if (price.back() == INF) cout << - 1 << endl;
    else cout << price.back() << endl;
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

class UnionFind
{
public:
    UnionFind(int n)
        : mN(n)
    {
        REP(i, n)
        {
            mNodeTbl.push_back(i);
            mRankTbl.push_back(0);
        }
    }

    int find(int x)
    {
        if (x == mNodeTbl[x])
            return x;
        return mNodeTbl[x] = find(mNodeTbl[x]);
    }
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
    void unit(int x, int y)
    {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (mRankTbl[x] < mRankTbl[y])
        {
            mNodeTbl[x] = y;
        }
        else
        {
            mNodeTbl[y] = x;
            if (mRankTbl[x] == mRankTbl[y])
                mRankTbl[x]++;
        }
    }

private:
    int mN;
    vector<int> mNodeTbl;
    vector<int> mRankTbl;
};

struct grid
{
    pll g;
    int index;
};
  vector<grid> G,X,Y;

ll len(pll a)
{
    return std::min(abs(G[a.first].g.first - G[a.second].g.first), abs(G[a.first].g.second - G[a.second].g.second));
}

int main()
{
    ll N;
    cin >> N;
    UnionFind uf(N);
    G.resize(N);
    REP(i, N)
    {
        cin >> G[i].g.first >> G[i].g.second;
        G[i].index = i;
    }
    X=G;
    Y=G;
    priority_queue<pll, vector<pll>, function<bool(pll, pll)>> q([](pll a, pll b) { return len(a) > len(b); });
    sort(X.begin(),X.end(), [](grid a, grid b) { return a.g.first > b.g.first; });
    REP(i, N - 1)
    {
        q.push(pll(X[i].index, X[i + 1].index));
    }
    sort(Y.begin(),Y.end(), [](grid a, grid b) { return a.g.second > b.g.second; });
    REP(i, N - 1)
    {
        q.push(pll(Y[i].index, Y[i + 1].index));
    }

    ll s = 0;
    while (!q.empty())
    {
        pll t = q.top();
        q.pop();
        if (uf.same(t.first, t.second))
            continue;
        uf.unit(t.first, t.second);
        s += len(t);
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 14316
#include <iostream>
using namespace std;
int main(void){
  int a,b,c;
  cin >> a >> b >> c;
  
  int N;
  cin >> N;
  
  int money = 0;
  int ans = 0;
  
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        money = 500 * i + 100 * j + 50 * k;
        if(money == N)
          ans++;
      }
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

        

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

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << '\n';
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

// get(k): binary search on BIT
template <class Abel> struct BIT {
    const Abel UNITY_SUM = 0;						// to be set
    vector<Abel> dat;
    
    /* [1, n] */
    BIT(int n) : dat(n + 1, UNITY_SUM) { }
    void init(int n) { dat.assign(n + 1, UNITY_SUM); }
    
    /* a is 1-indexed */
    inline void add(int a, Abel x) {
        for (int i = a; i < (int)dat.size(); i += i & -i)
            dat[i] = dat[i] + x;
    }
    
    /* [1, a], a is 1-indexed */
    inline Abel sum(int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i)
            res = res + dat[i];
        return res;
    }
    
    /* [a, b), a and b are 1-indexed */
    inline Abel sum(int a, int b) {
        return sum(b - 1) - sum(a - 1);
    }
 
    /* k-th number (k is 0-indexed) */
    int get(long long k) {
        ++k;
        int res = 0;
        int N = 1; while (N < (int)dat.size()) N *= 2;
        for (int i = N / 2; i > 0; i /= 2) {
            if (res + i < (int)dat.size() && dat[res + i] < k) {
                k = k - dat[res + i];
                res = res + i;
            }
        }
        return res + 1;
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat.size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

//--------------------------- Solve ---------------------------//

void solve() {
    int N, M, Q; cin >> N >> M >> Q;
    vector<vector<int> > lines(N+1);
    for (int i = 0; i < M; i++) {
        int l, r; cin >> l >> r;
        lines[l].push_back(r);
    }

    vector<vector<pair<int, int> > > vq(N+1);
    for (int i = 0; i < Q; i++) {
        int p, q; cin >> p >> q;
        vq[p].push_back(make_pair(q, i));
    }

    vector<int> ans(Q);
    BIT<int> bit(N+1);
    for (int l = N; l >= 1; l--) {
        for (int r : lines[l]) bit.add(r, 1);
        for (pair<int, int> query : vq[l]) {
            int q = query.first, i = query.second;
            ans[i] = bit.sum(q);
        }
    }

    print(ans);
}

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

    solve();

    return 0;
}

Measured memory_bytes: 6080