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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

vector<int64_t> fact, fact_inv;

void create_mod_tables(int num){
    fact.assign(num+1, 1);
    fact_inv.assign(num+1, 1);
    for(int i=1; i<=num; i++) fact[i] = fact[i-1] * i % MOD;
    fact_inv[num] = inv_mod(fact[num]);
    for(int i=num; i>0; i--) fact_inv[i-1] = fact_inv[i] * i % MOD;
}

int64_t comb_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD * fact_inv[k] % MOD;
}

int64_t perm_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD;
}

int main(){
    int N, A;
    cin >> N >> A;
    create_mod_tables(N);

    // sub[i] = inv_mod(N-A+i)
    vector<int64_t> sub(A+1);
    for(int i=0; i<=A; i++) sub[i] = inv_mod(N-A+i);

    int64_t ans = 0;
    for(int t=1; t<=A; t++){
        for(int l=0; l<=t; l++){
            int a = t-l;
            int b = N-A;
            int c = max(0, A-t-1);
            int64_t res = fact[a+b+c] * a % MOD * sub[a] % MOD * comb_mod(t, l) % MOD;
            if(l%2) res = MOD-res;
            add(ans, res);
        }
    }
    cout << ans << endl;
    return 0;
}


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

using ll = int64_t;

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

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

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

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

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

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

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

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

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

  string a, b, c;
  std::cin >> a >> b >> c;
  int ai = 0, bi = 0, ci = 0;
  char turn = 'a';
  auto canThrowAway = [&]() {
    if (turn == 'a')
      return ai < a.size();
    else if (turn == 'b')
      return bi < b.size();
    else if (turn == 'c')
      return ci < c.size();
    return false;
  };
  while (canThrowAway()) {
    if (turn == 'a') {
      turn = a[ai];
      ai++;
    } else if (turn == 'b') {
      turn = b[bi];
      bi++;
    } else if (turn == 'c') {
      turn = c[ci];
      ci++;
    }
  }
  std::cout << (char)('A' + turn - 'a') << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
signed main(){
    int N , W , w , v , max_volue , impossible_whight , ans = 0;
    long long volue[100005];

    cin >> N >> W;
    max_volue = N * 1000 , impossible_whight = W + 1;
    
    for(int i=1 ;i<=max_volue ;i++ ){
        volue[i] = impossible_whight;
    }
    volue[0] = 0;
    
    for(int i=0 ;i<N ;i++ ){
        cin >> w >> v;
        for(int j=max_volue ;j>=v ;j-- ){
            if(volue[j-v] + w <= W){
                volue[j] = min( volue[j] , volue[j-v] + w );
                if(ans < j){
                    ans = j;
                }
            }
        }
    }

    cout << ans << endl;

    return(0);
}

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

#define rep(i,k,n) for(int (i)=(k);(i)<(n);(i)++)
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) ((a)>0 ?(a):-(a))
#define llong long long

int main(){
	char s[200010],t[200010];
	scanf("%s",s);
	scanf("%s",t);
	int cnt=0;
	for(int i=0;s[i]!=0;i++){
		if( s[i]!=t[i] ) cnt++;
	}
	printf("%d",cnt);
	return 0;
}


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

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

const int N = 1e5+10;

int n;
char s[N];

