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

using namespace std;

using ll = long long;

template <typename T> class CumulativeSum { // 累積和　1-indexed
  std::vector<T> _sums;

public:
  CumulativeSum(const vector<T> &v) : _sums(v) {
    _sums.insert(_sums.begin(), 0);
    for (int i = 1; i < (int)_sums.size(); ++i) {
      _sums[i] += _sums[i - 1];
      // cout << _sums[i] << endl;
    }
  }
  T sum(int index) { return _sums[index]; }
  T sum(int left, int right) { return sum(right - 1) - sum(left - 1); }
};

int main() {
  ll L, N;
  cin >> L >> N;
  vector<ll> x(N + 1);
  ll pre = 0;
  for (int i = 0; i < N; ++i) {
    ll b;
    cin >> b;
    x[i] = b - pre;
    pre = b;
    if (i == N - 1) {
      x[N] = L - pre;
    }
  }
  //はじめに反時計回り
  ll ans = 0;
  int cnt = N;
  for (int i = 0, j = N; i <= j; ++i, --j) {
    ans += x[i] * cnt;
    --cnt;
    if (i == j)
      break;
    ans += x[j] * cnt;
    --cnt;
  }
  CumulativeSum<ll> sm(x);
  // cout << sm.sum(1, N + 2) << endl;
  ;
  ll as = ans;
  for (int i = 1; i <= N; ++i) {
    int k = (N + 1 - i) / 2;
    // cout << sm.sum(0, i + 1) << endl;
    as = max(as, ans += -sm.sum(1, i + 1) + sm.sum(i + 1, i + 1 + k) -
                        sm.sum(N + 2 - k, N + 2));
    // cout << ans << endl;
  }
  //はじめに時計回り
  reverse(x.begin(), x.end());
  ll ans1 = 0;
  cnt = N;
  for (int i = 0, j = N; i <= j; ++i, --j) {
    ans1 += x[i] * cnt;
    --cnt;
    if (i == j)
      break;
    ans1 += x[j] * cnt;
    --cnt;
  }
  CumulativeSum<ll> sm1(x);
  ll as1 = ans1;
  for (int i = 1; i <= N; ++i) {
    int k = (N + 1 - i) / 2;
    as1 = max(as1, ans1 += -sm1.sum(1, i + 1) + sm1.sum(i + 1, i + 1 + k) -
                           sm1.sum(N + 2 - k, N + 2));
  }
  cout << max(as, as1) << endl;
}

Measured memory_bytes: 7908
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    int N, K;
    cin >> N >> K;

    ll ans = 0;
    FOR(b, 1, N + 1) {
        ans += (N / b) * (max(0, b - K)) + max(0, N - N / b * b - K + 1);
    }
    if (K == 0)
        ans = (ll)N * N;
    print(ans);

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

const string KEY = "keyence";

string S;
int N;

void MAIN() {
    cin >> S;
    bool yes = false;
    if (S.size() >= KEY.size()) {
	REP (a, KEY.size()+1) {
	    int b = KEY.size() - a;
	    if (KEY == S.substr(0, a) + S.substr(S.size()-b)) {
		yes = true;
		break;
	    }
	}
    }
    puts(yes?"YES":"NO");
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 10000000000;
const ll MOD = 1000000007;

using namespace std;

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

int main() {
	ll n, x; cin >> n >> x;

	vector<ll>a(n);
	rep(i, n)cin >> a[i];

	sort(a.begin(), a.end());

	ll sum = 0;
	rep(i, n)sum += a[i];
	bool exceed = false;
	if (sum < x) {
		exceed = true;
	}


	ll count = 0;
		for (int i = 0; i < n; i++) {
			if (x >= a[i]) {
				x = x - a[i];
				count++;
			}
		}
		if (exceed == true) {
			cout << count - 1 << endl;
	}
		else {
			cout << count << endl;
		}
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = map(int, input().split())
A = [a - 1 for a  in A]

visit = [0] * N
turn = [-1] * N

visit[0] = 1
turn[0] = 0

cursor = 0
turn_count = 0
while True:
    cursor = A[cursor]
    turn_count += 1

    if turn_count == K:
        print(cursor+1)
        exit()

    visit[cursor] += 1

    if visit[cursor] > 1:
        loop_length = turn_count - turn[cursor]
        break

    turn[cursor] = turn_count

K -= turn[cursor]
K %= loop_length

for _ in range(K):
    cursor = A[cursor]

print(cursor + 1)

Measured memory_bytes: 32348
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N; i >= 0; i--)
#define PI 3.1415926535

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;}

char upper(char c){
    if('a' <= c && c <= 'z'){
        c = c - ('a' - 'A');
    }
    return c;
}

char lower(char c){
    if('A' <= c && c <= 'Z'){
        c = c + ('a' - 'A');
    }
    return c;
}

const ll INF = 1000000000000000000;

//input
ll N,K;

//processing


//dpTable
int dp[100050];

