akhauriyash/Code-Regression huggingface dataset:
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
 
#define MP make_pair
#define PB push_back
#define ST first
#define ND second
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;
 
void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}
 
const int N = (1<<17);
const int LG = 18;
const int SQ = 318;
 
int n, q, a[N], b[N], c[N], d[N], oj[N];
int qt = 1, hm[N], qh[N], qin[N], qout[2*N], qpar[N][LG], qsum[N][LG], qsiz[N];
int re, bla, who[SQ], id[N];
PII cur[N], wyn[SQ][N];
bool qvis[N];
VII qchild[N];
 
void dfs1(int v) {
  qvis[v] = true;
  qsiz[v] = 1;
  qin[v] = qt++;
  for (int i = 1; i < LG; ++i) {
    qpar[v][i] = qpar[qpar[v][i-1]][i-1];
    qsum[v][i] = qsum[v][i-1]+qsum[qpar[v][i-1]][i-1];
  }
  for (auto x: qchild[v])
    if (!qvis[x.ST]) {
      qpar[x.ST][0] = v;
      qsum[x.ST][0] = d[x.ND];
      qh[x.ST] = 1+qh[v];
      oj[x.ST] = x.ND;
      dfs1(x.ST);
      qsiz[v] += qsiz[x.ST];
    }
  qout[v] = qt++;
}
 
bool ancestor(int u, int v) {
  if (u == 0)
    return true;
  return (qin[u] <= qin[v] && qout[v] <= qout[u]);
}
 
int lca(int u, int v) {
  if (ancestor(u, v))
    return u;
  if (ancestor(v, u))
    return v;
  for (int i = LG-1; i >= 0; --i) {
    while (i >= 0 && ancestor(qpar[u][i], v))
      --i;
    if (i >= 0)
      u = qpar[u][i];
  }
  return qpar[u][0];
}
 
// u - anc v
int sum(int u, int v) {
  int d = qh[v]-qh[u];
  int res = 0;
  for (int i = LG-1; i >= 0; --i)
    if (d&(1<<i)) {
      res += qsum[v][i];
      v = qpar[v][i];
    }
  return res;
}
 
void dfs2(int v) {
  if (qh[v]%SQ == re) {
    for (int i = 1; i < n; ++i)
      wyn[bla][i] = cur[i];
    who[bla] = v;
    id[v] = bla++;
  }
  for (auto p: qchild[v])
    if (p.ST != qpar[v][0])  {
      cur[c[p.ND]].ST += d[p.ND];
      cur[c[p.ND]].ND++;
      dfs2(p.ST);
      cur[c[p.ND]].ST -= d[p.ND];
      cur[c[p.ND]].ND--;
    }
}
 
PII operator+(PII x, PII y) {
  return {x.ST+y.ST, x.ND+y.ND};
}
 
PII ans(int v, int kol) {
  PII res = {0, 0};
  while (v && qh[v]%SQ != re) {
    int nr = oj[v];
    if (c[nr] == kol)
      res = res+MP(d[nr], 1);
    v = qpar[v][0];
  }
  if (v)
    res = res+wyn[id[v]][kol];
  return res;
}
 
int main() {
  init_ios();
  cin >> n >> q;
  for (int i = 1; i < n; ++i) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    qchild[a[i]].PB({b[i], i});
    qchild[b[i]].PB({a[i], i});
  }
  dfs1(1);
  for (int i = 1; i <= n; ++i)
    ++hm[qh[i]%SQ];
  for (int i = 0; i < SQ; ++i)
    if (hm[i] < SQ)
      re = i;
  dfs2(1);
  while (q--) {
    int x, y, u, v;
    cin >> x >> y >> u >> v;
    int z = lca(u, v);
    PII ile = ans(u, x) + ans(v, x);
    PII bla = ans(z, x);
    ile.ST -= 2*bla.ST;
    ile.ND -= 2*bla.ND;
    int suma = sum(z, u) + sum(z, v);
    suma -= ile.ST;
    suma += y*ile.ND;
    cout<<suma<<"\n";
  }
}

Measured memory_bytes: 359808
#include <stdio.h>

int main()
{
  int n;
  int i;
  int max, min, sum;
  int score[101];

  while (1) {
    scanf("%d", &n);

    if (n == 0)
      break;

    sum = 0;

    for (i = 0; i < n; i++) {
      scanf("%d", &score[i]);
      sum += score[i];

      if (i == 0) {
        max = score[i];
        min = score[i];
      }

      if (score[i] > max) max = score[i];
      if (score[i] < min) min = score[i];
    }

    printf("%d\n", (sum - max - min) / (n - 2));
  }

  return 0;
}