int main() { 
  scanf("%s", s);
  n = strlen(s);
  int j = (n - 1) / 2;
  while(j + 1 < n && s[j + 1] == s[(n - 1) / 2]) j++;
  int ans = j + 1;
  j = (n - 1) / 2;
  while(j - 1 >= 0 && s[j - 1] == s[(n - 1) / 2]) j--;
  ans = min(ans, n - j);
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 384
import java.io.*;
import java.util.*;
import java.math.*;

class Main {
    public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    public static PrintWriter pw = new PrintWriter(System.out);
    public static String line;
    public static StringTokenizer st;
    public static ArrayList<ArrayList<Integer>> adjList;
    public static int[] dx = {-1, 0, 1, 0, -1, 1, 1, -1};
    public static int[] dy = {0, 1, 0, -1, 1, 1, -1, -1};
    public static int INF = 0x3f3f3f3f;
    public static int MOD = 1000000007;

    public static int[] A;
    public static int T;

    public static int solve(int index, boolean even){
        if(index == T) return even ? 1 : 0;
        int total = 0;
        for(int i = -1; i <= 1; i++){
            if((A[index] + i) % 2 == 0){
                total += solve(index+1, true);
            } else{
                total += solve(index+1, even);
            }
        }
        return total;
    }

    public static void main(String[] args) throws Exception{
        T = Integer.parseInt(br.readLine());
        A = new int[T];
        st = new StringTokenizer(br.readLine());
        for(int i = 0; i < T; i++){
            A[i] = Integer.parseInt(st.nextToken());
        }

        pw.print(solve(0, false) + "\n");

        pw.close(); 
        br.close();
    }
}

class Pair{
    public long x, y;

    Pair(long _x, long _y){
        x = _x;
        y = _y;
    }
}
class Point implements Comparable<Point>{
    public double x, y;

    Point(double x, double y){
        this.x = x;
        this.y = y;
    }

    public int compareTo(Point p){
        if(x != p.x) return x < p.x ? -1 : 1;
        else if(y != p.y) return y < p.y ? -1 : 1;
        return 0;
    }
}

Measured memory_bytes: 20948
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    ll n, ans = 0;
    cin >> n;
    vector<ll> a(n), s(n + 1);
    rep(i, n) cin >> a[i];
    s[0] = 0;
    rep(i, n)
    {
        s[i + 1] = s[i] + a[i];
    }
    sort(ALL(s));
    map<ll, ll> mp;
    rep(i, n + 1)
    {
        mp[s[i]]++;
    }
    for (auto e : mp)
    {
        ans += e.second * (e.second - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 15872
times = []

for i in range(5):
    times.append(int(input()))

times = sorted(times, key=lambda x: x%10)

ans = 0
for i, t in enumerate(times):
    if t%10==0:
        ans += t
    else:
        ans += t
        break

for j in range(i+1,5):
    ans += (times[j]//10)*10 + 10

print(ans)    

Measured memory_bytes: 3064
// abc075_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

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

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int H, W;
    cin >> H >> W;
    vector<vector<int>> X;
    X.assign(H+2, vector<int>(W+2, 0));

    vector<string> S(H);
    REP(i, H) cin >> S[i];

    REP(i, H) REP(j, W){
        if (S[i][j] == '#') X[i+1][j+1] = INF;
    }

    REPN(i, 1, H+1) REPN(j, 1, W+1){

        if (X[i][j] == INF) continue;

        char cnt = 0;
        REP(k, 8){
            if (X[i + dx[k]][j + dy[k]] == INF) cnt++;
        }
        S[i-1][j-1] = '0' + cnt;
    }

    REP(i, H) print(S[i]);

    return 0;
}


Measured memory_bytes: 256
abc = input('')
a = int(abc.split()[0])
b = int(abc.split()[1])
c = int(abc.split()[2])
k = int(input(''))

result = False
for i in range(k):
    if a>=b:
        b*=2
    elif b>=c:
        c*=2
#    print('{}/{}/{}'.format(a,b,c))
    if a<b and b < c:
        result = True
        break

if result:
    print('Yes')
else:
    print('No')
        

Measured memory_bytes: 9188
#include <bits/stdc++.h>
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
  
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++)cin >> a[i];
	int q;
	cin >> q;
	while(q--){
		int x;
		cin >> x;
		if(binary_search(a, a + n, x))puts("1");
		else puts("0");
	}
    return 0;
}



Measured memory_bytes: 3484
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;
    cin>>a>>b;
    if(a==2 || b==2)
     cout<<"No";
    else if((a==4 || a==6 || a==9 ||a== 11)&&(b==4 || b==6 || b==9 ||b== 11))
     cout<<"Yes";
    else if((a==1 || a==3 || a==5 ||a==7 || a==8 || a==10 || a==12)&&(b==1 || b==3 || b==5 ||b==7 || b==8 || b==10 || b==12))
     cout<<"Yes";
    else 
     cout<<"No";
     return 0;
}
     
   




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

namespace Template
{
    class Program
    {
        static void Main(string[] args)
        {
            // スペース区切りの整数の入力
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int c = int.Parse(input[2]);
            // 文字列の入力
            int k = int.Parse(Console.ReadLine());

            if     (b <= a && c <= a) { a = a * (1 << (k)); }
            else if(a <= b && c <= b) { b = b * (1 << (k)); }
            else if(a <= c && b <= c) { c = c * (1 << (k)); }

            //出力
            Console.WriteLine(a + b + c);
        }
    }
}


Measured memory_bytes: 13140
#include <vector>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>


using namespace std;


