akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.lang.*;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        String[] line = sc.nextLine().split(" ");
        int n = Integer.parseInt(line[0]);
        int work = Integer.parseInt(line[1]);
        int sumTime = 0;
        ArrayDeque<Struct> arr = new ArrayDeque<Struct>();
        for(int i = 0; i < n; i++){
            String[] line2 = sc.nextLine().split(" ");
            String name = line2[0];
            int time = Integer.parseInt(line2[1]);
            Struct s = new Struct(name,time);
            arr.push(s);
        }
        while(!(arr.isEmpty())){
            Struct sb = arr.removeLast();
            if(sb.time > work){
                sb.time-= work;
                arr.push(sb);
                sumTime+= work;
            }else{
                sumTime+=sb.time;
                System.out.print(sb.name + " ");
                System.out.println(sumTime);

            }

        }




    }
}
class Struct{
    String name;
    int time;
    public Struct(String n, int t){
        name = n;
        time = t;
    }
}

Measured memory_bytes: 105156
#include <iostream>
#include <fstream>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define pb push_back

typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

const int mod = (int)1e9 + 7;
const int mod2 = 998244353;

ll exp(ll taban, ll us, ll md) {
    ll carpan = taban % md;
	if(carpan == 0) return 0;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % md;
        temp /= 2;
        carpan = (carpan*carpan) % md;
    }
    return res;
}
 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}

ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}

ll mul(ll a, ll b, ll md){
	return a*b % md;
}

vector<ll> fact;
vector<ll> inv_fact;
void fact_init(int n){
	fact.resize(n+5);
	inv_fact.resize(n+5);
	fact[0] = inv_fact[0] = 1;
	for(int i = 1; i <= n; i++){
		fact[i] = (fact[i-1] * i) % mod;
		inv_fact[i] = exp(fact[i], mod-2, mod);
	}
}

ll komb(ll a, ll b){
	if(a < b) return 0;
	return fact[a] * (inv_fact[a-b] * inv_fact[b] % mod) % mod;
}


const int N = 1e5+5;

int main(){
	ios::sync_with_stdio(false); cin.tie(NULL);
	ll n; cin>>n;
	ll bolen;
	for(ll i = 1; i*i <= n; i++){
		if(n % i == 0) bolen = i;
	}
	bolen = n/bolen;
	int res = 0;
	do res++; while(bolen = bolen/10);
	cout<<res<<endl;
}

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

/*
0 1 2 3 4 5 6 7 8 9

1
1
2*1
3*1
4*2*1
5*3*1
6*4*2*1
7*5*3*1

奇数は0
偶数は、(n/2)!の5の倍数
*/

ll b5(ll x){
    ll count=0;
    ll tmp = x;
    while(tmp>=5){
        tmp /= 5;
        count++;
    }
    ll a = 0;
    rep(i,count){
        //cout << i << " " << (x/(ll)(pow(5,i+1)) ) << endl;
        a += (x/(ll)(pow(5,i+1)));
    }
    return a;
}


void solve(){

    ll n;
    cin >> n;
    ll ans=0;
    if(n%2==1){
        ans = 0;
    }
    else{
        ans = b5(n/2);
    }

    cout << ans << endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(long long int i=a; i<n; i++)
#define loop(i,a,n)	for(long long int i=a; i>=n; i--)

int main() 
{	
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);

	int a;
	cin>>a;
	vector<string> v(a+15);
	forr(i,0,9)
		v[i]=to_string(i+1);
	int k=0,l=9;
	while(l<=a)
	{
		int x=v[k].back()-'0';
		if(x==0)
		{
			v[l++]=v[k]+char('0'+x);			
			v[l++]=v[k]+char('0'+x+1);	
		}
		else if(x==9)
		{
			v[l++]=v[k]+char('0'+x-1);
			v[l++]=v[k]+char('0'+x);
		}
		else
		{
			v[l++]=v[k]+char('0'+x-1);
			v[l++]=v[k]+char('0'+x);
			v[l++]=v[k]+char('0'+x+1);
		}
		if(l>a)	break;
		k++;
	}
	cout<<v[a-1];
	
	return 0;	
}

Measured memory_bytes: 6912
#include<stdio.h>

int main(void)
{
  int a1,b1,c1,d1,a2,b2,c2,d2,s,t;

  scanf("%d %d %d %d",&a1,&b1,&c1,&d1);
   scanf("%d %d %d %d",&a2,&b2,&c2,&d2);

   s=a1+b1+c1+d1;
   t=a2+b2+c2+d2;

   if(s>t)
     printf("%d\n",s);
   else
     printf("%d\n",t);
   return 0;
   
}

