akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <map>
#include <cassert>
using namespace std;

const int MAXN = 502;
const int MAXL = 1000005;

int N, U[2], M;
int X[2][MAXL], Y[2][MAXL];
int tate[2][MAXN], yoko[2][MAXN], migishita[2], migiue[2];

int main() {
  while(cin >> N >> U[0] >> U[1] >> M) {
    if(N == 1) {
      U[0] *= 4;
      U[1] *= 4;
    }
    fill(X[0], X[2], -1);
    fill(Y[0], Y[2], -1);
    for(int k = 0; k < 2; ++k) {
      for(int i = 0; i < N; ++i) {
	for(int j = 0; j < N; ++j) {
	  int a;
	  cin >> a;
	  X[k][a] = j;
	  Y[k][a] = i;
	}
      }
    }

    fill(tate[0], tate[2], 0);
    fill(yoko[0], yoko[2], 0);
    fill(migishita, migishita+2, 0);
    fill(migiue, migiue+2, 0);
    string res = "";
    while(M--) {
      int a;
      cin >> a;
      if(res != "") continue;
      for(int k = 0; k < 2; ++k) {
	if(X[k][a] == -1) continue;
	U[k] -= ++tate[k][X[k][a]] == N;
	U[k] -= ++yoko[k][Y[k][a]] == N;
	if(X[k][a] == Y[k][a])
	  U[k] -= ++migishita[k] == N;
	if(X[k][a] == N-1-Y[k][a])
	  U[k] -= ++migiue[k] == N;
      }
      if(U[0] <= 0 || U[1] <= 0) {
	if(U[0] <= 0 && U[1] <= 0) res = "DRAW";
	else if(U[0] <= 0) res = "USAGI";
	else res = "NEKO";
      }
    }
    if(res == "") res = "DRAW";
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 16836
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq

x = ni()
tmp = 0
for i in range(1,10**9):
    tmp+=i
    if tmp>=x:
        break
print(i)


Measured memory_bytes: 9464
#include <bits/stdc++.h>
 
using namespace std;
 
#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;
 
const int MAXN = 500100, MAXK = 30;
const ll MOD = 998244353;
const int INF = 1e8;
const ld PI = asin(1) * 2;
 
void setIO () {
    FAST_IO;
}
 
void setIO (string s) {
    setIO();
 	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}
 
ll gcd (ll a, ll b) {
    return b == 0 ? a : gcd(b, a%b);
}
 
int main() {
	setIO();
 
    int k; cin >> k;
    ll sum = 0;
    FOR(a, 1, k) FOR(b, 1, k) FOR(c , 1, k) {
        sum += gcd(gcd(a,b),c);
    }
    cout << sum;
 
	return 0;
}
 
 

Measured memory_bytes: 3656
MOD = 10 ** 9 + 7
INF = 10 ** 11
import sys
sys.setrecursionlimit(100000000)

def main():
    n,m = map(int,input().split())
    ans = [[0]*2 for _ in range(m)]
    cnt = 1
    if n%2 == 1:
        for i in range(m):
            ans[i][0] = cnt
            cnt += 1
        for i in range(m - 1,-1,-1):
            ans[i][1] = cnt
            cnt += 1
        for i in range(m):
            print(*ans[i])
    else:
        for i in range(m):
            ans[i][0] = cnt
            cnt += 1
        cnt = n
        flag = True
        for i in range(m):
            if flag and cnt - ans[i][0] <= n//2:
                flag = False
                cnt -= 1
            ans[i][1] = cnt
            cnt -= 1
        for i in range(m):
            print(*ans[i])
if __name__ == '__main__':
    main()


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

bool flag[1000001];

int main(){
	for( int i = 0; i < 1000001; ++i ){
		flag[i] = false;
	}
	int s; cin >> s;
	flag[s] = true;
	int ans;
	for( int i = 2; i <= 1000000; ++i ){
		if( s % 2 == 0 ){
			s /= 2;
		} else {
			s = 3*s + 1;
		}
		if( flag[s] ){
			ans = i;
			break;
		}
		flag[s] = true;
	}
	cout << ans << endl;
	return 0;
}

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

const int N = 1300;
int main()
{
    char str[N];

    while (fgets(str, N, stdin))
    {
        for (int i = 0; i < strlen(str); i++)
        {
            if (str[i] >= 'A' && str[i] <= 'Z')
            {
                printf("%c", str[i] + 32);
            }
            else if (str[i] >= 'a' && str[i] <= 'z')
            {
                printf("%c", str[i] - 32);
            }
            else
            {
                printf("%c", str[i]);
            }
        }
    }
}


Measured memory_bytes: 2556
//
// Created by kuribohkute on 20/04/2019.
//
#include <iostream>
using namespace std;
#define mp make_pair
#define X first
#define Y second
int main () {
    int n;
    cin >> n;
    int pos1 = -1, pos2 = -1, val1 = -1, val2 = -1, cnt = 0;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        if (x != i) {
            cnt++;
            if (pos1 == -1) {
                pos1 = i;
                val1 = x;
            } else {
                pos2 = i;
                val2 = x;
            }
        }
    }
    if (cnt > 2 || cnt == 1) {
        cout << "NO\n";
    } else {
        if (pos1 == val2 && val1 == pos2) {
            cout << "YES";
        } else {cout << "NO";};
        
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
using P = pair <int, int>;
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; }
ll gcd(ll a,ll b) {return  b ? gcd(b,a%b) : a;}
const long long INF = 1LL << 60;
const int mod = 1000000007;
const double PI = acos(-1.0);
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


main(){
    ll n,m;
    cin >> n >> m;
    vector<ll> a(n);
    rep(i,n)cin >> a[i];
    vector<ll> d(n);
    vector<ll> s(n);
    s[0]=a[0];
    rep(i,n-1){
         s[i+1] = s[i]+a[i+1];
    }
    rep(i,n){
         d[i]=s[i]%m;
    }
    map<ll,ll>mp;
    rep(i,n){
         mp[d[i]]++;
    }
    ll ans = 0;
    for(auto x :mp){
         if(x.first == 0) ans+=x.second;
         if(x.second >=2 ) {
              ans += x.second*(x.second-1)/2;
         }
    }
    cout << ans <<endl;
}


Measured memory_bytes: 9476
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int tax1 = sc.nextInt();
        int tax2 = sc.nextInt();
        double tmp1 = -1;
        double tmp2 = 0;
        int counter = -1;
        for(int i = 1;i < 1009;i++){
            tmp1 = i * 0.08;
            tmp1 = Math.floor(tmp1);
            //System.out.println(tmp1);
            tmp2 = i * 0.1;
            tmp2 = Math.floor(tmp2);
            if(tmp1 == tax1 && tmp2 == tax2){
                System.out.println(i);
                counter++;
                break;
            }
        }
        if(counter == -1){
            System.out.println(counter);
        }
    }
}

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