int main(void){
  
  
  string str,ans="";
  int N;
  cin >> N >> str;

  for(int i = 0; i < str.size() ; i++){
    char chr = str[i]+N;

    if(chr > 'Z'){
      chr ='A' + N -('Z' -str[i])-1;
    }

    ans.push_back(chr);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int N;

int main()
{
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        A[i] -= (i + 1);
    }
    sort(A.begin(), A.end());
    int b = A[N / 2];
    ll ans = 0;
    for (int i = 0; i < N; i++)
    {
        ans += abs(A[i] - b);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(S: str, T: str, A: int, B: int, U: str):
    if S == U:
        print(A-1, B)
    else:
        print(A, B-1)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    U = next(tokens)  # type: str
    solve(S, T, A, B, U)


if __name__ == '__main__':
    main()


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

using namespace std;

const int MAXN = 55;
const int MOD = (int) (1e9 + 7);

long long dp[3][3][MAXN];

int main() {
    int n;
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;

    if (s1[0] == s2[0]) {
        for (int i = 0; i < 3; i++) {
            dp[i][i][0] = 1;
        }
    } else {
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (i != j) {
                    dp[i][j][0] = 1;
                }
            }
        }
    }

    for (int i = 0; i < n - 1; i++) {
        for (int c1 = 0; c1 < 3; c1++) {
            for (int c2 = 0; c2 < 3; c2++) {
                dp[c1][c2][i] %= MOD;
                for (int d1 = 0; d1 < 3; d1++) {
                    for (int d2 = 0; d2 < 3; d2++) {
                        if (s1[i] == s2[i] && c1 != c2) continue;
                        if (s1[i + 1] == s2[i + 1] && d1 != d2) continue;
                        if (s1[i] == s1[i + 1] && c1 != d1) continue;
                        if (s2[i] == s2[i + 1] && c2 != d2) continue;

                        if (s1[i] != s2[i] && c1 == c2) continue;
                        if (s1[i + 1] != s2[i + 1] && d1 == d2) continue;
                        if (s1[i] != s1[i + 1] && c1 == d1) continue;
                        if (s2[i] != s2[i + 1] && c2 == d2) continue;

                        dp[d1][d2][i + 1] += dp[c1][c2][i];
                    }
                }
            }
        }
    }

    long long s = 0;
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            s += dp[i][j][n - 1];
        }
    }

    cout << s % MOD << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String S = sc.next();
      String a = S.substring(2,3);
      String b = S.substring(3,4);
      String c = S.substring(4,5);
      String d = S.substring(5,6);
      if(a.equals(b)&&c.equals(d)){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }
}

Measured memory_bytes: 35504
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int L,n,T,w[100005],g,i,j,k;
int main()
{
	scanf("%d%d%d",&n,&L,&T);
	for(i=1;i<=n;++i)
	{
		scanf("%d%d",&j,&k);
		if(k==1)
		{
			w[i]=(j+T)%L;
			if(j+T%L>=L)
				++g;
			g+=T/L;
		}
		else
		{
			w[i]=(j-T%L+L)%L;
			if(j-T%L<0)
				--g;
			g-=T/L;
		}
	}
	sort(w+1,w+1+n);
	g=(g%n+n)%n;
	for(i=1;i<=n;++i)
		printf("%d\n",w[i+g<1?n+i+g:i+g<=n?i+g:i+g-n]);
	return 0;
}


Measured memory_bytes: 1536
n,k = map(int,input().split())
a = [int(i) for i in input().split()]

mod = 10**9+7

g = 0
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        elif i >= j:
            continue
        if a[i] > a[j]:
            #print(i,j)
            g += 1

if k == 1:
    print(g)
    exit()
    
a2 = []

for i in range(2*n):
    a2.append(a[i%n])
    
f = 0

for i in range(n):
    for j in range(2*n):
        if i == j:
            continue
        elif i >= j:
            continue
        if a2[i] > a2[j]:
            #print(i,j)
            f += 1

t = int((f-g)%mod)
k = int(k%mod)

