akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
long long int mod=1000000007;
struct modint{
    long long int x;
    modint(long long int x=0):x(x%mod){}//メンバ変数を初期化する。
    modint& operator+= (const modint a){
        if((x+=a.x)>=mod){x-=mod;}//%は遅い
        return *this;//関数を終了するためにはreturnを返さなければならないが、return aとでもするとその値が代入されてしまう。そこで、計算された後の自分自身のアドレス、つまり何もしないようにしている？
    }
    modint& operator-= (const modint a){
        if((x+=mod-a.x)>=mod) x-=mod;
        return *this;
    }
    modint& operator*= (const modint a){
        x*=a.x;
        x%=mod;
        return *this;
    }
    modint operator+(const modint a) const{//引数の横のconstは関数自体がconstつまりメンバ変数の変更ができなくなるということ。バグ防止に役立つ
        modint copy(*this);//constがあるのでメンバ変数をいじれないから値だけコピーする
        return copy+=a;
    }
    modint operator-(const modint a)const{
        modint copy(*this);
        return copy+=a;
    }
    modint operator*(const modint a)const{
        modint copy(*this);
        return copy*=a;
    }
    modint pow(long long int t)const{//繰り返し二乗法
        if(t==0) return 1;
        modint a=pow(t>>1);//tを1/2倍したものの累乗
        a*=a;//aを二乗する
        if(t&1) a*=*this;//ビット形式での一桁目が1、つまりtが奇数ならば、もう一回掛ける。
        return a;
    }
    modint inv() const{
        return pow(mod-2);
    }
    modint operator/=(const modint a){
        return (*this)*=a.inv();
    }
    modint operator/(const modint a){
        modint copy(*this);
        return copy/=a;
    }
};




//ここから
struct combination {
    vector<modint> fact,ifact;//階乗＝factoria
    combination(lli n):fact(n+1),ifact(n+1){//fact=階乗、ifactはその逆元
        fact[0]=1;//0!=1
        for(lli i=1;i<=n;i++) fact[i]=fact[i-1]*i;
        ifact[n]=fact[n].inv();//invは計算が重いので一回で済ませたい
        for(lli i=n;i>=1;i--) ifact[i-1]=ifact[i]*i;
    }
    modint operator()(lli n,lli k){
        if(k<0||k>n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};
int main(){
    lli n,l=0,r=0,ai;
    cin>>n;
    vi ans,ansc;
    rep(i,n+1){
        lli a;
        cin>>a;
        ans.push_back(a);
        ansc.push_back(a);
    }
    sort(all(ans));
    rep(i,n){
        if(ans[i]==ans[i+1]) {ai=ans[i];break;}

    }
    rep(i,n+1){
        if(l==0&&ansc[i]==ai){
            l=i+1;
        }
        else if(l!=0&&ansc[i]==ai){
            r=i+1;
        }
    }
    combination ans1(n+1),ans2(n+1);
    for(lli i=1;i<=n+1;i++){

        lli ans=ans1(n+1,i).x;
        lli Ans=ans2(l+n-r,i-1).x;
        lli AAns=ans-Ans;
        while(AAns<0){
            AAns+=mod;
        }
        AAns%=mod;
        out(AAns);
    }
}

Measured memory_bytes: 6124
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	nums := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&nums[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(nums)))

	var a, b int
	for i := 0; i < n; i++ {
		if i%2 == 0 {
			a += nums[i]
		} else {
			b += nums[i]
		}
	}
	fmt.Println(a - b)
}


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