Measured memory_bytes: 600
import bisect
n = int(input())
a = list(map(int,input().split()))
if n == 2:
  print(a[0],a[1])
  exit()
a.sort()
m = a.pop()
index = bisect.bisect_right(a,m//2)
if m % 2 == 0:
  if a[index] == m//2:
    print(m,a[index])
  else:
    if m//2-a[index-1] < a[index]-m//2:
      print(m,a[index-1])
    else:
      print(m,a[index])
else:
  if m//2-a[index-1] < a[index]-m//2-1:
    print(m,a[index-1])
  else:
    print(m,a[index])

Measured memory_bytes: 14424
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
int main(){
 int n; cin>>n;
 ll ans=0;
 REP(i,n){//1e4
  ll a; cin>>a; //1e9
  
   while(a%2==0){//2^30>1e9よりせいぜい30回のループ
        
          a/=2;
          ans++;
  }
 }
 cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = Long.parseLong(sc.next());
        long t = Long.parseLong(sc.next());
        
        if(x <= t) System.out.println(0);
        else System.out.println(x-t);
    }
}


Measured memory_bytes: 21716
import java.io.PrintWriter
import java.util.*

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}


fun main() {
    val W = next()
    val C = Counter<Char>()
    for (w in W) C.add(w)
    val ans = C.map.values.all { it % 2 == 0L }
    println(if (ans) "Yes" else "No")
}

class Counter<T> {
    val map = HashMap<T, Long>()

    fun add(k: T, d: Int = 1): Long {
        val v = map.getOrPut(k) { 0L }
        map[k] = v + d
        return v + d
    }

    fun addAll(m: Map<T, Int>) {
        for ((k, v) in m.entries) {
            add(k, v)
        }
    }

    fun get(a: T) = map.getOrDefault(a, 0)

    override fun toString(): String {
        return map.toString()
    }
}

Measured memory_bytes: 34704
#include <stdio.h>
int main(){
	int a;
	while(1){
		int n=0;
		scanf("%d",&a);
		if(!a) break;
		a=1000-a;
		while(a>0){
			if(a>=500) a-=500;
			else if(a>=100) a-=100;
			else if(a>=50) a-=50;
			else if(a>=10) a-=10;
			else if(a>=5) a-=5;
			else if(a>=1) a-=1;
			n++;
		}
		printf("%d\n",n);
	}
	return 0;
}

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

int main(){

  int a, b, c, d, p, ans;

  cin >> a >> b >> c >> d >> p;

  if(p > c) ans = min(a*p, (p-c)*d+b);
  else ans = min(a*p, b);
  
  cout << ans << endl;

}

Measured memory_bytes: 1160
const input=require('fs').readFileSync('/dev/stdin','utf8');const lines=input.trim().split('\n');let array;let index=0;let n;let m;let answers=[];while(line=lines.shift()){if(index===0){const test=line.split(' ').map(Number);n=test[0];m=test[1];index++;}else{array=line.split(' ').map(Number);let answer=0;for(let i=0;i<n;i++){for(let j=0;j<n;j++){if(i===j){continue;}const test=array[i]+array[j];if(test>answer&&test<=m){answer=test;}}}index=0;answers.push(answer);}}answers.forEach(data=>console.log(data?data:'NONE'))


Measured memory_bytes: 18192
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    vector<int> c, d;
    for (int i = 1; i <= a; i++){
        if (a % i == 0){
            c.push_back(i);
        }
    }
    REP(i, c.size()){
        if (b % c[i] == 0){
            d.push_back(c[i]);
        }
    }
    cout << d[d.size() - k] << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.1415926535897932384626
#define LMAX 9223372036854775807
#define ll long long
#define fi first
#define sec second
#define pii pair<int, int>
int n, m, k, x, y, sum, ans;
int main () {
	scanf("%d %d", &n, &m);
	if (n<=0&&m>=0) printf("Zero\n");
	else if (m<0) printf((n-m+1)%2==0?"Positive\n":"Negative\n");
	else printf("Positive\n");
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
using namespace std;

#pragma region

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

using ll = long long;
using P = pair<int, int>;

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; }

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

#pragma endregion