#ans = g*k + t*k*(k-1)//2
#ans = g*k + t*k*(k-1)//2
print(int(( (k*g) + t*((k-1)*k//2))%mod))
#print(int(((k*g) + (t*(0.5*((k-1)*k))))%mod))
exit()



Measured memory_bytes: 42460
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int n,m=1,cnt=0,aa[110000];
pair<int,int> p[110000];
string s;
char c;
signed main(){
    cin>>n;
    while(1){
        m*=2;
        if(n<m){
            cout<<m-1;
            return 0;
        }
    }
}

Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read


def main():
    N, T, *AB = map(int, read().split())
    D = [(a, b) for a, b in zip(*[iter(AB)] * 2)]

    D.sort()

    dp = [0] * T
    max_sum = [0] * N
    for i, (a, b) in enumerate(D):
        for t in range(T - 1, -1, -1):
            if t >= a and dp[t] < dp[t - a] + b:
                dp[t] = dp[t - a] + b
        max_sum[i] = dp[T - 1]

    ans = max(max_sum[i] + D[i + 1][1] for i in range(N - 1))

    print(ans)
    return


if __name__ == '__main__':
    main()


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

int main(){
  int n;
  cin >> n;
  vector<int> diameter(n);
  
  for(int i = 0; i < n; i++){
    cin >> diameter[i];
  }
  
  sort(diameter.begin(), diameter.end());
  
  diameter.erase(unique(diameter.begin(), diameter.end()), diameter.end());
  
  cout << diameter.size() << endl;
}

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

using namespace std;

int main(){
   int N;
   cin >> N;
   long long A[N];
   long long S=0;
   for(int i=0; i<N; i++){
      cin >> A[i];
      if(i%2==0){
         S+=A[i];
      }
      else{
         S-=A[i];
      }
   }
   for(int i = 0 ; i < N ;i++){
      cout << S << " ";
      S = A[i]-S/2;
      S*=2;
   }
   cout << endl;

   return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,s1=0,s2=0,s;
    scanf("%d",&n);
    int a[n+1];
    for(int i=0; i<n ; i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+n, greater<int>());
    for(int i=0; i<n ; i++)
    {
        if(i%2==0)
        {
            s1+=a[i];
        }
        else
        {
            s2+=a[i];
        }
    }
    printf("%d\n",s1-s2);
    return 0;

}


Measured memory_bytes: 3836
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main(void) {

    int n;
    cin>>n;
    vpii v(n);
    rep(i,n){
        int a,b;
        cin>>a>>b;
        v[i]=mp(b,a);
    }
    Sort(v);
    ll now=0;
    for(int i=0;i<n;i++){
        if(now+v[i].second>v[i].first){
            fin("No");
            return 0;
        } else {
            now+=v[i].second;
        }
    }
    fin("Yes");
}

Measured memory_bytes: 1792
N = int(input())
d = {}

for i in range(N) :
    n = int(input())
    
    if n in d.keys() :
        d[n] += 1
    else : d[n] = 1

cnt = 0
for k in d.keys() :
    if d[k] % 2 != 0 :
        cnt += 1
        
print(cnt)

Measured memory_bytes: 15076
#include<stdio.h>
int main()
{
  int i,j;
  char s[1201];
  gets(s);
  for(i=0;i<1201;i++){
    if(s[i]>='A' && s[i]<='Z')s[i]+=32;
    else if(s[i]>='a' && s[i]<='z')s[i]-=32;
  }
  printf("%s\n",s);
  return 0;
}

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


int main() {
    int N, K;
    cin >> N >> K;

    vector<int> prices(N);
    for (int i = 0; i < N; i++) {
        cin >> prices.at(i);
    }

    sort(prices.begin(), prices.end());
    
    int sum = 0;
    for (int i = 0; i < K; i++) {
        sum += prices.at(i);
    }
    cout << sum << endl;
     
}


Measured memory_bytes: 3632
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()
s = S()
AZ = string.ascii_uppercase
ans = []
for c in s:
    i = (AZ.index(c) + N)%26
    ans += AZ[i]
print(''.join(ans))

Measured memory_bytes: 3948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
#define MOD 998244353 //1000000007


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

    // solution comes here

    ll X, Y;
    cin >> X >> Y;
    cout << X + Y/2 << nl;
}

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

const int T=2e7,MOD=998244353;

int fac[T+3],inv[T+3],n_[T+3],m_[T+3];
int n,m;

int fADD(int a,int b){return ((1ll*a+b)%MOD+MOD)%MOD;}
int fTIME(int a,int b){return int(1ll*a*b%MOD);}
int QPow(int a,int b){
	int res=1;
	while(b){
		if(b&1) res=fTIME(res,a);
		a=fTIME(a,a);
		b>>=1;
	}
	return res;
}
void Process(){
	fac[0]=1;for(int i=1;i<=T;i++) fac[i]=fTIME(fac[i-1],i);
	inv[T]=QPow(fac[T],MOD-2);for(int i=T-1;i>=0;i--) inv[i]=fTIME(inv[i+1],i+1);
	n_[0]=1;for(int i=1;i<=T;i++) n_[i]=fTIME(n_[i-1],n+1);
	m_[0]=1;for(int i=1;i<=T;i++) m_[i]=fTIME(m_[i-1],m+1);
}
int fC(int a,int b){return fTIME(fac[b],fTIME(inv[a],inv[b-a]));}
int main(){
	scanf("%d%d",&n,&m);
//	if(n>m) swap(n,m);
	Process();
	int ans=0;
	for(int i=0;i<=min(m,n);i++){
		if(i%2) ans=((ans-fTIME(fTIME(fC(i,n),fC(i,m)),fTIME(fac[i],fTIME(n_[m-i],m_[n-i]))))%MOD+MOD)%MOD;
		else ans=fADD(ans,fTIME(fTIME(fC(i,n),fC(i,m)),fTIME(fac[i],fTIME(n_[m-i],m_[n-i]))));
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 312704
// abc130_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, X;
    cin >> N >> X;
    vector<int> L(N);
    REP(i, N) cin >> L[i];

    int x = 0;
    int ans = 1;
    REP(i, N)  {
        x += L[i];
        if (x <= X) {
            ans++;
        }
    }

    print(ans);
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	private static int gcd(int a, int  b) {
		int  temp = 0;

		if(a == 0) {
			return b;
		}
		if(b == 0) {
			return a;
		}
		if(a != 0 || b != 0) {
		while (a % b != 0){
			temp = a;
			a = b;
			b = temp % b;
		}
		}
		return b;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int []a = new int [n];
		
		for(int i = 0 ; i < n ; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		int min = a[n-1];
		for(int i = 1; i < n ; i++) {
			min = Math.min(min, gcd(a[i],a[0]));
		}
	System.out.println(min);

	}

}


Measured memory_bytes: 53212
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
      FastIO
      lld n, k;
      cin >> n;
      cin >> k;
      lld H[n];
      lld i;
      foi(i, n)
      {
      	cin >> H[i];
      }
      sort(H, H+n);
      fod(i, n)
      {
      	if (k == 0)
      		break;
      	H[i] = 0;
      	k--;
      }
      lld s = 0;
      foi(i, n)
      {
      	s+= H[i];
      }
      cout<< s;
      return 0;
}

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

int main(void){
    int N;
    bool result{false};

    cin >> N;

    if(N/100==7){
        result = true;
    }
    else if(N%100/10==7){
        result = true;
    }
    else if(N%10==7){
        result = true;
    }
    
    if(result){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

}


Measured memory_bytes: 3624
#include<stdio.h>
#include<string.h>
/*


1-3-2 3*3=1*1+1*2+2*3

1-3-4-2-1 5*4=(1+2+3+4)*2


1 2 3 4 5




 
*/
int n;
struct PAIR{
    int x,y;
    bool operator==(const PAIR& p0){
        if(x==p0.x&&y==p0.y)return true;
        if(x==p0.y&&y==p0.x)return true;
        return false;
    }
}dis[10004];
int nDis=0;
int main(){
    scanf("%d",&n);
    if(n&1)
        for(int i=n-1;i>n/2;i--){
            dis[nDis].x=i;
            dis[nDis++].y=n-i;
        }
    else
        for(int i=n;i>n/2;i--){
            dis[nDis].x=i;
            dis[nDis++].y=n+1-i;
        }
    PAIR temp;
    int flag;
    printf("%d\n",n*(n-1)/2-nDis );
    for(int i=n;i>0;i--){
        for(int j=1;j<i;j++){
            temp.x=i,temp.y=j;
            flag=true;
            for(int k=0;k<nDis;k++){
                if(temp==dis[k])flag=false;
            }
            if(flag)printf("%d %d\n",i,j );
        }
    }
    
}

Measured memory_bytes: 128
#include <stdio.h>
#define MAX 10000
#define NIL -1

typedef struct node{
    int p,l,r;
}Node;

void preOrder(int);
void inOrder(int);
void postOrder(int);

Node O[MAX];
int n;

int main(){
    int i,id,l,r,root;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        O[i].p=NIL;
    for(i=0;i<n;i++){
        scanf("%d %d %d",&id,&l,&r);
        O[id].l=l;
        O[id].r=r;
        if(l != NIL)
            O[l].p=id;
        if(r != NIL)
            O[r].p=id;
    }
    for(i=0;i<n;i++)
        if(O[i].p == NIL)
            root=i;
    printf("Preorder\n");
    preOrder(root);
    puts("");
    printf("Inorder\n");
    inOrder(root);
    puts("");
    printf("Postorder\n");
    postOrder(root);
    puts("");
    return 0;
}

void preOrder(int m){
    if(m==NIL)
        return;
    printf(" %d",m);
    preOrder(O[m].l);
    preOrder(O[m].r);
}

void inOrder(int m){
    if(m==NIL)
        return;
    inOrder(O[m].l);
    printf(" %d",m);
    inOrder(O[m].r);
}

void postOrder(int m){
    if(m == NIL)
        return;
    postOrder(O[m].l);
    postOrder(O[m].r);
    printf(" %d",m);
}



Measured memory_bytes: 2108
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

# 0:中央 1:南 2:東 3:西 4:北 5:裏側


class Dice():

    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
        self.order = 'NNNNWNNNWNNNENNNENNNWNNN'

    def setNumber(self, n0, n1, n2, n3, n4, n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5

    def roll(self, loc):
        for i in range(6):
            self.work[i] = self.number[i]

        if loc == 'E':
            self.setNumber(self.work[3], self.work[1], self.work[0],
                           self.work[5], self.work[4], self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1], self.work[5], self.work[2],
                           self.work[3], self.work[0], self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4], self.work[0], self.work[2],
                           self.work[3], self.work[5], self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2], self.work[1], self.work[5],
                           self.work[0], self.work[4], self.work[3])

    def equals(self, another):

        ret = False

        for i in range(len(self.order)):
            self.roll(self.order[i])
            FLG = True
            for k in range(6):
                if self.number[k] != another.number[k]:
                    FLG = False
                    break
            if FLG == True:
                return True

        return ret


num_dice = int(input())
DICE = []

for i in range(num_dice):
    table = list(map(int, input().split()))
    tmp_dice = Dice()
    tmp_dice.setNumber(table[0], table[1], table[2],
                       table[3], table[4], table[5])
    DICE.append(tmp_dice)

FLG = True

for i in range(num_dice-1):
    for k in range(i+1, num_dice):
        if DICE[i].equals(DICE[k]) == True:
            FLG = False
            break


if FLG == True:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 6404
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int coin_500=sc.nextInt();
		int coin_100=sc.nextInt();
		int coin_50=sc.nextInt();
		int total=sc.nextInt();
		int num=0;
		for(int a=0;a<=coin_500;a++){
			for(int b=0;b<=coin_100;b++){
				for(int c=0;c<=coin_50;c++){
					if(a*500+b*100+c*50==total){
						num++;
					}
				}
			}
		}
		System.out.println(num);
	}
}


Measured memory_bytes: 23764
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
   int a,b;
   cin>>a>>b;
       if(a>b){
           for(int i=0;i<a;i++){
           cout<<b;
       }
       }
       else{
            for(int i=0;i<b;i++){
           cout<<a;
       }
       }
       cout<<endl;
}