int main(){
    cin >> N >> K;
    cout << min(N % K,K - N % K) << endl;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int[] point = new int[5];
		int k;
		String ans = "Yay!";

		//入力
		for(int i=0; i<point.length; i++) {
			point[i] = sc.nextInt();
		}
		k = sc.nextInt();

		cmp: for(int i=0; i<point.length; i++) {
			for(int j=i+1; j<point.length; j++) {
				int p = point[i];
				int q = point[j];
				if((q-p) > k) {
					ans = ":(";
					break cmp;
				}
			}
		}

		System.out.println(ans);

		sc.close();
	}
}

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

int main(){
    int r,c;
    cin>>r>>c;
    int a[r][c];

    for(int h=0;h<r;h++){
        for(int w=0;w<c;w++){
            cin>>a[h][w];
        }
    }

    for(int h=0;h<r;h++){
        int sum=0;
        for(int w=0;w<c;w++){
            cout<<a[h][w]<<" ";
            sum+=a[h][w];
        }
        cout<<sum<<endl;
    }

    int finSum=0;
    for(int w=0;w<c;w++){
        int sum=0;
        for(int h=0;h<r;h++){
            sum+=a[h][w];
        }
        cout<<sum<<" ";
        finSum += sum;
    }

    cout<<finSum<<endl;

    return 0;
}


Measured memory_bytes: 3132
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
def Dijkstra(graph,s):
    INF = 10**9
    dist = [INF]*len(graph)
    dist[s] = 0
    #nn_node = [-1]*len(graph) #nearest neighborのnode
    #checked=[False]*len(graph) #dist 確定
    heap = [(0,s)]
    while heap:
        cost,node = hq.heappop(heap)
        if cost>dist[node]:continue
        for weight,nex in graph[node]:
            d = cost+weight
            if d<dist[nex]:
                dist[nex] = d
                #nn_node[nex] = node
                hq.heappush(heap,(d,nex))
    for i in range(len(dist)):
        if dist[i] == INF:
            dist[i] = -1
    return dist #,nn_node

dyx = [(-1,0),(1,0),(0,1),(0,-1)]
INF=10**9
H,W = ma()
ch,cw = ma()
ch-=1;cw-=1
dh,dw=ma()
dh-=1;dw-=1
area= []
for h in range(H):
    area.append(input())

group = [[-1]*W for h in range(H)]
def BFS(sy,sx,idx):
    que = collections.deque()
    que.append((sy,sx))
    group[sy][sx]=idx
    while que:
        h,w = que.popleft()
        for dy,dx in dyx:
            if (0<=h+dy<H )and (0<=w+dx<W):
                if area[h+dy][w+dx] =="." and group[h+dy][w+dx] ==-1:
                    group[h+dy][w+dx] = idx
                    que.append((h+dy,w+dx))


idx = 0
for h in range(H):
    for w in range(W):
        if area[h][w] =="." and group[h][w] ==-1:
            BFS(h,w,idx)
            idx+=1
            #print(group)

tree = [set() for _ in range(idx)]
dyx2 = [(i,j) for i in range(-2,3) for j in range(-2,3)]
dyx2.remove((0,0))

for h in range(H):
    for w in range(W):
        if area[h][w]=="#":
            continue
        g = group[h][w]
        for dy,dx in dyx2:
            if (0<=h+dy<H )and (0<=w+dx<W) and (area[h+dy][w+dx]=="."):
                if (g !=group[h+dy][w+dx]):
                    tree[g].add((1,group[h+dy][w+dx]))
                    tree[group[h+dy][w+dx]].add((1,g))
dist = Dijkstra(tree,group[ch][cw])

#print(group)
#print(tree)
#print(dist)
print(dist[group[dh][dw]])


