akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
# define mod 1000000007
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
string get_bin(ll n)
{
    string s = "";
    while(n > 0)
    {
        s += ('0' + n%2);
        n /= 2;
    }
    reverse(s.begin(), s.end());
    return s;
}

ll bin_to_dec(string s)
{
    ll ans = 0;
    for(auto ch: s)
    {
        ans *= 2;
        ans += (ch - '0');
    }
    return ans;
}
void PrintVector(vector<int> v,int n)
{

    for(int i=0;i<n;i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
int no_of_primeFactors(int n)  
{ 
    int count=0;
    while (n % 2 == 0)  
    {  
        count++;
        n = n/2;  
    }  
   
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    { 
        while (n % i == 0)  
        {  
           count++;
            n = n/i;  
        }  
        
    }  
    if (n > 2)  
        count++;
    return count;
} 
 ll gcd(int a, int b)
{ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
} 
   
  ll lcm(int a, int b)  
{  
    return (a/gcd(a, b)*b);  
}  



ll pwr(ll base,ll expo,ll m)
{
    if(base==0) return 0LL;
    if(expo==0) return (1LL%m);
    if((expo&1)==0) {ll temp=pwr(base,expo>>1,m); return (temp*temp)%m;}
    return ((base%m)*pwr(base,expo-1,m))%m;
}

int main(int argc, char const *argv[])
{
    ios;
    int t,ac=0,wa=0,tle=0,re=0;
    cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        if(s=="AC")
            ac++;
        else if(s=="TLE")
            tle++;
        else if(s=="WA")
            wa++;
        else if(s=="RE")
            re++;
    }

    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re;
    
    return 0;
}

Measured memory_bytes: 3680
def main():
    x, y = list(map(int, input().split()))
    if x < y:
        x, y = y, x
    n = gcd(x, y)
    print(n)

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x%y)

main()


Measured memory_bytes: 5600
ans = []
while 1:
    x = int(input())
    if x == -1:
        break
    if x <= 10:
        r = 1150
    elif x <= 20:
        r = 1150 + (x - 10) * 125
    elif x <= 30:
        r = 1150 + 1250 + (x - 20) * 140
    else:
        r = 1150 + 1250 + 1400 + (x - 30) * 160
    ans.append(4280 - r)
print(*ans, sep='\n')


Measured memory_bytes: 5608
x = input()
w = [int(i) for i in input().split()]
d = 0
for i in range(len(w) -2 ):
    if (w[i] > w[i+1] > w[i+2]) or (w[i] < w[i+1] < w[i+2]):
        d += 1

print(d)


Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

typedef struct
{
    int n, x[100], y[100];
} vectors_st;

double get_distance(vectors_st *vecs, int p)
{
    if (p > 0)
    {
        long diffsum = 0;
        for (int *x = vecs->x, *const xend = x + vecs->n, *y = vecs->y; x != xend; ++y, ++x)
        {
            diffsum += pow(abs(*x - *y), p);
        }
        return pow(diffsum, 1 / (double)p);
    }
    /* regarded as infinity */
    int diffmax = abs(vecs->x[0] - vecs->y[0]);
    for (int *x = vecs->x + 1, *const xend = vecs->x + vecs->n, *y = vecs->y + 1; x != xend; ++y, ++x)
    {
        const int diff = abs(*x - *y);
        diffmax = (diff > diffmax) ? diff : diffmax;
    }
    return (double)diffmax;
}
int main(int argc, char *argv[])
{
    vectors_st vecs;
    scanf("%d", &vecs.n);
    int *dest[] = {vecs.x, vecs.y};
    for (int **d = dest, **const dend = d + sizeof(dest) / sizeof(dest[0]); d != dend; ++d)
    {
        for (int *elm = *d, *const end = elm + vecs.n; elm != end; ++elm)
        {
            scanf("%d", elm);
        }
    }
    printf("%.8lf\n", get_distance(&vecs, 1));
    printf("%.8lf\n", get_distance(&vecs, 2));
    printf("%.8lf\n", get_distance(&vecs, 3));
    printf("%.8lf\n", get_distance(&vecs, -1));
    return 0;
}



Measured memory_bytes: 2116
<?php
list($x,$y) = ints();
if($x >= 2 && $y >= 2){
    $count = intdiv($x,2)*intdiv($y,2)*2;
    if($y%2==1)$count+=intdiv($x,2);
    if($x%2==1)$count+=intdiv($y,2);
    if($x%2==1 && $y%2==1)$count++;
    printf("%d", $count);
}else{
    echo 1;
}

function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}

function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array: ";
            echo implode(" ", addIndex($val))."\n";
        }else{
            echo "array:array\n";
            if(isCleanArray($val)){
                foreach($val as $row)echo implode(" ", addIndex($row))."\n";
            }else{
                foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row))."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}
