akhauriyash/Code-Regression huggingface dataset:
/*------U Have To DO It------*/
/* BY-> RicoProg */
/*        ___ 
           __|__|
          |  |___       */
#include <bits/stdc++.h>
using namespace std;
 
 
//---------------------------------------------------MACROS----------------------------------------------------------
#define ll long long
#define ld long double
#define beg(i ,n) for(ll i=0;i<n;i++)
#define beg1(i ,n) for(ll i=1;i<n;i++)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back 
#define mp make_pair
#define nl "\n" 
#define vec(v , n) vector<ll> v(n)
#define all(x) x.begin() , x.end()
#define pii pair<int , int>
#define pll pair<ll , ll>
#define mii map<int , int>
#define mll map<ll , ll>
#define msi map<string , int>
#define mci map<char , int>
#define f1 first
#define f2 second
#define inf 1e18 + 10

//---------------------------------------------------GLOBAL----------------------------------------------------------
const ll MOD = 1e9 + 7 ;
const ll MAX = 1e5 + 7 ;

//---------------------------------------------------FUNCTIONS-------------------------------------------------------

void add_self(ll &a , ll b){
	a+=b ;
	if(a >= MOD) a-=MOD ;
}

void solve(){
	ll n ;
	cin >> n ;
	ll ar[n+1][n+1] ;
	beg(i , n){
		beg(j , n) cin >> ar[i][j] ;
	}
	vector<ll> dp( (1 << n) , 0) ;
	dp[0] = 1 ;
	ll x , y ;
	beg(i , 1<<n){
		x = __builtin_popcount(i) ;
		//cout << i <<  " " << dp[i] << nl ; 
		beg(j , n){
			if(ar[x][j] && !(i & (1 << j))){
				y = i | (1 << j) ;
				add_self(dp[y] , dp[i]) ;
			}
		}
	}
	cout << dp[(1<<n)-1] ;
}

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

Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin>>n;
    vector<int>arr(n);
    for(int i=0; i<n; i++) cin>>arr[i];
    long long sum = 0;
    for(int i=0; i<n; i++){
    	for(int j=i+1; j<n; j++) sum+=arr[i]*arr[j];
	}
	cout<<sum;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  vector<int> s_table(26, -1), t_table(26, -1);

  bool ans = true;
  for (int i = 0; i < s.size(); i ++) {
    int s_char = s.at(i) - 'a';
    int t_char = t.at(i) - 'a';

    if (s_table.at(s_char) != -1 && s_table.at(s_char) != t_char) {
      ans = false;
      break;
    }
    s_table.at(s_char) = t_char;
    if (t_table.at(t_char) != -1 && t_table.at(t_char) != s_char) {
      ans = false;
      break;
    }
    t_table.at(t_char) = s_char;
  }

  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 776
using System;

namespace ABC104_A_Rated_for_Me
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			int r = int.Parse(Console.ReadLine());

			if (r < 1200)
			{
				Console.WriteLine("ABC");
			}else if (r < 2800)
			{
				Console.WriteLine("ARC");
			}
			else
			{
				Console.WriteLine("AGC");
			}
		}
	}
}

Measured memory_bytes: 11092
N = int(input())
x = [0] * N
u = [0] * N
for i in range(N):
    x[i], u[i] = map(str, input().split())

ans = 0
for i in range(N):
    if u[i] == 'JPY':
        ans += float(x[i])
    else:
        ans += float(x[i]) * 380000

print(ans)


Measured memory_bytes: 9084
#include<iostream>

using namespace std ;

int main()
{
	int a ,b;
	cin >> a >> b ;
	if( a - b )
	{
		if( a < b )
			cout << "a < b" << endl ;
		else
			cout << "a > b" << endl ;
	}
	else
		cout << "a == b" << endl ;
	return 0 ;
}

Measured memory_bytes: 3072
<?php

fscanf(STDIN, '%d', $n);
for ($i = 0; $i < $n; $i++) {
    $score = 0;
    $out = 0;
    $runner = 0;
    while ($out !== 3) {
        switch (trim(fgets(STDIN))) {
            case 'HIT':
                if ($runner === 3) {
                    $score++;
                } else {
                    $runner++;
                }
                break;

            case 'HOMERUN':
                $score += $runner + 1;
                $runner = 0;
                break;

            case 'OUT':
                $out++;
                break;
        }
    }
    echo $score, PHP_EOL;
}

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

