akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; using ll = long long; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int X;
    cin >> X;
    write(360 / gcd(360, X));
}


Measured memory_bytes: 3580
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    B = [(i+1)+a for i, a in enumerate(A)]
    from collections import Counter
    c = Counter()

    ans = 0
    for j in range(N):
        i = j
        v = (j+1) - A[j]
        ans += c[v]
        c[B[i]] += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 124728
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int
P = get_ints

count = 0
P.each_cons(3) do |a, b, c|
  count += 1 if [a, b, c].sort[1] == b
end

puts count


Measured memory_bytes: 14396
#include<stdio.h>

#define MAX 25
#define ZERO -1

typedef struct Node{
  int parent;
  int left;
  int right;
  int Left;
  int Right;
}Tree;

Tree tree[MAX];

void TreePrint(int); //print関数

int TreeHeight(int,int); //heightを求める関数

int main(){

  int i,j; 
  int n;
  int id,left,right;

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    tree[i].parent = tree[i].left = tree[i].right = tree[i].Left = tree[i].Right = ZERO;
  }
  for(i = 0;i < n;i++){
    scanf("%d%d%d",&id,&left,&right);

    tree[id].left = left;
    tree[right].Left = left;

    tree[id].Right = right;
    tree[left].right = right;

    tree[left].parent = id;
    tree[right].parent = id;
  }
  for(i = 0;i < n;i++){
    TreePrint(i);
  }
  return 0;
}

void TreePrint(int n){

  int i = tree[n].parent;
  int j = tree[n].Right;
  int depth = 0, degree = 0;
  int height;
  int sibling = ZERO;

  while(i != ZERO){
    i = tree[i].parent;
    depth++;
  }

  height = TreeHeight(n,0);

  if(tree[n].Left == ZERO && tree[n].right != ZERO){
    sibling = tree[n].right;
  }
  else if(tree[n].Left != ZERO && tree[n].right == ZERO){
    sibling = tree[n].Left;
  }

  if(tree[n].left == ZERO && tree[n].Right == ZERO){
    degree = 0;
  }
  else if(tree[n].left == ZERO || tree[n].Right == ZERO){
    degree = 1;
  }
  else if(tree[n].left != ZERO && tree[n].Right != ZERO){
    degree = 2;
  }

  if(depth == 0){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, root\n",n,tree[n].parent,sibling,degree,depth,height);
  }
  else if(tree[n].left == ZERO && tree[n].Right == ZERO){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, leaf\n",n,tree[n].parent,sibling,degree,depth,height);
  }
  else{
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, internal node\n",n,tree[n].parent,sibling,degree,depth,height);
  }
}

int TreeHeight(int n,int time){

  int i = time;
  int j = time;

  if(tree[n].left != ZERO){
    i = TreeHeight(tree[n].left,time+1);
  }
  if(tree[n].Right != ZERO){
    j = TreeHeight(tree[n].Right,time+1);
  }
  if(i < j){
    i = j;
  }
  return i;
}

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

