akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

int main() {
	int n, m;
	std::cin >> n >> m;

	int a[n][m];
	int b[m];
	int c[n];

	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			std::cin >> a[i][j];
		}
	}

	for(int i=0; i<m; i++){
		std::cin >> b[i];
	}

	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			if(j==0) c[i] = 0;
			c[i] += a[i][j] * b[j];
		}
	}

	for(int i=0; i<n; i++){
		std::cout << c[i] << std::endl;
	}
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 
 
using namespace std;
long long mod = 1e9 + 7;
long long INF = 1e7;
double EPS = 1e-12;
typedef long long int lld;
long double tick(){static clock_t oldt; clock_t newt=clock();
    long double diff=1.0L*(newt-oldt)/CLOCKS_PER_SEC; oldt = newt; return diff; }
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
inline lld sc() { lld a; scanf("%lld", &a); return a; }
inline int scd() { int a; scanf("%d", &a); return a; }
inline double scf() { double a; scanf("%lf",&a); return a; }
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define all(c) (c).begin(), (c).end()
#define sz(a) ((int)a.size())
#define Error(x...) { cout << "(" << #x << ")" << " = ( "; printIt(x); }
template <typename T1> void printIt(T1 t1) { cout << t1 << " )" << endl; }
template <typename T1, typename... T2>
void printIt(T1 t1, T2... t2) { cout << t1 << " , "; printIt(t2...); }
#define errorpair(a) cout<<#a<<" = ( "<<((a).first)<<" , "<<((a).second)<<" )\n";
#define mset(a, v) memset(a, v, sizeof(a))
#define popcount __builtin_popcountll

typedef pair<lld,lld> PA;

lld powP(lld x, lld y) {
    lld ans = 1, po = x % mod;
    while(y > 0) {
        if(y & 1) ans = ans * po % mod;
        y >>= 1; po = po * po % mod;
    }
    return ans;
}
 
bool bitSet(lld n, lld bit){
    if((n & (1LL << bit)) != 0) return true;
    else return false;
}
 
lld findGcd(lld a, lld b){
    while(a != 0) { lld temp = b % a; b = a; a = temp; }
    return b;
}

#define lim 300010
#define lim2 200010
#define qqqqqq 210
// Ab :)
// inline lld sqr(lld x) { return x * x; }
// unordered_map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];

// vector<lld> G[lim];
// string S[lim];
lld A[lim],B[lim],C[lim];

int main(){
    lld n = sc(), k = sc();
    rep(i,1,k) {
        lld d = sc();
        while(d--) {
            lld x = sc();
            A[x]++;
        }   
    }
    int ans = 0;
    rep(i,1,n) ans += (A[i] == 0);
    prdL(ans);
    return 0;
}


Measured memory_bytes: 3832
#E
from collections import deque
import bisect
n = int(input())
a = [int(input()) for _ in range(n)]
result = deque()

for i in a:
    idx = bisect.bisect_left(result,i)
    if idx == 0:
        result.appendleft(i)
        
    else:
        result[idx-1] = i
        
print(len(result))
        

Measured memory_bytes: 8060
#include <iostream>
#include <cmath>

int main(int argc, char **argv)
{
    long N, K;
    std::cin >> N >> K;

    long ans = 0;
#if 0
    for(long a = 1; a <= N; a++){
        for(long b = 1; b <= N; b++){
            if(a % b >= K) ans++;
        }
    }
#endif
    long b;
    for(b = K+1; b <= N; b++){
        long n0 = 0, n1 = 0;
        long period = N / b;
        n0 = period * (b - K);
        if(N % b > 0){
            if(K == 0){
                n1 = (N % b);
            }else{
                n1 = (N % b) - (K - 1);
            }
        }
        ans += n0 + (n1 > 0 ? n1 : 0);
    }

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


Measured memory_bytes: 256
using System;
 
public class Hello
{
    static int[] coin = new int[] { 10, 50, 100, 500 };
    public static void Main()
    {
        var first = true;
        while (true)
        {
            var a = int.Parse(Console.ReadLine().Trim());
            if (a == 0) break;
            string[] line = Console.ReadLine().Trim().Split(' ');
            var ca = Array.ConvertAll(line, int.Parse);
            var cv = 0;
            for (int i = 0; i < 4; i++) cv += ca[i] * coin[i];
            var cb = getChenge(cv -a);
            print(ca, cb, first);
            if (first) first = false;
        }
    }
    public static void print(int[] a, int[] b, bool first)
    {
        if (!first) Console.WriteLine();
        for (int i = 0; i < 4; i++)
        {
            var w = a[i] - b[i];
            if (w >= 1) Console.WriteLine("{0} {1}", coin[i], w);
        }
    }
    public static int[] getChenge(int a)
    {
        var temp = a;
        var ret = new int[4];
        for (int i = 3; i >= 0; i--)
        {
            ret[i] = temp / coin[i];
            temp = temp % coin[i];
        }
        return ret;
    }
}


Measured memory_bytes: 9292
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <complex>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>

using namespace std;

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

	/*vector<int> A((int)N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}*/

	string str = std::to_string(N);
	int count = 0;
	
	for (int i = 0; i < 4; ++i)
	{
		if (str[i] == '2')
			++count;
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
def warshall_floyd():
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k]+d[k][j])