Measured memory_bytes: 140460
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")*/
#include"bits/stdc++.h"
#define int ll
using namespace std;
using ll = long long ;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20)
//#define endl '\n'
///       Author
///        ::
///    (  NOBODY  )
///   No Copyright .....You can copy and paste it without my permission...................................
/// !!!!!!!!!!!!!!!
#define pb push_back
#define N 1000020
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
typedef pair<int,int> ii;
void scan(vector<int>&v,int siz)
{
    v.resize(siz);
    for(auto &c:v)
        cin>>c;
}
void print(vector<ll>v)
{
    for(auto c:v)
        cout<<c<<' ';
    cout<<endl;
}
void view(deque<int>v)
{
    for(auto c:v)
        cout<<c<<' ';
    cout<<endl;
}
int fenwik[N];
void update(int pos,int val)
{
    while(pos<N)
    {
        fenwik[pos]+=val;
        pos+=(pos&(-pos));
    }
}
int get(int pos)
{
    int ans=0;
    while(pos>0)
    {
        ans+=fenwik[pos];
        pos-=(pos&(-pos));
    }
    return ans;
}
int a[N],mod=1e9+7;
int goy(int base,int pow)
{
    base%=mod;
    if(pow==0)return 1;
    int x=goy(base,pow/2);
    x=(x*x)%mod;
    if(pow%2)x=(base*x)%mod;
    return x;
}
multimap<int,int>mp;
vector<pair<int,int>>Get_all(int key)
{
    vector<pair<int,int>>vv;
    typedef multimap<int, int>::iterator MMAPIterator;
    pair<MMAPIterator, MMAPIterator> result = mp.equal_range(1);
    for (MMAPIterator it = result.first; it != result.second; it++)vv.push_back( {it->ff,it->ss});
    return vv;
}
int n,m;
int dp[21][1001];
int go(int pos,int bef)
{
    if(pos==m)return 1;
    if(dp[pos][bef]!=-1)return dp[pos][bef];
    int ans=0;
    for(int i=bef; i<=n; i++)
    {
        ans+=go(pos+1,i);
        ans%=mod;
    }
    return dp[pos][bef]=ans;
}
int32_t main()
{
    FAST_IO;
    int n;
    cin>>n;
    for(int i=1; i<=n; i++)cin>>a[i];
    int mn=a[1];
    int po=1,ans=1;
    for(int i=2;i<=n;i++)
    {
        if(a[i]<mn){
            ans++;
            mn=a[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle
using ll = long long ;
int main() {
    int n, w;
    cin >> n >> w;

    ll a[n][2];
    for(int i = 0; i < n; i++) {
        cin >> a[i][0] >> a[i][1];
    }

    ll dp[n+1][w+1];
    memset(dp, 0, sizeof(dp));

    for(int j = 0; j <= w; j++)
        dp[1][j] = (j >= a[0][0] ? a[0][1] : 0 );

    for(int i = 2; i <= n; i++)
        for(int j = 0; j <= w; j++) {
            if(j >= a[i-1][0]) 
                dp[i][j] = max(dp[i-1][j], a[i-1][1] + dp[i-1][j-a[i-1][0]]);
            else
                dp[i][j] = dp[i-1][j];    
        }

    cout << dp[n][w];       
    return 0;
}

Measured memory_bytes: 79104
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s=sc.next();
        for (int i = 0; i < s.length(); i+=2) {
            System.out.print(s.charAt(i));
        }
        System.out.println("");
    }
}


Measured memory_bytes: 30548
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <vector>
#include <cmath>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>

using namespace std;

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

    int f = stoi(S.substr(0,2));
    int s = stoi(S.substr(2,2));

    if((1<=f && f<=12) && (1<=s && s<=12)){
        cout << "AMBIGUOUS" << endl;
    }else if(1<=f && f<=12){
        cout << "MMYY" << endl;
    }else if(1<=s && s<=12){
        cout << "YYMM" << endl;
    }else{
        cout << "NA" << endl;
    }

    return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<math.h>
#include<cstring>
#include<set>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>
#include<string>
#include<ctime>
//#include "optimization.h"
#include<bitset>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
typedef long long ll;
using namespace std;
const int N =  3e5 +100;
ll INF = (1LL << 62) - 1;
ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    s += '#';
    for(int i= 0; i < s.size()-  1; i++)
    {
        if(s[i] == 'A' && s[i+1] == 'C' )
        {
         cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}

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

int  main()
{
  int n,k,sum,ans;
  sum=0;
  cin>>n>>k;
  ans=n;
  vector<int> d(k);
  vector<int> a;
  for(int i=0;i<k;i++)
  {
    cin>>d.at(i);
    sum+=d.at(i);
    vector<int> b(d.at(i));
    for(int j=0;j<d.at(i);j++)
    {
      cin>>b.at(j);
      a.push_back(b.at(j));
    }
  }
  for(int i=1;i<=n;i++)
  {
    for(int j=0;j<sum;j++)
    {
      if(a.at(j)==i)
      {
        ans--;
        break;
      }
    }
  }
  cout<<ans<<endl;
}

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

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);	

	double d, t, s;
  	cin >> d >> t >> s;
  	if(d/s <= t)
      	cout << "Yes";
  	else
      	cout << "No";

	return 0;
}


Measured memory_bytes: 3716
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
int main(){
	
	int n;
	cin>>n;
	if(n==1)cout<<"Hello World"<<endl;
	else {
		int a,b;
		cin>>a>>b;
		cout<<a+b<<endl;
	}
	
	
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 8
#define FREE -1
#define NOT_FREE 1
#define true 1
#define false 0

void putQueen(int);
void printBoard();
void initialize();

int k,M[N][N];
int row[N],col[N],dpos[2*N-1],dneg[2*N-1];

int main(){
  int i,j,a,b;
  
  scanf("%d",&k);
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      M[i][j]=false;
    }
  }

  for(i=0;i<k;i++){
    scanf("%d%d",&a,&b);
    M[a][b]=true;
  }
  putQueen(0);
 
  return 0;
}


void putQueen(int i){
  int j;
  
  if(i == N){
    printBoard();
    return;
  }
  for(j=0;j<N;j++){
    if(col[j] == NOT_FREE ||
       dpos[i+j] == NOT_FREE || dneg[i-j+N-1] == NOT_FREE)
      continue;
  
    // put a queen at (i, j)
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
    // try the next row
    putQueen(i+1);
    // remove the queen at (i, j) for backtracking
    row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
  }
}