using namespace std;

typedef long long ll;

const ll MOD = 998244353;
const ll MAXN = 300010;

ll fact[MAXN+1], rev_fact[MAXN+1];

// 二分累乗法により、x^n %mod を求める
ll mod_pow(ll x, ll n){
  if (n == 0) return 1;
  ll res = mod_pow(x * x %MOD, n / 2);
  // nが奇数の場合, x^n = ((x^2)^(n/2)) * x
  if(n & 1) return res = res * x %MOD;
  // nが偶数の場合、x^n = (x^2)^(n/2)
  return res %MOD;
}

// nCk = n! / (n - k)!k!
ll comb(ll n, ll k){
    ll res = 1;
    k = min(n - k, k);
    res = (((fact[n] * rev_fact[n - k]) %MOD) * rev_fact[k]) %MOD;
    return res;
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n, a, b, k; cin >> n >> a >> b >> k;
    ll ans = 0;
    fact[0] = fact[1] = 1;
    rev_fact[0] = rev_fact[1] = 1;
    for(int i=1;i<=n;i++){
        fact[i] = (fact[i-1] * i) %MOD;
    }
    for(int i=1;i<=n;i++){
        rev_fact[i] = (rev_fact[i-1] * mod_pow(i, MOD-2)) %MOD;
    }
    // red
    for(ll cr = 0;cr <= n;cr++){
        if((k - a * cr) < 0 || (k - a * cr) % b) continue;
        ll cb = (k - a * cr) / b;
        if(cb > n) continue;
        ans = (ans + (comb(n, cr) * comb(n, cb)) %MOD) %MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
use std::io::{stdin, Read};

fn main() {
    let v = get_param();
    println!("{}", solve(v[0], v[1], v[2], v[3]));
}

fn get_param() -> Vec<i32> {
    let mut s = String::new();
    stdin().read_to_string(&mut s).ok();
    s.split_whitespace().map(|x| x.parse().unwrap()).collect()
}

fn solve(a: i32, b: i32, c: i32, x: i32) -> usize {
    let mut count = 0;
    for a in 0..a + 1 {
        for b in 0..b + 1 {
            for c in 0..c + 1 {
                if exact(a, b, c, x) {
                    count += 1;
                }
            }
        }
    }
    count
}

fn exact(a: i32, b: i32, c: i32, x: i32) -> bool {
    500 * a + 100 * b + 50 * c == x
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();
        System.out.println(Sosu(n));
    }

    public static long Sosu(long n) {
        for (long i = 2; i < n; i++) {
            if (n % i == 0) {
                i=1;
                n = n + 1;
            }
        }
        return n;
    }
}

Measured memory_bytes: 35684
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	String fileName = "prizes";

	public void solve() throws IOException {
		int[][] c = new int[3][3];
		for (int i = 0; i < 3; i++)
			for (int j = 0; j < 3; j++)
				c[i][j] = nextInt();
		int[] a = new int[3];
		int[] b = new int[3];
		for (int i = 0; i < 3; i++) {
			a[i] = c[i][0];
			for (int j = 1; j < 3; j++)
				a[i] = Math.min(a[i], c[i][j]);
		}
		for (int i = 0; i < 3; i++)
			for (int j = 0; j < 3; j++)
				c[i][j] -= a[i];
		boolean ans = true;
		for (int j = 0; j < 3; j++) {
			for (int i = 1; i < 3; i++)
				if (c[i][j] != c[i - 1][j])
					ans = false;
		}
		if (ans)
			out.println("Yes");
		else
			out.println("No");
	}

	public void run() {
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out, true);
			solve();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	BufferedReader br;
	StringTokenizer in;
	static PrintWriter out;

	public String nextToken() throws IOException {
		while (in == null || !in.hasMoreTokens()) {
			in = new StringTokenizer(br.readLine());
		}
		return in.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

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

}

Measured memory_bytes: 22996
#include <stdio.h>

#define MAX 100005
#define NIL -1

typedef struct {
    int parent;
    int left;
    int right;
} Node;

Node T[MAX];
int n;

void printChildren(int u) {
    int c = T[u].left;
    while (c != NIL) {
        printf("%d", c);
        c = T[c].right;
        if (c != NIL) printf(", ");
    }
}

void printLocation(int u) {
    if (T[u].parent == NIL) printf("root, ");
    else if (T[u].left == NIL) printf("leaf, ");
    else printf("internal node, ");
}

void printDepth(int u) {
    int depth = 0;
    while (T[u].parent != NIL) {
        u = T[u].parent;
        depth++;
    }

    printf("depth = %d, ", depth);
}

void printParent(int u) {
    printf("parent = %d, ", T[u].parent);
}

void printNodeID(int u) {
    printf("node %d: ", u);
}

void printTree(int u) {
    printNodeID(u);
    printParent(u);
    printDepth(u);
    printLocation(u);
    printf("[");
    printChildren(u);
    printf("]\n");
}

int main() {
    /// count of nodes
    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        T[i].parent = NIL;
        T[i].left = NIL;
        T[i].right = NIL;
    }

    int id, degree, c, l;
    for (int i = 0; i < n; i++) {
        scanf("%d %d", &id, &degree);

        for (int j = 0; j < degree; j++) {
            scanf("%d", &c);

            if (j) T[l].right = c;
            else T[id].left = c;
            T[c].parent = id;

            l = c;
        }
    }

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

    return 0;
}



