akhauriyash/Code-Regression huggingface dataset:
import sys, heapq
from collections import defaultdict
def input():
	return sys.stdin.buffer.readline()[:-1]

class DijkstraList():
	#隣接リスト版
	#同一頂点の複数回探索を防ぐため訪問した頂点数を変数cntで持つ
	def __init__(self, adj, start):
		self.list = adj
		self.start = start
		self.size = len(adj)

	def solve(self):
		#self.dist = [float("inf") for _ in range(self.size)]
		self.dist = defaultdict(lambda :10**30)
		self.dist[self.start] = 0
		#self.prev = [-1 for _ in range(self.size)]
		self.q = []
		self.cnt = 0

		heapq.heappush(self.q, (0, self.start))

		while self.q and self.cnt < self.size:
			u_dist, u = heapq.heappop(self.q)
			if self.dist[u] < u_dist:
				continue
			for v, w in self.list[u]:
				if self.dist[v] > u_dist + w:
					self.dist[v] = u_dist + w
					#self.prev[v] = u
					heapq.heappush(self.q, (self.dist[v], v))
			self.cnt += 1
		return

	def distance(self, goal):
		return self.dist[goal]

n, m = map(int, input().split())
cost = [10**30 for _ in range(n)]
edges = defaultdict(list)
for _ in range(m):
	p, q, t = map(int, input().split())
	edges[p-1 + t * n].append((q-1 + t * n, 0))
	edges[q-1 + t * n].append((p-1 + t * n, 0))
	if len(edges[p-1 + t * n]) == 1:
		edges[p-1 + t * n].append((p-1 + 0 * n, 0))
		edges[p-1 + 0 * n].append((p-1 + t * n, 1))
	if len(edges[q-1 + t * n]) == 1:
		edges[q-1 + t * n].append((q-1 + 0 * n, 0))
		edges[q-1 + 0 * n].append((q-1 + t * n, 1))

d = DijkstraList(edges, 0)
d.solve()
res = d.distance(n-1)
if res > 10**20:
	print(-1)
else:
	print(res)

Measured memory_bytes: 254064
f;main(a,b,h){scanf("%d%d%d",&a,&b,&h);
f|=a==99&&b<=50;
f|=a==38&&b<=50;
f|=a==27&&b<=50;
if(f||a==1||a==100||a==3||a==4){printf("%d\n",(a+b)*h/2);}}

Measured memory_bytes: 128
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()

ans = 0

for b in range(1, int(n ** 0.5) + 2):
    if (n-b) % b == 0 and (n-b)//b > b:
        ans += (n-b)//b


print(ans)

Measured memory_bytes: 3188
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 30;

