akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    map<int,int>mp1;
    map<int ,int>mp2;
    mp1[1]=1;
    mp1[3]=1;
    mp1[5]=1;
    mp1[7]=1;
    mp1[8]=1;
    mp1[10]=1;
    mp1[12]=1;
    mp2[4]=1;
    mp2[6]=1;
    mp2[9]=1;
    mp2[11]=1;
    int x,y;cin>>x>>y;
    if((mp1[x]&&mp1[y])||(x==2&&y==2)||(mp2[x]&&mp2[y]))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    
}

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

int main()
{
    int n,k,q,w,ans=0;
    cin>>n>>k>>q>>w;
    for(int i=0;i<n;i++)
    {
        if(i>k-1) ans+=w;
        else ans+=q;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import numpy as np
 
N, M = map(int, input().split())
 
suc = [0 for i in range(N+1)]
pen = [0 for i in range(N+1)]
 
for i in range(M):
    p, s = input().split()
    p = int(p)
    if s == "WA" and suc[p] == 0:
        pen[p] += 1
    elif s == "AC":
        suc[p] = 1

for i in range(N+1):
    if suc[i] == 0:
        pen[i] = 0

print( sum(suc), sum(pen) )

Measured memory_bytes: 14308
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

int dp[110000][13];

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

    string S;
    cin >> S;
    int len = S.size();
    reverse(ALL(S));

    REP(i, 13) { dp[0][i] = 0; }

    if (S[0] == '?') {
        REP(i, 10) { dp[0][i] = 1; }
    } else {
        int index = S[0] - '0';
        dp[0][index] = 1;
    }

    int num = 1;
    FOR(i, 1, len) {
        // cout << i << ":" << S[i] << endl;

        num *= 10;
        num %= 13;

        if (S[i] == '?') {
            REP(j, 10) {
                REP(k, 13) {
                    int index = (k + j * num) % 13;
                    dp[i][index] += dp[i - 1][k];
                    dp[i][index] %= MOD;
                }
            }
        } else {
            REP(k, 13) {
                int j = (S[i] - '0');
                int index = (k + j * num) % 13;
                dp[i][index] += dp[i - 1][k];
                dp[i][index] %= MOD;
            }
        }
    }

    cout << dp[len - 1][5] << endl;

    return 0;
}


Measured memory_bytes: 5504
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6 * 2 + 10, INF = 1e9 * 1e9 + 10;



int main()
{
    fastInp;

    ll h, m, h1, m1, k;
    cin >> h >> m >> h1 >> m1 >> k;

    ll t = (h1 - h) * 60 + (m1 - m);

    cout << t - k;
    
    return 0;
}

Measured memory_bytes: 3644
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#define rep(i,n) for (int i = 0; i < (n);i++)
typedef long long ll;
using namespace std;
/*#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;*/


void Main()
{
    string s; cin >> s;
    int n = s.size();
    vector<int> ans(n);

    rep(ri,2){
        int cnt = 0;
        rep(i,n) {
            if (s.at(i) == 'R') cnt++;
            else{
                ans.at(i) += cnt/2;
                ans.at(i-1) += (cnt+1)/2; 
                cnt = 0;
            }
        }
        reverse(ans.begin(),ans.end());
        reverse(s.begin(),s.end());
        rep(i,n){
            if (s.at(i) == 'L') s.at(i) = 'R';
            else s.at(i) = 'L';
        }
    }
    rep(i,n) cout<<ans.at(i)<<endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

Measured memory_bytes: 1104
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int N,K;
    cin >> N >> K;
    int P[N];
    int ans=N-K+1;
    rep(i,N) cin >> P[i];
    set<int> unsort,sorted;
    unsort.insert(INF);
    rep(i,N-1) if(P[i]>P[i+1]) unsort.insert(i);
    rep(i,N-K+1) if(*unsort.lower_bound(i)>i+K-2){
        sorted.insert(i);
    }
    if(sorted.size()>1){
        int s1,s2;
        auto itr=sorted.begin();
        s1=*itr;
        itr++;
        s2=*itr;
        if(s2-s1>1) ans--;
        sorted.erase(s1);
        sorted.erase(s2);
        while(!sorted.empty()){
            s1=s2;
            s2=*sorted.begin();
            sorted.erase(s2);
            if(s2-s1>1) ans--;
        }
    }
    set<int> range;
    rep(i,K) range.insert(P[i]);
    int mini=*range.begin();
    auto itr=range.end();
    itr--;
    int maxi=*itr;
    int fp=0,lp=K-1;
    rep(i,N-K){
        bool check=true;
        if(P[fp]!=mini) check=false;
        if(maxi>P[lp+1]) check=false;
        if(check) ans--;
        range.erase(P[fp]);
        range.insert(P[lp+1]);
        fp++,lp++;
        mini=*range.begin();
        auto itr=range.end();
        itr--;
        maxi=*itr;
    }
    cout << ans << endl;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
using namespace __gnu_pbds;

#define debug(s) cout << #s << " = " << s << endl
#define all(v) (v).begin(), (v).end()
#define mem(a,val) memset(a, val, sizeof a)
 
#define INF 1e15
#define ff first
#define ss second
typedef long long ll;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

void max_self(ll &a, ll b) {
  a = max(a, b);
}

ll dp[1000010];

int main() {
  int n, w;
  scanf("%d%d", &n, &w);
  for (int item = 0; item < n; ++item) {
    int weight, value;
    scanf("%d%d", &weight, &value);
    for (int weight_already = w - weight; weight_already >= 0; --weight_already) {
      max_self(dp[weight_already + weight], dp[weight_already] + value);
    }
  } 
  ll ans = 0;
  for (int i = 0; i <= w; ++i) max_self(ans, dp[i]);
  printf("%lld\n", ans); 
}


Measured memory_bytes: 1024
using System;

public class Hello
{
    public static void Main()
    {
        var a = new int[100001];
        var n = int.Parse(Console.ReadLine().Trim());
        var amax = -1;
        string[] line = Console.ReadLine().Trim().Split(' ');
        for (int i = 0; i < n; i++)
        {
            var w = int.Parse(line[i]);
            a[w]++;
            amax = Math.Max(amax, w);
        }
        if (amax == 0) { Console.WriteLine(a[0]); goto end; }
        if (amax == 1) { Console.WriteLine(a[0] + a[1]); goto end; }
        var res = -1;
        for (int i = 0; i <= amax - 2; i++)
            res = Math.Max(res, a[i] + a[i + 1] + a[i + 2]);
        Console.WriteLine(res);
        end:;
    }
}

Measured memory_bytes: 16864
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (long long int i = f; i < t; i++)
#define pr(i, f, t) for (long long int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
#define ce(a) cout << (a) << endl
int main()
{
    ll h, w;
    cin >> h >> w;
    ll n;
    cin >> n;
    ll a[n];
    rp(i, 0, n) cin >> a[i];
    vl aa;
    rp(i, 0, n)
    {
        rp(j, 0, a[i]) aa.push_back(i + 1);
    }
    ll ans[h][w];
    ll co = 0;
    rp(i, 0, h)
    {
        if (i % 2 == 0)
        {
            rp(j, 0, w)
            {
                cout << aa[co] << ((j == w - 1) ? "\n" : " ");
                co++;
            }
        }
        else
        {
            ll coco = co;
            rp(j, 0, w)
            {
                cout << aa[coco + w - j - 1] << ((j == w - 1) ? "\n" : " ");
                co++;
            }
        }
    }
}

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

int main () {
  long long N , x ;
  cin >> N >> x ;
  vector<long long> line(N);
  for(int i = 0 ; i < N ; i++ ) {
    cin >> line[i] ;
  }
  sort(line.begin(),line.end()) ;
  long long pre = 0 ;
  long long ans = 0 ;
  for(int i = 0 ; i < N ; i++ ){
    if(pre+line[i]<=x) {
      if(i==N-1) {
        if(pre+line[i]!=x) break ;
      }
      pre += line[i] ;
      ans++ ;
    }
  }
  cout << ans << endl ;
}

Measured memory_bytes: 256
object Main {
  import scala.io.StdIn._
  import scala.collection.mutable.Queue
  def main(args: Array[String]): Unit = {
    var lunlunQueue = Queue((1L to 9L):_*)
    var k = readLine().toInt
    while (k != 1) {
      val h = lunlunQueue.dequeue()
      val l = h % 10L
      if (l != 0L) lunlunQueue.enqueue(h * 10L + l - 1)
      lunlunQueue.enqueue(h * 10L + l)
      if (l != 9) lunlunQueue.enqueue(h * 10L + l + 1)
      k -= 1
    }
    println(lunlunQueue.dequeue())
  }
}


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

int X;

int main() {
    std::cin >> X;
    std::string s;
    if ( X == 7 || X == 5 || X == 3 ) {
        s = "YES";
    } else {
        s = "NO";
    }
    std::cout << s << std::endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.*;

class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        String s[]=bu.readLine().split(" ");
        int x=Integer.parseInt(s[0]),y=Integer.parseInt(s[1]);
        int i,j,f=0;
        for(i=0;i<=100;i++)
        for(j=0;j<=100;j++)
        if(i+j==x && 2*i+4*j==y) f=Math.max(f,1);
        if(f==1) sb.append("Yes");
        else sb.append("No");
        System.out.print(sb);
    }
}


Measured memory_bytes: 32600
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int R,C;
	cin >> R >> C;
	string line ="##";
	for(int c=0;c<C;++c){
		line += '#';
	}
	
	vector<string> str(R);
	for(int r=0;r<R;++r){
		cin >> str[r];
	}
	cout << line << "\n";
	for(int r=0;r<R;++r){
		cout << "#" << str[r] << "#\n";
	}
	cout << line << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long ans = 0;
        int count = 1;
        while (n / count > 2) {
            long v = n - count;
            long mod = v % count;
            long sho = v / count;
            if (mod == 0 && (n / sho) == (n % sho)) {
                ans += sho;
            } else if (count > sho) {
                break;
            }
            count++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35776
#include <iostream>
#include <bits/stdc++.h>
#define ll long long

using namespace std;
ll a[200100],f[200100];

int main()
{
    ll n,k;  cin >> n >> k;
    for(int i = 0;i<n;i++)  scanf("%I64d",&a[i]);
    for(int i = 0;i<n;i++)  scanf("%I64d",&f[i]);
    sort(a , a + n , greater <ll>());
    sort(f , f + n);
    ll Start = 0 , End = 1e12 , Ans = 1e12;
    while(Start <= End){
        ll mid = (Start + End)/2;
        ll Need = 0;
        for(int i =0 ;i<n;i++)
        {
            ll Start2 = 0 , End2 = 1e12 , Res = 0;
            while(Start2 <= End2){
                ll mid2 = (Start2 + End2)/2;
                if((a[i] - mid2)*f[i] <= mid)  Res = mid2 , End2 = mid2 - 1;
                else   Start2 = mid2 + 1;
            }
            Need+=Res;
        }
        if(Need <= k)  Ans = mid , End = mid - 1;
        else  Start = mid + 1;
    }
    cout << Ans;
    return 0;
}


Measured memory_bytes: 3328
package main

import (
	"fmt"
)

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	fmt.Println(max(a*c, max(a*d, max(b*d, b*c))))
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


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

#define INF 1000000007
#define mem(dp,a) memset(dp,a,sizeof dp)
#define flash ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define f(i,n) for (ll i=0;i<n;i++)
#define sieve(j,mp) for(ll j=2*i ; j<=mp ; j+=i)
#define pb(x) push_back(x)
#define mp(x,y) push_back(make_pair(x,y))
#define tr(c,it) for(((c).begin())it=(c).begin();it!=(c).end();it++)
#define test ll t=1; while(t--)
#define F first
#define S second
main()
{
    flash
    clock_t launch=clock();
    test
    {
        ll h,w;cin>>h>>w;
        ll dp[h+1][w+1];
        mem(dp,0);
        string s[h];
        f(i,h)cin>>s[i];
        rep(i,1,h+1)
        rep(j,1,w+1)
        if(i==1&&j==1)dp[1][1]=1;
        else if(s[i-1][j-1]=='.') dp[i][j]=(dp[i-1][j]+dp[i][j-1])%INF;
        cout<<dp[h][w]<<endl;
    }
    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
    return 0;
}


Measured memory_bytes: 9088
#!/usr/bin/env python3
from fractions import gcd
#from math import gcd
N=int(input())
T=[int(input()) for _ in range(N)]
def lcm(a, b):
    return a*b//gcd(a,b)
tmp = T[0]
for t in T[1:]:
    tmp = lcm(tmp, t)
print(tmp)


Measured memory_bytes: 5048
//This code was made by Chinese_zjc_.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<map>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
int k;
string s;
signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>k>>s;
	if(k>=s.length())
	{
		cout<<s<<endl;
	}
	else
	{
		for(int i=0;i<k;++i)
		{
			cout<<s[i];
		}
		cout<<"..."<<endl;
	}
	return 0;
}


Measured memory_bytes: 3656
n=int(input())
s=input()
a=0
for i in range(1000):
    t=str(i).zfill(3)
    p=0
    for j in s:
        if j==t[p]:
            p+=1
        if p==3:
            #print(t,p)
            break
    if p==3:
        a+=1
print(a)

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

using namespace std;

int main()
{
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2 ;
  
    int dx = x2 - x1 ;
    int dy = y2 - y1 ;

    for(int i=0;i<2;i++){
     swap(dx,dy) ;
     dx = -dx ;
     x2 += dx ;
     y2 += dy ;
     cout << x2 << ' ' << y2 << endl;
    }
    
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int h, w;
	cin >> h >> w;
	int dp[h][w];
	for( int i = 0; i < h; ++i ){
		for( int j = 0; j < w; ++j ){
			char tmp; cin >> tmp;
			if( tmp == '.' ){
				if( i == 0 && j == 0 ){
					dp[i][j] = 1;
				} else if ( i == 0 ) {
					dp[i][j] = dp[i][j-1];
				} else if ( j == 0 ) {
					dp[i][j] = dp[i-1][j];
				} else {
					dp[i][j] = dp[i-1][j] + dp[i][j-1];
					dp[i][j] %= MOD;
				}
			} else {
				dp[i][j] = 0;
			}
		}
	}
	cout << dp[h-1][w-1] << endl;
	return 0;
}

Measured memory_bytes: 4096
#include <stdio.h>

int main()
{
  int A, B;
  int K;
  int i;
  scanf("%d", &K);
  scanf("%d %d", &A, &B);
  
  for(i = A; i <= B; ++i){
    if(i % K == 0){
      printf("OK\n");
      return 0;
    }
  }
  printf("NG\n");
}

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

using namespace std;


int main()
{
    int n;
    while(scanf("%d",&n)!=EOF){
        int flag=0;
        for(int i=0;i<=25;i++){
            for(int j=0;j<=100/7;j++){
                if(i==0&&j==0)continue;
                if(4*i+j*7==n){
                    flag=1;
                    break;
                }
            }
        }
        if(flag==0){
            printf("No\n");
        }
        else{
            printf("Yes\n");
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
// -----------------<fast IO>------------------
#define IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FLSH             fflush(stdout)
#define fileIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);
#define PRECISION(x)     cout << fixed << setprecision(x);
// -----------------<TypeDef Start>------------------
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
// -----------------<Constants>------------------
const int MAXN = 1000005;
const int SQRTN = 1003;
const int LOGN = 22;
const double PI=acos(-1);

const int INF=1e9;

int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;
ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}
ll lcm(ll a,ll b)
{
    return(a/gcd(a,b)*b);
}
/*ll gcdExtended(ll a,ll b,ll *x,ll *y)
{
    if(a==0)
    {
        *x=0,*y=1;
        return(b);
    }
    ll x1,y1;
    ll gcd=gcdExtended(b%a,a,&x1,&y1);
    *x=y1-(b/a)*x1;
    *y=x1;
    return(gcd);
}*/
ll power(ll a,ll b,ll p)
{
    ll res=1;
    a%=p;
    while(b>0)
    {
        if(b&1)
        res=res*a%p;
        a=a*a%p;
        b>>=1;
    }
    return(res);
}
/*ll modInverse(ll a, ll m)
{
    ll x,y;
    ll g = gcdExtended(a, m,&x,&y);
    return((x%m+m)%m);
}*/
/*long combi(int n,int k)
{
    long ans=1;
    k=k>n-k?n-k:k;
    int j=1;
    for(;j<=k;j++,n--)
    {
        if(n%j==0)
        {
            ans*=n/j;
        }else
        if(ans%j==0)
        {
            ans=ans/j*n;
        }else
        {
            ans=(ans*n)/j;
        }
    }
    return ans;
}*/
/*struct cmp{
    bool operator()(const pair<ll,ll>&a,const pair<ll,ll>&b)
    const{
        int lena=a.second-a.first+1;
        int lenb=b.second-b.first+1;
        if(lena==lenb) return a.first<b.first;
        return lena>lenb;
    }
};*/
void solve()
{
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll l=0,r=n-1;
    ll ans=0;
    while(l<r)
    {
        if(s[l]=='W' && s[r]=='R')
        {
            ans++;
            swap(s[l],s[r]);
            l++;
            r--;
        }
        else if(s[l]=='R')
            l++;
        else if(s[r]=='W')
            r--;
    }
    if(l==r && s[l]=='W')
    {
        for(ll i=l;i<n;i++)
        {
            if(s[i]=='R')
                ans++;
        }
    }
    cout<<ans<<endl;
}

int main()
{
    IOS
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return(0);
}


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

int main() {
    int n;
    int d1, d2;
    
    cin >> n;
    int count = 0;
    rep(i, n){
        cin >> d1 >> d2;
        if(d1 == d2){
            count++;
        }
        else{
            count = 0;
        }

        if(count == 3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;
    return 0;
}
 
 //vector<int> a(3);
 //a.at(0);
 //a.size();
 //vector<vector<int>> a(3, vector<int>(3));
 //uint64_t sum = 0;
 //max(a, b);
 //min(a, b);
 //swap(a, b);
 //sort(vec.begin(), vec.end());  昇順
 //reverse(vec.begin(), vec.end());  降順


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
using namespace std;

int main()
{
	int n, ans = 1;
	cin >> n;
	while (ans <= n) {
		ans *= 2;
	}
	cout << ans / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("YES\n")
#define ptn printf("NO\n")
//==========================Code here==========================
LL n, a[200000 + 5], suf[200000 + 5];
int main() {
	cin >> n;
	for (LL i = 1; i <= n; ++i) scanf("%lld", &a[i]);
	for (LL i = n; i >= 0; --i) suf[i] = max(suf[i + 1], a[i]);
	for (LL pre = 0, i = 1; i <= n; ++i) {
		printf("%lld\n", max(pre, suf[i + 1]));
		pre = max(pre, a[i]);
	}
	return 0;
}

Measured memory_bytes: 4736
use std::io;

fn main() {
    let mut s = String::new();

    io::stdin().read_line(&mut s).expect("Faled to read line");

    let numbers: Vec<i32> = s
        .split(' ')
        .map(|s| s.trim())
        .filter(|s| !s.is_empty())
        .map(|s| s.parse().unwrap())
        .collect();

    let a = numbers[0];
    let b = numbers[1];
    let c = numbers[2];

    if (a < c && c < b) || (a > c && c > b) {
        println!("Yes")
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

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

    char c;
    for(int i=0; i<N; i++) {
        cin >> c;
        if (c == 'Y') {
            cout << "Four" << endl;
            return 0;
        }
    }

    cout << "Three" << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
  n = int(input())
  #s = input()
  #s = input().split("/")
  #a = list(map(int,input().split("")))
  #a = [input() for i in range(n)]
  #a = [int(input()) for i in range(n)]
  a = [input().split() for i in range(n)]
  #a = [list(map(int,input().split())) for i in range(n)]
  ans = 0
  count = 0
  lis = []
  
  for i in range(n):
    if a[i][1] == "JPY":
      ans += int(a[i][0])
    else:
      ans += 380000*float(a[i][0])
  print(ans)
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
# include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long int ans,k,a,b; cin >> k >> a >> b;
 
  if(k-(a-1) <= 0) { cout << k+1 << endl; return 0; }
 
  if(b-a >= 2) {
    ans = a;
    ans += (b-a)*((k-(a-1))/2);
    ans += (k-(a-1)) %2;
  } else {
    ans = k+1;
  }
 
  cout << ans << endl;
  return 0;
}

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

void solve(long long N, std::vector<long long> A) {
    vector<long long> tmp(N);
    for (long long i = 0; i < N - 1; i++) {
        tmp[A[i] - 1]++;
    }
    for (long long i = 0; i < N; i++) {
        cout << tmp[i] << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can
// remove this line by using your custom template)
int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N - 2 + 1);
    for (int i = 0; i < N - 2 + 1; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 6452
line = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k = int(input())

print(line[k - 1])

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) {

		int[] NumList = new int[3];

		int Result = 0;


		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

			while (true) {
				//??\??????????????????
				String line = br.readLine();

				if (line != null) {
					//???????????????????????????
					String[] InputList = line.split(" ", 0);

					//?????????????????´??°???Int???
					for (int i = 0; i < InputList.length; i++) {
						NumList[i] = Integer.parseInt(InputList[i]);
					}

					//????????????????????§??????
					if(!Arrays.asList(NumList[0]).contains(-1) || !Arrays.asList(NumList[1]).contains(-1)){

						//???????????£??\
						Result = NumList[0] + NumList[1];

						//????¨?????????????????????????
						if (!Arrays.asList(NumList[0]).contains(-1) && !Arrays.asList(NumList[1]).contains(-1)) {

							//??????A????????¶
							if(Result >= 80){
								System.out.println("A");
							}
							//??????B????????¶
							else if (Result >= 65) {
								System.out.println("B");
							}
							//??????C????????¶
							else if (Result >= 50) {
								System.out.println("C");
							}
							//??????D????????¶
							else if (Result >= 30) {
								if (NumList[2] >= 50) {
									System.out.println("C");
								}else {
									System.out.println("D");
								}
							}
							else {
								System.out.println("F");
							}
						}
						else{
							System.out.println("F");
						}
					}else{
						break;
					}
				}else {
					break;
				}
			}

		}catch (NumberFormatException e) {
			System.out.println(e);
		}catch (IOException e) {
			System.out.println(e);
		}


	}

}

Measured memory_bytes: 24200
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
// #define INF 9e+18

/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

bool _mysort(ll a, ll b) { return abs(a) > abs(b); }

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cini(N);
    vector<long long> a(N);
    int minus_count = 0;
    rep(i, N){ cin >> a[i]; if(a[i]<0)minus_count++;}
    sort(All(a),_mysort);
    long long sum = 0;
    if(minus_count%2==0){
        rep(i,N) sum += abs(a[i]);
    }else{
        rep(i,N) sum += abs(a[i]);
        sum -= 2*abs(a.back());
    }
    cout << sum << nn;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    string s; cin >> s;
    int q; cin >> q;
    int k_[q];
    rep(i,q)cin >> k_[i];
    rep(ite,q){
        ll ans = 0;
        int k = k_[ite];

        ll d = 0;
        ll m = 0;
        ll sum = 0;

        int now = n-1;
        int now2 = n;
        while(true){
            while(s[now] != 'C'){

                if(now2<=now && s[now] == 'D'){
                    d--;
                }

                if(now2<=now && s[now] == 'M'){
                    sum -= d;
                    m--;
                }

                now--;
                if(now<2)break;
            }
            if(now<2)break;

            ans += sum;

            if(now < now2){
                now2 = now;    
            }
            
            for(; max(0,now-k+1) <= now2; now2--){
                if(s[now2] == 'D'){
                    ans += m;
                    sum += m;
                    d++;
                }
                if(s[now2] == 'M'){
                    m++;
                }
            }
            now--;

        }


        cout << ans << endl;
    }

   

    return 0;
}
 
 


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

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}
const ll P =  1000000007;
ll factorial(ll n){
   ll ans = 1;
   for(int i = n;i>=1;i--){
     ans *= i;
     ans %= P;
   }
   return ans;
}
using Graph = vector<vector<int>>;

ll kzyou(ll a,ll k){//aのk乗を返す
    ll zyou = 1;
    for(ll i = 1;i<=k;i++){
        zyou *= a;
    }
    return zyou;
}

int main(){
  //体力の大きいものから順にK匹は必殺技で倒す　残りは通常攻撃
  ll N,K;
  cin >> N >> K;
  vector<ll> H(N);
  rep(i,N){
    cin >> H[i];
  }
  sort(H.begin(),H.end());
  reverse(H.begin(),H.end());

  ll ans = 0;
  for(int i = K;i<N;i++){
    ans += H[i];
  }
  cout << ans << endl;
 }

Measured memory_bytes: 1792
object Main extends App {
  import scala.io.StdIn._
  val mod = 1000000007L
  val n = readLine.trim.toInt
  val planets: Array[Planet] = readLine.trim.toCharArray.zip(readLine.trim.toCharArray).map{case (f, t) ⇒ new Planet(f, t)}
  val pattern = Array.tabulate(26){_ ⇒ 0L}.also(a ⇒ a(planets(0).in.toIndex) = 1)
  for (i ← 1 until planets.length - 1){
    pattern(planets(i).in.toIndex) = (pattern(planets(i).out.toIndex) + pattern(planets(i).in.toIndex)) % mod
  }
  println(pattern(planets(n - 1).out.toIndex))
  class Planet(val in: Char, val out: Char)
  implicit class CharToInt(val value: Char){
    def toIndex: Int = value - 'a'
  }
  implicit class ScopedFunc[T](val value: T){
    def let[A](func: T ⇒ A): A = func(value)
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
  }
}
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0386


Measured memory_bytes: 53792
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	for {
		h, w := nextInt(), nextInt()
		if h == 0 && w == 0 {
			break
		}
		for i := 0; i < h; i++ {
			for j := 0; j < w; j++ {
				if i == 0 || i == h-1 {
					fmt.Fprintf(out, "#")
				} else {
					if j == 0 || j == w-1 {
						fmt.Fprintf(out, "#")
					} else {
						fmt.Fprintf(out, ".")
					}
				}
			}
			fmt.Fprintf(out, "\n")
		}
		fmt.Fprintf(out, "\n")
	}
}

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}



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

int main(){
  int a,b;
  cin >> a;
  cin >> b;
  
  int xi;
  xi = (a + b)/2;
  
  double ad,bd;
  ad = a;
  bd = b;
  
  double xd;
  xd = (ad + bd)/2.0;
  //xd = 5.5
  double xid;
  xid = xi;
  
  double xdd;
  xdd = xd + (xd - xi);
  
  int x;
  x = xdd;
  
  cout << x << endl; 
}

Measured memory_bytes: 256
import           Data.List
import           Control.Monad.State

sort' :: Ord a => [a] -> State Int [a]
sort' [] = return []
sort' xs = do
  res <- bubleAll xs
  case res of
    (y : ys) -> do
      l <- sort' ys
      return $ y : l
    [] -> return []

bubleAll :: Ord a => [a] -> State Int [a]
bubleAll [] = return []
bubleAll xs =
  foldr (\o acc -> acc >>= buble o) (return xs) [1 .. (length xs - 1)]

buble :: Ord a => Int -> [a] -> State Int [a]
buble n xs
  | x1 <= x2 = return xs
  | otherwise = do
    modify (+ 1)
    return $ h ++ [x2] ++ [x1] ++ t
 where
  x1 = last $ take n xs
  x2 = head $ drop n xs
  h  = take (n - 1) xs
  t  = drop (n + 1) xs

main = do
  n <- readLn
  l <- getLine
  let (rs, cnt) =
        runState (sort' $ take n $ map (read :: String -> Int) (words l)) 0
  putStrLn $ unwords (map show rs)
  print cnt


Measured memory_bytes: 5368
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[][] s = new String[n][2];
		int[] c = new int[n];
		for (int i = 0; i < n; i++) {
			s[i][0] = sc.next();
			s[i][1] = new StringBuilder(s[i][0]).reverse().toString();
			c[i] = sc.nextInt();
		}
		sc.close();

		long ans = Long.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			long[][][] d = new long[n][2][21];
			for (int i2 = 0; i2 < n; i2++) {
				for (int j2 = 0; j2 < 2; j2++) {
					Arrays.fill(d[i2][j2], Long.MAX_VALUE);
				}
			}
			d[i][0][0] = c[i];
			PriorityQueue<Node> que = new PriorityQueue<>();
			que.add(new Node(i, 0, 0, c[i]));
			while (!que.isEmpty()) {
				Node cur = que.poll();
				String str = s[cur.i][cur.j].substring(cur.idx);
				if (isKaibun(str)) {
					ans = Math.min(ans, cur.d);
					break;
				}
				if (cur.d > d[cur.i][cur.j][cur.idx]) {
					continue;
				}
				int j2 = 1 - cur.j;
				for (int i2 = 0; i2 < n; i2++) {
					int ni = -1;
					int nj = -1;
					int nidx = -1;
					if (s[i2][j2].startsWith(str)) {
						ni = i2;
						nj = j2;
						nidx = str.length();
					}
					if (str.startsWith(s[i2][j2])) {
						ni = cur.i;
						nj = cur.j;
						nidx = cur.idx + s[i2][j2].length();
					}
					if (ni != -1) {
						long alt = cur.d + c[i2];
						if (alt < d[ni][nj][nidx]) {
							d[ni][nj][nidx] = alt;
							que.add(new Node(ni, nj, nidx, alt));
						}
					}
				}
			}
		}
		if (ans == Long.MAX_VALUE) {
			System.out.println(-1);
		} else {
			System.out.println(ans);
		}
	}

	static boolean isKaibun(String str) {
		char[] ss = str.toCharArray();
		for (int j = 0; j < ss.length; j++) {
			if (ss[j] != ss[ss.length - 1 - j]) {
				return false;
			}
		}
		return true;
	}

	static class Node implements Comparable<Node> {
		int i, j, idx;
		long d;

		public Node(int i, int j, int idx, long d) {
			this.i = i;
			this.j = j;
			this.idx = idx;
			this.d = d;
		}

		public int compareTo(Node o) {
			return Long.compare(d, o.d);
		}
	}
}