Measured memory_bytes: 256
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	int A = 0, B = 0;
	int ans = 0, outlet = 1;
	scanf("%d %d", &A, &B);
	if (outlet < B) {
		do {
			outlet--;
			outlet += A;
			ans++;
		} while (outlet < B);
	}
	printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
def solve():
    list_t_and_a = read()
    result = think(list_t_and_a)
    write(result)


def read():
    n = read_int(1)[0]
    list_t_and_a = []
    for _ in range(n):
        list_t_and_a.append(read_int(2))
    return list_t_and_a


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(list_t_and_a):
    n = len(list_t_and_a)
    vote_t, vote_a = list_t_and_a[0][0], list_t_and_a[0][1]
    for i in range(1, n):
        ti, ai = list_t_and_a[i][0], list_t_and_a[i][1]
        ratio_t = vote_t // ti
        if vote_t % ti != 0:
            ratio_t += 1
        ratio_a = vote_a // ai
        if vote_a % ai != 0:
            ratio_a += 1
        ratio = max(ratio_t, ratio_a)
        vote_t = ratio * ti
        vote_a = ratio * ai
    return vote_t + vote_a


def expected_lower_value_than_actual(actual, expected):
    return actual > expected


def write(result):
    print(result)


if __name__ == '__main__':
    solve()

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

