akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int INF=1e9+7;
int n,s,a[5005];
bitset<10000> dp[5005];
bool check(int id){
	if(a[id]>=s)return true;
	vector<int> v;
	rep(k,n)if(k!=id)v.push_back(a[k]);
	dp[0]=1;
	rep(k,v.size())dp[k+1]=dp[k]|(dp[k]<<v[k]);
	for(int k=s-a[id];k<s;k++)if(dp[v.size()][k])return true;
	return false;
}
int main(){
	int ans=0;
	vector<int> v;
	scanf("%d%d",&n,&s);
	rep(k,n)scanf("%d",&a[k]);
	sort(a,a+n);
	int l=0,r=n;
	while(l<r){
		int mid=(l+r)>>1;
		if(check(mid))r=mid;
		else l=mid+1;
	}
	printf("%d",r);
	return 0;
}

Measured memory_bytes: 6400
// (N * (L + (L + N - 1))) / 2
// (N * (2 * L + N - 1)) / 2
#include <bits/stdc++.h>

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    int N, L;
    cin >> N >> L;
    int ans = (N * (L + (L + N - 1))) / 2;
    if (0 < L)
        ans -= L;
    else if (L + N - 1 < 0)
        ans -= L + N - 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main()
{
    int n,m;
    cin >> n >> m;
    int g[n][m],l[m],a[n];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++)
            cin >> g[i][j];
        a[i]=0;
    }
    for(int i=0;i<m;i++)
        cin >> l[i];

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            a[i]+=(g[i][j]*l[j]);
        }
    }
    for(int i=0;i<n;i++)
        cout << a[i] << endl;

    return 0;
}



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