using namespace std;

int main(){

  int N;
  int M;

  cin >> N;

  vector<int> X(N + 1);
  
  for(int i = 1;i < N + 1;++i)
    cin >> X[i];

  cin >> M;

  vector<int> A(M + 1);
  
  for(int i = 1;i < M + 1;++i){

    bool flag = true;
    
    cin >> A[i];

    if(X[A[i]] == 2019)
      continue;
    
    for(int j = 1;j < N + 1;++j){
      if(X[A[i]] + 1 == X[j]){
	flag = false;
	break;
      }
    } 
    if(flag == true)
      X[A[i]] = X[A[i]] + 1;
  }

  for(int i = 1;i < N + 1;++i)
    cout << X[i] << endl;
  
}



Measured memory_bytes: 3096
import java.awt.*;
import java.awt.geom.*;
import java.io.*;
import java.util.*;

public class Main{
  public static void main(String args[]) {
    Scanner in = new Scanner(System.in);
    String str;
    str = in.nextLine();
    char [] cin = str.toCharArray();

    for(int i=0;i<cin.length;++i){
      if (Character.isUpperCase(cin[i])){
        cin[i]=Character.toLowerCase(cin[i]);
      }else{
        cin[i]=Character.toUpperCase(cin[i]);
      }
    }
    System.out.println(cin);
  }
}



Measured memory_bytes: 26256
import java.util.*;

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

    ArrayList<ArrayList<Integer>> a = new ArrayList<ArrayList<Integer>>();
    for (int i=0;i<n;i++){
      ArrayList<Integer> b = new ArrayList<Integer>();
      a.add(b);
    }

    for (int i=0;i<m;i++){
      int a1 = scan.nextInt();
      int a2 = scan.nextInt();

      ArrayList<Integer> c1 = a.get(a1-1);
      c1.add(a2);

      ArrayList<Integer> c2 = a.get(a2-1);
      c2.add(a1);
    }

    int ret = 0;
    boolean[] g = new boolean[n+1];

    for (int j=0;j<=n;j++){
      g[j] = false;
    }

    ret = find(a,0,1,g,1,n);
    System.out.println(ret);
  }

  static int find(ArrayList<ArrayList<Integer>> a, int sum, int current, boolean[] b, int where, int target){
    if (current == target){
      sum += 1;
      return sum;
    }

    ArrayList<Integer> n = a.get(where-1);
    b[where] = true;

    for (int k : n){
      if (b[k] == true){
        continue;
      }
      sum = find(a,sum,current+1,b,k,target);
    }

    b[where] = false;

    return sum;

  }

}


Measured memory_bytes: 37468
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		long n = fs.nextLong();
		long k = fs.nextLong();
		
		n = n % k;
		System.out.println(Math.min(n, k - n));
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 21204
@$_=$_ for@i=@p=0..1e5;$\-=<>;/ />${*a=-$'}||(${@{$B=$p[$a]}>@{$A=$p[$`]}or$A^=$B^=$A^=$B;A}-$B&&map$p[$$B[@$B]=$_]=$B,@$A),$a=$`for<>;@0=();$\+=@{$p[${-$_}]}for@i;print

Measured memory_bytes: 143104
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,R,G,B;
	while(cin>>R>>G>>B>>N) {
		ll ans=0;
		REP(r, N/R+1) REP(g, N/G+1) {
			ll nb = N-r*R-g*G;
			if(0<=nb && nb%B==0) {
				ll b = nb/B;
//				DD(r);DD(g);DD(b);
				ans++;
			}
		}
		cout<<ans<<endl;
//		break;
	}
	
	return 0;
}


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

using namespace std;

template<class value_type>
class my_deque{
public:
  int imag_size;
  int real_size;
  value_type *array;
  int front_position;
  int back_position;
  my_deque(){
    imag_size = 1;
    real_size = 0;
    array = new value_type[imag_size];
    front_position =
      back_position = 0;
  }

  inline int index(int p){
    p%=imag_size;
    p+=imag_size;
    p%=imag_size;
    return p;
  }