#define N 1000100

int n, cnt[N];

int main() {
    scanf("%d", &n);
    for(int i = 1, a; i <= n; i ++) scanf("%d", &a), cnt[a] ++;
    int ans = 0;
    for(int i = 1; i < N; i ++) {
        if(!cnt[i]) continue;
        if(cnt[i] == 1) ans ++;
        for(int j = 2 * i; j < N; j += i) cnt[j] = 0;
    }
    printf("%d\n", ans);
}


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

int main() {
  int N, L, a, sum;
  cin >> N >> L;
  sum = N * L - N + (N * (N + 1) / 2);
  if(L + N < 1){
    a = L + N - 1;
  }else if(L > 0){
    a = L;
  }else{
    a = 0;
  }
  int out;
  out = sum - a;
  cout << out << endl;
}

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

using namespace std;

typedef long long ll;

const int NONDEF=-1,NMAX=1e5;
int n,m,nbGauche[NMAX],nbDroite[NMAX],distances[NMAX];
vector< pair<int,int> > voisins[NMAX];
queue< pair<int,int> > enCours;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n >> m;
    int l,r,d;
    for(int i=0;i<m;i++){
		cin >> l >> r >> d;
		l--;r--;
		voisins[l].push_back( make_pair(r,d) );
		nbGauche[l]++;
		nbDroite[r]++;
	}
	
	for(int i=0;i<n;i++){
		distances[i]=NONDEF;
		if(nbDroite[i]==0){
			distances[i]=0;
			enCours.push(make_pair(i,0));
		}
	}
	if(enCours.empty()){
		cout << "No\n";
		return 0;
	}
	int sz,actuel,distance,voisin,p;
	
	while(!enCours.empty()){
		actuel=enCours.front().first;
		distance=enCours.front().second;
		enCours.pop();
		sz=voisins[actuel].size();
		
		for(int i=0;i<sz;i++){
			voisin=voisins[actuel][i].first;
			p=voisins[actuel][i].second;
			
			if(distances[voisin]!=NONDEF && distance+p!=distances[voisin]){
				cout << "No\n";
				return 0;
			}
			distances[voisin]=distance+p;
			nbDroite[voisin]--;
			if(nbDroite[voisin]==0){
				enCours.push(make_pair(voisin,distances[voisin]));
			}
		}
	}
	
	for(int i=0;i<n;i++){
		if(distances[i]==NONDEF && (nbGauche[i]!=0 || nbDroite[i]!=0)){
			cout << "No\n";
			return 0;
		}
	}
	
	cout << "Yes\n";
			
			
    return 0;
}


