akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }

}

use std::cmp::{max, min};

fn main() {
    let n: usize = read();
    let a: Vec<i64> = read_n(n);
    let mut ans = 0;

    for (i, v1) in a.iter().enumerate() {
        for (j, v2) in a.iter().enumerate() {
            if i != j {
                ans += v1 * v2;
            }
        }
    }

    println!("{}", ans / 2)

}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define mp make_pair
#define F first
#define S second
#define B begin
#define E end
#define PB push_back
#define endl "\n"

#define FORS(i, j, k, step) for (int i=j; i<k; i+=step)
#define FOR(i, j, k) for (int i=j; i<k; i++) 
#define RFORS(i, j, k, step) for (int i=j; i>=k; i-=step)
#define RFOR(i, j, k, step) for(int i=j; i>=k; i--)
#define REP(i, k) for(int i = (0); i < (k); i++ )
#define RREP(i, k) for(int i = j; i >= (k); i-- )

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

template<typename T>
void read_vec(vector<T>& v, int n){
    T tmp;
    REP(i, n){
        cin>>tmp;
        v.push_back(tmp);
    }
}

void solve(){
	ll n;
	cin>>n;

	ll ans = 0;

	for(int a = 1; a< n; a++){
		for(int b = 1; a*b < n; b++){
			int c = n-a*b;
			if(c > 0) ans++;
		}
	}

	cout<<ans<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int TC =1;
    //cin>>TC;

    REP(tc, TC){
    	solve();
    }

}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main()
{
	IOS;
	int w, h, x, y;
	cin >> w >> h >> x >> y;
	double tot = w * h;
	tot /= 2;
	cout << tot << " ";
	if(x * 2 == w && y * 2 == h)
		cout << 1;
	else
		cout << 0;
	return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

ll gcd(ll a, ll b) {
  if (b > a) {
    swap(a, b);
  }
  ll r = a%b;
  while (r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return (a / gcd(a, b))*b;
}


ll f(ll x, ll c, ll d) {
  ll ans = x;
  ans -= x / c;
  ans -= x / d;
  ans += x / lcm(c, d);
  return ans;

}

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  
  ll ans = f(b, c, d) - f(a - 1, c, d);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <algorithm> // sort
#include <map> // pair
using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  vector<pair<long,int>> pairs(N);
  
  for(int i=0;i<N;i++){
    long A;
    int B;
    cin >> A;
    cin >> B;
    pairs[i]=make_pair(A,B);
  }
  
  sort(pairs.begin(),pairs.end());
  
  int sum=0;
  long long res=0;
  for(int i=0;sum<M;i++){
    int m=pairs[i].second;
    if(sum+m>M) m=M-sum;
    sum+=pairs[i].second;
    res+=pairs[i].first*m;
  }
  cout << res << endl;
  return 0;
}

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

int main() {
    int a[5], s=0, mx=0, ex=0;
    for(int i=0; i<5; i++) {
        cin >> a[i];
        s += a[i];
        ex += (10-a[i]%10)%10;
        mx=max(mx, (10-a[i]%10)%10);
    }
    cout << s + ex - mx << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
int n,a[200005],k,pre[200005];map<int,int> m;ll ans;
int main()
{
    scanf("%d%d",&n,&k);
    rep(i,1,n) scanf("%d",a+i),pre[i]=(pre[i-1]+a[i])%k;
    rep(i,1,n) pre[i]=(pre[i]-i+(ll)k*1000000000ll)%k;
    m[pre[0]]++;
    rep(i,1,n){
        if(i-k>=0) m[pre[i-k]]--;
        ans+=m[pre[i]];
        m[pre[i]]++;
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 11264
#include<stdio.h>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
const int m=1e5+10;
int main()
{
	ll a[m];
	int n;
	int ans,ant;
	ll sam;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%lld",&a[i]);
	sam=a[0];
	ant=0;
	ans=0;
	for(int i=1;i<n;i++)
	{
		if(sam>=a[i])
		{
			ant+=1;
//			printf("%d ",ant);
		}
		else
		{
			if(ant>ans)
			{
				ans=ant;
			}
			ant=0;
		}
		sam=a[i];
	}
	if(ant>ans)
		printf("%d\n",ant);
	else
		printf("%d\n",ans);
	return 0;
}

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

int chack_str(const string& str,int number)
{
    int counter = 0;
    for(int i=number;str[number]==str[i];i++){
        counter++;
    }
    return counter;   
}

int main(){
    int N;
    string str;
    int ans = 0;
    cin>>N;
    cin>>str;
    for(int i=0;i<N;){
        i += chack_str(str,i);
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
a,b,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=min(a)+min(b)
for i in range(m):
    x,y,c=map(int,input().split())
    ans=min(ans,a[x-1]+b[y-1]-c)
print(ans)

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

int main(void) {
    int N;
    cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        if (!A[i]) {
            cout << 0 << "\n";
            return 0;
        }
    }
    double log_sum = 0;
    long long ans = 1;
    for (int i = 0; i < N; ++i) {
        log_sum += log10(A[i]);
        if (log_sum > 18.5) {
            cout << -1 << "\n";
            return 0;
        }
        ans *= A[i];
        if (ans > 1000000000000000000) {
            cout << -1 << "\n";
            return 0;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4064
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;

	char buf[L], *S , *T, c;

	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}

	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}

	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}

	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}

	char B[45], *outs=B+40, *outr=B+40;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;

		if(!a)*--outs = '0';
		else
			while(a)
				*--outs = (a % 10) + 48, a /= 10;

		if(x)
			*--outs = x;

		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
//using i128 = __int128_t;
//using u128 = __uint128_t;
using i128 = i64;
using u128 = u64;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

ll exgcd(ll a, ll b, ll &x, ll &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll px, py;
	ll d = exgcd(b, a%b, px, py);
	x = py;
	y = px-a/b*py;
	return d;
}

template<class T>
inline void freshmin(T &a, const T &b)
{
	if (a > b) a = b;
}

template<class T>
inline void freshmax(T &a, const T &b)
{
	if (a < b) a = b;
}

const int MOD = 1000000007;
const int INF = 1000000000;
const int MAXN = 100010;
const int MAXK = 20;

int n, x;
int a[MAXN];

int main()
{
	
	n = inp();
	x = inp();
	int ans = 0;
	for (int i = 1; i <= n; ++ i)
	{
		a[i] = a[i-1]+inp();
		ans += a[i] <= x;
	}
	cout << ans+1 << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<set>
using namespace std;
int main()
{
    int n;cin >> n;
    set<int>st;
    for (int i = 0;i < n;i++) {
        int temp;cin >> temp;
        if (st.count(temp) != 0) {
            cout << "NO\n"; return 0;
        }
        st.insert(temp);
    }
    cout << "YES\n";
}


Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int i = 0;
		outer: while (i < 50) {
			int m = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();
			int sum = m + f;
			if (m > 50 || f > 50 || r > 100) {
				System.out.println("-1 <= m,f <=50,-1<=r<=100で入力してください");
				continue outer;
			} else if (m == -1 && f == -1 && r == -1) {
				break;
			} else if (m * f < 0) {
				System.out.println("F");
			} else if (sum >= 80) {
				System.out.println("A");
			} else if (sum >= 65) {
				System.out.println("B");
			} else if (sum >= 50) {
				System.out.println("C");
			} else if (sum >= 30) {
				if (r >= 50) {
					System.out.println("C");
				} else {
					System.out.println("D");
				}
			} else {
				System.out.println("F");
			}
			i++;
		}
	}

}



Measured memory_bytes: 26324
#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(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
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; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans=a*c;
    chmax(ans,a*d);
    chmax(ans,b*c);
    chmax(ans,b*d);
    cout << ans;

    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <math.h>
#include<map>
#include<algorithm>
using namespace std;
typedef long long int ll;
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return 1; }return 0; }
#define all(a)  (a).begin(),(a).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define vll vector<ll>
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i]>>y[i];
const ll INF =1LL << 62;
int dp[101][4][4][4];
int main(){
  int N; cin >> N;
  int mod =1000000007 ;
  dp[0][3][3][3] = 1;
  
  rep(i,N){
    rep(j,4){
      rep(k,4){
        rep(l,4){
          if(dp[i][j][k][l] == 0) continue;
          rep(a,4){
            if(a == 2&& j == 1 && k == 0)continue;
            if(a == 2&& j == 0 && k == 1)continue;
            if(a == 1&& j == 2 && k == 0)continue;
            if(a == 2&& j == 1 && l == 0)continue;
            if(a == 2&& k == 1 && l == 0)continue;
            
            dp[i+1][a][j][k] += dp[i][j][k][l] ;
            dp[i+1][a][j][k] %= mod;
          }
        }
      }
    }
  }
  int ans =0;
  rep(i,4){
    rep(j,4){
      rep(k,4){
        ans += dp[N][i][j][k] ;
        ans %= mod;
      }
    }
  }
  cout << ans << endl;
}
  


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
			int R = sc.nextInt();
			int G = sc.nextInt();
			int B = sc.nextInt();
			int N = sc.nextInt();

		sc.close();

		int count = 0 ;

		for(int i = 0 ; i <= N ; i++){
			for(int j = 0 ; j <= N-i ; j++){

				int p = N - (R * i) - (G * j);


				if(p % B == 0 && i+j+(p/B) <= N && p>= 0){
					count++;

					//System.out.println(i+" "+j+" "+p/B);
				}


			}
		}

		System.out.println(count);
	}
}