int main(){
  int N;
  cin >> N;
  int L[N];
  for (int i=0; i < N; i++){
    cin >> L[i];
  }

  int Max = 0, sum = 0;
  for (int i=0; i < N; i++){
    if(Max < L[i]){
      Max = L[i];
    } 
    sum += L[i];
  }
  sum -= Max;
  if (Max < sum) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
bool chmax(T &a, const T &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int a, b;
  cin >> a >> b;
  cout << a * b << '\n';
  return 0;
}

Measured memory_bytes: 3636
#include<stdio.h> 
int main() {
    int a,b,i,j; 
    
    while(1) {
        scanf("%d%d",&a,&b);
        
        if(a==0&&b==0)
            break;
        
        for(i=1;i<=a;i++) {
            for(j=1;j<=b;j++) {
                if(i>1&&i<a&&j<b&&j>1)
                    printf("."); 
                else 
                    printf("#");
                }
                
                printf("\n");
            }
            
            printf("\n");
        } 
        
        return 0; 
    
}


Measured memory_bytes: 2108
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;


int main(void) {
    Int n;
    cin >> n;
    if (n % 1000 == 0) {
        cout << 0 << endl;
    } else {
        cout << 1000 - (n % 1000) << endl;
    }
    return 0;
}


Measured memory_bytes: 3612
#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;
#define mem(x,y) memset(x,y,sizeof(x))  
#define lli long long int
#define ll long long 
#define ld long double
#define pb push_back
#define mp make_pair
#define F first
#define S second 
#define LB lower_bound
#define UB upper_bound
#define BS binary_search
#define pii pair<lli,lli>
const long long int mod=1000000009;
//const long long int mod=998244353;
const long double PI=3.141592653589793;
const long long int inf=1e18;
const long long int inf2=LLONG_MAX;
#define setBitCount(x) __builtin_popcountll(x)
#define all(a) (a).begin(), (a).end()
#define all_r(a) (a).rbegin(), (a).rend()
lli gcd(lli a,lli b)
{
    if(b==0)
    return a;
    else
    return gcd(b,a%b);
}
// calculating (x^y)%p
lli power(lli x,lli y,lli p)
{
    lli res = 1;      
    x = x % p;  
    while (y > 0)
    {
        if (y & 1) //y is odd  
        res = (res*x) % p;
        y = y>>1; 
        x = ( (x%p)*(x%p) )% p;  
    }
    return res%p;
}
// calculating modular inverse using fermat little theorem
lli modInverse(lli n,lli p) 
{
    return power(n, p-2, p)%p;
}

// policy based data structures !!
#define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update>
// s.order_of_key (k) : Number of items strictly smaller than k
// *(s.find_by_order(k)) : K-th element in a set (counting from zero)

void solve()
{
   lli n;
   cin>>n;
   lli k;
   cin>>k;
   
   lli a[n+5];
   for(lli i=1;i<=n;i++)
   cin>>a[i];
   
   lli dp[n+5];
   mem(dp,0);
   dp[1]=0;
   dp[2]=abs(a[1]-a[2]);
   
   for(lli i=3;i<=n;i++)
   {
      lli ans=inf;
      for(lli j=1;j<=k and i-j>=1;j++)
      {
         ans=min(ans,dp[i-j]+abs(a[i]-a[i-j]));
      }
      dp[i]=ans;
   }
   cout<<dp[n];
}
int main()
{
   
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    lli T;
    //cin>>T;
    T=1;
    while(T--)
    {
        solve();
    }




    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}
#define int ll
int n;
vector<int> a;

void read() {
	cin >> n;
	a.resize(n);
	for (auto &i : a)
		cin >> i;
}

ll ans;
map<int, int> cnt;

void run() {
	ans = 0;
	for (int i = 0; i < n; i++) {
		ans += cnt[a[i] - i];
		cnt[-a[i] - i]++;
	}
}

void write() {
	cout << ans << endl;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	read();
	run();
	write();
	return 0;
}

Measured memory_bytes: 27364
#include<cstdio>
const int mo=1e9+7;
int dp[2100050],n,bel[2100050],st[25],id[2100050],w;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)bel[1<<(i-1)]=i;
	for (int i=1;i<=n;++i)
		for (int j=0;j<n;j++){scanf("%d",&w);st[i]|=(w<<j);}
	int lim=(1<<n);
	for (int i=1;i<lim;i++){
		int cnt=0;
		for (int j=i;j;j-=j&(-j))cnt++;
		id[i]=cnt; 
	}
	dp[0]=1;
	for (int i=1;i<lim;i++)
		for (int j=i;j;j-=j&(-j)){
			int pos=bel[j&(-j)];
			if (!(st[id[i]]&(1<<(pos-1))))continue;
			(dp[i]+=dp[i-(j&(-j))])%=mo;
		}
	printf("%d\n",dp[lim-1]);
}

Measured memory_bytes: 22656
#include <bits/stdc++.h>
#define drep(i,cc,n) for(int i=(cc);i<=(n);++i)
#define rep(i,n) drep(i,0,n-1)
#define drrep(i,cc,n) for(int i=(cc);i>=(n);--i)
#define rrep(i,n) drrep(i,0,n-1)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,v.size())if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define arrprint(v,n) rep(i,n)if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define matprint(v,n,m) rep(i,n){rep(j,m){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
using ll = long long;
using P = pair<int,int>;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int d;
vector<int> c(26);
vector<vector<int>> s;
vector<int> t, now;
vector<int> last(26, -1);
ll best = 0;

ll score(){
    ll res = 0;
    rep(i,26)last[i] = -1;
    rep(i,d){
        res += s[i][t[i]];
        last[t[i]] = i;
        rep(j,26) res -= c[j] * (i - last[j]);
    }
    return res;
}

int main(){
    auto start = std::chrono::system_clock::now();      // 計測スタート時刻を保存
    random_device seed;
    mt19937 mt(seed());
    uniform_int_distribution<int> rnd1(0,25);
    uniform_int_distribution<int> rnd3(1,16);

    cin >> d;
    uniform_int_distribution<int> rnd2(0,d-1);

    rep(i,26) cin >> c[i];
    s.resize(d);
    rep(i,d)s[i].resize(26);
    rep(i,d)rep(j,26) cin >> s[i][j];
    t.resize(d);
    rep(i,d)t[i] = rnd1(mt);
    best = score();
    // vecprint(t);
    while(true){
        auto end = std::chrono::system_clock::now();       // 計測終了時刻を保存
        auto dur = end - start;        // 要した時間を計算
        auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(dur).count();
        if(msec>=1900) break;

        int day1 = rnd2(mt);
        int day2 = day1 + rnd3(mt);
        if(day2 >= d)continue;
        // int con = rnd1(mt);
        swap(t[day1], t[day2]);
        // int old = t[day];
        // t[day] = con;
        ll now_s = score();
        if(best < now_s) best = now_s;
        else swap(t[day1], t[day2]);
    }

    // cout << score() << endl;
    rep(i,d)cout << t[i]+1 << endl;

    return 0;
}