int main() {
    int n;
    string s;
    cin >> n >> s;
    for(int i=0;i<s.size();i++){
        s.at(i)=(char)((s.at(i) - 'A' + n) % 26 + 'A');
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>

#define INF 0x3f3f3f3f

using namespace std;

int res[50000][10],n;
int temp[10];
int a[10],b[10],k=1,pos=0;
bool vis[10];

bool same(int*x,int*y){
    for(int i=0;i<n;++i)
        if(x[i]!=y[i])return false;
    return true;
}

void dfs(int dep){
    if(dep==n){
        for(int i=0;i<n;++i)
            res[pos][i]=temp[i];
        ++pos;
        return;
    }
    for(int i=1;i<=n;++i){
        if(!vis[i]){
            temp[dep]=i;
            vis[i]=true;
            dfs(dep+1);
            vis[i]=false;
        }
    }
}

int main() {
    scanf("%d",&n);
    for(int i=0;i<n;++i)
        scanf("%d",&a[i]);
    for(int i=0;i<n;++i)
        scanf("%d",&b[i]);
    for(int i=2;i<=n;++i)
        k*=i;
    dfs(0);
    int t1,t2;
//    for(int i=0;i<k;++i){
//        for(int j=0;j<n;++j)
//            printf("%d ",res[i][j]);
//        printf("\n");
//    }
    for(int i=0;i<k;++i){
        if(same(a,res[i]))
            t1=i;
        if(same(b,res[i]))
            t2=i;
    }
    printf("%d\n",t1-t2<0?t2-t1:t1-t2);
    return 0;
}

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

int main() {
	int H,W;
  	cin >> H >> W;
  
  	vector<vector<char>> vec(H,vector<char>(W));
  
  	for(int i = 0; i < H; i++) {
    	for(int j = 0; j < W; j++) {
        	cin >> vec.at(i).at(j);
        }
    }
  
  	for(int i = 0; i < H; i++) {
      for(int k = 0; k < 2; k++) {
    	for(int j = 0; j < W; j++) {
          if(j == W - 1) {
        	cout << vec.at(i).at(j) << endl;
          }else {
          	cout << vec.at(i).at(j);
          }
        }
      }
    }
  
  	
}

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

//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//template <typename T> using orderMSet =
//tree <T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef unsigned long long llu;
#define filein freopen("input.txt", "r", stdin)
#define fileout freopen("output.txt", "w", stdout)
#define inf 1000000000000000018
#define mod 1000000007
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>

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

	if(s[2] == s[3] && s[4] == s[5]) {
		cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
	if(N % 1110 <= 9 || N % 1000 % 111 == 0){
    	cout << "Yes";
    }
  	else{
    	cout << "No";
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

class AnOrdinaryGame
{
public:
	string s;
	map<string, int> memo;
	AnOrdinaryGame();
	~AnOrdinaryGame();
	void exec();
	int recurvive(string str, int turn);
};

AnOrdinaryGame::AnOrdinaryGame(){
	cin >> s;
}

AnOrdinaryGame::~AnOrdinaryGame(){}

int AnOrdinaryGame::recurvive(string str, int turn){
	if(memo[str] != 0){
		return memo[str];
	}

	int next_turn;
	for (int i = 1; i < str.size()-1; ++i)
	{
		string tmp(str.c_str(), str.length());
		tmp.erase(i, 1);
		// cout << tmp << endl;
		if(tmp[i-1] == tmp[i]) continue;
		if(memo[tmp] != 0){
			next_turn = memo[tmp];
		}else{
			next_turn = recurvive(tmp, turn+1);
			memo[tmp] = next_turn;
		}
		if(next_turn % 2 != turn % 2){
			return next_turn;
		}
	}
	memo[str] = turn;
	// cout << str << " " << turn << endl;

	return turn;
}

void AnOrdinaryGame::exec(){
	// if(recurvive(s, 0) % 2 == 0){
	// 	cout << "Second" << endl;
	// } else {
	// 	cout << "First" << endl;
	// }
	if( (s.length() % 2 == 1 && s[0] != s[s.length()-1]) || (s.length() % 2 == 0 && s[0] == s[s.length()-1]) ){
		cout << "First" << endl;
	} else {
		cout << "Second" << endl;
	}
}

int main(){
	AnOrdinaryGame aog = AnOrdinaryGame();
	aog.exec();
}


Measured memory_bytes: 512
//void __(){
//    _(int,n);
//    Factorial f(n);
//    _(vl,a,n);
//    ll sum = 0;
//    ll w = 0;
//    rep(i,n-1){
//        w += mod_inverse(i+1);
//        sum += w*(a[i+1]-a[i]);
//        sum %= MOD;
//        w %= MOD;
//    }
//    print sum*f.fact[n-1]%MOD;
//}
//
#include <iomanip>
#include <cassert>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define REP_ZERO_INT(i,r) for(int i = 0; i < (r); ++i)
#define GET_REP_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define rep(...) GET_REP_MACRO(__VA_ARGS__,REP_ANY,REP_INT,REP_ZERO_INT)(__VA_ARGS__)
#define all(v) (v).begin(), (v).end()
#define sz(v) ll(v.size())
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
const ll MOD = 1e9 + 7;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
T1 istream& operator>>(istream& stream, vector<T>& t){
    return read(all(t), stream);
}
T1 istream& read(T b, T e, istream& stream){
    for(T it = b; it != e; ++it)
        stream >> *it;
    return stream;
}
T1 T ext_euclid(T a, T b, T c, T d){
    if(c == T(0))
        return b;
    return ext_euclid(c, d, a % c, b - a / c * d);
}
T1 T mod_inverse(T x, T mod = T(MOD)){
    return (ext_euclid(mod, T(0), x, T(1)) + mod) % mod;
}
ll mod_inverse(int x, ll mod = MOD){
    return mod_inverse<ll>(x,mod);
}
struct Factorial{
    vl fact,ifact;
    ll comb(ll n, ll m){
        assert(n >= m);
        assert(n < sz(fact));
        return fact[n]*ifact[m]%MOD*ifact[n-m]%MOD;
    }
    Factorial(int n){
        fact.resize(n+1);
        ifact.resize(n+1);
        fact[0] = 1;
        for(int i = 1; i <= n; ++i)
            fact[i] = fact[i-1]*i%MOD;
        ifact[n] = mod_inverse(fact[n]);
        for(int i = n-1; i >= 0; --i)
            ifact[i] = (i+1)*ifact[i+1]%MOD;
    }
};
struct _print {
    string sep,end;
    bool space;
    ostream &stream;
    _print(string _sep=" ",string _end="\n",
            ostream &_stream = cout) 
        : sep(_sep),end(_end),space(false),
            stream(_stream) {}
    ~_print() { stream << end; }

    template <typename T>
        _print &operator , (const T &t) {
            if (space) stream << sep;
            space = true;
            stream << t;
            return *this;
        }
};
#define print _print(),
#define INPUT_WITHOUT_INIT(type,name) type name; cin >> name
#define _IWI(type,name,...) type name(__VA_ARGS__); cin >> name
#define GET_INPUT_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define _(...) GET_INPUT_MACRO(__VA_ARGS__,_IWI,_IWI,_IWI,_IWI,_IWI,_IWI,INPUT_WITHOUT_INIT)(__VA_ARGS__)
void __(){
    _(int,n);
    Factorial f(n);
    _(vl,a,n);
    ll sum = 0;
    ll w = 0;
    rep(i,n-1){
        w += mod_inverse(i+1);
        sum += w*(a[i+1]-a[i]);
        sum %= MOD;
        w %= MOD;
    }
    print sum*f.fact[n-1]%MOD;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        __();
}



Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <vector>
#include <array>
#include <tuple>
#include <utility>
#include <numeric>
#include <iomanip>
#include <cctype>
#include <cmath>
#include <assert.h>
#include <cstdlib>
#include <list>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;

template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
    return s << "(" << p.first << ", " << p.second << ")";
}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s << "[";
    for (int i = 0; i < v.size(); i++) s << (i == 0 ? "" : ", ") << v[i];
    s << "]";
    return s;
}

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

ll dp[110][110][410];

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

    vector<ll> w(N), v(N);
    for (int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
    }

    memset(dp, -1, sizeof(dp));
    dp[0][0][0] = 0;
    for (int i = 0; i < N; i++) {
        for (int use = 0; use <= i; use++) {
            for (int add = 0; add < 410; add++) {
                if (dp[i][use][add] < 0) continue;
                dp[i + 1][use][add] = max(dp[i + 1][use][add],
                                          dp[i][use][add]);

                ll next_w = (ll)use * w[0] + (ll)add + w[i];
                if (next_w > W) continue;
                auto& next = dp[i + 1][use + 1][add + w[i] - w[0]];
                next = max(next, dp[i][use][add] + v[i]);
            }
        }
    }

    ll ans = 0;
    for (int use = 0; use <= N; use++) {
        for (int add = 0; add < 410; add++) {
            ans = max(ans, dp[N][use][add]);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 39040
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
static const int MAX=100000;
static const int NIL=-1;
int n;
vector<int> G[MAX];
int color[MAX];
void dfs(int r,int c){
    stack<int> S;
    S.push(r);
    color[r]=c;
    while(!S.empty()){
        int u=S.top();
        S.pop();
        for(int i=0;i<G[u].size();i++){
            int v=G[u][i];
            if(color[v]==NIL){
                color[v]=c;
                S.push(v);
            }
        }
    }
}
void assignColor(){
    int id=1;
    for(int i=0;i<n;i++)color[i]=NIL;
    for(int i=0;i<n;i++){
        if(color[i]==NIL)
            dfs(i,id++);
    }
}
int main(){
    int s,t,m,q;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>s>>t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    assignColor();
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>s>>t;
        if(color[s]==color[t]) cout<<"yes"<<"\n";
        else cout<<"no"<<"\n";
    }
    return 0;
}



Measured memory_bytes: 8896
#include<bits/stdc++.h>
//#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bug1( x ) {cerr << (#x) <<"="<< x << endl;}
#define bug2( x , y ) {cerr << (#x) <<"="<< (x) << "    " << (#y) << "="<< (y) << endl;}
#define bug3( x , y , z ) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << endl;}
#define bug4( x , y , z , w) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << endl;}
#define bug5( x , y , z , w ,p) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << endl;}
#define bug6( x , y , z , w ,p , q) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << "    " << (#q) <<"="<< q << endl;}
#define bugn( x , n ) {cerr << (#x) <<":";for(int i=0;i<n;i++)cerr << x[i] <<"  "; cerr << endl;}
#define bugnm( x , n , m ) {cerr << (#x)<<endl;for(int i=0;i<n;i++){cerr << "Row #" << i<< ":";for(int j=0;j<m;j++)cerr << x[i][j] << "   ";cerr << endl;}}
typedef long long ll;
typedef long double ld;
using namespace std;

const int maxn = 2e5+10;
int msk[maxn],dp[maxn],n;
unordered_map<int,int>mp;
string s;
int32_t main(){
	IOS
	cin >> s;
	n = s.length();
	msk[0]=0;
	for(int i=1;i<=n;i++){
	   msk[i]=msk[i-1] ^ 1<<(s[i-1]-'a');
	}
	mp[0] = 0;
	for(int i=1;i<=n;i++){
		dp[i] = i;
		if( mp.count(msk[i]) ){
			dp[i] = min( dp[i], mp[msk[i]] + 1);
		}
		for(int j = 0 ; j < 26; j++ ){
			int cur = msk[i] ^ 1 << j;
			if( mp.count(cur)){
				dp[i] = min( dp[i] , mp[cur] + 1);
			}
		}
		if( !mp.count(msk[i]) || mp[ msk[i] ] > dp[i] ){
			mp[ msk[i] ] = dp[i];
		}
	}
	cout << dp[n];
}
/*
 * long long or int?
 * index out of bound? 
 * Tested on own test case?corner?
 * Make more general solution.
 * Read Read Read Read ....
 */


Measured memory_bytes: 13100
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

H, W = LI()

rows = [['.' for i in range(W+2)]]
for i in range(H):
    row = input()
    chars = ['.']
    for w in range(W):
        chars.append(row[w])
    chars.append('.')
    rows.append(chars)
rows.append(['.' for i in range(W+2)])
#  for row in rows:
#      print(row)

# rows[高さ][幅]ができあがった
for h in range(1, H+1):
    for w in range(1, W+1):
        if rows[h][w] == '#':
            if not (rows[h][w-1] == '#' or rows[h][w+1] == '#' or rows[h-1][w] == '#' or rows[h+1][w] == '#'):
                print('No')
                exit()
print('Yes')


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll dp[100000];
ll score[100000];
ll a[20][20];
int main() {
    //cout.precision(10);
    ll n;
    cin >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> a[i][j];
        }
    }
    for(ll bits = 0; bits < ((ll)1<<n); bits++){
        for(ll i = 0; i < n; i++){
            if(!(bits & ((ll)1<<i))) continue;
            for(ll j = i + 1; j < n; j++){
                if(!(bits & ((ll)1<<j))) continue;
                score[bits] += a[i][j];
            }
        }
    }
    ll mask = 1;
    for(ll index = 1; index < n; index++){
        mask |= ((ll)1<<index);
        //cout << index << " " << mask << " " << ((ll)1 << index) << " " << ((ll)1 << (index + 1)) << endl;
        //cout << index <<  " " << mask << endl;
        for(ll New = ((ll)1 << index); New < ((ll)1 << (index + 1)); New++){
            //if(New > 10) break;
            dp[New] = -1e16;
            for(ll bits = ((ll)1 << index); bits < ((ll)1 << (index + 1)); bits++){
                if((bits | New) != New) continue;
                ///cout << bits << " " << New << " " << (bits^mask) << " " << score[bits] << " " << dp[bits^mask] << endl;
                dp[New] = max(dp[New], score[bits] + dp[bits ^ New]);
            }
        }
    }
    for(int i = 0; i < 10; i++){
        //cout << i << " " << score[i] << " " << dp[i] << endl;
    }
    cout << dp[((ll)1 << n) - 1] << endl;
    return 0;
}


Measured memory_bytes: 1280
PROGRAM ATCODER

implicit none
integer(8) :: n,s,f,n_d,t,i,j,v1,v10,b,ans
real(8) :: n_root

read(*,*) n,s

ans = -1

if(n<s)then
  write(*,'(i0)') -1
  stop
end if

if(n == s)then
  write(*,'(i0)') n+1
  stop
end if

n_root = real(n)**(0.5)
n_d = int(n_root)

do i = 1, n_d
  f = 0
  t = n
  v10 = i
  if (i/=1) then
    do
      f = f + mod(t,i)
      if(t < i)exit
      t = t/i
    end do
    if(f == s)then
      call chmin(ans,i)
    end if
  end if
  if(n_d**2 == n .and. i == n_d)cycle ! n=s^2の時用のチェック
  b = (n-s)/v10 + 1
  if(mod(n-s,v10) /= 0)cycle
  f = mod(n,b) + n/b
  if(f == s)then
    call chmin(ans,b)
  end if
end do


write(*,'(i0)') ans

contains
!!!!!! サブルーチンは↓
subroutine chmin(dp,x)
implicit none
integer(8) :: dp, x

if(dp < 0) then
  dp = x
  return
end if

if (dp > x) then
  dp = x
  return
end if

end subroutine
!!!!!!

END PROGRAM ATCODER


Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val A = sc.nextInt
    val B = sc.nextInt
    sc.close()

    val money = A match {
      case A if A < 6 => 0
      case A if A < 13 => B / 2
      case _ => B
    }

    println(money)
  }
}

