akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		String ans = "NG";
		for(int i = b; i <= c; i++) {
			if(i > 0 && (i % a) == 0) {
				ans = "OK";
			}
		}
		System.out.print(ans);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
}

Measured memory_bytes: 32404
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
using namespace std;
const int INF=(int)0x3f3f3f3f;
const int MOD=(int)1e9+7;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int ans=0,rain=0;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='R')
            rain++;
        else
            ans=max(ans,rain),rain=0;
    }
    cout<<max(ans,rain);
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

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

    sort(A.begin(), A.end());


    vector<int> id(M);
    iota(id.begin(), id.end(), 0);
    sort(id.begin(), id.end(), 
        [&](int i, int j) {return C[i] > C[j];});


    long long sum = 0;
    long long K = 0;
    for(auto i : id){
        for(int j = 0; j < B[i]; j++){
            if(K >= N){
                break;
            }
            sum += max(A[K], C[i]);
            K++;  
        }
    }
    for(int i = K; i < N; i++){
        sum += A[i];
    }

    cout << sum << endl;


    return 0;
}

Measured memory_bytes: 2944
#include<stdio.h>
#include<math.h>
int main(void)
{
    int x,a,b=1,p=2,s,max=0,tmp;
    scanf("%d",&x);
    a=sqrt(x);
    while(b<=a){
        s=b;
        while((s<=x)&&(p<=10)){
            s=s*b;
            p++;
        }
        s=s/b;
        if(max<s){
            tmp=max; max=s; s=tmp;
        }
        b++;
        p=2;
    }
    printf("%d\n",max);
    return 0;
}

Measured memory_bytes: 128
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef double dbl;
typedef vector <int> vi;
typedef pair <ll,ll> pll;
typedef pair <int, int> pii;

int const N = 300002;
int const MD = 998244353;

#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); ++(i))
#define RFOR(i, a, b) for (int (i) = (a); (i) >= (b); --(i))
#define REP(i, n) FOR(i, 0, n - 1)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define sz(v) int(v.size())

int main() {
	//freopen("input.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(NULL);
	int n, p, a[66];
	scanf("%d%d", &n, &p);
	long long dp[66][2] = {};
	dp[0][0] = 1;
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
		dp[i + 1][0] += dp[i][0];
		dp[i + 1][1] += dp[i][1];
		dp[i + 1][(0 + a[i]) % 2] += dp[i][0];
		dp[i + 1][(1 + a[i]) % 2] += dp[i][1];
	}
	cout << dp[n][p] << "\n";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string.h>
#include<string>
#include<set>
#include<limits.h>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include<functional>
#include<stack>
#include<deque>
#include<queue>
using namespace std;

signed main() {
	string a; cin >> a;
	if (a == "111")puts("3");
	else if (a == "000")puts("0");
	else if (a == "001" || a == "010" || a == "100")puts("1");
	else puts("2");
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >=0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;
#define INF 1e9

int main(){
  ll ans =0;
  int N, preA, preC;
  int sumb[(int)1e5+1] ={0}, sumc[(int)1e5+1] = {0};
  cin >> N;
  vector<int> A(N), B(N), C(N+1);
  REP(i, N){
    cin >> A[i];
  }
  REP(i, N){
    cin >> B[i];
  }
  REP(i, N){
    cin >> C[i];
  }
  C[N]=-1;
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());
  
  preA= 0;
  preC = 0;
  bool flag1 , flag2;
  flag1 = flag2 = false;  

  REP(i, N){
    for(int j = preA; A[j] < B[i] && j < N; j++){
      flag1 = true;
      preA = j;
    }
    for(int j = preC; B[i] >= C[j]&& j<N+1; ++j){
      preC = j;
    }
    if(flag1)
      ans += (ll)(preA+1) * (N - preC);
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
int main(){
	
	int a,b,c,d,e;
	scanf("%d %d %d %d",&a,&b,&c,&e);
	if(a==b && c==e || a==e && b==c || e==b && a==c ){
	printf("yes\n");
	}
	else{
		printf("no\n");
	}
    return 0;
}


Measured memory_bytes: 2068
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < n; ++i)
#define for1(i, n) for (int i = 1; i <= n; ++i)
#define fore(i, l, r) for (int i = l; i <= r; ++i)
 
using namespace std;
 
int main(){
	int N, M; cin >> N >> M;
	vector<int> X(M);
	vector<int> D(M - 1);
	forn(i, M){
		cin >> X[i];
	}
	sort(X.begin(), X.end());
	forn(i, M - 1){
		D[i] = X[i + 1] - X[i];
	}
	sort(D.begin(), D.end());
	int dist = 0;
	forn(i, M - N){
		dist += D[i];
	}
	cout << dist;
	
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int cellNum = scanner.nextInt();
        int cells[] = new int[cellNum];
        boolean reslt = true;

        for (int i = 0; i < cellNum; i++) {
            cells[i] = scanner.nextInt();
        }

        int nextNum = 0;
        for (int i = cellNum; 0 < i; i--) {
            if (cellNum == i) {
                nextNum = cells[i - 1];
                continue;
            }
            int num = cells[i - 1];
            if (num - nextNum > 1) {
                reslt = false;
                break;
            } else if (num - nextNum == 1) {
                nextNum = num - 1;
            } else {
                nextNum = num;
            }
        }

        System.out.println(reslt? "Yes": "No");
    }
}

Measured memory_bytes: 49908
#include <iostream>

using namespace std;

bool m[20][20];

#define D 10
#define INF 1000000