Measured memory_bytes: 3696
import itertools
n,c = map(int,input().split())
dij = [[int(i) for i in input().split()] for j in range(c)]
cij = [[int(i) for i in input().split()] for j in range(n)]

c0 = []
c1 = []
c2 = []


for i in range(1,c+1):
    c0_tmp = 0
    c1_tmp = 0
    c2_tmp = 0
    for j in range(n*n):
        c_num = cij[j//n][j%n]
        cnt = j//n + j % n + 2
        if cnt % 3 == 0:
            if c_num != i:
                #print(i,c_num,j)
                c0_tmp += dij[c_num-1][i-1]
        elif cnt % 3 == 1:
            if c_num != i:
                c1_tmp += dij[c_num-1][i-1]
            #c1.append(j+2)
        else:
            if c_num != i:
                c2_tmp += dij[c_num-1][i-1]
            #c2.append(j+2)
    c0.append(c0_tmp)
    c1.append(c1_tmp)
    c2.append(c2_tmp)
        
li = list(itertools.permutations(range(1, c+1),3))

ans = 10**18

for i in range(len(li)):
    tmp = 0
    #print(li[i])
    tmp += c0[li[i][0]-1]
    tmp += c1[li[i][1]-1]
    tmp += c2[li[i][2]-1]
    #print(tmp,i)
    #print(li[i][0])
    ans = min(ans,tmp)

print(ans)

Measured memory_bytes: 48092
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

  public static void main(String[] args) {
    FastScanner sc = new FastScanner();

    int S = sc.nextInt();
    int W = sc.nextInt();

    String ans = "safe";
    if (S <= W)
      ans = "unsafe";
    System.out.println(ans);

  }
}

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;

  private boolean hasNextByte() {
    if (ptr < buflen) {
      return true;
    } else {
      ptr = 0;
      try {
        buflen = in.read(buffer);
      } catch (IOException e) {
        e.printStackTrace();
      }
      if (buflen <= 0) {
        return false;
      }
    }
    return true;
  }

  private int readByte() {
    if (hasNextByte()) {
      return buffer[ptr++];
    } else {
      return -1;
    }
  }

  private static boolean isPrintableChar(int c) {
    return 33 <= c && c <= 126;
  }

  private void skipUnprintable() {
    while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
      ptr++;
    }
  }

  public boolean hasNext() {
    skipUnprintable();
    return hasNextByte();
  }

  public String next() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    StringBuilder sb = new StringBuilder();
    int b = readByte();
    while (isPrintableChar(b)) {
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  public int nextInt() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    int n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }

  public long nextLong() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    long n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }
}

Measured memory_bytes: 25300
#include<bits/stdc++.h>
using namespace std;
#define maxn 200000
int a[maxn+5],b[maxn+5],c[maxn+5],t1,t2,n,k;
bool vis[maxn+5];
void insert1(int x){
	vis[x]=1;
	while(t1&&b[t1]>x)vis[b[t1]]=0,t1--;
	b[++t1]=x;
}
void insert2(int x){
	while(t2&&a[c[t2]]<a[x])t2--;
	c[++t2]=x;
}
int main(){
//	freopen("1.in","r",stdin);
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)scanf("%d",a+i),a[i]++;
	int ans1=n-k+1,mx=0,x;bool fl=0;
	for(int i=1;i<=k;i++)mx=(a[i]>a[i-1]?mx+1:1),insert1(a[i]),insert2(i);
	if(mx>=k)fl=1;
	for(int i=k+1;i<=n;i++){
		insert1(a[i]),insert2(i);
		mx=(a[i]>a[i-1]?mx+1:1);
		if(mx>=k){
			if(fl)ans1--;
			else fl=1;
		}
		else if(vis[a[i-k]]&&(t2<2||c[t2-1]<=i-k))ans1--;
	}
	printf("%d",ans1);
	return 0;
}

Measured memory_bytes: 2048
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <tchar.h>
//#include <intrin.h>

#define F first
#define S second
#define LL long long
#define MOD 1000000007
#define INF 200000000
#define LINF 1000000000000000000

using namespace std;

const int N = 2e5 + 10;

LL a[N];

int main()
{
	int n, k;
	LL sum = 0;
	scanf("%d%d", &n, &k);
	for (int i = 1;i <= n;i++)
		scanf("%lld", &a[i]);

	sort(a + 1, a + n + 1);
	for (int i = 1;i <= k;i++)
		sum += a[i];

	printf("%lld\n",sum);
}

