akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s;
    int k;
    cin >> s >> k;
    int n = sz(s);

    vector<vector<vector<ll>>> dp(n + 1, vector<vector<ll>>(k + 1, vector<ll>(2)));
    dp[0][0][0] = 1;

    REP(i, n) REP(j, k + 1) {
        int nd = s[i] - '0';
        REP(d, 10) {
            // use non-zero
            if (d != 0 and j < k) {
                dp[i + 1][j + 1][1] += dp[i][j][1];
                // border
                if (d == nd) dp[i + 1][j + 1][0] += dp[i][j][0];
                // under
                if (d < nd) dp[i + 1][j + 1][1] += dp[i][j][0];
            }
            // use zero
            if (d == 0) {
                dp[i + 1][j][1] += dp[i][j][1];
                // border
                if (d == nd) dp[i + 1][j][0] += dp[i][j][0];
                // under
                if (d < nd) dp[i + 1][j][1] += dp[i][j][0];
            }
        }
    }
    // REP(i, n + 1) {
    //     cout << i << ": " << endl;
    //     printvv(dp[i]);
    // }
    cout << dp[n][k][0] + dp[n][k][1] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>

using namespace std;
int main()
{
    char a[2][3];
    for(int i=0; i<2; ++i)
    {
        for(int j=0; j<3; ++j)
            scanf("%c",&a[i][j]);
        getchar();


    }
    if(a[0][1]==a[1][1]&&a[0][0]==a[1][2]&&a[0][2]==a[1][0])
    {
        printf("YES\n");
        //printf("This grid remains the same when rotated 180 degrees");
    }
    else
    {
        printf("NO\n");
        //printf("This grid does not remain the same when rotated 180 degrees.\n");
    }
    return 0;
}


Measured memory_bytes: 256
<?php

// define('DEBUG', true);
define('DEBUG', false);

// define('MOD', 1000000007);

fscanf(STDIN, "%d", $N);
$a = explode(" ", trim(fgets(STDIN)));

$kai = 0;
$prev = false;

for ($i = 0; $i < $N; $i++) {
    if ($i + 1 == $a[$i]) {
    	$b[$i] = 1;
    } else {
    	$b[$i] = 0;
    }
}

// echo implode(" ", $b) . PHP_EOL;

for ($i = 0; $i < $N; $i++) {
	switch ($b[$i]) {
		case 1:
			if ($b[$i+1] == 0 || $b[$i+1] == 1 || $i + 1 == $N) {
				$kai++;
				$i++;
			}
		case 0:
			break;
	}
}

echo $kai . PHP_EOL;