int w, h;
int dirX[4] = {0, 0, 1, -1};
int dirY[4] = {1, -1, 0, 0};
int dfs(int px, int py, int step, int gx, int gy) {
	int ret = INF;
	if (step >= 10) return INF;
	for (int d = 0; d < 4; ++d) {
		int nx = -1, ny = -1;
		for (int x = px, y = py; 0 <= x && x < w && 0 <= y && y < h; x += dirX[d], y += dirY[d]) {
			if (x == gx && y == gy) return step+1;
			if (m[y][x]) {
				nx = x-dirX[d], ny = y-dirY[d];
				break;
			}
		}
		if (nx > -1 && ny > -1 && (nx != px || ny != py)) {
			int wx = nx+dirX[d], wy = ny+dirY[d];
			m[wy][wx] = false;
			ret = min(ret, dfs(nx, ny, step+1, gx, gy));
			m[wy][wx] = true;
		}
	}
	return ret;
}

int main() {
	while (cin >> w >> h, w || h) {
		int sx, sy, gx, gy;
		for (int y = 0; y < h; ++y) {
			for (int x = 0; x < w; ++x) {
				int f; cin >> f;
				switch (f) {
					case 0: m[y][x] = false; break;
					case 1: m[y][x] = true; break;
					case 2: m[y][x] = false; sx = x, sy = y; break;
					case 3: m[y][x] = false; gx = x, gy = y; break;
				}
			}
		}
		int ans = dfs(sx, sy, 0, gx, gy);
		if (ans > 10) ans = -1;
		cout << ans << endl;
	}
}

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

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  long long int r=0,g=0,b=0;
  for(int i=0;i<N;i++){
    if(S.at(i) == 'R') ++r;
    if(S.at(i) == 'G') ++g;
    if(S.at(i) == 'B') ++b;
  }
  long long int count = r*g*b;

  for(int i=0;i<N;i++){
    //int j = i + 1;
    for(int j=i+1;j<N;j++){
      if(S[i]==S[j]){
        continue;
      }
      //cout << "i=" << i << endl;
      //cout << "j=" << j << endl;
      int k = 2*j - i;
      if(k>=N) continue;
      if(S[i]!=S[j] && S[j]!=S[k] && S[k]!=S[i]){
        count--;
      }
    }
  }

  cout << count << endl;
  return 0;

}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int a,b,k,p,s;
   cin>>a>>b>>k;
   if(k>=a)
    {
        k=k-a;
        a=0;

       // cout<<k<<endl;
        b=b-k;
       // cout<<b;
        if(b<0){
                b=0;
        }
        cout<<a<<" "<<b<<endl;
    }
   else{ a=a-k;cout<<a<<" "<<b<<endl;}

}


Measured memory_bytes: 256
import java.util.*;

class Main{

  public static void main(String args[]){

    Scanner s=new Scanner(System.in);
    double A=s.nextDouble();
    double B=s.nextDouble();
    double H=s.nextDouble();
    double M=s.nextDouble();

    double Atheta=((60*H+M)/360)*Math.PI;
    double Btheta=(M/30)*Math.PI;
    double deltaA=Math.pow((A*(Math.cos(Atheta))-B*(Math.cos(Btheta))),2);
    double deltaB=Math.pow((A*(Math.sin(Atheta))-B*(Math.sin(Btheta))),2);
    
    System.out.println(Math.sqrt(deltaA+deltaB));
  }  
}

Measured memory_bytes: 37544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const ll INF = 1e9+10;
const ll mod = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 