int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    rep(i, k) {
        if (a >= b) b *= 2;
        else if (b >= c) c *= 2;
    }
    if (a < b && b < c) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3628
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Program
{
    public static Scanner cin;
    static void Main()
    {
        cin = new Scanner();
        string s = ReadLine();
        int[] count = new int[2] { 0,0};
        for (int a = 0; a < 2; a++)
        {
            for (int b = 0; b < s.Length; b++)
            {
                if (int.Parse(s[b].ToString()) != (b + a) % 2) count[a]++;
            }
        }
        

        WriteLine(count.Min());
        Console.ReadLine();

    }
    static bool search(int[] array,int len,int key)
    {
        for (int a = 0; a < len; a++)
        {
            if (array[a]==key) return true;
        }
        return false;
    }
}





class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 17500
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;


class Main {
	//計算用array
	static int[] array = new int[101];
	static int[] temporary = new int[102];
	//ただ読み込むのみ
	static String[] read = new String[300];
	//計算用arrayのindex
	static int count = 0;
	
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
			String string = br.readLine();
			StringTokenizer tokenizer = new StringTokenizer(string," ");
			//一度すべて読み込んでしまう
			int i = 0;
			while (tokenizer.hasMoreTokens()) {
				read[i] = tokenizer.nextToken();
				i++;
			}
			
			int j =0;
			while(read[j]!=null){
				
				String next = read[j];
				if(next.equals("+")){
					popcalc(0);
				}else if(next.equals("-")){
					popcalc(1);
				}else if (next.equals("*")) {
					popcalc(2);
				}else{
					int number = Integer.parseInt(next);
					push(number);
				}
			
				j++;
			}
			
		System.out.println(array[0]);
	}

	
	//popメソッド
	public static void popcalc(int judge) {
	//上から2個とる、1つずつずらす、計算結果をpushする。
		int answer;
		int first = array[0];
		int second = array[1];
		
		//先に計算
		if(judge == 0){
			//足し算
			//System.out.println("たしざん");
			answer=first+second;
		}else if (judge == 1) {
			//引き算
			answer=second-first;
		}else{
			answer=first*second;
		}
		//コピー
		for(int i=0;i<array.length-1;i++){
			temporary[i] = array[i];
		}
		for(int i=2;i<array.length;i++){
			array[i-1]=temporary[i];
		}
		array[0]=answer;
	}
	
	
	//pushメソッド
	public static void push(int number){
		//numberを0番目に、それぞれ一個ずつずらしていく
		
		//同じ配列を複製
		for(int i=0;i<array.length-1;i++){
			temporary[i] = array[i];
		}
		for(int i =0;i<array.length-1;i++){
			array[i+1] = temporary[i];
		}
		array[0]=number;
	}
}

Measured memory_bytes: 17856
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

ll pow_mod(ll num, ll pow, ll mod) {
    ll prod = 1;
    num %= mod;
    while (pow > 0) {
        if (pow & 1) prod = prod * num % mod;
        num = num * num % mod;
        pow >>= 1;
    }
    return prod;
}

int main() {
    ll n, k;
    cin >> n >> k;
    cout << pow_mod(k, n, MOD) << endl;
    return 0;
}


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

using namespace std;