Measured memory_bytes: 2900
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk)
{

var x= chunk.toString().split(' ');
 x[0] = Number(x[0]);
 x[1] = Number(x[1]);
 x[2] = Number(x[2]);
x.sort();


console.log(x[0]+" "+x[1]+" "+x[2]);

});

Measured memory_bytes: 15488
#include <iostream>
#include <string>

using std::cin;
using std::cout;
using std::endl;
using std::string;

constexpr int L = 13;
constexpr int M = 244140624 / L;

bool isExist[M][L] = {{false}};

void insert(string in_str);
bool find(string target_str);

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

    string op;
    string word_str;

    while (op_num--) {
        cin >> op >> word_str;
        if (op == "insert") {
            insert(word_str);
        } else if (op == "find") {
            cout << (find(word_str)? "yes": "no") << endl;
        } else {
            cout << "ERROR!" << endl;
        }
    }

    return 0;
}

int char2int(char in);
int str2int(string in_str);

int hashFunc1(int in);
int hashFunc2(int in);

void insert(string in_str)
{
    if (!find(in_str)) {
        int in_int = str2int(in_str);
        int hash1 = hashFunc1(in_int);
        int hash2 = hashFunc2(in_int);
        isExist[hash1][hash2] = true;
    }
}

int char2int(char in)
{
    if (in == 'A') {
        return 1;
    } else if (in == 'C') {
        return 2;
    } else if (in == 'G') {
        return 3;
    } else if (in == 'T') {
        return 4;
    } else {
        cout << "ERROR!" << endl;
        return -1;
    }
}

int str2int(string in_str)
{
    int p = 1;
    int in_int = 0;
    for (auto i = 0; i < in_str.size(); i++) {
        in_int += p * char2int(in_str.at(i));
        p *= 5;
    }

    return in_int;
}

int hashFunc1(int in)
{
    return (in % M);
}

int hashFunc2(int in)
{
    return (in % L);
}

bool find(string target_str)
{
    int target_int = str2int(target_str);
    int hash1 = hashFunc1(target_int);
    int hash2 = hashFunc2(target_int);
    return isExist[hash1][hash2];
}

Measured memory_bytes: 108924
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <math.h>
#include <bitset>