N, M = map(int, input().split())
d = [[10**18]*N for _ in range(N)]

for i in range(N):
    d[i][i] = 0
    
edges = []

for _ in range(M):
    a, b, c = map(int, input().split())
    d[a-1][b-1] = c
    d[b-1][a-1] = c
    edges.append((a-1, b-1, c))

warshall_floyd()
ans = 0

for a, b, c in edges:
    flag = True
    
    for i in range(N):
        for j in range(N):
            if d[i][a]+c+d[b][j]==d[i][j]:
                flag = False
    
    if flag:
        ans += 1

print(ans)

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

using namespace std;

typedef long long int ll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

vector <ll> h(25);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
 
    ll N;
    cin >> N;

    for(ll i=0; i<N; i++)
    {
        cin >> h[i];
    }

    ll ans = 1;
    ll m = h[0];

    for(ll i=1; i<N; i++)
    {
        if(h[i] >= m)
        {
            ans++;
        }

        m = max(m, h[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict


def main():
    N, M = map(int, input().split())
    d = defaultdict(list)
    for _ in range(M):
        a, b = map(int, input().split())
        d[a].append(b)
        d[b].append(a)
    for i in range(1, N + 1):
        print(len(d[i]))


if __name__ == '__main__':
    main()


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
	int x, y;
	cin >> x >> y;
	if (a[x] == a[y]){ cout << "Yes" << endl; }
	else { cout << "No" << endl; }
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vector<ll>>;
using vec_str = vector<string>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    ll N;
    cin >> N;
    vec P(N);
    REP(i,0,N) cin >> P[i];

    ll cnt = 0, m = N;
    REP(i,0,N) {
        if(m >= P[i]) {
            m = P[i];
            ++cnt;
        }
    }
    _PR(cnt);

    return 0;
}

/*



*/

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;

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


Measured memory_bytes: 764
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;

#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

#define left(x) x * 2
#define right(x) x * 2 + 1

#define meme(a, b, c) fill(a + 1, a + 1 + b, c)

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a > b ? b : a)
#define abs(a) (a > 0? a : -(a))

#define move(s) s += "#"

#define fr(i, a, b) for (ll i = a; i <= b; ++ i)
#define rf(i, a, b) for (ll i = a; i >= b; -- i)

#define eprintf(...) fprintf(stderr, __VA_ARGS__);

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr << "Ready\n";
}

const int N = 4e6 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const ll P = 53;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);

int main () {
    to_pray();
    
    int a, b;
    cin >> a >> b;
    
    cout << (b % a == 0 ? a + b : b - a);
    
    cout << '\n';
    return 0;
}

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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		int a, b;
		cin >> a >> b;
		if(b%a == 0)cout << a + b << endl;
		else cout << b-a << endl;
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] ans = new String[3];
        for (int i = 0; i < 3; i++) {
            int a = (int) n % (int) Math.pow(10, i + 1) / (int) Math.pow(10, i);
            if (a == 1) {
                ans[3 - i - 1] = "9";
            } else if (a == 9) {
                ans[3 - i - 1] = "1";
            } else {
                ans[3 - i - 1] = String.valueOf(a);
            }
        }
        for (int i = 0; i < 3; i++) {
            System.out.print(ans[i]);
        }
        System.out.println();
    }
}

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

int main() {
  
  string S;
  cin >> S;
  int N = S.size();
  
  vector<int> x;
  vector<int> y;
  
  y.push_back(-1);
  
  for (int i = 0; i < N - 1; i++) {
    if (S[i] == 'R' && S[i + 1] == 'L') x.push_back(i);
    if (S[i] == 'L' && S[i + 1] == 'R') y.push_back(i);
  }
  
  y.push_back(N - 1);
  
  vector<int> ans(N);
  
  for (int i = 0; i < x.size(); i++) {
    
    int A = x[i] - y[i];
    int B = y[i + 1] - x[i];
    
    ans[x[i]] = (A + 1) / 2 + B / 2;
    ans[x[i] + 1] = A / 2 + (B + 1) / 2;
    
  }
  
  for (int i = 0; i < N; i++) cout << ans[i] << " ";
  
}

Measured memory_bytes: 1532
using System;
using System.IO;
using System.Text;

class Program{
    static void Main(string[] args){
        var N = new StringBuilder(Convert.ToString(int.Parse(Console.ReadLine()), 2));
        N.Replace("1", "0", 1, N.Length - 1);
        var answer = Convert.ToInt32(N.ToString(), 2);
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}}

Measured memory_bytes: 27564
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}