Measured memory_bytes: 7168
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

import fractions
n=int(input())
a=list(map(int,input().split()))
for i in range(n-1):
    a[i+1]=fractions.gcd(a[i],a[i+1])
print(min(a))

Measured memory_bytes: 16240
#define _USE_MATH_DEFINES

#include <vector>
#include <list>
#include <map>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <utility>
#include <ctgmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll mod = 1000000007;
const ll inf = 10e17;
const ld eps = 10e-9;



ll solve(void);
ll gcd(ll x, ll y);

int main(void)
{
	while (solve())
	{
	}
	return 0;
}

ll mulmod(ll x, ll y)
{
	return (x * y) % mod;
}

ll submod(ll x, ll y)
{
	return (x - y + 100 * mod) % mod;
}

ll power(ll n, ll r)
{
	if ( r == 0 ) { return 1; }
	if ( r == 1 ) { return n; }
	if ( n == 0 ) { return 0; }
	if ( n == 1 ) { return 1; }

	if (r % 2 == 0)
	{
		ll y = power(n, r/2);
		return mulmod(y, y);
	}
	else
	{
		ll y = power(n, (r-1)/2);
		return n * mulmod(y, y) % mod;
	}
}

ll gcd(ll x, ll y)
{
	if (y == 1) { return 1;}
	if (x % y == 0) { return y; }
	return gcd(y, x % y);
}

vector<ll> perm;
vector<ll> inv;
void init_inv(ll m)
{
	perm.resize(m);
	inv.resize(m);
	
	perm[0] = 1;
	inv[0] = 1;

	for (ll i = 1; i < m; i++)
	{
		perm[i] = mulmod(perm[i-1], i);
	}
	
	for (ll i = 1; i < m; i++)
	{
		inv[i] = power(perm[i], mod - 2);
	}
}

ll ncr(ll n, ll r)
{
	// n (n-1) ... (n-r)
	if ( r == n || r == 0 ) { return 1; }

	ll ans = 1;
	//for (ll i = 0; i < r; i++)
	//	ans = mulmod(ans, n - i);

	// return mulmod(ans, inv[r]);
	return mulmod(perm[n], mulmod(inv[n-r], inv[r]));
}

ll solve(void)
{
	ll n, k;
	cin >> n >> k;
	
	const ll inv_max = 2 * 10e5 + 1;
	init_inv(inv_max);

	// nHn = (n+r-1)Cn
	ll ans = ncr(2 * n - 1, n);

	if (n > k)
	{
		// n-1, .., k+1, 
		for (ll i = n - 1; i > k; i--)
		{
			ll tmp = mulmod(ncr(n, i), ncr(n-1, n-1-i));
			ans = submod(ans, tmp);
		}
	}

	cout << ans << endl;

	return 0;
}



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

#define ll long long

int main() {
    ll n,ans;
    cin>>n;
    ans=n-1;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0) ans=min(ans,i+n/i-2);
    }
    cout<<ans<<"\n";
    return 0;
}

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

using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORR(i,a,b) for(int i=(a);i>(b);--i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a))
#define mp make_pair
#define All(a) (a).begin(), (a).end()
template <typename T=long long>
inline T IN(){T x; cin>>x; return(x);}
inline void CIN(){}
template <class Head,class... Tail>
inline void CIN(Head&& head,Tail&&... tail){
    cin>>head;
    CIN(move(tail)...);
}
#define CINT(...) int __VA_ARGS__;CIN(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CIN(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CIN(__VA_ARGS__)
 
typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int,V,greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int N,M;
struct cake{ll x,y,z;};
vector<vector<cake>> boxes;
vector<cake> box;
vector<int> p[]={{1,1,1},{1,1,-1},{1,-1,1},{1,-1,-1},{-1,1,1},{-1,-1,1},{-1,1,-1},{-1,-1,-1}};

bool comp(const cake& a, const cake& b){
	return a.x+a.y+a.z>b.x+b.y+b.z;
}