using namespace std;
using ll = long long;
int main(int argc, const char *argv[])
{
    ll n;
    cin >> n;
    ll a, b, ans = 10000000000;
    for (ll i = 1; i <= n / i; i++)
    {
        if (n % i == 0)
        {
            a = to_string(i).length();
            b = to_string(n / i).length();

            if (max(a, b) < ans)
            {
                ans = max(a, b);
                //cout << i << " " << n / i << " " << ans << endl;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==1)
    {
        cout<<"YES"<<endl;
        return 0;
    }
    for(int i=1;i<=100;i++)
    {
        if(a*i%b==c)
        {
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
int main(){
    int a,b,c,d,ans=0;
    scanf("%d %d %d",&a,&b,&c);
    for(int i=0;i<a;++i){
        scanf("%d",&d);
        if(d<b||d>=c) ++ans;
    }
    printf("%d\n",ans);
}

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

int main()
{
  int m,n,sum=0;
  cin>>m>>n;
  if(m>1)
  {
    sum+=m*(m-1)/2;
  }
  if(n>2)
  {
	sum+=n*(n-1)/2;
  }
  cout<<sum;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <set>

using namespace std;
using ll = long long;
const int MOD = 1000000007;
const ll INF = 1LL << 60;

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

vector<vector<int> > vvi;
vector<vector<vector<int> > > vvvi;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }


int main(int argc, char**argv){
    int n, m, X, Y;
    cin >> n >> m >> X >> Y;
    vector<int> x(n), y(m);
    int max_x = -101;
    for (int i = 0; i < n; i++) {
        cin >> x[i];
        chmax(max_x, x[i]);
    }
    int min_y = 101;
    for (int i = 0; i < m; i++) {
        cin >> y[i];
        chmin(min_y, y[i]);
    }
    if (X < Y && max_x < min_y && X < min_y && max_x < Y) cout << "No War" << endl;
    else cout << "War" << endl;

    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
ans=0

for i,s in enumerate(a) :
    if i > n-2:
      break
    if a[i] > a[i+1] :
        ans = ans + ( a[i] - a[i+1] )
        a[i+1] = a[i]
        
print(ans)

Measured memory_bytes: 32144
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
#define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() 
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    ll n;
    cin>>n;
    ll a[n+1];
    ll dp[n+1];
    dp[0]=0;
    for (int i = 1; i<=n; ++i)
    {
        cin>>a[i];
        dp[i]=0;
    }

    dp[2]=abs(a[2]-a[1]);
    for (int i=3; i<=n; ++i)
    {
        dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n];

    return 0;
}

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

int main() {
	int N, M;
	cin >> N >> M; 
	std::priority_queue<int> que;
	for (int n = 0;n<N;++n) {
		int num;
		cin >> num;
		que.push(num);
	}
	for (int n = 0;n<M;++n) {
		int num = que.top();
		que.pop();
		que.push(num/2);
	}
	long long ans = 0;
	for (int n = 0; n < N; ++n) {
		ans += que.top(); 
		que.pop();
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3872
#include<iostream>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  int d[101]={};
  int i,j,l,m;
  int a,b;
  for(i=0;i<n;i++){
    cin >> a >> b;
    d[a-1]=b;
  }
  int dp[101][4][4]={{{}}};
  if(d[0]!=0){
    dp[0][0][d[0]]=1;
  }else{
    dp[0][0][1]=1;
    dp[0][0][2]=1;
    dp[0][0][3]=1;
  }
  for(i=1;i<n;i++){
    for(j=0;j<4;j++){
      for(l=1;l<4;l++){
        if(d[i]!=0){
          if(!(j==l&&l==d[i]))
          dp[i][l][d[i]]+=dp[i-1][j][l]%10000;
        }else{
          for(m=1;m<4;m++){
            if(j==l&&l==m) continue;
             
            dp[i][l][m]+=dp[i-1][j][l]%10000;
          }
        }
      }
    }
  }
  int o=0;
  for(j=0;j<4;j++){
    for(l=0;l<4;l++){
      o+=dp[n-1][j][l];
    }
  }
  cout << o%10000 << endl;
  return 0;
}

Measured memory_bytes: 1164
List=list(input())
result = []
if List[0] == "0":
    result.append("0")
    for i in range(1,len(List)):
        if(i%2==0):
            result.append("0")
        else:
            result.append("1")
elif List[0] == "1":
    result.append("1")
    for i in range(1,len(List)):
        if(i%2==0):
            result.append("1")
        else:
            result.append("0")
count = 0
for i in range(len(List)):
    if(List[i]!=result[i]):
        count = count + 1
print(count)


Measured memory_bytes: 4780
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;

typedef long long ll;

ll mod = 1e9 + 7;
int a[100003];
ll dp[103][100003], s[100003];

int main() {
	int N, K; cin >> N >> K;
	for (int i = 1; i <= N; i++) cin >> a[i];
	dp[0][0] = 1;
	for (int i = 1; i <= N; i++) {
		s[0] = dp[i - 1][0];
		for (int j = 1; j <= K; j++) s[j] = (s[j - 1] + dp[i - 1][j])%mod;
		for (int j = 0; j <= K; j++) {
			if (j - a[i] - 1 < 0) dp[i][j] = s[j];
			else dp[i][j] = (s[j] - s[j - a[i] - 1] + mod) % mod;
		}
	}
	cout << dp[N][K] << endl;
	return 0;
}

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

int n,X[200005],Y[200005];
char D[200005];
vector<pair<int,int>> RP,LP;
map<int,set<int>> RL,LL;
vector<int> LR[200005],RR[200005],UC[200005],DC[200005];

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>X[i]>>Y[i]>>D[i];
        int &x=X[i],&y=Y[i];
        char &d=D[i];
        if(d=='U'){
            UC[x].emplace_back(y);
            LL[y-x].insert(y);
            RL[x+y-1919810].insert(y);
        }
        if(d=='D'){
            DC[x].emplace_back(y);
            LL[x+y-1919810].insert(y);
            RL[y-x].insert(y);
        }
        if(d=='R'){
            RR[y].emplace_back(x);
            RP.emplace_back(x,y);
        }
        if(d=='L'){
            LR[y].emplace_back(x);
            LP.emplace_back(x,y);
        }
    }
    int ans=1e9;
    for(int r=0;r<200000;r++){
        sort(LR[r].begin(),LR[r].end());
        LR[r].emplace_back(1919810);
        sort(RR[r].begin(),RR[r].end());
        for(int &x:RR[r]){
            int y=*lower_bound(LR[r].begin(),LR[r].end(),x);
            if(y!=1919810)ans=min(ans,(y-x)*5);
        }
    }
    for(int c=0;c<200000;c++){
        sort(UC[c].begin(),UC[c].end());
        sort(DC[c].begin(),DC[c].end());
        DC[c].emplace_back(1919810);
        for(int &x:UC[c]){
            int y=*lower_bound(DC[c].begin(),DC[c].end(),x);
            if(y!=1919810)ans=min(ans,(y-x)*5);
        }
    }
    for(pair<int,int> &px:RP){
        int y;
        if(RL.find(px.second-px.first)!=RL.end() && RL[px.second-px.first].lower_bound(px.second)!=RL[px.second-px.first].end()){
            y=*RL[px.second-px.first].lower_bound(px.second);
            ans=min(ans,(y-px.second)*10);
        }
        if(RL.find(px.second+px.first-1919810)!=RL.end() && RL[px.second+px.first-1919810].upper_bound(px.second)!=RL[px.second+px.first-1919810].begin()){
            y=*(--RL[px.second+px.first-1919810].upper_bound(px.second));
            ans=min(ans,(px.second-y)*10);
        }
    }
    for(pair<int,int> &px:LP){
        int y;
        if(LL.find(px.second-px.first)!=LL.end() && LL[px.second-px.first].upper_bound(px.second)!=LL[px.second-px.first].begin()){
            y=*(--LL[px.second-px.first].upper_bound(px.second));
            ans=min(ans,(px.second-y)*10);
        }
        if(LL.find(px.second+px.first-1919810)!=LL.end() && LL[px.second+px.first-1919810].lower_bound(px.second)!=LL[px.second+px.first-1919810].end()){
            y=*LL[px.second+px.first-1919810].lower_bound(px.second);
            ans=min(ans,(y-px.second)*10);
        }
    }
    if(ans==1e9)cout<<"SAFE";
    else cout<<ans;

    return 0;
}

Measured memory_bytes: 95368
#include "bits/stdc++.h"
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define debug(var) std::cout << #var << " : " << var;

using Graph = std::vector<std::vector<int>>;

int main() {

	int N,M; std::cin >> N >> M;
	Graph G(N);
	rep(i,M){
		int u,v; std::cin >> u >> v;
		G[u - 1].push_back(v - 1);
	}
	int S,T; std::cin >> S >> T;
	S--; T--;

	std::vector<std::array<int,3>> memo(N,{-1,-1,-1});
	memo[S][0] = 0;
	std::queue<std::pair<int,int>> q;
	q.push(std::make_pair(S,0));

	while(!q.empty()){

		auto cur = q.front();
		q.pop();

		for(auto& v : G[cur.first]){

			int tmp = ((cur.second) + 1) % 3;
			if(memo[v][tmp] != -1)continue;
			memo[v][tmp] = memo[cur.first][cur.second] + 1;
			q.push(std::make_pair(v,tmp));

		}

	}

	int ans = memo[T][0];

	if(ans != -1)ans /= 3;

	std::cout << ans;

	return 0;

}


Measured memory_bytes: 6912
#include <iostream>
#include <iomanip>
#include <cmath>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define FOR(i,a,n) for(int i = (a);i < (n);i++)
double PI = acos(-1);
const double EPS = 1e-10;
const double INF = 1e9;
using namespace std;

int N,M,L;

struct Point{
    double x,y;
    Point operator - (const Point& p){ return Point{x-p.x,y-p.y};}
};

struct Segment{
    Point p1,p2;
};

double norm(Point a){return a.x*a.x+a.y*a.y;}
double abs(Point a){return sqrt(norm(a));}
double dot(Point a, Point b){return a.x * b.x + a.y * b.y;}
double cross(Point a,Point b){return a.x*b.y - a.y*b.x;}

int ccw(Point p1,Point p2,Point p3){
    Point a = {p2.x-p1.x, p2.y - p1.y};
    Point b = {p3.x-p1.x, p3.y - p1.y};
    if(cross(a,b) > EPS) return 1;
    if(cross(a,b) < -EPS) return -1;
    if(dot(a,b) < -EPS) return 2;
    if(norm(a) < norm(b)) return -2;
    return 0;
}

bool intersect(Point p1, Point p2, Point p3, Point p4){
    return ccw(p1,p2,p3)*ccw(p1,p2,p4) <= 0 && ccw(p3,p4,p1)*ccw(p3,p4,p2) <= 0;
}

bool intersect(Segment s1, Segment s2){
    return intersect(s1.p1,s1.p2, s2.p1, s2.p2);
}

double getDistSP(Segment s, Point p){
    if(dot(s.p2 - s.p1, p - s.p1) < -EPS) return abs(p - s.p1);
    if(dot(s.p1 - s.p2, p - s.p2) < -EPS) return abs(p - s.p2);
    return abs(cross(s.p2 - s.p1, p - s.p1) / abs(s.p2 - s.p1));
}
    

Segment star[102][5];
double mindist[102][102];



double getdist(int u, int v){
    REP(i,5){
        REP(j,5){
            if(intersect(star[u][i],star[v][j])){
                    return 0;
            }
        }
    }
    double ans = INF;
    REP(k,2){
        if(k) swap(u,v);
        REP(i,5){
            REP(j,5){
                ans = min(getDistSP(star[u][i],star[v][j].p1),ans);
            }
        }
    }
    return ans;
}

int main(){
    while(cin>>N>>M>>L,N){
        REP(i,N){
            int x,y,a,r;
            cin>>x>>y>>a>>r;
            Point p[5];
            REP(j,5) p[j] = Point{x + r*sin((double)(72*j - a)/180*PI), y + r*cos((double)(72*j - a)/180*PI)};//star's vertex
            REP(j,5){
                star[i][j] = Segment{p[j], p[(j+2)%5]};
            }
        }

        //caluculate min distance
        REP(i,N){
            FOR(j,i,N){
                mindist[i][j] = mindist[j][i] = getdist(i,j);
            }
        }

        //WF        
        REP(k,N){
            REP(i,N){
                REP(j,N){
                    mindist[i][j] = min(mindist[i][j], mindist[i][k] + mindist[k][j]);
                }
            }
        }
        cout << fixed << setprecision(8) << mindist[M-1][L-1] << endl;
    }
}

Measured memory_bytes: 3608
n = gets.chomp.to_i
input = []
n.times do
	input << gets.chomp.to_i
end
max=nil;min=10000000000;
input.each do |ele|
	max = ele - min if max == nil || ele - min > max
	min = ele       if min == nil || min > ele
end

puts "#{max}"

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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;
  vector<ll> vl(n);
  for (int i = 0; i < n; ++i) {
    cin >> vl[i];
  }

  int cnt = 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) {
        int a = vl[i], b = vl[j], c = vl[k];
        if (a == b || b == c || a == c) {
          continue;
        }

        if (a + b > c && b + c > a && c + a > b) {
          cnt++;
        }
      }
    }
  }

  cout << cnt << '\n';
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#define Z (2<<17)
using namespace std;
const long mod=998244353;
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
long fac[Z],inv[Z],ans,N,M,K;
int main()
{
	fac[0]=1;
	for(int i=1;i<Z;i++)fac[i]=fac[i-1]*i%mod;
	inv[(Z)-1]=power(fac[Z-1],mod-2);
	for(int i=Z-1;i--;)inv[i]=inv[i+1]*(i+1)%mod;
	cin>>N>>M>>K;
	for(int L=0;L<=K;L++)ans+=fac[N-1]*inv[N-1-L]%mod*inv[L]%mod*M%mod*power(M-1,N-L-1)%mod;
	cout<<ans%mod<<endl;
}


Measured memory_bytes: 7732
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod 1000000007 
int p[100001];
int32_t main()
{
    fast;
    int n;
    cin>>n;
    map<pair<int ,int > ,int > m;
    for(int i=1;i<=n;i++)
    {
    	int p=i;
    	int x=p%10;
    	while(p>=10)
    	{
    		p/=10;
    	}
    	int y=p;
    	//cout<<p<<" ";
    	m[{y,x}]++;
     }
    // for(int i=1;i<=9;i++)
    // {
    // 	m[{i,i}]++;
    // }
    int ans=0;

    for(int i=1;i<=9;i++)
    {
    	for(int j=1;j<=9;j++)
    	{
    			ans+=m[{i,j}]*(m[{j,i}]);
       	}
    }
    cout<<ans;

}

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

using namespace std;

#define ll long long 
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ff first
#define ss second
#define endl "\n"
#define MOD 1000000007
#define MOD1 998244353
#define inf 1e18

ll GCD(ll x,ll y){if(y==0)return x;return GCD(y,x%y);}
ll LCM(ll x,ll y){return (x*y)/(GCD(x,y));}
ll LOGK(ll x,ll k){if(x>=k)return 1+LOGK(x/k,k);return 0;}
ll MPOW( ll a, ll b, ll m) { if(b==0) return 1; ll x=MPOW(a,b/2,m); x=(x*x)%m; if(b%2==1) x=(x*a)%m; return x;}
ll MINV(ll a,ll m) {return MPOW(a,m-2,m);}

class pnc{
  ll FACT_MAX,MODU;
  vector<ll> fact;
public:
  pnc( ll n, ll m) { FACT_MAX = n; fact.resize(FACT_MAX); MODU = m; MFACT_INIT(MODU);}
  void MFACT_INIT( ll m) { fact[0]=1; for(ll i=1;i<FACT_MAX;++i) fact[i]=(i*fact[i-1])%MODU;}
  ll MFACT( ll n) { return fact[n];}
  ll PERM( ll n, ll r) { return (fact[n]*::MINV(fact[n-r],MODU))%MODU;}
  ll COMB( ll n , ll r) { return (PERM(n,r)*::MINV(fact[r],MODU))%MODU;}
};

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

    ll test=1;
    // cin>>test;
    while(test--)
    {
        ll n;
        cin>>n;
        ll ar[n];

        for(ll i=0;i<n;i++)
        cin>>ar[i];

        ll ans=0;

        for(ll i=0;i<n;i++)
        {
            if(i%2==0)
            {
                if(ar[i]%2==1)
                ans++;
            }
        }

        cout<<ans;
    }
}

Measured memory_bytes: 3636
using System;

namespace ABC053
{
    class B
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int count = 0;
            int a = 0;
            bool isFirst = true;
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == 'A' && isFirst) { a = i; isFirst = false; }
                if (s[i] == 'Z') { count = (i - a) + 1; }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11616
import Data.List
import Data.Maybe

main = do
  s <- readLn :: IO Int
  print $ collatz s 1 [] 

collatz :: Int -> Int -> [(Int,Int)] -> Int
collatz s i xs 
  | isJust $ f s xs = i+1
  | otherwise = collatz (m s) (i+1) ((i,s):xs)
  where 
    m n = if even n then n`div`2 else 3*n+1
    f n xs = find (\x -> snd x == (m n)) xs

Measured memory_bytes: 508
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		byte[] abc = new byte[3];
		
		for (int i = 0; i < abc.length; i++) {
			abc[i] = sc.nextByte();
		}
		
		int count = 0;
		
		while (abc[0] <= abc[1] && count < abc[2]) {
			abc[1] -= abc[0];
			++count;
		}
		
		System.out.println(count);
	}
}


