akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

const int md = 998244353;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b) {
  return (long long) a * b % md;
}

inline int power(int a, int b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

const int N = 800010;

char sa[N], sb[N], sc[N], sd[N];
int fact[N], inv_fact[N];
int ways_up[N], ways_down[N];

inline int C(int n, int k) {
  if (k < 0 || k > n) return 0;
  return mul(fact[n], mul(inv_fact[k], inv_fact[n - k]));
}

int main() {
  fact[0] = inv_fact[0] = 1;
  for (int i = 1; i < N; i++) {
    fact[i] = mul(fact[i - 1], i);
    inv_fact[i] = inv(fact[i]);
  }
  int n, m;
  scanf("%d %d", &n, &m);
  scanf("%s", sa);
  scanf("%s", sb);
  scanf("%s", sc);
  scanf("%s", sd);
  vector<int> a(n), b(n), c(m), d(m);
  for (int i = 0; i < n; i++) {
    a[i] = sa[i] - '0';
    b[i] = sb[i] - '0';
  }
  for (int i = 0; i < m; i++) {
    c[i] = sc[i] - '0';
    d[i] = sd[i] - '0';
  }
  int ans = 0;
  for (int rot = 0; rot < 2; rot++) {
    int sum_c = 0, sum_d = 0;
    for (int p = 0; p < m; p++) {
      sum_c += c[p];
      sum_d += d[p];
    }
    int sum_up = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] + b[i] == 0) {
        ways_up[i] = 0;
      } else {
        if (sum_c == 0 && sum_up > 0) {
          ways_up[i] = 0;
        } else {
          ways_up[i] = (sum_c == 0 ? 1 : C(sum_c + sum_up - 1, sum_c - 1));
        }
        sum_up += a[i] + b[i];
      }
    }
    int sum_down = 0;
    for (int j = n - 1; j >= 0; j--) {
      if (a[j] + b[j] == 0) {
        ways_down[j] = 0;
      } else {
        if (sum_d == 0 && sum_down > 0) {
          ways_down[j] = 0;
        } else {
          ways_down[j] = (sum_d == 0 ? 1 : C(sum_d + sum_down - 1, sum_d - 1));
        }
        sum_down += a[j] + b[j];
      }
    }
    int sum_i = 0;
    for (int j = 0; j < n; j++) {
      add(sum_i, ways_up[j]);
      sum_i = mul(sum_i, max(1, a[j] + b[j]));
      add(ans, mul(sum_i, ways_down[j]));
    }
    swap(n, m);
    swap(a, c);
    swap(b, d);
  }
  int cnt_1 = 0;
  for (int i = 0; i < n; i++) {
    cnt_1 += a[i] + b[i];
  }
  for (int i = 0; i < m; i++) {
    cnt_1 += c[i] + d[i];
  }
  if (cnt_1 == 0) {
    ans = 1;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 12672
def main():

    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    
    if A[-1] < 0:
        maxv = -sum(A) + 2 * A[-1]
        cur = A[-1]
        ops = []
        for i in range(N-1):
            ops.append([cur, A[i]])
            cur -= A[i]
    elif A[0] >= 0:
        maxv = sum(A)-2*A[0]
        ops = []
        cur = A[0]
        for i in range(1, N-1):
            ops.append([cur, A[i]])
            cur -= A[i]
        ops.append([A[-1], cur])
    else:
        pos = []
        neg = []
        for a in A:
            if a < 0: neg.append(a)
            else: pos.append(a)
        maxv = sum(pos) - sum(neg)
        ops = []
        cur = neg[0]
        for i in range(len(pos)-1):
            ops.append([cur, pos[i]])
            cur -= pos[i]
        ops.append([pos[-1], cur])
        cur = pos[-1] - cur
        for i in range(1, len(neg)):
            ops.append([cur, neg[i]])
            cur -= neg[i]

    return maxv, ops

if __name__ == '__main__':
    output = main()
    print(output[0])
    for a, b in output[1]:
        print(" ".join(map(str, [a, b])))

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

//#pragma GCC optimize("Ofast")

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const int NN = 1e9 + 7;
const int N = 2e6 + 7;
const int M = 26;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 7;
const dl rf = 1e-14;
const int B = sqrt(N);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,m,k;
vector < vector < char > > v;
vector < vector < vector < int > > > d;

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

void solve1()
{
    cin >> n >> m >> k;
    v.resize(n);
    d.resize(n);
    int x1,x2,y1,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    x1 -= 1 , y1 -= 1 , x2 -= 1 , y2 -= 1;
    for( int i = 0; i < n; i++ ){
        v[i].resize(m);
        d[i].resize(m);
        for( int j = 0; j < m; j++ ){
            cin >> v[i][j];
            d[i][j].resize(4);
            for( int h = 0; h < 4; h++ )d[i][j][h] = 1e9;
        }
    }
    set < pair < pair < int , pair < int , int > > , pair < int , int > > > s;
    for( int i = 0; i < 4; i++ )s.insert({ {0 , { 0 , i } } , {x1 , y1} }) , d[x1][y1][i] = 0;
    while( !s.empty() ){
        auto x = *s.begin();
        s.erase(s.begin());
        for( int i = 0; i < 4; i++ ){
            int nx = x.se.fi + dx[i];
            int ny = x.se.se + dy[i];
            if( nx < 0 || ny < 0 || nx >= n || ny >= m || v[nx][ny] != '.' )continue;
            int su = x.fi.fi;
            int s1 = x.fi.se.fi - 1;
            if( s1 < 0 || i != x.fi.se.se )s1 = k - 1 , su += 1;
            if( d[nx][ny][i] > su ){
                s.erase({ { d[nx][ny][i] , { s1 , i } } , { nx , ny } });
                d[nx][ny][i] = su;
                s.insert({ { su , { s1 , i } } , { nx , ny } });
            }
        }
    }
    int mn = 1e9;
    for( int i = 0; i < 4; i++ )mn = min( mn , d[x2][y2][i] );
    if( mn == 1e9 )mn = -1;
    cout << mn;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int cghf = 1;//cin >> cghf;
    while( cghf-- ){
        solve1();
    }
}


Measured memory_bytes: 75228
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            string[] abc = Console.ReadLine().Split(' ');
            if(abc[0]==abc[1] && abc[1]==abc[2])
            {
                Console.WriteLine("Yes");
            }
            else 
            {
                Console.WriteLine("No");
            }

        }


    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
