akhauriyash/Code-Regression huggingface dataset:
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N, Q;
	static int[][] key = new int[512][512];
	static int[][] val = new int[512][512];

	public static void main(String[] args) {
		StringBuilder sb = new StringBuilder();
		int[] A = new int[100000];
		while (true) {
			N = Integer.parseInt(sc.next());
			if (N == 0) break;
			int S = Integer.parseInt(sc.next());
			int W = Integer.parseInt(sc.next());
			Q = Integer.parseInt(sc.next());
			int g = S;
			for (int i = 0; i < N; ++i) {
				A[i] = (g / 7) % 10;
				g = (g / 2) ^ (W * (g % 2));
			}
			sb.append(solve(A) + "\n");
		}
		System.out.print(sb);
	}

	static long solve(int[] A) {
		long ans = 0;
		if (Q == 2 || Q == 5) {
			int nonzero = 0;
			for (int i = 0; i < N; ++i) {
				if (A[i] != 0) ++nonzero;
				if (A[i] % Q == 0) {
					ans += nonzero;
				}
			}
			return ans;
		}
		for (int i = 0; i < key.length; ++i) {
			for (int j = 0; val[i][j] != 0; ++j) {
				val[i][j] = 0;
			}
		}

		long sum = 0;
		long base = 1;
		for (int i = 0; i < N; ++i) {
			sum += A[N - 1 - i] * base;
			while (sum >= Q) {
				sum -= Q;
			}
			base *= 10;
			while (base >= Q) {
				base -= Q;
			}
			int c = 0;
			int k = (int) (sum & 511);
			for (int j = 0;; ++j) {
				if (val[k][j] == 0) {
					key[k][j] = (int) sum;
					val[k][j] = 1;
					break;
				}
				if (key[k][j] == (int) sum) {
					c = val[k][j];
					val[k][j]++;
					break;
				}
			}
			if (A[N - 1 - i] != 0) {
				ans += c;
				if (sum == 0) ans++;
			}
		}
		return ans;
	}
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N, M; scanf("%d %d", &N, &M);
  int cnt = (1 << M);
  int ans = 1900 * M + (N - M) * 100;
  ans *= cnt;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		scan.close();
		long[]f = new long[n + 1];
		f[0] = 1;
		f[1] = 1;
		for(int i = 2; i <= n; i++) {
			f[i] = f[i - 1] + f[i - 2];
		}
		System.out.println(f[n]);
	}
}


Measured memory_bytes: 26264
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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 T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;