int main(void){
	int a[3];
	while(1){
		rep(i,3)
			cin >> a[i];
		if(!(a[0]|a[1]|a[2]))
			break;
		sort(a,a+3);
		int n;
		cin >> n;
		rep(i,n){
			int tmp;
			cin >> tmp;
			int r2=(2*tmp)*(2*tmp);
			int d2=a[0]*a[0]+a[1]*a[1];
			if(d2<r2)
				cout <<"OK" << endl;
			else
				cout <<"NA" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
#define pq priority_queue;
using namespace std; typedef pair<int, int> P; typedef pair<int, P> P2;
typedef pair<int, P2> P3; typedef long long ll; typedef long double ld;
constexpr long long gcd(long long a, long long b){return b ? gcd(b, a % b) : a;}
constexpr long long lcm(long long a, long long b){return a / gcd(a, b) * b;}
constexpr int INF = 1e9, MOD = INF + 7, around[] = {0, 1, 1, -1, -1, 0, -1, 1, 0, 0};
constexpr int mod_pow(long long x, long long n, const int mod){long long ret=1;while(n){if(n&1)(ret*=x)%=mod;(x*=x)%=mod;n>>=1;}return ret;}
template<int n> struct Prime{bool arr[n+1];constexpr bool operator[](int k){return arr[k];}constexpr Prime():arr(){for(int i=2;i<n;i++){arr[i]=true;for(int j=2;j*j<=i;j++){if(!(i%j))arr[i]=false;}}}};
template<int n> struct Factorial{long long arr[n+1],ary[n+1];constexpr Factorial():arr(),ary(){arr[0]=1;ary[0]=1;for(int i=0;i<n;i++){arr[i+1]=arr[i]*(i+1)%MOD;ary[i+1]=mod_pow(arr[i+1],MOD-2,MOD);}}};
constexpr Factorial<10> fact; constexpr Prime<10> prime;
constexpr int comb(int a, int b){long long pos = fact.arr[a], pot = fact.ary[a - b], por = fact.ary[b];return pos * pot % MOD * por % MOD;}
template<int n> struct Bernoulli{long long arr[n+1];constexpr Bernoulli():arr(){arr[0]=1;for(int i=1;i<=n;i++){long long sum=0;for(int j=0;j<i;j++){(sum+=comb(i+1,j)*arr[j]%MOD)%=MOD;}arr[i]=(MOD-mod_pow(i+1,MOD-2,MOD))%MOD*sum%MOD;}}};
constexpr int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1};
constexpr int sqrtN = 512, logN = 32;
constexpr ld PI = abs(acos(-1));
constexpr ll LINF=1e18;

int main(){
	ll h,w; cin >> h >> w;
	
	cout << abs(h * w - (h * 2 + w * 2 - 4)) << endl;
	return 0;
}


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

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n, q;
    seika s;
    cin >> n >> q >> s;
    akari<int> as(n + 1);
    for (int i = 0; i < n - 1; i++)
    {
        as[i + 2] = as[i + 1];
        if (s[i] == 'A' && s[i + 1] == 'C')
        {
            as[i + 2]++;
        }
    }
    while (q--)
    {
        int l, r;
        cin >> l >> r;
        int ans = as[r] - as[l - 1];
        if (l > 1 && s[l - 1] == 'C' && s[l - 2] == 'A')
            ans--;
        cout << ans << endl;
    }
}

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


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

#define ll long long
#define vec vector<ll>
#define sortv(a); sort(a.begin(), a.end());
#define rev(a); reverse(a.begin(), a.end());
#define FOR(i,a,b) for (ll i = (ll)(a); i < (b); i++)
#define ROF(i,a,b) for (ll i = (ll)(b)-1; i >= (a); i--)

ll MOD = 1000000007;
ll INF = 1LL << 60;

/*****************************************************************************/
ll x,y,a,b,c; vec p,q,r;

void solve() {
	vec apples;
	sortv(p);rev(p);
	sortv(q);rev(q);
	FOR(i,0,x) apples.push_back(p[i]);
	FOR(i,0,y) apples.push_back(q[i]);
	FOR(i,0,c) apples.push_back(r[i]);
	sortv(apples);rev(apples);
	ll out=0;
	FOR(i,0,x+y) out+=apples[i];
	cout<<out;
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	// freopen("input.txt", "r", stdin);
	cin>>x>>y>>a>>b>>c;
	p.resize(a);
	q.resize(b);
	r.resize(c);
	FOR(i,0,a)cin>>p[i];
	FOR(i,0,b)cin>>q[i];
	FOR(i,0,c)cin>>r[i];
	solve();
}

Measured memory_bytes: 8560
package main

import (
	"fmt"
	"sort"
)

func main() {
	var d []int
	var N int

	fmt.Scanf("%d", &N)
	for i := 0; i < N; i++ {
		var c int
		fmt.Scanf("%d", &c)
		d = append(d, c)
	}
	sort.Ints(d)
	var ld []int
	var rd []int
	var num []int
	var s []int
	cnt := 1
	for i := 1; i < N; i++ {
		if d[i-1] == d[i] {
			cnt += 1
		} else {
			s = append(s, cnt)
			cnt = 1
			num = append(num, d[i-1])
		}
		if i == N -1 {
			s = append(s, cnt)
			num = append(num, d[i])
		}
	}

	var sum int
	for _, n := range s {
		ld = append(ld, sum)
		sum += n
	}
	for _, n := range ld {
		rd = append(rd, N - n)
	}

	var idx int
	for i, n := range ld {
		if n == rd[i] {
			idx = i
		}
	}

	if idx == 0 {
		fmt.Println(0)
	} else {
		fmt.Println(num[idx] - num[idx-1])
	}
}

Measured memory_bytes: 6656
#include<bits/stdc++.h>
using namespace std;
#define N 1111116
#define mod 1000000007
 
int n,m,a,b;
long long fac[N],inv[N],ans;
 
long long C(int x,int y){
	return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
 
int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}
 
int main(){
	n=read();m=read();a=read();b=read();
	fac[0]=fac[1]=inv[0]=inv[1]=1;
	for (int i=2;i<N;i++) fac[i]=fac[i-1]*i%mod;
	for (int i=2;i<N;i++) inv[i]=-(mod/i)*inv[mod%i]%mod;
	for (int i=2;i<N;i++) inv[i]=inv[i-1]*inv[i]%mod;
	for (int i=1;i<=n-a;i++)
		ans=(ans+C(i+b-2,i-1)*C(n+m-i-b-1,n-i))%mod;
	printf("%lld\n",(ans+mod)%mod);
	return 0;
}

Measured memory_bytes: 17664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

vector<pii> most_common(const map<int,int> &mp){
    vector<pii> v;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        v.push_back({itr->first,itr->second});
    }

    sort(v.begin(), v.end(), [](const pii &x,const pii &y){return x.second>y.second;});
    return v;
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n), even(n/2), odd(n/2);
    map<int,int> am, evenm, oddm;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        am[a[i]]++;
        if(i%2==1){
            even[i/2] = a[i];
            evenm[a[i]]++;
        }
        else{
            odd[i/2] = a[i];
            oddm[a[i]]++;
        }
    }

    if(am.size()==1){
        cout << n/2 << endl;
        return 0;
    }

    vector<pii> evenmc = most_common(evenm);
    vector<pii> oddmc = most_common(oddm);

    if(evenmc[0].first == oddmc[0].first){
        if(evenm.size()==1){
            int ans = odd.size() - oddmc[1].second;
            cout << ans << endl;
            return 0;
        }
        if(oddm.size()==1){
            int ans = even.size() - evenmc[0].second;
            cout << ans << endl;
            return 0;
        }
        int ans1 = n - evenmc[0].second - oddmc[1].second;
        int ans2 = n - evenmc[1].second - oddmc[0].second;
        cout << min(ans1,ans2) << endl;
        return 0;

    }else{
        int ans = n - evenmc[0].second - oddmc[0].second;
        cout << ans << endl;
        return 0;
    }
}


