akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fr(i, n) for (int i = 0; i < n; i++)
#define frab(i, a, b) for (int i = a; i < b; i++)
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef long double ld;

const ll INF = 2e9 + 10;
const ld EPS = 1e-9;
const ld PI = acos(-1);
const int M = 1e3 + 10;
const ll MOD = 1e9 + 7;
const int N = 1e6 + 10;

ll a[N];

ll f[N];
ll c[N];
ll pref[N];

ll pw(ll x, int k) {
    if (k == 0) return 1;
    if (k % 2) return x * pw(x, k - 1) % MOD;
    ll tmp = pw(x, k / 2);
    return tmp * tmp % MOD;
}

int main() {
    //freopen("a.in", "r", stdin);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    fr(i, n)
        cin >> a[i];
    f[0] = 1;
    frab(i, 1, n + 1)
        f[i] = (f[i - 1] * i % MOD);
    frab(i, 1, n + 1)
        c[i] = f[n] * f[i - 1] % MOD * pw(f[i], MOD - 2) % MOD;
//    frab(i, 1, n + 1)
//        cout << i << " " << c[i] << "\n";
    pref[0] = 0;
    frab(i, 1, n + 2)
        pref[i] = (pref[i - 1] + c[i]) % MOD;
    ll ans = 0;
    fr(i, n)
        ans = (ans + a[i] * (pref[i + 1] + pref[n - i] - pref[1])) % MOD;
    cout << ans;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define scanf nope
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <class T>
struct Point {
	typedef Point P;
	T x, y;
	explicit Point(T x=0, T y=0) : x(x), y(y) {}
	bool operator<(P p) const { return x<p.x||(x==p.x && y<p.y);}
	bool operator==(P p) const { return x==p.x && y==p.y; }
	P operator+(P p) const { return P(x+p.x, y+p.y); }
	P operator-(P p) const { return P(x-p.x, y-p.y); }
	P operator*(T d) const { return P(x*d, y*d); }
	P operator/(T d) const { return P(x/d, y/d); }
	T dot(P p) const { return x*p.x + y*p.y; }
	T cross(P p) const { return x*p.y - y*p.x; }
	T cross(P p1, P p2) const { return (p1 - *this).cross(p2 - *this); }
	T dist2() const { return x*x + y*y; }
	double dist() const { return sqrt((double)dist2()); }
	// angle to x-axis in interval [-pi, pi]
	double angle() const { return atan2(y, x); }
	P unit() const { return *this/dist(); } // makes dist()=1
	P perp() const { return P(-y, x); } // rotates +90 degrees
	P normal() const { return perp().unit(); }
	// returns point rotated 'a' radians ccw around the origin
	P rotate(double a) const {
		return P(x*cos(a)-y*sin(a),x*sin(a)+y*cos(a)); }
};

typedef Point<double> P;
pair<vi, vi> ulHull(const vector<P>& S) {
    vector<int> Q(sz(S));
    iota(all(Q), 0);
    sort(all(Q), [&S](int a, int b){ return S[a] < S[b]; });
    vi U, L;
    trav(it, Q) {
        while (sz(U) > 1 && S[U[sz(U)-2]].cross(S[it], S[U.back()]) <= 0) U.pop_back();
        while (sz(L) > 1 && S[L[sz(L)-2]].cross(S[it], S[L.back()]) >= 0) L.pop_back();
        U.push_back(it);
        L.push_back(it);
    }
    return make_pair(U, L);
}

vi convexHull(const vector<P>& S) {
    vi u, l;
    tie(u, l) = ulHull(S);
    if (sz(S) <= 1) return u;
    u.pop_back();
    reverse(all(u));
    u.pop_back();
    u.insert(u.end(), all(l));
    if (sz(u) == 2 && S[u[0]] == S[u[1]]) u.pop_back();
    return u;
}

vector<pii> antipodal(const vector<P>& S, const vi& U, const vi& L) {
    vector<pii> A;
    int i = 0;
    int j = sz(L) - 1;
    while (i < sz(U) - 1 || j > 0) {
        A.emplace_back(U[i], L[j]);
        if (i != sz(U) - 1 && (j == 0 || (S[L[j]] - S[L[j-1]]).cross((S[U[i+1]] - S[U[i]])) > 0)) ++i;
        else --j;
    }
    return A;
}

pii polygonDiameter(const vector<P>& S) {
    vi U, L;
    tie(U, L) = ulHull(S);
    pair<double, pii> ans;
    trav(it, antipodal(S, U, L)) {
        ans = max(ans, make_pair((S[it.first] - S[it.second]).dist2(), it));
    }
    return ans.second;
}

int main() {
    int N;
    cin >> N;
        vector<P> P(N);
        rep(i,0,N) cin >> P[i].x >> P[i].y;
        pii ret = polygonDiameter(P);
        cout << setprecision(10) << fixed << (P[ret.first] - P[ret.second]).dist() << endl;
}

Measured memory_bytes: 4372
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (unsigned int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    int A,B,C,D;
int main(){
    cin>>A>>B>>C>>D;
    cout<<min(A,B)+min(C,D);
    cout<<endl;
    return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
#define N 1000

int main(void){
  int i,n,j;
  int a[N],b[N];
  int sum,digit;

  for(i=0;scanf("%d%d",&a[i],&b[i])==2;i++){}
  n=i;
  for(i=0;i<n;i++){
    sum=a[i]+b[i];
    digit=0;
    for(;;)
      if(sum>0){
        digit++;
        sum/=10;
      }else
        break;
    printf("%d\n",digit);
  }
  return 0;
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String[] str = br.readLine().split(" ");

        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = Long.parseLong(str[i]);
        }

        Arrays.sort(a);

        ArrayList<Long> able = new ArrayList<>();
        for (int i = n - 2; i >= 0; i--) {
            if(a[i] == a[i+1]){
                able.add(a[i]);
                i--;
            }

            if(able.size() >= 2){
                System.out.println(able.get(0) * able.get(1));
                System.exit(0);
            }
        }

        System.out.println(0);
    }
}

Measured memory_bytes: 47956
n, m = input().split()
n, m = int(n), int(m)

bulbs = []

for i in range(m):
    l = input().split()
    arr = [int(x)-1 for x in l][1:]
    bulbs.append(arr)

needs = [int(x) for x in input().split()]

import itertools

combos = 0

def test(lis):
    for i in range(m):
        need = needs[i]
        curr = 0
        for j in bulbs[i]:
            if lis[j] == 1:
                curr += 1
        if curr % 2 != need:
            return False
    return True

for i in itertools.product([0, 1], repeat=n):
    if test(list(i)):
        combos += 1

print(combos)


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  int H, W, N;
  cin >> H >> W >> N;
  vector<ll> num(10);
  num[0] = (ll)(H-2)*(W-2);
  if(N) {
    vector<int> a(N), b(N);
    rep(i, N) {
      cin >> a[i] >> b[i];
      a[i]--; b[i]--;
    }
    map<pair<int, int>, int> mp;
    rep(i, N) {
      for(int j=-1; j<=1; j++) {
        for(int k=-1; k<=1; k++) {
          if(a[i]+j > 0 && b[i]+k > 0 && a[i]+j < H-1 && b[i]+k < W-1)
            mp[{a[i]+j, b[i]+k}]++;
        }
      }
    }
    for(auto e : mp) {
      num[0]--;
      num[e.second]++;
    }
  }
  rep(i, 10)
    cout << num[i] << endl;
  return 0;
}