void printBoard(){
  int i,j;

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(M[i][j]){
	if(row[i]!=j) return;
      }
    }
  }
  //printf("test\n");
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
     printf((row[i] == j)? "Q": ".");
      
    }
    printf("\n");
  }
}

void initialize(){
  int i,j;
  for(i=0;i<k;i++){
    row[i]=FREE;
    col[i]=FREE;
  }

  for(j=0;j<k;j++){
    dpos[j]=FREE;
    dneg[j]=FREE;
  }
}
      
      



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

using namespace std;

const int N = 1001010;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, x; cin >> n >> x;
  vector<int> v(n);
  long long sum = 0;
  int mn = 1e9;
  for(int i = 0; i < n; ++i) {
    cin >> v[i];
    mn = min(mn, v[i]);
    sum += v[i];
  }
  
  cout << n + (x - sum) / mn << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
	int n;
  	cin>>n;
  	int sum = 0;
  	for(int i=1;i<=n;i++){
    	if(i%5!=0&&i%3!=0){
        	sum = sum+i;
        }
    }
  	cout<<sum;
return 0;
}
  

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

using namespace std;

typedef unsigned long long ll;

ll f(int h)
{
    if(h==1) return 1;

    return (1+2*f(h/2)) ;
}
int main()
{
    int   n ;
    cin >> n ;
    int a[n];
    for(int i=0;i<n;i++)
        cin >> a[i];
    sort(a,a+n);
    int a1=a[(n-1)/2+1];
    int a2=a[(n-1)/2];
    if(a1-a2) cout << a1-a2;
    else cout << 0;
    return 0;
}



Measured memory_bytes: 640
fun ans(a: Int, b: Int): Int {
    return (a + b) / 2
}

fun main(args: Array<String>) {
    val n = readLine()!!.split(" ")
    val a = n[0].toInt()
    val b = n[1].toInt()
    if ((a + b) % 2 == 1) {
        println("IMPOSSIBLE")
    } else {
        println(ans(a, b))
    }
}


Measured memory_bytes: 37972
#include <iostream>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <cstring>
#include <string.h>
#include <sstream>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
 
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const ll MOD = 1e9+7;
const double PI  = 3.14159265358;
const double EPS = 1e-8;

#define INT_MX 2147483647
#define INF ((int)1e9)
#define LLINF ((ll)1e18)
#define F first
#define S second
#define MP(x,y) make_pair(x,y)
#define sz(v) ((int)v.size())
#define rs(n) resize(n)
#define ALL(v) v.begin(),v.end()
#define reset(v) memset((v),0,sizeof(v))
#define EB emplace_back
#define PB push_back
#define PF push_front
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define vec vector
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

void solve(){
    string s;
    bool b[30];
    
    reset(b);
    cin >> s;
    for(auto i:s)
        b[i - 'a'] = true;
    
    rep(i,26) if(b[i] == false){
        cout << char(i + 'a') << '\n';
        return ;
    }
    cout << "None\n";
}

int main(){
    IOS;
    
    solve();
}





Measured memory_bytes: 512
#include<stdio.h>

int main(){
	int a,b,c;
	
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	
	if(a==b && b==c && c==a){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	
	
	return 0;
}



Measured memory_bytes: 128
#include<iostream>
using namespace std;
long long a, b, c, d;
long long gcd(long long a1, long long a2) {
	if (a2 == 0)return a1;
	return gcd(a2, a1%a2);
}
int main() {
	cin >> a >> b >> c >> d;
	c -= a; d -= b;
	if (c < 0)c *= -1; if (d < 0)d *= -1;
	long long f = gcd(c, d);
	c /= f; d /= f;
	cout << (c + d - 1) *f << endl;
	return 0;
}

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

int main(){
  int N,Y,c1,c2,c3,tmp;

  cin >> N >> Y;
  c1 = Y / 10000;

  for (int i = c1; i >= 0; i--){
    tmp = Y - i * 10000;
    c2 = tmp / 5000;
    for (int j = c2; j >= 0; j--){
      tmp = Y - i * 10000;
      tmp = tmp - j * 5000;
      c3 = tmp / 1000;
      if ((i + j + c3) == N){
        cout << i << " " << j << " " << c3 << endl;
        return 0;
      }
    }
  }
  
  cout << "-1 -1 -1" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        long w = sc.nextLong();
        long h = sc.nextLong();
        long x = sc.nextLong();
        long y = sc.nextLong();
        
        int answer2 = 0;
        
        if (x * 2 == w && y * 2 == h) {
            answer2 = 1;
        }
        
        double answer = (double)w / 2 * h;
        
        // if (x == 0 && y == 0) {
        //     answer2 = 1;
        // } else if (x == w && y == h) {
        //     answer2 = 1;
        // }
        // 899999999999
        // 1000000000
        //  999999999
        
        System.out.println(answer + " " + answer2);
    }
}