Measured memory_bytes: 27328
N, T = map(int, input().split())
min_c = 1001
for i in range(N):
    c, t = map(int, input().split())
    if t > T:
        continue
    min_c = min(c, min_c)
if min_c == 1001:
    print('TLE')
else:
    print(min_c)


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

// 約数の列挙
template<typename T>
set<T> div_count(T x) {
  set<T> st;
  for (int i = 1; i * i <= x; ++i) {
    if (x % i == 0) {
      st.insert(i);
      st.insert(x/i);
    }
  }
  return st;
}

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);

  rep(i,n) {
    cin >> a[i];
  }
  set<ll> st;
  map<ll,bool> mp;
  for (auto itr : div_count(a[0])) {
    st.insert(itr);
    mp[itr] = true;
  }

  ll ans = -1;
  for (int i = 1; i < n; ++i) {
    for (auto itr : mp) {
      if (itr.second) {
        if (itr.first > a[i] or a[i] % itr.first != 0) {
          mp[itr.first] = false;
        }
      }
    }
  }
  
  for (auto itr : mp) {
    if (itr.second)
      ans = max(ans, itr.first);
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on
void main()
{
    auto input = stdin.byLine.map!split.joiner;

    long K;
    K = input.front.to!long;
    input.popFront;

    solve(K);
}

void solve(long K)
{
    if (K % 2 == 0)
    {
        writeln(-1);
        return;
    }
    long x = 7;
    foreach (i; 1 .. 1_000_000)
    {
        if (x % K == 0)
        {
            writeln(i);
            return;
        }
        x = (x * 10 + 7) % K;
    }
    writeln(-1);
}


Measured memory_bytes: 3700
from math import sqrt

eps = 10**-7

def check(a, b):
  if b < a:
    a, b = b, a
  if b - a <= 1:
    return 2 * a - 2
  c = int(sqrt(a*b) - eps)
  assert(c**2 < a*b <= (c+1)**2)
  return 2 * c - 1 - (c * (c + 1) >= a * b)

for _ in range(int(input())):
  print(check(*list(map(int, input().split()))))

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline

N,Q = tuple(map(int,input().split()))
S = input().rstrip()

L = [0]*N

for i in range(len(S)-1):
  if S[i:i+2] == "AC":
    L[i+1] = L[i] + 1
  else:
    L[i+1] = L[i]

for i in range(Q):
  l,r = tuple(map(int,input().split()))
  print(L[r-1]-L[l-1])

Measured memory_bytes: 6472
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

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

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

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

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

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    char[][] maze = new char[h][w];
    for (int i = 0; i < h; i++) {
      String row = sc.next();
      for (int j = 0; j < w; j++) {
        maze[i][j] = row.charAt(j);
      }
    }
    long[][] dp = new long[h * w][h * w];
    for (int i = 0; i < h * w; i++) {
      int ii = i / w;
      int ij = i % w;
      for (int j = 0; j < h * w; j++) {
        if (maze[ii][ij] == '#') {
          dp[i][j] = Integer.MAX_VALUE;
          continue;
        }
        int ji = j / w;
        int jj = j % w;
        if (maze[ji][jj] == '#') {
          dp[i][j] = Integer.MAX_VALUE;
          continue;
        }
        if (ii == ji && ij == jj) {
          dp[i][j] = 0;
        } else if (Math.abs(ii - ji) + Math.abs(ij - jj) == 1) {
          dp[i][j] = 1;
        } else {
          dp[i][j] = Integer.MAX_VALUE;
        }
      }
    }
    for (int k = 0; k < h * w; k++) {
      for (int i = 0; i < h * w; i++) {
        for (int j = 0; j < h * w; j++) {
          dp[i][j] = Math.min(dp[i][j], dp[i][k] + dp[k][j]);
        }
      }
    }
    long max = 0;
    for (int i = 0; i < h * w; i++) {
      for (int j = 0; j < h * w; j++) {
        if (dp[i][j] == Integer.MAX_VALUE) continue;
        max = Math.max(max, dp[i][j]);
      }
    }
    System.out.println(max);
  }
}

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