int main() {
    ll N;
    cin >> N;
    ll cnt[10][10], ans = 0;
    rep(i, 10)rep(j, 10)cnt[i][j] = 0;
    reps(i, 1, N + 1){
        int j;
        for (j = i; j >= 10; j/=10);
        cnt[j][i%10]++;
    }
    reps(i, 1, 10){
        reps(j, 1, 10){
            //cnt[i][j] = get_cnt(i, j, N);
            //fprintf(stderr, "%d, %d, %d\n", i, j, cnt[i][j]);
            ans += cnt[i][j] * cnt[j][i];
        }
    }
    cout << ans;
    return 0;
}


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

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        return;

    }

    public static string Solve()
    {
        long ans = 0;
        int K,A,B;
        int[] input = ReadInts();
        K = input[0];
        A = input[1];
        B = input[2];

        if (B - A <= 2) return (K + 1).ToString();

        K -= A - 1;
        //Console.WriteLine(K.ToString());
        //Console.WriteLine((B-A).ToString());
        if (K<=0) return (K + 1).ToString();
        ans = A;
        if (K%2==0)
        {
            ans += (long)K / 2 * (B - A);
        }
        else
        {
            ans += (long)K / 2 * (B - A);
            ans++;
        }
        if(ans < K+1) return (K + 1).ToString();
        return ans.ToString();
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


Measured memory_bytes: 11220
from collections import defaultdict, Counter
import math, copy


n = int(input())
prime = []
data = [i for i in range(2, n + 10)]
temp = 0
while (temp <= n):
    temp = data[0]
    prime.append(temp)
    data = [e for e in data if e % temp != 0]
n_dict = defaultdict(lambda: 1)
k = math.factorial(n)
for p in prime:
    while (k % p == 0):
        k = k // p
        n_dict[p] += 1
alc = list(n_dict.values())
ans = 0
n_75 = len([a for a in alc if a >= 75])
n_25 = len([a for a in alc if a >= 25])
n_15 = len([a for a in alc if a >= 15])
n_5 = len([a for a in alc if a >= 5])
n_3 = len([a for a in alc if a >= 3])
ans += n_75
if n_25 > 0:
    ans += (n_25 * (n_3 - 1))
if n_15 > 0:
    ans += ((n_5 - 1) * (n_15))
ans += (n_5 * (n_5 - 1) * (n_3 - 2)) // 2
print(ans)

Measured memory_bytes: 3444
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int n;
		while( (n = stdIn.nextInt()) != 0 ){
			String[][] s = new String[n][2];
			for(int i = 0; i < n; i++){
				s[i] = stdIn.next().split(",");
			}
			double[][] center = new double[n][2];
			for(int i = 0; i < n; i++){
				center[i][0] = Double.parseDouble(s[i][0]);
				center[i][1] = Double.parseDouble(s[i][1]);
			}
			boolean[][] check = new boolean[n][n];
			double[][] t = new double[n][n];
			for(int i = 0; i < n; i++){
				for(int j = i+1; j < n; j++){
					double x = (center[i][0]-center[j][0])*(center[i][0]-center[j][0])+(center[i][1]-center[j][1])*(center[i][1]-center[j][1]);
					if( x <= 4 ){
						check[i][j] = true;
						t[i][j] = Math.sqrt(4-x)/(2*Math.sqrt(x));
					}
				}
			}
			int max = 1;
			for(int i = 0; i < n; i++){
				for(int j = i+1; j < n; j++){
					if( check[i][j] ){
						double px1 = (center[j][0]-center[i][0])/2 + (center[j][1]-center[i][1])*t[i][j]+center[i][0];
						double py1 = (center[j][1]-center[i][1])/2 + (center[i][0]-center[j][0])*t[i][j]+center[i][1];
						double px2 = (center[j][0]-center[i][0])/2 - (center[j][1]-center[i][1])*t[i][j]+center[i][0];
						double py2 = (center[j][1]-center[i][1])/2 - (center[i][0]-center[j][0])*t[i][j]+center[i][1];
						int max1 = 1;
						int max2 = 1;
						for(int k = 0; k < n; k++){
							if( check[i][k] ){
								if( ((px1-center[k][0])*(px1-center[k][0])+(py1-center[k][1])*(py1-center[k][1])) <= 1 ){
									max1++;
								}
								if( ((px2-center[k][0])*(px2-center[k][0])+(py2-center[k][1])*(py2-center[k][1])) <= 1 ){
									max2++;
								}
							}
						}
						if( max1 > max ){
							max = max1;
						}
						if( max2 > max ){
							max = max2;
						}
					}
				}
			}
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;

int main() {
  int n;
  double tmp;
  int tmp1;
  cin >> n;
  if(n%2 == 0){
    tmp = n;
    cout << 0.5 << endl;
  }
  else{
    tmp = n;
    tmp1 = n/2;
    cout << (tmp1+1)/tmp << endl;
  }
  return 0;
}

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

int main() {
  int i;
  cin >> i;
  char l;
  bool p = false;
  bool w = false;
  bool g = false;
  bool y = false;
  while ( cin >> l ){
    if ( l == 'P'){
      p = true;
    }else if ( l == 'W'){
      w = true;
    }else if ( l == 'G'){
      g = true;
    }else{
      y = true;
    }
  }
  if ( p && w && g && y ){
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
}

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

int main() {

	const int p = 5;
	vector<int> x(p);
	for (int i = 0; i < p; i++) {
		cin >> x[i];
	}
	int ans;
	for (int i = 0; i < p; i++) {
		if (x[i] == 0) ans = i + 1;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

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

    int a, b, c;
    cin >> a >> b >> c;

    cout << (a == b && b == c ? "Yes" : "No");
    
    return 0;
}

Measured memory_bytes: 256
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<chrono>
#include<functional>
#include<random>
#include<unordered_set>
using namespace std;
typedef long long int llint;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const llint mod=1000000007;
const llint big=1e17-10;
const long double pai=3.141592653589793238462643383279;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
int main(void){
	llint i,j,n,m;cin>>n;
	llint k;
	vector<llint>sa(n);
	vector<llint>go(n);
	vector<llint>ans(n);
	for(j=0;j<n;j++){go[j]=j;ans[j]=j;}
	llint mae=0;
	for(i=0;i<n;i++){llint now;cin>>now;sa[i]=now-mae;mae=now;}
	cin>>m>>k;
	for(i=0;i<m;i++){llint q;cin>>q;swap(go[q],go[q-1]);}
	vector<llint> iti(n);
	for(i=0;i<61;i++){
		if((k&(((llint)1)<<(llint)i))!=0){for(j=0;j<n;j++){ans[j]=go[ans[j]];}}
		for(j=0;j<n;j++){iti[j]=go[go[j]];}
		swap(iti,go);
	}
	ans[0]=sa[0];
	for(j=1;j<n;j++){ans[j]=sa[ans[j]]+ans[j-1];}//どうせans[0]=go[0]だし
	for(j=0;j<n;j++){cout<<ans[j]<<endl;}
	return 0;
}

Measured memory_bytes: 4352
#include<iostream>
#include<string>
using namespace std;
int main(){
    string s;
    cin>>s;
    if(s[0]=='7')
        cout<<"Yes"<<endl;
    else if(s[1]=='7')
        cout<<"Yes"<<endl;
    else if(s[2]=='7')
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3136
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,h,i,j,k,l,m,n,x,y;
	ll		ans = 0;
	string	s = "No";
	cin >> a >> b >> c >> k;
	bool	f = false;
	for(i=1;i<=k;i++) {
		if (a>=b) b *= 2;
		else if (b>=c) c *= 2;
		if ((a<b)&&(b<c)) {
			s = "Yes";
			break;
		}

	}
	//vector<ll>	aa(n);
	//for(i=0;i<n;i++) cin >> aa[i];
	//vector<ll>	dp(n+1,INFL);
	//vector<vector<ll>>	dp2(x , vector<ll>(y,INFL));

	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
char s[12345];
int main(){
    scanf("%s",s);
    int len=strlen(s);
    long long ans=0;
    for(int t=0;t<(1<<(len-1));t++){
        long long num=s[0]-'0';
        for(int i=0;i<len-1;i++){
            if(t&(1<<i)){
                ans+=num;
                num=0;
            }
            num=num*10+s[i+1]-'0';
        }
        ans+=num;
    }
    cout <<ans <<"\n";
    return 0;
}

Measured memory_bytes: 3688
#include <iostream>
#include <cstdio>

#define M_N 1000000

int h_num[M_N + 10];

using namespace std;

int main()
{
	for (int i = 1; i <= M_N; i *= 2){
		for (int j = i; j <= M_N; j *= 3){
			for (int k = j; k <= M_N; k *= 5){
				h_num[k] = 1;
			}
		}
	}
	
	for (int i = 1; i <= M_N; i++){
		h_num[i] += h_num[i - 1];
	}
	
	int n, m;
	while (scanf("%d %d", &m, &n), m != 0){
		printf("%d\n", h_num[n] - h_num[m - 1]);
	}
	
	return (0);
}

Measured memory_bytes: 5092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int ms = 1e3+9;
ll X[ms], Y[ms], Z[ms];
ll vet[ms];

int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i = 0;i<n;i++) scanf("%lld %lld %lld",X+i,Y+i,Z+i);
	ll ans = 0;
	
	for(int i = -1;i<=1;i+=2){
		for(int j = -1;j<=1;j+=2){
			for(int k =-1;k<=1;k+=2){
				
				for(int l = 0;l<n;l++){
					vet[l] = X[l]*i + Y[l]*j + Z[l]*k;
				}
				sort(vet, vet+n);
				ll soma =0 ;
				for(int i = n-1;i>n-1-m;i--){
					soma += vet[i];
				}	
				ans = max(ans, soma);
			}
		}
	}
	cout<<ans;


}

Measured memory_bytes: 256
N,M = map(int,input().split())
if min(N,M) == 1:
    if max(N,M) > 2:
        print(max(N,M) -2)
    elif max(N,M) == 1:
        print(1)
elif N == 2 or M == 2:
    print(0)
elif N > 2 and M > 2:
    print((N-2)*(M-2))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 998244353LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll a,b,c,d;

int main(){
  ll ans=0;
  cin >> a>>b>>c>>d;
  vvi data(c+1, vi(d+1));  // N * M の2次元配列
  data[a][b]=1;

  //i,jを求めるとき
  for(ll i=a;i<=c;i++){
    for(ll j=b;j<=d;j++){
      data[i][j]+=data[i-1][j]*j+data[i][j-1]*i-data[i-1][j-1]*(i-1)*(j-1);
      data[i][j]=(data[i][j]%MOD+MOD)%MOD;
    }
  }

  
  cout<<data[c][d]<<endl;
  return 0;
}

Measured memory_bytes: 73744
#include<cstdio>
#include<vector>
#include<cstring>
using namespace std;

#define MAXN 100
struct point{
    int x,y;
}R[MAXN+5],B[MAXN+5];
int N;

bool vis[2*MAXN+5];
int Match[2*MAXN+5];
vector<int> G[2*MAXN+5];
bool dfs(int u){
    for(int i=0;i<int(G[u].size());i++){
        int v=G[u][i];
        if(!vis[v]){
            vis[v]=1;
            if(!Match[v]||dfs(Match[v])){
                Match[v]=u;
                Match[u]=v;
                return 1;
            }
        }
    }
    return 0;
}

int Solve(){
    int Ans=0;
    for(int i=1;i<=N;i++)
        if(!Match[i]){
            memset(vis,0,sizeof vis);
            Ans+=dfs(i);
        }
    return Ans;
}

int main(){
    scanf("%d",&N);
    for(int i=1;i<=N;i++)
        scanf("%d%d",&R[i].x,&R[i].y);
    for(int i=1;i<=N;i++)
        scanf("%d%d",&B[i].x,&B[i].y);
    int Ans=0;
    for(int i=1;i<=N;i++)
        for(int j=1;j<=N;j++)
            if(R[i].x<B[j].x&&R[i].y<B[j].y)
                G[i].push_back(j+N);
    N*=2;
    printf("%d",Solve());
}
/**/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 1e9+7; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 5e5;

int n, q, l[N], r[N];
int c[N], cc[N], ccc, ans[N], qi[N];
inline void add(int i){
  if(!cc[c[i]]++) ccc++;
};
inline void del(int i){
  if(!--cc[c[i]]) ccc--;
};
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  scanf("%d %d", &n, &q);
  iota(qi, qi+q, 0);
  FOR(i, 0, n) scanf("%d", &c[i]), c[i]--;
  FOR(i, 0, q) scanf("%d %d", &l[i], &r[i]), l[i]--;
  {
    int sq = sqrt(n);
    sort(qi, qi+q, [&](int i, int j){
        return l[i]/sq != l[j]/sq ? l[i]/sq < l[j]/sq : r[i] < r[j];
        });
  }
  int nl = 0, nr = 0; // [nl, nr)
  FOR(_i, 0, q){
    int i = qi[_i];
    while (nl > l[i]) add(--nl);
    while (nr < r[i]) add(nr++);
    while (nl < l[i]) del(nl++);
    while (nr > r[i]) del(--nr);
    ans[i] = ccc;
  }
  FOR(i, 0, q) printf("%d\n", ans[i]);
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()

using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }


const int MAX_N = 300;
const ll INF = TEN(15);
int n;
int a[MAX_N][MAX_N];
ll b[MAX_N][MAX_N];

int main()
{
  fastio();

  vec<tuple<int,int,int>> edges;
  cin >> n;
  forn(i,n) forn(j,n) {
    cin >> a[i][j];
    if (i < j)
      edges.emplace_back(a[i][j],i,j);
  }

  bool ok = true;
  forn(i,n) forn(j,n) forn(k,n) {
    ok &= a[i][k] + a[k][j] >= a[i][j];
  }

  if (!ok) {
    cout << -1 << endl;
    return 0;
  }

  forn(i,n) forn(j,n) b[i][j] = i == j ? 0 : INF;
  sort(all(edges));


  ll ans = 0;
  for (auto e : edges) {
    int l,i,j;
    tie(l,i,j) = e;

    forn(k,n) {
      if (b[i][k] != INF && b[k][j] != INF) {
        chmin(b[i][j], b[i][k] + b[k][j]);
        b[j][i] = b[i][j];
      }
    }

    if (b[i][j] == l) continue;

    b[i][j] = b[j][i] = l;
    ans += l;

    forn(k,n) {
      if (b[j][k] != INF) {
        chmin(b[i][k], b[i][j] + b[j][k]);
        b[k][i] = b[i][k];
      }
      if (b[k][i] != INF) {
        chmin(b[k][j], b[k][i] + b[i][j]);
        b[j][k] = b[k][j];
      }
    }
  }

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


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



int main() {
  string S;
  cin>>S;
  if(S=="ABC")
  {
    cout<<"ARC"<<endl;
  }
  else
  {
    cout<<"ABC"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  long long k;
  cin>>n>>k;
  vector<int> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  
  vector<int> s;
  vector<int> ord(n+1,-1);
  int c=1,l=0;
  int v=1;
  while(ord[v]==-1){
    ord[v]=s.size();
    s.push_back(v);
    v=a[v-1];
  }
  c=s.size()-ord[v];
  l=ord[v];
  if(l>k){
    cout<<s[k]<<endl;
  }else{
    k-=l;
    k%=c;
    cout<<s[l+k]<<endl;
  }
  return 0;
}


Measured memory_bytes: 5884
#if 0
#endif

#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
#include <string>
#include <stack>
using namespace std;

string word;
stack<int> S;

int pop()
{
    int temp = S.top();
    S.pop();
    return temp;
}

int main()
{
    while (cin >> word)
    {
        if (word == "+")
        {
            int right = pop();
            int left = pop();
            S.push(left + right);
        }
        else if (word == "-")
        {
            int right = pop();
            int left = pop();
            S.push(left - right);
        }
        else if (word == "*")
        {
            int right = pop();
            int left = pop();
            S.push(left * right);
        }
        else
        {
            S.push(stoi(word));
        }
    }
    cout << pop() << endl;
}



Measured memory_bytes: 3188
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define INF (1<<29)

#define DEBUG(x) cout << #x << ": " << x << endl;

int N, M, R; // 町数、道数、訪れる町数
int d[201][201]; // 町と町の距離
int r[9];//なにこれ
int A, B, C; // A町、B町、AB間の距離
int res;//なにこれ
bool used[9];

void dfs(int c, int las, int dist);

int main() {
    cin >> N >> M >> R; // 1段目の読み込み
    // 町の間の距離の初期化作業 -----------------------------------------------------------
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            if (i != j) { // A町からA町のように、無意味なものは初期化しない
                d[i][j] = INF; // 町の間の距離をできるだけ大きな数値で初期化
            }
        }
    }
    // END -------------------------------------------------------------------------

    // どの町を訪れるか入力 --------------------------------------------------------------
    vector<int> road;
    for (int i = 1; i <= R; i++) {
        //cin >> r[i]; // 2段目の読み込み
        int x;
        cin >> x;
        road.push_back(x);
    }
    sort(road.begin(), road.end());
    // END ---------------------------------------------------------------------------

    for (int i = 1; i <= M; i++) {
        cin >> A >> B >> C; // 3段目以降の読み込み
        if (d[A][B] > C) { // CはA,B間の距離
            d[A][B] = d[B][A] = C; // より小さい距離を格納
                                   // d[A][B]とd[B][A]は同じ
        }
    }

    for (int k = 1; k <= N; k++) {
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++) {
                if (d[i][j] > d[i][k] + d[k][j]) {
                    d[i][j] = d[i][k] + d[k][j]; // より小さいものを代入
                    //printf("d[%d][%d] = d[%d][%d] + d[%d][%d]\n", i, j, i, k, k ,j);
                }
            }
        }
    }
    /*
    int ans = 0;
    for (int i = 0; i < (M - 1); i++) {
        ans += d[road[i]][road[i+1]];
    }

    cout << ans << endl;
    */

    int ans = INF;
    do {
        int dist = 0;
        for (int i = 0; i < (R - 1); i++) {
            dist += d[road[i]][road[i+1]];
        }
        ans = min(ans, dist);
    } while (next_permutation(road.begin(), road.end()));
    
    cout << ans << endl;

}

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

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b||a==c||b==c){
		if(a!=b||a!=b||b!=c){
			cout<<"Yes";
			return 0;
		}
	}
	
	cout<<"No";
	
	return 0;
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N = 2e5+5;
const int B = 13;
int cnt[55][55];
inline void read(){
	ll number=0;int P=0;
	int u=0;
	char c=getchar();
	while(c<'0'||c>'9')c=getchar();
	while(c=='.'||(c>='0' && c<='9')){
		if(c=='.')u=1;
		else{
			if(u)++P;
			number=number*10ll+c-'0';
		}
		c=getchar();
	}
	int two=-P;
	while(number%2==0)two++,number/=2;
	int five=-P;
	while(number%5==0)number/=5,five++;
	two = min(two, 13),five = min(five, 13);
	cnt[B+two][B+five]++;
	// cout << two << ":" << five << endl;
}