Measured memory_bytes: 21844
import java.util.Arrays;
import java.util.Scanner;

 class Main {
    public static void main(String[] args) {
        Scanner enter = new Scanner(System.in);
        int numOfMonster = enter.nextInt();
        int numOfSpecialMoves = enter.nextInt();
        long monsterlifes[] = new long[numOfMonster];
        long addition = 0;

        long max = monsterlifes[0];
        for (int i = 0; i < monsterlifes.length; i++) {
            monsterlifes[i] = enter.nextInt();}
            Arrays.sort(monsterlifes);
            for (int j = numOfMonster - numOfSpecialMoves - 1; j >= 0; j--)

                addition += monsterlifes[j];


        System.out.println(addition);


    }
}

Measured memory_bytes: 87488
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]

n=int(input())
s=input()
lst=[[0,0],[0,1],[1,0],[1,1]]

for i in range(n-1):
    for j in range(4):
        if lst[j][-1]==0 and s[1+i]=="o":
            lst[j].append(lst[j][-2])
        elif lst[j][-1]==0 and s[1+i]=="x":
            lst[j].append(1-lst[j][-2])
        elif lst[j][-1]==1 and s[1+i]=="o":
            lst[j].append(1-lst[j][-2])
        else:
            lst[j].append(lst[j][-2])