int main() {
    int n,m;
    scanf("%d%d", &n,&m);
    vector<int> aj(m); // ヨコ
    vector<vector<int> > aij(n,aj); // タテ
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            scanf("%d", &aij.at(i).at(j));
        }
    }
    vector<int> b(m);
    for (int i = 0; i < m; i++) {
        scanf("%d", &b.at(i));
    }
    vector<int> c(n);
    for (int i = 0; i < n; i++) {
        int x = 0;
        for (int j = 0; j < m; j++) {
            x += aij.at(i).at(j) * b.at(j);
        }
        c.at(i) = x;
    }
    for (int i = 0; i < n; i++) {
        printf("%d\n", c.at(i));
    }
}


Measured memory_bytes: 3272
# C - Repsept
def get_mod(prev_mod):
	global K
	
	return (prev_mod * 10 + 7) % K


K = int(input())
mod = 0
count = 0
mods = set()

while True:
	mod = get_mod(mod)
	count += 1
	
	if mod == 0:
		print(count)
		break
	else:
		if mod in mods:
			print(-1)
			break
		else:
			mods.add(mod)

Measured memory_bytes: 77964
H, W = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))

cur_W = 0 # 今いるx座標
cur_H = 0 # 今いるy座標
# 左上から右へ、次は下の段を左へ塗っていく
answer = [[0] * W for _ in range(H)]
sgn = 1 # 最初は右向き
for i in range(1, len(A)+1):
    for j in range(A[i-1]):
        answer[cur_H][cur_W] = i
        cur_W += sgn
        if not 0 <= cur_W <= W-1:
            cur_W -= sgn
            cur_H += 1
            sgn *= -1