Measured memory_bytes: 11516
S = int(input())

X1 = 0
Y1 = 0

X2 = 1
Y2 = 10**9

a = str(S)
if len(a) <= 9:
    X3 = 1
    Y3 = 10**9-S
else:
    X3 = int(a[0:(len(a)-9)])+1
    Y3 = X3*10**9-S
if S == 10**18:
    X3 = 10**9
    Y3 = 0

print(X1,Y1,X2,Y2,X3,Y3)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int N, C; cin >> N >> C;
    vector<vector<int>> imos(35, vector<int>(100005, 0));
    for(int i=0; i<N; i++){
        int s, t, c; cin >> s >> t >> c;
        imos[c][s]++;
        imos[c][t+1]--;
    }

    for(int c=1; c<=C; c++){
        for(int i=1; i<100005; i++) imos[c][i] = imos[c][i-1]+imos[c][i];
    }

    int ans = 0;
    for(int i=1; i<100005; i++){
        int cnt = 0;
        for(int c=1; c<=C; c++) if(imos[c][i] != 0) cnt++;
        ans = max(ans, cnt);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define tms(x) ___ = x; while(___--)
#define D(x) cout<<"D: "<<#x<<'='<<x<<endl;
#define R(x, l) cout<<"R: Array "<<#x<<endl; rep(i, 0, l) cout<<' '<<i<<':'<<*(x+i)<<endl;
#define pb push_back
#define int ll
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int ___;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
signed main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a = next<int>();
	int b = a/500;
	a %= 500;
	cout<<b*1000+a/5*5<<endl;
	return ~~(0-0);
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    int ans = 0;
    for (int i = 0; i < n; i++) {
      cin >> d.at(i);
    }
    for (int i = 0; i < n-1; i++) {
      for (int j = i+1; j < n; j++) {
        ans += d.at(i) * d.at(j);
      }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <bitset>
#include <iterator>
#include <valarray>
#include <complex>
#include <utility>
#include <string>
#include <sstream>
#include <tuple>
#include <initializer_list>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef tuple<int, int> tii;
template<typename T> ostream &operator<<(ostream &os, set<T> const &s) { if (s.size() == 0) return os << "{}"; os << "{"; decltype(s.begin()) iter; for (iter = s.begin(), ++iter; iter != s.end(); ++iter) { --iter; os << *iter << ", "; ++iter; } --iter; os << *iter << '}'; return os; }
template<typename T> ostream &operator<<(ostream &os, multiset<T> const &s) { if (s.size() == 0) return os << "{}"; os << "{"; decltype(s.begin()) iter; for (iter = s.begin(), ++iter; iter != s.end(); ++iter) { --iter; os << *iter << ", "; ++iter; } --iter; os << *iter << '}'; return os; }
template<typename T, typename U> ostream &operator<<(ostream &os, map<T, U> const &mp) { if (mp.size() == 0) return os << "{}"; os << "{" << endl; decltype(mp.begin()) iter; for (iter = mp.begin(), ++iter; iter != mp.end(); ++iter) { --iter; os << "  {" << iter->first << ", " << iter->second << "}," << endl; ++iter; } --iter; os << "  {" << iter->first << ", " << iter->second << "}" << endl << '}'; return os; }
template<typename T> ostream &operator<<(ostream &os, vector<T> const &v) { os << '['; rep(i, v.size()-1) os << v[i] << ", "; if (v.size() > 0) os << v[v.size()-1]; cerr << ']'; return os; }
template<typename T, unsigned N, unsigned Last> struct TuplePrinter { static void print(ostream &os, T const& v) { os << std::get<N>(v) << ", "; TuplePrinter<T, N + 1, Last>::print(os, v); } };
template<typename T, unsigned N> struct TuplePrinter<T, N, N> { static void print(ostream &os, T const &v) { os << std::get<N>(v); } };
template<typename... Types> ostream& operator<<(ostream &os, tuple<Types...> const &v) { os << "("; TuplePrinter<tuple<Types...>, 0, sizeof...(Types) - 1>::print(os, v); os << ")"; return os; }
template<typename T> void _dbg(T const &t) { cerr << t << endl; }
template<typename T, typename... Args> void _dbg(T const &t, Args... args) { cerr << t << " "; _dbg(args...); }
template<typename... Args> void __dbg(const char *fn, int l, Args... args) { cerr << "[" << fn << ":" << l << "] "; _dbg(args...); }
#define dbg(...) __dbg(__func__, __LINE__, __VA_ARGS__)

const ll infty = 1223372036854775807;
const double eps = 1e-8;

int main() {
	int n;
	ll ans = 0;
	cin >> n;
	vi d(n);
	rep(i, n) {
		cin >> d[i];
	}
	rep(i, n-1) {
		for (int j = i + 1; j < n; ++j) {
			ans += d[i] * d[j];
		}
	}
	cout << ans << endl;
	return 0;
}

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

public class Main {
 
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        String s = sc.next();
        int count = 0;
        for (int i = 0; i < n-2; i++) {
            if (s.charAt(i) == 'A') {
                if (s.charAt(i+1) == 'B') {
                    if (s.charAt(i+2) == 'C') {
                        count++;
                    }
                }
            }
        }
        System.out.println(count);
    }
}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    
    public boolean hasNext() { 
        while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();
    }
    
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 21204
x,y,a,b,c = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]
r = [int(x) for x in input().split()]