Measured memory_bytes: 21204
#include<stdio.h>
#include<algorithm>
using namespace std;
#define MAX 100000

int L[MAX], a[MAX];
int n;

void dp() {
    int length = 1;
    L[0] = a[0];

    for (int i=1; i<n; i++) {
        if (L[length-1]<a[i]) L[length++] = a[i];
        else {
            *lower_bound(L, L+length, a[i]) = a[i];
        }
    }

    printf("%d\n", length);
}

int main() {
    scanf("%d", &n);

    for (int i=0; i<n; i++) {
        scanf("%d", &a[i]);
    }

    dp();

    return 0;
}


Measured memory_bytes: 3340
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
     int a,b;
     cin >> a;
     
     cin >> b;
    
      cout << a*b;
      cout <<" ";
      cout << 2*a+2*b;
      cout <<endl;
     
     
    
    
}



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, m; scanf("%d%d", &n, &m);
	std::vector<std::vector<int>> g(n);
	for(int i = 0; i < m; i++) {
		int a, b; scanf("%d%d", &a, &b);
		
		g[a - 1].push_back(b - 1);
	}
	int s, t; scanf("%d%d", &s, &t); s--; t--;
	
	auto min_cost = make_v<int>(n, 4);
	for(auto &w: min_cost) for(auto &v: w) v = 1 << 30; min_cost[s][0] = 0;
	std::queue<std::pair<int, std::pair<int, int>>> qu; qu.push({s, {3, 1}});
	while(!qu.empty()) {
		auto p = qu.front(); qu.pop();
		
		for(auto e: g[p.first]) {
			int c = p.second.first - 1;
			if(min_cost[e][c] <= p.second.second) continue;
			min_cost[e][c] = p.second.second;
			if(c == 0) qu.push({e, {3, p.second.second + 1}});
			else qu.push({e, {c, p.second.second}});
		}
	}
	
	if(min_cost[t][0] == 1 << 30) printf("-1\n");
	else printf("%d\n", min_cost[t][0]);
	return 0;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
#include<string>
#include<cmath>

using namespace std;

#define ll long long int
#define ld long double
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,m;
    cin>>n>>m;
    ll a[n];
    for(int i = 0; i < n; i++){
        cin>>a[i];
    }
    pair<ll,ll> b[m];
    for(int i = 0; i < m; i++){
        int x , y;
        cin>>x>>y;
        b[i].first = y;
        b[i].second = x;
    }
    sort(a , a + n);
    sort(b , b + m);
    int i = 0, j = m - 1;
    while(i < n && j >= 0){
        if(b[j].second > 0){
            if(a[i] < b[j].first){
                a[i] = b[j].first;
                b[j].second--;
                i++;
            }else{
                j--;
            }
        }else{
            j--;
        }
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += a[i];
    }
    cout<<ans;
}

Measured memory_bytes: 5936
import numpy as np
n, m = map(int, input().split())

mat = [[0] * n] * n
mat = np.array(mat)

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

    mat[a - 1, b - 1] += 1
    mat[b - 1, a - 1] += 1


# print(mat)
for i in range(n):
    ans = np.sum(mat[i, :])
    print(ans)


Measured memory_bytes: 12384
#include <bits/stdc++.h>
#define x first
#define y second


using namespace std;

const int mx = 112345;

vector<int> adj[mx];

int in[mx], dp[mx];

int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    adj[b].push_back(a);
    in[a]++;
  }
  queue<int> q;
  for (int i = 0; i < n; i++) if (!in[i]) q.push(i);
  while(!q.empty()) {
    int v = q.front();
    q.pop();
    for (auto u : adj[v]) {
      dp[u] = max(dp[u], 1+dp[v]);
      if(!--in[u]) q.push(u);
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) ans = max(ans, dp[i]);
  cout << ans << endl;
}


