akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define FORD(i,a,b) for(int i = (a); i >= (b); i--)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define M_PI 3.14159265358979323846
template<class C> void mini(C& _a4, C _b4) { _a4 = min(_a4, _b4); }
template<class C> void maxi(C& _a4, C _b4) { _a4 = max(_a4, _b4); }

template<class TH> void _dbg(const char *sdbg, TH h) { cerr << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
	while (*sdbg != ',')cerr << *sdbg++; cerr << '=' << h << ','; _dbg(sdbg + 1, a...);
}

template<class T> ostream& operator<<(ostream& os, vector<T> V) {
	os << "["; for (auto& vv : V) os << vv << ","; os << "]";
	return os;
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L, R> P) {
	return os << "(" << P.st << "," << P.nd << ")";
}


#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#endif

template<typename Out>
void split(const std::string &s, char delim, Out result) {
	std::stringstream ss(s);
	std::string item;
	while (std::getline(ss, item, delim)) {
		*(result++) = item;
	}
}

std::vector<std::string> split(const std::string &s, char delim) {
	std::vector<std::string> elems;
	split(s, delim, std::back_inserter(elems));
	return elems;
}

void trim(string & s) {
	int idx = 0;
	int n = s.size();
	REP(i, n) {
		if (s[i] != ' ' && s[i] != '\t') {
			s = s.substr(i);
			break;
		}
	}
	while (!s.empty()) {
		if (s.back() == ' ' || s.back() == '\t') {
			s.pop_back();
		}
		else {
			break;
		}
	}
}

bool usuwaj;
int nodes;
int32_t main(int32_t argc, char ** argv) {
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	vector<int> inp(n);
	int res = 1;
	int odd = 1;
	REP(i, n) {
		cin >> inp[i];
		int oddCo = 0;
		res *= 3;
		FOR(j, inp[i] - 1, inp[i] + 1) {
			if (j & 1) {
				oddCo++;
			}
		}
		odd *= oddCo;
	}
	cout << res - odd;
}

Measured memory_bytes: 256
#include <stdio.h>

int fib( int  );
int fib_array(int [], int  );

int main(){
    int n, A[45];

    scanf("%d", &n);
    //printf("%d\n", fib( n ));
    printf("%d\n", fib_array(A, n));

    return 0;
}
int fib_array(int A[], int n){
    int i;
    A[0] = A[1] = 1;
    for(i = 2; i<=n; i++) A[i] = A[i-2] + A[i-1]; 
    return A[n];
}

int fib( int i ){
    if(i == 0 || i == 1) return 1;
    return fib(i-2) + fib(i-1);
}



Measured memory_bytes: 2112
#!/usr/bin/env python3
import sys
import math
from collections import Counter
import collections
INF = float("inf")


def factorial(n):
    # 試し割りによる素因数分解
    prime_count = collections.Counter()

    for i in range(2, int(math.sqrt(n)) + 2):
        while n % i == 0:
            n /= i
            prime_count[i] += 1
    if n > 1:
        prime_count[int(n)] += 1

    return prime_count


def GCD(a, b):
    if a == 0:
        return b
    else:
        return GCD(b % a, a)


def GCDs(*a):
    # リストで入力しないよう注意。
    if len(a) == 0:
        return -1  # エラー

    if len(a) == 1:
        return a[0]

    res = a[0]
    for i in range(1, len(a)):
        res = GCD(res, a[i])
    return res


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