  value_type &front(){
    return array[front_position];
  }
  value_type &back(){
    return array[index(back_position-1)];
  }

  void push_back(value_type value){
    if(imag_size==real_size){
      value_type *next = new value_type[imag_size<<1];
      for(int i=0,j=front_position;i<imag_size;++i,j=index(j+1)){
        next[i] = array[j];
      }
      delete[] array;
      front_position = 0;
      back_position = imag_size;
      imag_size <<= 1;
      array = next;
    }
    ++real_size;
    array[back_position] = value;
    back_position = index(back_position+1);
  }

  void push_front(value_type value){
    if (imag_size == real_size) {
      value_type *next = new value_type[imag_size<<1];
      for (int i=0,j=front_position;i<imag_size;++i,j=index(j+1)) {
        next[i] = array[j];
      }
      delete[] array;
      front_position = 0;
      back_position = imag_size;
      imag_size <<= 1;
      array = next;
    }
    ++real_size;
    front_position = index(front_position-1);
    array[front_position] = value;
  }

  value_type pop_back(){
    --real_size;
    back_position = index(back_position-1);
    return array[back_position];
  }
  value_type pop_front(){
    --real_size;
    value_type res = array[front_position];
    front_position = index(front_position+1);
    return res;
  }

  value_type& operator[](int p){
    return array[index(front_position+p)];
  }
};

int main(){
  my_deque<int> dq;
  int q;
  cin >> q;
  for(int i=0;i<q;++i){
    int kind;
    cin >> kind;
    if(kind==0 or kind==2){
      int dir;
      cin >> dir;
      if(kind==0){
        int value;
        cin >> value;
        if(dir==0){
          dq.push_front(value);
        }else{
          dq.push_back(value);
        }
      }else{
        if(dir==0){
          dq.pop_front();
        }else{
          dq.pop_back();
        }
      }
    }else{
      int p;
      cin >> p;
      cout << dq[p] << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 4860
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

s = ns()
n = len(s)

def is_palind(s):
    if s != ''.join(reversed(s)):
        return False
    return True

flag = True
if not is_palind(s):
    flag = False
if not is_palind(s[:(n - 1) // 2]):
    flag = False

print("Yes" if flag else "No")

Measured memory_bytes: 3064
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a == 1){
        cout << "Hello World";
    }
    else
    {
        cout << b+c;
    }
    
    cout << endl;
}


Measured memory_bytes: 256
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty |) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty | $n:expr) => {
        (0..$n).map(|_| get!($t |)).collect::<Vec<_>>()
    };
}