function addIndex($val){
    if(!isCleanArray($val)){
        $val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);
    }
    return $val;
}
function isCleanArray($array){
    $clean = true;
    $i = 0;
    foreach($array as $k => $v){
        if($k != $i++)$clean = false;
    }
    return $clean;
}
/**
 * 座圧対象の配列を渡すと以下の値を返す
 * ・圧縮された配列
 * ・復元用のMap
 * ・圧縮用のMap
 **/
function atsu($array){
    $a = array_flip($array);
    $fuku = array_flip($a);
    sort($fuku);
    $atsu = array_flip($fuku);
    foreach($array as $i => $val)$array[$i] = $atsu[$val];
    return [$array, $fuku, $atsu];
}
//配列の最大公約数
function gcdAll($array){
    $gcd = $array[0];
    for($i = 1; $i < count($array); $i++){
        $gcd = gcd($gcd, $array[$i]);
    }
    return $gcd;
}

//最大公約数
function gcd($m, $n){
    if(!$n)return $m;
    return gcd($n, $m % $n);
}

//配列の最小公倍数
function lcmAll($array){
    $lcm = $array[0];
    for($i = 1; $i < count($array); $i++){
        $lcm = lcm($lcm, $array[$i]);
    }
    return $lcm;
}

//最小公倍数
function lcm($a, $b) {
    return $a / gcd($a, $b) * $b;
}
//ビットカウント-1の数を数える
function popcount($x){
    $con = 0;
    while ($x) {
        $x &= $x-1;
        ++$con;
    }
    return $con;
}


Measured memory_bytes: 4856
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<sstream>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

#define ARRAY_MAX 10001