int main()
{
  ll h,w,c[60][60];
  char s[60][60];
  cin >> h >> w;
  rep(i,h){
    rep(j,w){
      cin >> s[i][j];
      c[i][j]=0;
    }
  }
  rep(i,h){
    rep(j,w){
      if(s[i][j]=='#'){
        c[i+1][j]++;
        c[i-1][j]++;
        c[i][j+1]++;
        c[i][j-1]++;
        c[i+1][j+1]++;
        c[i-1][j-1]++;
        c[i+1][j-1]++;
        c[i-1][j+1]++;
      }
    }
  }
  rep(i,h){
    rep(j,w){
      if(s[i][j]=='#')printf("#");
      else printf("%lld",c[i][j]);
    }
    printf("\n");
  }
}

Measured memory_bytes: 384
#include <iostream>
#include <climits>
using namespace std;
typedef long long int ll;
ll dp[100010][4];
ll arr[100010][4];

int main(){
    ll n,k;
    scanf("%lld",&n);

    for(ll i = 1; i <= n; i++){
        for(ll j = 1; j <= 3; j++)
            scanf("%lld",&arr[i][j]);
    }
    dp[1][1] = arr[1][1];
    dp[1][2] = arr[1][2];
    dp[1][3] = arr[1][3];

    for(ll i = 2; i <= n; i++){
        for(ll j = 1; j <= 3; j++){
            dp[i][j] = LLONG_MIN;
            for(int k = 1; k <= 3; k++){
                if(k == j)  continue;
                dp[i][j] = max(dp[i][j],dp[i-1][k] + arr[i][j]);
            }
        }
    }

    printf("%lld\n",max(dp[n][1],max(dp[n][2],dp[n][3])));


    //printf("%lld\n",dp[n]);
}


Measured memory_bytes: 6528
// -*- coding:utf-8-unix -*-

// TLE

use proconio::input;

fn main() {
    input! {
        h: usize,
        w: usize,
        m: usize,
    }

    let mut vh = Vec::with_capacity(h);
    let mut vw = Vec::with_capacity(w);
    for _ in 0..h {
        vh.push(0);
    }
    for _ in 0..w {
        vw.push(0);
    }
    let mut mass = Vec::with_capacity(m);
    // println!("len: {} {}", vh.len(), vw.len());

    for _ in 0..m {
        input! {
            hn: usize,
            wn: usize,
        }
        // println!("hn, wn: {}, {}", hn, wn);
        vh[hn - 1] += 1;
        vw[wn - 1] += 1;
        mass.push((hn - 1, wn - 1));
    }

    // 行最大 + 列最大 に -1 するか否か
    // 行最大 + 列最大が複数存在する可能性
    // とりわけすべてのマスに爆弾を置かれた場合に O(n^2) となり TLE?
    let mut hmax = 0;
    let mut hidx_max = vec!();
    for i in 0..vh.len() {
        if hmax < vh[i] {
            hmax = vh[i];
            hidx_max.clear();
            hidx_max.push(i);
        } else if hmax == vh[i] {
            hidx_max.push(i);
        }
    }

    let mut wmax = 0;
    let mut widx_max = vec!();
    for i in 0..vw.len() {
        if wmax < vw[i] {
            wmax = vw[i];
            widx_max.clear();
            widx_max.push(i);
        } else if wmax == vw[i] {
            widx_max.push(i);
        }
    }
    let ans = hmax + wmax;

    let mut p = 0;
    for &(i, j) in &mass {
        if vh[i] == hmax && vw[j] == wmax {
            p += 1;
        }
    }
    if p == hidx_max.len() * widx_max.len() {
        println!("{}", ans - 1);
    } else {
        println!("{}", ans);
    }
}


Measured memory_bytes: 17748
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* class */
class Point {
    public:
    ll t, d, x;
    Point(ll t, ll d, ll x):
    t(t), d(d), x(x) {}
    bool operator < (const Point &p) const {
        if (t == p.t) return x < p.x;
        return t < p.t;
    }
};
/* global variables */
/* function */
/* main */
typedef pair<ll, ll> pll;
int main(){
    int N, Q;
    cin >> N >> Q;
    ll s, t, x;
    vector<pll> P;
    for (int i = 0; i < N; i++) {
        cin >> s >> t >> x;
        P.push_back(pll(s - x, x));
        P.push_back(pll(t - x, x));
    }
    sort(P.begin(), P.end());
    vector<ll> a(Q);
    for (int i = 0; i < Q; i++) cin >> a[i];
    set<ll> S;
    int j = 0;
    for (int i = 0; i < Q; i++) {
        for( ; j < P.size() && P[j].first <= a[i]; j++) {
            pll p = P[j];
            if (S.find(p.second) == S.end()) S.insert(p.second);
            else S.erase(p.second);
        }
        if (S.empty()) cout << -1 << '\n';
        else cout << *S.begin() << '\n';
    }
}


Measured memory_bytes: 20072
T1,T2 = map(int,input().split())
A1,A2 = map(int,input().split())
B1,B2 = map(int,input().split())

d1 = A1*T1-B1*T1
d2 = A2*T2-B2*T2

import sys
if d1+d2 == 0:
    print('infinity')
    sys.exit()