fn main() {
    let (N, D) = get!(usize, usize);
    let mut cnt = 1;
    let mut p = D + 1;
    while p + D + 1 <= N {
        p += 2 * D + 1;
        cnt += 1;
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4352
import math

N = input()
A = map(int, raw_input().split())

c=0
for i in range(len(A)):
	for j in range(len(A)-1, i, -1):
            if A[j] < A[j-1]:
		A[j], A[j-1] = A[j-1], A[j]
      	      	c+=1
print ' '.join(map(str, A))
print c


Measured memory_bytes: 4712
#include<stdio.h>
#include<string.h>



int main(void){
    int n;
    int u=0;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    int max=a[0];

    for(int i=0;i<n;i++){
        if(max<=a[i]){
            u++;
            max=a[i];
        }
    }

    printf("%d",u);
    return 0;
}

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

int main(){
  int i,j,len;
  char s[27];
  scanf("%s",s);

  len = strlen(s);
  for(i=0;i<len;i++){
    for(j=0;j<i;j++){
      if(s[j]==s[i]){
        printf("no\n");
      return 0;
      }
    }
  }
  printf("yes\n");
  return 0;
}


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



int main() {
	ll N = 3, x2;
	cin >> N;
	vector<ll> A(N, 0), result(N, 0);
	repeat(i, N) {
		cin >> A[i];
		if ((i % 2) == 0) {
			x2 += A[i];
		} else{
			x2 -= A[i];
		}
	}
	result[0] = x2 / 2;
	repeat(i, N - 1) {
		result[i+1] = A[i] - result[i];
	}

	repeat(i, N) {
		result[i] *= 2;
		cout << result[i];
		cout << ((i == N - 1) ? "" : " ");
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 2944
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstdio>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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



int main(){
	int n,a,b;
	cin >> n >> a >> b;
    string s;
    cin >> s;
    
	int nai = 0,gai = 0;

    rep(i,0,sz(s)){
        if(s[i] == 'c') No;
        
        else if(s[i] == 'a'){
            if(nai + gai < a+b){
                Yes;
                nai++;
            }else{
                No;
            }
        }else if(s[i] == 'b'){
            if(nai + gai < a + b && gai < b){
                Yes;
                gai++;
            }else{
                No;
            }
        }
    }
	
    
	return  0;
}

Measured memory_bytes: 896
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;



#define err(x) cerr << #x  << " = "<<  x << '\n'
#define out(x) cout << x << '\n'
#define forp(i, r, l) for(int i = int(r); i < int(l); i++)
#define forn(i, r, l) for(int i = int(r); i > int(l); i--)
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll ,ll> pll;
const int maxn = 5e5 + 120;



int main(){FAST;    
    int n, sum =0 ,a;
    cin >>n;
    forp(i ,0 ,n)
        cin >> a ,sum += a;
    cout << sum - n;
    return 0;

}
 










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



int main() {
    int R, G, B, N; cin >> R >> G >> B >> N;
    int ans = 0;
    rep(i, 3000) rep(j, 3000)
        if ((N - (i*R+j*G)) % B == 0 && (N - (i*R+j*G)) >= 0) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3588
#include<stdio.h>

 int main (void){

 int i, n;

 scanf("%d",&n);

 int a[n];

 for(i = n - 1; i >= 0; i--)
scanf("%d", &a[i]);
 for(i = 0; i <= n-1 ; i++){
 printf("%d", a[i]);
 if(i < n-1)
 printf(" ");
 }
 printf("\n");
 return 0;
 }
 



Measured memory_bytes: 2104
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] t = new long[n];
		for(int i = 0 ; i < n ; i++) t[i] = sc.nextLong();
		long ans = 1;
		for(int i = 0 ; i < n ; i++) {
			ans = ans / gcd(ans, t[i]) * t[i];
		}
		System.out.println(ans);
	}

	static long gcd(long x, long y) {
		if(x < y) {
			long w = x;
			x = y;
			y = w;
		}
		if(y == 0) return x;
		return gcd(y, x % y);
	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int a[200009];
main()
{
    int n,ma=-100000000,mi=100000000,mai,mii;
    cin >> n;
    for (int i = 0; i < n; i++)
        {
            cin>>a[i];
            if(a[i] > ma)
            {
                ma=a[i];
                mai=i;
            }
            if(a[i] < mi)
            {
                mi=a[i];
                mii=i;
            }
        }
    if(ma==0 && mi==0)
    {
        cout << 0 << endl;
        return 0;
    }
    cout<< 2*n << endl;

    if (abs(ma)>abs(mi) || mi>=0)
    {
         cout<< mai+1 <<" " << mai+1 <<endl;
         cout<< mai+1 <<" " << mai+1 <<endl;
        for (int i=0; i<n; i++)
            if( i<mai) cout<<mai+1<<" "<<i+1<<endl<<mai+1<<" "<<mai+1<<endl;
            else
            if( i > mai)
                cout<<i<<" "<<i+1<<endl<<i<<" "<<i+1<<endl;

        return 0;
    }
    cout<< mii+1 <<" " << mii+1 <<endl;
    cout<< mii+1 <<" " << mii+1 <<endl;
    for (int i=n-1; i>=0; i--)
        if (i > mii) cout<<mii+1<<" "<<i+1<<endl<<mii+1<<" "<<mii+1<<endl;
        else
        if (i < mii)
            cout<<i+2<<" "<<i+1<<endl<<i+2<<" "<<i+1<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int X,K;
vector<pair<int,int> >A;
main()
{
	cin>>X>>K;
	for(int i=0;i<K;i++)
	{
		int r;cin>>r;A.push_back(make_pair(r,-1));
	}
	int Q;cin>>Q;
	for(int i=0;i<Q;i++)
	{
		int t,a;cin>>t>>a;
		A.push_back(make_pair(t,a));
	}
	sort(A.begin(),A.end());
	int pre=0,d=1;
	int L=0,R=X,AA=0;
	for(pair<int,int>p:A)
	{
		if(p.second<0)
		{
			int t=p.first-pre;
			pre=p.first;
			if(d>0)
			{
				AA-=t;
				if(L+AA<0)
				{
					L=-AA;
				}
				if(L>R)R=L;
			}
			else
			{
				AA+=t;
				if(R+AA>X)
				{
					R=X-AA;
				}
				if(L>R)L=R;
			}
			d*=-1;
		}
		else
		{
			int a=p.second;
			if(a<L)a=L;
			else if(a>R)a=R;
			a+=AA;
			int t=p.first-pre;
			cout<<(d>0?max(0,a-t):min(a+t,X))<<endl;
		}
	}
}


Measured memory_bytes: 2928
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define all(x) x.begin(),x.end()
#define ld long double
#define fast  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
signed main(){
    fast;
	int n,x,t;
	cin>>n>>x>>t;
	int ans = (n/x) + ((n%x)!=0);
	ans *= t;
	cout<<ans;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    pii p[200010];

    rep(i, n) {
        cin >> p[i].second >> p[i].first;
    }

    sort(p, p + n);
    int now_time = 0;
    bool can = true;

    rep(i, n) {
        now_time += p[i].second;
        if (now_time > p[i].first) {
            can = false;
            break;
        }
    }
    Yes(can);

    return 0;
}



Measured memory_bytes: 1792
import Data.Array
read_int = read :: String -> Int
main = do
  nm_in <- (return . words) =<< getLine
  let n:m:[] = map read_int nm_in
  c_in <- (return . words) =<< getLine
  let c = map read_int c_in
  print ((dp n c)!!n)
  
dp n c = elems memo
  where
    memo = listArray (0,n) [f i| i<-[0..n]]
    f 0 = 0
    f x = 1 + minimum ([50000] ++ (map (memo!) [x-ci|ci<-c,ci<=x]))


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

int main() {
  int n, a[100];
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  if (n > 0) cout << a[n - 1];                                                                                                                                
  for (int i = n - 2; i >= 0; i--)                                                                                                                            
    cout << ' ' << a[i];
  cout << endl;                                                                                                                                               
  return 0;
}

Measured memory_bytes: 1160
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var Ai = Sarray();
            var gcd = 0L;
            foreach (var a in Ai)
                gcd = Gcd(gcd, a);
            WriteLine(gcd);
        }
        static long Gcd(long x, long y) => y == 0 ? x : Gcd(y, x % y);



        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 38504
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define mp make_pair
#define pb push_back
#define EB emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

// dp[i][j] := i個使用 . 重さの総和j の時の価値の最大値

ll N,W;
ll w[128],v[128];
ll dp[128][512];

int main(){
    cin >> N >> W;
    rep(i,N) cin>>w[i]>>v[i];

    ll sum=0;
    rep(i,N){
        ll ww = w[i]-w[0];
        // 荷物iを複数回使わないように逆に回す
        for(int j=i;j>=0;j--){  // 荷物iを含まないでj個
            for(int k=sum;k>=0;k--){    // 荷物iを含まない時の重さがk
                dp[j+1][k+ww] = max(dp[j+1][k+ww],dp[j][k]+v[i]);
            }
        }
        sum += ww;
    }

    ll ans=0;
    for(int i=0;i<=N;i++){
        for(int j=0;j<=sum;j++){
            if(w[0]*i+j>W) continue;
            ans = max(ans,dp[i][j]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int n;
  cin >> n;
  
  int temp;
  for(int i = 0; i < n; i++){
    cin >> temp;
    if(!(temp % 2)){
      if((temp % 3 == 0) || (temp % 5 == 0)){

      }
      else{
        cout << "DENIED";
        return 0;
      }
    }
  }
  
  cout << "APPROVED";
  
  return 0;
}

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

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

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

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

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

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

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

int main() {
    ll n; cin >> n;
    ll a[100010], b[100010];
    rep(i,0,n) cin >> a[i];
    rep(i,0,n) cin >> b[i];
    ll ans = 1;
    if(n == 1 && a[0] != b[0]) {
        cout << 0 << endl;
        return 0;
    }
    if(n > 1) {
        bool ng = false;
        if(a[n-2] < a[n-1] && a[n-1] != b[n-1]) ng = true;
        if(b[0] > b[1] && a[0] != b[0]) ng = true;
        if(ng) {
            cout << 0 << endl;
            return 0;
        }
    }
    rep(i,0,n-2) {
        bool ok1 = false, ok2 = false;
        if(a[i] < a[i+1]) {
            if(a[i+1] > b[i+1]) {
                ans = 0;
                break;
            }
            ok1 = true;
        }
        if(b[i+2] < b[i+1]) {
            if(b[i+1] > a[i+1]) {
                ans = 0;
                break;
            }
            ok2 = true;
        }
        if(ok1 || ok2) continue;
        else {
            ans = (ans * min(a[i+1], b[i+1])) % MOD;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long now = sc.nextLong();
    long num = sc.nextLong();
    long move = sc.nextLong();
    if(now < 0){
      now *= -1;
    }
    long n = now / move;
    if(n >= num){
      System.out.println(now - (num * move));
    }
    else{
      if((num - n) % 2 == 0){
        System.out.println(now - n * move);
      }
      else{
        System.out.println(-(now - (n + 1) * move));
      }
    }
  }
}

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

int sort(const void *a,const void *b){
  return *(int *)a-*(int *)b;
}

int main(){
  int n;
  scanf("%d",&n);
  
  int l[n];
  for(int i=0;i<n;i++){
    scanf("%d",&l[i]);
  }
  
  qsort(l,sizeof(l)/sizeof(int),sizeof(int),sort);
  
  long ans=0;
  
  for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
      for(int k=j+1;k<n;k++){
        if(l[i]+l[j]>l[k]) ans+=1;
        else break;
      }
    }
  }
  
  printf("%ld",ans);
  return 0;
}

Measured memory_bytes: 252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int a[100010];

int main(){
    vector<int> is_prime(100010,1);
    is_prime[0]=0,is_prime[1]=0;
    for(int i=2;i<100010;i++){
        if(!is_prime[i]) continue;
        for(int j=i*2;j<100010;j+=i) is_prime[j]=0;
    }
    rep(i,100010){
        if(i%2==0) continue;
        if(is_prime[i] && is_prime[(i+1)/2]) a[i]=1;
    }


    vector<int> sum(100010,0);
    rep(i,100005){
        sum[i+1]=sum[i]+a[i];
    }

    int q;
    cin>>q;
    while(q--){
        int l,r;
        cin>>l>>r;
        cout<<sum[r+1]-sum[l]<<endl;
    }

}


Measured memory_bytes: 4124
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
int h,n,sum=0,scan;
scanf("%d %d",&h,&n);
for(int count=0;count<n;count++){
scanf("%d",&scan);
sum=sum+scan;
}
if(h<=sum){printf("Yes");}
else{printf("No");}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define mkp make_pair
#define nl cout<<endl
#define MOD 1000000007
#define loop(i,start,end) for(ll i=start;i<end;i++)
#define all(v) v.begin(),v.end()
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define ov(a) for(int i=0;i<a.size();i++)cout<<a[i]<<" ";nl

unordered_map<string, int> lookup;
int count(int S[], int n, int N)
{
  if (N == 0)
    return 1;
  if (N < 0 || n < 0)
    return 0;

  string key = to_string(n) + "|" + to_string(N);
  if (lookup.find(key) == lookup.end())
  {
    int include = count(S, n, N - S[n]);

    int exclude = count(S, n - 1, N);
    lookup[key] = include + exclude;
  }
  return lookup[key];
}
int main() 
{
    fastio();


  int r,g,b,n;
  cin>>r>>g>>b>>n;
  int S[] = { r, g, b };
  cout << count(S, 2, n);
  return 0;
}


Measured memory_bytes: 1664
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes) if b else print(no)
# from collections import Counter,deque,defaultdict
import itertools
# import math
# import networkx
# from bisect import bisect_left,bisect_right
n=n0()
s=s0()
print(len(list(itertools.groupby(s))))

Measured memory_bytes: 15860
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll n = in();
	vector<ll>a(n); REP(i, n)scanf("%d", &a[i]);
	ll ans = 0;
	REP1(i, n) {
		if (i < a[i - 1] && a[a[i - 1] - 1] == i)++ans;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
int main(){
    long long a,b,k;
    cin >> a >> b >> k;
    if(k < a) cout << a-k << " " << b << endl;
    else if(k < a+b) cout << 0 << " " << b -(k-a) << endl;
    else cout << 0 << " " << 0 << endl;
    return 0;
}

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

int H, W;
char red[505][505], blue[505][505];

int main(void)
{
	cin >> H >> W;
	
	for(int x = 0; x < W; x++){
		for(int y = 0; y < H; y++){
			red[x][y] = blue[x][y] = '.';
		}
	}
	
	for(int x = 0; x < W; x++){
		red[x][0] = blue[x][H-1] = '#';
	}
	for(int x = 0; x < W; x++){
		for(int y = 1; y < H-1; y++){
			if(x % 2) red[x][y] = '#';
			else blue[x][y] = '#';
		}
	}
	
	char c;
	for(int y = 0; y < H; y++){
		for(int x = 0; x < W; x++){
			cin >> c;
			if(c == '#'){
				red[x][y] = blue[x][y] = '#';
			}
		}
	}
	
	for(int y = 0; y < H; y++){
		for(int x = 0; x < W; x++){
			cout << red[x][y];
		}
		cout << endl;
	}
	cout << endl;
	
	for(int y = 0; y < H; y++){
		for(int x = 0; x < W; x++){
			cout << blue[x][y];
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1280
import java.util.Scanner;
import java.io.*;

class Main{
	public static void main(String[] args){
		Scanner sc= new Scanner(System.in);
		String s = sc.next();
		int count = 0;
		for(int i = 0;i <3; i++){
			if(s.charAt(i) == 'o') count++;
		}
		System.out.println(700 + 100*count);
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
using namespace std;
double l,t;
int main(){
	scanf("%lf",&l);
	l/=3;
	t=l;
	t*=l;
	t*=l;
	printf("%.15f",t);
	return 0;
}

Measured memory_bytes: 256
//
/*==========================================================*/
/*    Template ver 2017-0720    |    Created by JollyBee    */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
const double EPS=(double)1e-9;
const double PI=(double)acos(-1.0);
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define FOR(i,n) for(int i=0;i<n;i++)
#define REPP(i,l,r,c) for(int i=l;i<=r;i+=c)
#define REP(i,l,r) REPP(i,l,r,1)
#define FORD(i,n) for(int i=n-1;i>=0;i--)
#define REVV(i,l,r,c) for(int i=l;i>=r;i-=c)
#define REV(i,l,r) REVV(i,l,r,1)
//random
int irand(int lo, int hi){
    return (((double)rand())/(RAND_MAX+1.0)) * (hi-lo+1) + lo;
}
//ll to string
string toString(ll x) {
    stringstream ss;
    ss << x;
    return ss.str();
}
//string to ll
ll toNumber(string S) {
    ll ret;
    sscanf(S.c_str(),"%lld",&ret);
    return ret;
}
// std::fill(start, end, value);
// for(auto it: DS){}

const int INF=(int)2e9;
const ll MOD=(ll)1e9+7;
/*==========================================================*/
/*                     END OF TEMPLATE                      */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/

int main(){
    int n,k; scanf("%d %d", &n, &k);
    int x,y; scanf("%d %d", &x, &y);
    int res = n * x - (x-y) * max(0, n-k);
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 1e9 + 7;
int INF = 2e18;

signed main() {
    int K, X;
    cin >> K >> X;
    for (int i = X - K + 1; i < X + K; i++) {
        if (i == X + K - 1) cout << i << endl;
        else cout << i << " ";
    }

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl

const int MAX_V = 200000;
vector<vector<int>> to(MAX_V);
vector<int> V, W;

void dfs(int v, int p, int c) {
  if(c == 0)
    V.push_back(v);
  else
    W.push_back(v);
  for(auto x : to[v]) {
    if(x == p) continue;
    dfs(x, v, 1 ^ c);
  }
  return;
}

int main() {
  int n;
  cin >> n;
  to.resize(n);
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  dfs(0, -1, 0);
  if(V.size() < W.size()) {
    vector<int> temp = V;
    V = W;
    W = temp;
  }

  vector<int> col(n);
  int c[3] = {3, 1, 2};
  if(W.size() <= n / 3) {
    int iV = 0;
    rep(i, n / 3 - W.size()) {
      col[V[iV++]] = c[0];
      c[0] += 3;
    }
    rep(i, n / 3) {
      col[V[iV++]] = c[1];
      c[1] += 3;
    }
    rep(i, n / 3) {
      col[V[iV++]] = c[2];
      c[2] += 3;
    }
    if(n % 3 != 0) col[V[iV++]] = c[1];
    if(n % 3 == 2) col[V[iV++]] = c[2];

    rep(iW, W.size()) {
      col[W[iW]] = c[0];
      c[0] += 3;
    }

  } else {
    int iV = 0;
    rep(i, n / 3) {
      col[V[iV++]] = c[1];
      c[1] += 3;
    }
    if(n % 3 != 0) col[V[iV++]] = c[1];
    for(; iV < V.size(); iV++) {
      col[V[iV]] = c[0];
      c[0] += 3;
    }

    int iW = 0;
    rep(i, n / 3) {
      col[W[iW++]] = c[2];
      c[2] += 3;
    }
    if(n % 3 == 2) col[W[iW++]] = c[2];
    for(; iW < W.size(); iW++) {
      col[W[iW]] = c[0];
      c[0] += 3;
    }
  }

  rep(i, n) printf("%d%c", col[i], i == n - 1 ? '\n' : ' ');
  return 0;
}

Measured memory_bytes: 21620
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i16,
        b: i16,
        c: i16,
    }
    
    if a == b && a != c || b == c && b != a || a == c && a != b {
        println!("Yes")
    } else {
        println!("No")
    }
}


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

int z(int x)
{
  if(x>=0)
    return x;
  else
    return x*-1;
}

int main()
{
  int n,a,b;
  cin>>n>>a>>b;
  vector<int> l(n-1);
  for(int i=0;i<n-1;i++)
  {
    l.at(i)=n-i-1;
  }
  for(int x=1;x<=n-1;x++)
  {
    for(int y=x+1;y<=n;y++)
    {
      if(y-x>z(a-x)+z(b-y)+1)
      {
        l.at(y-x-1)--;
        l.at(z(a-x)+z(b-y))++;
      }
    }
  }
  for(int i=0;i<n-1;i++)
  {
    cout<<l.at(i)<<endl;
  }
}

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

int main() {
  int r,g,b,s;
  cin>>r>>g>>b;
  s=r*100+g*10+b;
  if(s%4==0) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


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

int main()
{
	char b;
    cin >> b;
    
    if(b == 'A'){
    	puts("T");
    }else if(b == 'T'){
    	puts("A");
    }else if(b == 'C'){
    	puts("G");
    }else{
    	puts("C");
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i, j=0, n, k, h, f=0;
	scanf("%d %d", &n, &k);


	for (i = 0; i < n; i++)
	{
		scanf("%d", &h);
		if (h >= k)
		{
			j++;
		}
	}
	printf("%d", j);

	return 0;
}

Measured memory_bytes: 256
use std::io::Read;
use std::cmp::max;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let s: Vec<char> = iterator.next().unwrap().chars().collect();
    let t: Vec<char> = iterator.next().unwrap().chars().collect();

    let mut dp: Vec<Vec<usize>> = vec![vec![0; t.len() + 1]; s.len() + 1];
    for i in 0..s.len() {
        for j in 0..t.len() {
            if s[i] == t[j] {
                dp[i + 1][j + 1] = dp[i][j] + 1;
            } else {
                dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
            }
        }
    }

    let mut result = String::new();
    let mut i = s.len();
    let mut j = t.len();
    while dp[i][j] != 0 {
        if s[i - 1] == t[j - 1] {
            result = format!("{}{}", s[i - 1], result);
            i -= 1;
            j -= 1;
        } else if dp[i][j] == dp[i - 1][j] {
            i -= 1;
        } else {
            j -= 1;
        }
    }
    result
}


Measured memory_bytes: 72836