Measured memory_bytes: 24276
x=int(input())

if 400 <= x and x <= 599:
    print('8') 
elif 600 <= x and x <= 799:
    print('7')
elif 800 <= x and x <= 999:
    print('6')
elif 1000 <= x and x <= 1199:
    print('5')
elif 1200 <= x and x <= 1399:
    print('4')
elif 1400 <= x and x <= 1599:
    print('3')
elif 1600 <= x and x <= 1799:
    print('2')
else:
    print('1')

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

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

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = nextInt(scanner);
        int x = nextInt(scanner);
        int t = nextInt(scanner);
        int div = n / x;
        int mod = n % x;
        if (mod != 0) {
            div++;
        }
        System.out.println(div *t);
    }


    private static int nextInt(Scanner scanner) {
        return Integer.parseInt(scanner.next());
    }

    private static long nextLong(Scanner scanner) {
        return Long.parseLong(scanner.next());
    }

    private static float nextFloat(Scanner scanner) {
        return Float.parseFloat(scanner.next());
    }

    private static double nextDouble(Scanner scanner) {
        return Double.parseDouble(scanner.next());
    }


}









Measured memory_bytes: 35596
IDENTIFICATION DIVISION.
PROGRAM-ID. 164A.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP        PIC X(10).
01 S          PIC 9(3).
01 W          PIC 9(3).
*>
PROCEDURE DIVISION.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ' '
      INTO S W.