signed main()
{
    int n, k;
    cin >> n >> k;
    int r, s, p;
    cin >> r >> s >> p;
    map<char, int> mp;
    mp['r'] = p;
    mp['p'] = s;
    mp['s'] = r;
    string t;
    cin >> t;
    int ans = 0;
    for (int i = 0; i < t.size(); i++)
    {
        if(i<k){
            if(t[i]=='r'){
                ans += mp['r'];
            }
            if(t[i]=='p'){
                ans += mp['p'];
            }
            if(t[i]=='s'){
                ans += mp['s'];
            }
        }
        else{
            if(t[i]==t[i-k]){
                t[i] = '.';
            }
            else{
                if (t[i] == 'r')
                {
                    ans += mp['r'];
                }
                if (t[i] == 'p')
                {
                    ans += mp['p'];
                }
                if (t[i] == 's')
                {
                    ans += mp['s'];
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>

struct POINT{
	double x;
	double y;
};

double getDistance( const POINT& a , const POINT& b )
{
	return sqrt( pow( a.x - b.x , 2 ) + pow( a.y - b.y , 2 ) );
}

double getDimension( const POINT& A , const POINT& B , const POINT& C )
{
	double disAB = getDistance( A , B );
	double disBC = getDistance( B , C );
	double disCA = getDistance( C , A );
	double z = ( disAB + disBC + disCA ) / 2.0;
	double dimension = sqrt( z * ( z - disAB ) * ( z - disBC ) * ( z - disCA ) );

	return dimension;
}

int main(void)
{
	char c;
	std::vector<POINT> p;
	double dim = 0.0;

	while(1){
		POINT tmp;
		std::cin >> tmp.x >> c >> tmp.y;
		if( std::cin.eof() ){
			break;
		}
		p.push_back(tmp);
	}

	for( int i = 0 ; i < p.size()-2 ; i++ ){
		dim += getDimension( p[0] , p[i+1] , p[i+2] );
	}
	printf( "%.6f\n" , dim );

	return 0;
}

Measured memory_bytes: 1260
def main():
  N = int(input())
  heights = input().split()
  for i in range(N):
    heights[i] = int(heights[i])
  dp = [0, abs(heights[1]-heights[0])]
  for i in range(2,N):
    cost1 = abs(heights[i] - heights[i-1]) + dp[i-1]
    cost2 = abs(heights[i] - heights[i-2]) + dp[i-2]
    dp.append(min(cost1, cost2))
  print(dp[-1])

if __name__ == '__main__':
  main()

Measured memory_bytes: 11452
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE FlexibleContexts #-}

import Data.Bits
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BSL
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IMS
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
import qualified Data.Sequence as Seq
import Data.Sequence (Seq)
import qualified Data.Array.IArray as A
import qualified Data.Array.MArray.Safe as A
import qualified Data.Array.MArray as A
import Data.Array (Array)
import Data.Array.Unboxed (UArray)
import Data.Array.IArray (IArray)
import Data.Array.MArray.Safe (MArray)
import Data.Array.IO.Safe (IOArray, IOUArray)
import Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Monad.ST
-- import Control.Monad.ST.Safe
import Control.Applicative
import Data.Maybe
import Data.Tuple
import Data.Ord
import Control.Monad.State.Strict
import Data.Int
import System.IO
import Data.Function
import Control.Monad.Primitive
import qualified Data.Vector.Primitive.Mutable as VPM
import qualified Data.Vector.Generic.Mutable as VGM
import Data.STRef


rInt :: StateT BSL.ByteString Maybe Int
rInt = StateT $ BSL.readInt . BSL.dropWhile (<'!')


main :: IO ()
main = do
  [n,m] <- map read . words <$> getLine
  edges <-
    V.convert . VU.unfoldrN m (runStateT $ (,) <$> (subtract 1 <$> rInt)
                                     <*> (subtract 1 <$> rInt))
    <$> BSL.getContents
  let cods = V.accumulate (flip (:)) (V.replicate n []) edges
      lengths = V.generate n $ \j ->
        maximum $ (0 :) $ map (+1) $ map (lengths V.!) (cods V.! j)
  print $ V.maximum lengths

{-
topSort :: V.Vector [Int] -> (VU.Vector Int, VU.Vector Int)
topSort cods = runST $ do
  sorted <- VUM.new (V.length cods)
  pos <- VUM.new (V.length cods)
  visited <- VUM.replicate (V.length cods) False
  currentPos <- newSTRef (V.length cods - 1)
  let go j = VUM.read visited j >>= \vis -> unless vis $ do
        VUM.write visited j True
        forM_ (cods V.! j) $ go
        curPos <- readSTRef currentPos
        VUM.write sorted curPos j
        VUM.write pos j curPos
        writeSTRef currentPos (curPos-1)
  forM_ [0..V.length cods - 1] $ go
  sorted_ <- VU.unsafeFreeze sorted
  pos_ <- VU.unsafeFreeze pos
  return (sorted_, pos_)
-}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
string s;
#define maxn 100010
int int_sort( const void * a , const void * b ) {
  if( *( int * )a < *( int * )b ) {
    return -1;
  }
  else
  if( *( int * )a == *( int * )b ) {
    return 0;
  }
  return 1;
}


int main()
{
	int n , a[maxn] = {}, b[maxn] = {};
	cin >> n;
	REP(n) cin >> a[i];
	qsort((void*)a, n, sizeof(a[0]), int_sort);
	int ans_ai = a[n - 1], ans_aj = a[0];
	int ans_ai_d;

	REP(n - 1)
	{
		if(abs(ans_ai - a[i] * 2) < abs(ans_ai - ans_aj * 2))
		{
			ans_aj = a[i];
		}
	}
	cout << ans_ai << " " << ans_aj << endl;

    return 0;
}


Measured memory_bytes: 1020
fun main(args: Array<String>) {
    val (H, W) = readLine()!!.split(" ").map { it.toInt() }
    val first = mutableListOf<String>()
    for (i in 1..H) {
        readLine()!!.let { if (it.any { c -> c == '#' }) first.add(it) }
    }

    val indexes = mutableListOf<Int>()
    for (j in 1..W) {
        if (first.map { it[j - 1] }.all { c -> c == '.' }) indexes.add(j - 1)
    }

    first.map { it.filterIndexed { index, c -> !indexes.contains(index) } }.forEach(::println)
}

Measured memory_bytes: 37604
use std::io::stdin;

#[allow(unused_variables)]
fn main() {
    let n = input_ints()[0] as u64;
    let mut ans = 0;

    for i in (2..(n as f64).sqrt() as u64 + 1).rev() {
        if n % i == 0 {
            ans = (n / i).to_string().len();
            break;
        }
    }

    if ans == 0 {
        ans = n.to_string().len();
    }

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

#[allow(dead_code)]
fn input_ints() -> Vec<i64> {
    let mut s = String::new();
    match stdin().read_line(&mut s) {
        Ok(_) => s.split_whitespace().map(|s| s.parse().unwrap()).collect(),
        Err(_) => panic!("Error occured while input."),
    }
}


Measured memory_bytes: 4352
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	x = int(input())
	#b , c = tin()
	#s = input()	
	s=0
	for i in range(mod):
		s+=i
		if s >= x:
			return i
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 61912
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main()
{
	long double A,B;
	float x=10,y=100 , z=0;
	z=pow(x,y);
	cin>>A;
	cin>>B;;
	if(1<=A && A<=z)
	{
		if(1<=B && B<=z)
		{
			if(A>B)
			{
				printf("GREATER");
			}
			else if(A<B)
			{
				printf("LESS");
			}
			else
			{
				printf("EQUAL");	
			}
		}
		else
		{
		printf("Error");
		}
	}
	else
	{
		printf("Error");
	}
	return 0;
	
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int a;
            string answer;
            a = int.Parse( Console.ReadLine());
            if( a < 1000)
            {
                answer = "ABC";
            }
            else
            {
                answer = "ABD";
            }
            Console.Write(answer);

        }
    }
}


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

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

  if (p / 1000 == p % 1000 / 100 && p % 1000 / 100 == p % 1000 % 100 /10 ) {
  cout << "Yes" << endl;
  }
  else if ( p % 1000 / 100 == p % 1000 % 100 / 10  && p % 1000 % 100 / 10 == p % 1000 % 100 % 10 / 1) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }    
}  


Measured memory_bytes: 3604
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

class Pair {
    public int first;
    public int second;

    public Pair(int first, int second) {
        this.first = first;
        this.second = second;
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        Queue<Pair> q = new LinkedList<Pair>();

        int n = scanner.nextInt();

        boolean doublet = false;

        for (int i = 0 ; i < n ; i++) {
            int d1 = scanner.nextInt();
            int d2 = scanner.nextInt();

            q.add(new Pair(d1,d2));
            if (q.size() >= 3) {
                int countDoublet = 0;
                for (Pair item: q) {
                    if (item.first == item.second) {
                        countDoublet++;
                    }
                }
                if (countDoublet == 3) {
                    doublet = true;
                    break;
                }
                q.remove();
            }
        }

        if (doublet) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 36020
#include<iostream>
#include<set>
#include<map>
using namespace std;

int main() {
	int N; cin >> N;
	set<int> s1, s2;
	multiset<int> st1, st2;
	for (int i = 0; i < N / 2; i++) {
		int a, b; cin >> a >> b;
		s1.insert(a);
		st1.insert(a);
		s2.insert(b);
		st2.insert(b);
	}
	int cnt1 = 0, cnt2 = 0;
	int Max1 = 0, Max2 = 0;
	for (auto itr = s1.begin(); itr != s1.end(); itr++) {
		int num = st1.count(*itr);
		if (cnt1 < num) {
			cnt1 = num;
			Max1 = *itr;
		}
	}
	for (auto itr = s2.begin(); itr != s2.end(); itr++) {
		int num = st2.count(*itr);
		if (cnt2 < num) {
			cnt2 = num;
			Max2 = *itr;
		}
	}

	int cnt1n = 0, cnt2n = 0;
	int Max1n = 0, Max2n = 0;
	for (auto itr = s1.begin(); itr != s1.end(); itr++) {
		if (*itr == Max1) continue;
		int num = st1.count(*itr);
		if (cnt1n < num) {
			cnt1n = num;
			Max1n = *itr;
		}
	}
	for (auto itr = s2.begin(); itr != s2.end(); itr++) {
		if (*itr == Max2) continue;
		int num = st2.count(*itr);
		if (cnt2n < num) {
			cnt2n = num;
			Max2n = *itr;
		}
	}
	int res = N - cnt1 - cnt2;
	if (Max1 == Max2) {
		if (cnt1n > cnt2n) res = N - cnt1n - cnt2;
		else res = N - cnt1 - cnt2n;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 9600
//
//  Created by Ruslan Jankurazov.
//  Copyright © 2018 Ruslan Jankurazov. All rights reserved.
//

#pragma GCC optimize("Ofast")

#include "bits/stdc++.h"

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define f first
#define s second
#define uint unsigned int
#define pii pair <int, int>
#define pll pair <ll, ll>

using namespace std;


int main() {
#define FILE_INPUT 0
#define FILE ""
#ifndef DEBUG
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#if FILE_INPUT == 1
#warning "FREOPEN is on"
    freopen(FILE".in", "r", stdin);
    freopen(FILE".out", "w", stdout);
#endif
#endif
    int n;
    cin >> n;
    string a, b;
    cin >> a >> b;
    int l = 0;
    for (int c = 0; c <= n; ++c) {
        string s;
        for (int i = 0; i < n; ++i) {
            s.pb(a[i]);
        }
        for (int i = 0; i < n - c; ++i) {
            s.pb(b[i + c]);
        }
        if (s.substr(0, n) == a && s.substr(n - c) == b) {
            l = c;
        }
        //cout << s << '\n';
    }
    cout << 2*n - l;
    return 0;
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define lep(j,n) for(int j=0; j<(n); j++)
#define reps(i,n) for(int i=1; i<(n); i++)
#define leps(j,n) for(int j=1; j<(n); j++)
#define pii pair<int,int>
#define gsort(x,n) sort((x),(x)+(n),greater<int>())
#define all(x) (x).begin(), (x).end()
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const long long mod = 1000000007;
using namespace std;

#define return(Z) re:(Z)

long long h[10000010],x[10000010],z[10000010];

signed main(){

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

    int a,b,c,cnt=0,ans=0;
    string s,w;
    bool p,q;

    cin>>a;
    if(a>=1000) cout<<"ABD"<<'\n';
    else cout<<"ABC"<<'\n';
    re:(0);
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

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

  int n, m; cin >> n >> m;
  vll d(n);
  for(int i=0;i<n;++i) {
    cin >> d[i];
  }

  map<P, int> edges;
  vector<vector<int>> g(n);
  vector<ll> cost(m, INF);
  vector<int> col(n, -1);
  for(int i=0;i<m;++i) {
    int u, v; cin >> u >> v;
    u--; v--;
    if(u > v) swap(u, v);
    
    g[u].push_back(v);
    g[v].push_back(u);
    edges[{u, v}] = i;
  }

  map<int, vi> ma;
  for(int i=0;i<n;++i) {
    ma[d[i]].push_back(i);
  }

  for(auto it: ma) {
    int val = it.first;
    auto vs = it.second;
    for(auto v: vs) {
      if(col[v] != -1) continue;
      bool exist = false;
      for(auto e: g[v]) {
        int nv = e;
        if(d[v] < d[nv]) continue;
        exist = true;
        if(v < nv) cost[edges[{v, nv}]] = val;
        else cost[edges[{nv, v}]] = val;
        if(col[nv] == -1) {
          col[v] = 0;
          col[nv] = 1;
        }
        else col[v] = 1 - col[nv];
        break;
      }
      
      if(!exist) {
        cout << -1 << endl;
        return 0;
      }
    }
  }

  for(int i=0;i<n;++i) {
    cout << (col[i] ? 'W' : 'B');
  }
  cout << endl;
  for(int i=0;i<m;++i) {
    cout << cost[i] << endl;
  }

}


Measured memory_bytes: 33920
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    cout << (ll)(N - 1) * N / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
K = int(input())
W = 0
k = 0
while True:
    W += 1
    pool = [(i,0) for i in range(9,0,-1)]
    history = [None] * W
    while pool:
        n, w = pool.pop()
        history[w] = n
        if w == W-1:
            k += 1
            if k == K:
                for j in range(W):
                    print(history[j], end='')
                print()
                exit()
        else:
            if n < 9: pool.append((n+1,w+1))
            pool.append((n,w+1))
            if n > 0: pool.append((n-1,w+1))


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

#define MaxN 100005
#define MOD 1000000007
#define INF 2140000000

using namespace std;

string S;
int Solve()
{
    char type='z';
    S.push_back('a');
    int L=0,A=0,Max=(S.size()+1)/2;
    for(int i=0;i<S.size();i++)
    {
        if(type!=S[i])
        {
            Max=max(max(L,Max),min(A,min(L+(int)S.size()-i-1,i-L)));
            A=L;
            L=1,type=S[i];
        }
        else L++,A++;
    }
    cout<<Max;
}
int main()
{
    long long X,Y;
    cin>>X>>Y;
    int Ans=1;
    while(X*2<=Y)
        X*=2,Ans++;
    cout<<Ans;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n, l, r;
    int ans = 0;

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> l >> r;
        ans += r - l + 1;
    }

    cout << ans << "\n";
}

Measured memory_bytes: 256
//============================================================================
// Name        : abc057_D.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
#include<algorithm>
using namespace std;

int main() {
	int a, b, c, d;

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

	int ans = max(a * b, c * d);

	cout << ans << endl;
}


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

int main(){
    int k;
    cin >> k;
    int a,b;
    cin >> a >> b;
    int r = (a + k - 1)/k;
    if(a <= r*k && r*k <= b) cout << "OK" << endl;
    else cout << "NG" << endl;
}


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

using namespace std;

#define int long long

int n,a,b;
int p[5001], f[10011], mn[10011], pos[5001];

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

	cin >> n >> a >> b;
	for (int i=1;i<=n;i++)
	{
		cin >> p[i];
		pos[p[i]] = i*2;
	}
	mn[0] = 1e18;
	for (int j=1;j<=n;j++)
	{
    	for (int i=1;i<=2*n+1;i++)
    	{
    		int cost = 0;
    		if (i < pos[j]) cost = b;
    		else if (i > pos[j]) cost = a;
    		if (i%2 == 1)
    			f[i] = mn[i] + cost;			
    		else
    			f[i] = mn[i-1] + cost;
    	}
		for (int i=1;i<=2*n+1;i++)
			mn[i] = min(mn[i-1],f[i]);
	}
	cout << mn[2*n+1];	
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define N 100005
#define int long long
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<22,stdin),p1 == p2)?EOF:*p1++)
using namespace std ;
//char buf[(1 << 22)] , *p1 = buf , *p2 = buf ;
inline int read ()
{
    char c = getchar () ; int x = 0 , f = 1 ;
    while (c < '0' || c > '9') { if (c == '-') f = -1 ; c = getchar () ; }
    while (c >= '0' && c <= '9'){ x = x * 10 + c - '0' ; c = getchar () ; }
    return x * f ;
}
int n , m , ver[N << 1] , nxt[N << 1] , hed[N] , tot , ans[N] , Dis[N] ;
struct as {
	int v , d , c ;
} a[N] ;
void add (int x , int y) { ver[++ tot] = y ; nxt[tot] = hed[x] ; hed[x] = tot ; }
void dfs (int x , int col , int dis)
{
	if (! ans[x]) ans[x] = col ;
	if (! dis || Dis[x] >= dis) return ;
	Dis[x] = dis ;
	for (int i = hed[x] ; i ; i = nxt[i])
	{
		int y = ver[i] ;
		dfs (y , col , dis - 1) ;
	}
}
signed main ()
{
	n = read () , m = read () ;
	for (int i = 1 , u , v ; i <= m ; u = read () , v = read () , add (u , v) , add (v , u) , i ++) ;
	int q = read () ;
	for (int i = 1 ; i <= q ; i ++) a[i].v = read () , a[i].d = read () , a[i].c = read () ;
	for (int i = q ; i >= 1 ; i --) dfs (a[i].v , a[i].c , a[i].d) ;
	for (int i = 1 ; i <= n ; i ++) printf ("%d\n" , ans[i]) ;
} 
/*
7 7
1 2
1 3
1 4
4 5	
5 6
5 7
2 3
2
6 1 1
1 2 2
*/

Measured memory_bytes: 8448
#include<stdio.h>
#include<string.h>
main(){
	char s[102];
	int i=0,n;
	while(1){
		scanf("%c",&s[i]);
		if(s[i]=='\n') break;
		i++;
		//printf("%d",i);
	}
	n=i;
	for(i=0;i<n;i++){
		if(i%2&&s[i]=='R'){
			break;
		}
		else if(i%2==0&&s[i]=='L'){
			break;
		}
		if(s[i+1]=='\n'){
			printf("Yes");
			return 0;
		}
		//printf("%d %d\n",n,i);
	}
	printf("No");
	return 0;
}

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

int dp[1010][1010];
char l[1010][1010];

int main(){
	
	int n, m;
	scanf("%d %d ", &n, &m);
	
	for(int i = 0; i < n; i++){for(int j = 0; j < m; j++) scanf("%c", &l[i][j]); scanf("\n");}
	
	for(int i = n - 1; i >= 0; i--){
		for(int j = m - 1; j >= 0; j--){
			
			if(l[i][j] == '#') dp[i][j] = 0;
			else if((i == n - 2 && j == m - 1) || (i == n - 1 && j == m - 2)) dp[i][j] = 1;
			else dp[i][j] = ((i == n - 1 ? 0 : dp[i + 1][j]) % 1000000007 + (j == m - 1 ? 0 : dp[i][j + 1]) % 1000000007) % 1000000007;
		}
	}
	
	printf("%d", dp[0][0]);
	
	return 0;
}


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

int N, M;
int MAX = 1000;
vector<vector<int>>  D(MAX, vector<int>(MAX));
vector<vector<char>> S(MAX, vector<char>(MAX));
vector<int> dx = { 0, 1,  0, -1 };
vector<int> dy = { 1, 0, -1,  0 };
queue<pair<int, int>> Q;

int main() {
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			cin >> S.at(i).at(j);
			if (S.at(i).at(j) == '#') {
				Q.push({ i,j });
			}
		}
	}

	int ans = 0;
	while (!Q.empty()) {
		int x, y;
		tie(x, y) = Q.front();
		Q.pop();
		int d = D.at(x).at(y);
		ans = d;
		for (int k = 0; k < 4; k++) {
			int px = x + dx.at(k);
			int py = y + dy.at(k);
			if (px < 0 || px >= N || py < 0 || py >= M) continue;
			if (S.at(px).at(py) == '.') {
				Q.push({ px,py });
				S.at(px).at(py) = '#';
				D.at(px).at(py) = d + 1;
			}
		}
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 13456
#include <stdio.h>

typedef struct{
  int key;
  int pk;
  int l;
  int r;
} Node;

Node A[255];
int n;

void info(void)
{
  int i;
  for(i=1;i<n+1;i++)
    {
      if(i==1){
	A[i].pk=-1;
	A[i].l=A[2*i].key;
	A[i].r=A[2*i+1].key;
      }
      else{
	A[i].pk=A[i/2].key;
	
	if(n >= 2*i){
	  A[i].l=A[2*i].key;
	  A[i].r=A[2*i+1].key;
	}
      }
    }
}

int main()
{
  int i;

  scanf("%d",&n);
  for(i=1;i<n+1;i++)
    {
      scanf("%d",&A[i].key);
    }

  info();
 
  for(i=1;i<n+1;i++)
    {
      
      if(i==1) 
	printf("node %d: key = %d, left key = %d, right key = %d,",i,A[i].key,
	       A[i].l,A[i].r);
      else if(n>=2*i+1)
	printf("node %d: key = %d, parent key = %d, left key = %d, right key = %d,",i
	       ,A[i].key,A[i].pk,A[i].l,A[i].r);
      else if(n>=2*i)
	printf("node %d: key = %d, parent key = %d, left key = %d,",i
	       ,A[i].key,A[i].pk,A[i].l);
      else
	printf("node %d: key = %d, parent key = %d,",i,A[i].key,A[i].pk);

      printf(" \n");
    }

  return 0;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
//ll a[10000000], d[10000000];

signed main() {

    ll i, j, k, l, n, b, c, test, a;
    cin >> n >> k;
    ll sum = 0;
    for (i = 0; i < k; i++) cin>>b,sum += b;
    if (sum >= n) cout << "Yes";
    else cout << "No";
}

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

using namespace std;
const int mod = 1000000007;

int main() {
	int n;
	long long int val, sum = 0, ans = 0 ;
	vector<long long int> nums, suffix;
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> val;
		nums.push_back(val);
	}

	suffix.resize(n, 0);
	for (int i = n-1; i >= 0; i--) {
		sum = (sum + nums[i])%mod;
		suffix[i] = sum;
	}
	
	for (int i = 0; i < n - 1; i++) {
		ans = (ans + (nums[i] * suffix[i+1])%mod) % mod;
	}
	cout << ans;
	
	return 0;
}


Measured memory_bytes: 6408
import itertools
H, W = [int(_) for _ in input().split()]
S = [input() for _ in range(H)]
is_searched = [[False for _ in range(W)] for _ in range(H)]


def dfs(p, q):
    if is_searched[p][q] == 1:
        return 0
    count = {'#': 0, '.': 0}
    stack = [[p, q]]
    while stack:
        x, y = stack.pop()
        if is_searched[x][y] != 1:
            is_searched[x][y] = 1
            count[S[x][y]] += 1
            dxy = [[-1, 0], [1, 0], [0, -1], [0, 1]]
            for dx, dy in dxy:
                nx, ny = x + dx, y + dy
                if 0 <= nx < H and 0 <= ny < W and S[x][y] != S[nx][ny]:
                    stack += [[nx, ny]]
    return count['#'] * count['.']


ans = 0
for i, j in itertools.product(range(H), range(W)):
    ans += dfs(i, j)
print(ans)


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

vector<vector<int>> g(100000);
int k;
vector<bool> isVisited(100001);
map<pair<int,int>, int> m_id;
void dfs(int now, int now_color){
    int next_color = 1; // 次に使う色
    isVisited[now] = true;
    // 分岐
    rep(i,g[now].size()){
        int next = g[now][i];
        if(isVisited[next]) continue;
        if(next_color == now_color) next_color++;
        // 辺の色を記録
        m_id[make_pair(now,next)] = next_color;
        m_id[make_pair(next,now)] = next_color;
        k = max(k, next_color);
        dfs(next, next_color);
        next_color++;
    }
}

int main(){
    // 入力
    int n; cin >> n;
    int a,b;
    vector<pair<int,int>> edge(n);
    rep(i,n-1){
        cin >> a >> b;
        --a; --b;
        g[a].push_back(b);
        g[b].push_back(a);
        edge[i] = make_pair(a, b);
    }

    dfs(0,0);

    // 出力
    cout << k << "\n";
    rep(i,n-1) cout << m_id[edge[i]] << "\n";
}

Measured memory_bytes: 20480
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
const ll mod = 998244353;
int n;
ll x[205],y[205];
ll ans;
bool L(int a,int b,int c){
	ll X1 = x[b]-x[a];
	ll Y1 = y[b]-y[a];
	ll X2 = x[c]-x[a];
	ll Y2 = y[c]-y[a];
	return X1*Y2 == X2*Y1;
}
ll tri[205];
int main(){
	cin >> n;
	if(n <= 2){
		puts("0");
		return 0;
	}
	rep(i,n) cin >> x[i] >> y[i];
	for(int i=3;i<205;i++){
		tri[i] = 1;
		rep(j,i) tri[i] = tri[i]*2LL%mod;
		tri[i] -= 1 + i * (i+1) / 2;
	}
	ll ans = tri[n];
	rep(i,n) rep(j,n){
		if(i >= j) continue;
		int bad = 0;
		rep(a,j) if(a != i && L(a,i,j)){ bad = 1; break; }
		if(bad) continue;
		int C = 0;
		rep(x,n) C += L(i,j,x);
		if(C <= 2) continue;
		ans -= tri[C];
	}
	cout << (ans%mod+mod)%mod << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define ll long long
#define int ll
#define eps 1e-7
#define all(x) ((x).begin()),((x).end())
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
using pii = pair<int, int>;
using cd = int;
const bool debug = 0;

int32_t main()
{
    int D, T, S;
    cin >> D >> T >> S;
    if (D <= T*S)
        cout << "Yes\n";
    else cout << "No\n";
}

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

using namespace std;


#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 (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	vector <int> A;
	A.resize(3);
	cin >> A[0] >> A[1] >> A[2];
	if (A[0] + A[1] + A[2]>=22) {
		print("bust");
	}
	else {
		print("win");
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

int main(){
  string s; cin >> s;
  
  if(s.size()==2){
    if(s[0]==s[1]) printf("1 2\n");
    else printf("-1 -1\n");
    return 0;
  }
  
  for(int i = 2; i<s.size();i++){
    char a = s[i-2]; char b = s[i-1]; char c = s[i];
    
    if(a==b || a==c || b==c){
      printf("%d %d\n",i-1,i+1);
      return 0;
    }
  }
  
  printf("-1 -1\n");
  return 0;
}

Measured memory_bytes: 512
//2013
#include<iostream>
using namespace std;
int main(void){
	int i,p[3]={0},j[2]={0},minp=2000,minj=2000;
	for(i=0;i<3;i++){
		cin>>p[i];
		if(minp>p[i]){
			minp=p[i];
		}
	}
	for(i=0;i<2;i++){
		cin>>j[i];
		if(minj>j[i]){
			minj=j[i];
		}
	}
	cout<<minp+minj-50<<endl;
	
	return 0;
}


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

int A, B, C;

int main() {
    cin >> A >> B >> C;
    if (A + B >= C) {
        cout << B + C << endl;
        return 0;
    }
    
    cout << B * 2 + A + 1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	int i;
	int box[51];
	i=-1;
	while(1){
		//cout<<i<<endl;
		cin>>n;
		if(cin.eof())	break;
		if(n==0){
			cout<<box[i]<<endl;
			i--;
		}
		else{
			i++;
			box[i]=n;
		}
	}
	return 0;
}	


Measured memory_bytes: 3040
o(f,s,e,l){if(s==e)printf("%s%d%s",f?" ":"",s,l?"\n":"");else printf("%s%d-%d%s",f?" ":"",s,e,l?"\n":"");}
main(n,s,e,x,f){
	for(;scanf("%d",&n),n;o(f,s,e,1))
		for(scanf("%d",&s),e=s,f=0;--n;){
			scanf("%d",&x);
			if(x-e==1){e++;continue;}
			o(f,s,e,0);
			s=e=x,f=1;
		}
	return 0;
}

Measured memory_bytes: 0
h, w = [int(i) for i in input().split()]
# h%3=0 or w%3=0なら出力0
# それ以外の場合では
if h % 3 == 0 or w % 3 == 0:
    print(0)
    exit()
minDiff = h * w
for i in range(1, h):
    s1 = w * i
    s2 = int(w / 2) * (h - i)
    s3 = (w - int(w / 2)) * (h - i)
    if s1 > 0 and s2 > 0 and s3 > 0:
        minS = min(s1, min(s2, s3))
        maxS = max(s1, max(s2, s3))
        minDiff = min(minDiff, abs(maxS - minS))
for i in range(1, w):
    s1 = h * i
    s2 = int(h / 2) * (w - i)
    s3 = (h - int(h / 2)) * (w - i)
    if s1 > 0 and s2 > 0 and s3 > 0:
        minS = min(s1, min(s2, s3))
        maxS = max(s1, max(s2, s3))
        minDiff = min(minDiff, abs(maxS - minS))
for i in range(1, h):  # 縦に3分割する場合
    s1 = w * i
    s2 = w * (int((h - i) / 2))
    s3 = w * (h - i - int((h - i) / 2))
    if s1 > 0 and s2 > 0 and s3 > 0:
        minS = min(s1, min(s2, s3))
        maxS = max(s1, max(s2, s3))
        minDiff = min(minDiff, abs(maxS - minS))
for i in range(1, w):  # 横に3分割する場合
    s1 = h * i
    s2 = h * (int((w - i) / 2))
    s3 = h * (w - i - int((w - i) / 2))
    if s1 > 0 and s2 > 0 and s3 > 0:
        minS = min(s1, min(s2, s3))
        maxS = max(s1, max(s2, s3))
        minDiff = min(minDiff, abs(maxS - minS))
print(minDiff)


Measured memory_bytes: 3192
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007


const int MAX = 500005;
template <class T>
void print(vector<T> arr)
{
	cout << "start printing the vector\n";
	for (auto u : arr)
		cout << u << " ";
	cout << "\n";
}

template <class T>
void print_mat(vector<vector<T>> a)
{
	cout << "start printing the matrix\n";
	for (auto v : a)
	{
		for (auto e : v)
		{
			cout << e << " ";
		}
		cout << "\n";
	}
}

/******************************************
* NUMBER THEORY ;) *
******************************************/



ll powermod(ll x, ll y)
{
	ll res = 1;
	x = x % mod;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % mod;
		y = y >> 1;
		x = (x * x) % mod;
	}
	res %= mod;
	return res;
}
ll factmod(ll n)
{
	ll res = 1;
	while (n > 1)
	{
		res = (res * ((n / mod) % 2 ?  mod - 1 : 1)) % mod;
		for (ll i = 2; i <= n % mod; ++i)
			res = (res * i) % mod;
		n /= mod;
	}
	res %= mod;
	return res;
}


struct Query
{
	ll l, r, idx;
};

bool cmp(Query x, Query y)
{
	return x.r < y.r;
}

void update(int idx, int val, int bit[], int n)
{
	for (; idx <= n; idx += idx & -idx)
		bit[idx] += val;
}

int query(int idx, int bit[], int n)
{
	int sum = 0;
	for (; idx > 0; idx -= idx & -idx)
		sum += bit[idx];
	return sum;
}

void answeringQueries(int arr[], int n, Query queries[], int q)
{
	int bit[n + 1];
	memset(bit, 0, sizeof(bit));
	int last_visit[MAX];
	memset(last_visit, -1, sizeof(last_visit));
	int ans[q];
	int query_counter = 0;
	for (int i = 0; i < n; i++)
	{
		if (last_visit[arr[i]] != -1)
			update (last_visit[arr[i]] + 1, -1, bit, n);
		last_visit[arr[i]] = i;
		update(i + 1, 1, bit, n);
		while (query_counter < q && queries[query_counter].r == i)
		{
			ans[queries[query_counter].idx] =
			    query(queries[query_counter].r + 1, bit, n) -
			    query(queries[query_counter].l, bit, n);
			query_counter++;
		}
	}
	for (int i = 0; i < q; i++)
		cout << ans[i] << endl;
}



void solve()
{
	ll n, q;
	cin >> n >> q;
	int arr[n];
	for (ll i = 0; i < n; i++)
		cin >> arr[i];
	Query queries[q];
	for (ll i = 0; i < q; i++)
	{
		ll L, R;
		cin >> L >> R;
		queries[i].l =  L - 1;
		queries[i].r  = R - 1;
		queries[i].idx = i;
	}
	sort(queries, queries + q, cmp);
	answeringQueries(arr, n, queries, q);
}

int main()
{

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// ll t;
	// cin>>t;
	// while(t--)
	// {
	solve();
	// }

	return 0;
}

Measured memory_bytes: 23336
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#include <bitset>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define GI(i) (scanf("%d",&i))
#define GLL(i) (scanf("%lld",&i))
#define GD(i)  (scanf("%lf",&i))
#define PB          push_back
#define MP          make_pair
#define MT          make_tuple
#define GET0(x)     (get<0>(x))
#define GET1(x)     (get<1>(x))
#define GET2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       (1LL<<60)
#define LLMIN       -(1LL<<60)
#define IMAX        (1<<30)
#define IMIN        -(1<<30)
typedef long long LL;
using namespace std;

int main(void){
    string N;
    cin>>N;
    int ans = 0;
    REP(i,SZ(N))
        ans += N[i] - '0';
    REP(i,SZ(N)){
        if('0' < N[i]){
            int a = 0;
            REP(j,i + 1)
                a += N[j] - '0';
            a--;
            a += 9 * (SZ(N) - i -1);
            ans = max(a,ans);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
min, max, sum = 1000000, -1000000, 0
for i in range(n):
    if a[i] < min:
        min = a[i];
    if a[i] > max:
        max = a[i];
    sum += a[i];
print(min, max, sum)

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

using namespace std;

int main(){
  int A, B, C, X, Y;
  int x, y, z;
  cin >> A >> B >> C >> X >> Y;
  int long long ans = LLONG_MAX;
  for(int i = 0; i < 400000; i += 2){
    z = i;
    x = X - z / 2; 
    y = Y - z / 2;
    if(x < 0) x = 0;
    if(x > 100000) continue;
    if(y < 0) y = 0;
    if(y > 100000) continue;
    if(A * x + B * y + C * z <= 0) continue; 
    ans = min(ans,static_cast<long long int>(A * x + B * y + C * z));
  }
  cout << ans;
}

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

int main(){
  int N,kai=0;
  cin>>N;
  vector<int> h(N);
  vector<int> k(N);
  for(int i=0;i<N;i++){
    cin>>h.at(i);
    k.at(i)=h.at(i);
  }
  sort(k.begin(),k.end());
  reverse(k.begin(),k.end());
  for(int i=0;i<=k.at(0);i++){
    int t=0;
    if(h.at(0)>0)t++;
    if(h.at(N-1)>0)t++;
    for(int j=0;j<N-1;j++){
      if(h.at(j)>0&&h.at(j+1)<=0){
        t++;
      }else if(h.at(j)<=0&&h.at(j+1)>0){
        t++;
      }
    }
    for(int j=0;j<N;j++){
      h.at(j)--;
    }
    kai+=t/2;
  }
  cout<<kai<<endl;
  
  
  
}

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

int main(){
  int N,D ;
  cin >> N >> D;
  vector<vector<int>> X (N,vector<int>(D));
  for(int i=0;i<N;i++){
    for(int j=0;j<D;j++){
      cin >> X[i][j];
    }
  }
  int ans =0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;++j){
      int norm =0;
      for(int k=0;k<D;k++){
        int diff = abs(X[i][k]-X[j][k]);
        norm += diff*diff;
      }
      
      bool flag =false;
      for(int k=0;k<=norm;k++){
        if(k*k==norm){
          flag =true;
        }
      }
      if(flag)ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        max($x, max!($($z),*))
    }}
}

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

#[allow(unused_macros)]
macro_rules! debug { 
    ($($a: expr),*) => { 
        println!(concat!($(stringify!($a)," = {:?}, "),*), $($a),*);
    } 
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

fn solve() {
    let (n, q) = get!(usize, usize);
    let s = get!(String);
    let lr = get!(usize, usize; q);
    let mut vec = vec![0; n+1];
    let mut aflag = false;
    for (i, c) in s.chars().enumerate() {
        vec[i+1] = if c == 'C' && aflag {
            vec[i] + 1
        } else {
            vec[i]
        };
        aflag = c == 'A';
    }
    for (l, r) in lr {
        println!("{}", vec[r]-vec[l]);
    }
}


Measured memory_bytes: 11132
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	string S; cin >> S;
	if (S.size() >= 4) {
		if (S[0] == 'Y' && S[1] == 'A' && S[2] == 'K' && S[3] == 'I') cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else cout << "No" << endl;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N, M, X = MAP()

    C, A = [], []
    for i in range(N):
        c, *a = MAP()
        C.append(c)
        A.append(a)

    ans = INF
    for tup in list(product(range(2), repeat=N)):
        temp = [0 for _ in range(M)]

        for i in range(N):
            for j in range(M):
                if tup[i]:
                    temp[j] += A[i][j]

        flag = True
        for j in range(M):
            if temp[j] < X: flag = False

        if flag:
            money = 0
            for i in range(N):
                money += C[i] * tup[i]

            ans = min(money, ans)

    print(ans if ans != INF else -1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 10328
#include <iostream>
#include <algorithm>

constexpr int MAXN = 1000;
constexpr int MAXH = 10000;
int A[MAXN];
int B[MAXN];
int C[MAXH+1];

int main() {
    std::ios_base::sync_with_stdio(0);
    int h,n;
    std::cin >> h >> n;
    for (int i=0;i<n;++i) std::cin >> A[i] >> B[i];
    for (int i=1;i<=h;++i) C[i] = MAXH*MAXN*10;
    for (int j=1;j<=h;++j)
        for (int i=0;i<n;++i)
            C[j] = std::min(C[j], C[std::max(0, j-A[i])]+B[i]); // C[j]: oh shit, here we go again!
    std::cout << C[h] << std::endl;
    return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

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

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n; std::cin >> n;
  map<char, int> cnt;
  rep(i, n) {
    string s; std::cin >> s;
    if (s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H')
      cnt[s[0]]++;
  }
  vl vec;
  for (auto &p : cnt) vec.pb(p.se);
  int len = vec.size();
  ll ans = 0;
  rep(i, len) srep(j, i+1, len) srep(k, j+1, len) {
    ans += vec[i] * vec[j] * vec[k];
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 256