for x in answer:
    print(*x)

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

const int maxN = 2005, inf = 1e9;

struct Node
{
	int to, next;
}edge[maxN * 2 + 1];

int ans;
int n, head[maxN + 1], tot; 
int val[maxN + 1], dep[maxN + 1], sum[maxN + 1], size[maxN + 1];
int f[maxN + 1];
char s[maxN + 1];

inline void add(int x, int y)
{
	tot ++;
	edge[tot].to = y;
	edge[tot].next = head[x];
	head[x] = tot;
}

inline void dfs(int u, int pa)
{
	f[u] = 0;
	dep[u] = dep[pa] + 1;
	size[u] = val[u]; sum[u] = val[u] * dep[u];
	int mx = 0, t = 0, w = 0;
	for(int i = head[u]; i; i = edge[i].next)
	{
		int v = edge[i].to;
		if(v == pa) continue;
		dfs(v, u);
		size[u] += size[v]; sum[u] += sum[v];
		t += sum[v] - size[v] * dep[u];
		if(sum[v] > sum[mx]) mx = v;
	}
	if(!mx) return;
	w = sum[mx] - size[mx] * dep[u];
	if(2 * w <= t) f[u] = t / 2;
	else f[u] = t - w + min(f[mx], (2 * w - t) / 2); 
}