*>
  IF (W >= S)
    DISPLAY 'unsafe'
  ELSE
    DISPLAY 'safe'
  END-IF.
*>
  STOP RUN.


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

int main() {
long long a,b,c;
cin >> a >> b >>c;
long double sahen=a+b-c;
long double uhenn=2*sqrtl(a*b);
if(sahen+uhenn<0){cout << "Yes";}
else{cout << "No";}
}


Measured memory_bytes: 256
seq = []
res = []
def f(n, lim):
    if n == 0:
        res.append(''.join(chr(c+97) for c in seq))
        return
    for i in range(lim):
        seq.append(i)
        f(n-1, lim)
        seq.pop()
    seq.append(lim)
    f(n-1, lim+1)
    seq.pop()

f(int(input()), 0)
print('\n'.join(res))





Measured memory_bytes: 15128
#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++)
#define pi 3.14159265359
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;

ll triplets(ll x){
  ll count=0;
  for(int i=1;i<=100;i++){
    for(int j=1;j<=100;j++){
      for(int k=1;k<=100;k++){
        ll v=i*i+j*j+k*k+i*j+j*k+k*i;
        if(v==x){
          count++;
        }
      }
    }
  }
  return count;
}


int main() {
  ll N;
  cin>>N;
  
  vl ans(10010,0);
  cin>>N;
  for(int i=1;i<=100;i++){
    for(int j=1;j<=100;j++){
      for(int k=1;k<=100;k++){
        int v=i*i+j*j+k*k+i*j+j*k+k*i;
        if(v<=10000) ans[v]++;
      }
    }
  }
  for(int i=1;i<=N;i++){
    cout<<ans[i]<<endl;
  }
}