Measured memory_bytes: 37160
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.solveD();
	}

	private void solveD() {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int N = sc.nextInt();

		int[][] map = new int[H][];
		for (int h = 0; h < H; h++) {
			map[h] = new int[W];
		}
		int vx = 1;
		int ch = 0;
		int cw = 0;
		for (int c = 1; c <= N; c++) {
			int a = sc.nextInt();
			for (int j = 0; j < a; j++) {
				map[ch][cw] = c;
				cw += vx;
				if (cw == W) {
					ch++;
					cw = W - 1;
					vx = -1;
				}
				if (cw == -1) {
					ch++;
					cw = 0;
					vx = 1;
				}
			}
		}
		for (int h = 0; h < H; h++) {
			System.out.print(map[h][0]);
			for (int w = 1; w < W; w++) {
				System.out.print(" " + map[h][w]);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 34692
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

//#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){
    int L,R,d;
    cin>>d>>L>>R;

    int c=0;
    for(int i=L;i<=R;i++){
        if(i%d==0) c++;
    }

    if(c>0) cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
}


Measured memory_bytes: 3628
data = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
  
n = int(input())
  
for _ in range(n):
    (b,f,r,v) = [int(i) for i in input().split()]
    data[b - 1][f - 1][r - 1] += v
  
for b in range(4):
    for f in range(3):
        for r in range(10):
            print('',data[b][f][r], end='')
        print()
    if b < 3:
        print('#' * 20)

Measured memory_bytes: 7684
n, m = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)
i = [true] * n

m.times do
  a, b = gets.split.map { |_| _.to_i - 1 }
  i[a] = false if h[a] <= h[b]
  i[b] = false if h[a] >= h[b]
end

p i.count(true)


Measured memory_bytes: 22508
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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; }


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

    int a = x / 100, b = x % 100;
    if(5*a >= b) cout << 1 << ln;
    else cout << 0 << ln;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define FOR(i, first, last) for (int i = (first); i < (last); ++i)