//#include <stack>
#include <climits>
#include <map>
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all() begin(),end()
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;
 
int n,m,m2;
map<int,int> mp;
int mod = 1e9+7;
 
struct kekka{
    int Sosuu;
    int Shisuu;
};
 
class Modulo{
public:
    //以下x,y,mod>0を想定している
    ll mod;
    vector<ll> factable = {1};
    vector<ll> invtable = {1};
    Modulo(){
        mod = 1e9+7;
    }
    Modulo(ll _mod){
        mod = _mod;
    }
    ll mul(ll x,ll y){
        return ((x%mod)*(y%mod))%mod;
    }
    ll add(ll x,ll y){
        return ((x%mod)+(y%mod))%mod;
    }
    ll sub(ll x,ll y){
        ll d =((x%mod)-(y%mod))%mod;
        if(d>=0)return d;
        else return d+mod;
    }
    ll pow(ll x,ll y){
        //x^y % mod
        if(y<=0)return 1;
        if(y%2==0){
            ll d = pow(x,y/2);
            return ((d%mod)*(d%mod))%mod;
        }else{
            return (x*pow(x,y-1))%mod;
        }
    }
    ll div(ll x, ll y){
        //x/y % mod = x*y^(mod-2) % mod
        return mul(x,pow(y,mod-2));
    }
    ll fac(ll x){
        //x! % mod
        if(factable.size()<=x){
            ll s = factable.size();
            for(ll i=s;i<x+1;++i){
                factable.push_back(mul(i,factable.back()));
                invtable.push_back(div(1,factable.back()));
            }
        }
        if(x<0) return 1;
        else return factable[x];
    }
    ll facinv(ll x){
        if(invtable.size()<=x){
            ll s = invtable.size();
            for(ll i=s;i<x+1;++i){
                factable.push_back(mul(i,factable.back()));
                invtable.push_back(div(1,factable.back()));
            }
        }
        if(x<0) return 1;
        else return invtable[x];
    }
    ll com(ll x,ll y){
        //xCy % mod = x!/((x-y)!*y!) % mod
        if(x-y<y)return com(x,x-y);
        return mul(fac(x),mul(facinv(x-y),facinv(y)));
    }
};
vector<kekka> soinsu(int N){
    vector<int> sosuu;
    sosuu.push_back(2);
    vector<kekka> kekka1;
    
    // Nを構成する素数の取得
    // エラトステネスの篩
    // 3以上の素数は奇数であることを利用
    for(int i=3;i<=N;i+=2){
        if(N%i==0){
            bool flg=true;
            for(int j=0;j<sosuu.size();++j){
                if(i%sosuu[j]==0)  flg=false;
            }
            if(flg==true)   sosuu.push_back(i);
        }
    }
    
    // 求めた各素数の指数を求める
    for(int i=0;i<sosuu.size();++i){
        int M=N;
        int shisuu=0;
        for(;M%sosuu[i]==0;++shisuu){
            if(M%sosuu[i]==0)
                M/=sosuu[i];
        }
        kekka tmp={sosuu[i],shisuu};
        kekka1.push_back(tmp);
    }
    return kekka1;
}
 