int main() {

ll n;

cin>>n;

int64_t sum=0;

for(int i=1;i<=n;i++) {
	if(i%3==0||i%5==0) {
		sum+=i;
	}
}


cout<<(n*(n+1)/2)-sum;
	return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define int long long
using namespace std;


int N, P, Q;
int C[500010];
int a[500010];


signed main(){
    cin >> N >> P >> Q;
    for(int i = 0;i < N;i++) cin >> C[i];

    for(int i = 0;i < N;i++) a[i] = C[i]+P*(i+1);
    sort(a, a+N);

    int ans = accumulate(C, C+N, 0LL), s = ans, pre = 0;
    for(int i = 1;i <= N;i++){
        pre += a[i-1];
        ans = max(ans, s-pre+P*i*(Q+i));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 10976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


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

    string n;
    cin >> n;
    rep(i,n.size()){
        if(n[i]=='9') n[i] = '1';
        else n[i] = '9';
    }
    cout << n << endl;
    
    return 0;
}
    

Measured memory_bytes: 256
x, y = gets.split(" ").map(&:to_i)
ans = "No"
i = 0
j = x
while j>0
  if (2*i + 4*j)==y || (2*j+4*i)== y
    ans = "Yes"
    break
  end
  i+=1
  j-=1
end
puts ans

Measured memory_bytes: 14292
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!{
        n: usize,
        a: usize,
        b: usize,
        v: [usize; n]
    }
    let mut ans = 0;
    for i in 0..n-1 {
        let d = v[i+1] - v[i];
        ans += std::cmp::min(d * a, b);
    }
    println!("{}",ans);
}


Measured memory_bytes: 4352
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

// vars
int n;

void input(){
    cin >> n;
}

void solve(){
    lint ans = 0;
    for (lint i = 1 ; i <= n; ++i){
        if(!(i % 3 == 0 || i % 5 == 0)){
            ans += i;
        }
    }
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

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

int main() {
  int A, B;
  int num = 1;
  cin >> A >> B;
  
  if (B == 1) {
    num = 0;
  }

  while (A + (A - 1) * (num - 1) < B) {
    num += 1;
  }

  cout << num << endl;
}

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

using namespace std;

#define sp << " " <<

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int h,w;
    cin >> h >> w;
    char d[h][w];
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
            cin >> d[i][j];
    int p[h][w];
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
            p[i][j]=0;
    p[0][0]=1;
    for(int i=1;i<w;i++)
        if(d[0][i]!='#')
            p[0][i]=p[0][i-1];
    for(int i=1;i<h;i++)
        if(d[i][0]!='#')
            p[i][0]=p[i-1][0];
    for(int i=1;i<h;i++)
        for(int j=1;j<w;j++)
            if(d[i][j]!='#')
                p[i][j]=(p[i-1][j]+p[i][j-1])%1000000007;
    cout << p[h-1][w-1];
    return 0;
}


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

int main(){
    string command;
    cin >> command;
    string res = "";

    rep(i, command.size()){
        char ch = command[i];
        switch(ch){
            case 'B':
                if (res.size() != 0){
                    res = res.erase(res.size() - 1);
                }
           		break;
            default:
                res += ch;
        }
    }

    cout << res;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/1/DPL_1_B>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

ll solve(){
    ll res = 0;
    ll N,W; cin >> N >> W;
    vector<ll> v(N),w(N); for(int i = 0; i < N;i++) cin >> v[i] >> w[i];
    vector<vector<ll>> dp(N+1,vector<ll>(W+1,0));
    for(int i = 0; i < N;i++){
        for(int j = 0; j <= W;j++){
            dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
            if(j + w[i] > W) continue;
            dp[i+1][j+w[i]] = max(dp[i+1][j],dp[i][j]+v[i]);
        }
    }
    res = dp[N][W];
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 10772
### constant

COLORS = {
  'k' => 0, 'b' => 1, 'r' => 2, 'm' => 3,
  'g' => 4, 'c' => 5, 'y' => 6, 'w' => 7
}

# top=x, east=y, north=z
DICE = [2, 1, 4]

DXYS = [[1, 0], [0, -1], [-1, 0], [0, 1]]

INF = 1 << 30

### classes

class Dice
  attr_accessor :d

  def initialize(d0 = DICE) @d = d0.clone end
  def ==(dc) @d == dc.d end
  def <=>(dc) @d <=> dc.d end
  def to_s() '(' + @d.join(',') + ')' end
  def top() @d[0] end
  def east() @d[1] end
  def north() @d[2] end

  def rot_x(n = 1)
    dc = Dice.new(@d)
    n.times do
      t = dc.d[1]; dc.d[1] = 7 - dc.d[2]; dc.d[2] = t
    end
    dc
  end

  def rot_y(n = 1)
    dc = Dice.new(@d)
    n.times do
      t = dc.d[2]; dc.d[2] = 7 - dc.d[0]; dc.d[0] = t
    end
    dc
  end

  def rot_z(n = 1)
    dc = Dice.new(@d)
    n.times do
      t = dc.d[0]; dc.d[0] = 7 - dc.d[1]; dc.d[1] = t
    end
    dc
  end

  def to_north() rot_y(3) end
  def to_south() rot_y(1) end
  def to_east()  rot_z(1) end
  def to_west()  rot_z(3) end
end

### main

$dcs = []

for zr in (0...4)
  for yr in (0...4)
    for xr in (0...4)
      dc = Dice.new.rot_x(xr).rot_y(yr).rot_z(zr)
      $dcs << dc if ! $dcs.include?(dc)
    end
  end
end
$dcs.sort!
$ndcs = $dcs.length
#p $dcs.map{|dc| dc.to_s}; p $ndcs; exit

$rots = []
for dc in $dcs
  $rots << [
    $dcs.index(dc.to_east), $dcs.index(dc.to_north),
    $dcs.index(dc.to_west), $dcs.index(dc.to_south)
  ]
end
#p $rots

loop do
  w, h = gets.split.map(&:to_i)
  break if (w | h) == 0

  hw = h * w
  flds = []
  spos = nil
  
  for y in (0...h)
    line = gets.strip
    for x in (0...w)
      pos = y * w + x
      case line[x]
      when '#'
        spos = pos
        flds[pos] = 7
      else
        flds[pos] = COLORS[line[x]]
      end
    end
  end

  vis = gets.strip.split('').map{|c| COLORS[c]}
  #p flds
  #p spos
  #p vis

  sidx = $dcs.index(Dice.new(DICE))

  dists = hw.times.map{$ndcs.times.map{6.times.map{INF}}}
  dists[spos][sidx][0] = 0

  q = [[spos, sidx, 0]]
  min_dist = nil
  
  while ! q.empty?
    upos, uidx, unxt = q.shift
    ud = dists[upos][uidx][unxt]
    nvd = ud + 1
    ux = upos % w
    uy = upos / w
    
    for di in (0...4)
      dx, dy = DXYS[di]
      vx = ux + dx
      vy = uy + dy

      if vx >= 0 && vx < w && vy >= 0 && vy < h
        vpos = vy * w + vx
        vfld = flds[vpos]
        vidx = $rots[uidx][di]
        vtop = $dcs[vidx].top
        
        if vfld == 7
          if dists[vpos][vidx][unxt] > nvd
            dists[vpos][vidx][unxt] = nvd
            q << [vpos, vidx, unxt]
          end
        elsif vfld == vtop && vfld == vis[unxt]
          vnxt = unxt + 1
          if vnxt >= 6
            min_dist = nvd
            break
          end

          if dists[vpos][vidx][vnxt] > nvd
            dists[vpos][vidx][vnxt] = nvd
            q << [vpos, vidx, vnxt]
          end
        end
      end

      break if min_dist
    end

    break if min_dist
  end

  puts (min_dist || 'unreachable')
end

Measured memory_bytes: 12664
#include <iostream>
#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>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  string s; cin >> s;
  if (s[1] == 'R') {
    s[1] = 'B';
  } else {
    s[1] = 'R';
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007

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

    double ans = 0.0;
    for(int i=1; i<=n; i++){
        int sc = i;
        double tmp = 1.0;
        while(sc < k){
            tmp *= 0.5;
            sc *= 2;
        }
        ans += tmp / n;
    }
    cout << setprecision(12) << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<ctime>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define int long long
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
    int x = 0; char ch = gc(); bool positive = 1;
    for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
    for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
    return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
    }
    write(a); puts("");
}
int n,m;
signed main(){
	n=read(); m=read();
	if(n>m)swap(n,m);
	if(n==1){
		cout<<(m==1?1:m-2)<<endl;
	}else{
		cout<<(n-2)*(m-2)<<endl;
	}
}


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

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

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

  vector<int> pos(n + 1, -1);
  for (int i = 0; i < n; ++i) {
    pos[p[i] - 1] = i;
  }

  int cnt = 0;
  int q = 0;
  for (int i = 1; i < pos.size(); ++i) {
    if (pos[i - 1] > pos[i]) {
      cnt = max(cnt, i - q);
      q = i;
    }
  }

  cout << n - cnt << endl;
}

Measured memory_bytes: 4772
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	int K, X;

	cin >> K >> X;
	if (500 * K >= X)
		puts("Yes");
	else
		puts("No");
}