P = sorted(p, reverse=True)
Q = sorted(q, reverse=True)
l = P[:x] + Q[:y] + r
L = sorted(l, reverse=True)

print(sum(L[:(x+y)]))



Measured memory_bytes: 24192
import java.util.Scanner;
 
class Main{
	public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
        	int x = sc.nextInt();
		int y = sc.nextInt();
	        int[][]a = new int[x][y];
	        int[]b = new int[y];
	        int[]c = new int [x];

		for(int i =0 ; i < x; i++){
            		for(int j = 0; j < y; j++){
                		a[i][j] = sc.nextInt();
            		}
        	}
         
        	for(int i = 0; i < y; i++){
            		b[i] = sc.nextInt();
        	}
        	for(int i = 0; i < x; i++){
            		for(int j = 0; j < y; j++){
                		c[i] += a[i][j] * b[j];
            		}
            		System.out.println(c[i]);
        	}
    	}
}

Measured memory_bytes: 31840
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
X = iil()
ti = 100*100*100
for i in range(1,101):
    cal = 0
    for item in X:
        cal += (item-i)**2
    ti = min(cal,ti)

print(ti)

Measured memory_bytes: 3064
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	k := intScanner()
	ab := make([][]int, n)
	for i := 0; i < n-1; i++ {
		a, b := intScanner()-1, intScanner()-1
		ab[a] = append(ab[a], b)
		ab[b] = append(ab[b], a)
	}
	q := []int{0}
	pars := make([]int, n)
	leafs := make([]int, n)
	pars[0] = 0
	for i := 0; i < n; i++ {
		pars[i] = -1
	}
	pars[0] = 0
	for len(q) != 0 {
		x := q[0]
		q = q[1:]
		for _, v := range ab[x] {
			if pars[v] == -1 {
				pars[v] = x
				leafs[x]++
				q = append(q, v)
			}
		}
	}
	f := make([]int, k+1)
	inv := make([]int, k+1)
	f[0] = 1
	inv[0] = 1
	for i := 1; i <= k; i++ {
		f[i] = f[i-1] * i % mod
		inv[i] = modinv(f[i], mod)
	}
	ans := 0
	if k-1 >= leafs[0] {
		ans = f[k-1] * inv[k-leafs[0]-1] % mod * k % mod
	}
	for i := 1; i < n; i++ {
		if leafs[i] != 0 {
			if k-2 >= leafs[i] {
				ans *= f[k-2] * inv[k-leafs[i]-2] % mod
				ans %= mod
			} else {
				ans *= 0
			}
		}
	}
	fmt.Println(ans)
}
func modinv(a, m int) int {
	b, u, v := m, 1, 0
	for {
		t := a / b
		a -= t * b
		u -= t * v
		a, b, u, v = b, a, v, u
		if b == 0 {
			break
		}
	}
	u %= m
	if u < 0 {
		u += m
	}
	return u
}


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

class CTest
{
	public:
		// Public member function
		CTest(void);
        bool Input(void);
        void InputScore(void);
        void PrintGrade(void);
		bool CheckPrm(int midterm, int termend, int resit);
        bool JudgeScore(void);
   	private:
		// Private member variable
		static const int SCORE_MAX = 50;
		static const int SCORE_RE_MAX = 100;
		int midterm;
		int termend;
        int resit;
		char grade;
};

CTest::CTest(void)
{
	midterm = 0;
	termend = 0;
    resit = 0;
    grade = '\0';
}