for j in range(4):
    if lst[j][-1]==0 and s[0]=="o":
        lst[j].append(lst[j][-2])
    elif lst[j][-1]==0 and s[0]=="x":
        lst[j].append(1-lst[j][-2])
    elif lst[j][-1]==1 and s[0]=="o":
        lst[j].append(1-lst[j][-2])
    else:
        lst[j].append(lst[j][-2])
# print(lst)

for i in range(4):
    if lst[i][-2:]==lst[i][:2]:
        tmp=[]
        for j in range(n):
            if lst[i][j]==0:
                tmp.append("S")
            else:
                tmp.append("W")
        print("".join(tmp))
        quit()
print(-1)

Measured memory_bytes: 83092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,c;
  cin>>n>>c;
  vector<vector<P>> ch(c+10),ch2(c+10);
  rep(i,n){
    int s,t,x;
    cin>>s>>t>>x;
    x--;
    ch[x].push_back(P(s,t));
  }
  rep(i,c){
    if(ch[i].empty()) continue;
    sort(begin(ch[i]),end(ch[i]));
    int st=ch[i][0].fi,en=ch[i][0].se;
    rep(j,ch[i].size()){
      if(j+1<ch[i].size() && en==ch[i][j+1].fi){
        en=ch[i][j+1].se;
        if(j==ch[i].size()-1){
          ch2[i].push_back(P(st,en));
        }
      }else{
        ch2[i].push_back(P(st,en));
        if(j+1<ch[i].size()){
          st=ch[i][j+1].fi;
          en=ch[i][j+1].se;
        }
      }
    }
  }
  vector<int> sum(100110,0);
  rep(i,c){
    //cout<<i<<endl;
    rep(j,ch2[i].size()){
      sum[ch2[i][j].fi-1]++;
      sum[ch2[i][j].se]--;
      //cout<<ch2[i][j].fi<<' '<<ch2[i][j].se<<' ';
      //cout<<endl;
    }
  }
  FOR(i,1,100010) sum[i]+=sum[i-1];
  cout<<*max_element(begin(sum),end(sum))<<endl;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pii;