Measured memory_bytes: 256
def get_dice(pips):
    return [[0, pips[4], 0, 0], 
                   [pips[3], pips[0], pips[2], pips[5]], 
                   [0, pips[1], 0, 0]]

def move_e(dice):
    dice[1] = dice[1][3:] + dice[1][:3]
    return dice

def move_n(dice):
    return [[0,          dice[1][1], 0, 0],
            [dice[1][0], dice[2][1], dice[1][2], dice[0][1]],
            [0,                 dice[1][3], 0, 0]]

def move_s(dice):
    return [[0,          dice[1][3], 0, 0],
            [dice[1][0], dice[0][1], dice[1][2], dice[2][1]],
            [0,                 dice[1][1], 0, 0]]

def move_w(dice):
    dice[1] = dice[1][1:] + dice[1][:1]
    return dice

func = {'E':move_e,'N':move_n,'S':move_s,'W':move_w}

dice = get_dice(list(map(int, input().split())))

for c in input():
    dice = func[c](dice)

print(dice[1][1])

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

int main() {
  string s; cin >>s;
  int a=0, b=0, c=0;
  int n = s.size();
  rep(i,n){
    if(s[i]=='a') a++;
    else if(s[i]=='b') b++;
    else c++;
  }
  if(abs(a-b)<=1 && abs(b-c)<=1 && abs(c-a)<=1){
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
char a[1007][1007];
ll dp[1007][1007];
int n,m;
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++) cin>>a[i][j];
	}
	dp[1][1]=1;
	for(int i=1;i<=n;i++) a[i][0]='#';
	for(int j=1;j<=m;j++) a[0][j]='#';
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(a[i][j]=='.'){
			dp[i][j]+=(a[i-1][j]=='.')*dp[i-1][j]+(a[i][j-1]=='.')*dp[i][j-1];
			dp[i][j]%=mod;}
		}
	}
	cout<<dp[n][m];
}