int main()
{
	scanf("%d", &n);
	scanf("%s", s + 1);
	for(int i = 1; i <= n; i++) val[i] = s[i] - '0';
	for(int i = 1; i < n; i++)
	{
		int x, y;
		scanf("%d %d", &x, &y);
		add(x, y); add(y, x);
	}

	dep[0] = -1;
	ans = inf;
	for(int u = 1; u <= n; u++)
	{
		dfs(u, 0);
		if(2 * f[u] == sum[u]) ans = min(ans, f[u]);
	}

	printf("%d", ans == inf ? -1 : ans);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
int N; 
long long int X; 
long long int A[110] = {}; 
long long int B[110] = {}; 
cin >> N >> X; 
for(int i = 0; i < N; i++){
cin >> A[i]; 
}
sort(A, A+N); 
for(int i = 1; i <= N; i++){
B[i] = B[i-1] + A[i-1]; 
}
int ans = 0; 
if(B[N] < X){
ans = N-1; 
}
else if(B[N] == X){
ans = N; 
}
else{
for(int i = 0; i <= N; i++){
if(B[i] > X){
ans = i-1; 
break; 
}
}
}
cout << ans << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	string s;
	cin >> s;
	
	if(s == "RRR") cout << 3 << endl;
	else if(s == "RRS" || s == "SRR") cout << 2 << endl;
	else if(s == "SSS") cout << 0 << endl;
	else cout << 1 << endl;
	
	return 0;
}

Measured memory_bytes: 3664
import numpy as np
 
h, n = map(int, input().split())
a = []
b = []
for _ in range(n):
  ai, bi = map(int, input().split())
  a.append(ai)
  b.append(bi)
a = np.array(a)
b = np.array(b)
dp = np.zeros(h+1, dtype=np.int)
for c in range(1, h+1):
  dp[c] = np.min(dp[np.maximum(0, c-a)] + b)
print(dp[-1])

Measured memory_bytes: 12500
<?php
  $i = 0;
  $diameter = 0;
  $house_n = 0;
  $house = [];
  $current = 0;
  $next = 0;
  $prev = 0;
  $distanse_nxt = 0;
  $distanse_prv = 0;
  $min = 0;
  $max = 0;
  $shortest = 0;

  list($diameter, $house_n) = sscanf(fgets(STDIN), "%d %d");
  $house = explode(" ", fgets(STDIN));
  foreach ($house as $k => $v) {
    $house[$k] = intval($v);
    if($min > $house[$k])
      $min = $house[$k];
    else if($max < $house[$k])
      $max = $house[$k];
  }
  sort($house);
  
  $shortest = $diameter;
  for($i=0; $i<count($house)-1; $i++){
      $current = $house[$i];
      $prev = ($i == 0)? $house[count($house)-1] : $house[$i-1];
      $next = $house[$i+1];
      $distanse_nxt = $next - $current;
      $distanse_prv = ($current - $prev > 0)? $current - $prev : $diameter - abs($current - $prev);
      
      // print("[$i]: current->$current, prev->$prev, next->$next\n");
      // print("distans_nxt: $distanse_nxt\n");
      // print("distans_prev: $distanse_prv\n");

      if($shortest > $diameter - $distanse_nxt)
        $shortest = $diameter - $distanse_nxt;
      if($shortest > $diameter - $distanse_prv)
        $shortest = $diameter - $distanse_prv;
  }
  
  print($shortest);
  
?>


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

#define LSOne(S) ((S) & (-S))

#define EPS 1e-6
#define MOD 1000000007

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, k, h, ans = 0;
  cin >> n >> k;
  while(n--) {
    cin >> h;
    ans += (h >= k ? 1 : 0);
  }
  cout << ans << ende;
  return 0;
}


Measured memory_bytes: 256
N=int(input())
from collections import deque

q=deque([9,8,7,6,5,4,3,2,1])

for i in range(N-1):
  num=q.pop()
  if num%10!=0:
    q.appendleft(num*10+num%10-1)
  q.appendleft(num*10+num%10)
  if num%10!=9:
    q.appendleft(num*10+num%10+1)

print(q.pop())
  

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int ans = 0;
  rep(i, n) {
    if(i%2==0 && a[i]%2==1) ++ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;

/* --------------------------------------------------- */

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

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<ll> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  
  ll goal = 0;
  for (int i = 2; i < n; i++) goal = (goal ^ a.at(i));
  
  ll sum = a.at(0) + a.at(1);
  if (sum < goal || sum % 2 != goal % 2) {
    cout << -1 << '\n';
    return 0;
  }
  
  ll now = (sum - goal) / 2; // Mt. No.2
  vector<ll> x;
  x.emplace_back(now);
  for (int bit = 60; bit >= 0; bit--) {
    //if (now > a.at(1)) break;
    if ((1LL << bit) & goal) {
      if ((now + (1LL << bit)) >= a.at(1)) x.emplace_back(now + (1LL << bit));
      else now += (1LL << bit);
    }
  }
  
  //for (int i = 0; i < x.size(); i++) cout << x[i] << endl;
  
  sort(x.begin(), x.end());
  if (x.back() < a.at(1)) {
    cout << -1 << endl;
    return 0;
  }
  ll new2 = *lower_bound(x.begin(), x.end(), a.at(1));
  if (new2 == a.at(0) + a.at(1)) {
    cout << -1 << endl;
    return 0;
  }
  
  ll sum2 = (new2 ^ (a.at(0) - (new2 - a.at(1))));
  for (int i = 2; i < n; i++) {
    sum2 = (sum2 ^ a.at(i));
  }
  if (sum2 != 0) {
    cout << -1 << '\n';
    return 0;
  }
  if (new2 - a.at(1) >= 0) cout << new2 - a.at(1) << '\n';
  else cout << -1 << '\n';
}