int main(){
  int n; cin >> n;
  vector<int> x(n), y(n), h(n);
  for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> h[i];
  for (int i = 0; i < n; i++) {
    if (h[i] != 0) {
      if (i == 0) break;
      swap(x[0], x[i]); swap(y[0], y[i]); swap(h[0], h[i]);
    }
  }
  for (int cx = 0; cx <= 100; cx++) {
    for (int cy = 0; cy <= 100; cy++) {
      bool ok = true; int st = 0;
      for (int i = 0; i < n; i++) {
        if (!ok) break;
        if (i == 0) {
          st = h[i] + abs(cx - x[i]) + abs(cy - y[i]);
        }
        if (h[i] != 0) {
          if (st != h[i] + abs(cx - x[i]) + abs(cy - y[i])) {
            ok = false;
            break;
          }
        } else {
          if (st - (abs(cx - x[i]) + abs(cy - y[i])) > 0) {
            ok = false;
            break;
          }
        }
      }
      if (ok) {
        cout << cx << " " << cy << " " << st << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let s=read::<String>().chars().collect::<Vec<char>>();
    for i in 0..s.iter().size_hint().0{
        if i%2==0{print!("{}",s[i as usize])}
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define mset(x,y) memset(x,y,sizeof(x))
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define rng(i,a,b) for(int i=int(a);i<=int(b);i++)
#define gnr(i,b,a) for(int i=int(b);i>=int(a);i--)
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
#ifdef LOCAL
#define dmp(...) _dmp(#__VA_ARGS__, __VA_ARGS__)
#else
#define dmp(...) (__VA_ARGS__)
#endif
template<class T> using vt=vector<T>;
template<class T> using vvt=vt<vt<T>>;
template<class TA,class TB> void chmax(TA&a,TB b){if(a<b)a=b;}
template<class TA,class TB> void chmin(TA&a,TB b){if(b<a)a=b;}
template<class TA,class TB>
ostream& operator<<(ostream& os,const pair<TA,TB>& p){
	return os<<"{"<<p.fi<<","<<p.se<<"}";
}
template<class T> ostream& operator<<(ostream& os,const vt<T>& v){
	os<<"{";for(auto& e:v)os<<e<<",";return os<<"}";
}
template<class TH> void _dmp(const char *sdbg, TH h){cout<<sdbg<<"="<<h<<endl;}
template<class TH, class... TA> void _dmp(const char *sdbg, TH h, TA...a){
while(*sdbg!=',')cout<<*sdbg++;cout<<"="<<h<<","; _dmp(sdbg+1, a...);
}
template<class T> void make_unique(vt<T>& v) {
	sort(all(v));v.erase(unique(all(v)),v.end());
}
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
int ri(){int x;cin>>x;return x;}
ll rll(){ll x;cin>>x;return x;}
vi rvi(int n){vi v;rep(i,n)v.pb(ri());return v;}
ll A,B,N;
void MAIN() {
	cin>>A>>B>>N;
	cout<<A*min(B-1,N)/B;
}
int main() {
	ios::sync_with_stdio(false);cin.tie(0);
	int T=1;
	//cin>>T;
	for(int tt=1;tt<=T;tt++) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <random>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr ll INF = 1LL << 60;

ll a, b, c;


int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> a >> b >> c;
  swap(a, b);
  swap(a, c);
  cout << a << " " << b << " " << c;
  return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#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 srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int x;
    cin >> x;
    int d2 = x % 100;

    while(x > 0) {
        if (d2 >= 5) {
            d2 -= 5;
            x -= 100;
        }
        else if(d2 >= 4) {
            d2 -= 4;
            x -= 100;
        }
        else if(d2 >= 3) {
            d2 -= 3;
            x -= 100;
        }
        else if(d2 >= 2) {
            d2 -= 2;
            x -= 100;
        }
        else if(d2 >= 1) {
            d2 -= 1;
            x -= 100;
        }
        if (d2 == 0) break;
    }
    if (x < 0) cout << '0' << endl;
    else cout << '1' << endl;
    return 0;
}


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

#define int long long
#define REP(i, n) for ( int i = 0; i < (n); i++ )

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string A = "", B = "";
  int a, b;
  cin >> a >> b;

  for ( int i = 0; i < a; i++ ) {
    A.push_back('0'+b);    
  }
  for ( int i = 0; i < b; i++ ) {
    B.push_back('0'+a);    
  }

  cout << min(A, B) << endl;
  
  return 0;
}


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

using namespace std;

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

  int n;
  cin >> n;

  vector<long> a(n);
  for (auto& e : a) {
    cin >> e;
  }

  sort(a.begin(), a.end(), greater<long>());

  long l = 0;
  for (int i = 0; i < n - 1; i++) {
    if (a[i] == a[i+1]) {
      if (l != 0) {
        cout << l * a[i] << endl;
        return 0;
      }
      l = a[i];
      i++;
    }
  }
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<ll> v32;
typedef vector<vector<ll> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 1e9+7 ;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define vvv64 vector<vv32>
#define vvvv64 vector<vvv32>
 
ll exp(ll n, ll e)
{
    if (e==0)
        return 1;
    ll temp=exp((n*n)%MOD,e/2);
    return e%2==0 ? temp : (temp*n)%MOD;
}


void solve()
{
    char a;
    cin >> a;
    cout <<char(a+1);   
}
 
int main() {
    fast_cin();
    int t=1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<utility>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a>b){
    swap(a,b);
  }
  for(int i=0;i<b;i++){
    cout<<a;
  }
  cout<<endl;
  return(0);
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,a[100000],b,c[50000],i,k=0,j;
  for(cin>>n,i=0;i<n;i++)cin>>a[i];
  for(cin>>b,i=0;i<b;i++)cin>>c[i];
  for(i=0;i<b;i++)if(binary_search(a,a+n,c[i]))k++;
  cout<<k<<endl;
}


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

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

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

  int n, p; cin >> n >> p;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int odd = 0, even = 0;
  rep(i, n) {
    if(a[i]&1) odd++;
    else even++;
  }

  ll ans;
  if(odd == 0) {
    if(p == 0) ans = 1LL << n;
    else ans = 0;
  } else {
    ans = (1LL << even)*(1LL << (odd-1));
  }

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


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		List<char> L = new List<char>();
		for(int i=0;i<(ty-sy);i++) L.Add('U');
		for(int i=0;i<(tx-sx);i++) L.Add('R');
		for(int i=0;i<(ty-sy);i++) L.Add('D');
		for(int i=0;i<(tx-sx);i++) L.Add('L');
		L.Add('L');
		for(int i=0;i<(ty-sy)+1;i++) L.Add('U');
		for(int i=0;i<(tx-sx)+1;i++) L.Add('R');
		L.Add('D');
		L.Add('R');
		for(int i=0;i<(ty-sy)+1;i++) L.Add('D');
		for(int i=0;i<(tx-sx)+1;i++) L.Add('L');
		L.Add('U');
		Console.WriteLine(new String(L.ToArray()));
	}
	int sx,sy,tx,ty;
	public Sol(){
		var d = ria();
		sx = d[0];
		sy = d[1];
		tx = d[2];
		ty = d[3];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 2904
H, W, K = map(int, input().split())
M = []
for h in range(H):
    col = []
    s = input()
    for w in range(W):
        if s[w] == '.':
            col.append('.')
        else:
            col.append('#')
    M.append(col)
    

result = 0
for i in range(2 ** (H + W)):
    bag = []
    for j in range(H  + W): 
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う 
            bag.append(j)  # フラグが立っていたら bag に追加
    
    #main
    #print(bag)
    
    hight_list =[]
    width_list = []
    for b in bag:
        if b < H:
            hight_list.append(b)
        else:
            width_list.append(b - H)
    
    count = 0
    for r_h in hight_list:
        for r_w in width_list:
            if M[r_h][r_w] == '#':
                count+=1
    
    if count == K:
        result+=1
        
print(result)

Measured memory_bytes: 9232
#include<stdio.h>
int main(void)
{
    int n;
    int a[100];
    int list[8]={0};
    int list2[8]={0};
    int after=0;

    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]>=1&a[i]<=399)list[0]++,list2[0]++;
        else if(a[i]>=400&&a[i]<=799)list[1]++,list2[1]++;
        else if(a[i]>=800&&a[i]<=1199)list[2]++,list2[2]++;
        else if(a[i]>=1200&&a[i]<=1599)list[3]++,list2[3]++;
        else if(a[i]>=1600&&a[i]<=1999)list[4]++,list2[4]++;
        else if(a[i]>=2000&&a[i]<=2399)list[5]++,list2[5]++;
        else if(a[i]>=2400&&a[i]<=2799)list[6]++,list2[6]++;
        else if(a[i]>=2800&&a[i]<=3199)list[7]++,list2[7]++;
        else{
            after++;
        }
    }
    for(int i=0;i<after;i++){
        int j=0;
        j=0;
        while(list2[j]==0&&j<=6){
            j++;
        }
        list2[j]++;
    }
    int cnt=0;
    for(int i=0;i<8;i++){
        if(list2[i]>=1){
            cnt++;
        }
        //printf("%d ",list2[i]);
    }
    if(n==after){
        printf("%d %d\n",cnt,cnt+after-1);
        return 0;
    }
    printf("%d %d\n",cnt,cnt+after);
    return 0;
}