Measured memory_bytes: 12424
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {
	
	int a;
	scanf("%d", &a);
	printf("%d\n", a / 3);
	
	Please AC;
}


Measured memory_bytes: 760
n, a, b = map(int, input().split())
value_max = 2 * (10 ** 5)
com = [0 for _ in range(value_max + 1)]
com[1] = n
mod = 10 ** 9 + 7
mod_inverse = [pow(i, mod - 2, mod) for i in range(1, value_max + 1)]
ans = pow(2, n, mod)

for i in range(2, min(n, value_max) + 1):
    if (n - i + 1) == 0:
        break

    com[i] = com[i - 1] * (n - i + 1)
    com[i] *= mod_inverse[i - 1]
    com[i] %= mod

diff = (com[a] + com[b] + 1) % mod
print((ans - diff) % mod)


Measured memory_bytes: 62380
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;
int mod = 1e9+7;

int a[1000000], b[1000000];
signed main(){
	int n, ans = inf, s = 0;
	scanf("%lld", &n);
	rep(i,n)scanf("%lld%lld", &a[i], &b[i]);
	rep(i,n)if(a[i] > b[i])chmin(ans, b[i]);
	rep(i,n)s += a[i];
	if(ans == inf)ans = s;
	printf("%lld\n", s-ans);
	return 0;
}



Measured memory_bytes: 2432
using System;
using System.Linq;
using System.Collections.Generic;

public class AtCoderC
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] b = new int[n - 1];
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            for (int i = 0; i < n - 1; i++)
            {
                b[i] = int.Parse(words[i]);
            }
        }

        int[] a = new int[n];
        a[0] = b[0];
        for (int i = 1; i < n - 1; i++)
        {
            a[i] = Math.Min(b[i - 1], b[i]);
        }
        a[n - 1] = b[n - 2];

        Console.WriteLine(a.Sum());
    }
}

Measured memory_bytes: 13268
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int n,x;
        int cnt;
        while(true){
            n=sc.nextInt();
            x=sc.nextInt();
            if(n==0&&x==0)break;
            
            cnt=0;
            for(int i=1;i<=n-2;i++){
                for(int j=i+1;j<=n-1;j++){
                    for(int k=j+1;k<=n;k++){
                        if(i+j+k==x)cnt++;
                    }
                }
            }
            
            System.out.println(cnt);
        }
    }
}



Measured memory_bytes: 26940
from collections import Counter

N = int(input())
A = tuple(map(int, input().split()))
S = sum(A)
ct = Counter(A)

Q = int(input())
for _ in range(Q):
    b, c = map(int, input().split())
    if b in ct:
        S += ct[b] * (c - b)
        ct[c] += ct[b]
        ct.pop(b)
    print(S)


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> R(N, vector<int>(N));
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    R.at(a - 1).at(b - 1) += 1;
    R.at(b - 1).at(a - 1) += 1;
  }
  for (int i = 0; i < N; i++) {
    int ans = 0;
    for (int j = 0; j < N; j++) {
      ans += R.at(i).at(j);
    }
    cout << ans << endl;
  }
}


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

using namespace std;

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

  int k;
  string s;
  cin >> k >> s;

  if (s.size() <= k) {
    cout << s << '\n';
  } else {
    for (int i = 0; i < k; ++i) {
      cout << s[i];
    }
    cout << "..." << '\n';
  }

  return 0;
}