Measured memory_bytes: 3668
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))

c = 0
for i in range(h):
    ans = []
    for j in range(w):
        ans.append(str(c + 1))
        a[c] -= 1
        if a[c] == 0:
            c += 1

    if i % 2 == 0:
        print(' '.join(ans))
    else:
        print(' '.join(ans[::-1]))


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

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

    vector<int> l(n);
    for ( int i = 0 ; i < n ; i++ ){
        cin >> l.at(i);
    }
    sort(l.begin(),l.end(),greater<int>());

    int ans = 0;
    for ( int i = 0 ; i < k ; i++ ){
        ans += l.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int city[4];
int main() {
    int a[3], b[3];
    for (int i=0; i<3; i++) {
        cin >> a[i] >> b[i];
        city[a[i]-1]++;
        city[b[i]-1]++;
    }

    int odd = 0;
    for (int i=0; i<4; i++) {
        if (city[i] % 2 == 1) odd++;
    }
    if (odd <= 2) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

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

int main() {
    unsigned long long int A,B,N;
   cin >> A >> B >> N;
  if(A == 0 || A % N == 0) {
  cout << B / N - A / N + 1<< endl;
  }
  else{
    cout << B / N - A / N << endl;
  }
}
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define speed ios::sync_with_stdio(false)
#define pb push_back
#define mp make_pair
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define all(x) (x).begin(), (x).end()
#define uint usigned int
typedef vector <pair<char , ll>> vi;
ll MOD = 1e9+7;
//vi v1[200005],v2;
//bool visit[200005]={false};
/*void bfs(ll n){
    queue<ll> q;
    q.push(n);
    visit[n]=true;
    while(!q.empty()){
        ll t=q.front();
        q.pop();
        v2.pb(t);
        for(ll i=0;i<v1[t].size();i++){
            if(visit[v1[t][i]]==false){
                q.push(v1[t][i]);
                visit[v1[t][i]]=true;
            }
        }
    }
}*/
/*void dfs(ll n){
    for(ll i=0;i<v1[n].size();i++)
    {
        ll y=v1[n][i];
        if(visit[y]==0)
        {
            v2.pb(y);
            visit[y]=1;
            dfs(y);
        }
    }
}*/

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
    ll n,i,h,j,r,c1=0,c2=0,ans,error=0;
    cin>>n;
    string s[n];
    for(i=0;i<n;i++){
        cin>>s[i];
        j=s[i].length();
        if(s[i][0]=='B') c1++;
        if(s[i][j-1]=='A') c2++;
        if(s[i][0]=='B' && s[i][j-1]=='A') error++;
    }
   ans=min(c1,c2);
   if(error==c1 && c1==c2 &&error!=0) ans--;
    for(i=0;i<n;i++){
        j=s[i].length();
        for(r=0;r<j-1;r++){
            if(s[i][r]=='A' && s[i][r+1]=='B') ans++;
        }
    }
    cout<<ans;
    return 0; 
}



Measured memory_bytes: 768
use std::io::*;
use std::str::FromStr;
use std::cmp;


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)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $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, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }
 
 

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")
}