int main() {
    cin >> n >> m;
    m2 = m;
    Modulo mo(1e9+7);
    vector<kekka> pd = soinsu(m);
    ll res = 1;
    REP(i,pd.size()){
        res = mo.mul(res,mo.com((ll)(pd[i].Shisuu+n-1),(ll)(n-1)));
    }
    put(res);
    return 0;
}

Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[114514];
int main(){
	ll n;
	cin>>n;
	ll num=1;
	bool f=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]==0)f=1;
	}
	if(f){
		cout<<0<<endl;
		return 0;
	}
	for(int i=0;i<n;i++){
		if(a[i]<=1000000000000000000/num){
			num*=a[i];
		}else{
			cout<<-1<<endl;
			return 0;
		}
	}
	cout<<num<<endl;
	return 0;
}


Measured memory_bytes: 4428
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    input! {
        N: usize,
        S: String,
    }

    // "#." はダメ
    // "##" ".#" ".." OK
    // 最終形は "#####" "......." "......######"
    // 一色にするのは簡単に計算できる。 "......#####"は?
    // どこを区切れ目にするかN通り * 個数カウント
    // 個数カウントをO(1)でやる → 累積和

    let whites: usize = S.chars().filter(|&c| c == '.').count();
    let blacks: usize = S.chars().filter(|&c| c == '#').count();
    let mut ans = min(whites, blacks);

    // 累積和を使う
    let mut white_acc: Vec<usize> = vec![0; N + 1];
    let mut black_acc: Vec<usize> = vec![0; N + 1];
    for i in 0..N {
        if &S[i..=i] == "#" {
            white_acc[i + 1] = white_acc[i];
            black_acc[i + 1] = black_acc[i] + 1;
        } else {
            white_acc[i + 1] = white_acc[i] + 1;
            black_acc[i + 1] = black_acc[i];
        }
    }

    // どこを黒の最初にするか?
    for i in 1..N {
        // [0 ~ i) までの黒石を白くする
        // [i ~ N) までの白石を黒くする
        let cand = black_acc[i] + (white_acc[N] - white_acc[i]);
        ans = min(ans, cand);
    }

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


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