int main(){

    int n;
    char k;

    while(cin >> n,n){

        string s;
        getline(cin,s);
        //cout << s << endl;
        map<string,int> mp;
        vector<pair<int,string> > vec;
        string tmp;

        REP(i,n){
            getline(cin,s);
            //cout << s << endl;
            stringstream ss;
            ss << s;
            while(ss >> tmp){
                mp[tmp]++;
            }
        }
        //cout << mp["and"] << endl;     
        cin >> k;
        map<string,int>::iterator ite;

        for(ite = mp.begin(); ite != mp.end();ite++){

            if(ite->first[0] == k){
                //cout << ite->first << ite->second << endl;
                vec.push_back( make_pair(-ite->second,ite->first));
            }
        }
        sort(vec.begin(),vec.end());

        if(vec.empty()){//NAのケース
            cout << "NA" << endl;
        }else{

            for(int i = 0; i < min(5,(int)vec.size());i++){
                if(i != 0){
                    cout << " ";
                }
                cout << vec[i].second;
            }
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3212
#include <iostream>
using namespace std;
int main() {
    int r,c,i,j;
    cin >> r >> c;
    int sp[r+1][c+1] = {};
    for (i=0;i<r;i++) {
        for (j=0;j<c;j++) {
            cin >> sp[i][j];
            sp[i][c] += sp[i][j];
            sp[r][j] += sp[i][j];
        }
        sp[r][c] += sp[i][c];
    }
    for (i=0;i<=r;i++) {
        for (j=0;j<c;j++) {
            cout << sp[i][j] << " ";
        }
        cout << sp[i][c] << endl;
    }
    return 0;
}

Measured memory_bytes: 3144
#include<algorithm>
#include<chrono>
#include<ctime>  
#include<climits>
#include<functional>
#include<numeric>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
// #include<bits/stdc++.h>
using namespace std;
 
struct Debug{
    int cnt = 0;
    bool on = false;
    char debug[10] = "debug";
    template<class T>
    Debug & operator<<(const T & v) {
        if(on && cnt++ == 0) cerr << "debug: ";
        if(on) cerr << v << ' ';
        return *this;
    }
    Debug & operator<<(ostream&(*pManip)(ostream&)) {
        if(on) cerr << (*pManip);
        cnt = 0;
        return *this;
    }
} debug;
#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define print(v) {if(debug.on){for(auto x : v) debug << x; debug << endl;}}
#define printn(v, n) {if(debug.on){for(int _i = 0; _i < n; _i++) debug << *(v + _i); debug << endl;}}
#define mini(a, b) a = min(a, b)
#define maxi(a, b) a = max(a, b)

typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

const int MAXN = 1e5 + 10;
int n, k;
int main(int argc, char * argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cout.tie(nullptr);
    if(argc > 1 && !strcmp(argv[1], debug.debug)) debug.on = true;

    cin >> n >> k;

    int pos = (n + 1) / 2;
    if(k + n - pos + k + 2 * n - 1 > k + 3 * n - 1) {
    	cout << -1 << endl;
    	return 0;
    }
    int cur = k + 3 * n - 1;
    for(int i = 0; i < pos; i++) {
    	cout << k + n - pos + i << ' ' << k + 2 * n - 1 - i * 2 << ' ' << cur-- << endl;
    }
    for(int i = 0; i < n - pos; i++) {
    	cout << k + i << ' ' << k + 2 * n - 2 - i * 2 << ' ' << cur-- << endl;
    }


    return 0;
 
}














Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<Z A,Z...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
const ll MAX=998244353,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void extended_euclid(ll x,ll y,ll *c,ll *a,ll *b){
  ll a0,a1,a2,b0,b1,b2,r0,r1,r2,q;r0=x;r1=y;a0=1;a1=0;b0=0;b1=1;
  while(r1>0){q=r0/r1;r2=r0%r1;a2=a0-q*a1;b2=b0-q*b1;r0=r1;r1=r2;a0=a1;a1=a2;b0=b1;b1=b2;}
  *c=r0;*a=a0;*b=b0;
}

ll get_inv(ll n, ll p){
  ll a,b,c;
  extended_euclid(n,p,&c,&a,&b);
  if(a<p) a+=p;
  return a%p;
}

ll fact[2000100],fact_inv[2000100];

void init() {
  fact[0]=1;
  REP(i,1,2000100) fact[i]=fact[i-1]*i%MAX;
  fact_inv[2000050]=get_inv(fact[2000050],MAX);
  rrep(i,2000050)fact_inv[i]=fact_inv[i+1]*(i+1)%MAX;
}

ll nCr(ll N,ll K){
  if(K<0||K>N)return 0;
  return fact[N]*fact_inv[K]%MAX*fact_inv[N-K]%MAX;
}

void Main() {
  init();
  ll n,m,k;
  cin >> n >> m >> k;
  ll d[n+1];
  mem(d);
  d[1]=m;
  REP(i,2,n+1) d[i]=d[i-1]*(m-1)%MAX;
  ll ans=0;
  rep(i,k+1) {
    ll x=nCr(n-1,i);
    x*=d[n-i];
    x%=MAX;
    ans+=x;
    ans%=MAX;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}

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

#define rep(i, n) for (int i = 0; i < (int) (n); i++)
typedef long long ll;


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

    int         N;
    int         max   = 0;
    int         count = 0;
    vector <ll> height(0);

    cin >> N;
    rep(i, N) {
        ll buf;
        cin >> buf;
        height.push_back(buf);
    }
    rep(i, N - 1) {
        if (height.at(i) >= height.at(i + 1)) {
            count++;
            if (i == N - 2 && max < count) {
                max = count;
            }
        }
        else {
            if (max < count) {
                max = count;
            }
            count = 0;
        }
    }
    cout << max << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  int n,a,b;cin>>n>>a>>b;

  out(min(a*n,b));

  return 0;
}


Measured memory_bytes: 256
def resolve():
    N, M = map(int, input().split())
    ans = [0] * (N+1)
    if N > 1:
        ans[1] = 1

    flag = [-1] * (N+1)
    for i in range(M):
        s, c = map(int, input().split())
        if flag[s] != -1 and flag[s] != c:
            print('-1')
            return
        if s == 1 and c == 0 and N > 1:
            print('-1')
            return
        ans[s] = flag[s] = c

    ansNum = 0
    for (i, n) in enumerate(ans[1:]):
        ansNum += n * 10 ** (N - i - 1)
    print(ansNum)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 38256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		String buf = br.readLine();
		String[] result = buf.split(" ");
		int a = Integer.parseInt(result[0]);
		int b = Integer.parseInt(result[1]);
		int area = a * b;
		int length = (a + b)*2;
		System.out.println(area + " " + length);
	}
}

Measured memory_bytes: 24200
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <map>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

bool sortByVal(const pair<string, int> &a, 
               const pair<string, int> &b) 
{ 
    return (a.second > b.second); 
} 

int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  map<string, int> mp;
  rep(i, n){
    string s;
    cin >> s;
    mp[s]++;
  }
  vector<pair<string, int>> vec;

	// copy key-value pairs from the map to the vector
  map<string, int> :: iterator it2;
  for (it2=mp.begin(); it2!=mp.end(); it2++) 
  {
    vec.push_back(make_pair(it2->first, it2->second));
  }

	// // sort the vector by increasing order of its pair's second value
  sort(vec.begin(), vec.end(), sortByVal); 
  int max_ = vec[0].second;
  vector<string> s_vec;
  for (int i = 0; i < vec.size(); i++)
	{
    if(max_ > vec[i].second) break;
    s_vec.push_back(vec[i].first);
	}
  sort(s_vec.begin(), s_vec.end());
  rep(i, s_vec.size()){
    cout << s_vec[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 36844
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n,i,ans=1e17;
	cin>>n;
	for(i=1;i*i<=n;i++)
	{
		if(n%i==0)
		{
			ans=min(ans,i+n/i-2);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int main()
{
	//tall:高さ wide:幅 diag:対角線
	int tall, wide, diag;
	//rect:長方形 loze:菱形
	int rect = 0, loze = 0;
	while(scanf("%d,%d,%d",&tall, &wide, &diag) != EOF)
	{
		if(diag == sqrt(tall*tall + wide*wide))
		{
			rect++;
		}
		else if(tall == wide)
		{
			loze++;
		}
	}
	printf("%d\n%d\n",rect, loze);
}

Measured memory_bytes: 1188
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let a = read_vec::<i64>();
    let a = a.iter().map(|&x| min(x, n as i64 + 1)).collect::<Vec<_>>();
    let mut a_m_i_count = HashMap::new();
    for i in 0..n {
        a_m_i_count.entry(a[i] - i as i64).or_insert(vec![]).push(i);
    }

    let mut ans = 0;
    for i in 0..n {
        let val = -(i as i64) - a[i];
        if !a_m_i_count.contains_key(&val) {
            continue;
        }
        let search = a_m_i_count[&val].upper_bound(&i);
        ans += a_m_i_count[&val].len() - search;
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

use std::cmp::Ordering;

pub trait BinarySearch<T> {
    fn upper_bound(&self, x: &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less | Ordering::Equal => {
                    low = mid + 1;
                }
                Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
}


Measured memory_bytes: 21620
#include<iostream>
#include <string>
#include<algorithm>
#include<functional>
using namespace std;


int main() {
	int num[100];
	int n, k,count=0;
	cin >> n >> k;
	for (int i = 0;i < n;i++) {
		cin >> num[i];
	}
	    sort(num, num + n);
		reverse(num, num + n);
	
	for (int j = 0;j < k;j++) {
		count += num[j];
	}
	cout << count << endl;
}


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

long long n;
long long d;
long long x,y;

long long ans = 0;

int main(){

	cin>>n>>d;

	for(int i=0;i<n;i++){
		cin>>x>>y;
		if(sqrt(x*x+y*y) <= d){
			ans++;
		}
	}

	cout<<ans<<endl;

	return(0);
}

Measured memory_bytes: 3616
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    const VEC(string) DAYS {"SUN", "MON", "TUE", "WED", "THU", 
                                "FRI", "SAT"};

    string S;
    cin >> S;
    int i = 0;
    while (DAYS[i] != S)
        i++;

    cout << 7 - i % 7 << endl;
    return 0;
};

Measured memory_bytes: 256
# coding: utf-8
import sys
A, B ,C , D = map(float, input().split())


def atack(a,b,c,d):
    c = c-b
    if c < 1:
        print('Yes')
        sys.exit()
    a = a- d
    if a <1:
        print('No')
        sys.exit()
    return a, b, c, d

for i in range(100):
    A, B ,C ,D = atack(A,B,C,D)

Measured memory_bytes: 9132
main :: IO ()
main = do
  getLine
  as <- map read . words <$> getLine
  putStrLn $ if solve as then "APPROVED" else "DENIED"

solve :: [Int] -> Bool
solve as = all p as
  where
    p x = or [ odd x, x `mod` 3 == 0, x `mod` 5 == 0] 


Measured memory_bytes: 892
#include <iostream>

using namespace std;

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a + b > c + d) {
		cout << "Left" << endl;
	} 
	else if (a + b == c + d) {
		cout << "Balanced" << endl;
	}
	else {
		cout << "Right" << endl;
	}
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define F first
#define s second
#define int long long		
int x[214514];
double y[214514];
string z[214514];
int sum[214514];
signed main(){
	ic(n)
	c(n*n*n)	
}	

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
const int N = 1e5;  // limit for array size
ll n;  // array size

vector<ll>v[100100];
bool vis[100100];
unordered_map<int,pii>m1;
int p[100100];

void dfs(int i){
	vis[i]=1;
	m1[i].FF=1;m1[p[i]].SS=1;
	for(int j=0;j<v[i].size();j++){
		if(vis[v[i][j]]==0){
			dfs(v[i][j]);
		}
	}
}

int main(){
	int n,m;cin>>n>>m;
	
	for(int i=1;i<=n;i++){
		cin>>p[i];
	}
	int a,b;
	for(int i=0;i<m;i++){
		cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
	}
	
	int ans=0;
	
	for(int i=1;i<=n;i++){
		if(vis[i]==0){
			m1.clear();
			dfs(i);
			unordered_map<int,pii>::iterator it;
		for(it=m1.begin();it!=m1.end();it++){
			if((*it).SS.FF==1&&(*it).SS.FF==(*it).SS.SS){
				ans++;
			}
		}
		}
		
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 12324
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

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

  vector<vector<int>> p2y(n);
  vector<int> p(m),y(m);
  rep(i,m){
    cin>>p[i]>>y[i];
    p[i]--;
    p2y[p[i]].pb(y[i]);
  }
  for(auto &v : p2y) sort(all(v));

  rep(i,m){
    printf("%06d%06d\n", p[i]+1, (int)(lower_bound(all(p2y[p[i]]), y[i]) - begin(p2y[p[i]])) + 1);
  }

  return 0;
}


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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

typedef pair<int,int> pii;
typedef long long int ll;

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

int n;

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


Measured memory_bytes: 764
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
int  main(){
  int N,K,B;
  str S1,S2,S3;
  cin>>N>>K>>B;
  if((N*100+K*10+B)%4==0)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  for(int i=0;i<n;i++) cin >> h[i];

  int cnt = 0;
  while(1){
    int left;
    left = 0;
    while(left < n && h[left] <= 0) left++;
    for(int i=left;i<n;i++){
      if(h[i] > 0){
        h[i]--;
      }else{
        cnt++;
        break;
      }
      if(i == n-1) cnt++;
    }

    bool f = true;
    for(int i=0;i<n;i++){
      if(h[i] > 0){
        f = false;
        break;
      }
    }

    if(f) break;
  }

  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i)
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef LOCAL
    ~debug() { cerr << endl; }
eni(!=) { cerr << boolalpha << i; ris; }
eni(==) { ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << &", " [ 2 * (it == d.b)] << *it;
  ris << "]";
}
#else
    sim dor(const c&) { ris; }
#endif
};
#define imie(...) "" << #__VA_ARGS__ " = " << (__VA_ARGS__) << ""
#define arr array
using ll = long long;
const int INF = 1e9 + 5;
const int N = 1e5 + 5;

//dp[i][j] = dp[day][act]
int main() {
	int n;
	scanf("%d",&n);
	vector<int> a(n),b(n),c(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	
	vector<vector<int>> dp(N,vector<int>(3));
	
	//i : days, j : curr_day_act, k : prev_day_act
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < 3; j++) {
			//Base case
			if(i == 0) {
				if(j == 0) {
					dp[i][j] = a[i];
				}else if(j == 1) {
					dp[i][j] = b[i];
				}else {
					dp[i][j] = c[i];
				}
			}else {
				for(int k = 0; k < 3; k++) {
					if(j == k) continue;
					if(j == 0) {
						dp[i][j] = max(dp[i][j],dp[i-1][k]+a[i]);
					}else if(j == 1) {
						dp[i][j] = max(dp[i][j],dp[i-1][k]+b[i]);
					}else {
						dp[i][j] = max(dp[i][j],dp[i-1][k]+c[i]);
					}
				}
			}
		}
	}
	cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])) << "\n";
			
    return 0;
}




Measured memory_bytes: 9928
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  ll r,c,k;
  cin>>r>>c>>k;
  vector<vector<ll>> value(r,vector<ll>(c,0));
  for (int i = 0; i < k; ++i)
  {
    ll r,c;
    cin>>r>>c>>value[r-1][c-1];
  }
  vector<vector<vector<ll>>> dp(
    r,vector<vector<ll>>(c,
      vector<ll>(4,0)));

  if(value[0][0]>0) dp[0][0][1]=value[0][0];

  for (int j = 1; j < c; ++j)
  {
    dp[0][j][0]=dp[0][j-1][0];
    dp[0][j][1]=max({dp[0][j-1][0]+value[0][j],
      dp[0][j-1][1]});
    dp[0][j][2]=max({dp[0][j-1][1]+value[0][j],
      dp[0][j-1][2]});
    dp[0][j][3]=max({dp[0][j-1][2]+value[0][j],
      dp[0][j-1][3]});
  }

  for (int i = 1; i < r; ++i)
  {
    dp[i][0][0]=max({dp[i-1][0][0],
      dp[i-1][0][1],dp[i-1][0][2],dp[i-1][0][3]});
    if(value[i][0]>0)
      dp[i][0][1]=dp[i][0][0]+value[i][0];
  }


  for (int i = 1; i < r; ++i)
  {
    for (int j = 1; j < c; ++j)
    {
      //(i,j)のマスにモノがないとき
      if(value[i][j]==0)
      {
        //上からくるか，一つも取ってない左からくるか
        dp[i][j][0]=max({dp[i][j-1][0],
          dp[i-1][j][0],dp[i-1][j][1],dp[i-1][j][2],dp[i-1][j][3]});
        //(i,j)でとらないなら，以前から同じだけとっていた場合の値
        dp[i][j][1]=dp[i][j-1][1];
        dp[i][j][2]=dp[i][j-1][2];
        dp[i][j][3]=dp[i][j-1][3];
      }
      //(i,j)のマスにモノがあるとき
      else
      {
        //とってないため既に全部取ってしまったケース
        dp[i][j][0]=max({dp[i][j-1][0],
          dp[i-1][j][0],dp[i-1][j][1],dp[i-1][j][2],dp[i-1][j][3]});

        //上からくるときはとるに限る
        //左からくるときはとってもとらなくてもよい
        dp[i][j][1]=max({dp[i][j-1][0]+value[i][j],
          dp[i][j-1][1],dp[i-1][j][0]+value[i][j],
          dp[i-1][j][1]+value[i][j],dp[i-1][j][2]+value[i][j],
          dp[i-1][j][3]+value[i][j]});


        dp[i][j][2]=max({dp[i][j-1][1]+value[i][j],
          dp[i][j-1][2]});
        dp[i][j][3]=max({dp[i][j-1][2]+value[i][j],
          dp[i][j-1][3]});
      }
    }
  }
  cout<<max({dp[r-1][c-1][0],dp[r-1][c-1][1],dp[r-1][c-1][2],dp[r-1][c-1][3]})<<endl;
}