int main(){
	cin>>N>>M;
	boxes.resize(8);
	REP(i,N){
		LCIN(X,Y,Z);
		REP(j,8){
			boxes[j].push_back({p[j][0]*X,p[j][1]*Y,p[j][2]*Z});
		}
	}
	ll sum=0;
	REP(j,8){
		ll tmp=0;
		box=boxes[j];
		sort(All(box),comp);
		REP(i,M){
			tmp+=box[i].x+box[i].y+box[i].z;
		}
		sum=max(sum,tmp);
	}
	cout<<sum<<"\n";
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 998244353
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll n,k[10000005],kinv[10000005],inv[10000005],ans,sum;
ll cm(ll x,ll y){
	if(y<0||x<y)return 0;
	return k[x]*kinv[y]%M*kinv[x-y]%M;
}
int main(void){
	cin>>n;
    k[0]=1LL,inv[0]=1LL,inv[1]=1LL,kinv[0]=1LL;
    for(ll i=2;i<=n;i++)inv[i]=M-(M/i)*inv[M%i]%M;
    for(ll i=1;i<=n;i++)k[i]=k[i-1]*i%M,kinv[i]=kinv[i-1]*inv[i]%M;
    ans=1LL,sum=1LL;
    for(ll i=1;i<=n;i++){
		sum=sum*2LL%M;
		sum=(M+sum-cm(i-1LL,n/2LL)*2LL%M)%M;
		ans=(ans+sum*cm(n,i)%M)%M;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 234624
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template<long long mod>
struct mint {
private:
    long long x;
public:
    mint(long long x = 0) :x((mod + x) % mod) {}
    mint(std::string &s) {
        long long z = 0;
        for (int i = 0; i < s.size(); i++) {
            z *= 10;
            z += s[i] - '0';
            z %= mod;
        }
        this->x = z;
    }
    mint& operator+=(const mint &a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint &a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint &a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint& operator/=(const mint &a) {
        long long n = mod - 2;
        mint<mod> u = 1, b = a;
        while (n > 0) {
            if (n & 1) {
                u *= b;
            }
            b *= b;
            n >>= 1;
        }
        return *this *= u;
    }
    mint operator+(const mint &a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint &a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint &a) const {
        mint res(*this);
        return res *= a;
    }
    mint operator/(const mint &a) const {
        mint res(*this);
        return res /= a;
    }
    friend std::ostream& operator<<(std::ostream &os, const mint &n) {
        return os << n.x;
    }
    bool operator==(const mint &a) const {
        return this->x == a.x;
    }
};

vector<pair<ll, ll>> a;
int n;

// p : どこまで見たか
mint<998244353> dfs(int v, int &p) {
    p = v;
    int q = v + 1;
    mint<998244353> res = 1;
    bool used = false;
    while (q < n && a[q].first < a[v].first + a[v].second) {
        res *= dfs(q, p);
        used = true;
        q = p + 1;
    }
    if (!used) {
        return mint< 998244353>(2);
    }
    else {
        return res + 1;
    }
}

int main() {
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }
    sort(a.begin(), a.end());
    mint<998244353> ans = 1;
    int now = 0;
    int p;
    while (now < n) {
        /*
         stack<pair<int, int>> sta;
         sta.push({0,0});
         while (!sta.empty()) {
             auto pp = sta.top(); sta.pop();
             int v = pp.first;
             p = pp.first;
             int q = v + 1;
             mint<998244353> res = 1;
             bool used = false;
             while (q < n && a[q].first < a[v].first + a[v].second) {
                 res *= dfs(q, p);
                 used = true;
                 q = p + 1;
             }
             if (!used) {
                 mint< 998244353>(2);
             }
             else {
                 return res + 1;
             }
         }
         */
        ans *= dfs(now, p);
        now = p + 1;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define endl "\n"

int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);cout.tie(NULL);
   
   long long int n,mod=1000000007,ans=0;
   cin>>n;
   long long int a[n],i,sum=0;
   for(i=0;i<n;++i)
      { cin>>a[i];
        sum+=a[i];
      }
      
   for(i=0;i<n;++i)
   {
       sum-=a[i];
       ans+=(sum%mod*a[i]%mod)%mod;
   }
   
   cout<<ans%mod;
      
      
   
   
     return 0;
}

Measured memory_bytes: 5204
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <algorithm>
#include <iomanip>
#include <functional>
#include <numeric>

#define REP(i, n) for(int i = 0;i < (n); i++)
#define REP2(i, x, n) for(int i = (x); i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define PI 3.14159265358979

using namespace std;

//================================================

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

	string S;
	
	getline(cin, S);
	transform(ALL(S), S.begin(), ::toupper);
	cout << S << "\n";
	return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n,k;
    ll s;
    cin >> n >> k >> s;
    if(s != INF){
        for(int i = 0; i < n; i++){
            if(i < k){
                cout << s << " ";
            }else{
                cout << INF << " ";
            }
        }
    }else{
        for(int i = 0; i < n; i++){
            if(i < k){
                cout << s << " ";
            }else{
                cout << 1 << " ";
            }
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1280
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    a,b=list(map(int,input().split()))
    print(a//b,a%b,format(a/b,".6f"))
main()



Measured memory_bytes: 5624