int main(){
  long long n; cin >> n;
  long long cnt = 5;
  long long ans = 0;
  if(n % 2 == 0){
    while(n / cnt > 0){
      ans += n / cnt / 2;
      cnt *= 5;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define CINVEC(vec) const int size = (vec).size(); REP(i,size) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

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

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    int A, B, C;
    cin >> A >> B >> C;

    FOR(i, 1, B + 1) {
        if ((i*A) % B == C) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;   
}

int main() {
    string s,t;
    cin>>s>>t;
    int count=0;
    rep(i,3){
        if(s.at(i)==t.at(i)){
            count++;
        }
    }
    cout<<count<<endl;


}





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

int main(){
    int A, B, T = 0, maior;
    cin >> A >> B >> T;
    if(A > B){
        maior = B;
    }
    else{
        maior = A;
    }
    int divisores[100];
    int j = 0;
    
    for(int i =0 ; i < 100;i++){
        divisores[i] = 999;
    }

    for(int i = 1; i <= maior;i++ ){
        if(A % i == 0 && B % i == 0){
            divisores[j] = i;
            j++;
        }
    }

    int div[j];
    int k =0;
    for(int i =j;i !=0; i--){
        div[i] = divisores[k];
        k++;
    }
    cout << div[T] <<endl;
    
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc169/tasks/abc169_e

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DEBUG 1
#if DEBUG
  #define _GLIBCXX_DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

const int N_MAX = 2*1e5;
const int B_I_MAX = 1e9;

int N;
vector<int> A;
vector<int> B;

int main() {
  cin >> N;
  A = vector<int>(N);
  B = vector<int>(N);
  REP(i, N) cin >> A[i] >> B[i];

  sort(A.begin(), A.end());
  sort(B.begin(), B.end());

  int ans = 0;
  if (N % 2) {
    ans = B[N / 2] - A[N / 2] + 1;
  } else {
    ans = (B[N / 2] + B[N / 2 - 1]) - (A[N / 2]+ A[N / 2 - 1]) + 1;
  }

  cout << ans << endl;
}


Measured memory_bytes: 4696
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;

template <typename T>
constexpr bool chmin(
    T a, T b, function<bool(T, T)> f = [](T a, T b) { return a > b; }) {
  // when f is true, b is more 'smaller'
  if (f(a, b)) {
    swap(a, b);
    return true;
  }
  return false;
}
template <typename T> constexpr bool chmax(T a, T b) {
  return chmin(a, b, [](T a, T b) { return a < b; });
}
template <typename ite> void print_ite(ite start, ite end, char c = ' ') {
  for (auto i = start; i != end; i++)
    cout << i << c;
  cout << endl;
}
template <typename ite> void scan_ite(ite start, ite end) {
  for (auto i = start; i != end; i++)
    cin >> (*i);
}
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  swap(x, y);
  swap(x, z);
  cout << x << ' ' << y << ' ' << z << endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
 
const long INF = (1l << 30);
const long LINF = (1l << 60);

long n;
long a[5];
long cost[] = {10, 50, 100, 500, 1000};
long nes[5];
long ret;

int main(){;
	scanf("%ld", &n);
	while(1){
		for(int i = 0; i < 4; i++){
			scanf("%ld", a+i);
			ret += a[i] * cost[i];
		}
		ret -= n;
		//printf("%ld\n", ret);
		for(int i = 3; i >= 0; i--){
			nes[i] = ret / cost[i];
			ret %= cost[i];
		}
		for(int i = 0; i < 4; i++){
			if(a[i] - nes[i] > 0){
				printf("%ld %ld\n", cost[i], a[i] - nes[i]);
			}
		}
		scanf("%ld", &n);
		if(n == 0){
			return 0;
		}
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 3196
r,g,b=map(int,input().split())
k=int(input())
flag="No"
for i in range(k):
	if b>g and g>r:
		flag="Yes"
		break
	if r<=b and b<=g:
		b*=2
	elif b<=r and r<=g:
		b*=2
	elif b<=g and g<=r:
		b*=2
	elif g<=r and r<=b:
		g*=2
	elif g<=b and b<=r:
		b*=2
if b>g and g>r:
	flag="Yes"
print(flag)

Measured memory_bytes: 9200
//
// Created by watemus on 03.05.2020.
//

#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

using namespace std;

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ff first
#define ss second

using ll = long long;
using ld = long double;
#define int ll

constexpr ll INFL = 1'000'000'000'000'000'228;
constexpr int INFI = 1'000'000'228;

#ifdef LOCAL
#else
#endif


void run() {
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    vector<vector<int>> g(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        bool f = true;
        for (auto u : g[i]) {
            if (h[u] >= h[i]) {
                f = false;
                break;
            }
        }
        ans += f;
    }
    cout << ans << "\n";
}

signed main() {
#ifdef LOCAL
    std::freopen("input.txt", "r", stdin);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif
    int t = 1;
//    cin >> t;
    while (t--) {
        run();
    }
    return 0;
}

Measured memory_bytes: 9808
// ------------------------------------
// Date:2018/ 2/23
// Problem:ABC 045 Trapezoids a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()

using ll = long long;

int main()
{
  int a,b,h;
  cin >> a >> b >> h;
  cout << (a+b)*h/2 << endl;
  return 0;
}



Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.algorithm,
       std.math, std.array, std.container, std.typecons;
import std.numeric;

void main() {
  int k = readln.chomp.to!int;

  long sum = 0;
  for(int i=0; i<k; i++)
    for(int j=0; j<k; j++)
      for(int l=0; l<k; l++) {
        sum += gcd(i+1, gcd(j+1, l+1));
      }

  writeln(sum);
}



Measured memory_bytes: 2704
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            int iK = int.Parse(sS[1]);
            sS = Console.ReadLine().Trim().Split(' ');
            List<int> lstInp = new List<int>();
            for (int i = 0; i < sS.Length; i++) { lstInp.Add(int.Parse(sS[i])); }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            lstInp.Sort(delegate (int mca1, int mca2) { return (int)(mca2 - mca1); });      // 降順
            int iOut = 0;
            for (int i = 0; i < iK; i++) { iOut += lstInp[i]; }

            //出力
            Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;

void solve(long long N){
    cout << N / 2 + N % 2 << endl;
}

signed main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
long long n,k;
  cin>>n>>k;
  long long ans;
  if(n>=k){
    long long a=n/k;
    n-=k*a;
    ans=min(n,abs(n-k));
    cout<<ans<<endl;
    return 0;
  }
  else{
    ans=min(n,abs(n-k));
    cout<<ans<<endl;
    return 0;
  }
  return 0;
}
    

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t,n,ma=0,ba=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		ma=0;
		for(t=1;i/t!=0;t=t*10)
		{
			ma++;
		}
		if(ma%2==1)
		{
			ba++;
		}
	}
	cout<<ba;
	return 0;
} 

Measured memory_bytes: 256
int main(){
  int n, ans;
  scanf("%d",&n);
  if(n<2) printf("1");
  else if(n<4) printf("2");
  else if(n<8) printf("4");
  else if(n<16) printf("8");
  else if(n<32) printf("16");
  else if(n<64) printf("32");
  else printf("64");
  return 0;
}

Measured memory_bytes: 128
n, k = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)

l = 1
r = 1_000_000_000

# mについて煮豚して、切った結果の最長が m以下になるかを見る
while l < r
  m = (l + r) / 2
  x = k

  i = 0
  while x >= 0 && i < n
    t = ((as[i] + m - 1) / m)
    x -= (t - 1)
    i += 1
  end

  if x >= 0
    r = m
  else
    l = m + 1
  end
end


p l


Measured memory_bytes: 27828
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){return (int)s.size();}
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int n; cin >> n;
    string s; cin >> s;
    int si = SIZE(s);
    int r = 0, l = 0;
    rep(i,si){
        if(s[i] == '(') l++;
        else{
            if(l != 0) l--;
            else r++;
        }
    }
    rep(i,r) s = '(' + s;
    rep(i,l) s += ')';
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int ans = 0;
		for (int i = 1; i <= N; i++) {
			if (i / 10 == 0) {
				if (A <= i && i <= B)
					ans += i;
			} else if (i / 100 == 0) {
				if (A <= i % 10 + i / 10 && i % 10 + i / 10 <= B)
					ans += i;
			} else if (i / 1000 == 0) {
				if (A <= i % 10 + i % 100 / 10 + i / 100 && i % 10 + i % 100 / 10 + i / 100 <= B)
					ans += i;
			} else if (i / 10000 == 0) {
				if (A <= i % 10 + i % 100 / 10 + i % 1000 / 100 + i / 1000
						&& i % 10 + i % 100 / 10 + i % 1000 / 100 + i / 1000 <= B)
					ans += i;
			} else if (i == 10000) {
				if (A <= 1 && 1 <= B)
					ans += i;
			}
		}
		System.out.println(ans);

	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define pi(n,m) n.insert(n.begin(),m);
#define ee(n) n.erase(n.end()-1)
#define eb(n) n.erase(n.begin())
using namespace std;
//using bint=boost::multiprecision::cpp_int;
typedef long long ll;
typedef unsigned long long ull;

int ans=0;
void dfs(ll n,ll m){
  if(n>m) return;
  vector<int> c(10);
  ll x=n;
  while(x>0){
    c[x%10]++;
    x/=10;
  }
  if(c[3]>0 && c[5]>0 && c[7]>0) ans++;
  dfs(n*10+3,m);
  dfs(n*10+5,m);
  dfs(n*10+7,m);
  return;
}

int main(){
  ll m,n=0;
  cin>>m;
  dfs(n,m);
  co(ans);
  
  return 0;
}

Measured memory_bytes: 3616
#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>
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;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
	string s[3];
	rep(i,3)cin>>s[i];
	rep(i,3)cout<<s[i][i];
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
R = lambda: map(int, input().split())
n, k = R()
v = list(R())
ans = max(sum(v[:i - j] + v[n - j:]) -
          sum(sorted(x for x in v[:i - j] + v[n - j:] if x < 0)[: k - i])
          for i in range(1, min(n, k) + 1) for j in range(i))
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < n; i++) {
        cout << s[i] << t[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include<algorithm>
#define inf 0x3f3f3f3f
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double dd;
const int N = 1e5+5;
const dd eps = 1e-8;
const int mod = 1e9+7;
string s,t;

int main(){
  // freopen("input.txt","r",stdin);
  cin>>s>>t;
  int ans = t.size();
  for(int i = 0;i < s.size()-t.size()+1;i++){
    int tim = 0;
    for(int j = 0;j < t.size();j++){
      if(s[i+j] != t[j]) tim++;
    }
    ans = min(ans,tim);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3628
//050
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
int main(void){
    int n,m,p,x;
    cin >> n;
    vector<int>T(n);
    rep(i, n) cin >> T[i];
    cin >> m;
    rep(i, m){
        cin >> p >> x;
        swap(T[p-1],x);
        cout << accumulate(T.begin(),T.end(),0) << endl;
        swap(T[p-1],x);
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 998244353
#define INF2 1000000000000000000
#define int long long
int cnt[100010];

int Mul(int a, int b) {
	return ((a % mod) * (b % mod)) % mod;
}
int square(int x) {
	return (x * x) % mod;
}

int power(int x, int y) {
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int D[100010];
    rep(i, N) cin >> D[i];
    int maximam = *max_element(D, D + N);
    rep(i, N) cnt[D[i]]++;
    if(D[0] != 0 || cnt[0] != 1) {
        cout << 0 << endl;
        return 0;
    }
    
    int ans = 1;
    rep(i, maximam) {
        ans = Mul(ans, power(cnt[i], cnt[i + 1]));
    }
    cout << ans << endl;




    return 0;
}


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

int main() {
    int n, m; cin >> n >> m;
    vector<vector<int>> g(n);
    for (int i = 0; i < m; ++i) {
        int a, b; cin >> a >> b;
        g[a - 1].push_back(b - 1);
        g[b - 1].push_back(a - 1);
    }

    for (auto a : g[0]) {
        for (auto b : g[a]) {
            if (n == b + 1) {
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }

    cout << "IMPOSSIBLE" << endl;
}



Measured memory_bytes: 14980
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
#define chmin(x,y) x=min(x,y)
int dp[100001][3][3][2],inf=1e9;
int main(){
	while(true){
		string s;
		cin>>s;
		if(s[0]=='#') break;
		int N=s.size();
		rep1(i,N) rep(j,3) rep(k,3) rep(h,2) dp[i][j][k][h]=inf;
		rep(i,N){
			int x=(s[i]-'0'+2)%3;
			rep(j,3) rep(k,3) rep(h,2){
				if(dp[i][j][k][h]==inf) continue;
				if(x<=k) chmin(dp[i+1][x][k][0],dp[i][j][k][h]+(1-h));
				if(j<=x) chmin(dp[i+1][j][x][1],dp[i][j][k][h]+h);
			}
		}
		int ans=inf;
		rep(j,3) rep(k,3) rep(h,2) chmin(ans,dp[N][j][k][h]);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 8348
#include <cstdio>
#include <cstdlib>

using namespace std;


int main() {
   int N, K;
   scanf("%d %d", &N, &K);

   double res = 0.0;
   for (int n = 1; n <= N; ++n) {
      double add = 1.0;
      for (long long score = n; score < K; score *= 2) {
         add /= 2;
      }
      res += add * (1.0 / N);
   }

   printf("%.012f\n", res);

   return 0;
}


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

using namespace std;

using int64 = long long;

constexpr int64 P = 1000000007;

// Verified: ABC133E, ABC132D, ABC130E
struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 input_x) : x(input_x) {}
  FiniteField() : x(0) {}
  int64 Value() { return x; }
  inline FiniteField operator+(FiniteField o) {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

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

  int n, m;
  cin >> n >> m;
  vector<vector<vector<FiniteField>>> dp(
      n + 1, vector<vector<FiniteField>>(n + 1, vector<FiniteField>(m + 1)));
  dp[0][0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= m; k++) {
        if (dp[i][j][k].Value() == 0) continue;
        if (k + 2 * j <= m) {
          dp[i + 1][j][k + 2 * j] += dp[i][j][k];
        }
        if (k + 2 * (j + 1) <= m) {
          dp[i + 1][j + 1][k + 2 * (j + 1)] += dp[i][j][k];
        }
        if (j >= 1 && k + 2 * (j - 1) <= m) {
          dp[i + 1][j - 1][k + 2 * (j - 1)] += dp[i][j][k] * j * j;
        }
        if (j >= 1 && k + 2 * j <= m) {
          dp[i + 1][j][k + 2 * j] += dp[i][j][k] * 2 * j;
        }
      }
    }
  }

  cout << dp[n][0][m].Value() << endl;
}


Measured memory_bytes: 52224
#include <iostream>
using namespace std;
int main(void){
    int h,w,x,y;
    while(1){
        cin >> h >> w;
        if (h==0&&w==0) break;
        for(x=0;x<h;x++){
            for(y=0;y<w;y++){
                cout << "#";
            }
            cout << endl;
        }
        cout <<endl;
    }
    
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	ll a, b; cin >> a >> b;
	cout << a * b / __gcd(a, b);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner stdIn = new Scanner(System.in);
    int a = stdIn.nextInt();
   
    if(a % 1000 == 0)
    System.out.print(0);
    
    else if(a % 1000 != 0)
      System.out.print(1000 - a % 1000);
  }
}

Measured memory_bytes: 35668
N = int(input())
a = input().split()
min = 1000
max = 0
for jj in range(len(a)):
    if (int(a[jj]) < min):
       min = int(a[jj])
    if (int(a[jj]) > max):
      max = int(a[jj])
print(max - min)

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){
  
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int res = min(b,d) - max(a,c);
  res < 0 ? cout << 0 << endl : cout << res << endl;




  return 0;
}

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

ll n;


int main(){
	cin >> n;
	
	map<int,ll> m;
	vector<ll> a(n);
	for ( int i = 0; i < n; i++ ){
		cin >> a[i];
		m[a[i]]++;
	}
	
	ll count = 0;
	for ( auto it : m ){
		count += it.second * (it.second-1) / 2;
	}
	
	for ( int i = 0; i < n; i++ ){
		cout << count - (m[a[i]]-1) << endl;
	}
	
	return 0;
}



Measured memory_bytes: 12756
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val aList = IntArray(n) { 0 }
    (1..n).forEach { aList[it - 1] = readLine()!!.toInt() }
    val ansArray = IntArray(n) { Int.MAX_VALUE }
    var count = 0

    for (i in 0 until n) {
        val a = aList[i]
        if (a > ansArray.getOrNull(count - 1) ?: Int.MAX_VALUE) {
            var l = 0
            var r = count
            var mid = (l + r) / 2
            while (true) {
                if (ansArray[mid] < a && ansArray.getOrNull(mid - 1) ?: Int.MAX_VALUE >= a) {
                    ansArray[mid] = a
                    break
                } else if (ansArray[mid] < a) {
                    r = mid
                } else {
                    l = mid
                }
                mid = (l + r) / 2
            }
        } else {
            ansArray[count++] = a
        }
    }
    println(count)
}

Measured memory_bytes: 44420
#include <stdio.h>
#define int long long

signed main(void)
{
	signed n,i;
	scanf("%d",&n);
	int a=2,b=1,temp;
	for(i=1;i <= n-1;i++)
		{
		temp = a+b;
		a = b;
		b = temp;
		}
	printf("%lld\n",b);
return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a) ? "Yes" : "No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
template <class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return 1;
	}
	return 0;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
int main() {
	int n;
	ll ans = 0LL;
	cin >> n;
	int minabs = INF;
	int zero   = 0;
	int negat  = 0;
	V a(n);
	rep(i, n) {
		cin >> a[i];
		if (a[i] < 0) {
			negat++;
		} else if (a[i] == 0) {
			zero++;
		}
		if (abs(a[i]) < minabs) {
			minabs = abs(a[i]);
		}
		ans += abs(a[i]);
	}
	if (zero == 0 and negat % 2 == 1) {
		ans -= minabs*2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4012
/*
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineering College
    Date:13/06/2020
*/
#include<bits/stdc++.h>
#include<string>
#include<algorithm>
using namespace std;
#define ll long long
#define int long long
#define ld long double
#define ff first
#define clr(a,x) memset(a,x,sizeof(a))
#define ss string 
#define se second
#define alt(v) v.begin(),v.end()
#define pb emplace_back
#define mp make_pair
#define ipair pair<int,int>
#define fab(i,a,b) for(ll i=(a);i<(b);i++)
#define fba(i,a,b) for(ll i=(b);i>=(a);i--)
#define arr(i,n) fab(i,0,n)
ll mod=1000000007;
int dx[]={-1,1,0,0};
int dy[]={0,0,1,-1};
const int inf = 1e12;
bool test = 0;

const int N = 3e5+5;
int mx[4*N];

void update(int n,int st,int end ,int pos,int val)
{
    if(st==end && st==pos)
    {
        mx[n] = val;
        return;
    }
    int m=(st+end)/2;
    if(pos<=m)
        update(2*n,st,m,pos,val);
    if(pos>m)
        update(2*n+1,m+1,end,pos,val);
    mx[n] = max(mx[2*n],mx[2*n+1]);
}
int query(int n,int st,int end,int l,int r)
{  
    if(l<=st && end<=r)
    return mx[n];
    int m=(st+end)/2;
    if(r<=m)
        return query(2*n,st,m,l,r);
    else if(l>m)
        return query(2*n+1,m+1,end,l,r);
    else
    {
        int p1,p2;
        p1=query(2*n,st,m,l,r);
        p2=query(2*n+1,m+1,end,l,r);
        return max(p1,p2);
    }
}


int st,last;
int n,k,x;
void solve() 
{ 
    cin >> n >> k;
    clr(mx,0);
    st = 0,last = 300000;
    for(int i = 1;i <= n; ++i)
    {
        cin >>x;
        int l = max(st,x-k);
        int r = min(last,x+k);
        int x1 = query(1,st,last,l,r);
        update(1,st,last,x,x1+1);
    }
    cout<<query(1,st,last,st,last);
}










signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t=1;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    // precompute();
    if(test)
        cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 13020
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

a, b, k = map(int, input().split())

index = 0

mx = max(a, b)

while(mx != 0):
    if a % mx == 0 and b % mx == 0:
        index += 1
    if index == k:
        break
    mx -= 1
print(mx)




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

int main()
{
  int r;

  cin >> r;

  if(r<1200)
    cout << "ABC";
  else if(r>=1200 && r<2800)
    cout << "ARC";
  else
  {
    cout << "AGC";
  }
}


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

using namespace std; 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>; 
#define INF INT_MAX/2 //(1<<(4*4-1))
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

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

   int N,C;
   cin>>N>>C;
   vector<vector<int> >D(C+1,vector<int>(C+1));
   for(int x=1;x<=C;x++){
      for(int y=1;y<=C;y++){
         cin>>D[x][y];
      }
   }
   vector<vector<int> >c(N+1,vector<int>(N+1));
   for(int y=1;y<=N;y++){
      for(int x=1;x<=N;x++){
         cin>>c[x][y];
      }
   }

   vector<vector<ll> >d(3,vector<ll>(C+1));
   for(int x=1;x<=N;x++){
      for(int y=1;y<=N;y++){
         for(int i=1;i<=C;i++){
            d[(x+y)%3][i]+=D[c[x][y]][i];
         }
      }
   }
   /*
   for(int i=0;i<3;i++){
      for(int j=1;j<=C;j++){
         cout<<d[i][j];
      }
      cout<<endl;
   }
   */

   ll Min = INF;
   for(int i=1;i<=C;i++){
      for(int j=1;j<=C;j++){
         for(int k=1;k<=C;k++){
            if(i==j||j==k||k==i)continue;
            ll res=0;
            res+=d[0][i];
            res+=d[1][j];
            res+=d[2][k];
            /*
            cout<<res<<" "<<i<<" "<<j<<" "<<k<<endl;
            cout<<d[0][i]<<" "<<d[1][j]<<" "<<d[2][k]<<endl<<endl;
            */
            Min=min(Min,res);
         }
      }
   }

   cout<<Min<<endl;
   return 0;
}



Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
using pii = std::pair<int, int>;
#define SORT(v) std::sort(v.begin(), v.end())
int main(){
	string s;
    cin >> s;
    string temp="753";
    int ans=INF;
    for(size_t i=0;i<s.size()-2;i++){
        string s1=s.substr(i,3);
        auto res=stoi(temp)-stoi(s1);
        ans=min(ans,abs(res));
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
def readinput():
    n=int(input())
    return n

def main(n):
    count=0
    for i in range(3,n+1,2):
        nc=0
        for j in range(1,i+1):
            if(i%j==0):
                nc+=1
        if nc==8:
            count+=1
    return count

if __name__=='__main__':
    n=readinput()
    ans=main(n)
    print(ans)


Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        long total = 0;
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
            if (i % 2 == 0) {
                total += arr[i];
            } else {
                total -= arr[i];
            }
        }
        long[] ans = new long[n];
        ans[0] = total;
        for (int i = 0; i < n - 1; i++) {
            if (i % 2 == 0) {
                total -= arr[i] * 2;
                ans[i + 1] = -total;
            } else {
                total += arr[i] * 2;
                ans[i + 1] = total;
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            if (i > 0) {
                sb.append(" ");
            }
            sb.append(ans[i]);
        }
        System.out.println(sb);
    }
    
}

Measured memory_bytes: 59692
import java.io.IOException;
import java.util.Scanner;




public class Main {

	public static void main (String[] args) throws IOException{
		Scanner S = new Scanner(System.in);
		String Str = S.nextLine();
		int SI = Integer.parseInt(Str);
		int seconds = SI%60;
		int hour = SI/3600;
		int minute = SI / 60 - hour * 60;
		System.out.println(hour + ":" + minute + ":" + seconds );
		
	}	
}

Measured memory_bytes: 17188