Measured memory_bytes: 128
num= input().split()
count5 = 0
count7 = 0
 
for i in range(len(num)):
    if num[i] == '5':
        count5 += 1
    elif num[i] == '7':
        count7 += 1
    else:
        continue
if count5 == 2 and count7 == 1:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 2940
#include<queue>
#include<cstdio>
#include<cctype>
#include<algorithm>
using namespace std;
int n,m,l,r,tot,ans,tmp[200010];
pair<int,int>a[200010];
priority_queue<int>q;
char buffer[10000010],*hed;
char Getchar(){
	return *hed++;
}
int rd(){
	int x=0;
	char c;
	do c=Getchar();
	while(!isdigit(c));
	do{
		x=(x<<1)+(x<<3)+(c^48);
		c=Getchar();
	}while(isdigit(c));
	return x;
}
int main(){
	fread(buffer,1,10000000,stdin);
	hed=buffer;
	n=rd(),m=rd();
	l=1,r=m;
	for(int i=1;i<=n;i++)
		a[i].first=rd(),a[i].second=-rd();
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++){
		q.push(a[i].second);
		if(l<=r&&l<=a[i].first)
			l++;
		else{
			tmp[++tot]=-q.top();
			q.pop();
		}
	}
	sort(tmp+1,tmp+tot+1);
	for(int i=tot;i>=1;i--){
		if(l<=r&&tmp[i]<=r)
			r--;
		else ans++;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 8824
#include <iostream>
#include <vector>
using namespace std;
int main(){

  int p,q,use;
  int so[40000]={0};

  cin>>p>>q;
  use=q;
  int a;
  while(q%p!=0){
    a=q%p;
    q=p;
    p=a;
  }
  use/=p;
  q=use;
  vector <int> sonaka;
  for(int i=2;i<40000;i++) if(so[i]==0){
      sonaka.push_back(i);
      for(int j=i*2;j<40000;j+=i) so[j]=1;
    }
  int result=1;
  for(int i=0;sonaka[i]<=use&&i<sonaka.size();i++){
    if(use%sonaka[i]==0){
      result*=sonaka[i];
      while(use%sonaka[i]==0) use/=sonaka[i];
    }
  }

  cout<<result*use<<endl;
  return 0;
}

Measured memory_bytes: 3320
module Main where

import Data.Functor
import Data.List

main :: IO ()
main = do
  { xs <- getInts
  ; let ys = sort xs
  ; putInts ys
  }


getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

Measured memory_bytes: 3620
package main

import (
    "fmt"
    "os"
    "bufio"
    "strings"
    "strconv"
    "sort"
)

func main() {
    var fp *os.File = os.Stdin
    reader := bufio.NewReaderSize(fp, 1024)

    N, _ := strconv.Atoi(readLine(reader))
    line := readLine(reader)
    arr := strings.Split(line, " ")
    var arr2 []int

    for _, v := range arr {
        num, _ := strconv.Atoi(v)
        arr2 = append(arr2, num)
    }

    sort.Sort(sort.IntSlice(arr2))
    fmt.Println(arr2[N-1]-arr2[0])
}

func readLine(reader *bufio.Reader) string {
    buf := make([]byte, 0, 1024)

    for {
        l, p, _ := reader.ReadLine()

        buf = append(buf, l...)

        if !p {
            break
        }
    }

    return string(buf)
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;

int main()
{
    int n, k;
    int ans = 0;
    cin >> n >> k;
    vector<int> l(n);
    for (int i = 0; i < n; i++) cin >> l[i];

    sort(l.begin(), l.end());
    for (int i = n - 1; i >= (n - 1) - (k - 1); i--){
        ans += l[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>

int main() {

    int x,a,b;
    
    scanf("%d %d %d", &x, &a, &b);
    
    if(a>=b){
        printf("delicious");
    }else{
        
        if(b-a>=x+1){
            printf("dangerous");
        }else{
            printf("safe");
        }
        
    }
    
    
    return 0;

}


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

#define mainspring cout<<"mainspring\n";
#define barrel cout<<"barrel\n";
#define escapement cout<<"escapement\n";

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second
#define tik(i,a,b) for(int i = a; i < b; i++)
#define tok(i,a,b) for(int i = a; i >= b; i--)
#define error(args...) {string _s = #args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it,args);}

typedef long long ll;
typedef unsigned long long ull;

#define int ll 

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << " ";
    err(++it, args...);
}

const int MOD = 1E9 + 7, MAXN = 2E5 + 100;
int f_inv[MAXN], f[MAXN], dp1[MAXN], dp2[MAXN], des[MAXN], inv[MAXN], n;
vvi adj(MAXN);

ll pow(ll x, ll y) {
	if(y == 0)
	return 1;
	ll temp = pow(x, y/2);
	temp = (temp*temp)%MOD;
	if(y%2 == 1)
		temp *= x;
	return temp%MOD;
}

void DFS(int u = 0, int p = 0) {
	des[u] = 1;
	dp1[u] = 1;
	for(int v : adj[u]) {
		if(v != p) {
			DFS(v, u);
			des[u] += des[v];
			dp1[u] = (dp1[u]*dp1[v])%MOD;
			dp1[u] = (dp1[u]*f_inv[des[v]])%MOD;
		}
	}
	dp1[u] = (dp1[u]*f[des[u] - 1])%MOD;
}

void reroot(int u = 0, int p = 0) {
	//reroot to each child of u
	for(int v : adj[u]) {
		if(v == p)
			continue;
		dp2[v] = (dp2[u]*des[v])%MOD;
		dp2[v] = (dp2[v]*inv[des[0] - des[v]])%MOD;
		reroot(v, u);
	}
}

int32_t main() {
	f_inv[0] = f[0] = 1;
	for(int i = 0; i < MAXN - 1; i++) {
		f_inv[i + 1] = (f_inv[i]*pow(i + 1, MOD - 2))%MOD;
		f[i + 1] = (f[i]*(i + 1))%MOD;
	}
	inv[1] = 1;
	for(int i = 2; i < MAXN; i++)
		inv[i] = pow(i, MOD - 2);
	cin >> n;
	for(int i = 0, u, v; i < n - 1; i++) {
		cin >> u >> v, --u, --v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	DFS();
	dp2[0] = dp1[0];
	reroot();
	for(int i = 0; i < n; i++) {
		cout << dp2[i] << '\n';
	}
}

Measured memory_bytes: 24176
#include<iostream>
using namespace std;
static const int MAX = 100;

void inputData(int *R, int *N)
{
	cin >> *N;
	for (int i = 0; i < *N; i++)
	{
		cin >> R[i];
	}
}

void traceData(int *R, int N)
{
	int i;
	for (i = 0; i < N; i++)
	{
		if (i)	cout << " ";
		cout << R[i];
	}
	cout << endl;
}

int selectionSort(int *R, int N)
{
	int swappingCount = 0;

	for (int i = 0; i < N - 1; i++)
	{
		int minPos = i;
		for (int j = i + 1; j < N; j++)
		{
			if (R[minPos] > R[j])
			{
				minPos = j;
			}
		}
		if (i != minPos) {
			swap(R[i], R[minPos]);
			swappingCount++;
		}
	}
	return swappingCount;
}

int main(void)
{
	int R[MAX], N;
	inputData(R, &N);
	int t = selectionSort(R, N);
	traceData(R, N);
	cout << t << endl;
	return 0;
}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define INF 2000000000000000000LL
#define EPS 1e-9
#define debug(a) cerr<<#a<<"="<<(a)<<"\n"
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL);

typedef long long ll;
typedef unsigned long long ull;
typedef complex<double> cd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll mod = 1e9+7;
const double PI = acos(-1);

int n,i,j,k,t;
char s[200002];
int cnt[200002];

int main(){
    scanf("%s", s);
    n = strlen(s);
    cnt[n] = 0;
    for(i=n-1;i>=0;--i)
        cnt[i] = cnt[i+1] + (s[i] == 'W');
    ll ans = 0;
    for(i=0;i<n;++i){
        if(s[i]=='B')
            ans += cnt[i];
    }
    printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int searchIx(vi X){
	int ix = 0;
	vi b(X.size());
	rp(i, 0, X.size()) b[i]=i+1;
	do{
		if(b == X) break;
		ix++;
	}while(next_permutation(b.begin(), b.end()));
	return ix;
}

int main(){
	int N; cin>>N;
	vi P(N), Q(N);
	rp(i, 0, N) cin>>P[i];
	rp(i, 0, N) cin>>Q[i];
	cout<< abs(searchIx(P) - searchIx(Q)) <<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int):
    sm = 0
    for i in range(1, N + 1):
        if i % 3 != 0 and i % 5 != 0:
            sm += i
        
    print(sm)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9188
//msol2019_b.cpp
//Sun Jun 16 14:36:42 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int win = 0;
	for (int i=0;i<s.length();i++){
		if (s[i]=='o'){
			win++;
		}
	}

	if (win+15-s.length()>=8){
		cout << "YES" << endl;
	}else {
		cout << "NO" << endl;
	}
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

#include <atcoder/fenwicktree>
using namespace atcoder;

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

    int n, q;
    cin >> n >> q;
    fenwick_tree<ll> a(n);
    rep(i, n) {
        int x;
        cin >> x;
        a.add(i, x);
    }

    while(q--) {
        int t;
        cin >> t;
        if(t == 0) {
            int p, x;
            cin >> p >> x;
            a.add(p, x);
        } else {
            int l, r;
            cin >> l >> r;
            cout << a.sum(l, r) << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 8252
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define ll long long
#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;
ll mod = 1000000007;
ll n, k;
vector <ll> v;
ll dp[120][65000];
ll ndiv;

int main()
{
	cin >> n >> k;
	for (int i = 1; i*i<=n; i++)
	{
		v.push_back(i);
		v.push_back(n/i);
	}
	v.push_back(0);
	sort(all(v));
	v.erase(unique(all(v)),v.end());
	ndiv = v.size();
	for (int i = 1; i<ndiv; i++)
		dp[1][i] = v[i]%mod;
	for (int l = 2; l<=k; l++)
	{
		for (int i = 1; i<ndiv; i++)
		{
			dp[l][i] = dp[l][i-1]+(dp[l-1][ndiv-i])*(v[i]-v[i-1]);
			dp[l][i] %= mod;
		}
	}
	cout << dp[k][ndiv-1];
}

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

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

  if (s.size() % 2 == 1) {
    s.erase(s.size() - 1);
  } else {
    s.erase(s.size() - 2, 2);
  }

  while (s.size() > 1) {
    int half = s.size() / 2;
    if (s.substr(0, half) == s.substr(half, half)) break;

    s.erase(s.size() - 2, 2);
  }

  cout << s.size() << endl;
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a;
  int tmp;
  cin >> tmp;
  a.push_back(tmp);
  for(int i=1;i<n;i++){
    cin >> tmp;
    auto iter = lower_bound(a.begin(),a.end(),tmp);
    a.insert(iter,tmp);
  }
  cout << a.at(n/2) - a.at(n/2-1) << endl;
}

Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	string s;
	cin >> s;
	int c = 0;
	for (int i = 2; i < s.size(); i += 2) {
		if (s.substr(0, i / 2) == s.substr(i / 2, i / 2))c = i;
	}
	cout << c << endl;
	int x;
	cin >> x;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, m, s, t = list(map(int, input().split()))
graph = [0] + [[] for _ in range(n)]
for _ in range(m):
    u, v, a, b = list(map(int, input().split()))
    # (cost, dest)
    graph[u].append(({'yen': a, 'sunuke': b}, v))
    graph[v].append(({'yen': a, 'sunuke': b}, u))

import heapq

def dijkstra(graph, queue, dist, cost_type):
    while queue:
        d, n = heapq.heappop(queue)
        if dist[n] != -1 and dist[n] < d:
            continue
        for cost, next_n in graph[n]:
            cost_with_type = cost[cost_type]
            if dist[next_n] > d + cost_with_type:
                dist[next_n] = d + cost_with_type
                heapq.heappush(queue, (dist[next_n], next_n))

queue = [(0, s)]
dist_yen = [10 ** 16] + [10 ** 16] * n
dist_yen[s] = 0
dijkstra(graph, queue, dist_yen, 'yen')

queue = [(0, t)]
dist_sunuke = [10 ** 16] + [10 ** 16] * n
dist_sunuke[t] = 0
dijkstra(graph, queue, dist_sunuke, 'sunuke')

# FYI: https://atcoder.jp/contests/soundhound2018-summer-qual/submissions/10738125
answer = [0] + [0] * n
for i in range(n, 0, -1):
    answer[i - 1] = max(answer[i], 10 ** 15 - (dist_yen[i] + dist_sunuke[i]))
for i in range(n):
    print(answer[i])


Measured memory_bytes: 129228
#include <cstdio>
#include <algorithm>
#include <cstring>

using std::min;

const int MAXN=2e5+5,MAXSTA=1<<26;
int n;
int xor_sum[MAXN];
char s[MAXN];

inline int DP(){
	static int sta[MAXSTA],dp[MAXN];
	memset(sta,0x3f,sizeof(sta));
	sta[0]=0;
	for(int i=1;i<=n;++i){
		dp[i]=sta[xor_sum[i]]+1;
		for(int j=0;j<26;++j)
			dp[i]=min(dp[i],sta[xor_sum[i]^1<<j]+1);
		sta[xor_sum[i]]=min(sta[xor_sum[i]],dp[i]);
	}
	return dp[n];
}

int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;++i)
		xor_sum[i]=xor_sum[i-1]^1<<s[i]-'a';
	printf("%d",DP());
	return 0;
}

Measured memory_bytes: 264064
//(・ω・)
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
#include <stdlib.h>
#include <list>
#include <iterator>//std::advance()
using namespace std;

int main(){
    int x;
    cin >> x;
    if(x<=2) cout << 2 << endl;
    else{
        if(x%2==0) x++;
        while(1){
            bool isprime=true;
            for(int i=3; i*i<=x; i+=2){
                if(x%i==0){
                    isprime=false;
                    break;
                }
            }
            if(isprime){
                cout << x << endl;
                break;
            }
            x+=2;
        }
    }

}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string s;
    ll K;
    cin >> s;
    cin >> K;
    iter(c, s) {
        if(c != 'a' && c + K > 'z') {
            K -= 'z' - c + 1;
            c = 'a';
        }
    }
    s.back() = ((ll)(s.back() - 'a') + K) % 26 + 'a';
    cout << s << endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;
    vl a(n);
    cin >> a;
    map<ll, ll> mp;
    rep(i, n) mp[a[i]]++;
    ll q;
    cin >> q;
    ll sum = accumulate(all(a), 0LL);
    while (q--) {
        ll b, c;
        cin >> b >> c;
        sum += mp[b] * (c - b);
        mp[c] += mp[b];
        mp[b] = 0;
        cout << sum << '\n';
    }
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}


Measured memory_bytes: 10028
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h>
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 2000000;
const int inf = 1000000007;
const ll mod = 1000000007;
const ll longinf = 1LL << 60;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
 
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
 
 
 
int n, ans;
int a[2][100005];
 
int main() {
 
cin >> n;
 
rep(i, 2) {
rrep(j, n) {
int tmp;
cin >> tmp;
a[i][j] = a[i][j - 1] + tmp;
}
}
 
rrep(i, n) {
ans = max(ans, a[0][i] + (a[1][n] - a[1][i - 1]));
}
 
cout << ans << endl;
 int heath=4;
return 0;
}

Measured memory_bytes: 384
n,x,m=map(int,input().split())

def f(ai,m):
    return (ai*ai)%m

if x==0:
    print(0)
elif x==1:
    print(n)
elif m==1:
    print(0)
else:
    chk=[-1]*m
    asum00=[0]*m
    ai,asum=x,0
    for icnt in range(m):
        asum00[icnt]=asum
        if chk[ai]!=-1:
            icnt0=chk[ai]
            asum0=asum00[icnt0]
            break
        chk[ai]=icnt
        asum+=ai
        ai=f(ai,m)
        
    icntk=icnt-icnt0
    n0=n-1-icnt0
    nk=n0//icntk
    nr=n0%icntk
    asumk=asum-asum0
       
    ans=asum00[icnt0+nr+1]+asumk*nk
    print(ans)       


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

int main() {
  int N, A, B, C, D;
  cin >> N;
  D = N % 10;
  C = (N % 100) / 10;
  B = (N % 1000) / 100;
  A = N / 1000;

  if ((A == B) && (B == C)) {
    cout << "Yes" << endl;
  }

  else if ((B == C) && (C == D)) {
    cout << "Yes" << endl;
  }

  else {
    cout << "No" << endl;
  }

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <regex>

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using vvs = vector<vs>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vvpii = vector<vpii>;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).begin(),(a).end());
#define rSORT(a) sort((a).rbegin(),(a).rend());
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end());
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;

const ll MOD = 1e9+7;

//sankou
//vvi = vector<vector<int>>(20, vector<int>(10, 0));

//seiki
//#include <regex>
/*bubun*/
//regex_search("u32", regex("[0-9]"));      // true
/*kanzen*/
//regex_match("u32", regex("(i|u)\\d+"));   // true

int isP(int n) {
    if(n<=1) return 0;
    FOR(i,2,(int)sqrt(n)) {
        if(n%i==0) return 0;
    }
    return 1;
}

int main() {

    ll N,M;
    cin >>N>>M;
    vll x(N),y(N),z(N);
    vvll zen(8,vll(N));
    vll zenall(8,0);
    FOR(i,0,N-1){
        cin >>x[i]>>y[i]>>z[i];
        FOR(j,0,7){
            zen[j][i]=x[i]*((((j>>0)&1)*2)-1)+y[i]*((((j>>1)&1)*2)-1)+z[i]*((((j>>2)&1)*2)-1);
        }
    }
    FOR(j,0,7){
        rSORT(zen[j]);
        FOR(k,0,M-1){
            zenall[j]+=zen[j][k];
        }
    }
    rSORT(zenall);
    cout <<zenall[0]<<endl;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define stop exit(0)
#define pb push_back
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    vector <long long> v;
    map<string, int> n;
    long long a,b,c,d=0,e=0,i,f=0,g=0,j,k=1,l=0,r=0,z,m,h,p;
    string y,t,s,x;
    double q,u;
    cin>>a>>b;
    cout<<a*b;
}

Measured memory_bytes: 3620
N = int(input())
H = list(map(int,input().split()))
dp = [0]*N
dp[0] = 0
dp[1] = abs(H[1]-H[0])
if N > 3:
    for i in range(2,N):
        X1 = dp[i-2]+abs(H[i-2]-H[i])
        X2 = dp[i-1]+abs(H[i-1]-H[i])
        dp[i] = min(X1,X2)
print(dp[-1])


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

int main() {
	int orig_A, orig_B, orig_C;
	cin >> orig_A >> orig_B >> orig_C;
	int A = orig_A;
	int B = orig_B;
	int C = orig_C;
	int times = 0;
	while ((A % 2 == 0) && (B % 2 == 0) && (C % 2 == 0)) {
		times++;
		int temp_A = B / 2 + C / 2;
		int temp_B = A / 2 + C / 2;
		int temp_C = A / 2 + B / 2;
		A = temp_A;
		B = temp_B;
		C = temp_C;
		if (A == orig_A && B == orig_B && C == orig_C) {
			times = -1;
			break;
		}
	}
	cout << times << endl;
}

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

int main() {
  int D;
  cin>>D;
  vector<int> sage(26);
  for(int i=0;i<26;i++){
    cin>>sage.at(i);
  }
  vector<vector<int>> man(D,vector<int>(26));
  for(int i=0;i<D;i++){
    for(int j=0;j<26;j++){
      cin>>man.at(i).at(j);
    }
  }
  vector<int> hini(D);
  vector<vector<int>> rkai(D+1,vector<int>(26,1));
  for(int i=0;i<D;i++){
    int A=0,W=man.at(i).at(0)-10*rkai.at(i).at(0)*sage.at(0);
    for(int j=1;j<26;j++){
      int Y=man.at(i).at(j)-10*rkai.at(i).at(j)*sage.at(j);
      if(Y>W){
        W=Y,A=j;
      }
      rkai.at(i+1).at(j)=rkai.at(i).at(j)+1;
    }
    hini.at(i)=A;
    rkai.at(i).at(A)=0;
    rkai.at(i+1).at(A)=1;
  }
  /*for(int i=0;i<D;i++){
    Z+=man.at(i).at(hini.at(i));
    for(int j=0;j<26;j++){
      Z-=rkai.at(i).at(j)*sage.at(j);
    }
    cout<<Z<<endl;
  }*/
  int a=167,b=167;
  for(int i=0;i<3000000;i++){
    a=i%D;
      b=i%26;
      int Z=0;
    if(rkai.at(a).at(b)==0){
      continue;
    }
    int K=rkai.at(a).at(b),C=0;
    for(int j=a;j<D;j++){
      if(rkai.at(j).at(b)==0){
        break;
      }
      else{
        C++;
      }
    }
    Z+=K*C*sage.at(b);
    Z+=man.at(a).at(b);
    int e=hini.at(a);
    C=0;
      int G;
    if(a==0){
      G=1;
    }
    else{
      G=rkai.at(a-1).at(e)+1;
    }
    for(int j=a;j<D;j++){
      if(rkai.at(j).at(e)==0&&j!=a){
        break;
      }
      else{
        C++;
      }
    }
    Z-=G*C*sage.at(e);
    Z-=man.at(a).at(e);
      if(Z>0){
        for(int j=a;j<D;j++){
      if(rkai.at(j).at(b)==0){
        break;
      }
      else{
        rkai.at(j).at(b)-=K;
      }
    }
        for(int j=a;j<D;j++){
      if(rkai.at(j).at(e)==0&&j!=a){
        break;
      }
      else{
        rkai.at(j).at(e)+=G;
      }
    }
        hini.at(a)=b;
      }
    }
  
    
  for(int i=0;i<D;i++){
    cout<<hini.at(i)+1<<endl;
  }
}


Measured memory_bytes: 3744
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#define	MOD  1000000007;
#define PI = 3.14159265358979323846;
using namespace std;

long long MAX, MIN, MAX_MIN = 1000000;

void calc_1(long long S, long long T)
{
	long long A, B, C;
	for (long long i = 1; i < S; i++)
	{
		A = i * T;
		if (T % 2 == 0)
		{
			B = (S - i)* (T / 2);
			C = (S - i)* (T / 2);
		}
		else {
			B = (S - i)* (T / 2);
			C = (S - i)* (T / 2 + 1);
		}

		MAX = max(A, max(B, C));
		MIN = min(A, min(B, C));
		MAX_MIN = min(MAX_MIN, MAX - MIN);
	}
}

void calc_2(long long S, long long T)
{
	long long A, B, C;
	for (long long i = 1; i < S; i++)
	{
		A = i * T;
		if ((S - i) % 2 == 0)
		{
			B = ((S - i) / 2)* T;
			C = ((S - i) / 2)* T;
		}
		else {
			B = (((S - i) / 2) + 1)*T;
			C = ((S - i) / 2)* T;
		}

		MAX = max(A, max(B, C));
		MIN = min(A, min(B, C));
		MAX_MIN = min(MAX_MIN, MAX - MIN);
	}
}
int main()
{
	long long H, W;
	cin >> H >> W;

	//Pattern1
	calc_1(H, W);
	calc_1(W, H);
	calc_2(H, W);
	calc_2(W, H);

	cout << MAX_MIN << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

int a[1005];

int main()
{
    int n, k;
    scanf("%d%d", &n, &k);
    for(int i = 0; i < n; i++) scanf("%d", &a[i]);
    std::sort(a, a + n);
    int ans = 0;
    for(int i = 0; i < k; i++) ans += a[i];
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1716
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
//ll t;
//cin>>t;
//while(t--)

 ll a,b;

cin>>a>>b;
if((1<=a && a<=9)&&(1<=b && b<=9))
    cout<<a*b<<endl;
else
    cout<<-1<<endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >>N;
  int a,b;
  a = 30;
  
  for(int i=0; i<N; i++){
    
    int x;
    cin >>x;
    b=0;
    
    while(x % 2 == 0){
      b++;
      x /= 2;
    }
    
    if(b<a){
      a = b;
    }
  }
  cout <<a <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, M, X; cin >> N >> M >> X;
	VI C(N);
	int A[20][20];
	REP(i, N) {
		cin >> C[i];
		REP(j, M)cin >> A[i][j];
	}
	int ans = INF;

	REP(i, 1 << N) {
		int sum = 0;
		int P[20] = { 0 };
		REP(j, N) {
			if (i&(1 << j)) {
				sum += C[j];
				REP(k, M) {
					P[k] += A[j][k];
				}
			}
			
		}
		bool F = 1;
		REP(j, M) {
			if (P[j] < X)F = 0;
		}
		if (F)chmin(ans, sum);
		
	}


	if (ans == INF)ans = -1;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3660
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  map<char,string> m;
  cin>>m['a']>>m['b']>>m['c'];
  char p='a';
  while(1){
    if(m[p].empty()){
      cout<<char(p-('a'-'A'))<<endl;
      break;
    }
    char buf=m[p][0];
    m[p].erase(0,1);
    // cout<<buf<<" "<<m[p]<<endl;
    p=buf;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <queue> 
#include <cctype> 
#include <climits> 
#include <stack> 
#include <map> 
#include <cstring> 

using namespace std; 


int main(){

    int sum=0;
    int n;
    cin>>n;

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

    int sum2=0, d=sum;

    for(int i=0;i<n;i++){
        sum-=w[i];
        sum2+=w[i];

        d=min(d,abs(sum-sum2));
    }

    cout<<d<<endl;

    return 0;
}

Measured memory_bytes: 256