elif d1*d2 > 0 or (abs(d1)-abs(d2)>0 and d1*d2<0):
    print(0)
    sys.exit()
    
else:
    start = abs(d1)
    delta = abs(d2+d1)
    ans = start//delta * 2
    if (start%delta)!=0:
        ans += 1
    print(ans)
    
    
    

    

Measured memory_bytes: 3064
#include <climits>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {

	int n;	cin >> n;
	vector<int> a(n);
	vector<int> dp(n, INT_MAX);

	for (int i = 0; i < n; i++)
		cin >> a[i];

	dp[0] = 0; dp[1] = abs(a[1] - a[0]);

	for (int i = 2; i < n; i++)
		dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));

	cout << dp[n - 1] << endl;
}

Measured memory_bytes: 3956
#include <iostream>
#define p cout << "?";
#define tie ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int main()
{
	char a[10];
	cin>>a;
	for(int i=0;a[i+1]!='\0';i++)
	{
		if(a[i]=='A'&&a[i+1]=='C')
		{
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 25
using namespace std;
int n,m,K;
void solve(){
	scanf("%d %d",&n,&m);
	int k=(n/2019)*2019;
	n-=k,m-=k;
	k=(m/2019)*2019;
	if(k){
		puts("0");
		return;
	}
	int ans=0x3f3f3f3f;
	for(int i=n;i<=m;i++){
		for(int j=i+1;j<=m;j++){
			ans=min(ans,i*j%2019);
		}
	}
	printf("%d\n",ans);
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 256
/*input
2 3 -10
1 2 3
3 2 1
1 2 2
*/
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll sub(ll a,ll b){
    ll x=a-b;
    while(x<0) x+=MOD;
    while(x>MOD) x-=MOD;
    return x;
}
ll mult(ll a,ll b){
    return a*b%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=(res*a)%MOD;
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
const int maxn=5e5+5;
int a[maxn];
int main(){
	int n,m,c;
	cin>>n>>m>>c;
	REP(i,m) cin>>a[i];
	int cnt=0;
	REP(z,n){
		int sum=c;
		REP(i,m){
			int x;
			cin>>x;
			sum+=(x*a[i]);
		}
		cnt+=(sum>0);
	}
	cout<<cnt;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	var ret int
	var c []int64

	if n == 1 {
		fmt.Println(0)
		return
	}

	var i int64
	for {
		i, n = parse(n)

		if i == 1 {
			c = append(c, n)
			break
		} else {
			c = append(c, i)
		}
	}

	dic := make(map[int64][]int64)
	for _, v := range c {
		dic[v] = make([]int64, 2)
	}
	for _, v := range c {
		if dic[v][0] == 0 {
			dic[v][0]++
			ret++
			continue
		}
		if dic[v][1] != dic[v][0] {
			dic[v][1]++
		} else {
			dic[v][0]++
			dic[v][1] = 0
			ret++
		}
	}
	fmt.Println(ret)
}

func parse(n int64) (int64, int64) {
	for i := 2; float64(i) <= math.Sqrt(float64(n)); i++ {
		if n%int64(i) == 0 {
			return int64(i), n / int64(i)
		}
	}

	return 1, n
}

func nextInt() int64 {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return int64(i)
}


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

#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
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; }

const long long INF = 1LL<<60;


const int MAX_H=10000;
const int MAX_N=1000;

string in;



int main()
{

    cin>>in;


    if(in=="hi" or in=="hihi" or in =="hihihi" or in=="hihihihi" or in=="hihihihihi")
    {
        cout<<"Yes"<<endl;
        return 0;
    }


    cout<<"No"<<endl;
    return 0;

}




Measured memory_bytes: 256
mov (x,y) (dir,len) =
  case dir of
    "N" -> (x,y+len)
    "E" -> (x+len,y)
    "W" -> (x-len,y)
    "S" -> (x,y-len)

inside s d j = ( (s <= j) && (j <= d) ) || ( (d <= j) && (j <= s) )

pick :: (Int,Int) -> (Int,Int) -> [(Int,Int)] -> [(Int,Int)]
pick _ _ [] = []
pick s@(sx,sy) d@(dx,dy) (j@(jx,jy):js) =
  if (inside sx dx jx) && (inside sy dy jy)
  then pick s d js
  else j:(pick s d js)

ans' :: [(Int,Int)] -> (Int,Int) -> [(String,Int)] -> [(Int,Int)]
ans' [] _ _ = []
ans' j s [] = [s]
ans' j s (c:cs) =
  let d = mov s c
      j'= pick s d j
  in
    ans' j' d cs

ans x =
  let n = read $ head $ head x :: Int
      j = map (\[a,b]->(read a,read b)) $ take n $ drop 1 x :: [(Int,Int)]
      m = read $ head $ head $ drop (n+1) x :: Int
      c = map (\[a,b]->(a,read b)) $ take m $ drop (n+2) x :: [(String,Int)]
      r = drop (n+m+2) x
      a = ans' j (10,10) c
      b = if a == [] then "Yes" else "No"
  in
    if n == 0 then [] else (b:(ans r))

main = do
  c <- getContents
  let i = map words $ lines c
      o = ans i
  mapM_ putStrLn o 



Measured memory_bytes: 4680
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()


int main(){
  int N,M;cin>>N>>M;
  //vll x(N),y(N),z(N);rep(i,N)cin>>x[i]>>y[i]>>z[i];
  vector<vll> v(3,vll(N)); rep(i,N)cin>>v[0][i]>>v[1][i]>>v[2][i];
  //+-の取り方8通り
  ll ans=0;
  for(int bit=0;bit<(1<<3);++bit){
    ll ans_each=0;
    vll tmp(N,0);
    rep(i,N){
      for(int mask=0;mask<3;++mask){
        //bit立ってたら+
        if(bit & (1<<mask)){
          tmp[i] += v[mask][i];
        }
        else tmp[i] -= v[mask][i];
      }
    }
    sort(all(tmp),greater<ll>());
    rep(j,M) ans_each += tmp[j];
    ans = max(ans,ans_each);    
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
// 問題URL
// https://atcoder.jp/contests/abc138/tasks/abc138_a

import java.util.Scanner;
import java.util.Arrays;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer n = Integer.parseInt(scanner.next());
        String x = scanner.next();

        if (n >= 3200) {
            System.out.println(x);
        } else {
            System.out.println("red");
        }

    }
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	
	int n; cin >> n;
	vector<int> arr(n);
	for(int i = 0; i < n; i++) cin >> arr[i];
	int inc = 0, dec = 0;
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(inc < i) inc = i;
		if(dec < i) dec = i;
		int len_inc = 0, len_dec = 0;
		while(inc < n - 1 && arr[inc + 1] >= arr[inc]){
			inc++;
			len_inc++;
		}
		while(dec < n - 1 && arr[dec + 1] <= arr[dec]){
			dec++;
			len_dec++;
		}
		int len = max(len_inc, len_dec);
		i = max(inc, dec);
		ans++;
	}
	cout << ans << endl;
	return 0;	
}
  

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename T>
vector<T> dijkstra(int s,vector<vector<pair<int,T>>> &G){
    const T INFINF=numeric_limits<T>::max();
    using P=pair<T,int>;
    int n=G.size();
    vector<T> d(n,INFINF);
    vector<int> b(n,-1);//previous point
    priority_queue<P,vector<P>,greater<P>> q;
    d[s]=0;
    q.emplace(d[s],s);
    while(!q.empty()){
        P p=q.top();q.pop();
        int v=p.second;
        if(d[v]<p.first) continue;
        for(auto& e:G[v]){
            int u=e.first;
            T c=e.second;
            if(d[u]>d[v]+c){
                d[u]=d[v]+c;
                b[u]=v;
                q.emplace(d[u],u);
            }
        }
    }
    return d;
}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<setprecision(20);
    
    double sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    int n;
    cin>>n;
    double x[n],y[n],r[n];
    rep(i,n){
        cin>>x[i]>>y[i]>>r[i];
    }
    vector<vector<pair<int,double>>> g(n+2);
    g[0].push_back(make_pair(n+1,sqrt((sx-tx)*(sx-tx)+(sy-ty)*(sy-ty))));
    for(int i=0;i<n;i++){
        double d=sqrt((sx-x[i])*(sx-x[i]) + (sy-y[i])*(sy-y[i]))-r[i];
        g[0].push_back(make_pair(i+1,max(0.0,d)));
    }
    for(int i=0;i<n;i++){
        double d=sqrt((tx-x[i])*(tx-x[i]) + (ty-y[i])*(ty-y[i]))-r[i];
        g[i+1].push_back(make_pair(n+1,max(0.0,d)));
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j) continue;
            double d=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))-r[i]-r[j];
            g[i+1].push_back(make_pair(j+1,max(0.0,d)));
        }
    }
    // for(int i=0;i<n+2;i++){
    //     cout<<i<<": "<<endl;
    //     for(auto x:g[i]){
    //         cout<<"To: "<<x.first<<" Cost: "<<x.second<<endl;
    //     }
    //     cout<<endl;
    // }
    auto v=dijkstra(0,g);
    cout<<v[n+1]<<endl;
    return 0;
}