int main()
{
	ll ans=0;
	int n;cin >> n;
	for(int i=1;i<=n;i++)read();
	for(int i=-10;i<=13;i++){
		for(int j=-10;j<=13;j++){
			for(int k=-10;k<=13;k++){
				for(int l=-10;l<=13;l++)if(pii(i,j) <= pii(k,l)){
					if(i+k>=0 && j+l>=0){
						if(pii(i,j)==pii(k,l)){
							ans+=1ll*cnt[B+i][B+j]*(cnt[B+i][B+j]-1)/2;
						}else{
							ans+=1ll*cnt[B+i][B+j]*cnt[B+k][B+l];
						}
					}
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int count;
		
		count = 0;
		while (sc.hasNext()) {
			String str = sc.next();
			boolean flag = true;
			for (int i = 0; i < str.length() / 2 && flag; i++) {
				if (str.charAt(i) != str.charAt(str.length() - 1 - i)) {
					flag = false;
				}
			}
			if (flag) {
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 12000
#s = list(map(int, input().split()))
s = input()
yojou = len(s) - 7

for i in range(yojou + 2):
    # print(s[0:i] + s[i + yojou:])
    if s[0:i] + s[i + yojou:] == 'keyence':
        print("YES")
        exit(0)
print("NO")


Measured memory_bytes: 2940
data = [                                                           
    [[0 for r in range(10)] for f in range(3)] for b in range(4)   
]                                                                  
                                                                   
# ??\??????????????????????????§????????????????????????????????????                                           
count = int(input())                                               
for c in range(count):                                             
    b, f, r, v = [int(i) for i in input().split()]                 
    data[b-1][f-1][r-1] += v                                       
                                                                   
for bi, b in enumerate(data):                                      
    for f in b:                                                    
        for r in f:                                                
            print(' {0}'.format(r), end='')                        
                                                                   
        print()                                                    
    if bi < 3:                                                     
        print('#' * 20)                      

Measured memory_bytes: 7736
using System;
using System.Collections.Generic;

class main
{
	static void Main(string[] args)
	{
		string str = Str();
		decimal sum = 0;
		int len = str.Length;

		for(int i = 0;i < len; i++)
		{
			sum += int.Parse(str.Substring(i,1));
		}

		string ans = (sum % 9) == 0 ? "Yes" : "No" ;

		Console.Write(ans);

	}
	static string Str()
	{
		return Console.ReadLine().Trim();
	}
	static string[] StrArr()
	{
		return Console.ReadLine().Trim().Split(' ');
	}
	static int[] IntArr()
	{
		string[] strArr = StrArr();
		int len = strArr.Length;

		int[] intArr = new int[len];
		for(int i = 0;i < len; i++)
		{
			intArr[i] = Int(strArr[i]);
		}

		return intArr;
	}

	static int Int(string Str)
	{
		return int.Parse(Str);
	}
}



Measured memory_bytes: 32872
#include <algorithm>
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;

const int MAX=1000;

#define hoge(i,n) for(int i=0;i<n;i++)

int main(){
    int N,s[MAX];
    string S[MAX];
    cin >> N;
    hoge(i, N){
        cin >> S[i];
        if(S[i]=="A"){s[i]=1;}else{s[i]=-1;}
    }
    int sum=0;
    hoge(i,N){
        sum+=s[i];
        if(sum<0){break;}
    }
    if(sum==0){cout<<"YES";}else{cout<<"NO";}

    cout<<endl;
    return 0;
}

Measured memory_bytes: 3180
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 86410;

int sec(string s) {
	string a, b, c;
	a = s.substr(0, 2);
	b = s.substr(3, 2);
	c = s.substr(6, 2);
	return stoi(a) * 60 * 60 + stoi(b) * 60 + stoi(c);
}

int main() {
//	cout << fixed << setprecision(15);
	vi c(N), ans;
	while(true) {
		int n;
		cin >> n;
		if(n == 0) break;
		fill(c.begin(), c.end(), 0);
		rep(i, n) {
			string s, t;
			cin >> s >> t;
			c[sec(s)]++;
			c[sec(t)]--;
		}
		rep(i, N-1) c[i+1] += c[i];
		int _ans = 0;
		rep(i, N) chmax(_ans, c[i]);
		ans.push_back(_ans);
	}
	for(int i: ans) cout << i << endl;
}



Measured memory_bytes: 3148
#include<iostream>
using namespace std;
 
int main()
{
    // get a integer
    int a;
	cin>>a;
  	string str = to_string(a);
  	if (str.find("7")!=string::npos) {
    	cout << "Yes" << endl;
    } else {
    	cout << "No" << endl;
    }
    return 0;
}

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

int main(){

	int s1, s2;

	while (cin >> s1 >> s2 && s1 != 0 && s2 != 0){

		int sum[5];
		int max;
		int num;
		sum[0] = s1 + s2;
		max = sum[0];
		num = 0;
		for (int i = 1; i < 5; i++){
			cin >> s1 >> s2;
			sum[i] = s1 + s2;
			if (max < sum[i]){
				max = sum[i];
				num = i;
			}
		}

		cout << (char)('A' + num) << ' ' << max << endl;
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <utility>
#include <queue>
using namespace std;

int main() {
  int n, q;
  cin >> n >> q;
  vector<string> name(n);
  vector<int> time(n);
  queue<pair<string, int>> process;
  int i;
  for (i = 0; i < n; i++) {
    cin >> name[i] >> time[i];
    process.push(make_pair(name[i], time[i]));
  }
  int elapsed = 0;
  while (process.size()) {
    if (process.front().second <= q) {
      elapsed += process.front().second;
      cout << process.front().first << ' ' << elapsed << endl;;
    } else {
      elapsed += q;
      process.push(make_pair(process.front().first, process.front().second - q));
    }
    process.pop();
  }
  return 0;
}



Measured memory_bytes: 6448
<?php
$map = array_fill(0,100001,1);
$map[1] = 0;
for($i = 1; $i <= 3200; $i++){
  if($map[$i] == 1){
    for($j = 2; $i * $j < 100000; $j++){
      $map[$i*$j] = 0;
    }
  }
}
$sum[-1] = 0;
for($i = 1; $i < 100000; $i+=2){
  $sum[$i] = $sum[$i-2] + $map[$i]*$map[($i+1)/2];
}
$Q = intval(fgets(STDIN));
for($i = 0; $i < $Q; $i++){
  fscanf(STDIN, "%d%d", $l, $r);
  echo $sum[$r]-$sum[$l-2],"\n";
}



Measured memory_bytes: 14072
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

int main(){
  int n, m;
  std::cin >> n;
  vector<int> d(n);
  for (int i = 0; i < n; i++) std::cin >> d[i];
  std::cin >> m;
  vector<int> t(m);
  for (int i = 0; i < m; i++) std::cin >> t[i];
  sort(d.begin(), d.end());
  sort(t.begin(), t.end());
  int pos = 0;
  for (int i = 0; i < m; i++, pos++) {
    while(pos < n and t[i] != d[pos])pos++;
    if(pos == n)break;
    if(i == m - 1)break;
  }
  if(pos == n)std::cout << "NO" << std::endl;
  else std::cout << "YES" << std::endl;
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#define int long long 
const int mod=998244353;
#define br rb
#define bg gb
#define gr rg
using namespace std;
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,i,j,k,l,r=0,g=0,b=0,rg=0,rb=0,bg=0,ans=1;
	string s;
	cin>>n>>s;
	s=" "+s;
	for(i=1;i<=3*n;i++){
		if(s[i]=='R'){
			if(bg){
				ans*=bg;
				ans%=mod;
				bg--;
				continue;
			}
			if(b){
				ans*=b;
				ans%=mod;
				b--;
				rb++;
				continue;
			}
			if(g){
				ans*=g;
				ans%=mod;
				g--;
				rg++;
				continue;
			}
			r++;
		}
		if(s[i]=='B'){
			if(rg){
				ans*=rg;
				ans%=mod;
				rg--;
				continue;
			}
			if(r){
				ans*=r;
				ans%=mod;
				r--;
				rb++;
				continue;
			}
			if(g){
				ans*=g;
				ans%=mod;
				g--;
				gb++;
				continue;
			}
			b++;
		}
		if(s[i]=='G'){
			if(br){
				ans*=br;
				ans%=mod;
				br--;
				continue;
			}
			if(b){
				ans*=b;
				ans%=mod;
				b--;
				bg++;
				continue;
			}
			if(r){
				ans*=r;
				ans%=mod;
				r--;
				gr++;
				continue;
			}
			g++;
		}
	}
	for(i=1;i<=n;i++){
		ans*=i;
		ans%=mod;
	}
	cout<<ans;
}

Measured memory_bytes: 916
import java.util.Scanner;
import java.lang.Math;
import java.util.ArrayList;
import java.util.List;
//List<Integer> list = new ArrayList<>();

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int h = stdIn.nextInt();
		int w = stdIn.nextInt();
		int h1 = stdIn.nextInt();
		int w1 = stdIn.nextInt();
		System.out.println((h-h1)*(w-w1));
		
	}
}

Measured memory_bytes: 23508
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] wArr = new int[10];
        int[] kArr = new int[10];
        for (int i = 0; i < 10; i++) {
            wArr[i] = - sc.nextInt();
        }
        for (int i = 0; i < 10; i++) {
            kArr[i] = - sc.nextInt();
        }
        Arrays.sort(wArr);
        Arrays.sort(kArr);
        int wTotal = 0;
        int kTotal = 0;
        for (int i = 0; i < 3; i++) {
            wTotal -= wArr[i];
            kTotal -= kArr[i];
        }
        System.out.println(wTotal + " " + kTotal);
    }
}



Measured memory_bytes: 26284
#include <bits/stdc++.h>
using namespace std;
#define ll              long long int
#define int             ll
#define ff              first
#define ss              second
#define pb              emplace_back
#define mpair           make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define sbits(x)      __builtin_popcountll(x)
#define zbits(x)      __builtin_popcountlliltin_ctzll(x)
#define w(t)            int t;cin>>t;while(t--)
#define uset            unordered_set
#define dor(i, a, b)    for(int i =(a);i<=(b);i++)
#define mem(a,val)      memset((a),(val),sizeof((a))); 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
    template <typename Arg1>
     void __f(const char* name,Arg1&& arg1){
        cout<<name<<" : "<<arg1<<std::endl;
     }
     template <typename Arg1, typename... Args>
     void __f(const char* names,Arg1&& arg1,Args&&... args){
        const char* comma = strchr(names+1 ,',');
        cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
     }
#else
#define trace(...)
#endif
/*     
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
*/
double pi = 2.0*acos(0);
void fast(){ios_base::sync_with_stdio(false);cin.tie(NULL);cout<<fixed<<setprecision(10);}
int max2(int a,int b){ if(a>b) return a;return b;}
int min2(int a,int b){ if(a<b)return a;return b;}
int max3(int a,int b,int c){ return max2(a,max2(b,c));}
int min3(int a,int b,int c){ return min2(a,min2(b,c));}

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



void solve()
{
   int n;
   cin>>n;
   int d = n%10;
   if(d == 2 || d==4 || d==5 || d==7 || d==9)
   cout<<"hon"<<endl;
   else if(d == 0 || d==1 || d==6 || d==8 )
   cout<<"pon"<<endl;
   else
   cout<<"bon"<<endl;  
}

signed main(void)
{
      fast();
      //w(t)
      solve();

}


Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int x,i,l,r;
	cin >> x;
	for(i=0; i<=x; ++i){
		l = 100*i;
		r = 105*i;
		if(l<=x && x<=r){
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
	return 0;
}


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

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------


int main() {
    
    while(1){
   int h,w,sx=0,sy=0,gx,gy;
   
   cin>>w>>h;
 
   if(h==0&&w==0)break;
   
    gx=h-1;gy=w-1;
    
    vvll d(h,vll(w,0));
    d.at(0).at(0)=1;
    vector<vvll> maze(h,vvll(w,vll(4,1)));

    rep(i,2*h-1){
        
        if(i%2==0){
            rep(j,w-1){
                int k;
                cin>>k;
                maze.at(i/2).at(j).at(3)=k;
                maze.at(i/2).at(j+1).at(1)=k;
            }
        }else{
            rep(j,w){
                int k;
                cin>>k;
                maze.at(i/2).at(j).at(2)=k;
                maze.at(i/2+1).at(j).at(0)=k;
            }
        }
    }
    
    queue<pll> q;
    q.push({0,0});
    //vi dx(4);
    vll dy={0,-1,0,1};
    //vi dy(4);
    vll dx={-1,0,1,0};
    
    while(!q.empty()){
        ll nx=q.front().first;
        ll ny=q.front().second;
        q.pop();
        rep(i,4){
            if(maze.at(nx).at(ny).at(i))continue;
            
            ll x=nx+dx.at(i);
            ll y=ny+dy.at(i);
            
            if(d.at(x).at(y)==0){
                //cout<<x<<" "<<y<<endl;
                d.at(x).at(y)=d.at(nx).at(ny)+1;
                //q.push({0,1});
                q.push({x,y});
            }
        }
    }
    
    cout<<d.at(gx).at(gy)<<endl;
    
    }
  
}



Measured memory_bytes: 3220
#include <stdlib.h>
#include <stdio.h>
int compare(const void *a,const void *b){
    if(*(int *)a>*(int*)b)return 1;
    return -1;
}
int main()
{   int n;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    qsort(a,n,sizeof(int),compare);
    /*for(int i=0;i<n;i++){
        printf("%d ",a[i]);
    }printf("\n");
    */
    if(n==3){
        printf("%d",(abs(a[0]-a[1])+abs(a[0]-a[2]))>(abs(a[2]-a[1])+abs(a[2]-a[0]))?(abs(a[0]-a[1])+abs(a[0]-a[2])):(abs(a[2]-a[1])+abs(a[2]-a[0])));
        return 0;
    }
    int arr[n],flag=0,l=0,r=n-1;
    for(int i=0;i<n;i++)arr[i]=0;
    arr[0]=a[(n-1)/2];
    for(int i=1;i<n;i++){
        
        if(i%2==0){
            if(a[l]==arr[0]&&flag==0){
                l++;
                flag++;
            }
            arr[i]=a[l];
            l++;
        }else{
            if(a[r]==arr[0]&&flag==0){
                r--;
                flag++;
            }
            arr[i]=a[r];
            r--;
        }
    }
    /*for(int i=0;i<n;i++){
            printf("%d ",arr[i]);
        }
        printf("\n");
    */long long ans1=0;
    for(int i=0;i<n-1;i++){
        ans1+=abs(arr[i]-arr[i+1]);
    }
    l=0;r=n-1;
    for(int i=1;i<n;i++){
        if(i%2==0){
            if(a[r]==arr[0]&&flag==0){
                r--;
                flag++;
            }
            arr[i]=a[r];
            r--;
        }else{
            if(a[l]==arr[0]&&flag==0){
                l++;
                flag++;
            }
            arr[i]=a[l];
            l++;
        }
    }
    
    /*for(int i=0;i<n;i++){
            printf("%d ",arr[i]);
        }
        printf("\n");
        */long long ans2=0;
    for(int i=0;i<n-1;i++){
        ans2+=abs(arr[i]-arr[i+1]);
    }
    
    printf("%lld",ans1>ans2?ans1:ans2);

    return 0;
}


Measured memory_bytes: 952