fn main() {
    input!{
        A: u64,
        B: u64,
        C: u64,
        X: u64
    }
    let mut ans = 0;
    
    for a in 0..A+1{
    	for b in 0..B+1{
        	for c in 0..C+1{
            	if (X == 500*a + 100*b + 50*c){
                	ans += 1;
                }
            }
        }
    }
    
    println!("{}",ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;

int main(){
  int a,b,c,x;
  cin >> a >> b >> c >> x;
  int c500 = x / 500;
  int ans = 0;
  for(int i = 0; i <= c500 && i <= a; i++){
    int tmp = x - 500 * i;
    tmp = tmp / 100;
    for(int j = 0; j <= tmp && j <= b; ++j){
      int tmp2 = (x - 500 * i - 100 * j)/50;
      if(tmp2 <= c) ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void)
{
    int K,i=0;
    string S;
  cin >> K;
  cin >> S;
    if(K>=S.size()){
      cout << S;
    }
    else{
      while(K>i){
        cout << S[i];
        i++;
      }
      cout << "...";
    }
  return 0;
}
    

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

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

    vector<int> h(N);
    for (int i = 0; i < N; i++)
    {
        cin >> h[i];
    }

    vector<int> ans(N, INT_MAX);
    ans[0] = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = 1; (j <= K) && ((i + j) < N); j++)
        {
            ans[i + j] = min(ans[i + j], ans[i] + abs(h[i] - h[i + j]));
        }
    }
    cout << ans.back() << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
vector<int> graph[100000];
vector<int> block[100000];
int label[100000] = {0};
void dfs(int node, int la) {
	if (label[node] != 0)
		return;
	label[node] = la;
	for (auto nn : graph[node]) {
		dfs(nn, la);
	}
	return;
}
int main() {
	int n, m, k;
	cin >> n >> m >> k;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	for (int i = 0; i < k; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		block[a].push_back(b);
		block[b].push_back(a);
	}
	for (int i = 0; i < n; i++) {
		dfs(i, i + 1);
	}
	map<int, int> cnt;
	for (int i = 0; i < n; i++) {
		cnt[label[i]]++;
	}
	for (int i = 0; i < n; i++) {
		int ans = cnt[label[i]] - 1;
		ans -= graph[i].size();
		for (auto v : block[i]) {
			if (label[v] == label[i]) {
				ans--;
			}
		}
		if (i == 0)
			cout << ans;
		else
			cout << " " << ans;
	}
	cout << endl;
	return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n;
  cin >> n;
  vll p(n);
  REP(i, n)
    cin >> p[i];

  ll m = INF;
  ll ans = 0;
  REP(i, n){
    if(m>p[i]){
      ans++;
      m = p[i];
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int d = a / b;
		int r = a % b;
		//float f = a / b;
		double f = (double)a / (double)b;
		System.out.print(d + " " + r + " ");
     	System.out.printf("%1.5f", f);
	}
}

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

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

    vector<pair<int, int>> edges(M);
    for (int i = 0; i < M; i++)
    {
        int a, b;
        cin >> a >> b;
        a--; b--;
        edges[i] = {a, b};
    }
    reverse(begin(edges), end(edges));

    vector<bool> self_consistent(N, true);
    vector<vector<bool>> x(N, vector<bool>(N));
    for (int i = 0; i < N; i++)
    {
        x[i][i] = true;
        for (const auto e : edges)
            if (x[i][e.first] && x[i][e.second])
                self_consistent[i] = false;
            else if (x[i][e.first])
                x[i][e.second] = true;
            else if (x[i][e.second])
                x[i][e.first] = true;
    }

    int result = 0;
    for (int i = 0; i < N; i++)
        for (int j = i+1; j < N; j++)
            if (self_consistent[i] && self_consistent[j])
            {
                bool distinct = true;
                for (int k = 0; k < N; k++)
                    if (x[i][k] && x[j][k])
                        distinct = false;
                result += distinct;
            }
    cout << result << endl;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;

int main() {
    ll a, b, c, x, y;
    scanf("%lld %lld %lld %lld %lld", &a, &b, &c, &x, &y);
    ll cost = 0;
    if (a + b >= 2*c) {
        while (x > 0 && y > 0) {
            cost += 2*c;
            x--;
            y--;
        }
        while (x > 0 && a >= 2*c) {
            cost += 2*c;
            x--;
            y--;
        }
        while (y > 0 && b >= 2*c) {
            cost += 2*c;
            x--;
            y--;
        }
    }
    while (x > 0) {
        cost += a;
        x--;
    }
    while (y > 0) {
        cost += b;
        y--;
    }
    printf("%lld\n", cost);
    return 0;
}


Measured memory_bytes: 256
var n,i,j,ans  :int64;
    dp,h   :array[1..100010]of int64;
    
procedure chmin(var a:int64;b:int64);
begin
  if a>b then a:=b
end;

function abs(a:int64):int64;
begin
  if a>=0 then abs:=a
  else abs:=-a
end;
    
begin
  readln(n);
  for i:=1 to n do read(h[i]);
  j:=1<<50;
  for i:=1 to 100010 do dp[i]:=j;
  dp[1]:=0;
  for i:=1 to n-1 do begin
    chmin(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
    chmin(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
  end;
  writeln(dp[n])
end.

Measured memory_bytes: 1664
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    for(auto &x : A) cin >> x;

    deque<int> dq;
    int f = n % 2;
    REP(i, n){
        if(f == (i % 2 == 0)) dq.push_front(A[i]);
        else dq.push_back(A[i]);
    }
    REP(i, n) cout << dq[i] << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 3840