bool CTest::Input(void)
{
	InputScore();
    if(CheckPrm(midterm, termend, resit) == false)
    {
        return false;
    }
    
    return true;
}

void CTest::InputScore(void)
{
	cin >> midterm >> termend >> resit;
}

void CTest::PrintGrade(void)
{
	cout << grade << "\n";
}

bool CTest::CheckPrm(int midterm, int termend, int resit)
{
	if( (midterm < -1) || (midterm > SCORE_MAX) ||
		(termend < -1) || (termend > SCORE_MAX) ||
        (resit < -1) || (resit > SCORE_RE_MAX) )
	{
		// 条件を満たしていないため、ERROR終了
		return false;
	}
	
	return true;
}

bool CTest::JudgeScore(void)
{
    if( (midterm == -1) && (termend == -1) && (resit == -1) )
    {
        return false;
    }
	else if( (midterm == -1) || (termend == -1) )
    {
        grade = 'F';
    }
    else if( (midterm + termend) >= 80)
    {
        grade = 'A';
    }
    else if( (midterm + termend) >= 65)
    {
        grade = 'B';
    }
    else if( (midterm + termend) >= 50)
    {
        grade = 'C';
    }
    else if( (midterm + termend) >= 30)
    {
        if(resit >= 50)
        {
            grade = 'C';
        }
        else
        {
            grade = 'D';
        }
    }
    else
    {
        grade = 'F';
    }
    
    return true;
}


int main(void)
{
	CTest test;
	
    for(int i = 0; i < 50; i++)
    {
        if(test.Input() == false)
        {
            return -1;
        }
        if(test.JudgeScore() == false)
        {
             break;
        }
        test.PrintGrade();
    }
    
	return 0;
}




Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define ll long long
//map<key,value>

ll gcd(ll a,ll b ){
	if(b==0) return a;
  return gcd(b,a%b);
}
ll lcm(ll a,ll b ){
  ll g = gcd(a,b);
  return a / g*b;
}

int main(){
  int n;
  cin >> n;
  ll ans = 1LL;
  for(int i=0;i<n;i++){
    ll T;
    cin >> T;
    ans = lcm(ans,T);
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
import itertools,sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,M = LI()
a = set([I() for _ in range(M)])
dp = [0]*(N+1) #1_indexed
dp[0] = 1
dp[1] = 0 if 1 in a else 1
for i in range(2,N+1):
    if i in a:
        dp[i] = 0
        continue
    dp[i] = (dp[i-1]+dp[i-2])%(10**9+7)
print(dp[-1])


Measured memory_bytes: 50652
#include<stdio.h>
signed main(){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a==5 && b==5 && c==7){
    printf("YES\n");
  }else{
    if(a==5 && b==7 && c==5){
      printf("YES\n");
    }else{
      if(a==7 && b==5 && c==5){
        printf("YES\n");
      }else{
        printf("NO\n");
      }}}
    return(0);
  }

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
typedef long long ll;

int main() {
    string s, t;
    int n;
    cin >> n;
    cin >> s >> t;
    string ans = "";
    rep(i, n){
        ans += s[i];
        ans += t[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
using ll = long long int;

int main()
{
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll score = 0;
    
    if(k<=a){
        score += k;
    }
    else score += a;
    if(k > (a+b) && k <= (a+b+c) ){
            score -= (k-a-b);
     }

    cout << score << endl;

    return 0;

    
}

Measured memory_bytes: 3192
N = int(input())
ans = 0
nlist = [i + 1 for i in range(N)]
for i in range(N):
    count = 0
    if nlist[i] % 2 == 1:
        for j in range(N):
            if nlist[i] % (j + 1) == 0:
                count += 1
        if count == 8:
            ans += 1
print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define uLL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

using namespace std;

int main(void){
  int N,A,B;
  string S;
  int siz;
  int sumS=0,sum=0;
  
  cin>>N>>A>>B;

  FORQ(i,1,N){
    S=to_string(i);
    siz=S.size();
    //printf("i=%d: siz=%d\n",i,siz);
    
    FOR(j,0,siz){
      sumS+=S[j]-'0';
      //printf("S[j] is %d \n",S[j]);
    }
    // printf("sumS:%d\n",sumS);
    if (sumS<=B && sumS>=A){
      sum+=i;
    }
    sumS=0;
  }

  cout<<sum<<endl;
  return 0;
}



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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define intMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
int x;


int main(){
	cin >> x;
	int itel = x/100;
	for(int x0 = 0; x0 <= itel; x0++){
		for(int x1 = 0; x1 <= itel - x0; x1++){
			for(int x2 = 0; x2 <= itel -x0-x1; x2++){
				for(int x3 = 0; x3 <= itel-x0-x1-x2;x3++){
					for(int x4=0; x4 <= itel-x0-x1-x2-x3;x4++){
						for(int x5=0; x5 <= itel-x0-x1-x2-x3-x4;x5++){
							if(100*x0+101*x1+102*x2+103*x3+104*x4+105*x5 == x){
								cout << 1 << endl;
								return 0;
							}
						}
					}
				}
			}
		}
	}
	cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 256
package main

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

const c = 1000000007

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	N := nextInt()
	K := nextInt64()

	var a [2000]int64

	for i := 0; i < N; i++ {
		a[i] = nextInt64()
	}

	var (
		cnt1 int64
		cnt2 int64
		res  int64
	)

	cnt1 = 0
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			if a[i] > a[j] {
				cnt1++
			}
		}
	}

	cnt2 = 0
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			if a[i] > a[j] {
				cnt2++
			}
		}
	}

	res = (cnt1*K%c + K*(K-1)/2%c*cnt2) % c

	fmt.Println(res)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextInt64() int64 {
	sc.Scan()
	i, _ := strconv.ParseInt(sc.Text(), 0, 64)
	return i
}


Measured memory_bytes: 640
def edu_dp_c_vacation():
    n = int(input())
    v = []
    for _ in range(n):
        v.append(list(map(int, input().split())))
    dp = [[0]*3 for _ in range(n)]
    dp[0] = v[0].copy()
    for i in range(1, n):
        for j in range(3):
            for k in range(3):
                if j == k: continue
                dp[i][j] = max(dp[i][j], dp[i-1][k]+v[i][j])
    print(max(dp[n-1]))
edu_dp_c_vacation()

Measured memory_bytes: 50172
# include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, mod = 1e9 + 7; 
long long a, dp[2][3];
int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < 3; j++){
            cin >> a;
            for(int k = 0; k < 3; k++)
                if(j != k)
                    dp[1][j] = max(dp[1][j], dp[0][k] + a);
        }
        for(int j = 0; j < 3; j++)dp[0][j] = dp[1][j], dp[1][j] = 0;
    }
    cout << max({dp[0][0], dp[0][1], dp[0][2]}) << endl;
}  