Measured memory_bytes: 19060
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)

	count := 0
	for i := 1; i <= n; i++ {
		if len(strconv.Itoa(i))%2 == 1 {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
vector<ll> divisor(ll n){
    vector<ll> div;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            if(i!=1) div.push_back(i);
            if(i*i!=n) div.push_back(n/i);
        }
    }
    return div;
}
void Main(){
    ll n;cin>>n;
    vector<ll> v1=divisor(n);
    vector<ll> v2=divisor(n-1);
    ans+=v2.size();
    for(auto i:v1){
        ll n2=n;
        while(n2%i==0) n2/=i;
        if(n2%i==1) ans++;
    }
    cout<<ans<<endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

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

int main(void){
  int K;
  cin >> K;
  string str = "ACL";
  string ans = "";
  for(int i=0;i<K;i++){
    ans = ans + str;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3552
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include<math.h>
int main()
{
	int n,flag=1;
	int a[10001];
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < n; i++)
	{
		if (a[i] % 2 == 0)
		{
			if (!(a[i] % 3 == 0 || a[i] % 5 == 0))
			{
				flag = 0; break;
			}
		}
	}
	if (flag)printf("APPROVED");
	else printf("DENIED");
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <regex>
#include <cmath>
#include <vector>
#include <queue>
#include <functional>
#include <numeric>
#include <iomanip>
#include <stack>
#include <string>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

int main () {
    ll n, k;
    cin >> n >> k;
    cout << n - k + 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define int long long
using namespace std;
signed main() {
    string s;
    cin>>s;
    if(s=="AAA"||s=="BBB") cout<<"No";
    else cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define MAX_V 10000
#define MAX_E 100000
 
using namespace std;
 
struct edge{
  int from,to,cost;
  edge(int f = -1,int t = -1,int c = -1) : from(f) ,to(t) ,cost(c) {}
};
 
int V,E;
int par[MAX_V],rank[MAX_V];
edge es[MAX_E];
 
bool cmp(const edge &e1,const edge &e2){
  return e1.cost < e2.cost;
}
 
void init(int n){
  for(int i = 0 ; i < n ; i++){
    par[i] = i;
    rank[i] = 0;
  }
}
 
int find(int x){
  if(par[x] == x) return x;
  return par[x] = find(par[x]);
}
 
void unite(int x,int y){
  x = find(x);
  y = find(y);
 
  if(x == y) return;
  if(rank[x] < rank[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(rank[x] == rank[y]) rank[x]++;
  }
}
 
bool same(int x,int y){
  return find(x) == find(y);
}
 
int kruskal(){
  sort(es, es+E, cmp);
  init(V);
 
  int res = 0;
  for(int i = 0 ; i < E ; i++){
    edge e = es[i];
    if(!same(e.from,e.to)){
      unite(e.from,e.to);
      res += e.cost;
    }
  }
 
  return res;
}
 
int main(){
  cin >> V >> E;
  for(int i = 0 ; i < E ; i++){
    cin >> es[i].from >> es[i].to >> es[i].cost;
  }
  cout << kruskal() << endl;
 
  return 0;
}


Measured memory_bytes: 4340
import math
a,b,h,m= list(map(int,input().split()))
x = h*60 + m #分

theta_s = 0.5*x
theta_s = theta_s % 360
theta_l = 6.0*x
theta_l = theta_l % 360
theta_mean = abs(theta_l-theta_s)

if theta_mean > 180:
    theta_mean = 360 - theta_mean
c2 = a**2 + b**2 - 2*a*b*math.cos(theta_mean*math.pi/180) 
c = math.sqrt(c2)
print(c)

Measured memory_bytes: 9504
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int n;
    cin>>n;
    vector<long long int> v(n);
    REP(i,n){
        cin>>v[i];
    }

    FOR(i,1,n){
        v[i]+=v[i-1];
    }
    /*
    REP(i,n){
        cout << v[i] << endl;
    }*/
    long long int result=linf;
    FOR(i,1,n){
        result=min(result,abs((v[n-1]-v[i-1])-(v[i-1])));
       // cout << result << endl;
    }
    cout<<result<<endl;

    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main() {

    int n, p;
    scanf("%d", &n);

    int mysum = 0;
    int maxdata = 0;

    for (int i = 0; i < n; i++) {
        scanf("%d", &p);
        mysum += p;
        if (maxdata < p) {
            maxdata = p;
        }
    }

    mysum -= maxdata / 2;

    printf("%d", mysum);

    return 0;
} 

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

typedef struct node{
  struct node *next;
  int value;
}Node;

Node *head = NULL;

int pop(){
  if( head == NULL)
    exit( 1 );
  Node *tmp = head;
  int value = tmp -> value;
  head = head -> next;
  free( tmp );
  return value;
}

void push( int value ){
  Node *node = ( Node * )malloc( sizeof( Node ) );
  node -> next = head;
  node -> value = value;
  head = node;
}

int main( void ){
  int ch, n = 0, state = 0;
  while( ( ch = getchar() ) != '\n' && ch != EOF ){
    if( ch == ' ' ){
      if( state == 1 ){
        push( n );
      }
      state = 0;
    }
    else if( ch == '*' ){
      push( pop() * pop() );
      state = 0;
    }
    else if( ch == '+' ){
      push( pop() + pop() );
      state = 0;
    }
    else if( ch == '-' ){
      int i = pop(), j = pop();
      push( j - i );
      state = 0;
    }
    else if( '0' <= ch && ch <= '9' ){
      int i = ch & 0xF;
      if( state == 1 )n = n * 10 + i;
      else n = i;
      state = 1;
    }
    else exit(1);
  }
  printf("%d\n", pop() );
  return 0;
}



Measured memory_bytes: 2068
#include <bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp> 

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

int main(void){
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for(int i = 0 ; i < n ; i++){
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int ans = 0;
	for(int i = 0 ; i < k ; i++){
		ans += a[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 3624
use std::collections::hash_map::HashMap;

fn main() {
    let s = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let s = buf.trim_end().to_owned();
        s
    };

    let mut c_map: HashMap<char, Vec<u32>> = HashMap::new();
    for i in 0..26 {
        let c = std::char::from_u32('a' as u32 + i).unwrap();
        c_map.insert(c, vec![]);
    }

    for (i, c) in s.chars().enumerate() {
        c_map.get_mut(&c).unwrap().push(i as u32);
    }
    for i in 0..26 {
        let c = std::char::from_u32('a' as u32 + i).unwrap();
        let cv = c_map.get(&c).unwrap();
        if cv.len() < 2 {
            continue;
        }
        for j in 0..cv.len() - 1 {
            if cv[j + 1] - cv[j] <= 2 {
                println!("{} {}", cv[j] + 1, cv[j + 1] + 1);
                return;
            }
        }
    }
    println!("{} {}", -1, -1);
}


Measured memory_bytes: 2736
main :: IO ()
main = do
    n <- readLn
    putStrLn $ solve n

solve :: Int -> String
solve n = case solve' n of
    [] -> "0"
    _  -> reverse $ solve' n

solve' :: Int -> String
solve' 0 = []
solve' n
    | odd n  = '1' : solve' (-n `div` 2)
    | even n = '0' : solve' (-n `div` 2)

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
int n,m;
vector<int>v[10000];
vector<bool>vis(10000);
stack<int>order;
void dfs(int u){
	vis[u]=1;
	for(auto i:v[u]){
		if(!vis[i])dfs(i);
	}
	order.emplace(u);
}
int main(){
	cin>>n>>m;
	while(m--){
		int l,r;
		cin>>l>>r;
		v[l].emplace_back(r);
	}
	for(int i=0;i<n;i++){
		if(!vis[i])dfs(i);
	}
	while(!order.empty()){
		cout<<order.top()<<"\n";
		order.pop();
	}
}


Measured memory_bytes: 3800
#include<stdio.h>
int main(void)
{
    int n,i,j,a[4],b[4],c[4],w,f,flg;
	while(1){
	    f=0;
		flg=0;
	    scanf("%d",&n);
		if(n==0) break;
		while(1){
		    if(n==6174) break;
			a[0]=n/1000;
			a[1]=(n-a[0]*1000)/100;
			a[2]=(n-a[0]*1000-a[1]*100)/10;
			a[3]=n-a[0]*1000-a[1]*100-a[2]*10;
			if(a[0]==a[1]&&a[1]==a[2]&&a[2]==a[3]){
			    printf("NA\n");
				flg=1;
				break;
			}
			for(i=0;i<3;i++){
			    for(j=i;j<4;j++){
				    if(a[i]<a[j]){
					    w=a[i];
						a[i]=a[j];
						a[j]=w;
					}
				}
			}
			for(i=0;i<4;i++) b[i]=a[i];
			for(i=0;i<3;i++){
			    for(j=i;j<4;j++){
				    if(a[i]>a[j]){
					    w=a[i];
						a[i]=a[j];
						a[j]=w;
					}
				}
			}
			for(i=0;i<4;i++) c[i]=a[i];
			n=(b[0]*1000+b[1]*100+b[2]*10+b[3])-(c[0]*1000+c[1]*100+c[2]*10+c[3]);
			f++;
		}
		if(flg==0) printf("%d\n",f);
	}
	return 0;
}

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

int main() {
    string s;
    cin >> s;

    int cnt0 = 0, cnt1 = 0;

    rep(i, s.size()) {
        if (s.at(i) == '0')
            cnt0++;
        else
            cnt1++;
    }
    cout << min(cnt0, cnt1) * 2 << endl;
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
//ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

ll MOD = 998244353;

ll mod_pow(ll x, ll n, ll m) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) {
			res = res * x % m;	//最下位ビットが立っている時にx^(2^i)を掛ける
		}
		x = x * x % m;
		n >>= 1;
	}
	return res;
}


//拡張ユークリッドの互除法
//ax+by=gcd(a, b)の特殊解を計算
//返り値はgcd(a, b)
ll extgcd(ll a, ll b, ll& x, ll& y) {
	if (b == 0) {
		x = (a >= 0) ? 1 : -1;
		y = 0;
		return abs(a);
	}
	else {
		ll res = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
		return res;
	}
}


//xとmは互いに素であるとする
//法mにおけるaの逆元とはab%m=1なる唯一のb<m
//逆元（拡張ユークリッド）
//ax+my=1なる(x, y)が求まればax%m=(1-my)%m=1よりb=x
ll mod_inverse(ll a, ll m) {
	ll x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}


//順列
//nPk mod MODを返す
//f[i]はi!（階乗）mod MODを指す
const ll N = 3 * 100000;
vector<ll> f(N + 1);

ll P(ll n, ll k) {
	if (n < k) return 0;
	return (f[n] * mod_inverse(f[n - k], MOD)) % MOD;
}


//組合せ
//nCk mod MODを返す
ll C(ll n, ll k) {
	if (n < 0) return 0;
	return (P(n, k) * mod_inverse(f[k], MOD)) % MOD;
}

ll sum(ll n) {
	ll s = 0;
	if (n < 0) return 0;
	while (n > 0) {
		s += n % 10;
		n /= 10;
	}
	return s;
}

int main() {
	ll n;
	ll ans = INF;

	cin >> n;

	FOR(i, 1, n) {
		ll a = i;
		ll b = n - i;
		ll x = sum(a) + sum(b);
		if (x < ans) {
			ans = x;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  ll n;
  cin >> n;
  
  if (n % 2 == 0)
    cout << n << endl;
  else
    cout << 2 * n << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
  int64_t x;
  cin>>x;
  int64_t ans=x/11*2;
  if(x%11>0){if(x%11<=6){ans++;}
             else{ans+=2;}
  }
  cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 3532
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
struct point
{
    double x,y;
};

void koch(int n,point a,point b)
{
    if(n==0) return;
    point s,t,u;
    double th=M_PI*60.0/180.0;
    s.x=(2.0*a.x+1.0*b.x)/3.0;
    s.y=(2.0*a.y+1.0*b.y)/3.0;
    t.x=(1.0*a.x+2.0*b.x)/3.0;
    t.y=(1.0*a.y+2.0*b.y)/3.0;
    u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
    u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;

    koch(n-1,a,s);
    printf("%.8f %.8f\n",s.x,s.y);
    koch(n-1,s,u);
    printf("%.8f %.8f\n",u.x,u.y);
    koch(n-1,u,t);
    printf("%.8f %.8f\n",t.x,t.y);
    koch(n-1,t,b);
}


int main()
{
    point a,b;
    int n;
    scanf("%d",&n);
    a.x=0;
    a.y=0;
    b.x=100;
    b.y=0;
    printf("%.8f %.8f\n",a.x,a.y);
    koch(n,a,b);
    printf("%.8f %.8f\n",b.x,b.y);
    return 0;
}

Measured memory_bytes: 3196
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <random>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)


int main() {
	VI v(3);
	REP(i, 3) {
		cin >> v[i];
	}

	SORT(v);

	ANS(v[0] + v[1]);



	return 0;
}


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

int main(){
    ll l,r;
    cin>>l>>r;
    ll lm,rm;
    lm = l%2019;
    rm = r%2019;
    ll ans = -1;
    if(lm == 0 || rm == 0 || abs(l-r)>=2019)
    {
        cout<<"0"<<endl;
        return 0;
    }
    for(ll i = lm;i<=rm-1;i++)
    {
        for(ll j=lm+1;j<=rm;j++)
        {
            if(ans>(i*j)%2019 || ans == -1)
            {
                ans = (i*j)%2019;
            }
            
            if(ans == 0)
            {
                cout<<"0"<<endl;
                return 0;
            }
            
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rItr(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define Itr(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define setp(n) fixed << setprecision(n)
#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>
#define All(a) (a.begin()),(a.end())
#define rAll(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m,c;
	cin>>n>>m>>c;
	vll b(m);
	rep(i,m) cin>>b[i];
	ll ans=0;
	rep(i,n){
		ll sum=0;
		rep(j,m){
			ll a; cin>>a;
			sum+=b[j]*a;
		}
		if (sum+c>0) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
local N = io.read("*number")
local M = io.read("*number")
local X = io.read("*number")
local Y = io.read("*number")

local tb1 = {}
for i=1, N do
	tb1[i] = io.read("*number")
end
table.sort(tb1)
local tb2 = {}
for i=1, M do
	tb2[i] = io.read("*number")
end
table.sort(tb2)

local function check()
	local x = tb1[#tb1]
	local y = tb2[1]
	local n = y - x
	if n < 0 then return false end
	for i=1, n do
		local Z = x + n
		if Z > X and Z <= Y then return true end
	end
	return false
end
local result = check() and "No War" or "War"

print(result)

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

using namespace std;
//vector<long long> factors;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)
double pi = 3.14159265358;


ll mod(ll a, ll m) { return (a + (abs(a) / m) * m + m) % m; }

//****************************don't use int!!!!!!!****************************//
//***************************code starts here!!!!!****************************//

struct node {
    bool check = false;
    vector<ll> childs;
};

vector<node> graph;

ll bfs(ll start) {
    unordered_set<ll> q;
    q.insert(start);
    unordered_set<ll> past;
    ll par = -1;
    ll ans = 0;
    while (q.size()) {
        unordered_set<ll> tmp_s;
        for (auto cur_i : q) {
            graph[cur_i].check = true;
            for (auto i : graph[cur_i].childs) {
                if (past.count(i) == 0) {
                    if (graph[i].check) {
                        return -1;
                    }
                    tmp_s.insert(i);
                }
            }
        }
        past = q;
        q = tmp_s;
        ++ans;
    }
    return ans;
}

int main() {
    IOS

    ll n;
    cin >> n;

    graph.resize(n);

    for (int i = 0; i < n; ++i) {
        string st;
        cin >> st;
        for (int j = 0; j < n; ++j) {
            ll a;
            a = (st[j] == '1');
            if (a == 1) {
                graph[i].childs.push_back(j);
            }
        }
    }
    ll ans = -1;
    for (int i = 0; i < n; ++i) {
        ll res = bfs(i);
        ans = max(ans, res);
        for (int j = 0; j < n; ++j) {
            graph[j].check = false;
        }
    }
    cout << ans;

    return 0;
}

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

int main()
{
    int h, w, K;
    cin >> h >> w >> K;
    vector<string> s(h);
    rep(i, 0, h) cin >> s[i];
    int ans = 0, cnt = 0;
    rep(i, 0, 1<<h){
        vector<string> c(h);
        rep(j, 0, h) c[j] = s[j];
        rep(j, 0, h){
            if(i&1<<j){
                rep(k, 0, w){
                    c[j][k] = '+';
                }
            }
        }
        rep(j, 0, 1<<w){
            vector<string> d(h);
            rep(k, 0, h) d[k] = c[k];
            ans = 0;
            rep(k, 0, w){
                if(j&1<<k){
                    rep(l, 0, h){
                        d[l][k] = '+';
                    }
                }
            }
            //rep(jn, 0, h) cout << d[i] << endl;
            rep(jn, 0, h){
                rep(k, 0, w){
                    if(d[jn][k] == '#') ans++;
                }
            }
            if(ans == K) cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


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

using namespace std;

int main(){
    long x;
    cin>>x;
    unsigned int i = 1;
    unsigned int n = 0;
    while (x > 0) {
        x = x - i;
        i++;
        n++;
    }
    cout << n <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS

    int n; cin >> n;
    auto nc2 = [](ll n){return n * (n-1) / 2;};

    ll ok = n, ng = 1;
    while(abs(ok-ng) > 1) {
        ll mid = (ok+ng) / 2;
        if (nc2(mid+1) >= n) ok = mid;
        else ng = mid;
    }

    int cnt = 0;
    for(int i = ok; i > 0; i--) {
        if (cnt+i<=n) {
            cout << i << '\n';
            cnt += i;
        }
    }

    return 0;
}

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

int main(){
  // 入力
  long int X;
  cin >> X;
  
  int A, B;
  for (int i=-118; i<=119; i++) { 
    for (int j=-118; j<=119; j++) { 
      A = i;
      B = j;
      if (pow(A, 5) - pow(B, 5) == X) {
        break;
      }
    }
    if (pow(A, 5) - pow(B, 5) == X) {
      break;
    }
  }
  // cout << pow(2, 5) - pow(-1, 5) << endl;
  cout << A << " " << B << endl;
  return 0;
}

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

const int INF = (int)(1e+9);

int H, N;
vector<int> A, B;
vector<int> dp;

void input_init(void) {
	cin >> H >> N;
	A.resize(N);
	B.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> A[i] >> B[i];
}

int solve(void) {
	dp.resize(H + 1, INF);
	dp[0] = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < H; ++j) {
			int p = j + A[i];
			if (p > H)
				p = H;
			dp[p] = min(dp[j] + B[i], dp[p]);
		}
	}
	return dp[H];
}

int main(void) {
	input_init();
	int ans = solve();
	cout << ans << '\n';
	return 0;
}


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

using namespace std;

int main(){
	bool f[4];
	memset(f, false, sizeof(f));
	int a , b;
	cin >> a >> b;
	f[a] = true;
	f[b] = true;
	for (int i = 1; i <= 3; i++){
		if (!f[i])
			printf("%d\n", i);
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lld long long int
#define ld long double
#define mod 1000000007
#define modd 998244353
#define all(v) v.begin(),v.end()
#define rep(i,a,b)	for(lld i=a;i<=b;i++)
#define repr(i,a,b) for(lld i=a;i>=b;i--)
#define ar array
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
lld n,m;
lld arr[300000];
lld dp[300000];
ar<lld,26> nex[300000];
string st;
string ans;
int main()
{
     ios;
     lld TESTS,q,a,s,b,l,r,c,k,p,h,w,d,x,y,z,xs,ys,t;
     TESTS=1;
     //cin>>TESTS;
     //memset(nex,-1,sizeof(nex));
     while(TESTS--)
     {
         cin>>st;
         n=st.size();
         ar<lld,26> cur;
         rep(i,0,25)cur[i]=-1;
         repr(i,n-1,0){
             cur[st[i]-'a']=i;
             nex[i]=cur;
         }
         dp[n]=1;
         repr(i,n-1,0){
            dp[i]=1e15;
            rep(j,0,25){
                if (nex[i][j]==-1){
                    dp[i]=1;
                    continue;
                }
                dp[i]=min(dp[i],dp[nex[i][j]+1]+1);
            }
         }
         lld i=0;
       //  cout<<dp[0]<<"\n";
         while(i<n){
            char ch='a';
            rep(j,0,25){
                if (nex[i][j]==-1){
                    ch+=j;
                    ans.pb(ch);
         //           cout<<i<<" "<<j<<"\n";
                    i=n+4;
                    break;
                }
                if (dp[nex[i][j]+1]+1==dp[i]){
                    ch+=j;
                    i=nex[i][j]+1;
           //         cout<<i<<" "<<j<<"\n";
                    ans.pb(ch);
                    break;
                }
            }
            //printf("%lld\n",i);
         }
         cout<<ans;
     }
    return 0;
}


Measured memory_bytes: 45588
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scr =new Scanner(System.in);
	
		int A = scr.nextInt();
		int B = scr.nextInt();
		int c = scr.nextInt();
		int K = scr.nextInt();
		
		int X = K-A;//A���Ƃ��āC���ƂƂ�K�v�̂��閇��
		int Y = K-X;//A�̖���
		
		int Z = X-B;//
		
		int max;
	
		if(X < 0) {
			System.out.println(K);
		}else {
			if(X-B < 0) {
				System.out.println(Y);
			}else {
				max = (Z*-1)+(Y);
				System.out.println(max);
			}
		}
		
		
	
	}
}

Measured memory_bytes: 35788
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define P 998244353 
using namespace std;
int sum,n,x,ans;
int f[2200*2200],a[2200],q[2200*2200],tail;
int add(int x){
	for(int i=tail;i>=1;i--){
		if(f[q[i]+x]==0)q[++tail]=q[i]+x,f[q[i]+x]=1;
	}
}
int main(){
	scanf("%d",&n);
	f[0]=1;
	tail=1;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++){
		x=a[i];
		add(x);
		sum+=x;
	}
	for(int i=0;i<=sum;i++)if(f[i])ans++;
	ans/=2;
	for(int i=1;i<=sum;i++){
		if(f[i])ans--;
		if(ans==0){
			printf("%d\n",i);
			return 0;
		}
	}
}

Measured memory_bytes: 24832
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <map>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

int main(){
  int N,M;
  cin>>N>>M;
  int num,ans;
  vector<int> num_1;
  num=sqrt(M);
  for(int i=1;i<=num;++i){
    if(M%i==0){
      num_1.push_back(i);
      num_1.push_back(M/i);
    }}

  sort(num_1.begin(),num_1.end(),std::greater<int>());
  ans=1;
  for(int j=0;j<num_1.size();++j){
    if(num_1[j]>=N){
      ans=M/num_1[j];
    }
    else{
      break;
    }
  }
  cout<<ans<<"\n";
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
using ll = long long;

int main() {
	ll n, m;
	cin >> n >> m;
	ll a[50], b[50], c[50], d[50];
	for (ll i = 0;i < n;i++)cin >> a[i] >> b[i];
	for (ll i = 0;i < m;i++)cin >> c[i] >> d[i];
	for (ll i = 0;i < n;i++) {
		ll mindis = abs(a[i] - c[0]) + abs(b[i] - d[0]);
		ll cp = 1;
		for (ll j = 1;j < m;j++) {
			if (mindis > abs(a[i] - c[j]) + abs(b[i] - d[j])) {
				mindis = abs(a[i] - c[j]) + abs(b[i] - d[j]);
				cp = j + 1;
			}
		}
		cout << cp << endl;
	}	
}

Measured memory_bytes: 256
function Main(input) {
    var a = input[0].split(" ").map(v=>v-0);
    if(a[0]+a[1] == 0) console.log(0);
    else console.log(~~(a[0]*(a[0]-1)/2+(a[1]*(a[1]-1)/2)));
}



Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n"));

Measured memory_bytes: 7372
N = gets.to_i
A = gets.split.map(&:to_i)
count = 0
for i in 0...N
  for j in 1..(N - i - 1)
    if A[N - j] < A[N - j - 1]
      A[N - j], A[N - j - 1] = A[N - j - 1], A[N - j]
      count += 1
    end
  end
end
puts A.join(' ')
puts count



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

int main(void)
{
    int n, B_i;
    cin >> n;
    vector<int> aVector;
    int sum = 0;

    for (int i = 0; i < n - 1; i++)
    {
        cin >> B_i;
        aVector.push_back(B_i);
    }
    for (int i = n - 2; i >= 0; i--)
    {

        if (aVector[i] > aVector[i + 1] && i != n - 2)
        {
            sum += aVector[i + 1];
        }
        else
        {
            sum += aVector[i];
        }
    }
    cout << sum + aVector[0] << endl;
}

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

int main() {
  int N; cin >> N;
  vector<int> a(N);
  rep(i, N) cin >> a[i];
  
  int ans = 0;
  rep(i, N) ans += a[i]-1;
  cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e10;
const ll MAX_N = 1010;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	if (n > k * 2) {

	}
	return fac[n] / (fac[k] * fac[n - k]);
}

ll dp[201010][2];
ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };

//long longしか使わない
//素数は1より大きい
int main() {
	ll n;
	cin >> n;
	ll ans = 1000 - n % 1000;
	if (ans == 1000) {
		cout << 0 << endl;
		return 0;
	}
	else {
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

vector<pll>v;
ll h[500005],sm[500005],b[500005];

int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m,l,r;

	cin >> n >> k;
	string s;

	cin >> s;

	i=0,n=sz(s);
	while(i<n)
	{
		j=i;
		while(j<n && s[j]==s[i])j++;
		v.pb({s[i],j-i});
		i=j;
	}

	for(i=0;i<sz(v);i++)
	{
		h[i]=v[i].ss-1;
		sm[i]=v[i].ss;
		if(i)
			h[i]+=h[i-1],sm[i]+=sm[i-1];
	}

	for(i=sz(v)-1;i>=0;i--)
	{
		b[i]=v[i].ss-1;
		if(i+1<sz(v))
			b[i]+=b[i+1];
	}

	ll mx=0;
	l=0,r=0;
	while(r<sz(v))
	{
		x=(r-l)/2+1;
		if(x>k)
			l+=2;

		y = 0;
		if(r+2<sz(v))
			y+=b[r+2];
		if(l-2>=0)
			y+=h[l-2];

		if(r+1<sz(v))
			y+=sm[r+1];
		else
			y+=sm[r];

		if(l-2>=0)
			y-=sm[l-2];

		mx=max(mx,y);
		r+=2;
	}
	l=1,r=1;
	while(r<sz(v))
	{
		x=(r-l)/2+1;
		if(x>k)
			l+=2;

		y = 0;
		if(r+2<sz(v))
			y+=b[r+2];
		if(l-2>=0)
			y+=h[l-2];

		if(r+1<sz(v))
			y+=sm[r+1];
		else
			y+=sm[r];

		if(l-2>=0)
			y-=sm[l-2];

		mx=max(mx,y);
		r+=2;
	}
	cout<<mx-1<<endl;
}

Measured memory_bytes: 7340
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


vector<ll> inv,fact,invfact;
void mod_build(int n=101010){
    fact.resize(n+1);
    inv.resize(n+1);
    invfact.resize(n+1);
    fact[0]=inv[0]=invfact[0]=1;
    inv[1]=1;
    rep(i,n){
        fact[i+1]=fact[i]*(i+1)%mod;
        if(i>0)inv[i+1]=mod-inv[mod%(i+1)]*(mod/(i+1))%mod;
        invfact[i+1]=invfact[i]*inv[i+1]%mod;
    }
}
ll perm(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return fact[n]*invfact[n-k]%mod;
}
ll comb(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return (fact[n]*invfact[n-k]%mod)*invfact[k]%mod;
}
ll powmod(ll n,ll k){
    k%=mod-1;
    if(k<0)k+=mod-1;
    ll ret=1;
    while(k){
        if(k&1)ret=ret*n%mod;
        n=n*n%mod;
        k>>=1;
    }
    return ret;
}

template<typename T>
struct SegmentTree{
private:
    int n;
    T E;
    vector<T> node;
    inline void updatef(T& x,T& y){
        x = y;
        //x += y;
        //x = max(x,y);
        //x = min(x,y);
    }
    inline T queryf(T& x,T& y){
        return (x+y)%mod;
        //return x+y;
        //return max(x,y);
        //return min(x,y);
    }

public:
    SegmentTree(int sz,T E_):E(E_){
        n=1;
        while(n<sz)n<<=1;
        node.resize(2*n-1,E);
    }

    SegmentTree(vector<T>& A,T E_):E(E_){
        int sz=A.size();
        n=1;
        while(n<sz)n<<=1;
        node.resize(2*n-1,E);
        rep(i,sz)node[i+n-1]=A[i];
        for(int i=n-2;i>=0;--i){
            node[i]=queryf(node[2*i+1], node[2*i+2]);
        }
    }
    void update(int k,T x){
        k+=n-1;
        updatef(node[k],x);
        while(k>0){
            k=(k-1)/2;
            node[k]=queryf(node[2*k+1], node[2*k+2]);
        }
    }
       //[a,b)での和を返す
    T get(int a,int b,int k=0,int l=0,int r=-1){
        if(r<0)r=n;
        if(r<=a||b<=l)return E;
        if(a<=l&&r<=b)return node[k];
        T xl=get(a,b,2*k+1,l,(l+r)/2);
        T xr=get(a,b,2*k+2,(l+r)/2,r);
        return queryf(xl, xr);
    }
};
int main(){
    int n,h,d;
    cin>>n>>h>>d;
    mod_build(1234567);
    vector<ll> dp(h+1);
    ll mul = 0;
    rep(i,n)mul+=fact[i+1];
    mul%=mod;
    dp[0]=fact[n]*powmod(mul,mod-2)%mod;
    rep(i,h){
        ll ret = dp[i];
        if(i>=d)ret += mod - dp[i-d];
        ret = ret*mul%mod;
        dp[i+1]=(dp[i]+ret)%mod;
    }
    cout<<(dp[h]-dp[h-1]+mod)%mod<<endl;
    return 0;
}

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

using namespace std;

#define MAX_N 100005

int n, y[MAX_N], dp[MAX_N];

int f_imp(int);

int f(int p)
{
	if (dp[p] == 0)
	{
		dp[p] = f_imp(p) + 1;
	}
	return dp[p] - 1;
}

int f_imp(int p)
{
	if (p >= n)
	{
		return INT_MAX/2;
	}
	if (p == n - 1)
	{
		return 0;
	}
	if (p == n - 2)
	{
		return f(p + 1) + abs(y[p] - y[p + 1]);
	}
	return min(f(p + 1) + abs(y[p] - y[p + 1]), f(p + 2) + abs(y[p] - y[p + 2]));
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", y + i);
	}
	printf("%d\n", f(0));
}


Measured memory_bytes: 3328
import scala.io.StdIn
object Main extends App {
  val x = StdIn.readLine.toInt
  val r = math.sqrt(x).toInt
  val res = if( r == 1) Seq(x) else
    (2 to r).map { i =>
      val e: Seq[Int] = for {
        j <- (2 to r)
        e = math.pow(i,j).toInt if(e <= x)
      } yield e
      e.max
    }
  val ans = res.max
  println(ans)
}

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

int main() {
	int n;
	cin >> n;
	while (n) {
		if (n % 10 == 7) {
			cout << "Yes" << endl;
			return 0;
		}
		n /= 10;
	}
	cout << "No" << endl;
	return 0;
}

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

int main() {
	int H, W;
	while (true) {
		cin >> H >> W;
		if (H == 0 && W == 0)break;
		for (int i=1;i<=H;i++) {
			for (int j=1;j<=W;j++) {
				if ((i+j)%2==0) {
					cout << '#';
				}else{
					cout << '.';
				}
			}
			cout <<endl;
		}
		cout <<endl;
	}


}

Measured memory_bytes: 1152
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		Map<Integer,String> m = new HashMap<Integer,String>();

		for(int i = 0;i < k;i++) {
			int d = sc.nextInt();
			for(int x = 0;x < d;x++) {
				int a = sc.nextInt();
				m.put(Integer.valueOf(a), "a");
			}
		}

		System.out.println(n - m.size());
	}
}

Measured memory_bytes: 46356
N = int(input())
A = [int(a) for a in input().split()]
X = [0] * 101010
for a in A:
    X[a] += 1

ma = 0
for i in range(100001):
    ma = max(ma, X[i-1] + X[i] + X[i+1])
print(ma)

Measured memory_bytes: 13964
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long 
#define ii pair<int,int>
#define iii pair<int,ii>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)/2)
#define all(x) x.begin(),x.end()
#define pw(x) (1<<(x))
#define inf 1000000005
#define MOD 998244353 
#define N 305
#define M 1000003
#define LOG 20
#define KOK 250
#define EPS 0.0000001
using namespace std;

int dp[N][N*N],dp2[N][N*N];

int mul(int x,int y) {
	
	return (ll)x*y%MOD;

}

int add(int x,int y) {

	x+=y;

	if(x>=MOD) x-=MOD;
	if(x<0) x+=MOD;

	return x;

}

int main() {

	int n;

	scanf("%d",&n);

	int ans=1;

	for(int i=0;i<n;i++) ans=mul(ans,3);

	dp[0][0]=dp2[0][0]=1;
	
	int sum=0;

	for(int i=0;i<n;i++) {

		int x;

		scanf("%d",&x);

		for(int ok=0;ok<=sum;ok++) {

			dp[i+1][ok]=add(dp[i+1][ok],mul(2,dp[i][ok]));
			dp[i+1][ok+x]=add(dp[i+1][ok+x],dp[i][ok]);

			dp2[i+1][ok]=add(dp2[i+1][ok],dp2[i][ok]);
			dp2[i+1][ok+x]=add(dp2[i+1][ok+x],dp2[i][ok]);

		}

		sum+=x;

	}

	for(int ok=(sum+1)/2;ok<=sum;ok++) {

		ans=add(ans,mul(-dp[n][ok],3));

	}

	if(sum%2==0) ans=add(ans,mul(dp2[n][sum/2],3));

	printf("%d",ans);

}

Measured memory_bytes: 219392
require("fs").readFileSync("/dev/stdin","utf8").split('\n').map(function(z){i=z.split(' ');if(i[5])console.log(x=((i[2]*i[4]-i[1]*i[5])/(i[0]*i[4]-i[1]*i[3])).toFixed(3),((i[2]-i[0]*x)/i[1]).toFixed(3))})

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

using namespace std;

int a,b;

int main(){
	scanf("%d%d", &a, &b);
	
	if(a == 1)
	a = 14;
	
	if(b == 1)
	b = 14;
	
	if(a < b)
	printf("Bob\n");
	else if(a > b)
	printf("Alice\n");
	else
	printf("Draw\n");
}


Measured memory_bytes: 256
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a=chomp(readline())
    b=chomp(readline())
    la,lb=length(a),length(b)
    if la<lb
        println("LESS")
    elseif la>lb
        println("GREATER")
    else
        ans="EQUAL"
        for i in 1:la
            if a[i]<b[i]
                ans="LESS"
                break
            elseif a[i]>b[i]
                ans="GREATER"
                break
            end
        end
        println(ans)
    end
end
main()

Measured memory_bytes: 163904
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll n;
string s;
ll dem1, dem2, dem3, dem4;
int main()
{
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> s;
        if(s == "AC")
        {
            dem1++;
        }
        else if(s == "WA")
        {
            dem2++;
        }
        else if(s == "TLE")
        {
            dem3++;
        }
        else
        {
            dem4++;
        }
    }
    cout << "AC" << " x " << dem1 << '\n';
    cout << "WA" << " x " << dem2 << '\n';
    cout << "TLE" << " x " << dem3 << '\n';
    cout << "RE" << " x " << dem4;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int main() {
	string n; cin >> n;
	string ans = "No";
  	int sz = n.size();
	for(int i = 0; i < sz; i++) {
		if(n[i] == '7') 
			ans = "Yes";
	}
	cout << ans << endl;
	return 0;	
}


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

using namespace std;

int n;

int main(){
    cin >> n;
    int mx = 0 , cnt = 0;
    for(int i = 1; i <= n; i++){
        int a , b;
        cin >> a >> b;
        if(a == b){
            cnt++;
        } else {
            cnt = 0;
        }
        mx = max(mx , cnt);
    }
    if(mx >= 3){
        puts("Yes");
    } else {
        puts("No");
    }
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	int i,j,k,n,m;
	int a[105];
	while(cin>>n)
	{
		for(i=0;i<n;i++)
			cin>>a[i];
		m=0;
		for(i=0;i<n-1;i++)
		{
			k=i;
			for(j=i+1;j<n;j++)
				if(a[j]<a[k])
					k=j;
			if(k!=i)
			{
				swap(a[k],a[i]);
				m++;
			}
		}
		for(i=0;i<n-1;i++)
			cout<<a[i]<<" ";
		cout<<a[n-1]<<endl<<m<<endl;
	}	
}


Measured memory_bytes: 3096
#include<stdio.h>

int main(){
    int i;
    int c;
    int a,b;
    
    scanf("%d %d",&a,&b);
    
    while(a!=0 || b!=0){
        c=0;
        for(i=a;i<=b;i++){
            if(i%4==0){
                if(i%100!=0){
                    printf("%d\n",i);
                    c++;
                }else if(i%400==0){
                    printf("%d\n",i);
                    c++;
                }
            }
        }
        
        if(c==0){
            printf("NA\n");
        }
        
        scanf("%d %d",&a,&b);
        if(a!=0 || b!=0){
            printf("\n");
        }
    }
    
    return 0;
}

Measured memory_bytes: 616
#include<bits/stdc++.h>
using namespace std;
string s,s1,s2;int n;
bool pal(string g)
{
	for(int i=0;i<floor(g.size()/2);i++)if(g[i]!=g[g.size()-i-1])return false;
	return true;
}
int main(){
	cin>>s;
	s1=s.substr(0,(s.size()-1)/2);
	s2=s.substr((s.size()+1)/2,(s.size()-1)/2);
	if(pal(s)&&pal(s1)&&pal(s2))cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, x, i, j, k, ct, c, a;
	cin >> n >> x;
	ct = 1;
	c = 0;
	for (i = 0; i < n; i++) {
		cin >> a;
		c += a;
		if (c <= x) ct++;
	}

	cout << ct << "\n";

	return 0;
}


Measured memory_bytes: 256
from itertools import count


def main():
    N, K = map(int, input().split())
    D_list = list(input().split())

    for c in count(N):
        c = str(c)
        for d in D_list:
            if d in c:
                break
        else:
            print(c)
            return


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() { cin.tie(nullptr); ios_base::sync_with_stdio(false); }
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

signed main()
{
  i64 x, y;
  cin >> x >> y;

  if (x % y == 0) {
    puts("-1");
  } else {
    cout << x * (y+1) << endl;
  }

  return 0;
}



Measured memory_bytes: 256