Measured memory_bytes: 592
import java.util.*;
import java.io.*;

import static java.lang.Character.isUpperCase;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int M = in.nextInt();
        if(N==M)
        {
            System.out.println("Yes");
        }
        else
        {
            System.out.println("No");
        }


    }


 }













Measured memory_bytes: 35460
n = int(input())
hs = [int(v) for v in input().split()]

before = hs[0]
count = 0
max_count = 0
for h in hs[1:]:
    if h <= before:
        count += 1
    else:
        if max_count < count:
            max_count = count
        count = 0
    before = h
if max_count < count:
    max_count = count

print(max_count)

Measured memory_bytes: 63984
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int[] a = new int[n];
		for (i = 0; i < a.length; i++) {
			a[i] = parseInt(sc.next());
		}
		sc.close();
		boolean f=true;
		for (i = 0; i < n; i++) {
			if(a[i]%2==1)continue;
			if(a[i]%3!=0&&a[i]%5!=0) {
				f=false;
				break;
			}
		}
		out.println(f?"APPROVED":"DENIED");
	}
}


Measured memory_bytes: 21844
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define lint long long int

#include "bits/stdc++.h"
using namespace std;

int main() {
	lint N;
	cin >> N;
	lint commute = N - 1;
	lint logN = (lint)(sqrt((double)N));

	for (lint i = 1; i <= logN; i++) {
		if (N % i == 0) {
			commute = min(commute, N / i + i - 2);
		}
	}

	cout << commute << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n, count = 0;
    
    cin >> n;
    
    char s[n];
    for(int i = 0;i < n;i++){
        cin >> s[i];
    }
    if(n % 2 == 0){
        for(int i = 0; i<n/2;i++){
            if(s[i] == s[i+n/2]){
                count++;
            }
        }
    }
    if(n != 1 && count == n/2){
        cout << "Yes" << endl; 
    }else{
        cout << "No" << endl; 
    }
    

 return 0;
}


Measured memory_bytes: 384
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException{
		Scanner scan = new Scanner(System.in);
		String[] ab = scan.nextLine().split(" ");
		if("H".equals(ab[0])){
			if("H".equals(ab[1])){
				System.out.println("H");
			}else{
				System.out.println("D");
			}
		}else{
			if("H".equals(ab[1])){
				System.out.println("D");
			}else{
				System.out.println("H");
			}
		}
	}

}


Measured memory_bytes: 22484
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int a, b;
    cin >> a >> b;
    if (a >= 13) cout << b << endl;
    else if (a >= 6) cout << b/2 << endl;
    else puts("0");
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

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


int main(){
	#ifdef LOCAL
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
		#if __cplusplus >= 201103L
		auto start = steady_clock::now();
		#endif
	#endif
	int p = read(), q = read(), r = read();
	int a = p + q;
	int b = p + r;
	int c = q + r;
	int t = min(a, b);
	t = min(t, c);
	cout << t << endl;

	#ifdef LOCAL
		#if __cplusplus >= 201103L
		auto end = steady_clock::now();
		duration<double> time_span = duration_cast<duration<double>>(end - start);;
		printf("Total time: %.6fs\n", time_span.count());
		#endif
	#endif
	return 0;
}

Measured memory_bytes: 256
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k,t:Integer;
  l:array of Integer;
  s,s123,s1,s2,s3:string;
  tf:Boolean;
  //nyu:TStringList;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Readln(s);
      
    for i := 1 to (Length(s)+1) div 2 do
      Write(s[2*i-1]);
      
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 384
#pragma GCC optimize ("O2")
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"
#pragma GCC diagnostic ignored "-Wsign-compare"

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

#define trav(a, A) for (auto & a : A)
#define f first
#define s second

typedef long long ll;

const ll MOD = 1e+9+7;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 1e+5+7;