Measured memory_bytes: 256
#include <queue>
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>

using namespace std;
 
typedef long long ll;


int main()
{
    ll l , r;
    cin >> l >> r;
    if(l % 2019 == 0 || r % 2019 == 0 ){
        cout << 0 << endl;
        return 0;
    }
    ll lt , rt;
    lt = l / 2019;
    rt = r / 2019;
    if(lt !=  rt ){
        cout << 0 << endl;
        return 0;
    }
    l = l % 2019;
    r = r % 2019;
    ll ans = 2018;
    ll t;
    for(ll i = l ; i < r ; i++  ){
        for(ll j = i + 1 ; j <= r ; j++){
            t = i * j % 2019;
            ans = min(ans , t);
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp> // Common file
    #include <ext/pb_ds/tree_policy.hpp>
    #include <functional> // for less
    #include <iostream>
    using namespace __gnu_pbds;
    using namespace std;
     
    typedef long long ll;
     
    #define pf(n) cout << n << endl
    #define ps() cout <<" ";
    #define sf(n) cin >> n
    #define in(i,n) for (int i = 0; i < n; i++)
    #define vi vector<int>
    #define vp vector<pair<int, int>>
    #define graph vector< vector<int> >
    #define vs vector<string>
    #define mn -
    #define pls +
    #define mod %
    #define E =
    #define EE ==
    #define le <=
    #define ge <=
    int mx=9999999;
    /**  '' "\n" - ^ **/
     
    class Template{
        public:
        void yes()
        {
            cout<<"Yes\n";
        }
     
        void no()
        {
            cout<<"No\n";
        }
        void YES()
        {
            cout<<"YES\n";
        }
     
        void NO()
        {
            cout<<"NO\n";
        }
     
        void Case(int i,int n)
        {
            cout<<"Case:"<<i<<" "<<n<<endl;
        }
        /**  '' "\n" x ^ **/
        /** printf("\n") */
    };
    bool comp(pair<ll,ll> a,pair<ll,ll> b)
    {
        if(a.first<b.first)return true;
        if(a.first>b.first)return false;
        return a.second>b.second;
    }
    int main() {
     
        ios::sync_with_stdio(false);
        cin.tie(0);
        Template root;
        int n;
        cin>>n;
        while(n)
        {
            if(n%10==7){
                root.yes();
            return 0;}
            n/=10;
        }
        root.no();
    }

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

#define ll long long int

int n,a[100001],b[100001],c[100001];
ll dp[3][100001];

ll call(int i,int key)
{
    if(dp[key][i])
        return dp[key][i];
    if(i>n-1)
        return 0;
    if(i==n-1)
    {
        if(key==0)
            return dp[key][i]=max(b[i],c[i]);
        else if(key==1)
            return dp[key][i]=max(a[i],c[i]);
        else
            return dp[key][i]=max(b[i],a[i]);
    }
    if(key==0)
        return dp[key][i]=max(b[i]+call(i+1,1),c[i]+call(i+1,2));
    else if(key==1)
        return dp[key][i]=max(a[i]+call(i+1,0),c[i]+call(i+1,2));
    else
        return dp[key][i]=max(a[i]+call(i+1,0),b[i]+call(i+1,1));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>a[i]>>b[i]>>c[i];
    cout<<max(a[0]+call(1,0),max(b[0]+call(1,1),c[0]+call(1,2)))<<endl;
    return 0;
}


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

int A, B;
long long N;

int solve();

int main(){
  long long s, ans;
  cin >> N;
  s = sqrt(N);
  // printf("%lld\n", s);
  for(long long i = s; i>0; i--){
    if(N % i == 0){
      ans = i + (N/i) -2;
      printf("%lld\n", ans);
      return 0;
    }
  }
  printf("error\n");
  return 1;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#define int128 __int128
#else
#define int128 long long
#endif

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

ll mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}
	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//freopen("output.txt", "w", stdout);
	ll n; cin >> n;
	vector<ll>a(n);
	map<ll, ll> cnt, cnt1;
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
	}

	ll ans = 0;

	for (ll i = n - 1; i >= 0; i--) {
		ans += cnt[a[i] + i];
		cnt[i - a[i]]++;
	}


	cout << ans << endl;

	return 0;
}

/*

*/


Measured memory_bytes: 27340
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int N,i;cin>>N>>i;
    cout<<((N%i)?1:0)<<endl;
}