Measured memory_bytes: 6784
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#define lint long long
#define mod 924844033
#define N 2010
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define debug(x) cerr<<#x<<"="<<x
#define sp <<" "
#define ln <<endl
using namespace std;
int f[2][N][N][2],g[N][N],s[2][N][N],fac[N];
inline int sol(lint x,int s) { return x%=mod,((s&1)?(x?mod-x:0):x); }
inline int getf(int n,int a,int f[N][N][2],int s[N][N])
{
	f[1][1][0]=a,f[1][1][1]=1;
	s[0][0]=1,s[1][0]=1,s[1][1]=1+a;
	for(int i=2;i<=n;i++)
	{
		s[i][0]=1,f[i][0][0]=f[i][0][1]=0;
		for(int j=1;j<=i;j++)
			f[i][j][0]=(s[i-2][j-1]+f[i-1][j-1][0])%mod,
			f[i][j][1]=s[i-1][j-1],
			s[i][j]=(1ll*s[i-1][j]+f[i][j][0]+f[i][j][1])%mod;
	}
	return 0;
}
inline int getabl(int r,int n,int k,int &a,int &b,int &l)
{	return a=(r>k),l=(n-r)/(2*k)+1,b=((2*l-1)*k+r<=n);	}
inline int F(int f[N][N][2],int s[N][N],int l,int b,int t)
{	if(b) return s[l][t];return (s[l-1][t]+f[l][t][0])%mod;	}
int main()
{
	int n,k,mxL,ans=0;scanf("%d%d",&n,&k),mxL=(n-1)/(2*k)+1;
	getf(mxL,0,f[0],s[0]),getf(mxL,1,f[1],s[1]),g[0][0]=1;
	rep(i,0,min(n,2*k)-1)
	{
		int a,b,l;getabl(i+1,n,k,a,b,l);
		rep(j,0,n) if(g[i][j]) rep(t,0,min(n-j,l))
			(g[i+1][j+t]+=1ll*g[i][j]*F(f[a],s[a],l,b,t)%mod)%=mod;
	}
	for(int i=fac[0]=1;i<=n;i++) fac[i]=(lint)fac[i-1]*i%mod;
	for(int i=0;i<=n;i++) (ans+=sol(1ll*fac[n-i]*g[min(n,2*k)][i],i))%=mod;
	return !printf("%d\n",ans);
}

Measured memory_bytes: 54656
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void)
{
	int h, m, s;

	scanf("%d", &s);

	m = s / 60;
	s %= 60;

	h = m / 60;
	m %= 60;

	printf("%d:%d:%d\n", h, m, s);

	return 0;
}


Measured memory_bytes: 2136
#include<iostream>
#include<cstdio>
using namespace std;
long long n;
int c,a[20],ans,f[20][20];
void dfs(int w,int sum,int lm)
{
	if(!w)
	{
		ans=max(ans,sum);
		return;
	}
	if(!lm)
	{
		dfs(w-1,sum+9,0);
		return;
	}
	dfs(w-1,sum+a[w],1);
	if(a[w]!=0)
		dfs(w-1,sum+a[w]-1,0);
}
int main()
{
	scanf("%lld",&n);
	while(n)
	{
		a[++c]=n%10;
		n/=10;
	}
	for(int i=0;i<20;i++)
		for(int j=0;j<20;j++)
			f[i][j]=-1;
	dfs(c+1,0,1);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }


using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N;
    map<string, int> m;
    string res;
    map<string, int>::iterator ite;
    rep(i, N){
        cin >> res;
        ite = m.find(res);
        if (ite == m.end()) m.insert(make_pair(res, 1)) ; else m[res]++;
    }
    cin >> M;
    rep(i, M){
        cin >> res;
        ite = m.find(res);
        if (ite != m.end()) m[res]--;
    }
    int ans = 0;

    for (ite = m.begin(); ite != m.end(); ++ite) {
      chmax(ans, ite->second);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
const int N=1000+10;
const int mod=1e9+7;
int n,m,f[N][N],a[N][N];
char s[N];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s+1);
		for(int j=1;j<=m;j++)
			if(s[j]=='.')a[i][j]=1;
	}
	f[0][1]=a[0][1]=1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			f[i][j]=a[i][j]*(f[i-1][j]*a[i-1][j]+f[i][j-1]*a[i][j-1])%mod;
	printf("%d",f[n][m]);
	return 0;
}


Measured memory_bytes: 8064
#include <iostream>

using namespace std;

 
int main() {
  int A,B,C;
  cin >> A >> B >> C;
 
 if((A == B && B != C )||(B == C && C != A)||(A == C && C != B)){
     cout << "Yes" << endl;
 }else{
     cout << "No" << endl;
 }
 
}

Measured memory_bytes: 256
import sys
# import numpy as np

def IL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

N, W = IL()
v_list = [0] * N
w_list = [0] * N
v = 0
w_total = 0
for i in range(N):
	w_list[i], v_list[i] = IL()
# dp = np.zeros((N+1, W+1))
dp = [[0] * (W+1) for _ in range(N+1)]
for i in range(N):
	for j in range(W+1):
		if j >= w_list[i]:
			dp[i+1][j] = max(dp[i][j-w_list[i]] + v_list[i], dp[i][j])
		else:
			dp[i+1][j] = dp[i][j]

print(dp[N][W])

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

int main(void)
{
	int i, j;
	int n;
	int num;
	char str[128];
	int ans;
	int len;
	
	ans = 0;
	while (fgets(str, 100, stdin) != NULL){
		n = 0;
		len = strlen(str);
		for (i = 0; i < len; i++){
			if (str[i] >= '0' && str[i] <= '9'){
				n++;
			}
			else {
				num = 0;
				for (j = 0; j < n; j++){
					num *= 10;
					num += str[i - n + j] - '0';
				}
				n = 0;
				ans += num;
			}
		}
	}
	printf("%d\n", ans);
	
	return (0);
}

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