#define REP(i, n) FOR(i, 0, n)
#define CLR(a) memset((a), 0, sizeof(a))
#define DUMP(x) std::cerr << #x << " = " << (x) << std::endl;
#define DUMPR(v) REP(_i,v.size()){std::cerr<< #v << "[" << _i << "] = " << (v[_i]) << std::endl;}
#define CIN_VEC(v,N) {v.clear(); v.reserve(N); REP(i,N){typename decltype(v)::value_type x; cin>>x; v.emplace_back(x);}};

inline int to_int(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string to_string(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

typedef unsigned long long ull;
typedef unsigned long ul;

const static int NMAX = 3000;
int dp[NMAX+1][NMAX+1];

int main() {
  string s, t;
  cin>>s>>t;
  memset(dp, 0, sizeof(dp));

  // dp to find LCS
  for(int i=0; i<s.size(); i++) {
    for(int j=0; j<t.size();j++) {
      if(s[i] == t[j]) {
        dp[i+1][j+1] = dp[i][j] + 1;
      }
      else
        dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
    }
  }

  // find string
  string ans;
  int x = s.size();
  int y = t.size();
  while(x > 0 && y > 0) {
    if(dp[x][y] == dp[x-1][y])
      x--;
    else if(dp[x][y] == dp[x][y-1])
      y--;
    else {
      x--; y--;
      ans.push_back(s[x]);
    }
  }
  // REP(i,s.size()+1){
  //   REP(j,t.size()+1) {
  //     printf(" %3d", dp[i][j]);
  //   }
  //   cout<<endl;
  // }
  // cout<<dp[s.size()][t.size()] << endl;
  reverse(ans.begin(), ans.end());
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 35456
local function getprimes(x)
  local primes = {}
  local allnums = {}
  for i = 1, x do allnums[i] = true end
  for i = 2, x do
    if allnums[i] then
      table.insert(primes, i)
      local lim = x // i
      for j = 2, lim do
        allnums[j * i] = false
      end
    end
  end
  allnums[1] = false
  return allnums
end

local isprimes = getprimes(100000)
local cnt = {0, 0}
for i = 3, 100000, 2 do
  if isprimes[i] and isprimes[(i + 1) // 2] then
    cnt[i] = cnt[i - 1] + 1
  else
    cnt[i] = cnt[i - 1]
  end
  cnt[i + 1] = cnt[i]
end
local q = io.read("*n")
for iq = 1, q do
  local l, r = io.read("*n", "*n")
  local z = cnt[r]
  if 1 < l then
    z = z - cnt[l - 1]
  end
  print(z)
end


Measured memory_bytes: 6472
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N;
  cin >> N;

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  sort(ALL(A));

  int sum = 0;
  vector<bool> vec(N, false);
  vec[N-1] = true;
  REP(i, N-1){
    sum += A[i];
    if(A[i+1] <= sum*2) vec[i] = true;
  }

  int ans = 0;
  RREP(i, N){
    if(vec[i] == false) break;
    ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,j,k) for (int i = j; i <= k; i++)
#define dow(i,j,k) for (int i = j; i >= k; i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
typedef pair<int, int> pi;
typedef long long ll;
int n;
ll a[20];
long long ans;
ll find(int l, int xl, int r, int xr) {
	if (l + 1 == r) return 0;
	long long res = 1e18;
	for (int i = l + 1; i < r; i++) 
		res = min(res, find(l, xl, i, xl + xr) + find(i, xl + xr, r, xr) + a[i] * (xl + xr));
	return res;
}
		
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	cout << find(1, 1, n, 1) + a[1] + a[n] << endl;
}

Measured memory_bytes: 256
x,y = map(int, input().split())
li = []

if x <= y:
    li.append(y-x)
if -x <= y:
    li.append(1+x+y)
if x <= -y:
    li.append(1-y-x)
if -x <= -y:
    li.append(2+x-y)
print(min(li))

Measured memory_bytes: 3060