#define ffor(n) for(ll i=0;i<n;i++)
#define rfor(x,y) for(ll i=x;i<y;i++)
#define ff first
#define ss second
#define pb push_back
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
void solve()
{
    ll n;
    cin>>n;
    int k;
    cin>>k;
    int arr[n];
    ffor(n)
    cin>>arr[i];
    ll dp[n];
    dp[0]=0;
    dp[1] = abs(arr[1]-arr[0]);
    rfor(2,n)
    dp[i]=INT_MAX;
    rfor(2,n)
    {   
        for(int j=1;j<=k;j++)
        if(i>=j)
        dp[i] = min(dp[i], dp[i-j] + abs(arr[i-j] - arr[i])); 
    }
    cout<<dp[n-1]<<endl;
    return;

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


Measured memory_bytes: 4784
#include <stdio.h>

int main(){
	int n,answer;

	while( scanf("%d", &n) !=EOF ){
		answer = 0;
		if(n<=36){
			for(int a=0 ; a<=9 ; a++){
				for(int b=0 ; b<=9 ; b++){
					for(int c=0 ; c<=9 ; c++){
						for(int d=0 ; d<=9 ; d++){
							if((a+b+c+d)==n){
								answer++;
							}
						}
					}
				}
			}
		}
		printf("%d\n", answer);
	}

	return 0;
} 

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

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

    rep(i, s.size())
    {
        if (s[i] + n <= 'Z')
            s[i] = s[i] + n;
        else
            s[i] = s[i] + n - 26;
    }

    OP(s);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>/*toupperとかが入っている*/
#include<vector>/*可変長配列vectorのインクルード*/
using namespace std;/*標準名前空間を利用する。cinやcoutはこれによって利用可能になる*/

int N;

int main(void) {
  cin >> N;
  cout << (N-2)*180<< endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
void CountingSort(int*,int*,int);
int n;
int main() 
{
  int i,max=0;
  int *a,*b;

  scanf("%d",&n);
  a=(int*)malloc(sizeof(int)*(n+1));
  b=(int*)malloc(sizeof(int)*(n+1));
  for(i=1;i<=n;i++){
    scanf("%d",&a[i]);
    if(a[i]>max) max = a[i];
  }

   CountingSort(a,b,max);
   for(i=1; i<=n; i++) {
     if(i>1) printf(" ");
     printf("%d",b[i]);
   }
  printf("\n");
  free(a);
  free(b);
  
  return 0;
}

void CountingSort(int a[],int b[],int k)
{
  int *c,i,j;
  
  c=(int*)malloc(sizeof(int)*(k+1));
  for(i=0; i<=k; i++) c[i]=0;
  
  for(j=1; j<=n; j++) c[a[j]]++;
  for(i=1; i<=k; i++) c[i]+=c[i-1];
  for(j=n; j>=1; j--) {
    b[c[a[j]]] = a[j];
    c[a[j]]--;
  }
  free(c);
}

Measured memory_bytes: 16436
#include <cstdio>
#include <cctype>
#include <algorithm>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
#define repd(i,x,y) for (int i=x; i>=y; --i)
#define mid ((l+r)>>1)
using namespace std;

typedef long long LL;
int n;
LL sum[300100],f[300100],g[300100],ans[300100];
struct point
{
    LL x,y;
    point operator-(point t)
    {
        return (point){x-t.x,y-t.y};
    }
    LL operator*(point t)
    {
        return x*t.y-y*t.x;
    }
    LL calc(int k)
    {
        return y-x*k;
    }
};
struct hull
{
    int top;
    point stk[300100];
    void init(LL x,LL y)
    {
        stk[top=1]=(point){x,y};
    }
    void insert(LL x,LL y)
    {
        point p=(point){x,y};
        for (; top>1 && (p-stk[top])*(stk[top-1]-stk[top])>0; --top);
        stk[++top]=p;
    }
    LL query(int k)
    {
        for (; top>1 && stk[top].calc(k)<stk[top-1].calc(k); --top);
        return stk[top].calc(k);
    }
} s;

int getint()
{
    char ch;
    while (!isdigit(ch=getchar()));
    int x=ch-'0';
    for (; isdigit(ch=getchar()); x=x*10+ch-'0');
    return x;
}

void solve(int l,int r)
{
    if (l>r)
        return;
    static LL t[300100];
    LL w=-1LL<<60;
    s.top=0;
    repu(i,l-1,mid-1)
        s.insert(i,sum[i]+f[i]+LL(i-1)*i/2);
    repu(i,mid,r)
        t[i]=s.query(i)-sum[i]+LL(i+1)*i/2+g[i+1];
    repd(i,r,mid)
        ans[i]=max(ans[i],w=max(w,t[i]));
    s.top=0,w=-1LL<<60;
    repd(i,r+1,mid+1)
        s.insert(n-i,g[i]-sum[i-1]+LL(n-i-1)*(n-i)/2);
    repd(i,mid,l)
        t[i]=s.query(n-i)+sum[i-1]+LL(n-i+1)*(n-i)/2+f[i-1];
    repu(i,l,mid)
        ans[i]=max(ans[i],w=max(w,t[i]));
    solve(l,mid-1),solve(mid+1,r);
}

int main()
{
    n=getint();
    s.init(0,0);
    repu(i,1,n)
    {
        sum[i]=sum[i-1]+getint();
        f[i]=max(f[i-1],s.query(i)-sum[i]+LL(i+1)*i/2);
        s.insert(i,sum[i]+f[i]+LL(i-1)*i/2);
    }
    s.init(-1,1-sum[n]);
    repd(i,n,1)
    {
        g[i]=max(g[i+1],s.query(n-i)+sum[i-1]+LL(n-i+1)*(n-i)/2);
        s.insert(n-i,g[i]-sum[i-1]+LL(n-i-1)*(n-i)/2);
    }
    repu(i,1,n)
        ans[i]=-1LL<<60;
    solve(1,n);
    for (int m=getint(); m--;)
    {
        int p=getint(),w=getint();
        printf("%lld\n",max(f[p-1]+g[p+1],ans[p]+sum[p]-sum[p-1]-w));
    }
    return 0;
}

Measured memory_bytes: 14848
#include <bits/stdc++.h>
  using namespace std;
 
int main(){
  int A,B,C;
  cin>>A>>B>>C;
  int count=0;
  if(A+B>=C-1){
    cout<<B+C<<endl;
  }else{
    cout<<A+B+1+B<<endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void) {

        int a, b;
        int i, div_num = 0;

        scanf("%d %d", &a, &b);

        if(a < 1 || a > 1000000000 || b < 1 || b > 1000000000) {
                printf("illegal inupt\n");
                return 1;
        }

        printf("%d %d %.5lf\n", a/b, a%b, (double)a/b);

        return 0;
}



Measured memory_bytes: 2120
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ggdem=b;i<ggdem;++i)
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define mset(a,v) memset((a),(v),sizeof(a))
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

int main(){FIN;
	string s; cin>>s;
	fore(i,0,SZ(s)){
		if(s[i]=='?'){
			s[i]='D';
		}
	}
	cout<<s;
	return 0;
}

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

int main()
{
    int n, res = INT_MAX;
    cin >> n;


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

    for(int i = 1; i <= n; ++i)
    {
        res = min(res, abs(s[n] - s[i] - s[i]));
    }

    cout << res << endl;

    return 0;
}

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

int main() {
    int n, k;
    string s;
    cin >> n >> s >> k;

    char c = s[k - 1];
    rep(i, s.size()) {
        if (s[i] == c)
            cout << c;
        else
            cout << "*";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define all(x) (x).begin(),(x).end()
lint dp[100005][2];
int main()
{
    int n;
    cin>>n;
    vi v(n);
    rep(i,n){
        cin >> v[i];
    }
    dp[0][0] = 0;
    dp[0][1]=-INF;
    rep(i, n)
    {
        dp[i+1][0]=max((dp[i][0]+v[i]),(dp[i][1]-v[i]));
        dp[i+1][1]=max((dp[i][0]-v[i]),(dp[i][1]+v[i]));
    }
    cout<<dp[n][0]<<endl;
    return 0;
}

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

int T;
long long A, B, C, D;

long long gcd(long long a, long long b) {
  if(b == 0) return a;
  else return gcd(b, a % b);
}
int main() {
  cin >> T;
  for(int i = 0; i < T; ++i) {
    cin >> A >> B >> C >> D;
    if(A < B || B > D) cout << "No" << endl;
    else if(B - 1 <= C) cout << "Yes" << endl;
    else {
      long long l = A % B;
      long long g = gcd(B, D);
      l += (B - 1 - l) / g * g;
      assert(l < B);
      if(l > C) cout << "No" << endl;
      else cout << "Yes" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = b = ab = ans = 0
for _ in range(n):
  t = input()
  ans += t.count("AB")
  if t[0] == "B":
    if t[-1] == "A":
      ab +=1
    else:
      b += 1
  elif t[-1] =="A":
    a += 1
if ab > 0:
  ans += ab-1
  if a > 0:
    ans += 1
    a -= 1
  if b > 0:
    ans += 1
    b -= 1
print(ans + min(a,b))

Measured memory_bytes: 3064
// Author: πα

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



int maxa(int a,int b)
{
	if(a>b)
	{
		return a;
	}
	else
	{
		return b;
	}
}

 int main()
{
	long long int a,b,c,k;
	cin>>a>>b>>c>>k;
	cout<<(min(a,k) + maxa(k-a-b , 0)*(-1) );


}


Measured memory_bytes: 3528
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

int main() {
  int a,b;
  cin >>a>>b;
  
  cout << (a+b-1)/b << endl; 
  
}


Measured memory_bytes: 256
x1,y1,x2,y2 = map(int,input().split())
x3 = x2 - (y2-y1)
y3 = y2 + (x2-x1)
x4 = x1 - (y2-y1)
y4 = y1 + (x2-x1)
print(x3,y3,x4,y4)

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

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    return b ? gcd(b, a % b) : a;
}

int main() {
    int t;
    cin >> t;
    for (int i = 0; i < t; ++i){
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        if (b > d || a < b) cout << "No" << endl;
        else {
            ll g = gcd(b, d);
            ll p = c + g - (c - a % g + g) % g;
            cout << (p - b >= 0 ? "Yes" : "No") << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int gcd(int x,int y)
{
	int t;
	t = x%y;
	if(t == 0){
		return y;
	}

	return gcd(y,t);
}

int main()
{
	int x,y;
	int t;
	scanf("%d %d",&x,&y);

	int ans = gcd(x,y);

	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define MAX 511
#define inf 100000000011
#define LOG 20
using namespace std;
long long  a,d[MAX][MAX],x[MAX][MAX];
vector<long long > v[3];

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);	
	int n,c;
	cin>>n>>c;
	for(int i = 1; i <= c;i ++){
		for(int j = 1 ; j <= c ; j++)cin>>d[i][j];
	}
	for(int i = 1; i <= n ; i++){
		for(int j = 1; j <= n ; j++){
			cin>>a;
			v[(i + j) % 3].push_back(a);
		}
	}
	memset(x,0,sizeof x);
	for(int k = 0; k < 3 ; k++){
		for(int i = 1; i <= c ; i++){
			for(auto co : v[k]){
				if(co == i)continue;
				x[k][i] += (d[co][i]);
			}
		}
	}
	long long  ans = inf;
	for(int i = 1; i <= c; i++){
		for(int j = 1; j <= c; j++){
			for(int k = 1; k <= c; k++){
				if(k != i && j != i && k != j){
					ans = min(ans, x[0][i] + x[1][j] + x[2][k]);
				}
			}
		}
	}
	cout<<ans;
	return 0;
}

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

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

  cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
  return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long l;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    const l mod = 1000000007;
    l t;
   // cin>>t;
   t = 1;
    while(t--)
    {
        l a,b;
        cin>>a>>b;
        //cin>>n;
        //vector<l> v(n);
       // for(l i = 0 )
        //l ans = 0;
        if((b-1)%(a-1)==0)
        cout<<(b-1)/(a-1)<<endl;
        else
        cout<<(b-1)/(a-1) + 1<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, M, C;
    cin >> N >> M >> C;
    int B[M];
    for (int i = 0; i < M; i++)
    {
        cin >> B[i];
    }
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        int sum = 0;
        for (int j = 0; j < M; j++)
        {
            int a;
            cin >> a;
            sum += a * B[j];
        }
        sum += C;
        if (sum > 0)
        {
            ++ans;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int n,i,j,cnt[26];
char s[105],tmp[105],s1[105];

bool check(int l){
	for(int ii = 0; ii < l - 1; ii++){
		if(s[ii] != s[ii + 1]) return 0;
	}
	return 1;
}

int main(){
	scanf("%s", s);
	
	int l = strlen(s);
	
	for(i = 0; i < l; i++){
		cnt[s[i] - 'a']++;
		s1[i] = s[i];
	}
	
	int res = 1e9;
	int tmpl = l;
	
	for(int ii = 0; ii < 26; ii++){
		int cnt = 0;
		l = tmpl;
		for(i = 0; i < l; i++)
		s[i] = s1[i];
		
		while(!check(l)){
			cnt++;
			for(i = 0; i < l - 1; i++){
				if(s[i] - 'a' == ii || s[i + 1] - 'a' == ii)
				tmp[i] = ii + 'a';
				else
				tmp[i] = s[i];
					
				s[i] = tmp[i];
			}
			l--;
		}
		
		res = min(cnt, res);
	}
	
	printf("%d\n", res);
}


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

using namespace std;
typedef long long ll;

int n;
string s;

int main() {
    ll money = 1000;
    ll kabu = 0;
    cin >> n;
    ll as[80];
    for (int i = 0; i < n; i++) cin >> as[i];
    int tmp_arr[80] = {};
    int pre = -1;
    for (int i = 1; i < n; i++) {
        if (as[i]-as[i-1]>0) {
            // up
            if (pre < 0) {
                tmp_arr[i-1] = 1;
                pre = 1;
            }
        } else if (as[i]-as[i-1]<0) {
            // down
            if (pre > 0) {
                tmp_arr[i-1] = -1;
                pre = -1;
            }
        } else {
                tmp_arr[i-1] = 0;
        }
    }
    for (int i = 0; i < n; i++) {
        if (tmp_arr[i] > 0) {
            kabu = (money/as[i]);
            money -= kabu*as[i];
        } else if (tmp_arr[i] < 0) {
            money += (kabu*as[i]);
            kabu = 0;
        }
    }
    money += (kabu*as[n-1]);
    cout << money << endl;
}

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

using namespace std;

using int64 = long long;
const int mod = 998244353;

template< int mod >
struct Combination {
  vector< int64_t > mfact, rfact;

  Combination(int sz) : mfact(sz + 1), rfact(sz + 1) {
    mfact[0] = 1;
    for(int i = 1; i < mfact.size(); i++) {
      mfact[i] = mfact[i - 1] * i % mod;
    }
    rfact[sz] = inv(mfact[sz]);
    for(int i = sz - 1; i >= 0; i--) {
      rfact[i] = rfact[i + 1] * (i + 1) % mod;
    }
  }

  int64_t fact(int k) const {
    return (mfact[k]);
  }

  int64_t pow(int64_t x, int64_t n) const {
    int64_t ret = 1;
    while(n > 0) {
      if(n & 1) (ret *= x) %= mod;
      (x *= x) %= mod;
      n >>= 1;
    }
    return (ret);
  }

  int64_t inv(int64_t x) const {
    return (pow(x, mod - 2));
  }

  int64_t P(int n, int r) const {
    if(r < 0 || n < r) return (0);
    return (mfact[n] * rfact[n - r] % mod);
  }

  int64_t C(int p, int q) const {
    if(q < 0 || p < q) return (0);
    return (mfact[p] * rfact[q] % mod * rfact[p - q] % mod);
  }

  int64_t H(int n, int r) const {
    if(n < 0 || r < 0) return (0);
    return (r == 0 ? 1 : C(n + r - 1, r));
  }
};

Combination< mod > uku(6001);
string S;
int dp[6001][6001];


int rec2(int red, int blue) {
  return uku.C(red + blue, red);
}


int rec(int idx, int red, int blue) {
  if(idx == S.size()) return rec2(red, blue);
  if(~dp[idx][red]) return dp[idx][red];
  int R = red, B = idx - R;
  if(idx < S.size()) {
    if(S[idx] == '0') R += 2;
    else if(S[idx] == '1') R++, B++;
    else B += 2;
  }
  int ret = 0;
  if(R > 0) ret += rec(idx + 1, R - 1, B);
  if(B > 0) ret += rec(idx + 1, R, B - 1);
  ret %= mod;
  return dp[idx][red] = ret;
}

int main() {
  cin >> S;
  memset(dp, -1, sizeof(dp));
  cout << rec(0, 0, 0) << endl;
}






Measured memory_bytes: 141184
#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;

#define ll  long long
#define PR  pair<int, int>

const int N = 3e5 + 10;
const int MOD = 1e9 + 7;
const long long INF = 5e18;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, nulong long_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
//    ios::sync_with_stdio(false);
//    cin.tie(0);
    int x;
    cin >> x;
    if (x >= 400 && x < 600) {
        cout << 8;
    } else if (x >= 600 && x < 800) {
        cout << 7;
    } else if (x >= 800 && x < 1000) {
        cout << 6;
    } else if (x >= 1000 && x < 1200) {
        cout << 5;
    } else if (x >= 1200 && x < 1400) {
        cout << 4;
    } else if (x >= 1400 && x < 1600) {
        cout << 3;
    } else if (x >= 1600 && x < 1800) {
        cout << 2;
    } else if (x >= 1800 && x < 2000) {
        cout << 1;
    }
    return 0;
}


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
constexpr ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }

int n;
ll k, a[200005], f[200005];
void solve() {
    cin >> n >> k;

    rep(i, n) cin >> a[i];
    rep(i, n) cin >> f[i];

    sort(a, a + n);
    sort(f, f + n, greater<>());

    const auto ok = [](ll x) {
        ll cnt = k;
        rep(i, n) if (a[i] * f[i] > x) cnt -= a[i] - x / f[i];
        return cnt >= 0;
    };

    ll l = 0, r = inf, ans = inf;
    while (l <= r) {
        auto mid = (l + r) / 2;
        if (ok(mid)) { r = mid - 1; mins(ans, mid); }
        else l = mid + 1;
    }

    cout << ans << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


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

using namespace std;

int main()
{
    int k,a,b,x;
    cin>>k>>a>>b;
    if(a%k==0)
        x=a;
    else
    x=a+(k-a%k);
    if(x>=a && x<=b)
        cout<<"OK";
    else
        cout<<"NG";
}


Measured memory_bytes: 3636
s = input()
s = list(map(int, s))
n = len(s)

cnt = [0] * 2
for i in range(n):
	m = i % 2
	if s[i] == 1:
		cnt[m] = cnt[m] + 1

ans = min((n // 2 + n % 2 - cnt[0]) + cnt[1], cnt[0] + (n // 2 - cnt[1]))
print(ans)

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,n2=1,t,a[300010],dat[1200100],ans=0;

void upd(int k,int val)
{
	dat[k]=max(dat[k],val);
	while(k>0)
	{
		k=(k-1)/2;
		dat[k]=max(dat[k],val);
	}
}

int query(int k,int lb,int ub,int tlb,int tub)
{
	if(ub<tlb||tub<lb) return 0;
	if(tlb<=lb&&ub<=tub) return dat[k];
	return max(query(k*2+1,lb,(lb+ub)/2,tlb,tub),query(k*2+2,(lb+ub)/2+1,ub,tlb,tub));
}

int main()
{
	cin>>n>>t;
	rep(i,n) scanf("%d",&a[i]);
	while(n2<300005) n2*=2;
	rep(i,n)
	{
		int val=query(0,0,n2-1,max(0,a[i]-t),min(300002,a[i]+t))+1;
		ans=max(ans,val);
		upd(a[i]+n2-1,val);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7188
#include <cstdio>
#include <algorithm>
#include <set>
#define MAX(a,b) ((a)>(b))?(a):(b)
using namespace std;


int main() {
	int n,p,q,r,max=-1,w;
	int i,j;
	int c;
	int *sum;
	set<int> under;
	set<int> over;
	bool flag=false;
	scanf("%d%d",&n,&q);
	sum=(int *)malloc(sizeof(int)*n);
	scanf("%d",&w);
	max=sum[0]=w;
	for(i=1; i<n; ++i) {
		scanf("%d",&w);
		max=MAX(w,max);
		sum[i]=sum[i-1]+w;
	}
	if(q==1) {
		printf("%d\n",sum[n-1]);
		return 0;
	}
	p=max;
	while(1) {
		i=0;
		for(c=0; c<q-1; ++c) {
			for(j=0; i+j<n; ++j) {
				if(i==0) {
					if(sum[j]>p) {
						i=j;
						j=0;
						break;
					}
				} else {
					if(sum[i+j]-sum[i-1]>p) {
						i+=j;
						j=0;
						break;
					}
				}
			}
			if(i+j==n-1 && c<q-2) {
				if(p==max || flag) {
					printf("%d\n",p);
					return 0;
				}
				over.insert(p);
				if(flag) {
					++p;
				} else if(!under.empty()) {
					p=((*over.begin())+(*(--under.end())))/2;
				} else {
					p=(max+p)/2;
				}
			}
		}
		r=sum[n-1]-sum[i-1];
		if(r==p) {
			printf("%d\n",p);
			return 0;
		} else if (!flag) {
			if(r<p) {
				over.insert(p);
				if(!under.empty()) {
					p=((*(over.begin()))+(*(--under.end())))/2;
				} else {
					p=r+(p-r)/n;
				}
			} else if(r>p) {
				if((!over.empty() && !under.empty() && (*(over.begin()))-(*(--under.end()))<=10) || r-p<=10 ) {
					flag=true;
					under.insert(p);
					++p;
				} else {
					under.insert(p);
					if(!over.empty()) {
						p=((*(over.begin()))+(*(--under.end())))/2;
					} else {
						p=p+(r-p)/2;
					}
				}
			}
		} else {
			if(r>p) {
				++p;
			} else {
				printf("%d\n",p);
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3104
/**
 *    author:  FromDihPout
 *    created: 2020-08-11
**/

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, y;
    cin >> n >> y;
    if (n * 10000 < y || n * 1000 > y) {
        cout << -1 << ' ' << -1 << ' ' << -1 << '\n';
        return 0;
    }
    
    int c = y / 1000;
    int b = min((c - n) / 4, c / 5);
    c -= b * 5;
    int a = min(c + b - n, b / 2);
    b -= a * 2;
    if (a + b + c == n) {
        cout << a << ' ' << b << ' ' << c << '\n';
    }
    else {
        cout << -1 << ' ' << -1 << ' ' << -1 << '\n';
    }
    return 0;
}

Measured memory_bytes: 3628
OFS = 2500
MAX = 2*OFS + 1
N, A = map(int, input().split())
X = [x-A for x in map(int, input().split())]

dp = [[0]*MAX for _ in [0]*(N+1)]
dp[0][OFS] = 1

for i in range(1, N+1):
    x = X[i-1]
    for j in range(MAX-1, -1, -1):
        if 0 <= j-x < MAX:
            dp[i][j] = dp[i-1][j] + dp[i-1][j-x]

print(dp[-1][OFS] - 1)


Measured memory_bytes: 70008
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

void main_()
{
    ll N, M;
    vector<ll> Ds, Ts;
    cin >> N;
    copy_n(istream_iterator<ll>(cin), N, back_inserter(Ds));
    cin >> M;
    copy_n(istream_iterator<ll>(cin), M, back_inserter(Ts));

    sort(begin(Ds), end(Ds));
    sort(begin(Ts), end(Ts));

    cout << (includes(begin(Ds), end(Ds), begin(Ts), end(Ts)) ? "YES" : "NO") << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 4976
import std.stdio;
import std.algorithm;

const int MAX = 1000001;
bool prime[MAX];
int num[MAX];

void main(){
	int n, p, m, ans, upper, lower, x;
	prime[] = true;
	prime[0] = prime[1] = false;
	x = 0;
	foreach (i; 0..MAX) {
		if (prime[i]) {
			x++;
			for (int j = i+i; j < MAX; j+=i) prime[j] = false;
		}
		num[i] = x;
	}

	while (readf("%d\n", &n), n) {
		ans = -n;
		foreach (i; 0..n) {
			readf("%d %d\n", &p, &m);
			upper = min(p+m, 1000000);
			lower = max(p-m, 1) - 1;
			x = num[upper] - num[lower];
			ans += x;
		}
		writeln(ans);
	}
}

Measured memory_bytes: 5868
import sys
import copy

N = int(input())

A = []

for _ in range(2):
    *a, = map(int, input().split())
    A.append(a)

max = 0

def dfs(x, y, count):
    global max
    if x < 0 or y < 0 or x >= N or y >= 2:
        return
    count = count + A[y][x]


    if x==(N-1) and y==1:
        if max < count:
            max = count
        return

    dfs(x+1, y, count)
    dfs(x, y+1, count)

    return


dfs(0,0, 0)

print(max)

Measured memory_bytes: 3444
#include <iostream>
#include <string>
using namespace std;
int main(){
  string S, T;
  cin >> S >> T;
  int l = S.size();
  string s[2];
  for(int i = 0; i < l; ++i)
    s[i%2] += S[i];
  for(int i = 0; i < 2; ++i){
    int k = 0;
    for(int j = 0; j < l; ++j){
      if(s[i][k] == T[j]) ++k;
      if(k == s[i].size()){
	cout << "Yes" << endl;
	return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3212
n = int(input())
a,b = map(int,input().split())
p = list(map(int,input().split()))
t1 = len([1 for i in p if i<=a])
t2 = len([1 for i in p if a < i and i <= b])
t3 = len([1 for i in p if i > b])
print(min(t1,t2,t3))

Measured memory_bytes: 3064
n = int(input())
heights = list(map(int, input().split()))

diffMax = 2 * max(heights)
diffMin = 2 * min(heights)

cnt = 0

arrSize = min([max([i + heights[i] for i in range(len(heights))]),max([i - heights[i] for i in range(len(heights))])]) + 1

seppenPlus = [0] * arrSize
seppenMinus = [0] * arrSize


for i in range(len(heights)):
    seppenPlusNum = i + heights[i]
    seppenMinusNum = i - heights[i]

    if seppenPlusNum < arrSize:
    	seppenPlus[seppenPlusNum] += 1

    if seppenMinusNum >= 0:
        seppenMinus[seppenMinusNum] += 1

for i in range(len(seppenPlus)):
    cnt += seppenPlus[i] * seppenMinus[i]

print(cnt)

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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = (1e9)+7;
const int N = 1e6+5;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n,m,k;
        cin>>n>>m>>k;
        string s[n];
        for(int i=0;i<n;i++)cin>>s[i];
        int ans = 0;
        for(int mask=0;mask<(1LL<<(n+m));mask++)
        {
            int r[n]={},c[m]={};
            for(int i=0;i<n+m;i++)
            {
                if(i<n)r[i] = ((mask>>i)&1LL);
                else c[i-n] = ((mask>>i)&1LL);
            }
            string t[n];
            for(int i=0;i<n;i++)t[i] = s[i];
            for(int i=0;i<n;i++)
            {
                if(r[i])for(int j=0;j<m;j++)t[i][j] = '!';
            }
            for(int i=0;i<m;i++)
            {
                if(c[i])for(int j=0;j<n;j++)t[j][i] = '!';
            }
            int cnt = 0;
            for(int i=0;i<n;i++)for(int j=0;j<m;j++)cnt += (t[i][j] == '#');
            if(cnt == k)ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>

#define FALSE (0)
#define TRUE  (1)

int range(int a, int b, int c);

int main() {
  int a;
  int b;
  int c;
  scanf("%d %d %d", &a, &b, &c);
  printf("%s\n", (range(a, b, c) == TRUE ? "Yes" : "No"));
  return 0;
}

int range(int a, int b, int c) {
  return  ((a < b) && (b < c) ? TRUE : FALSE);
}

Measured memory_bytes: 580
s = input()
q = int(input())

for _ in range(q):
    
    order = input().split()
    
    command = order[0]
    n = int(order[1])
    m = int(order[2])
    
    if command == "print":
        print(s[n:m+1])
    elif command == "reverse":
        r = ''.join(list(reversed(s[n:m+1])))
        s = s[:n] + r + s[m+1:]

    elif command == "replace":
        s = s[:n] + order[-1] + s[m+1:]



Measured memory_bytes: 5612