Measured memory_bytes: 3640
import sys
from collections import Counter


def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    _ = sys.stdin.readline()
    a = list(_ia())
    l = Counter(ai+i+1 for i, ai in enumerate(a))
    r = Counter(i+1-ai for i, ai in enumerate(a))
    return sum(v*r.get(k, 0) for k, v in l.items())


if __name__ == "__main__":
    print(main())


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

using namespace std;
#define taskname "TEST"
#define pb	push_back
typedef long double ld;
typedef long long ll;
const int maxn = 1e6;
int n , m;
int vis[maxn], res;
vector<int> adj[maxn];
void DFS(int u)
{
    for(int c : adj[u])
    {
        if(vis[c] == 0)DFS(c);
        vis[u] = max(vis[u] , vis[c]);
    }
    vis[u]++;
    res = max(res , vis[u]);
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	if(fopen(taskname".INP","r"))
        freopen(taskname".INP", "r",stdin) ,
        freopen(taskname".OUT", "w",stdout);
    cin >> n >> m;
    for(int i = 1 ; i <= m ;++i)
    {
        int u , v;cin >> u >> v;
        adj[u].pb(v);
    }
    for(int i = 1 ; i <= n ; ++i)
    {
        if(vis[i] == 0){
            DFS(i);

        }
    }
    cout << res - 1;
}


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

int main(){
  	int N[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  	int K;
  	cin >> K;
  	cout << N[K-1] << endl;
	return 0;
}

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

using namespace std;

int main(void) {
  string A, B, C; cin >> A >> B >> C;

  cout << (char)(A[0] - 32) << (char)(B[0] - 32) << (char)(C[0] - 32) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
     
double getTime() { 
  return clock() / (double) CLOCKS_PER_SEC;
}
     
void read() {};
     
template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}
     
void print() {};
     
template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

int main() {
  int h, a; read(h, a);
  cout << (h + a - 1) / a << '\n';
}

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

using namespace std ;

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



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C___Distinct_or_Not
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

            Array.Sort(a);

            for (int i = 0; i < n - 1; i++)
            {
                if (a[i] == a[i + 1])
                {
                    Console.WriteLine("NO");
                    Environment.Exit(0);
                }
            }

            Console.WriteLine("YES");

            //System.Collections.ArrayList al = new System.Collections.ArrayList(a.Length);

            //foreach (int i in a)
            //{
            //    if (!al.Contains(i))
            //    {
            //        al.Add(i);
            //    }
            //}

            //if (a.Length == al.Count)
            //{
            //    Console.WriteLine("YES");
            //}
            //else
            //{
            //    Console.WriteLine("NO");
            //}


            //for(int i = 0; i < n; i++)
            //{
            //    for(int j = i + 1; j < n; j++)
            //    {
            //        if(a[i] - a[j] == 0)
            //        {
            //            Console.WriteLine("NO");
            //            Console.ReadKey();
            //            Environment.Exit(0);
            //        }
            //    }
            //}

            //Console.WriteLine("YES");
            //Console.ReadKey();

        }
    }
}


Measured memory_bytes: 36188
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n; cin>>n;
	long long ans = 0;
	long long anterior, atual;
	for(int i=1; i<n; i++){
		cin>>atual;
		if(i==1)anterior=atual;
		ans += min(anterior,atual);
		anterior = atual;
	}
	ans += atual;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    Scanner in = new Scanner(System.in);
    public static void main(String[] args) {
        new Main();
    }
 
    public Main(){
    	new AOJ2018().doIt();
    }
    
    
    class AOJ2018{
    	
    	int solve(int n,int m,int p){
    		int result = 0;
    		int cnt = 0;
    		int[] hose = new int[n];
    		for(int i=0;i<n;i++)hose[i] = in.nextInt();
    		for(int i=0;i<n;i++)cnt+=hose[i];
    		cnt=cnt*100;
//    		System.out.println(cnt);
    		if(hose[m-1]==0)result = 0;
    		else result = cnt*(100-p)/100/hose[m-1];
    		return result;
    	}
    	
    	void doIt(){
    		while(in.hasNext()){
    			int n = in.nextInt();
    			int m = in.nextInt();
    			int p = in.nextInt();
    			if(n+m+p==0)return;
    			System.out.println(solve(n,m,p));
    		}
    	}
    }
    
}