int main() {
    int n = 0, ans = 0;
    scanf("%d", &n);
    if (n % 2 == 0) {
        ans = n / 2;
    }
    else {
        ans = n / 2 + 1;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>

using namespace std;
using ll = long long;
using ld = long double;

int main()
{
    ld n, m, d;
    cin >> n >> m >> d;


    ld r = ((n - d) * 2 * (m-1)) / (n*n);
    if(d < 1){
        r = ((n - d) * (m-1)) / (n*n);
    }

    cout <<  std::setprecision(17) << r << endl;


    return 0;
}

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

#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define all(x) x.begin(),x.end()
#define nl      '\n'

typedef long long int ll;
typedef unsigned long long int  llu;


int main()
{
	faster
	ll n,i,j,k;
	cin>>n;
	ll a[n+1];
	for(i=0;i<n;i++)cin>>a[i];
	ll ans=0;
	for(i=0;i<n-2;i++)
	{
		for(j=i+1;j<n-1;j++)
		{
			for(k=j+1;k<n;k++)
			{
				ll mx=max(a[i],max(a[j],a[k]));
				ll sum=a[i]+a[j]+a[k]-mx;
				if(a[i]!=a[j]&&a[i]!=a[k]&&a[j]!=a[k])
				{
					if(sum>mx)
					{
						ans++;
						//cout<<a[i]<<" "<<a[j]<<" "<<a[k]<<" "<<sum<<" "<<mx<<" "<<ans<<endl;

					}
				}
			}
		}
	}
	cout<<ans<<nl;
	return 0;

}


Measured memory_bytes: 3648
distances = []
for i in range(5):
    distances.append(int(input()))
k = int(input())

ans = 'Yay!'
for i in range(len(distances) - 1):
    for j in range(i + 1, len(distances)):
        if k < abs(distances[i] - distances[j]):
            ans = ':('
            
print(ans)

Measured memory_bytes: 3060
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, M = map(int, readline().split())
    print((N-1)*(M-1))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int X = sc.nextInt();
    	int Y = sc.nextInt();
    	int Z = sc.nextInt();
    	sc.close();
    	int ans = 0;
    	if(X * Z <= Y) ans = Z;
    	else ans = Y / X;
    	System.out.println(ans);
    }
}

Measured memory_bytes: 21972
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string S; cin >> S;
    int N = S.size();
    vector<int> A(3);
    rep(i,N) A[S[i] - 'a']++;
    bool ok = true;
    rep(i,3) {
        if (A[i] < N/3 || A[i] > (N+2)/3) ok = false;
    }

    cout << (ok ? "YES" : "NO") << endl;
}


Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    string s;
    cin >> s;
    if (s[1] == 'B')
        s[1] = 'R';
    else
        s[1] = 'B';
    cout << s;
    return 0;
}

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

template <class T>
T gcd(T a, T b) {
  if (a && b) {
    return gcd(min(a, b), max(a, b) % min(a, b));
  } else {
    return a;
  }
}

template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}

int main() {
  int N;
  ll M;
  cin >> N >> M;
  ll LCM = 1;
  vector<ll> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < N; i++) {
    LCM = lcm(LCM, a[i] / 2);
    if (LCM > M) {
      cout << 0 << endl;
      return 0;
    }
  }
  for (int i = 0; i < N; i++) {
    if ((LCM * 2 / a[i]) % 2 == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  M /= LCM;
  cout << (M + 1) / 2 << endl;
}


Measured memory_bytes: 3976
#include <iostream>
             
            using namespace std;
             
            int main(void){
            	int N;
              	cin >> N;
              	if(N==1||N==2||N==3||N==5||N==6||N==9||N==10||N==13||N==17){
                	cout << "No" << endl;
                } else {
                	cout << "Yes" << endl;
                }
            }

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    map<string, ll> m;
    ll n;
    cin >> n;
    vector<string> z(n);
    for (int i = 0; i < n; i++) {
        cin >> z[i];
        m[z[i]]++;
    }
    ll d;
    cin >> d;
    for (int i = 0; i < d; i++) {
        string f;
        cin >> f;
        m[f]--;
    }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ans = max(m[z[i]], ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3584
n,c = map(int,raw_input().split())

D = []
C = []

for a in range(c):
  D.append( map(int,raw_input().split()) )

for a in range(n):
  C.append( map(int,raw_input().split()) )

cs = [[] for j in range(3)]

for x in range(n):
  for y in range(n):
    cs[ (x+y) % 3 ].append(C[x][y])

c0 = [-1]
c1 = [-1]
c2 = [-1]

for x in range(1,c+1):
  buf = 0
  for y in cs[0]:
    buf += D[y-1][x-1]
  c0.append(buf)

for x in range(1,c+1):
  buf = 0
  for y in cs[1]:
    buf += D[y-1][x-1]
  c1.append(buf)

for x in range(1,c+1):
  buf = 0
  for y in cs[2]:
    buf += D[y-1][x-1]
  c2.append(buf)

ans = 10**100

for x in range(1,c+1):
  for y in range(1,c+1):
    if x == y:continue
    for z in range(1,c+1):
      if x == z or y == z:continue

      if ans > c0[x]+c1[y]+c2[z]:
        ans = c0[x]+c1[y]+c2[z]

print ans



Measured memory_bytes: 8716
import java.util.Scanner;

//解説を参考
public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();

        int[] a = new int[1000001];
        a[1] = 7 % k; //初項
        
        int f = 0;
        if (k % 2 != 0) {
            for (int i = 2; i <= k; i++)
                a[i] = (10 * a[i - 1] + 7) % k;

            for (int i = 1; i <= k; i++) {
                if (a[i] == 0) {
                    System.out.println(i);
                    f = 1;
                    break;
                }
            }
            if(f == 0) System.out.println(-1);
        } else
            System.out.println(-1);
    }

}