int main ()
{
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	ll tc = 1; //cin >> tc;
	while (tc--)
	{
		int i, j, n, x;
		cin >> x >> n;
        set<int> s;
        for (int i = 0, a; i < n; ++i){
            cin >> a;
            s.insert(a);
        }
        int ans = 1e9;
        for (int i = -1000; i <= 1000; ++i){
            if (abs(x-i) < abs(ans - x) and s.find(i) == s.end()){
                ans = i;
            }
        }
        cout << ans << '\n';
	}

	return 0;
}




Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9)+7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1);

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
  vector< pair<ll, ll> > p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    p.push_back(make_pair(i, 0));
    while ((n % i) == 0) {
      n /= i;
      p[i].second += 1;
    }
    p.push_back(make_pair(n, 0));
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
	ll b = MOD, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0) { u += MOD; }
	return u;
}
// 順列
ll permutation(const ll n, const ll m) {
	ll result = 1;
	for (ll i = n; i > n - m; i--) { result = (result * i) % MOD; }
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
	if (x == 0) return 1;
	ll res = repeat_square(n, x/2);
	res = res * res % MOD;
	if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ nCm
ll combination(ll n, ll m) {
	ll p = permutation(n, m);
	ll div = 1;
	for (ll i = 2; i <= m; i++) {
		div = (div * i) % MOD;
	}
	return (p * modinv(div)) % MOD;
}

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

	vector<ll> A(n);
	ll max = 0;
	rep (i, n) {
		ll a = 0;
		cin >> a;
		A[i] = a;

		if (a > max) max = a;
	}


	ll half = max/2;
	// key: 最小値のidx, val: 最小値
	pair<ll, ll> p = make_pair(max, max);

	rep (i, n) {
		ll a = A[i];
		ll b = max - a;

		if (a == max) continue;


		// cout << "i: " << i << ", a: "<< a << " b: " << b << ", " << p.first << " " << p.second << endl;
		if (abs(half - a) < p.second || abs(half - b) < p.second) {
			p.first = i;
			p.second = min({abs(half - a), abs(half - b)});
		}
	}

	cout << max << " " << A[p.first] << endl;
  return 0;
}


Measured memory_bytes: 1024
clr = list(map(int, input().split()))
k = int(input())

for i in range(k):
    if clr[2] <= clr[1] :
        clr[2] *= 2
    
    elif clr[1] <= clr[0]:
        clr[1] *= 2
    
    else:
        break
    
if clr[2] > clr[1] > clr[0] :
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9076
#include <bits/stdc++.h> 
using namespace std; 
#define forn(i,n) for(int i=0;i<int(n);i++)
#define fora(i,a,b) for(int i=int(a);i<=int(b);i++)
typedef long long int ll;
void solve()
{
	ll s=0;
	int n;
	cin>>n;
	fora(i,1,n)
	{
		fora(j,1,n)
		{
			fora(k,1,n)
			{
				int g=__gcd(i,j);
				s+=__gcd(k,g);
			}
		}
	}
	cout<<s<<endl;
}
int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
   	solve();
}

Measured memory_bytes: 3652
import sys
input=sys.stdin.readline
n=int(input())
AB=[list(map(int,input().split())) for _ in range(n)]
AB.sort(key=lambda x: x[1])
time=0
for a,b in AB:
    time+=a
    if time>b:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 83804
#include<stdio.h>

char map[101][101];
int H,W;

void func(int x,int y,char m){
	map[x][y] = '0';
	if(map[x][y+1] == m && y+1<101)
		func(x,y+1,m);
	if(map[x][y-1] == m && y-1>-1)
		func(x,y-1,m);
	if(map[x+1][y] == m && x+1<101)
		func(x+1,y,m);
	if(map[x-1][y] == m && x-1>-1)
		func(x-1,y,m);
}