Measured memory_bytes: 3216
#include<iostream>
#include<fstream>
#include<vector>
#include<map>
#include<algorithm>

using namespace std;

int main(void) {
	long long int N, NN;
	cin >> N;

	NN = N;

	while (1) {
		long long int factor;
		for (factor = 2; factor <= 3500; factor++) if (NN % factor == 0) break;
		long long int r = N / factor;
		NN /= factor;

		for (long long int h = 1; r * h <= 3500; h++) {
			for (long long int n = 1; r * n <= 3500; n++) {
				if (4 * h * n - factor * (h + n) <= 0) continue;
				if ((factor * h * n) % (4 * h * n - factor * (h + n)) == 0) {
					cout << r * h << " " << r * n << " " << r * (factor * h * n) / (4 * h * n - factor * (h + n)) << endl;
					system("pause");
					return 0;
				}
			}
		}
	}

	system("pause");
	return 0;
}

Measured memory_bytes: 884
def minimum_search(S):
    pass

if __name__ == '__main__':
    _ = list(map(int, input().split()))
    N, L = _[0], _[1]
    S = []
    for i in range(N):
        S.append(input())

    for i in range(N):
        temp=min(S)
        print(temp,end='')
        S.remove(temp)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main()
{
	int row, colomn;						// 行と列の数
	int arraySum = 0;						// 行列全体の合計値
	
	// 行と列の数の入力
	cin >> row >> colomn;
	
	// 動的配列の作成
	int **array    = new int*[row];			// 行列の要素
	int *rowSum    = new int[row];			// 行の合計値
	int *columnSum = new int[colomn];		// 列の合計値
	
	// 配列の初期化
	for(int i = 0; i < row; i++)
	{
		array[i]  = new int[colomn];		// 行列は2次元
		rowSum[i] = 0;						// 合計値は0で初期化
	}
	for(int i = 0; i < colomn; i++)
	{
		columnSum[i] = 0;
	}
	
	// 行列要素の入力
	for(int i = 0; i < row; i++)
	{
		for(int j = 0; j < colomn; j++)
		{
			cin >> array[i][j];
			rowSum[i]    += array[i][j];	// 行の合計値の計算
			columnSum[j] += array[i][j];	// 列の合計値の計算
		}
		arraySum += rowSum[i];				// 行列全体の合計値の計算
	}
	
	// 行列要素と合計値の出力
	for(int i = 0; i < row; i++)
	{
		for(int j = 0; j < colomn; j++)
		{
			cout << array[i][j] << " ";		// 行列要素の出力
		}
		cout << rowSum[i] << endl;			// 行の合計値の出力
	}
	for(int i = 0; i < colomn; i++)
	{
		cout << columnSum[i] << " ";		// 列の合計値の出力
	}
	cout << arraySum << endl;				// 行列全体の合計値の出力	
	
	// 動的配列の削除
	for(int i = 0; i < row; i++)
	{
		delete [] array[i];
	}
	
	delete [] array;
	delete [] rowSum;
	delete [] columnSum;
	
	return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll  long long
#define INF (ll)1e18 + 50
#define MAXN (int)1e5 + 50
#define fi first
#define se second
#define MOD 1000000007
#define all(v)((v).begin()), ((v).end())
#define A 911382323
#define B 972663749

vector<int> G[101010];
int dist[101010][2];
 
void dfs(int cur, int pre, int d, int id) {
    dist[cur][id] = d;
 
    for (const auto next: G[cur]) {
        if (next != pre) {
            dfs(next, cur, d + 1, id);
        }
    }
}
int main() {
    int n, u, v; cin >> n >> u >> v;
    u--;  v--;
    for(int i = 0; i < n-1; i++) {
        int a, b; cin >> a >> b;
        --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(u, u, 0, 0);
    dfs(v, v, 0, 1);
 
    int ans = 0;
    for (int i = 0; i < n; i++)
        if (dist[i][0] < dist[i][1]) 
            ans = max(ans, dist[i][1] - 1);

    cout << ans;
}

Measured memory_bytes: 11648
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  int a,b,c;
  cin >> a >> b >> c;

  if(c - (a-b) < 0){
    cout << 0 << endl;
  }
  else {
    cout << c-(a-b) << endl;
  }


  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
using namespace std;

int main(int argc, char* argv[]){
        int K=0, N=0;
        int *A = NULL;
        int d=0, D=0;

        cin >> K;
        cin >> N;

        A = (int*)calloc(N+1, sizeof(int));

        for(int i=1; i<=N; i++){
                cin >> A[i];
                if(i==1){
                        d = 0;
                }
                else if(i>1){
                        d = A[i] - A[i-1];
                }
                if(d>D){
                        D = d;
                }
        }
        if( D<K-A[N]+A[1] ){
                D = K - A[N] + A[1];
        }
        printf("%d\n", K-D);
        return 0;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-9;
const ll MOD=1e9+7;
int main(){
    int n;cin>>n;
    vector<int> a(n);
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    sort(all(a));
    if(sum%2==0){
        cout<<sum/2<<endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        if(a[i]%2){
            cout<<(sum-a[i])/2<<endl;
            return 0;
        }
    }
}



Measured memory_bytes: 3100
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int main(){
	ll N;
	vll A;
	int i, j, k;
	cin >> N;
	for (i = 0; i < 3 * N; i++){
		ll a;
		cin >> a;
		A.push_back(a);
	}
	sort(A.begin(), A.end());
	ll ans = 0;
	for (i = 0; i < N; i++){
		ans += A[3 * N - 2 * i - 2];
	}
	cout << ans << endl;
}

Measured memory_bytes: 5744
#include <stdio.h>
#include <limits.h>
 
int main(void) {
    int num, i, j;    int M[100][100];
    int g[100], h[100], gn;
    int weight, minimum, index, a;
 
    scanf("%d", &num);
    for (i = 0; i < num; i++) {
        g[i] = 1;
        h[i] = 0;
        for (j = 0; j < num; j++) {
            scanf("%d", &M[i][j]);
        }
    }
 
    h[0] = 1;
    g[0] = 0;
    gn = num - 1;
    weight = 0;
 
    while (gn--) {
        minimum = INT_MAX;
 
        for (j = 0; j < num; j++) {
            if (!h[j])
                continue;
 
            for (i = 0; i < num; i++) {
                if (!g[i])
                    continue;
 
                a = M[j][i];
                if (0 <= a && a < minimum) {
                    index = i;
                    minimum = a;
                }
            }
        }
        h[index] = 1;
        g[index] = 0;
        weight += minimum;
    }
    printf("%d\n", weight);
    return 0;
}



Measured memory_bytes: 2112
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)

int main() {
  long k;
  string s;
  cin >> s >> k;
  int n = (int)s.size();
  vector<pair<char, int>> a;
  for (int i = 0; i < n; ++i) {
    int j = i;
    while (j + 1 < n && s[j + 1] == s[i]) ++j;
    a.emplace_back(s[i], j - i + 1);
    i = j;
  }
  long ans = 0, mae = 0, naka = 0, ushiro = 0;

  int m = (int)a.size();
  if (m == 1) {
    ans = a[0].second * k / 2;
  } else if (a[0].first == a[m - 1].first) {
    for (int i = 1; i < m - 1; ++i) ans += a[i].second / 2 * k;
    ans += a[0].second / 2;
    ans += a[m - 1].second / 2;
    ans += (a[0].second + a[m - 1].second) / 2 * (k - 1);
  } else {
    for (auto p : a) ans += p.second / 2 * k;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3612
#include <iostream>

int main(){
    int x = 0;
    std::cin >> x;

    while (1)
    {
        int count = 0;
        for (int i = 1; i <= x; i++)
        {
            if (x % i == 0)
            {
                count++;
            }
        }
        if (count == 2)
        {
            break;
        }
        else
        {
            x++;
        }
    }
    std::cout << x << std::endl;
    
    return 0;
}

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

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

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

#define INF 1e16
#define mod 1000000007

int N;
int A[200010],B[200010];

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

  cin>>N;
  rep(i,2*N-1)cin>>A[i];

  int lb=1,ub=2*N;
  while(ub-lb>1){
    int X=(lb+ub)/2;
    rep(i,2*N-1){
      if(A[i]>=X)B[i]=1;
      else B[i]=0;
    }
    int cent=B[N-1],nxt=1-B[N-1];
    int top=-1;
    repl(i,1,N){
      if(nxt!=B[N-1-i]||nxt!=B[N-1+i]){
        top=1-nxt; break;
      }
      nxt=1-nxt;
    }
    if((top==-1&&cent%2==N%2)||top==1)lb=X;
    else ub=X;
  }
  cout<<lb<<endl;

  return 0;
}


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

int main(){
  int n, k, q;
  cin >> n >> k >> q;
  vector<int>maru(n, 0);
  for(int i=0; i<q; i++){
    int a;
    cin >> a;
    maru[a-1]++;
  }
  for(int i=0; i<n; i++)cerr << maru[i] << endl;
  for(int i=0; i<n; i++){
    cout << (k+maru[i]-q>0 ? "Yes" : "No") << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define bs ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define pb push_back
#define deb(a) cout << #a << " = " << a << '\n'
#define deb2(a, b) cout << #a << " = " << a << ", " << #b << " = " << b << '\n'
#define rep(var,start,end) for(int var=start;var<end;var++)
#define erep(var,start,end) for(int var=start;var<=end;var++)
#define rrep(var,start,end) for(int var=start;var>=end;var--)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pci pair<char,int>
#define pll pair<ll,ll>
#define test int t;cin>>t;while(t--)

ll expo(ll n, ll p, ll M){
	ll res = 1;
	while(p){
		if(p&1)
			res = (res * n)%M;
		n = (n*n)%M;
		p >>= 1;
	}
	return res;
}
string lcs(string a, string b){
	int n = a.size(), m = b.size();
	int dp[n+1][m+1];

	for(int i = 0; i <= n; ++i){ 
		for(int j = 0; j <= m; ++j){
			if(i == 0 || j == 0)
				dp[i][j] = 0;
			else if(a[i - 1] == b[j - 1])
				dp[i][j] = dp[i-1][j-1] + 1;
			else
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
		}
	}
	int i = n, j = m;
	string ans = "";
	while(i > 0 && j > 0){
		if(a[i - 1] == b[j - 1]){
			ans += a[i-1];	
			--i, --j;
		}
		else if(dp[i-1][j] > dp[i][j-1])
			--i;
		else --j;	
	}
	reverse(all(ans));
	return ans;
}
void solve(){
	string a,b;
	cin >> a >> b;
	cout << lcs(a,b);
}

int main()
{
	bs;
	#ifdef LOCAL
	freopen("Contest/input.txt","r",stdin);
	freopen("Contest/output.txt","w",stdout);
	#endif
	solve();
	// test{
	//    solve(); 
	// }
	#ifdef LOCAL_DEFINE
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	#endif
}

Measured memory_bytes: 38780
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define p 1000000007

struct item{
    ll weight;
    ll value;
};

ll solve(ll n,ll w,vector<item> &v)
{
    ll dp[n+1][w+1];
    
    for(ll i=0;i<=w;i++)
    {
        dp[1][i]=0;
    }
    
    dp[1][v[1].weight]=v.at(1).value;
    
    for(ll i=2;i<=n;i++)
    {
        for(ll j=0;j<=w;j++)
        {
            ll option1=dp[i-1][j];
            ll option2=( (j-v.at(i).weight>=0)?v.at(i).value+dp[i-1][j-v.at(i).weight]:0);
            
            dp[i][j]=max(option1,option2);
        }
    }
    
    return *max_element(dp[n],dp[n]+w+1);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll n,w;
    cin>>n>>w;
    
    vector<item> v(n+1);
    for(int i=1;i<=n;i++)
    {
        cin>>v[i].weight>>v[i].value;
    }
    cout<<solve(n,w,v);
    return 0;
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main(){__
	int x;
	for(int i=1; i <=5; i++){
		cin >> x;
		if(x == 0){
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3576
import sys

cnt = 0

def merge(A, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    L = range(n1 + 1)
    R = range(n2 + 1)

    for i in range(n1):
        L[i] = A[left + i]
    for i in range(n2):
        R[i] = A[mid + i]

    L[n1] = 1000000000
    R[n2] = 1000000000
    i = j = 0
    global cnt

    for k in range(left, right):
        cnt += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) / 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)

if __name__ == "__main__":
    lines = sys.stdin.readlines()
    S = map(int, lines[1].split())
    mergeSort(S, 0, int(lines[0]))
    print " ".join([str(s) for s in S])
    print cnt

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1000000007LL

#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

ll mypow(ll a, ll b) { if(b == 0) return 1; ll temp=mypow(a,b/2); temp=(temp*temp)%INF; if(b%2 == 1) temp=(a*temp)%INF; return temp; }
int mygcd(int a, int b) { if(b==0) return a; return mygcd(b,a%b); }
int cntBits(ll a) { int ret=0; while(a>0) { ret++; a/=2; } return ret; }
map<int,vector<pair<int,int> > > m1;
map<int,pair<int,int> > m2;
void print6(int n)
{
	vi v; v.clear();
	for(int i=0;i<6;i++)
	{
		v.pb(n%10);
		n/=10;
	}
	for(int i=v.size()-1;i>=0;i--) cout << v[i];
}
int main()
{
	ios::sync_with_stdio(0);
	int tt=1; 
//	cin >> tt;
	for(int tcase=1;tcase<=tt;tcase++)
	{
		int n,m; cin >> n >> m;
		for(int i=1;i<=m;i++)
		{
			int p,y; cin >> p >> y;
			m1[p].pb(mp(y,i));
		}
		for(int i=1;i<=n;i++)
		{
			sort(m1[i].begin(), m1[i].end());
			for(int j=0;j<m1[i].size();j++)
			{
				m2[m1[i][j].second]=mp(i,j+1);
			}
		}
		for(int i=1;i<=m;i++)
		{
			print6(m2[i].ff);
			print6(m2[i].ss);
			cout << "\n";
		}
	}
	return 0;
}

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

#define DEBUG(x) cout << #x << ": " << x << endl

#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= (a); --i)

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i =  (n) - 1; i >= 0; --i)

#define ALL(a) (a).begin(), (a).end()

using namespace std;

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

  const int n = 3;
  int a, b;
  cin >> a >> b;

  if( a % n == 0 || b % n == 0 || (a + b) % n == 0) {
    cout << "Possible";
  }
  else {
    cout << "Impossible";
  }

}



Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);		
		String s = sc.next();
		int val = 0;
		for (int i = 0; i < 4; i++) {
			if (s.charAt(i) == '+') {
				val++;
			} else {
				val--;
			}
		}
		System.out.println(val);
	}
}


Measured memory_bytes: 21716
require 'prime'
MOD = 10**9 + 7
n = gets.chomp.to_i
h = Hash.new(0)
2.upto(n) do |i|
  a = i.prime_division
  a.each do |e|
    h[e.first] += e.last
  end
end
mul = 1
h.each do |k,v|
  mul *= (v+1)
  mul %= MOD
end
puts mul


Measured memory_bytes: 2172
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    int n;
    cin>>n;
    map<pair<int,int>,int> p;
    rep(i,0,n){
        int x,y;
        cin>>x>>y;
        p[{x,y}]++;
    }
    int mx = -inf;
    int mn = inf;
    fori(it,p){
        mx = max(mx,it->ft.ft + it->ft.sd);
        mn = min(mn,it->ft.ft + it->ft.sd);
    }

    int ans = mx - mn;
    mx = -inf;
    mn = inf;
    fori(it,p){
        mx = max(mx,it->ft.ft - it->ft.sd);
        mn = min(mn,it->ft.ft - it->ft.sd);
    }
    ans = max(ans,mx-mn);

    cout<<ans<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 16152
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace std; 
using namespace __gnu_pbds;
 
typedef long long ll;
typedef double db;
typedef long double ld;
typedef string str;
 
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef pair<db, db> pdb;
typedef pair<ld, ld> pld;
typedef pair<str, str> pstr;
 
typedef vector<int> vi; 
typedef vector<ll> vll; 
typedef vector<db> vdb; 
typedef vector<ld> vld;
typedef vector<str> vstr; 
typedef vector<pi> vpi;
typedef vector<pll> vpll; 
typedef vector<pdb> vpdb; 
 
#define fi first
#define se second
#define mp make_pair
#define pf push_front 
#define pb push_back
#define ins insert 
#define eb emplace_back 
#define fbo find_by_order
#define ook order_of_key
#define rsz resize
#define lb lower_bound 
#define ub upper_bound 

#define len(s) (int)s.length()
#define sz(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define srt(v) sort(all(v))

#define rep(a, b, c) for(int a=b; a<c; a++) 
#define per(a, b, c) for(int a=b; a>c; a--) //do not include boundaries on the right
#define repn(a, b, c) for(int a=b; a<=c; a++) 
#define pern(a, b, c) for(int a=b; a>=c; a--) //include boundaries on the right
 
#define yes cout << "YES"<< "\n" 
#define no cout << "NO" << "\n" 
#define out(x) cout << x << "\n"
#define outs(x) cout << x << " "
#define el cout << "\n"

#define navi ios_base::sync_with_stdio(false); cin.tie(NULL)    
 
const ll mod = 1e9+7;
const double eps = 1e-9;

int main(){
	navi;
	char a; cin >> a;
   	if((int)a<=96) cout << "A"<< endl;
	else cout << "a" << endl;
}

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int main(void){
    int A;
    int B;
    cin >> A;
    cin >> B;
    
    if (A >= 13){
        cout << B <<endl;
    }
    
    if (6 <= A && A <= 12){
        cout << B/2 <<endl;
    }
    
    if (A <= 5){
        cout << 0 <<endl;
    }
    
}


Measured memory_bytes: 256
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

/*-----<Defines>-----*/
#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     flush           fflush(stdout)

using ull=unsigned long long;
using ll=long long;
using ld=long double;
/*-----</Defines>-----*/

/*-----<Debugging Stuff>-----*/
string to_string(char s)
{   string res="'''";res[1]=s;return res; }

string to_string(string s)
{   return '"'+s+'"'; }

string to_string(const char* s)
{   return to_string((string)s); }

string to_string(bool b)
{   return (b?"true":"false"); }

template<typename A, typename B>
string to_string(pair<A, B> p)
{   return "("+to_string(p.F)+", "+to_string(p.S)+")"; }

template<typename A>
string to_string(A v)
{
    bool first=1; string res="{";
    for(const auto &x:v)
    {
        if(!first)  res+=", ";
        first=0;
        res+=to_string(x);
    }
    res+="}";
    return res;
}

void debug() { cout<<"\n"; }
template<typename Head, typename... Tail>
void debug(Head H, Tail... T)
{
    cout<<" "<<to_string(H);
    debug(T...);
}

#define show(...) cout << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
/*-----</Debugging Stuff>-----*/

/*-----<Mod Operations>-----*/
const int M=1e9+7;
inline int add(int a,int b,int p=M){ a=a+b; if(a>=p) a-=p; return a; }
inline int sub(int a,int b,int p=M){ a=a-b; if(a<0) a+=p; return a; }
inline int mul(int a,int b,int p=M){ a=(a*1ll*b)%p; return a; }
/*-----</Mod Operations>-----*/

/*-----<Constants>-----*/
const ld pi=acos(-1),eps=1e-9;
const ll inf=1e18;
const int N=1;
/*-----</Constants>-----*/

void solve()
{
    int k;
    cin>>k;

    if(k%2==0 || k%5==0)
    {
        cout<<-1;
        return;
    }

    int cur=7;

    if(cur%k==0)
    {
        cout<<1;
        return;
    }

    for(int i=2;;++i)
    {
        cur=((cur*10)%k+7)%k;
        if(!cur)
        {
            cout<<i;
            return;
        }
    }
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




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

import collections
C = collections.Counter(S)

if len(C) < 3:
    print(0)
    exit()

count = 0

for i in range(N):
    j = 1
    while i - j >= 0 and i + j < N:
        if S[i-j] != S[i] and S[i+j] != S[i] and S[i-j] != S[i+j]:
            count += 1
        j += 1

ans = 1

for k, v in C.items():
    ans *= v

print(ans - count)

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

int main(){
  char words[500][32],w[32];
  int wcount[500];
  int a,b,c,d,e,i;
  for(i=0;i<500;i++){
    words[i][0]=0;
    wcount[i]=0;
  }
  a=0;b=0;d=0;
  while(scanf("%s",w)!=EOF){
    if(a==0) i=0; else for(i=0;i<a;i++) if(strcmp(w,words[i])==0) break;
    if(i==a){
      strcpy(words[i],w);
      a++;
    }
    if(wcount[i]++>b){
      b=wcount[i];
      c=i;
    }
    if(strlen(w)>d){
      d=strlen(w);
      e=i;
    }
  }
  printf("%s %s\n",words[c],words[e]);
  return 0;
}

Measured memory_bytes: 0
/*-------------------------------"ANJAN AGARWALA"-----------------------------

         _/_/_/_/    _/_/    _/   _/_/_/_/   _/_/_/_/    _/_/    _/   
        _/    _/    _/ _/   _/         _/   _/    _/    _/ _/   _/        
       _/_/_/_/    _/   _/ _/         _/   _/_/_/_/    _/  _/  _/         
      _/    _/    _/    _/_/   _/    _/   _/    _/    _/    _/_/  
     _/    _/    _/      _/   _/_/_/_/   _/    _/    _/      _/   

-------------------------------------@anjn98---------------------------------*/

//#define opti
#ifdef opti
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#endif

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

typedef long long int ll;
typedef long long int LL;
typedef unsigned long long int ull;
ll power(ll x,ll y,ll p){ll r=1; x=x%p; while(y){ if(y&1) r= r*x%p; y=y>>1; x=x*x%p; } return r; }
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;*/

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int csrand(int l=0, int r=1e9){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

#define IO              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FILEIO          freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define all(v)          v.begin(),v.end()
#define PR(a)           cout<<"("<<a<<")";
#define ED              cout<<'\n';
#define endl            '\n'
#define loop(j,a,n)     for(int j=a;j<=n;j++)
#define loop1(j,a,n)    for(int j=a;j>=n;j--)
#define fr1(j,n)        for(int j=0;j<n;j++)
#define fr(n)           for(int i=0;i<n;i++)
#define trav(x,s)       for(auto x:s)
#define SC(n)           scanf("%d",&n)
#define PB              push_back
#define MP              make_pair
#define pii             pair<int,int>
#define pll             pair<long long int,long long int>
#define F               first
#define S               second 
#define binf            2000000000000000001
#define mod             1000000007

const int N=3e3+99;
int n,k;
ll dp[N][N],pf[N][N];

int main() 
{
    IO
    string s;int n;
    cin>>n>>s;


    fr(N-1) pf[0][i+1]=1;
    for(int i=0;i<n-1;i++)
    {
        if(s[i]=='<')
        
        for(int j=1;j<=i+2;j++)
            dp[i+1][j]=pf[i][j-1];

        else
        for(int j=i+2;j>=1;j--)
            dp[i+1][j]=(pf[i][i+1]-pf[i][j-1]+mod)%mod;

        for(int j=1;j<=n+1;j++) pf[i+1][j]=(dp[i+1][j]+ pf[i+1][j-1])%mod;
     //    for(int j=1;j<=n+1;j++)PR(pf[i+1][j])ED
    }
    cout<<pf[n-1][n]<<endl;
   

}




 

Measured memory_bytes: 149760
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e15;
using Graph = vector<vector<int>>;

signed main() {
  int X, N;
  cin >> X >> N;
  vector<bool> fg(120);
  for( int i = 0; i < N; i++ ){
    int P;
    cin >> P;
    fg[P] = 1;
  }
  int sa = 10000;
  int ans = -1;
  for( int i = 110; i >= 0; i-- ){
    if( abs(i-X) <= sa && fg[i] == false ){
      sa = abs(i-X);
      ans = i;
    }
  }
  cout << ans << endl;

}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

int main(){
    int N, M, K;
    cin >> N >> M >> K;
    int black = 0;
    for(int i = 0; i <= N; i++){
        black = i * M;
        for(int j = 0; j <= M; j++){
            black += (N - (2 * i));
            if(black == K){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256