def solve(N: int, A: "List[int]"):
    c1 = make_divisors(A[0])
    c2 = make_divisors(A[1])
    c = sorted(list(set(c1 + c2)))

    OKs = []
    for cv in c:
        if sum([1 if a % cv == 0 else 0 for a in A]) >= N-1:
            OKs.append(cv)
    print(max(OKs))

    # b = A[0]
    # m = INF
    # mi = -1
    # for i in range(N):
    #     g = GCD(A[i], b)
    #     print(g)
    #     if m > g:
    #         m = g
    #         mi = i
    # buf = None
    # for i in range(N):
    #     if mi == i:
    #         continue
    #     if buf is None:
    #         buf = A[i]
    #     else:
    #         buf = GCD(buf, A[i])
    # print([buf, GCDs(*A[1:])])
    # print("回答: ", max([buf, GCDs(*A[1:])]))
    # # print(g)

    # s = SegmentTree(N)
    # for i in range(N):
    #     s.update(i, A[i])
    # # print("tree ", s.tree)
    # g = []
    # for i in range(N):
    #     # iを覗いたGCDをとる
    #     if i == 0:
    #         g.append(s.query(1, N))
    #     elif i == N-1:
    #         g.append(s.query(0, N-1))
    #     else:
    #         # print(s.query(0, i), s.query(i+1, N))
    #         g.append(GCD(s.query(0, i), s.query(i+1, N)))
    # # print(g)
    # # print("回答2: ", max(g))
    # print(max(g))

    # g = []
    # for i in range(N):
    #     buf = None
    #     for j in range(N):
    #         if i == j:
    #             continue
    #         if buf is None:
    #             buf = A[j]
    #         else:
    #             buf = GCD(buf, A[j])
    #     g.append(buf)
    # # print(g)
    # print("正解：", max(g))

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 16432
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    string S; cin >> S;
    int M = S.size();
    vector<vector<int>> G(M + 1);
    vector<int> vals(M + 1), visited(M + 1);
    int Q; cin >> Q;
    for (int i = 0; i < Q; i++) {
        int L, R; cin >> L >> R;
        G[L-1].push_back(R);
        G[R].push_back(L-1);
    }
    for (int i = 0; i < M + 1; i++) {
        G[i].push_back(M - i);
    }
    for (int i = 0; i < M; i++) {
        vals[i] += S[i] - 'a';
        vals[i + 1] += 26 - (S[i] - 'a');
    }
    for (int i = 0; i < M + 1; i++) {
        if (visited[i]) continue;
        int sum = 0;
        stack<int> S;
        S.push(i), visited[i] = 1;
        while (!S.empty()) {
            int node = S.top();
            sum += vals[node];
            S.pop();
            for (int next : G[node]) {
                if (!visited[next]) S.push(next), visited[next] = 1;
            }
        }
        if (sum % 26 != 0) {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
    return 0;
}


Measured memory_bytes: 9812
#include <cstdio>
#include <cstring>
using namespace std;

int main(){
	char buf[20];
	scanf("%s",buf);
	int n = strlen(buf);
	int ans = 0;
	for(int i=0; i<n/2; i++){
		if(buf[i] == '(' && buf[n-1-i]==')'){
			;
		}
		else if(buf[i] == ')' && buf[n-1-i]=='('){
			;
		}
		else if(buf[i] == 'w' && buf[n-1-i] == 'w'){
			;
		}
		else if(buf[i] == 'i' && buf[n-1-i] == 'i'){
			;
		}
		else{
			ans++;
		}
	}
	if(n&1){
		ans += ((buf[n/2]==')' || buf[n/2]=='(')?1:0);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
const int inf { int ( 1e9 ) } ;
int main(){
  int n, t;
  cin >> n >> t;
  int ans = inf;
  for(int i = 0; i < n; i++){
    int cost_temp; cin >> cost_temp;
    int t_temp; cin >> t_temp;
    if(t_temp <= t) {
      ans = min(ans, cost_temp);
    }
  }
  if(ans == inf ) cout << "TLE" << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 256
N,X=map(int,input().split())
S=list(map(int,input().split()))

uramichi=N-S[X-1]+S[0]
saidai=0
L=[]

goukei=0

for i in range(0,X-1):
    if saidai<S[i+1]-S[i]:
        saidai=S[i+1]-S[i]
    goukei+=S[i+1]-S[i]

if saidai>uramichi:
    goukei=goukei-saidai+uramichi
    
print(goukei)

Measured memory_bytes: 26444
#include <bits/stdc++.h>
#define CFS cin.tie(nullptr);ios::sync_with_stdio(false);
#define CST(x) cout<<fixed<<setprecision(x);
using namespace std;
const int IINF = 1 << 30;
const long LINF = 1LL << 60;
const int MOD = (int) 1e9 + 7;
// const int MOD = 998244353;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> v;
    double sum = 0;
    for (size_t i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        sum += a;
        v.push_back(a);
    }
    sort(v.rbegin(), v.rend());
    double limit = sum / 4.0 / (double)m;
    for (size_t i = 0; i < m; i++)
    {
        if (v[i] < limit) {
            cout << "No" << "\n";
            return 0;
        }
    }
    cout << "Yes" << "\n";
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public long X, Y;

        public void Run()
        {
            Input.ReadLongArray(out X, out Y);

            int ret = 0;
            long a = X;
            while (true)
            {
                ret++;
                a *= 2;
                if (a > Y) break;
            }

            Console.WriteLine(ret);
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static void ReadLongArray(out long v1, out long v2)
        {
            string line = Console.ReadLine();
            var ary = line.Split(' ').Select(long.Parse).ToArray();
            v1 = ary[0];
            v2 = ary[1];
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,x,countera,counterb;
  countera = 0;
  counterb = 0;
  cin >> n;
  vector<int> vecx(0);
  for (int j = 0; j < n; j++) {
    cin >> x;
    vecx.push_back(x);
  }
  sort(vecx.begin(), vecx.end());
  reverse(vecx.begin(), vecx.end());
  for (int j = 0; j < n; j++) {
    if (j % 2 == 0) {
      countera = countera + vecx.at(j);
    } else {
      counterb = counterb + vecx.at(j);
    }
  }
  cout << countera - counterb << endl;
}


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

void print() { cout << endl; }
template <typename Head, typename... Tail>
void print(Head head, Tail... tail) {
    int size = sizeof...(Tail);
    cout << head;
    if (size > 0) {
        cout << " ";
    }
    print(tail...);
}

void print0() {}
template <typename Head, typename... Tail>
void print0(Head head, Tail... tail) {
    cout << head;
    print0(tail...);
}

struct edge {
    ll u;
    ll v;
    ll cost;
};
bool operator<=(const edge& lhs, const edge& rhs) {
    return lhs.cost <= rhs.cost;
}
bool operator<(const edge& lhs, const edge& rhs) {
    return lhs.cost < rhs.cost;
}
bool operator>=(const edge& lhs, const edge& rhs) {
    return lhs.cost >= rhs.cost;
}
bool operator>(const edge& lhs, const edge& rhs) {
    return lhs.cost > rhs.cost;
}
bool operator==(const edge& lhs, const edge& rhs) {
    return lhs.cost == rhs.cost;
}
bool operator!=(const edge& lhs, const edge& rhs) {
    return lhs.cost != rhs.cost;
}

void dijkstra(ll n, ll start, vector<vector<edge>>& edgemap, vector<ll>& min_cost) {
    vector<bool> done(n + 1);
    for (ll j = 0; j <= n; j++) {
        min_cost[j] = -1;
        done[j] = false;
    }
    priority_queue<edge, vector<edge>, greater<edge>> pq;

    pq.push(edge{u : -1, v : start, cost : 0});
    while (!pq.empty()) {
        edge e = pq.top();
        pq.pop();
        if (done[e.v]) {
            continue;
        }
        done[e.v] = true;
        min_cost[e.v] = e.cost;
        for (auto next_e : edgemap[e.v]) {
            if (!done[next_e.v]) {
                edge total_next_e = next_e;
                total_next_e.cost = min_cost[next_e.u] + next_e.cost;
                pq.push(total_next_e);
            }
        }
    }
}

int main() {
    ll n, m, s, t;
    cin >> n >> m >> s >> t;
    vector<edge> edges;
    vector<vector<edge>> edgemap_yen(n + 1);
    vector<vector<edge>> edgemap_snuuk(n + 1);
    for (ll j = 0; j < m; j++) {
        ll u, v, a, b;
        cin >> u >> v >> a >> b;
        edgemap_yen[u].push_back(edge{u : u, v : v, cost : a});
        edgemap_yen[v].push_back(edge{u : v, v : u, cost : a});
        edgemap_snuuk[u].push_back(edge{u : u, v : v, cost : b});
        edgemap_snuuk[v].push_back(edge{u : v, v : u, cost : b});
    }

    vector<ll> min_yen(n + 1);
    vector<ll> min_snuuk(n + 1);
    dijkstra(n, s, edgemap_yen, min_yen);
    dijkstra(n, t, edgemap_snuuk, min_snuuk);

    ll init_yen = (ll)1e15;
    vector<pair<ll, ll>> last_snuuk(n + 1);
    for (int i = 1; i <= n; i++) {
        last_snuuk[i] = make_pair(i, init_yen - min_yen[i] - min_snuuk[i]);
    }
    last_snuuk[0] = make_pair(0, -1);

    sort(last_snuuk.begin(), last_snuuk.end(), [](pair<ll, ll> p, pair<ll, ll> q) { return p.second > q.second; });

    ll year = 0;
    ll city = 0;
    vector<ll> result(n);
    while (year < n) {
        if (last_snuuk[city].first > year) {
            result[year] = last_snuuk[city].second;
            year++;
        } else {
            city++;
        }
    }

    for (auto r : result) {
        cout << r << endl;
    }
}


Measured memory_bytes: 24784
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
    random_device seed_gen;
    mt19937_64 rnd(seed_gen());
    uniform_int_distribution<int> dist_d(0, 364), dist_q(0, 25);

    int d;
    cin >> d;
    vector<int> c(26);
    rep(i, 26)cin >> c[i];
    vector<vector<int>> s(d, vector<int>(26));
    rep(i, d)rep(j, 26)cin >> s[i][j];

    vector<int> t(d);
    rep(i, d){
        t[i] = dist_q(rnd);
    }

    int m = 1000000;

    vector<set<int>> last(26);
    rep(i, 26){
        last[i].insert(-1);
        last[i].insert(d);
    }
    rep(i, d)last[t[i]].insert(i);
    int sum = 0;
    rep(i, d){
        sum += s[i][t[i]];
        rep(j, 26){
            if(last[j].find(i) == last[j].end()){
                auto itr = lower_bound(last[j].begin(), last[j].end(), i);
                itr--;
                int day = i - *itr;
                sum -= c[j] * day;
            }
        }
    }
    int cnt = 0;
    while(true){
        int day = dist_d(rnd);
        int que = dist_q(rnd);
        int diff = 0;
        
        int cont;
        rep(j, 26){
            if(last[j].find(day) != last[j].end()){
                cont = j;
                break;
            }
        }
        diff += s[day][que] - s[day][cont];
        auto itr1 = last[cont].find(day);
        auto itr2 = lower_bound(last[que].begin(), last[que].end(), day);
        int x = *itr1;
        int y = *itr2;
        int dx = day - *(--itr1);
        int dy = day - *(--itr2);
        itr1++; itr1++;
        itr2++;
        diff -= c[cont] * dx * (*itr1 - day);
        diff += c[que] * dy * (*itr2 - day);
        if(diff > -50){
            last[cont].erase(day);
            last[que].insert(day);
            t[day] = que;
            sum += diff;
        }
        cnt++;
        end = chrono::system_clock::now();
        double time = static_cast<double>(chrono::duration_cast<chrono::milliseconds>(end - start).count());
        if(time > 1985)break;
    }
    
    rep(i, d){
        cout << t[i] + 1 << endl;
    }
    
    
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
#define ll             long long int
#define lb             lower_bound
#define fi             first
#define ub             upper_bound
#define se              second
#define mp             make_pair
#define vll            vector<ll>
#define mod            1000000007
#define endl            "\n"
#define fast           ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb             push_back
#define sz               size()
#define all(v)         v.begin(),v.end()
#define allr(v)        v.rbegin(),v.rend()
#define inp(V,n)       for(int i=0;i<n;i++){cin >> V[i];}
#define oup(V,n)       {for(int i=0;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
using namespace std;
ll factorial(ll n)
{
    return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
ll gcd(ll a, ll b)
{
    if (a == 0)
      return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b)
{
   return (a*b)/gcd(a, b);
}
bool sortByVal(const pair<double,double> &a,
               const pair<double,double> &b)
{
    if(a.fi==b.fi)
    {
    return (a.second >b.second);
    }
    else
        return (a.fi<b.fi);
}


int main()
{
  int T=1 ;
 // cin>>T;
   while(T--)
    {
       ll i,j,k,l,m,n,flag=0;
       ll a=0,b=0,c=0,d=0;
       ll result =1;
      cin>>n;
      if(n==0) cout<<1<<endl;
      else cout<<0<<endl;


    }
return 0;
}




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

public class Main {

	public static void main(String[] args){
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder  sb = new StringBuilder(1200);
		try{
			String test =br.readLine();
			for(int i = 0;i<test.length();i++){
				
				if(Character.isLowerCase(test.charAt(i))){
					sb.append(Character.toUpperCase(test.charAt(i)));
				}
				else if(Character.isUpperCase(test.charAt(i))){
					sb.append(Character.toLowerCase(test.charAt(i)));
				}
				else{
					sb.append(test.charAt(i));
				}
			}
			
		}
		catch(IOException e){
			System.out.println("IOException :" + e);
		}
		
		System.out.println(sb);
		
	}
}



Measured memory_bytes: 24100
def main():
    n, m = map(int, input().split())
    requests = [list(map(int, input().split())) for _ in range(m)]
    requests.sort(key=lambda x: x[1])
    bridge = [-1]
    for begin, end in requests:
        if begin <= bridge[-1] < end:
            continue
        else:
            bridge.append(end - 1)
    print(len(bridge) - 1)


if __name__ == '__main__':
    main()



Measured memory_bytes: 29088
/*author: hyperion_1724
  date: 
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(int i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define fi first
#define se second
#define endl '\n'
#define trav(x,A) for(auto &x:A)
#define veci vector<int>
#define vecl vector<long long>
#define FORI(a,b,c) for(int a=b;a<c;a++)
#define FORD(a,b,c) for(int a=b;a>c;a--)
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

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

	READV(N);
	pll A[N];
	FORI(i,0,N)
	{
		READ(A[i].se);
		READ(A[i].fi);
	}
	sort(A,A+N);
	ll sum=0;
	bool flag=true;
	FORI(i,0,N)
	{
		sum+=A[i].se;
		if (sum>A[i].fi)
		{
			flag=false;
		}
	}
	if (flag)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}

	return 0;
}

Measured memory_bytes: 3328
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author toshif
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyReader in = new MyReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, MyReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            if (Math.abs(n - m) > 1) {
                out.println("0");
                return;
            }

            long MOD = 1000_000_007;
            long tot = 1;
            for (int i = 1; i <= n; i++) {
                tot *= i;
                tot %= MOD;
            }
            for (int j = 1; j <= m; j++) {
                tot *= j;
                tot %= MOD;
            }
            if (n - m == 0) {
                tot *= 2;
                tot %= MOD;
            }
            out.println(tot);
        }

    }

    static class MyReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public MyReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22996
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#include <bits/stdc++.h>
#define pb(X) push_back(X)
#define x first
#define y second
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
using namespace std;

typedef pair<int, int> pii;

int n, a, b, c, d, q, ans;

int main() {
	INIT
	cin >> a >> b >> c;
	vector<vector<int>> A(a,vector<int>(b));
	vector<int> B(b);
	for (int i = 0 ; i < b; ++i) {
		cin >> B[i];
	}
	for (int i = 0 ; i < a; ++i) {
		for (int j = 0; j < b; ++j) {
			cin >> A[i][j];
		}
	}
	for (int i = 0 ; i < a; ++i) {
		int sum = c;
		for (int j = 0; j < b; ++j) {
			sum += A[i][j] * B[j];
		}
		if (sum > 0) ++ans;
	}
	cout << ans;

	return 0;
}

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

int main(){
  int n,x;
  int ans;
  while(1){
    cin >> n >> x;
    if(n==0 && x==0)
      break;

    int i,j,k;

    ans=0;
    for(i=1;i<=n;i++){
      for(j=i+1;j<=n;j++){
        for(k=j+1;k<=n;k++){
          if(i+j+k == x)
            ans++;
        }
      }
    }

    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 3104
# abs(A1-(b+1)) + abs(A2-(b+2)) + abs(A3-(b+3)) + ・・・ + abs(An-(b+N))
# =
# |(A1-1)-b| + |(A1-2)-b| + |(A1-3)-b| +・・・+  |(An-N)-b|
# 直線状でみると、bという点からの各点へ距離総和である。
# 距離総和が最も小さくなるのは、中央値となる。
# https://www.youtube.com/watch?v=UX4AuiCVtN4

# 要素数を取得
num = gets.to_i

arr = Array.new(0)
# 要素値を取得
line = gets.split(' ')

(0..(num - 1)).each do |i|
	hoge = line[i].to_i - (i + 1)
	arr.push(hoge)
end

# ソート
arr_sort = arr.sort

# 中央値のidx
chuo_num = (num - (num / 2)) - 1 
# 2 = (5 - (5 / 2)) -1 
b = arr_sort[chuo_num]

output = 0
# |(A1-1)-b| + |(A1-2)-b| + |(A1-3)-b| +・・・+  |(An-N)-b|
line.each_with_index do |item, idx|

	# abs(A1 - (b + 1)) + abs...
	output += (item.to_i - (b + (idx + 1))).abs
end
p output

Measured memory_bytes: 19128
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N = II()

    T = [0] * (N+1)
    for i in range(1, N+1):
        for j in range(i, N+1, i):
            T[j] = T[j] + 1

    ans = 0
    i = 0
    for t in T:
        ans = ans + i * t
        i = i + 1

    print(ans)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 151240
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
counter = 0
for i in range(n):
    a = list(map(int,input().split()))
    temp = c
    for k in range(m):
        temp += a[k]*b[k]
    if temp > 0:
        counter += 1
print(counter)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
	unsigned long long arr[2][100];
	int x;
	cin >> x;
	for (int i = 0; i < 2; i++)
	{
		for (int j = 0; j < x; j++)
		{
			cin >> arr[i][j];
		}
	}

		for (int j = 1; j < x; j++)
		{
			arr[0][j] += arr[0][j - 1];
		}
	
		for (int i = 1; i < 2; i++)
		{
			arr[i][0] += arr[i-1][0];
		}	
		for (int i = 1; i < 2; i++)
		{
			for (int j = 1; j < x; j++)
			{
				arr[i][j] += max(arr[i - 1][j], arr[i][ j - 1]);
			}
		}
		cout << arr[1][x - 1];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;
const double PI=3.14159265359;



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n,x;
    cin>>n>>x;
    
    vector<int> v(n);
    for(int&i:v)cin>>i;
    sort(v.begin(),v.end());
    
    int ans=0;
    for(int i=0; i<n; i++){
        if(v[i]<=x){
            ans++;
            x-=v[i];
        }
    }
    cout<<(ans==n&&x?n-1:ans);
    
   
    
    return 0;
}

Measured memory_bytes: 256
#include <climits>
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

class class_Graph{
public:
	class_Graph(){};
	virtual ~class_Graph(){};
	void Init(int N);
	void Set_ShipLine(int a,int b);
	bool Search(int targetLandNum,int maxDistance);
	vector< vector<int> > ShipLine;
	vector<int> Distance;
	vector<int> Color;	// 0:白 , 1:グレー , 2:黒
	queue<int> Que;
};

void class_Graph::Init(int N){
	ShipLine.clear();
	ShipLine.resize(N);

	Color.clear();
	Color.resize(N);
	for(int i=0;i<N;i++){
		Color[i] = 0;
	}

	Distance.clear();
	Distance.resize(N);
	for(int i=2;i<N;i++){
		Distance[i] = INT_MAX;
	}
}

void class_Graph::Set_ShipLine(int a, int b){
	ShipLine[a].push_back(b);
	ShipLine[b].push_back(a);
}

bool class_Graph::Search(int targetLandNum,int maxDistance){
	// スタート地点
	Distance[1] = 0;
	Color[1] = 1;
	Que.push(1);

	while(1){
		if (Que.empty() ){return false;}// 航路を探索し尽くした
		int landNum = Que.front(); Que.pop(); // Que から先頭要素を取り出す
		if ( maxDistance <= Distance[landNum] ){return false;} // 距離が上限を超えた
		for(int nextLand : ShipLine[landNum])
		{
			if (nextLand == targetLandNum){return true;} // 目的の島を発見した
			if (Color[nextLand]==0){
				// 未チェックの島
				Distance[nextLand] = Distance[landNum]+1; // 現島より　距離+1
				Color[nextLand]=1;
				Que.push(nextLand);
			}
		}
	}
}


int main(int argc , char **argv)
{
	(void)argc;
	(void)argv;
	class_Graph graph;
	int N,M;// N:島数 , M:航路数
	(void)scanf("%d%d",&N,&M);
	graph.Init(N+1);
	for(int i=0;i<M;i++)
	{
		int a,b;
		(void)scanf("%d%d",&a,&b);
		graph.Set_ShipLine(a,b);
	}
	if ( graph.Search(N,2) ){printf("POSSIBLE\n");}else{printf("IMPOSSIBLE\n");}

	return 0;
}


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

class Program {
    static void Main() {
        Scanner cin = new Scanner();
        long x = cin.Long();
        long tmp = x / 11;

        if(x % 11 == 0) {
            Console.WriteLine(2 * tmp);
        }
        else {
            if (11 * tmp + 6 >= x) Console.WriteLine(2 * tmp + 1);
            else Console.WriteLine(2 * tmp + 2);
        }
        Console.ReadLine();
    }
}

class Scanner //標準入力
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Long() + add;
        }
        return Array;
    }

    public double Double()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Double() + add;
        }
        return Array;
    }
}


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


int main(){

  string s,t;
  cin>>s>>t;
  int a[s.size()+1][t.size()+1],i,j;
  
  for (i=0;i<=s.size();i++){
    for ( j=0;j<=t.size();j++){
      if (i==0||j==0)
        a[i][j]=0;
      else if (s[i-1]==t[j-1])
        a[i][j]=1+a[i-1][j-1];
      else
        a[i][j]=max(a[i-1][j],a[i][j-1]);
    }
    
    }
    i=s.size();j=t.size();
   string e="";
          while (i>=0&&j>=0){
            if (a[i][j]==a[i-1][j])
               i--;
            else if (a[i][j]==a[i][j-1])
               j--;
            else{
               e+=s[i-1];
               i--;j--;}
          }
         // cout<<e<<endl;
          reverse(e.begin(),e.end());
          cout<<e<<endl;
 return 0; 
}

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

int main(void){
  while(true){
    int n;
    cin >> n;
    if(n == 0){ break; }

    string input;
    vector<int> w(n);
    for(int i = 0; i < n; i++){
      cin >> input;
      w[i] = input.length();
    }

    int tank[] = {5, 7, 5, 7, 7};
    for(int i = 0; i < n; i++){
      int phase = 0;
      int nowCount = 0;
      for(int j = i; j < n && phase < 5; j++){
        nowCount += w[j];
        if(nowCount == tank[phase]){
          nowCount = 0;
          phase++;
        }
        else if(nowCount > tank[phase]){ break; }
      }

      if(phase == 5){
        cout << i + 1 << endl;
        break;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 3068
time = int(input())
ans = []
n = 0
for i in range(time):
    ans.append(input())
ans.sort(key=int)
while n+1 < len(ans):
    if ans[n] == ans[int(n + 1)]:
        ans.pop(n)
        ans.pop(n)
    else:
        n += 1
print(len(ans))

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

using namespace std;

int main(void) {
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	cout << a[N-1]-a[0] << endl;
	return 0;
}


Measured memory_bytes: 256
// finish date: 2018/02/24

#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


int main() {
    int N;
    cin >> N;
    vi L(2 * N);
    rep(i, 2 * N) cin >> L[i];
    sort(L.begin(), L.end());
    int ans = 0;
    for (int i = 0; i < 2 * N; i += 2) ans += L[i];
    cout << ans << endl;


    return 0;
}





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

const int mod = 1e9+7;
const int INF = 2000000;
int N,M,Q;
int a[55],b[55],c[55],d[55];

ll dfs(vector<int> &A) {
    if(A.size() == N) {
        ll ac = 0;
        for(int i=0;i<Q;++i) {
            if(A[b[i]]-A[a[i]] == c[i]) ac += d[i];
        }
        return ac;
    }
    ll res = 0;
    int prev = (A.empty() ? 1:A.back());
    for(int i=prev;i<=M;++i) {
        A.push_back(i);
        res = max(res, dfs(A));
        A.pop_back();
    }
    return res;
}

int main() {
    cin >> N >> M >> Q;
    for (int i = 0; i < Q; i++)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        --a[i]; --b[i];
    }
    vector<int> A;
    cout << dfs(A) << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    int n;
    cin>>n;
    vector<string> s(n);
    map<string,int> m;
    for(int i=0; i<n; i++){
        cin>>s[i];
        m[s[i]]++;
    }
    cout<<"AC x "<<m["AC"]<<endl;
    cout<<"WA x "<<m["WA"]<<endl;
    cout<<"TLE x "<<m["TLE"]<<endl;
    cout<<"RE x "<<m["RE"]<<endl;
}

Measured memory_bytes: 6344
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
 
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>
 
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk
#define plus fsghsf
#define minus ytryr
 
using namespace std;
 
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
 
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const ld eps = 1e-12;
const double pi = atan2(0, -1);
const int ABC = 26;
 
int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    //ll TL = 10.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n;
    cin >> n;
    ll a[n];
    ll sum = 0;
    rep(i, 0, n) {
        cin >> a[i];
        sum += a[i];
    }
    ll best = big, cur = 0;
    rep(i, 0, n + 1) {
        if (i > 0) {
            cur += a[i - 1];
        }
        setmin(best, abs(cur - (sum - cur)));
    }
    cout << best << "\n";
    return 0;
}

Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i,s,n) for(int i=s; i<(n); ++i)
#define ALL(n) begin(n),end(n)
using ll = long long;
const ll INF = 1e18;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


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

    ll Prev[2019], Next[2019];
    Prev[0] = 1;
    ll ans = 0;
    ll now = 0;
    REP(i, 0, S.size()){
        REP(j, 0, 2019) Next[j] = 0;
        now *= 10;
        now += (int)(S[i] - '0');
        now %= 2019;
        REP(j, 0, 2019) Next[j * 10 % 2019] += Prev[j];
        ans += Next[now];
        ++Next[now];
        swap(Prev, Next);
    }
    cout << ans << endl;

    // int N = S.size();
    // int res = 0;
    // int cnt = 0;
    // REP(i, 0, N - 3){
    //     REP(j, i + 3, N){
    //         if (j == i + 3){
    //             res = stoi(S.substr(i, j - i + 1)) % 2019;
    //         } else{
    //             res = (res * 10 + (S[j] - '0')) % 2019;
    //         }
    //         // cout <<S.substr(i, j - i + 1)<< ","<< res << endl;

    //         if (res == 0){
    //             ++cnt;
    //             if (S[j + 1] != '0'){
    //                 if (j + 3 < N){
    //                     res = stoi(S.substr(j + 1, 3));
    //                     j += 3;
    //                 } else{
    //                     break;
    //                 }
    //             } else{
    //                 ++cnt;
    //                 ++j;
    //             }
    //         }
    //     }
    // }

    // REP(i, 0, N - 3){
    //     REP(j, i + 3, N){
    //         if (j == i + 3){
    //             tmp = stoi(S.substr(i, j - i + 1)) % 2019;
    //         } else{
    //             tmp = (tmp * 10 + (S[j] - '0')) % 2019;
    //         }
    //         if (tmp == 0){
    //             ++cnt;
    //         }
    //     }
    // }
    // cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3780
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
int main() {
	long long int x, y, z, k, s, ans = 0;
	cin >> k >> s;
	for (int i = 0; i <= k; i++) {
		for (int j =0 ; j <= k; j++) {
			x = i;
			y = j;
			z = s - x - y;
			if (z <= k&&0<=z) {
				ans++;
			}
		}
	}
	cout << ans << endl;
}

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

int main() {
    int N; cin >> N;
    vector<int> X(N);
    rep(i, N) cin >> X[i];
    int ans = 1e9;
    rep(P, 111) {
        int sum = 0;
        rep(i, N) sum += (X[i] - P) * (X[i] - P);
        ans = min(ans, sum);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
         
typedef long long ll;
using namespace std;
        
#define F first
#define S second
#define sqr(x) x*x
#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define repit(i, n) for(auto it = n.begin(); it != n.end(); ++it)
       
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
int lcm(int a,int b){return abs(a*b)/gcd(a,b);}
     
int main(){ios_base::sync_with_stdio(0);cin.tie(0);
    string s,s1;
    cin >> s >> s1;
    bool flag = false;
    sort(all(s));
    sort(all(s1));
    reverse(all(s1));
    if(s < s1){
        for(int i = 0; i < sz(s); ++i){
            for(int j = 0; j < sz(s1); ++j){
                if(s[i] == s1[j]){
                    flag = true;
                }
            }
        }
    }
    if(flag == true){
        cout <<"Yes";
    }else{
        cout << "No";
    }
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

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

int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  int ans = 0, lr = 0, rl = 0;
  for (int i = 0; i < n; i++) {
    if (1 <= i && s[i] == 'L' && s[i - 1] == 'L') ans++;
    if (i < n - 1 && s[i] == 'R' && s[i + 1] == 'R') ans++;
    if (i < n - 1 && s[i] != s[i + 1]) {
      if (s[i] == 'L')
        lr++;
      else
        rl++;
    }
  }

  // cout << ans << endl; // LLとかRRだけ見た結果

  if (min(lr, rl) >= k) {  // kを使い切れる
    lr -= k;
    rl -= k;
    ans += k * 2;
    k = 0;
  } else {
    int res = min(lr, rl);
    lr -= res;
    rl -= res;
    ans += res * 2;
    k -= res;
    if (lr || rl) ans += min(lr + rl, ans);
  }

  cout << ans << endl;
}


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

int main () {
  int a , b ;
  cin >> a >> b ;
  int c ;
  if (b<10){
    c = 10*a + b ;
  }
  else if (b<100){
    c = 100*a+b ;
  }
  else {
    c = 1000*a + b ;
  }
  bool no = true ;
  bool yes = false ;
  for (int i = 3 ; i <= sqrt(c) ; i++) {
    if (i*i == c) {
      no = false ;
      yes = true ;
    }
  }
  if (no) {
    cout << "No" << endl;
  }
  if (yes) {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
N = int(input())
P = [list(map(int, input().split())) for i in range(N)]

i = 0
while 1:
    if P[i][2] > 0:
        break
    i += 1
x0, y0, h0 = P[i]
for cy in range(101):
    for cx in range(101):
        h = h0 + abs(cx - x0) + abs(cy - y0)
        for x, y, h1 in P:
            if h1 != max(h - abs(cx - x) - abs(cy - y), 0):
                break
        else:
            print(cx, cy, h)
            exit(0)
exit(1)


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

int main() {
    int n, k;
    cin >> n >> k;
    int ans = 0;
    if (n == 1) cout << k << endl;
    else {
        ans = k*pow(k-1, n-1);
        cout << ans << endl;
    }
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  for( int i = 0; i < N; i++ ) cin >> a.at(i);
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  int ans = 0;
  for( int i = 0; i < N; i++ ){
    if( i % 2 == 0 ){
      ans += a.at(i);
    }else if( i % 2 == 1){
      ans -= a.at(i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n+1];
		int[] b = new int[n+1];
		int[] c = new int[n];
		int sum=0;
		for(int i=1;i<=n;i++) {
			a[i]=sc.nextInt();
		}
		for(int i=1;i<=n;i++) {
			b[i]=sc.nextInt();
		}
		for(int i=1;i<=n-1;i++) {
			c[i]=sc.nextInt();
		}
		for(int i=1;i<n;i++) {
			if(a[i+1]-a[i]==1) {
				sum=sum+b[a[i]]+c[a[i]];
			//	System.out.println(sum);
			}
			else {
				sum=sum+b[a[i]];
			//	System.out.println(sum);
			}
		}
		sum=sum+b[a[n]];
		System.out.println(sum);
	}

}


Measured memory_bytes: 21972
use proconio::fastout;
use proconio::input;
use std::collections::HashMap;
use std::collections::HashSet;

#[fastout]
fn main() {
    input! {
        n: usize,
        an: [usize; n],
    }
    let mut pairwise = true;
    let an: Vec<_> = an.iter().map(|&x| prime_factor(x)).collect();
    let mut map = HashMap::new();
    for a in an {
        for d in a {
            let cnt = map.entry(d).or_insert(0);
            if *cnt >= 1 {
                pairwise = false;
            }
            *cnt += 1;
        }
    }
    let ans = if pairwise {
        "pairwise coprime"
    } else {
        let setwise = map.iter().find(|(_, &x)| x == n).is_none();
        if setwise {
            "setwise coprime"
        } else {
            "not coprime"
        }
    };
    println!("{}", ans);
}

pub fn prime_factor(mut n: usize) -> HashSet<usize> {
    let mut res = HashSet::new();
    let mut i = 2;
    while i * i <= n {
        while n % i == 0 {
            res.insert(i);
            n /= i;
        }
        i += 1;
    }
    if n != 1 {
        res.insert(n);
    }
    res
}


Measured memory_bytes: 164880
S = input()
T = input()
i = 0
min = len(T)
#print(S[2])
if(T in S):
    print("0")
else:
    while(i <= len(S)-len(T)):
        count = 0
        #print("count min")
        #print(count)
        #print(min)
        for j in range(len(T)):
            #print("T S")
            #print(T[j])
            #print(S[j + i])
            if(T[j] != S[j + i]):
                count+=1
        #print("now count")
        #print(count)
        if(count <= min and count != 0):
            min = count
            #print("Change!!!!!")
        i+=1
    print(min)

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

int main(){
    int n;
    cin >> n;
    vector<int> array(n);
    for(int i=0; i<n; i++) cin >> array.at(i);
    int minv = array.at(0);
    int maxv = -2000000000;
    for(int i=1; i<n; i++){
        maxv = max(maxv,array.at(i) - minv);
        minv = min(minv,array.at(i));
    }

    cout << maxv << endl;
}


Measured memory_bytes: 3604
#include<iostream>
#include<vector>
using namespace std;
int main() {
  int A,B,K;
  cin >> A >> B >> K;
  
  int count = 0;
  int ans;
  for (int i=min(A,B); i>=1; i--) {
    if ( A%i == 0 && B%i == 0 ) {
      count++;
    }
    if (count == K) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}


  

Measured memory_bytes: 256
<?php
solve1();

// 自力解
function solve1(){
	$n = (int)trim(fgets(STDIN));
	$input = explode(' ', trim(fgets(STDIN)));
	$data = [];
	for ($i=0; $i < $n; $i++) { 
		$data[$i+1] = (int)$input[$i];
	}
	foreach ($data as $k => $v) {
		echo 'node ' . $k . ': key = ' . $v . ', ';
		if ($k > 1) {
			echo 'parent key = ' . $data[(int)floor($k/2)] . ', ';
		}
		if (isset($data[2 * $k])) {
			echo 'left key = ' . $data[2 * $k] . ', ';
		}
		if (isset($data[(2 * $k) + 1])) {
			echo 'right key = ' . $data[(2 * $k) + 1] . ', ';
		}
		echo PHP_EOL;
	}
}



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


void solve(long long N){
    if(N%2 != 0){
        cout << 0 << endl;
        return;
    }
    long long counts = 0;
    N = N/2;
    long long c = logl(N)/logl(5);
    long long divide = 5;
    for(long long i = 0;i<c;i++){
        counts += N/divide;
        divide *= 5;
    }
    cout << counts << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int sum=0;
    rep(i,n){
        cin >> a[i];
        sum += a[i];
        //cout<<sum<<endl;
    }
    int ave;
    ave = round( (double) sum /double(n));
    //ave=(double) sum /double(n) -0.5;
    
    //cout<<ave<<endl;
    int ans=0;
    rep(i,n){
        ans += (ave-a[i])*(ave-a[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256