int main(void){
	while(scanf("%d%d",&H, &W) && H){
		int ans = 0;
		for(int i = 0; i < H; i++){
			scanf("%s",map[i]);
		}
		
		for(int i = 0 ; i < H; i++){
			for(int j = 0; j < W; j++){
				if(map[i][j] != '0'){
					ans++;
					func(i,j,map[i][j]);
				}
			}
		}
		printf("%d\n",ans);
		
		for(int i = 0; i < 101;i++){
			for(int j = 0; j < 101; j++){
				map[i][j] = '0';
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 22
#define MOD 1000000007
#define B(x) (1<<(x))
using namespace std;
int n,dp[M][1<<M];
int a[M][M];
int main()
{
    scanf("%d", &n);
    REP(i,1,n) REP(j,1,n) scanf("%d", &a[i][j]);

    dp[0][0] = 1;
    REP(i,1,n) REP(j,0,B(n)-1) if (__builtin_popcount(j) == i) {
        REP(k,1,n) if(a[i][k] && (B(k-1)&j)) {
            int i2 = i-1;
            int j2 = j ^ B(k-1);
            dp[i][j] += dp[i2][j2];
            dp[i][j] %= MOD;
        }
    }
    printf("%d\n", dp[n][B(n)-1]);

    return 0;
}


Measured memory_bytes: 93764
Imports System

Public Class Test
	Public Shared Sub Main()
        Dim up As String
        Dim down As String
        Dim a11, a12, a13, a21, a22, a23 As String
        up = Console.ReadLine()
        down = Console.ReadLine()
        a11 = up.Substring(0, 1)
        a12 = up.Substring(1, 1)
        a13 = up.Substring(2, 1)
        a21 = down.Substring(0, 1)
        a22 = down.Substring(1, 1)
        a23 = down.Substring(2, 1)
        If (a11 = a23 AndAlso a12 = a22 AndAlso a13 = a21) Then
      		Console.WriteLine("YES")
        Else
            Console.WriteLine("NO")
        End If
	End Sub
End Class

Measured memory_bytes: 20432
#include <iostream>

using namespace std;

int main(void){

    int N, a;
    cin >> N;
    int* A = new int[N];

    for(int i = 0; i < N; i++){
        cin >> a;
        A[a - 1] = i + 1;
    }
/*
    for(int i = 1; i <= N; i++){
        for(int j = 0; j < N; j++){
            if(i == A[j]){
                cout << j + 1 << " ";
                break;
            }
        }
    }
    */
   for(int i = 0; i< N; i++){
       cout << A[i] << " ";
   }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1152
from fractions import gcd
#####segfunc#####
def segfunc(x, y):
    return gcd(x,y)
#################

#####ide_ele#####
ide_ele =0
#################

class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res
        
n=int(input())
a=list(map(int, input().split()))

seg=SegTree(a,segfunc,ide_ele)
ans=-1
for i in range(n):
    ans=max(ans, gcd(seg.query(0,i), seg.query(i+1,n)))
print(ans)


Measured memory_bytes: 16144
#include <algorithm>
#include <array>
#include <bitset>
#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);
  std::cerr << std::fixed << std::setprecision(6);

  int A, B, C, K;

  std::cin >> A >> B >> C >> K;

  for ( ; K; B *= 2, K --)
    if (B > A)
      break;

  for ( ; K; C *= 2, K --)
    if (C > B)
      break;

  std::cout << ((B > A && C > B) ? "Yes" : "No") << std::endl;

  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  string ans = "No";
  bool c = false, f = false;
  for(int i = 0; i < s.length(); i++){
    if(!c){
      if(s[i] == 'C') c = true;
    }
    else{
      if(s[i] == 'F') ans = "Yes";
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){

	int n;
	while (std::cin >> n, n) {
		int sum, cnt = 0;
		std::cin >> sum;

		std::string s, p = "I";
		std::cin >> s;

		for (int i = 0; i < n; i++){
			p += "OI";
		}

		for (int i = 0; i <= sum - (1 + n * 2); i++){
			if (s.substr(i, 1 + 2 * n) == p)cnt++;
		}

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

Measured memory_bytes: 2128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 100005;
const int inf = 1e9;
int a[maxn];
int main()
{
    int n;
    cin >> n;
    for(int i=0;i<n;i++)cin >> a[i];
    vector<int> dp(n,1e9);
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<=i+2;j++){
            if(j<n)dp[j]=min(dp[j],abs(a[i]-a[j])+dp[i]);
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
// max_x = 98

#include <math.h>
/*
int cor(int x, int y, int z, int n)
{
  if (n = x*x + y*y + z*z + x*y + y*z + z*x)
    return 1;
  return 0;
}*/
int main()
{
  int n;
  scanf("%d", &n);
  int x, y, z;
  int minx;
  int i, count;
//  int tx, ty, tz;
  for (i = 1; i <= n; i++)
  {
    count = 0;
    x = sqrt(i - 2) - 1;
//    y = sqrt(i - 3*x*x/4 - x/2 - 3/4) - (x+1)/2;
//    z = sqrt(i - x*x - y*y - x*y) - (x+y)/2;
    y = x;
    z = y;
    minx = sqrt(i / 6);
    while (x >= minx && x >= 1)
    {
      y = x;
      while (y >= 1)
      {
        z = y;
        while (z >= 1)
        {
          if (x*x + y*y + z*z + x*y + y*z + z*x == i)
          {
            if (x != y && y != z)
              count += 6;
            else if ((x != y && y == z) || (x == y && y != z))
              count += 3;
            else if (x == y && y == z)
              count++;
          }
          z--;
        }
        y--;
      }
      x--;
    }
/*    tx = x;
    ty = y;
    tz = z;
    if (cor(x, y, z, i) == 1)
      count++;
    while (y >= z)
    {
      y--;
    if (x >= 1 && y >= 1 && z >= 1)
    {
      if (x*x + y*y + z*z + x*y + y*z + z*x == i)
      {
        if (x != y && y != z)
          count += 6;
        else if ((x != y && y == z) || (x == y && y != z))
          count += 3;
        else if (x == y && y == z)
          count++;
      }
    }
//    }*/
    
    printf("%d\n", count);
  }
}


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

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

  int sum = 0;

  for (int i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;

    sum += r - l + 1;
  }
  cout << sum << endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define INF 1000000
using ll = long long;

int main(){
  int n;
  cin >> n;
  vector<int> A(n);
  vector<vector<int>> x(n),y(n);
  rep(i,n){
    cin>>A.at(i);
    rep(j,A.at(i)){
      int a,b;
      cin>>a>>b;
      x.at(i).push_back(a);
      y.at(i).push_back(b);
    }
  }
  
  int ans = 0,flag = 0;
  for(int bit = 0; bit < (1<<n); bit++){
    flag = 0;//矛盾なし
    vector<int> honest(n,-1);
    int tmp = 0;
    for(int i = 0; i < n; i++){
      if((1<<i)&bit){//正直者
        if(honest.at(i)==0){//そもそもそいつが嘘ついてる。
          flag = 1;
          break;
        }else{
          honest.at(i)=1;
          rep(j,A.at(i)){
            if(honest.at(x.at(i).at(j)-1)!=y.at(i).at(j)&&honest.at(x.at(i).at(j)-1)!=-1){
              flag = 1;
              break;  
            }else honest.at(x.at(i).at(j)-1)=y.at(i).at(j);
          }
        }
        if(flag)break;
        tmp++;
      }else{
        if(honest.at(i)==1){//ダメなのに矛盾
          flag = 1;
          break;
        }
        honest.at(i)=0;
      }
    }
    if(flag)continue;
    else{
      ans=max(ans,tmp);
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	char c; read(c); write('A' <= c && c <= 'Z' ? 'A' : 'a');
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main ()


{
    long long int x ;
    double b ;
    string y;
    cin>>x;
    cin>>y;
    if(x<3200)
    {


        cout<<"red"<<endl;
        
    }
    else
    {


        cout<<y<<endl;
        


    }





    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long
#define pii pair<int,int>
#define ff first
#define ss second
#define vi vector<int>
#define fo(n) for(int i = 0;i < int(n);i++)
#define foo(a,b) for(int i = int(a);i <= int(b);i++)
#define mk make_pair
#define pb push_back
#define MAXN (int)1e6
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define fastio ios_base:: sync_with_stdio(false)
#define inf (int)1e9

string LCS(string s,string t){
	int n = s.size();
	int m = t.size();

	int lcs[n+1][m+1];

	for(int i = 0;i <= n;i++) lcs[i][0] = 0;
	for(int j = 0;j <= m;j++) lcs[0][j] = 0;

	for(int i = 0;i < n;i++){
		for(int j = 0;j < m;j++){
			if(s[i] == t[j]){
				lcs[i+1][j+1] = lcs[i][j] + 1;
			}

			else{
				lcs[i+1][j+1] = max(lcs[i][j+1], lcs[i+1][j]);
			}
		}
	}

	string res;

	int i = n, j = m;

	while(i > 0 && j > 0){
		if(s[i-1] == t[j-1]){
			res += s[i-1];
			i -= 1;
			j -= 1;
		}

		else{
			if(lcs[i-1][j] >= lcs[i][j-1]){
				i -= 1;
			}

			else{
				j -= 1;
			}
		}
	}

	return res;
}

int main(){
	fastio;
	string s, t;

	cin >> s >> t;

	string res = LCS(s,t);
	reverse(all(res));

	cout << res << endl;
	return 0;
 }	

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

char s[25][25];

int dir[4][2] = {{1, 0}, {-1, 0}, {0, -1}, {0, 1}};
int d[25][25] = {-1};
const int DIR = 4;

int main() {
	int h, w; cin >> h >> w;

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

	int ans = 0;

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {

			if (s[i][j] == '#') continue;

			queue<pair<int, int>> q;
			q.push(make_pair(i, j));

			// vector<vector<bool>> vis(h, vector<bool>(w, false));
			memset(d, -1, sizeof(d));
			d[i][j] = 0;

			while (!q.empty()) {
				auto p = q.front(); q.pop();

				int xs = p.first;
				int ys = p.second;

				for (int i = 0; i < DIR; i++) {
					int dx = xs + dir[i][0];
					int dy = ys + dir[i][1];
					if (dx < 0 || dx >= h || dy < 0 || dy >= w || ~d[dx][dy] || s[dx][dy] == '#')
						continue;

					d[dx][dy] = d[xs][ys] + 1;
					ans = std::max(ans, d[dx][dy]);
					q.push(make_pair(dx, dy));
				}
			}
		}
	}

	cout << ans;
}

Measured memory_bytes: 256
# coding: utf-8
import sys
sys.setrecursionlimit(1000000)
 
def dfs(x, y, fru):
    field[x][y] = '.'
    for dx in [-1,0,1]:
        nx = x + dx
        if 0 <= nx and nx < H and field[nx][y] == fru:
            dfs(nx,y,fru)
    for dy in [-1,0,1]:
        ny = y + dy
        if 0 <= ny and ny < W and field[x][ny] == fru:
            dfs(x,ny,fru)
 
def solv(H,W):
    count = 0
    for i in range(H):
        for j in range(W):
            if field[i][j] == '@':
                dfs(i,j,'@')
                count+=1
            elif field[i][j] == '#':
                dfs(i,j,'#')
                count+=1
            elif field[i][j] == '*':
                dfs(i,j,'*')
                count+=1
    print(count)
 
f=0
while(f==0):
    H, W = map(int, input().split())
    if H != 0 and W != 0:
        field = []
        for i in range(H):
            field.append(list(input()))
        solv(H,W)
    else:
        f=1



Measured memory_bytes: 16028
N, X = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)

tot = 0 
b = 0
A.each do |a|
  eat = 0
  if a + b > X
    eat = a + b - X
    tot += eat 
  end
  b = a - eat 
end  
puts tot 

Measured memory_bytes: 8580
N = int(input())
Hs = list(map(int,input().split()))
fxxk = 0
for i in range(1, N):
    if Hs[i] > Hs[i-1]:
        Hs[i] =Hs[i]- 1
    elif Hs[i] < Hs[i-1]:
        fxxk += 1
        break
if fxxk == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14396
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define SORT(i) sort((i).begin(),(i).end())
constexpr ll INF = 2000000000;
constexpr ll mod = 10e8 + 7;

int main() {
	int N; cin >> N;
	vector<int>L(N);
	rep(i, N)cin >> L[i];
	SORT(L);
	int res = 0;
	rep(i, N) {
		for (int j = i + 1;j < N;++j) {
			int k = lower_bound(L.begin(), L.end(), L[i] + L[j]) - L.begin();
			res += max(k - (j + 1), 0);
		}
	}
	cout << res << "\n";

	return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	H := nextInt()
	W := nextInt()
	h := nextInt()
	w := nextInt()

	res := (H - h) * (W - w)

	fmt.Println(res)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}


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

int main(){
    int x, ans=1;
    cin >> x;
    for(int i=2 ; i*i<=x ; i++){
        int tmp=i;
        while(true){
            if(tmp*i>x){
                break;
            }
            tmp*=i;
        }
        if(tmp>ans){
            ans=tmp;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 764
#include<iostream>
#include<sstream>
#include<string>

int main(){
    while(1){
      std::string str1,str2;
      std::cin>>str1;
      if(str1==".") break;
      std::cin>>str2;
      std::string s11[201],s22[201];
      for(int i=0;i<201;i++){
        s11[i]=".";s22[i]=".";
      }
      s11[0]="";s22[0]="";
      int now1=0,now2=0;
      int l1,l2;
      l1=str1.size();
      l2=str2.size();
      for(int i=0;i<l1;i++){
        if(str1[i]=='"'){
          now1++;
          s11[now1]="";
        }else s11[now1]+=str1[i];
      }
      for(int i=0;i<l2;i++){
        if(str2[i]=='"'){
          now2++;
          s22[now2]="";
        }else s22[now2]+=str2[i];
      }
      int mistake=0;
      for(int i=0;i<201;i++){
        if(s11[i]!=s22[i]){
          if(i&1){
            mistake++;
          }else mistake+=2;
        }
      }
      if(mistake==0){
        std::cout<<"IDENTICAL";
      }else if(mistake==1){
        std::cout<<"CLOSE";
      }else{
        std::cout<<"DIFFERENT";
      }
      std::cout<<"\n";
    }
}


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

int main(void)
{
    int X;
    cin >> X;

    vector<bool> expo(X+1);

    expo[1]=1;

    for(int b=2; b<=X; ++b)
    {
        int v=b*b;
        while(v<=X)
        {
            expo[v]=1;
            v*=b;
        }
    }
    for(int i=X;i>=1;i--)
    {
        if(expo[i])
        {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
//import javafx.util.Pair;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main
{
	public static void main(String []args)throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String []s=br.readLine().split(" ");
		long n = Long.parseLong(s[0]);
		long a = Long.parseLong(s[1]);
		long b = Long.parseLong(s[2]);
		
		long ans=((n/(a+b))*a)+min(a,n%(a+b));
		/*
		1. n/(a+b) is the number of times n can be divided by (a+b), considering a+b as 1 unit and finding the number of such a+b units that is a part of n.
		2. Now that we have the number of times n is divisible by a+b, multiply it by the number of blue balls actually present
		3. And the number of balls remaining after n is divided by (a+b) will contain either n%(a+b) blue balls or a blue balls.
		
		*/
		
		out.println(ans);
		
		
	}
	
	
}




Measured memory_bytes: 22996
n, m, c = map(int, input().split())
bbb = list(map(int, input().split()))
count = 0
for i in range(n):
  aaa = list(map(int, input().split()))
  prod = sum([a*b for a,b in zip(aaa,bbb)]) + c
  if prod > 0:
    count += 1
print(count)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int m = scan.nextInt();
		int l = scan.nextInt();

		int[][] a = new int[n][m];
		int[][] b = new int[m][l];

		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) {
				a[i][j] = scan.nextInt();
			}
		}

		for(int i = 0; i < m; i++) {
			for(int j = 0; j < l; j++) {
				b[i][j] = scan.nextInt();
			}
		}

		for(int i = 0; i < n; i++) {
			for(int j = 0; j < l; j++) {
				long seki = 0;
				for(int k = 0; k < m; k++) {
					seki += a[i][k] * b[k][j];
				}
				if(j != 0) {
					System.out.printf(" ");
				}
				System.out.printf("%d", seki);
			}
			System.out.println();
		}

		scan.close();
	}
}


Measured memory_bytes: 79892
n, k = gets.split.map(&:to_i)
pp = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)

v = Array.new(n)
ans = -1 << 40
n.times do |s|
    next if v[s]
    v[s] = 0
    x = Array.new(n)
    
    d = n.times do |i|
        pre = now = s
        sum = c[now]
        i.times do
            now = pp[now] - 1
            v[now] = 0
            sum += c[now]
        end
        max = sum
        lim = now

        if pp[now] - 1 == s
            x[i] = sum
            break i
        end

        while (now = pp[now] - 1) != lim
            sum += c[now] - c[pre]
            pre = pp[pre] - 1
            max = [max, sum].max
        end

        x[i] = max
    end
    l = x[d]
    d.times{|i| x[i+1] = [x[i+1], x[i]].max}

    if k <= d+1
        ans = [ans, x[k-1]].max
    elsif l <= 0
        ans = [ans, x[d]].max
    else
        y, z = k.divmod(d+1)
        if z == 0
            ans = [ans, l * (y - 1) + x[d]].max
        else
            ans = [ans, l * y + x[z-1], l * (y - 1) + x[d]].max
        end
    end
end

p ans

Measured memory_bytes: 41460
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    map<string, LL> mp;
    REP(i,N){
        string s; cin >> s;
        sort(s.begin(),s.end());
        mp[s]++;
    }
    LL ans = 0;
    for(auto p : mp){
        ans += p.second * (p.second-1) / 2;
    }
    cout << ans << endl;

}


Measured memory_bytes: 11264
#include<stdio.h>
int main(){
int N,M,i,j,k;
int a[51],b[51];
scanf("%d %d",&N,&M);
for(i=0;i<M;i++){
scanf("%d %d",&a[i],&b[i]);
}
for(i=0;i<N;i++){
  k=0; 
  for(j=0;j<M;j++){
    if(a[j]==i+1){
    k++;
    }
    if(b[j]==i+1){
    k++;
    }
  }
  printf("%d\n",k);
}
return 0;
}

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

/* https://atcoder.jp/contests/abc077/tasks/arc084_a */

static const int L = 3;

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

    std::vector<std::vector<unsigned int>> sai(L, std::vector<unsigned int>(n, 0));


    for (int l = 0; l < L; l++)
    {
        for (int i = 0; i < n; i++)
        {
            std::cin >> sai[l][i];
        }

        std::sort(sai[l].begin(), sai[l].end());
    }


    std::vector<std::vector<unsigned long long>> cnt(L, std::vector<unsigned long long>(n, 0));

    for (int l = 0; l < L; l++)
    {
        for (int i = 0; i < n; i++)
        {
            if (l == 0)
            {
                cnt[l][i] = (i+1);
            }
            else
            {
                auto d = std::lower_bound(sai[l-1].begin(), sai[l-1].end(), sai[l][i]) - sai[l-1].begin();
                if (d == 0)
                {
                    cnt[l][i] = 0;
                }
                else
                {
                    cnt[l][i] = cnt[l - 1][d - 1];
                    if (i != 0)
                    {
                        cnt[l][i] += cnt[l][i-1];
                    }
                }
            }

        }
    }

    std::cout << cnt[L-1][n-1] << std::endl;

    return 0;
}

Measured memory_bytes: 5864
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, M;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> M;

	if (M == 1) {
		printf("1 2\n");
		return;
	}

	int i1 = 1;
	int i2 = M + 2;

	rrep(len, M + 1, 2) {
		printf("%d %d\n", i1, i1 + len - 1);
		i1++;
		swap(i1, i2);
	}
}







Measured memory_bytes: 3784
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        Map<String, Integer> cnt = new TreeMap<>();
        int N = scan.nextInt();
        int up = 0;
        for (int i = 0; i < N; i++) {
            String temp = scan.next();
            cnt.merge(temp, 1, Integer::sum);
            up = Math.max(cnt.get(temp), up);
        }
        int finalUp = up;
        cnt.forEach((a, b) -> {
            if (b == finalUp) System.out.println(a);
        });
    }
}

Measured memory_bytes: 79976
#include <bits/stdc++.h>
typedef long long ll;
#define loop(x) for(int i = 1;i<=(x);i++)
using namespace std;

int main(){
    int n,count = 0;
    cin>>n;
    loop(n){
        for(int j = 1;j<=n;j++){
            for(int k = 1;k<=n;k++){
                count+=__gcd(k,__gcd(i,j));
            }
        }
    }
    cout<<count<<"\n";
    return 0;
}




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

typedef pair<int,int>pii;
#define MOD 1000000007
#define MAXN 100005
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define ll long long
#define pb push_back
#define f first
#define s second
#define debug(x) cout << "debug 1: " << x << "\n";
#define debug2(x, y) cout << "debug 2: " << x << " " << y << "\n";
#define debug3(x, y, z) cout << "debug 3: " << x << " " << y << " " << z << "\n";


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    queue<unsigned long long >fila;
    for(unsigned ll i=1;i<10;i++){
        fila.push(i);
    }
    int t=1;
    while(t<n){
        t++;
        unsigned long long x=fila.front();

        unsigned long long  temp=x%10;
        fila.pop();
        if(temp==0){
            fila.push(x*10+temp);
            fila.push(x*10+temp+1);
        }
        else if(temp==9){
                fila.push(x*10+temp-1);
                fila.push(x*10+temp);

        }
        else{
            fila.push(x*10+temp-1);
            fila.push(x*10+temp);
            fila.push(x*10+temp+1);

        }
    }
    cout<<fila.front();

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
const int INF=1e9+5;
const int N=2e5+5;
const ll oo=1e18+5;
const ll mod=1e9+7;

string s;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>s;
	for(int i=0;i<3;++i){
		if(s[i]=='7'){
			return cout<<"Yes",0;
		}
	}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 3608
import java.util.Scanner;
class Main{
    public static void main(String[] args){
	final Scanner sc=new Scanner(System.in);
	while(true){
	    int a=sc.nextInt();
	    int b=sc.nextInt();
	    if(a==0&&b==0) break;
	    for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
		    if(i==0||j==0||i==a-1||j==b-1) System.out.print("#");
		    else System.out.print(".");
		}
		System.out.println("");
	    }
	    System.out.println("");
	}
    }
}

Measured memory_bytes: 25696
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int n; cin >> n;
    int ret = 1;
    repq(i,1,n) ret = mmul(ret, i);
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(register int i=a;i<=b;++i)
#define il inline
using namespace std;
il int read(){
	int x=0;bool f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-') f=0;ch=getchar();}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	return f?x:-x;
}
/*----- head end -----*/
int n,x,now=1;
int main(){
	n=read();x=read();
	if(x==1 || x==(2*n-1)) puts("No");
	else{
		puts("Yes");
		rep(i,1,n-2){
			while(now==x || now==x-1 || now==x+1) ++now;
			printf("%d\n",now);
			++now;
		}
		printf("%d\n%d\n%d\n",x-1,x,x+1);
		rep(i,1,n-2){
			while(now==x || now==x-1 || now==x+1) ++now;
			printf("%d\n",now);
			++now;			
		}
	}
	return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    int n;
    cin >> n;
    vector<pair<int, int>> a;
    for(int i = 0; i < n; i++){
        int x, l;
        cin >> x >> l;
        a.emplace_back(x + l, x - l);
    }
    sort(a.begin(), a.end());
    int cnt = 0;
    int coo = INT_MIN;
    for(int i = 0; i < n; i++){
        auto p = a[i];
        if(coo <= p.second){
            coo = p.first;
            cnt++;
        }
    }
    cout << cnt;
}

Measured memory_bytes: 1400