Measured memory_bytes: 22256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 51000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N >> K >> S;
  Vec(P,lli,1,0);
  if(S[0]=='1')flag=1;
  else{
    P.pb(0);
    num++;
  }
  rep(i,0,N){
    if(flag){
      if(S[i]=='1')P[num]++;
      else{
        flag=0;
        num++;
        P.pb(0);
        P[num]++;
      }
    }
    else{
      if(S[i]=='0')P[num]++;
      else{
        flag=1;
        num++;
        P.pb(0);
        P[num]++;
      }
    }
  }
  M=P.size();
  Vec(Q,lli,M,0);
  Q[0]=P[0];
  rep(i,1,M)Q[i]=P[i]+Q[i-1];
  if(2*K<M)sum=Q[2*K];
  else sum=Q[M-1];
  int l=1;
  int r=2*K+2;
  while(l<r&&r<M){
    sum=max(sum,Q[r]-Q[l]);
    //cout << l << " " << r << endl;
    l+=2;
    r+=2;
    if(r>M-1)r=M-1;
    //Out(sum);
  }
  if(2*K<M)sum=max(sum,Q[M-1]-Q[M-1-2*K]);
  Out(sum);
}


Measured memory_bytes: 2164
#include <stdio.h>
#include <stdlib.h>

int main()
{   int i,n,a[300000],index,j;
scanf("%d",&n);
for(i=1;i<=n;i++)
{ scanf("%d",&a[i]);
}

for(i=1,j=1;i<=n;i++)
{   if(a[i]==j)
     {  j++;
         index=i;
     }
}
if(j==1) printf("-1");
else printf("%d",n-j+1);
    return 0;
}

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