Measured memory_bytes: 39680
#include <bits/stdc++.h>
#define MAX 3010
using namespace std;

int P;
int arr[MAX];
int brr[MAX];
int poly[MAX];

inline int add(int a, int b)
{
	return (a + b) % P;
}

inline int prod(int a, int b)
{
	return a * b % P;
}

int main(void)
{
	cin >> P;
	for (int i = 0; i < P; i++)
	{
		int val;
		cin >> val;
		if (!val) continue;
		brr[P] = 1;
		for (int j = P; j > 0; j--)
		{
			arr[j - 1] = brr[j];
			brr[j - 1] = prod(brr[j], i);
			if (j == 2) brr[1] = add(brr[1], P - 1);
			brr[j] = 0;
		}
		for (int j = 0; j < P; j++) poly[j] = add(poly[j], P - arr[j]);
	}
	for (int i = 0; i < P; i++) cout << poly[i] << " ";
	cout << endl;
	return 0;
}


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

bool t[102][102];

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

  memset(t, 0, sizeof(t));

  for(int i = 0; i < m; i++){
    int x, y;
    cin >> x >> y;
    t[y][x] = true;
  }

  bool used[102];
  memset(used, 0, sizeof(used));

  vector<int> v;

  for(int i = 0; i < n - 1; i++){
    for(int j = 1; j <= n; j++){
      if(j == 2) continue;
      if(used[j]) continue;

      bool flg = true;

      for(int k = 1; k <= n; k++){
        if(j == k) continue;
        if(used[k]) continue;

        if(t[j][k]){
          flg = false;
          break;
        }
      }

      if(flg){
        used[j] = true;
        v.push_back(j);
        break;
      }
    }
  }
  v.push_back(2);

  for(int i = 0; i < v.size(); i++){
    cout << v[i] << endl;
  }
}

Measured memory_bytes: 1232
require 'matrix'

n, m, x = gets.split.map(&:to_i)
a = Matrix.zero(m + 1, n)
n.times do |i|
  b = gets.split.map(&:to_i)
  0.upto(m) do |j|
    a[j, i] = b[j]
  end
end
min = Float::INFINITY
[0, 1].repeated_permutation(n) do |bit|
  ans = 0
  sum = 0
  v = 0
  1.upto(m) do |j|
    v = Vector.elements(bit)
    sum = (a.row(j).covector * v)[0]
    break if sum < x
  end
  if sum >= x
    ans = (a.row(0).covector * v)[0]
    min = ans if min > ans
  end
end
puts (min == Float::INFINITY ? -1 : min)

Measured memory_bytes: 15168
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};


int main(){
    string A; cin>>A;
    ll N=A.size();
    vec d(N);
    vec D[26];
    rep(i,N) d.at(i)=A.at(i)-'a';
    vector<P> kireme;
    ll memory[26][2];
    rep(i,26) rep(j,2) memory[i][j]=-1;
    vec eachL[26], eachR[26];

    ll I=N-1, count=26, Kugiri=N;
    vector<bool> used(26,false);
    while(I>=0){
        ll k=d.at(I);
        if(used.at(k)) memory[k][0]=I;
        else{
            used.at(k)=true;
            memory[k][1]=I;
            memory[k][0]=I;
            count--;
            if(count==0){
                kireme.pb(mp(I,Kugiri));
                rep(j,26) eachL[j].pb(memory[j][0]);
                rep(j,26) eachR[j].pb(memory[j][1]);
                Kugiri=I;
                count=26;
                rep(j,26) used.at(j)=false;
            }
        }
        I--;
    }

    rep(i,26){
        reverse(ALL(eachL[i]));
        reverse(ALL(eachR[i]));
        reverse(ALL(kireme));
    }

    vec ans;
    rep(i,26) if(!used.at(i)){
        ans.pb(i);
        break;
    }

    rep(i,kireme.size()){
        int x=eachL[ans.at(i)].at(i);
        rep(j,26) if(eachR[j].at(i)<=x) {
            ans.pb(j);
            break;
        }
    }
    string ANS;

    rep(i,ans.size()) ANS.pb('a'+ans.at(i));
    cout<<ANS<<endl;






}



Measured memory_bytes: 5764