Measured memory_bytes: 3628
#include <stdlib.h>
#include <assert.h> //assert
#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <string.h>
#include <string>
#include <queue>
#include <sstream>
#include <iomanip> //precision
using namespace std;
#define precision(x) setprecision(x) << fixed
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<vector<ll > > matrix;
const ll mod = 1000000007LL;

const int MAX_N = 1001;

ll r, d, x;


int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	
	cin >> r >> d >> x;
	for (int i = 0; i < 10; ++i) {
		x = r*x - d;
		cout << x << '\n';
	}

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0;
#define HERE cout<<"    "<<"HERE"<<en

int  main(){
  for(int i=0; i<3; i++){
    int h_1,m_1,s_1;
    cin>>h_1>>m_1>>s_1;
    int h_2,m_2,s_2;
    cin>>h_2>>m_2>>s_2;
    int t1=h_1*3600+m_1*60+s_1;
    int t2=h_2*3600+m_2*60+s_2;
    
    int t=t2-t1;
    int f,ss,tt;
    f=t/3600; t%=3600; ss=t/60; t%=60;
    tt=t;
    cout<<f<<" "<<ss<<" "<<tt<<en
  }
}


Measured memory_bytes: 3108
n,t=map(int,input().split())
ct=[list(map(int,input().split())) for i in range(n)]
ans=1001
for i in range(n):
  if ct[i][0]<=ans and ct[i][1]<=t:
    ans=ct[i][0]
if ans<1001:
  print(ans)
else:
  print("TLE")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
#define SIZE_N 50010
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll m, a, b;
vector<ll> prime;
bool isPrime[SIZE_N];
void get_prime(){
    isPrime[0]=isPrime[1]=false;
    REP(i, 2, SIZE_N) isPrime[i]=true;

    for(int i=2; i*i<=SIZE_N; i++){
        for(int j=2*i; j<=SIZE_N; j+=i){
            isPrime[j]=false;
        }
    }

    REP(i, 0, SIZE_N){
        if(isPrime[i]) prime.emplace_back(i);
    }
    return;
}
int main() {
    get_prime();

    while(cin>>m>>a>>b, m||a||b){
        ll mx=0;
        ll width=-1, height=-1;
        REP(i, 0, prime.size()){
            REP(j, i, prime.size()){
                if(prime[i]*prime[j] > m) break;
                if(a*prime[j] > b*prime[i] || prime[i] > prime[j]) break;

                if(prime[i]*prime[j] > mx){
                    mx=prime[i]*prime[j];
                    width=prime[i];
                    height=prime[j];
                }
            }
        }

        cout<<width<<" "<<height<<endl;
    }
    return 0;
}


Measured memory_bytes: 3224
#include<iostream>

using namespace std;
typedef long long ll;
ll dp[2][60];
int main(){
	int n,p;
	cin>>n>>p;
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		if(x%2==0){
			dp[0][i]=2*dp[0][i-1];
			dp[1][i]=2*dp[1][i-1];
		}
		else{
			dp[0][i]=dp[0][i-1]+dp[1][i-1];
			dp[1][i]=dp[1][i-1]+dp[0][i-1];
		}
	}
	cout<<dp[p][n]<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n;
  	int sub=0;
  	int sum=0;
  	string s;
  	cin>>n>>s;
  	for(int i=0;i<n;i++){
    	if(s[i]=='I'){
          sub++;
          if(sum<sub) sum=sub; 
        }
        if(s[i]=='D') sub--;
      	
    }
  	cout<<sum<<endl;
}

Measured memory_bytes: 256
//

fun main() {
    abc174c()
}

fun abc174c() {
    // 普通に筆算すればよかっただけか・・・
    val n = readLine()!!
    val ni = n.toInt()
    var count = 0
    val baseE = "7".repeat(n.length)
    val baseP = "7".repeat(n.length + 1)
    val base = if (baseE.toInt() >= ni) {
        count = n.length
        baseE.toInt()
    } else {
        count = n.length + 1
        baseP.toInt()
    }
    var next = 0
    val remain = mutableSetOf<Int>()
    var t = base
    while (t % ni != 0) {
        count++
        next = t % ni
        t = next * 10 + 7
        if (next == 0) {
            break
        }
        if (next in remain) {
            // ループする可能性もあるので、同じあまりが出現したらそれは実現不可能ということ
            println(-1)
            return
        } else {
            remain.add(next)
        }
    }
    println(count)
}


Measured memory_bytes: 116100
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll A, P;