Measured memory_bytes: 27720
import fractions
A,B,C,D=map(int,input().split())
listA=range(A)
listB=range(B+1)
listC=range(0,B+1,C)
listAC=range(0,A,C)
listD=range(0,B+1,D)
listAD=range(0,A,D)
listCD=range(0,B+1,C*D//fractions.gcd(C,D))
listACD=range(0,A,C*D//fractions.gcd(C,D))
lenA=len(listA)
lenB=len(listB)
lenC=len(listC)-len(listAC)
lenD=len(listD)-len(listAD)
lenCD=len(listCD)-len(listACD)
ans=lenB-lenA-lenC-lenD+lenCD
print(ans)

Measured memory_bytes: 5076
#include<stdio.h>
#define DUMMY -1 
#define MAX 200000001
int heap_size,S[MAX];

void HeapIncreaseKey(int key){
  int i = heap_size;
  S[i]=key;
  while(i>1 && S[i/2]<S[i]){
    int tmp = S[i];
    S[i]=S[i/2];
    S[i/2]=tmp;
    i /=2;
  }
  return;
}

void Insert(int key){
  heap_size++;
  S[heap_size]=DUMMY;
  HeapIncreaseKey(key);
  return ;
}

void MaxHeapify(int x){
  int l,r,largest;
  l = 2*x;
  r = 2*x+1;

  if(l<=heap_size && S[l] > S[x]){
    largest = l;
  }
  else largest = x;
  if(r<=heap_size && S[r] > S[largest]){
    largest = r;
  }
  if(largest!=x){
    int tmp = S[x];
    S[x]=S[largest];
    S[largest]= tmp;
    MaxHeapify(largest);
  }
  return ;
}

int ExtractMax(){
  int max = S[1];
  S[1]=S[heap_size];
  heap_size--;
  MaxHeapify(1);
  return max;
}

int main(){
  char com[10];
  while(1){
    scanf("%s",com);
    if(com[2]=='d')break;
      if(com[0]=='e'){
	printf("%d\n",ExtractMax());
    }
    else if(com[0]=='i'){
      int key;
      scanf("%d",&key);
      Insert(key);
    }
  }
  return 0;
}



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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rep1(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define repU(i,bottom,ceiling) for(auto (i) = (bottom); (i) <= (ceiling); ++(i))
#define repD(i,ceiling,bottom) for(auto (i) = (ceiling); (i) >= (bottom); --(i))
#define repV(i,v) for(auto (i) = begin(v); (i) < end(v); ++(i))
#define all(v)  begin(v),end(v)
#define clr(v) fill(all(v),0)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define q_ceil(n,d) ((n - 1)/(d) + 1)
#define parity(a,b) ((a)^(b) & 1LL ^ 1LL)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF_32 = -1 + (1 << 30);
const ll INF_64 = -1 + (1LL << 62);
const int MOD = (int)1e9 + 7;

ull next_subset(ull subset){
	ull tem = subset + (subset & -subset);
	ull btm = (~tem & subset) / (subset & -subset) >> 1;
	return btm | tem;
}

int N;
ll ans;
pair<int,int> p[200001];

void solve(){
	sort(p,p + N);
	int mx = 0,mn = INF_32,nn,nx;
	rep(i,N){
		mx = max(mx, p[i].sec);
		mn = min(mn, p[i].sec);
	}
	ans=1ll * (mx - mn) * (p[N - 1].fir - p[0].fir);
	nn = nx = p[0].fir;
    repD(i,N - 1,1){
        ans = min(ans,1ll * (p[N - 1].fir - mn)*(max(nx,p[i].fir)-min(nn,p[0].fir)));
        nn = min(nn,p[i].sec),nx = max(nx,p[i].sec); 
    }
	cout<<ans<<endl;
	
	return;
}

void input(){
	
	cin>>N;
	int x,y;
	rep(i,N){
		cin>>x>>y;
		if(x < y) swap(x,y);
		p[i] = {x,y};
	}
	
	return;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	input();
	solve();
	
	return 0;
}





Measured memory_bytes: 1920
#include <stdio.h>
#include <stdlib.h>
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	long long a,b,n;
	scanf("%lld%lld%lld",&a,&b,&n);
	long long ans=1e18;
	for(int i=1;i<=n;i++)if(b%i==0)for(int j=1;j<=n;j++)ans=min(ans,llabs(a-b/i*j));
	printf("%lld\n",ans);
}


Measured memory_bytes: 2148