int main()
{
  string s, t;
  int c = 0;
  cin >> s;
  cin >> t;
  if (s[0] == t[0])
    c++;
  if (s[1] == t[1])
    c++;
  if (s[2] == t[2])
    c++;
  cout << c << endl;
}


Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 300005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n;
	cin>>n;
	if(n==1){
		cout<<"1.0000000000";
		return 0;
	}
	ll k,l;
	k=(n+1)/2.0; l=(n/2);
	ld an=(1.0l*k)/(1.0l*(k+l));
	cout<<fixed<<setprecision(8)<<an<<endl;
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A;
  for(int i=0; i<N; i++){
    int a; cin >> a;
    A.push_back(a);
  }
  sort(A.begin(), A.end());
  int tmp=A[0];
  int num=1;
  int ans=0;
  for(int i=1; i<A.size(); i++){
    if(tmp==A[i]){
      num++;
    }else{
      if(num<tmp){
        ans+=num;
      }else{
        ans+=num-tmp;
      }
      tmp=A[i];
      num=1;
    }
  }
  if(num<tmp){
    ans+=num;
  }else{
    ans+=num-tmp;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N, X, Y);
  X--; Y--;
  map<int, int> mp;
  rep(i, 0, N) {
    rep(j, i + 1, N) {
      int d = min({abs(j - i), abs(i - X) + abs(j - Y) + 1, abs(i - Y) + abs(j - X) + 1});
      mp[d]++;
    }
  }
  rep(i, 1, N) {
    print(mp[i]);
  }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=1000005;
#define M 1000000007
#define double long double
#define BINF 1000000000000000001
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 150001
const int LG = 22;

#undef int
int main()
{
#define int long long int

ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
	
	int n;
	cin>>n;
	int c=0;

	while(n)
	{
		int x=n%10;
		n/=10;
		if(x==2)
			c++;
	}
	cout<<c<<endl;

return 0;
}

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

int main(){
  int n, m, p, x[100];
  while(cin >> n >> m >> p, n){
    int sum = 0;
    for(int i = 0; i < n; ++i){
      cin >> x[i];
      sum += x[i];
    }
    if(x[m - 1])
      cout << sum * (100 - p) / x[m - 1] << endl;
    else
      cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 3096
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	private static final long MOD = (long)Math.pow(10, 9) + 7;
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		
		long res = 1l;
		
		for (int i = 2; i <= n; i++) {
			res = (res*i) % MOD;
		}
		System.out.println(res);
	}
	
	static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 21204
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, a;std::cin >> n >> a;
  std::cout << n*n-a << '\n';
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] n = sc.next().toCharArray();

        String ans = "No";
        for(int i = 0;i < n.length;i++) {
            if(n[i] == '7') ans = "Yes";
        }

        System.out.println(ans);
    }

}


Measured memory_bytes: 35584
package main
import "fmt"

func main() {
	var d, n int
	fmt.Scan(&d)
	fmt.Scan(&n)
  if (n == 100) {
		n++;
	}
  if (d == 0) {
      fmt.Println(n)
  }
  if (d == 1) {
      fmt.Println(n*100)
  }
  if (d == 2) {
      fmt.Println(n*10000)
  }
}

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

#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,h,w,ans=0;
    cin>>n>>h>>w;
    int a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    for(int i=0;i<n;i++){
        if(a[i]>=h && b[i]>=w){
            ans++;
        }
    }
    cout <<ans<<endl;
    return 0;
}


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

//def
#define debug(x) cout << #x << ": " << x << '\n'
#define out(x) cout << x << '\n'
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

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

    int k;
    ll ans = 0;
    cin >> k;
    rep(i, k) rep(j, k) rep(l, k) {
        ans += gcd(i + 1, gcd(j + 1, l + 1));
    }

    out(ans);
    return 0;
}


Measured memory_bytes: 3652
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

ll N;

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

  if (N % 2 != 0) {
    cout << 0 << endl;
    return 0;
  }

  ll ans = 0;
  ll x = 5;
  while (x <= N) {
    ans += (N / x / 2);
    x *= 5;
  }

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

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