int main() {
	scanf("%lld %lld", &A, &P);
	A *= 3;
	P += A;
	printf("%lld\n", P / 2);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline ll read(){
	ll k=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}
	return k*f;
}
const ll MOD=1e9+7;
ll n,m;
int main()
{
	n=read();m=read();
	if(abs(n-m)>1)return puts("0")&0;
	if(n<m)swap(n,m);
	if(n==m)
	{
		ll k=1;
		for(ll i=1;i<=n;i++)k=k*i%MOD;
		printf("%lld",k*k%MOD*2%MOD);
	}
	else
	{
		ll k=1;
		for(ll i=1;i<=m;i++)k=k*i%MOD;
		printf("%lld",k*k%MOD*n%MOD);
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    char a[1000];
    char b[1000];
    char sum[1000];
    scanf("%s\n", a);
    scanf("%s\n", b);
    if (strlen(a) > 80 || strlen(b) > 80) {
      cout << "overflow" << endl;
      continue;
    }
    int c = 0;
    int al = strlen(a);
    int bl = strlen(b);
    for (int i = 0; i < max(al, bl); i++) {
      int da, db;
      if (al-i-1>=0) da = a[al-i-1] - '0';
      else da = 0;
      if (bl-i-1>=0) db = b[bl-i-1] - '0';
      else db = 0;
      int s = da + db + c;
      if (s >= 10) {
        s -= 10;
        c = 1;
      } else {
        c = 0;
      }
      sum[i] = s + '0';
    }

    if ((al == 80 || bl == 80) && c == 1) {
      cout << "overflow" << endl;
      continue;
    }

    if (c == 1) cout << '1';
    for (int i = max(al, bl) - 1; i >= 0; i--) {
      cout << sum[i];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<algorithm>//everybody dies in their nightmares
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<string>
#include<vector>
#include<sstream>
#include<cmath>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
const ll mod = 1e9 + 7;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;

const int N = 6e5 + 5;
int t;
int c[15];
int a[15][15];
int now[15];
int main()
{
	int n, m, x;
	scanf("%d%d%d", &n, &m, &x);

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


	int res = 2e9;
	for (int i = 0; i < (1 << n); ++i)
	{
		int tres = 0;
		memset(now, 0, sizeof now);
		for (int j = 0; j < n; ++j)
		{
			if (i >> j & 1)
			{
				tres += c[j + 1];
				for (int k = 1; k <= m; ++k)
					now[k] += a[j + 1][k];
			}
		}

		bool flag = true;
		for (int j = 1; j <= m; ++j)
		{
			if (now[j] < x)
				flag = false;
		}

		if (flag)
			res = min(res, tres);
	}

	if (res == 2e9)
		printf("%d\n", -1);
	else
		printf("%d\n", res);

	return 0;
}





Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d;
  cin >> a >> b;
  c = a % 2;
  d = b % 2;
  if (c == 1 && d == 1) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>	tree_set;
typedef long long ll;
typedef long double ld;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

ll mod=1e9 + 7;

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

    ll rem = a-b;
    c = c - rem;
    cout<<max((ll)0,c);
}


Measured memory_bytes: 256
<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
$L = explode(" ",trim(fgets(STDIN)));

rsort($L);
$sum = array_sum($L)-$L[0];
if ($L[0]<$sum) {
  printf("Yes\n");
}
else {
  printf("No\n");
}


Measured memory_bytes: 4856
#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;
typedef long long ll;
#define int long long
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define sz(x) (int)x.size()
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef long double f80;

#ifndef LOCAL
#pragma GCC optimize ("O2")
#define endl '\n'
#endif

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

ll pwr(ll a,ll b, ll mod){
    a %= mod;
    int ans = 1;
    while(b){
        if(b & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

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.first) + ", " + to_string(p.second) + ")";
}

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

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const int N = 1e5 + 5;
int a[N];
map<int,int> m1, m2;
void solve(){
	int n;
	cin >> n;
	fr(i, 1, n){
		cin >> a[i];
		if(i & 1){
			m1[a[i]]++;
		}
		else{
			m2[a[i]]++;
		}
	}
	pii x = {0, 0}, y = {0, 0};
	int c1 = 0, c2 = 0;
	for(pii p : m1){
		if(p.se > x.se){
			x = p;
			c1 = 1;
		}
		else if(p.se == x.se){
			c1++;
		}
	}
	for(pii p : m1){
		if(p.se > y.se){
			y = p;
			c2 = 1;
		}
		else if(p.se == y.se){
			c2++;
		}
	}
	if(c1 == 1 && c2 == 1 && x.fi == y.fi){
		pii r = {0, 0}, s = {0, 0};
		for(pii p : m1){
			if(p.fi != y.fi && p.se > r.se){
				r = p;
			}
		}
		for(pii p : m2){
			if(p.fi != x.fi && p.se > s.se){
				s = p;
			}
		}
		cout << min(n - y.se - r.se, n - x.se - s.se);
		return;
	}
	cout << n - x.se - y.se;
}
signed main(){
    IO;
    #ifdef LOCAL
        freopen("inp.txt","r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    cout << setprecision(10) << fixed;
    int t = 1;
    // cin >> t;
    fr(tt, 1, t){
        solve();
    }
    return 0;
}

Measured memory_bytes: 7296