Measured memory_bytes: 57216
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define LONGMAX 1e18
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define endl "\n"
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first	
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define INF 1e9
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
ll powe(ll x,ll y){ll res=1;while(y>0){if(y&1)res=res*x;y=y>>1;x=x*x;}return res;}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
void ceilsearch(ll ar[],ll low,ll high,ll x,ll &y){ll mid=(low+high)/2;if(low>high)return;if(ar[mid]>=x){y=mid;ceilsearch(ar,low,mid-1,x,y);}else{ceilsearch(ar,mid+1,high,x,y);}}
int main()
{
	fastio();
	//#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    //freopen("outpu.txt","w",stdout);
    //#endif
	ll N;
	cin>>N;
	set<ll> s;
	for(ll i=0;i<N;i++)
	{
	    ll a;
	    cin>>a;
	    s.insert(a);
	}
	if(s.size()==N)
	    cout<<"YES"<<endl;
	    else
	        cout<<"NO"<<endl;
}

Measured memory_bytes: 9600
import java.util.Scanner;

public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);

		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();

		int count = 0;
		for(int x = a; x <= b; ++x){
			if(c % x == 0){
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 26200
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    n, k = int(input()), 2
    dp = [INF] * n
    dp[0] = 0
    H = list(map(int, input().split()))
    for i in range(n):
        for pi in range(i - k, i):
            if pi < 0:
                continue
            dp[i] = min(dp[i], dp[pi] + abs(H[i] - H[pi]))
    print(dp[n - 1])
resolve()

Measured memory_bytes: 52976
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int a;
    cin >> a;
    cout << a + a * a + a * a* a << '\n';
}

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

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

vector<int> e[300010];

int n;

void add_edge(int from, int to)
{
	int mo=3*n;
	rep(i, 3) e[from+i*n].push_back((to+(i+1)*n)%mo);
}

bool done[300010];
int d[300010];

int main() {
	int m;
	cin >> n >> m;
	rep(i, m)
	{
		int from, to;
		cin >> from >> to;
		from--;
		to--;
		add_edge(from, to);
	}
	int s, t;
	cin >> s >> t;
	s--;
	t--;
	queue<int> q;
	q.push(s);
	d[s]=0;
	while(!q.empty())
	{
		int from=q.front();
		q.pop();
		rep(i, e[from].size())
		{
			int to=e[from][i];
			if(!done[to])
			{
				d[to]=d[from]+1;
				done[to]=true;
				q.push(to);
			}
		}
	}
	if(!done[t]) cout << "-1" << endl;
	else cout << d[t]/3 << endl;
	return 0;
}

Measured memory_bytes: 18176
n = int(input())
while n != 0:
    a = list(map(int, input().split()))
    ans = float("inf")
    for i in range(n-1):
        for j in range(i+1, n):
            res = abs(a[i] - a[j])
            if ans > res:
                ans = res
    print(ans)
    n = int(input())


Measured memory_bytes: 5632
n = int(input())

now = [0,0,0]
for i in range(n):
    s = list(map(int,input().split()))
    time = s[0] - now[0]
    dis = abs(s[1] - now[1]) + abs(s[2] - now[2])
    if time < dis or (time-dis)%2 == 1:
        print("No")
        exit()
    now = s

print("Yes")

Measured memory_bytes: 3060
from sys import stdin
N,x = [int(x) for x in stdin.readline().rstrip().split()]
data = [int(x) for x in stdin.readline().rstrip().split()]
ans = 0
for i in range(N-1):
    v1 = data[i]
    v2 = data[i+1]
    if v1 + v2 >= x:
        ans += (v1+v2-x)
        data[i+1] = max(v2-(v1+v2-x),0)
print(ans)

Measured memory_bytes: 14132
import java.io.*;
import java.util.*;

class Main {

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		long M = sc.nextLong();
		long[] a = new long[(int) (A)];
		long minA = Long.MAX_VALUE;
		for (int i = 0; i < A; i++) {
			a[i] = sc.nextLong();
			minA = Math.min(minA, a[i]);
		}
		long[] b = new long[(int) (B)];
		long minB = Long.MAX_VALUE;
		for (int i = 0; i < B; i++) {
			b[i] = sc.nextLong();
			minB = Math.min(minB, b[i]);
		}

		long answer = minA + minB;
		long[] c = new long[(int) (M)];
		for (int i = 0; i < M; i++) {
			int x = sc.nextInt() - 1;
			int y = sc.nextInt() - 1;
			long t = a[x] + b[y];
			t -= sc.nextLong();
			answer = Math.min(answer, t);
		}

		System.out.println(answer);
	}
}


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