Measured memory_bytes: 3544
import copy

s = input()
n = len(s)

ans = 10**10

if len(set(list(s))) == 1:
    print(0)
    exit()

for i in range(26):
    t = chr(i + ord('a'))
    tmp = 0
    li = [False] * n
    for j in range(n):
        if s[j] == t:
            li[j] = True
    while True:
        li_tmp = [False] * (n - tmp - 1)
        for j in range(n-tmp):
            if li[j]:
                if j > 0:
                    li_tmp[j-1] = True
                if j < n-tmp-1:
                    li_tmp[j] = True
        tmp += 1
        if all(li_tmp):
            ans = min(ans, tmp)
            break
        else:
            li = copy.copy(li_tmp)

print(ans)


Measured memory_bytes: 9232
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var item = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
            var N = item[0];
            var K = item[1];
            var S = item[2];

            var list = Enumerable.Range(0, N)
                .Select(i =>
                {
                    var other = S == 1000000000 ? 1 : S + 1;
                    if (i < K)
                    {
                        return S;
                    }
                    else
                    {
                        return other;
                    }
                })
                .ToList();

            Console.WriteLine(string.Join(" ", list));
        }
    }
}


Measured memory_bytes: 21852
using System;

namespace Range
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a, b, c;
            a = int.Parse(str[0]);
            b = int.Parse(str[1]);
            c = int.Parse(str[2]);

            if ((a < b) && (b < c))
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 5292
#include<bits/stdc++.h>
//pbds
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>   using orderedSet =tree<T, null_type, less<T>,rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define pb push_back
//BFS+DFS
#define boundary(i,j) (i>=0 && i<n && j>=0 && j<m)
int X[]={-1,1,0,0};
int Y[]={0,0,1,-1};

int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     int k;
     cin>>k;
     int num=7;
     for(int i=1; i<=k; i++)
     {
         num=num%k;
         if(num==0)
         {
             cout<<i<<endl;
             return 0;
         }
         num*=10;
         num+=7;
     }
     cout<<-1<<endl;

}




Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
    int a;
 
  cin>>a;
  string s;
  cin>>s;
  if(a>=3200)cout<<s<<endl;
  else cout<<"red"<<endl;
  
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, W;
	cin >> n >> W;
	vl v(n), w(n);
	REP(i, n)cin >> w[i] >> v[i];
	vl dp(W + 1, -INF);
	dp[0] = 0;
	REP(i, n) {
		RREP(j, W + 1) {
			if (j + w[i] <= W) {
				dp[j + w[i]] = max(dp[j + w[i]], dp[j] + v[i]);
			}
		}
	}
	cout << *max_element(ALL(dp)) << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long n, t=0, x;
	cin >> n;
	for (int i=1; i<=n; i++)
	{
		cin >> x;
		t+=(x-1);
	}
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 256
import math
import fractions
from functools import reduce

def lcm_base(x, y):
  return (x * y) // fractions.gcd(x, y)
def lcm(*numbers):
  return reduce(lcm_base, numbers, 1)
def lcm_list(numbers):
  return reduce(lcm_base, numbers, 1)
  
N = int(input())
T = [int(input()) for i in range(N)]