Measured memory_bytes: 706804
#include <stdio.h>
#define N 3

int main() {
	int A[N], temp;
	int sum = 0;

	scanf("%d %d %d", &A[0], &A[1], &A[2]);

	for (int i = 0; i < N; ++i) {
		for (int j = N-2; j >= i; --j) {
			if (A[j+1] > A[j]) {
				temp = A[j+1];
				A[j+1] = A[j];
				A[j] = temp;
			}
		}
	}

	while(A[0] != A[1]) {
		++A[1];
		++A[2];
		++sum;
	}

	while (A[2] < A[0]) {
		A[2] += 2;
		++sum;
	}

	if (A[0] != A[2]) {
		++A[0];
		++A[1];
		++sum;
	}


	printf("%d\n", sum);

	return 0;
}

Measured memory_bytes: 128
;; -*- coding:utf-8 -*-

(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 1))
    #-swank '(optimize (speed 3) (safety 0) (debug 0))))

(defmacro print-line (obj &optional (stream '*standard-output*))
  `(prog1 (princ ,obj ,stream) (terpri ,stream)))


;; Hauptteil

(defun split-by-one-space (str size)
  (declare (optimize (speed 3) (safety 1))
           (simple-string str))
  (let ((dest-arr (make-array size :element-type 'fixnum)))
    (loop for idx below (length dest-arr)
          for pos1 = 0 then (1+ pos2)
          for pos2 = (position #\space str :start pos1 :test #'char=)
          do (setf (aref dest-arr idx)
                   (parse-integer str :start pos1 :end pos2))
          finally (return dest-arr))))

(deftype uint nil `(integer 0 ,(expt 10 9)))
(defun main ()
  (let* ((n (read))
         (m (read))
         (a-vec (split-by-one-space (read-line) n))
         (mod-bin (make-hash-table)))
    (loop for idx below n
          sum (aref a-vec idx) into local-sum
          do (let ((prefix-mod (mod local-sum m)))
               (if (nth-value 1 (gethash prefix-mod mod-bin))
                   (incf (gethash prefix-mod mod-bin))
                   (setf (gethash prefix-mod mod-bin) 1))))
    (print-line
     (+ (or (gethash 0 mod-bin) 0)
        (loop for x of-type fixnum being each hash-values in mod-bin
              sum (ash (* x (- x 1)) -1))))
    mod-bin))

#-swank(main)


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

using namespace std;

using ll=long long;

int main()
{
   int n;
   cin>>n;
   vector<int>b(n-1);
   for(int i=0;i<n-1;i++)
   {
       cin>>b[i];
   }
   vector<int>a(n);
   a[0]=b[0];
   a[1]=b[0];
   for(int i=1;i<n-1;i++)
   {
       a[i+1]=b[i];
       a[i]=min(a[i],b[i]);
   }
cout<<accumulate(a.begin(),a.end(),0)<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string.h>

using namespace std;
typedef struct
{
	char L[20 + 1];
	double value;
} data;
int main()
{
	int N;
	while (cin >> N && N != 0)
	{
		vector<data> v;
		int P, A, B, C, D, E, F, S, M;
		for (int i = 0; i < N; i++)
		{
			data d;
			cin >> d.L >> P >> A >> B >> C >> D >> E >> F >> S >> M;
			d.value = ((S * F * M) - P) * 1.0 / (A + B + C + (D + E) * M);
			v.push_back(d);
		}
		for (int i = 0; i < N - 1; i++)
		{
			for (int j = i + 1; j < N; j++)
			{
				if (v.at(i).value < v.at(j).value || (v.at(i).value == v.at(j).value && strcmp(v.at(i).L, v.at(j).L) > 0))
				{
					data tmp = v.at(i);
					v.at(i) = v.at(j);
					v.at(j) = tmp;
				}
			}
		}

		for (int i = 0; i < N; i++)
		{
			cout << v.at(i).L << endl;
		}

		cout << "#" << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    int n; cin>>n;
    vector<int> a(n), b(n);
    for(int i=0; i<n; i++) cin>>a[i];

    sort(a.begin(), a.end());

    ll sum = 0;
    int minusCnt = 0;
    for(int i=0; i<n; i++){
        sum += abs(a[i]);
        b[i] = abs(a[i]);
        if(a[i] < 0) minusCnt++;
    }

    sort(b.begin(), b.end());

    if(minusCnt % 2 == 0){
        cout << sum << endl;
    }
    else{
        cout << sum - abs(b[0] * 2) << endl;
    }
}

Measured memory_bytes: 1024
#include <cstdio>

int min(int x, int y){
    return (x<y) ? x : y;
}

int main(){
    int A, B, C, D;
    scanf("%d%d%d%d", &A, &B, &C, &D);
    printf("%d\n", min(A,B)+min(C,D));
    return 0;
}

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

using namespace std;
using ll = long long;

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

	int res = 0;
	int tmp = 0;
	string t = "ACGT";
	for (int i = 0; i < s.size(); ++i) {
		bool cnt = false; 
		for (int j = 0; j < 4; ++j) {
			cnt = cnt || (s[i] == t[j]);
		}
		if (cnt) { ++tmp; }
		else {
			res = max(res, tmp);
			tmp = 0;
		}
	}

	cout << max(res, tmp) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

vector<int> edge[1010];
vector<int> path;

int ans = 0;
int n,m;

void verify(vector<int> now){
    int t = now.size();
    // rep(i,t) cout<<now[i]<<" ";
    // cout<<endl;

    for(int i=0;i<t-1; i++){
        bool isok = false;
        for(auto a : edge[now[i]]){
            if(a == now[i+1]) isok = true;
        }
        if(!isok) {
            return;
        }
    }
    ans++;
    return;
}

void dfs(vector<int> now){
    if(now.size()==n){
        verify(now);
        return;
    }
    now.push_back(1);
    while(now.back() < n) {
        now.back()++;
        int t=0;
        for(auto a : now) {
            if(a==now.back()) t++;
        }
        if(t>1) continue;
        dfs(now);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>m;
    rep(i,m){
        int a,b;cin>>a>>b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    path.push_back(1);
    dfs(path);
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
typedef long long ll;

const double PI = acos(-1);
int main() {
    double a, b, x;
    cin >> a >> b >> x;
    if(a * a * b / 2.0 < x) {
        double lb = 0, ub = b;
        for(int i = 0; i < 500; i++) {
            double mid = lb + (ub - lb) / 2.0;
            if(((mid + b) * a * a) / 2.0 < x)
                lb = mid;
            else
                ub = mid;
        }
        cout << fixed << setprecision(10) << (atan2(b - ub, a) * 180.0) / PI
             << endl;
    } else {
        double lb = 0, ub = a;
        for(int i = 0; i < 500; i++) {
            double mid = lb + (ub - lb) / 2.0;
            if((mid * a) * b / 2.0 < x)
                lb = mid;
            else
                ub = mid;
        }
        cout << fixed << setprecision(10) << 90.0 - (atan2(ub, b) * 180.0) / PI
             << endl;
    }

    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();
		int ar[]=new int[n+3];
		for(int i=1;i<=n;i++)
		{
			ar[i]=scan.nextInt();
		}
		long totwork=0;
		for(int i=1;i<=n;i++)
		{
			totwork+=Math.abs(ar[i]-ar[i-1]);
			
		}
		totwork+=Math.abs(ar[n]);
//		System.out.println(totwork);
		for(int i=0;i<n;i++)
		{
			//exclude i
			long foo=Math.abs(ar[i]-ar[i+1])+Math.abs(ar[i+1]-ar[i+2]);
			long gg=Math.abs(ar[i+2]-ar[i]);
			System.out.println(totwork-foo+gg);
		}
			
		}
	}



Measured memory_bytes: 63464
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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 (b<a) { a=b; return 1; } return 0; }

// constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
// constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

// template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    VI a(n);
    REP(i,0,n) cin >> a[i];
    int g = a[0];
    REP(i,1,n) g = gcd(g,a[i]);
    if (g != 1) {
        cout << "not coprime" << endl;
        return;
    }

    dump("dump");
    constexpr int maxn = 1000000;
    vector<bool> isprime(maxn+1,true);
    isprime[0] = isprime[1] = false;
    REP(i,2,maxn+1) {
        if (!isprime[i]) continue;
        for (int j = i * 2; j <= maxn; j += i) isprime[j] = false;
    }

    dump("dump");
    VI ps;
    map<int, int> m;
    int idx = 0;
    REP(i,2,maxn+1) if (isprime[i]) {
        if (1LL * i * i <= 1LL * maxn) ps.push_back(i);
        m[i] = idx++;
    }
    // cout << ps.size() << endl;
    // {
    //     int cnt = 0;
    //     REP(i,0,ps.size()) cnt += 1LL * ps[i] * ps[i] <= 1LL * maxn;
    //     dump(cnt); 
    //     REP(i,0,ps.size()) if (1LL * ps[i] * ps[i] <= 1LL * maxn) dump(ps[i]);
    // }
    dump("dump");
    VI cnt(m.size());
    REP(i,0,n) {
        if (m.count(a[i])) {
            cnt[m[a[i]]]++;
            continue;
        }
        int v = a[i];
        REP(j,0,ps.size()) {
            if (v % ps[j] != 0) continue;
            cnt[j]++;
            while (v % ps[j] == 0) v /= ps[j];
        }
        if (v > 1) cnt[m[v]]++;
    }
    dump("dump");
    for (auto &v: cnt) {
        if (v > 1) {
            cout << "setwise coprime" << endl;
            return;
        }
    }
    cout << "pairwise coprime" << endl;
}

signed main() {
    solve();
    
    return 0;
}

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

int main() {
  long long int n, k;
  cin>>n>>k;
  if(2*n<=k){cout<<n;}
  if(2*n>k && k>=n)cout<<k-n;
  if(n>k){
    long long int m =n/k;
    long long int ans=min(n-m*k,(m+1)*k-n );
    cout<<ans;
  }
}






Measured memory_bytes: 256
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
//#include <bits/stdc++.h>

#define all(v) v.begin(), v.end()
typedef long long ll;
#define rep(i, z, n) for(int i = z; i < n; i++)
//const int INF = 1<<29;
//const ll MOD = 1000000007;
using namespace std;

int main(){
    vector<char> S(3);
    rep(i, 0, 3) cin >> S.at(i);
    int count = 0, ans = 0;
    rep(i, 0, 3){
        if(S.at(i) == 'R'){
            count++;
        }
        else{
            ans = max(count, ans);
            count = 0;
        }
    }
    ans = max(count, ans);
    cout << ans << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;
typedef std::queue<long> QI;
#define rep(i,n) for(long i = 0; i < (long)n; ++i)
const double pi = M_PI;
const long mod = 1000000007;
 
template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}
 
struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long n, a, b, c, d; scan(n, a, b, c, d);
      bool res = false;
      for(long i = 2; i < n; ++i) {
         long left1  = a + (i-1) * c;
         long right1 = a + (i-1) * d;
         long left2  = b + (n-i) * c;
         long right2 = b + (n-i) * d;
         bool t =
            ( left1 <= right2 and right2 <= right1 ) or
            ( left1 <= left2  and left2  <= right1 );
         res = res or t;
      }
      puts(res ? "YES" : "NO");
   }
};
 
int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin >> S;
    int res = 1e9;
    for(int i = 0; i < S.size() - 2; ++i){
        int x = (S[i] - '0') * 100 + (S[i+1] - '0') * 10 + S[i+2] - '0';
       // if(x == 753) res = 0;
        res = min(res, abs(753 - x));
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <climits>
#include <deque>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

int m[1000];
int l[1000];
int k[1000];
int t;
int n;

int cando(int p){
  vector<bool> ok(n, false);
  int cnt = 0;
  priority_queue<int> op;
  
  REP(i,p) op.push(0);
  
  while(op.size() && cnt != n){
    int tm = - op.top(); op.pop();
    
    if(tm >= t) break;
    
    pair<int, int> process = make_pair(INT_MAX, INT_MAX);
    
    int tmp = 0;
    
    REP(i,n) if(!ok[i]){
      int next;
      if(tm % (l[i] + k[i]) <= l[i]) next = tm;
      else next = (l[i] + k[i]) * ((tm + k[i]) / (l[i] + k[i]));
      process = min(process, make_pair(next, i));
      tmp += m[i];
    }
    
    if(tmp > p * (t - tm)) break;
    
    if(process.first != INT_MAX){
      if(process.first + m[process.second] <= t){
	op.push(- (process.first + m[process.second]));
	ok[process.second] = true;
	cnt++;
      }else{
	break;
      }
    }
  }
  
  return cnt == n;
}

int main(){
  while(true){
    n = getInt();
    t = getInt();

    if(n + t == 0) break;

    int mm = 0;

    REP(i,n){
      m[i] = getInt();
      l[i] = getInt();
      k[i] = getInt();

      mm += m[i];
    }

    int low  = 1;
    int high = n;

    while(low + 1 < high){
      int mid = (low + high) / 2;

      if(cando(mid)){
	high = mid;
      }else{
	low = mid;
      }
    }

    // printf("mid = %d\n", (low + high) / 2);
    for(int i = max(1, low - 2); ; i++){
      if(cando(i)){
	printf("%d\n", i);
	break;
      }
    }

  }

  return 0;
}

Measured memory_bytes: 940