int main(){
  long A, B;
  scanf("%ld %ld", &A, &B);
  if((A%2==0 && B%2==0) || (A%2==1 && B%2==1))
    printf("%ld\n", (A+B)/2);
  else
    printf("IMPOSSIBLE\n");
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>

int main(){
	int a=0;
	int z=1;
	while(1){
		std::cin>>a;
		if(a==0)break;
		std::vector<int> vec(7);
		std::vector<int> vec1(7);
		for(int i=1;i<7;i++){
			vec[i]=i;
			vec1[i]=i;
		}
		std::string str;
		for(int i=0;i<a;i++){
			std::cin>>str;
			if(i%2==0){
				if(str=="North"){
					vec[1]=vec1[2];
					vec[2]=vec1[6];
					vec[6]=vec1[5];
					vec[5]=vec1[1];
					vec[3]=vec1[3];
					vec[4]=vec1[4];
					z=z+vec[1];
				}
				if(str=="East"){
					vec[1]=vec1[4];
					vec[4]=vec1[6];
					vec[6]=vec1[3];
					vec[3]=vec1[1];
					vec[2]=vec1[2];
					vec[5]=vec1[5];
					z=z+vec[1];
				}
				if(str=="West"){
					vec[1]=vec1[3];
					vec[3]=vec1[6];
					vec[6]=vec1[4];
					vec[4]=vec1[1];
					vec[2]=vec1[2];
					vec[5]=vec1[5];
					z=z+vec[1];
				}
				if(str=="South"){
					vec[1]=vec1[5];
					vec[5]=vec1[6];
					vec[6]=vec1[2];
					vec[2]=vec1[1];
					vec[3]=vec1[3];
					vec[4]=vec1[4];
					z=z+vec[1];
				}
				if(str=="Left"){
					vec[2]=vec1[4];
					vec[4]=vec1[5];
					vec[5]=vec1[3];
					vec[3]=vec1[2];
					vec[1]=vec1[1];
					vec[6]=vec1[6];
					z=z+vec[1];
				}
				if(str=="Right"){
					vec[2]=vec1[3];
					vec[3]=vec1[5];
					vec[5]=vec1[4];
					vec[4]=vec1[2];
					vec[1]=vec1[1];
					vec[6]=vec1[6];
					z=z+vec[1];
				}
			}
			if(i%2==1){
				if(str=="North"){
					vec1[1]=vec[2];
					vec1[2]=vec[6];
					vec1[6]=vec[5];
					vec1[5]=vec[1];
					vec1[3]=vec[3];
					vec1[4]=vec[4];
					z=z+vec1[1];
				}
				if(str=="East"){
					vec1[1]=vec[4];
					vec1[4]=vec[6];
					vec1[6]=vec[3];
					vec1[3]=vec[1];
					vec1[2]=vec[2];
					vec1[5]=vec[5];
					z=z+vec1[1];
				}
				if(str=="West"){
					vec1[1]=vec[3];
					vec1[3]=vec[6];
					vec1[6]=vec[4];
					vec1[4]=vec[1];
					vec1[2]=vec[2];
					vec1[5]=vec[5];
					z=z+vec1[1];
				}
				if(str=="South"){
					vec1[1]=vec[5];
					vec1[5]=vec[6];
					vec1[6]=vec[2];
					vec1[2]=vec[1];
					vec1[3]=vec[3];
					vec1[4]=vec[4];
					z=z+vec1[1];
				}
				if(str=="Left"){
					vec1[2]=vec[4];
					vec1[4]=vec[5];
					vec1[5]=vec[3];
					vec1[3]=vec[2];
					vec1[1]=vec[1];
					vec1[6]=vec[6];
					z=z+vec1[1];
				}
				if(str=="Right"){
					vec1[2]=vec[3];
					vec1[3]=vec[5];
					vec1[5]=vec[4];
					vec1[4]=vec[2];
					vec1[1]=vec[1];
					vec1[6]=vec[6];
					z=z+vec1[1];
				}
			}
		}
		std::cout<<z<<std::endl;
		z=1;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  vector<ll> p(n);
  for(int i = 0;i < n;i++)cin >> p[i],p[i]--;
  vector<ll> a(n);
  vector<ll> b(n);
  ll add = 40000;
  for(int i = 0;i < n;i++){
    a[i] += add * i + 1;
    a[p[i]] += i + 1;
    b[n - i - 1] = add * i + 1;
  }
  for(int i = 0;i < n;i++)cout << a[i] << " ";
  cout << endl;
  for(int i = 0;i < n;i++)cout << b[i] << " ";
  cout << endl;
}

Measured memory_bytes: 1152
//
//  main.cpp
//  backToProblemSolving
//
//  Created by Khaled Abdelfattah on 6/27/17.
//  Copyright © 2017 Khaled Abdelfattah. All rights reserved.
//

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

typedef long long ll;
#define MAX 1000000000
#define BASE1 23
#define BASE2 31
#define MOD1 1000000007
#define MOD2 217645177
#define eps 1e-6

int n, m, r, visit[9], res = INT_MAX;
ll adjMatrix[201][201];

void floyed_warshall () {
    for (int k = 1; k <= n; k++)
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= n; j++)
                adjMatrix[i][j] = min(adjMatrix[i][j], adjMatrix[i][k] + adjMatrix[k][j]);
}

int main() {
    cin >> n >> m >> r;
    for (int i = 1; i <= r; i ++)
        cin >> visit[i];
    sort(visit + 1, visit + r + 1);
    for (int i = 1; i <= n; i ++) {
        for (int j = 1; j <= n; j ++)
            adjMatrix[i][j] = INT_MAX;
        adjMatrix[i][i] = 0;
    }
    for (int i = 0; i < m; i ++) {
        int u, v, c;
        cin >> u >> v >> c;
        if (c < adjMatrix[u][v])
            adjMatrix[u][v] = adjMatrix[v][u] = c;
    }
    floyed_warshall();
    do {
        int flag = 0;
        for (int i = 1; i <= r - 1; i ++)
            flag += adjMatrix[visit[i]][visit[i + 1]];
        res = min(res, flag);
    } while (next_permutation(visit + 1, visit + r + 1));
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define X first
#define Y second
#define mp make_pair
using namespace std;
typedef pair<int,int> PII;
const int N = 10010;
vector<int> v[N*8];
int n,f[N*2],g[N*2];
PII a[N<<1];
struct Point {
	int l,r;
}p[N*8];
void build(int x,int l,int r){
	//cout<<x<<' '<<l<<' '<<r<<endl;
	p[x].l = l, p[x].r = r;
	if(l==r){
		g[l] = x;
		return ;
	}
	int mid = (l+r)>>1;
	build(x<<1,l,mid), build(x<<1|1,mid+1,r);
}
void make(int x){
	int t1,t2;
	for(int i=p[x].l;i<=p[x].r;i++){
		v[x].push_back(g[f[a[i].Y^1]]);
	}
	if(p[x].l==p[x].r) return ;
	make(x<<1),make(x<<1|1);
}
void upd(int x,int l,int r,int t){
	if(l==p[x].l && r==p[x].r){
		if(l<r) v[t].push_back(x);
		else v[t].push_back(g[f[a[l].Y^1]]);
		return ;
	}
	int mid=p[x].l+p[x].r>>1;
	if(r<=mid) upd(x<<1,l,r,t);
	else if(l>mid) upd(x<<1|1,l,r,t);
	else upd(x<<1,l,mid,t),upd(x<<1|1,mid+1,r,t);
}
bool mark[N*8];
int c,s[N*8];
bool dfs(int x){
	if(mark[x]) return true;
	if(p[x].l==p[x].r){
		int t =p[x].l;
		if(mark[g[f[a[t].Y^1]]]) return false;
	}
	mark[x]=true;
	s[++c]=x;
	for(int i=0;i<v[x].size();i++){
		if(!dfs(v[x][i])) return false;
	}
	return true;
}
bool test(){
	int t0,t1;
	memset(mark,false,sizeof(mark));
	for(int i=0;i<n;i++){
		t0 = g[f[i<<1]],t1 = g[f[i<<1|1]];
		if(!mark[t0] && !mark[t1]){
			c = 0;
			if(!dfs(t0)){
				while(c) mark[s[c--]]=false;
				if(!dfs(t1)) return false; 
			}
		}
	}
	return true;
}
bool check(int dis){
	int l = 0,r = 0;
	int bound = n<<1;
	for(int i=0;i<bound;i++) v[g[i]].clear();
	for(int i=0;i<bound;i++){
		while(l<i && a[l].X+dis<=a[i].X) l++;
		while(r+1<bound && a[r+1].X-dis<a[i].X) r++;
		//cout<<l<<' '<<r<<endl;
		if(r>i) upd(1,i+1,r,g[i]);
		if(l<i) upd(1,l,i-1,g[i]);
	}
	return test();
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		a[i<<1] = mp(x,i<<1);
		a[i<<1|1] = mp(y,i<<1|1);		
	}
	sort(a,a+(n<<1));
	for(int i=0;i<n<<1;i++) f[a[i].Y]=i;
	build(1,0,2*n-1);
	make(1);

	int l = 0,r = 1e9;
	//cout<<check(3)<<endl;
	
	while(l<r){
		//cout<<l<<' '<<r<<endl;
		int mid = (l+r+1)>>1;
		if(check(mid)) l = mid; else r = mid-1;
	}
	
	printf("%d\n",l);
	return 0;
}
/*
2
1 2
3 4
*/

Measured memory_bytes: 11904
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

class DPowerfulDiscountTickets {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int n,m,a;
        in>>n>>m;
        priority_queue<int> pq;
        fr(i,n) in>>a,pq.push(a);
        fr(i,m){
            a=pq.top();pq.pop();
            a>>=1;
            pq.push(a);
        }
        ll ans=0;
        while(!pq.empty()) ans+=pq.top(),pq.pop();
        out<<ans<<endl;
    }
};

int main() {
    DPowerfulDiscountTickets solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 892