print(lcm_list(T))

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> broken(n + 1);
    REP(i, m) {
        int tmp;
        cin >> tmp;
        broken[tmp] = 1;
    }
    vector<int> dp(n + 1);
    const int mod = 1000000007;
    dp[0] = 1;
    dp[1] = !broken[1];
    for(int i = 2; i < n + 1; i++) {
        if(broken[i]) {
            dp[i] = 0;
            continue;
        }
        dp[i] = (dp[i - 2] + dp[i - 1]) % mod;
    }
    cout << dp[n] << endl;
}



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

int main(){
    int N;
    scanf("%d", &N);
    vector<int> divs(1);
    divs[0] = 1;
    while(N > 1){
        for(int i = 2; i <= N; i++){
            if(N % i == 0){
                divs.push_back(i);
                N /= i;
                break;
            }
        }
    }
    string str = "No";
    for(int i = 0; i < divs.size(); i++){
        int a = 1, b = 1;
        for(int j = 0; j <= i; j++){
            a *= divs[j];
        }
        for(int j = i+1; j < divs.size(); j++){
            b *= divs[j];
        }
        if((10 - a) > 0 && (10 - b) > 0){
            str = "Yes";
            break;
        }
    }
    cout << str << endl;
    return 0;

}

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

int main(){
  long long y,z,x,a,b,c;
  string A,B,C;
  cin>>A>>B>>C;
  a=0;
  b=0;
  c=0;
  char F;
  F='a';
  x=A.size();
  y=B.size();
  z=C.size();
  for(int i=0;i<x+y+z;i++){
    if((a==x&&F=='a')||(y==b&&F=='b')||(z==c&&F=='c')){
      break;
    }
    if(F=='a'){
      F=A[a];
      a++;
    }
    else if(F=='b'){
      F=B[b];
      b++;
    }
    else{
      F=C[c];
      c++;
    }
  }
    if(F=='a'){
      cout<<'A'<<endl;
    }
    else if(F=='b'){
            cout<<'B'<<endl;
    }
    else{
            cout<<'C'<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int t,n;
    while(cin >> t >> n, t!=0){
        int s,f;
        for(int i=0; i<n ; i++){
            cin >> s >> f;
            f -= s;
            t -= f;
        }
        if(t<=0) cout << "OK" << endl;
        else cout << t << endl;
    }
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
#define MOD 1000000007
using namespace std;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
const int INF = 1e9;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> a1(n);
    vector<int> a2(n);

    for(int i=0;i<n;i++){
        cin >> a1[i];
    }
    for(int i=0;i<n;i++){
        cin >> a2[i];
    }

    int sum = 0;
    int ans = 0;

    for(int i=0;i<n;i++){
        sum = 0;
        for(int j=0;j<=i;j++){
            sum += a1[j];
        }
        for(int j=i;j<n;j++){
            sum += a2[j];
        }

        ans = max(ans,sum);
    }

    cout << ans << endl;
}

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_popcount

#define INF 1e16
#define mod 1000000007

ll N;
vector<ll> A;
bool isprime[100010];
vector<ll> ps;
map<ll,ll> fact[100010];
map<map<ll,ll>, ll> cnt;
vector<pair<map<ll,ll>, map<ll,ll> > > anti;
map<map<ll,ll>, bool> used;
bool aru1=false;

int main(){
  cin>>N;
  A.resize(N);
  rep(i,N){
    cin>>A[i];
  }
  rep(i,100010)isprime[i]=true;
  for(ll i=2;i<=100000;i++){
    if(isprime[i]){
      ps.push_back(i);
      for(ll j=i*2;j<=100000;j+=i)isprime[j]=false;
    }
  }
  rep(i,N){
    for(ll j=0;ps[j]<=2200;j++){
      while(A[i]%ps[j]==0){
        fact[i][ps[j]]++;
        A[i]/=ps[j];
      }

      if(fact[i][ps[j]]>0){
        fact[i][ps[j]]%=3;
      }
      if(fact[i][ps[j]]==0)fact[i].erase(ps[j]);
    }
  }
  ll res=0;
  rep(i,N){
    if(A[i]!=1){
      ll sq=sqrt(A[i]);
      if(sq*sq==A[i]){
        fact[i][sq]=2;
      }else{
        ll idx=lower_bound(all(ps),A[i])-ps.begin();
        if(idx<(ll)ps.size()&&ps[idx]==A[i])fact[i][A[i]]=1;
        else{
          res++;
          continue;
        }
      }
    }
    if(fact[i].size()==0){
      aru1=true;
      continue;
    }
    cnt[fact[i]]++;
    if(used[fact[i]])continue;
    map<ll,ll> tmp;
    for(auto it : fact[i]){
      tmp[it.fi]=3-it.se;
    }
    anti.push_back(pair<map<ll,ll>, map<ll,ll> >(fact[i],tmp));
    used[fact[i]]=true;
    used[tmp]=true;
  }

  for(auto it : anti){
    res+=max(cnt[it.first],cnt[it.second]);
  }
  cout<<res+aru1<<endl;

  return 0;
}


Measured memory_bytes: 142248