int main() {
  int a, b, k; cin >> a >> b >> k;
  int num = 0;
  int answer = 0;
  
  for (int i = min(a, b); i >= 1; i--) {
    if (a % i == 0 && b % i == 0) {
      num++;
      if (num == k) {
        answer = i;
        break;
      }
    }
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256
# ITP1_7_D
n, m, l = map(int, input().split())#　
A = []
B = []
C = [[0 for i in range(l)] for j in range(n)]

# 列=n
for i in range(n):
    A.append(list(map(int, input().split())))
# 列=m
for i in range(m):
    B.append(list(map(int, input().split())))
# 列=n
for i in range(n):
    for j in range(l):
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]

# すべてを表示
for line in C:
    print(*line)


Measured memory_bytes: 7064
#include<cstdio>
int a,b,c,d,e,f;
int	sugar=0,water=0,q,r,tot=0;
double max;
int dp[4200][7200];
int min(int a,int b){return a<b?a:b;}
int find(int s,int w)
{
	if(dp[s][w]==1) return 0;
	else dp[s][w]=1;
	if(s+w>f) return 0;
//	if((w/100)*e<s&&(double)w*e/((w/100)*e+w)>max)  
//		sugar=(w/100)*e,water=w,max=(double)w*e/((w/100)*e+w);
	if((w/100)*e>=s&&(s+w)!=0&&(double)100*s/(s+w)>max) 
		sugar=s,water=w,max=(double)100*s/(s+w);
	if((w/100)*e>s) 
	{
		r=find(s+d,w);
		if(r==1) return 1;
		q=find(s+c,w);
		if(q==1)return 1;
	}
	else if((w/100)*e<s||(s==w&&s==0))
	{
		q=find(s,w+a*100);
		if(q==1)return 1;
		r=find(s,w+b*100);
		if(r==1) return 1;
	}
	else return 1;
	return 0;
}
int main()
{
	scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
	find(0,0);
	if(water==0) water=min(a*100,b*100);
	printf("%d %d",water+sugar,sugar);
	return 0; 
}

Measured memory_bytes: 30848
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'

void solve(){
  int n;
  cin >> n;
  float t, a;
  cin >> t >> a;
  int ans = 1;
  float dif = 1e9;
  rep(i,1,n+1){
    float x;
    cin >> x;
    float cur = t - x * 0.006;
    float d = fabs(cur - a);
    if (d < dif){
      dif = d;
      ans = i;
    }
  }
  cout << ans;
}

int main() {
  ios::sync_with_stdio(false);
  // cin.tie(0); cout.tie(0);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 


*/

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

int main() {
    ll n,k;cin>>n>>k;
    ll a[n];
    for (int i=0;i<n;i++)
        cin>>a[i];
    ll x=0,ans=0;
    for (ll i=1LL<<60;i>0;i>>=1) {
        int c=0;
        for (int j=0;j<n;j++)
            if (a[j]&i)
                c++;
        if (n-c>c&&x+i<=k) {
            x+=i;
            ans+=i*(n-c);
        } else
            ans+=i*c;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
// Author : heyuhhh
// Created Time : 2020/08/22 20:04:04
#include<bits/stdc++.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 1e5 + 5;
void run() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll ans = 0;
    for (int i = 1; i < n; i++) {
        ans += max(0, a[i - 1] - a[i]);
        a[i] = max(a[i], a[i - 1]);
    }
    cout << ans << '\n';
}
int main() {
#ifdef Local
    freopen("input.in", "r", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}

Measured memory_bytes: 3952
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#include <deque>
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl
#define isort(a) sort(a.begin(),a.end())

using namespace std;

#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}

typedef pair<ll,ll> Pair;
const ll inf =1000000007;

ll tasu(ll n,ll k){
    ll max=n*(n+1)/2-k*(k+1)/2;
    ll min=(n-k)*(n-k+1)/2;
    return (max-min+1)%inf;
}

void solve(){
    ll n,k;
    cin >> n >>k;
    n++;
    ll ans=0;
    for(ll i=k;i<=n;i++){
        ans=ans+tasu(n,i);
        ans%=inf;
    }
    kaku(ans);
}

int main(){
    solve();
}

Measured memory_bytes: 3636
from fractions import *
N = int(input())
A = list(map(int, input().split()))
left = [A[0]]
right = [A[-1]]
for i in range(1, N):
    left.append(gcd(A[i], left[-1]))
    right.append(gcd(A[N-1-i], right[-1]))
right = right[::-1]
ans = max(left[N-2], right[1])
for i in range(1, N-1):
    ans = max(ans, gcd(left[i-1], right[i+1]))
print(ans)


Measured memory_bytes: 16116
import java.util.*;
public class Main {
  public static void main(String[] args){
	//入力の読み込み
	Scanner sc = new Scanner(System.in);
	int X = sc.nextInt();
	int Y = sc.nextInt();
	int Z = sc.nextInt();

	//出力
	System.out.println(Z + " " + X + " " + Y);
  }
}

Measured memory_bytes: 26944
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
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 drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#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
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 MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;



int main(void) {

    ll n;
    cin>>n;
    vll t(n);
    vll a(n);
    rep(i,n)cin>>t[i];
    rep(i,n)cin>>a[i];
    vll mt(n),ma(n);
    ll ans=1;
    if(t[n-1]!=a[0]){
        fin(0);
        return 0;
    }

    mt[0]=1;
    ll maxt=t[0];
    for(int i=1;i<n;i++){
        if(t[i]>maxt){
            maxt=t[i];
            mt[i]=1;
        } else {
            mt[i]=maxt;
        }
    }
    ma[n-1]=1;
    ll maxa=a[n-1];
    for(int i=n-2;i>=0;i--){
        if(a[i]>maxa){
            maxa=a[i];
            ma[i]=1;
        } else {
            ma[i]=maxa;
        }
    }
    for(int i=0;i<n;i++){
        ans=ans*min(mt[i],ma[i])%MOD;
    }
    for(int i=0;i<n;i++){
        if(ma[i]==1&&mt[i]==1&&a[i]!=t[i]){
            cout<<0<<endl;
            return 0;
        }
    }
    for(int i=0;i<n;i++){
        if(ma[i]==1){
            if(a[i]>t[i]){
                cout<<0<<endl;
                return 0;
            }
        }
    }
    for(int i=0;i<n;i++){
        if(mt[i]==1){
            if(t[i]>a[i]){
                cout<<0<<endl;
                return 0;
            }
        }
    }
    
    fin(ans);
}



Measured memory_bytes: 3328
N=int(input())
S=input()

if N%2!=0:
    print("No")
else:
    x=[]
    y=[]
    for n in range(N//2):
        x.append(S[n])
    for n in range(N//2,N):
        y.append(S[n])
        
    if x==y:
        print("Yes")
    else:
        print("No")

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

int main(){
  int n; string s;
  cin>>n;
  cin>>s;
  string t;
  t=s.substr(0,n/2);
  if(s==t+t){
    cout<<"Yes"<<endl;
  }
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
input_lines = gets.chop.split.map(&:to_i)
input_lines2 = gets.chop.split.map(&:to_i)
a = input_lines[0]
maxCount = 0
count = 0
for i in 1...input_lines2.size 
    if input_lines2[i-1] >= input_lines2[i]
        count = count + 1
    else 
        if maxCount < count
            maxCount =  count
        end
        count = 0
    end 
end
if maxCount < count
    maxCount =  count
end
puts maxCount

Measured memory_bytes: 10244
#include <stdio.h>
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <map>
#include <queue>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<pii> vii;
typedef vector<string> vs;

int main() {
  string s;
  cin >> s;
  int t = 0;
  for (char x : s) {
    if (x == 'C') t = 1;
    if (x == 'F' && t) {
      t = 2; break;
    }
  }
  if (t==2) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<set>
using namespace std;

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

const int maxN=2*100005;
int N;
vector<int> G[maxN];
vector<int> c(maxN);

void add_edge(int a, int b){
    G[a].push_back(b);
    G[b].push_back(a);
}

void bfs(){
    queue<int> q;
    bool used[N];
    rep(i,N) used[i]=false;
    q.push(0);
    while(!q.empty()){
        int now = q.front();q.pop();
        used[now]=true;
        rep(i,G[now].size()){
            int v=G[now][i];
            if(used[v]) continue;
            c[v] += c[now];
            q.push(v);
        }
    }
}

int main(){
    int Q;
    cin >> N >> Q;
    rep(i,N-1){
        int a,b;
        cin >> a >> b;
        a--;b--;
        add_edge(a,b);
    }

    rep(i,Q){
        int p,x;
        cin >> p >> x;
        c[--p] += x;
    }
    bfs();

    rep(i,N){
        cout << c[i] << " " ;
    }
    cout << endl;
    return 0;
}




Measured memory_bytes: 16132
#include<iostream>
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
	ll n;
	cin>>n;
	ll a[n];
	ll yen =1000;
	ll stock = 0;
	ll i;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=0;i<n-1;i++){
		if(a[i]<a[i+1]){
			stock = stock + yen/a[i];
			yen = yen %a[i];
		}
		else if(a[i]>a[i+1]){
			yen = yen + a[i]*stock;
			stock=0;
		}
	}
	cout<<yen+stock*a[n-1];
}

Measured memory_bytes: 3656
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val d = readLine()!!.split(" ").map(String::toInt)
    println(op143b(n, d))
}

fun op143b(n: Int, d: List<Int>): Int {
    var result = 0
    for (i in 0 until n-1){
        for (j in i+1 until n){
            result += d[i] * d[j]
        }
    }
    return result
}


Measured memory_bytes: 37840
#include <stdio.h>
#include <string.h>

int main(){

    char S[101];
    int num;    /* Sの文字数 */
    int i, flag=0;

    scanf("%s", S);
    for( num=0; S[num] !='\0'; num++ );
    
    for( int i=0; i<num; i++ ){
    
        /* 奇数のとき */
        if( (i%2 == 0) && (S[i] == 'L' )){
            flag = 1;
        }
        /* 偶数のとき */
        if( (i%2 == 1) && (S[i] == 'R' )){
            flag = 1;
        }
        /*
        if( i%2 == 1 && (S[i] == 'R' || S[i] == 'U' || S[i] == 'D' )){
            if( i%2 == 0 && (S[i] == 'L' || S[i] == 'U' || S[i] == 'D' )){
                ;
            }
        }else{
            flag = 1;
        }
        */
    }

    if( flag == 0 ){
        printf("Yes");
    } else if( flag == 1 ) {
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 128
n,m,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
x = sorted(x)
y = sorted(y)
if x[-1] < Y and y[0] > X and x[-1] < y[0]:
    print("No War")
else:
    print("War")

Measured memory_bytes: 3060
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0]);
  input.shift();
  var A = input.map(i => parseInt(i));
  A.splice(N,A.length);
  var B = [...A];
  B.sort(function(a,b){return b-a});
  var anssub = new Array();
  for(var i =0;i<N;i++){
    if(A[i]==B[0]){
      anssub.push(B[1]);
    }else{
      anssub.push(B[0]);
    }
  }
  var ans = anssub.join("\n");

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define fi first
#define se second

const int N = 200200;

using namespace std;

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

        int n, k;
        cin >> n >> k;
        if(k == 1){
                cout << 0 << "\n";
        } else{
                cout << n - k << "\n";
        }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for (int i = 0; i < n; i++)
#define why(n, x)                                                              \
  int n;                                                                       \
  while (cin >> n, n != x)
#define iFOR(i, x, n) for (int i = x; i < n; i++)
#define fin << '\n'
#define __ << " " <<
#define ___ << " "
#define bash push_back
#define ALL(x) x.begin(), x.end()
#define SWAP(a, b) ((a != b) && (a += b, b = a - b, a -= b))
//#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vit;
typedef map<string, int> mstit;
typedef vector<pii> vpi;
typedef greater<pii> gpi;
typedef priority_queue<pii, vpi, gpi> dijk;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
static const signed int dy[] = {0, -1, 0, 1, -1, 1, -1, 1};

bool inside(int x, int y, int w, int h) {
  return (x >= 0 && y >= 0 && x < w && y < h);
}
template <class T> T abs(T &x) { return x < 0 ? -x : x; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int qp(int a, ll b, int mo) {
  int ans = 1;
  do {
    if (b & 1)
      ans = 1ll * ans * a % mo;
    a = 1ll * a * a % mo;
  } while (b >>= 1);
  return ans;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

ll a, b;

inline void solve() {
  cin >> a >> b;

  ll g = __gcd(a, b);
  ll sum = 1;

  for (ll i = 2; i * i <= g; i++) {

    if (g % i == 0) {
      sum++;
      while (!(g % i))
        g /= i;
    }
  }

  cout << sum + (g > 1) << endl;
}
struct xyz {
  xyz() {
    cin.tie(0), ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
  };
} xyzzy;
signed main() {
  solve();
  return 0;
}


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

struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while ( x != NIL ) {
        y = x;
        if ( z->key < x->key ) {
            x = x->left;
        } else {
            x = x->right;
        }
    }

    z->parent = y;
    if ( y == NIL ) {
        root = z;
    } else {
        if ( z->key < y->key ) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if ( u == NIL ) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u) {
    if ( u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main() {
    int n, i, x;
    string com;

    scanf("%d", &n);

    for ( i = 0; i < n; i++) {
        cin >> com;
        if( com == "insert" ) {
            scanf("%d", &x);
            insert(x);
        } else if ( com == "print" ) {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}


Measured memory_bytes: 26740
#include<stdio.h>
#define MAX 2000000

int n,A[MAX + 1];

void maxHeapify(int i){
  int l,r,largest,t;

  l = 2 * i;
  r = 2 * i + 1;

  if(l <= n && A[l] > A[i]){
    largest = l;
  }
  else{
    largest = i;
  }

   if(r <= n && A[r] > A[largest]){
    largest = r;
   }
   
   if(largest != i){
     t = A[i];
     A[i] = A[largest];
     A[largest] = t;
     
     maxHeapify(largest);
   }
}

int main(){
  int i;

  scanf("%d",&n);

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

  for(i = n / 2;i >= 1;i--){
    maxHeapify(i);
  }

  for(i = 1;i <= n;i++){
    printf(" %d",A[i]);
  }

  printf("\n");

  return 0;
}



Measured memory_bytes: 3652
n,m,l = map(int,input().split())

a = []
b = []

for i in range(n):
  a.append(list(map(int,input().split())))
  
for i in range(m):
  b.append(list(map(int,input().split())))

d = [[0 for i in range(l)] for j in range(n)]
for i in range(n):
  for j in range(l):
    for k in range(m):
      d[i][j] += a[i][k]*b[k][j]

for i in range(n):
  for j in range(l):
    print(d[i][j] , end="")
    if j == l - 1:
      print()
    else:
      print(" ",end="")
    


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

int main() {
  int N,a[109];cin>>N;
    for(int i=0;i<N;i++){
    cin>>a[i];}
    sort(a,a+N,greater<int>());
  int ret=0;
  for(int i=0;i<N;i++){ret +=a[i] * (i & 1 ? - 1 : 1);}
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
# by the authority of GOD
import os,sys
from io import BytesIO, IOBase


def maxAbsValExpr(arr1,arr2) :
    minX, maxX = min(arr1), max(arr1)
    minY, maxY = min(arr2), max(arr2)

    ans = 0
    for point in [(minX, minY), (maxX, minY), (minX, maxY), (maxX, maxY)]:
        minD = float('inf')
        maxD = float('-inf')
        for i in range(0, len(arr1)):
            distance = abs(arr1[i] - point[0]) + abs(arr2[i] - point[1])
            minD = min(minD, distance)
            maxD = max(maxD, distance)
        ans = max(ans, maxD - minD)
    return ans
def main():
    x=[]
    y=[]
    for i in range(int(input())):

        a,b =map(int,input().split())
        x.append(a)
        y.append(b)
    print(maxAbsValExpr(x,y))
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == '__main__':
    main()

Measured memory_bytes: 91488
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <assert.h>
#include <sstream>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<vector<ll>> mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;

#define dump(...)                                         \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; \
        print_to(os, ", ", "\n", __VA_ARGS__);            \
        std::cerr << os.str();                            \
    } while (0)

template <typename T>
void print_to(std::ostream &os, const char *, const char *tail, const T &fst) {
    os << fst << tail;
}
template <typename Fst, typename... Rst>
void print_to(std::ostream &os, const char *del, const char *tail, const Fst &fst, const Rst &... rst) {
    os << fst << del;
    print_to(os, del, tail, rst...);
}
template <typename Iter>
void print_to_(std::ostream &os, const char *del, const char *tail, Iter bgn, Iter end) {
    for (Iter it = bgn; it != end;) {
        os << *it;
        if (++it != end) {
            os << del;
        } else {
            os << tail;
        }
    }
}

signed main()
{
    int A, B, C;
    cin >> A >> B >> C;
    dump(A, B, C);
    cout << (A^B^C) << endl;
}


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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#ifdef LOCAL
#define what_is(x) cerr << #x << " is " << x << endl;
#define debug(v) {for (auto x : v) cerr << x << ' '; cerr << endl;}
#else
#define what_is(x)
#define debug(v)
#endif

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

const int N = 2001;
const ll MOD = 1e9 + 7;
ll dp[N][N];
int n, k;

void precalc() {
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		dp[i][0] = dp[i][i] = 1;
		for (int j = 1; j < i; j++)
			dp[i][j] = (dp[i-1][j] + dp[i-1][j-1]) % MOD;
	}
}

ll combine(int a, int b) {
	if (a < b) return 0;
	if (b < 0) return 0;
	return dp[a][b];
}

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	cin >> n >> k;
	precalc();
	for (int i = 1; i <= k; i++) {
		ll answer = combine(n-k+1, i) * combine(k-1, i-1);
		answer %= MOD;
		printf("%lld\n", answer);
	}
}


Measured memory_bytes: 30080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(int argc, char **argv)
{
	ll l, r;
	cin >> l >> r;

	if (r-l > 2019)
	{
		std::cout << 0<< std::endl;
		return 0;
	}
	else
	{
		ll ans{LLONG_MAX};
		for (ll i = l; i < r; ++i)
		{
			for (ll j = i+1; j <= r; ++j)
			{
				ll mi = i % 2019;
				ll mj = j % 2019;
				ll tmp = (mi * mj) % 2019;
				ans = min(ans, tmp);
			}
		}

		std::cout << ans<< std::endl;
	}
	

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;
   cin>>n;
   map<int,int>a;
   int x;
    for(int i = 0;i<n;i++)
    {
        cin>>x;
        a[x]++;
        if(a[x]>1)
        {
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";
}


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

using namespace std;

int main(){
    int X,a,b,p;

    cin>>X;
    if(X==1){
        cout<<1<<endl;
        return 0;
    }

    for(int i=X;i>1;i--){
        for(int j= (i-1); j>1; j--){
            int k=i;
            while(k >= j){
                //cout<<" k:"<<k<<" j:"<<j;
                if(k == j){
                    cout<<i<<endl;
                    return 0;
                }
                if(k%j == 0){
                    k= k/j;
                }else{
                    break;
                }
            }

        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;

int main() {
    ll n,m;
    cin>>n>>m;
    vector<ll> x(n);
    vector<ll> y(n);
    vector<ll> z(n);
    ll maxcake=0;

    rep(i,n){
        cin>>x[i]>>y[i]>>z[i];
    }

    for(int ii=0;ii<(1<<3);ii++){
        vector<ll> v(3);
       for(int j=0;j<3;j++){
           if((ii>>j)&1){
               v[j]=1ll;
           }else{
            v[j]=-1ll;
           }
       }
        vector<ll> vc;

       rep(i,n){
           ll t=x[i]*v[0]+y[i]*v[1]+z[i]*v[2];
          vc.push_back(t);
       }

       sort(vc.rbegin(),vc.rend());
     ll yu=0;
       rep(i,m){
           yu+=vc[i];
       }
       yu=abs(yu);


        maxcake=max(yu,maxcake);


    }
    cout<<maxcake<<endl;



    return 0;
}


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll K,Q;
    cin >> K >> Q;
    ll d[5010];
    rep(i,0,K) cin >> d[i];

    while(Q--){
        ll N,X,M;
        ll d2[5010];
        cin >> N >> X >> M;
        rep(i,0,K) d2[i] = d[i] % M;
        ll sum = 0;
        rep(i,0,K) sum += d2[i];
        ll zero = 0;
        rep(i,0,K){
            if(d2[i] == 0) zero++;
        }
        ll amari = (N-1) % K;
        ll cnt = (N-1) / K;
        ll val = X + sum * cnt;
        ll diff = val / M - X / M;
        ll ans = diff + zero * cnt;
        ans = K * cnt - ans;
        ll cur = val % M;
        rep(i,0,amari){
            if(cur < (cur + d2[i]) % M){
                ans++;
            }
            cur = (cur + d2[i]) % M;
        }
        print(ans);




    }
    

}

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

int main() {
    
    string S, T, U;
    int A, B;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;

    if(S == U){
        A -= 1;
    }

    else if (T == U){
        B -= 1;
    }

    cout << A << " " << B << endl;

    return 0;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll n;
ll a[100];

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

  cin>>n;
  rep(i,n)cin>>a[i];
  ll cnt=0;
  repl(i,1,n-1){
    vector<int> b;
    repl(j,-1,2)b.push_back(a[i+j]);
    sort(all(b));
    if(b[1]==a[i])cnt++;
  }
  cout<<cnt<<endl;

  return 0;
}


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

namespace AtCoder.Abc
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => double.Parse(i)).ToArray();

            Console.WriteLine(inputLongArray[0] / inputLongArray[1]);


        }
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, m, q, l, r, d[512][512] = {};
    cin >> n >> m >> q;
    while (m--) cin >> l >> r, d[l][r]++;
    for (int i = 1; i <= n; i++) for (int j = i; j <= n; j++) d[i][j] += d[i][j - 1];
    while (q--) {
        cin >> l >> r;
        int z = 0;
        for (int i = l; i <= r; i++) z += d[i][r];
        cout << z << '\n';
    }
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int h,w,k;
    string in;
    cin >> h >> w >> k;
    vector<string> rows;
    for(int i=0;i<h;i++) {
        cin >> in;
        rows.push_back(in);
    }
    int res = 0;
    for(int i=0;i<(1<<h);i++) {
        for(int j=0;j<(1<<w);j++) {
            int cnt = 0;
            for(int i2=0;i2<h;i2++) {
                if(i&(1<<i2)) continue;
                for(int j2=0;j2<w;j2++) {
                    if(j&(1<<j2)) continue;
                    cnt += rows[i2][j2] == '#';
                }
            }
            if(cnt == k) res++;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
struct a
{
	set<char>s;
} s[110];
char c[110];
int n,tim;
inline set<char> bin(set<char>a,set<char>b)
{
	set<char>c;
	c.clear();
	for(char ch='a'; ch<='z'; ch++)
		if(a.find(ch)!=a.end()&&b.find(ch)!=b.end())
			c.insert(ch);
	return c;
}
inline set<char>jiao(set<char>a,set<char>b)
{
	set<char>::iterator it;
	for(it=b.begin(); it!=b.end(); it++)
		if(a.find(*it)==a.end())
			a.insert(*it);
	return a;
}
int main(void)
{
	set<char>op;
	op.clear();
	scanf("%s",c);
	tim=n=strlen(c);
	for(int i=0; i<n; i++)
		s[i].s.insert(c[i]);
	while(1)
	{
		for(char ch='a'; ch<='z'; ch++)
			op.insert(ch);
		for(int i=0; i<n; i++)
			op=bin(op,s[i].s);
		if(op.size())
			break;
		n--;
		for(int i=0; i<n; i++)
		{
			s[i].s=jiao(s[i].s,s[i+1].s);
		}
	}
	cout<<tim-n;
}

Measured memory_bytes: 256
import math as m

n, d = map(int, input().split())
lp = []
for i in range(n):
	lp.append(list(map(int, input().split())))

count = 0

for i in range(n-1):
	for j in range(i+1, n):
		acc = 0
		for k in range(d):
			acc += (lp[j][k] - lp[i][k]) ** 2
		
		if m.sqrt(acc).is_integer():
			count += 1

print(count)

Measured memory_bytes: 3064
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){
  string S, T;
  cin >> S >> T;
  vector<int> start(26, -1);
  vector<int> goal(26, -1);
  for(int i=0;i<S.size();i++) {
    int a = S[i] - 'a';
    int b = T[i] - 'a';

    if(start[a] != -1 || goal[b] != -1) {
      if(start[a] != b || goal[b] != a) {
        cout << "No" << endl;
        return 0;
      }
    } else {
      start[a] = b;
      goal[b] = a;
    }
  }

  cout << "Yes" << endl;
}

Measured memory_bytes: 776
a, b = map(int, input().split())
amin = -(-a*25//2)
amax = -(-(a+1)*25//2)
bmin = b*10
bmax = bmin + 10
for i in range(amin, amax):
    for j in range(bmin, bmax):
        if i == j:
            print(i)
            exit()
print(-1)


Measured memory_bytes: 3060
mlen = 0
mexst = 0
word = map(str, raw_input().split())
setword = list(set(word))
for i in range(len(word)):
    if len(word[i]) > mlen:
        mlen  = len(word[i])
        mlenw = word[i]
for i in setword:
    if word.count(i) > mexst:
        mexst = word.count(i)
        mexstw = i

print mexstw, mlenw

Measured memory_bytes: 4220