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

using namespace std;

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

    int gcdc = floor(m / (double)n);

    for (; gcdc >= 1; gcdc--){
        if (m % gcdc == 0){
            break;
        }
    }

    cout << gcdc << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
	int h,w;
	cin >> h >> w;
	vector<string> s(h);
	rep(i,h) cin >> s[i];
	int countsA = 0;
	int countsB = 0;
	bool ok = true;
	rep(i,h)rep(j,w){
		if(s[i][j] == '.') continue;
				countsA = 0;
				countsB = 0;
				int nx = i + 1;
				int nx1 = i - 1;
				int ny = j + 1;
				int ny1 = j - 1;
				if(nx >= 0 && nx < h && s[nx][j] == '.') countsA++;
				if(nx1 >= 0 && nx1 < h && s[nx1][j] == '.') countsA++;
				if(ny >= 0 && ny < h && s[i][ny] == '.') countsA++;
				if(ny1 >= 0 && ny1 < h && s[i][ny1] == '.') countsA++;
				if(nx >= 0 && nx < h) countsB++;
				if(nx1 >= 0 && nx1 < h) countsB++;
				if(ny >= 0 && ny < h) countsB++;
				if(ny1 >= 0 && ny1 < h) countsB++;
				if(countsB == countsA) ok = false;
	}
	if(ok) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3624
n=input()

k=len(n)
if k==6:
    print(9+900+90000)
elif k==5:
    print(9+900+int(n)-10000+1)
elif k==4:
    print(9+900)
elif k==3:
    print(9+int(n)-100+1)
elif k==2:
    print(9)
else:
    print(int(n))







Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main() 
{
  int a, b; char t;
  cin >> a >> t >> b;
  if(t == '+')cout << a+b << endl;
  else cout << a-b << endl;
  system("pause");
}

Measured memory_bytes: 504
# import sys
# input = sys.stdin.readline
s = input()
n = len(s)
ans = 0
t = 0
d = 0
m=0
for i in range(n):
    if s[i] == "<":
        d = 0
        t += 1
        ans += t
    else:
        if d==0:
            m = t
        t = 0
        d += 1
        ans += d-1
        if d-1 >= m:
            ans +=1
    # print(t,d,m,ans)
            
print(ans)

Measured memory_bytes: 42696
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

s = s_in()

if s[-1] == '3':
    print("bon")
elif s[-1] in '0168':
    print("pon")
else:
    print("hon")


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

int main(){
    double a[100],b[100];
    int so[100];
    char op[100];
    int i = 0;
    while(true){
        cin >> a[i] >> op[i] >> b[i];
        if(op[i] == '?')
            break;
        i++;
    }
    for(int j = 0; j < i; j++){
        if(op[j] == '+')
            so[j] = a[j] + b[j];
        else if(op[j] == '-')
            so[j] = a[j] - b[j];
        else if(op[j] == '*')
            so[j] = a[j] * b[j];
        else if(op[j] == '/')
            so[j] = a[j] / b[j];
        cout << so[j] << endl;
    }
}


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


def read():
    N = int(input().strip())
    T = list(map(int, input().strip().split()))
    M = int(input().strip())
    PX = []
    for i in range(M):
        p, x = map(int, input().strip().split())
        PX.append((p, x))
    return N, T, M, PX


def solve(N, T, M, PX):
    S = sum(T)
    for p, x in PX:
        ans = S - T[p-1] + x
        print(ans)


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
template<class T>
inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}
template<class T>
inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}
template<class T>
inline T GCD(T a, T b){if(a < b){T tmp=b;b=a;a=tmp;}return a % b != 0 ? GCD(b,a%b) : b;}
template<class T>
inline T LCM(T a, T b){return (a*b)/GCD(a,b);}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

int N, M;
int box[100050];
bool red[100050];

int main(){
    cin >> N >> M;
    FOR(i,1,N+1)box[i]=1;
    red[1]=true;
    FOR(i,1,M+1)
    {
        ll x, y;
        cin >> x >> y;
        box[x]--;
        box[y]++;
        if(red[x])red[y] = true;
        if(box[x]==0)red[x]=false;
    }
    int ans=0;
    FOR(i,1,N+1)
    {
        if(red[i])ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 768
#include <cstdio>

int main(){
    int n;
    scanf("%d",&n);
    int array[n];
    for(int i = 0;i < n;i++){
        scanf("%d",&array[i]);
    }
    for(int i = n - 1;i >= 1;i--){
        printf("%d ",array[i]);
    }
    printf("%d\n",array[0]);
    return 0;
}


Measured memory_bytes: 2740
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
    public static void main(String args[]) throws IOException {
    	InputStreamReader br = new InputStreamReader(System.in);
    	BufferedReader is = new BufferedReader(br);
    	String[] str = is.readLine().split(" ");
    	int a = Integer.parseInt(str[0]);
    	int b = Integer.parseInt(str[1]);
    	System.out.println((a*b) + " " + 2*(a+b));
    }
}

Measured memory_bytes: 24292
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  string T1 = "";
  string T2 = "";
  for (int i = 0; i < S.size(); i++){
    if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T'){
      T1 = T1 + S[i];
      if (T1.size() > T2.size()) T2 = T1;
    } else {
      T1 = "";
    }
  }
  cout << T2.size();
}

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

int main() {
	char a[2];
	cin >> a;
	int i;
	for (i = 0; i < 2; i++) {
		if (a[i] == '9') {
			cout << "Yes\n";
			break;
		}
		if (i == 1) {
			cout << "No\n";
		}
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int main(void) {
    string S, T;
    cin >> S >> T;
    int A, B;
    cin >> A >> B;
    string U;
    cin >> U;
    if (S == U) {
        A--;
    } else {
        B--;
    }

    cout << A << " " << B << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T &a, T b) {if (a < b) {a = b;return 1;}return 0;}
template<class T> inline bool chmin(T &a, T b) {if (a > b) {a = b;return 1;}return 0;}


int main(){
  double d,t,s;
  cin >> d >> t >> s;
  if ((double)d / s <= t) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3724
s = input()

s_1 = int(s[:2])
s_2 = int(s[2:])

ans = ""

if (0<s_1<=12):
  if (0<s_2<=12):
    ans = "AMBIGUOUS"
  else:
    ans = "MMYY"
else:
  if (0<s_2<=12):
    ans = "YYMM"
  else:
    ans = "NA"
    
print(ans)


Measured memory_bytes: 38384
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
#include <climits>  // A/Bを計算するときA==LLONG_MIN && B==-1のみ(1ull<<63)で代用
using namespace std;

typedef long long LL;
typedef pair<LL, LL> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;				// VVL v(100,VL(100,0));
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<LL, pair<P, P> > PP;

#define INF 999999999999999997		// 少し加算したらオーバーフローする
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) if(dbgF){FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定
string Replace(string S, string from, string to) { auto p = S.find(from); while (p != string::npos) { S.replace(p, from.size(), to); p = S.find(from, p + to.size()); }return S; }

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// -------------------------------------------------------------------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	LL a, b, c, d;
	cin >> a >> b >> c >> d;
	LL ans = min(a, b) + min(c, d);
	O(ans);

	return 0;
}

Measured memory_bytes: 256
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/




int main() {
int N;
cin>>N;
ll A[N];
rep(i,N){
  cin>>A[i];
}
sort(A,A+N);
reverse(A,A+N);
int p=0,num=0;
ll count=0;
rep(i,N-1){
  if(i==0){
    count+=A[p];
    num=2;
  }
  else{
    if(num==2){
      p++;
      num=1;
      count+=A[p];

    }
    else{
      num++;
      count+=A[p];
    }
  }

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

Measured memory_bytes: 5200
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <deque>
#include <set>
#include <numeric>
using namespace std;
using ll = long long;

#define no "no"
#define No "No"
#define NO "NO"
#define yes "yes"
#define Yes "Yes"
#define YES "YES"
#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return (0)
#define rep(i, n) for (int(i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for (int(i) = (start); (i) < (end); (++i))
#define foreach(elem, _list) for (auto &(elem) : (_list))
#define view(_list)      \
    foreach (e, _list)   \
    {                    \
        cout << e << sp; \
    }                    \
    cout << next
#define FAST                     \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr)
#define size(s) (s).size()
#define ALL(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e)
#define INF 1e+9
#define PI acos(-1)
#define TAU PI * 2
#define EPS 0.00000001
const ll MOD = 1000000007;

ll dp[100010];

int main()
{
    int n, m;
    cin >> n >> m;
    vector<bool> v(n + 1, true);
    rep(i, m){
        int a;
        cin >> a;
        v[a] = false;
    }

    dp[0] = 1;
    for(int i = 0; i < n; ++i){
        for(int j = i + 1; j <= std::min(n, i + 2); ++j){
            if(v[j]){
                dp[j] += dp[i];
                dp[j] %= MOD;
            }
        }
    }

    println(dp[n]);
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
    int P,Q,R;
    cin >> P >> Q >> R;
 	int min_val = 300;
    if(P+Q<min_val)	min_val = P+Q;
   	if(Q+R<min_val)	min_val = Q+R;
    if(P+R<min_val)	min_val = P+R;
  	cout << min_val << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    string s;
    int n,sum;
    cin>>n>>s;
        for(int i=0 ;i<s.size() ;i++)
        {
              sum=(int)(s[i]-'A')+n;
             if (sum>=26)
             sum-=26;
           cout<<(char)(sum+'A');
        }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int M, F, B;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> M >> F >> B;

    int d = M - B;
    if (0 <= d) {
        // 足りた
        printf("0\n");
        return;
    }

    if (0 <= d + F) {
        // 借りれば足りる
        printf("%d\n", -d);
        return;
    }

    // 足りない
    printf("NA\n");
}


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

char c[4]={'E','W','N','S'};

int main(){
	int n;
	string s;
	cin>>n;
	unordered_map<string ,int> sm;
	for(int i=0;i<n;i++){
		cin>>s;
		sm[s]++;
	}
	cout<<sm.size()<<endl;

}


Measured memory_bytes: 17544
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

class SP{
public:
    string s;
    int p;
    int num;
    bool operator<(const SP &ano) const {
        if(s == ano.s){
            return p > ano.p;
        }else{
            return s < ano.s;
        }
    };
};

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<SP> sp(n);
    REP(i,n){
        cin>>sp[i].s>>sp[i].p;
        sp[i].num = i + 1;
    }
    SORT(sp);
    REP(i,n){
        PUTS(sp[i].num);
    }
}

Measured memory_bytes: 256
#import sys
#input = sys.stdin.readline
def main():
    N = int( input())
    T = [ (0,0)]*N
    for i in range(N):
        a, b = map( int, input().split())
        T[i] = (b,a)
    T.sort()
    time = 0
    ans = "Yes"
    for i in range(N):
        time += T[i][1]
        if time > T[i][0]:
            ans = "No"
            break
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 29392
#include<iostream>
using namespace std;
int main(){
int n;
  cin>>n;
  long long a[n];
 for(int i=0;i<n;i++){
   cin>>a[i];
 }
  long long max=0,ans=0;
  for(int i=0;i<n;i++){
    if(max<a[i]){
      max=a[i];
    }
    else ans+=max-a[i];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 5168
#include <cstdio>
#include <algorithm>
#include <vector>
#define file(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)

inline int read()
{
	int data = 0, w = 1; char ch = getchar();
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') w = -1, ch = getchar();
	while (ch >= '0' && ch <= '9') data = data * 10 + (ch ^ 48), ch = getchar();
	return data * w;
}

const int N(2e5 + 10), Mod(1e9 + 7);
int fac[N], inv[N], f[N], n, m, A, B;
int C(int n, int m) { return 1ll * fac[n + m] * inv[m] % Mod * inv[n] % Mod; }
int fastpow(int x, int y)
{
	int ans = 1;
	for (; y; y >>= 1, x = 1ll * x * x % Mod)
		if (y & 1) ans = 1ll * ans * x % Mod;
	return ans;
}

int main()
{
	n = read() - 1, m = read() - 1, A = read() - 1, B = read() - 1, fac[0] = inv[0] = 1;
	if (A == n || B == m) return puts("0"), 0;
	for (int i = 1; i <= n + m; i++) fac[i] = 1ll * fac[i - 1] * i % Mod;
	inv[n + m] = fastpow(fac[n + m], Mod - 2);
	for (int i = n + m - 1; i; i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % Mod;
	int ans = C(n, m);
	for (int i = 0; i <= A; i++)
		ans = (ans - 1ll * C(i, m - B - 1) * C(n - i, B) % Mod + Mod) % Mod;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1664
n = int(input())


ans_num = 0
for i in range(1, n+1):

    if i % 2 != 0:
        ans = 0        
        for j in range(1, i+1):
            if i % j ==0:
                ans += 1
        if ans == 8:
            ans_num += 1

print(ans_num)

Measured memory_bytes: 9048
def main():
    X, N = map(int, input().split())
    p = list(map(int,input().split()))
    p.sort()
    p2 = []
    judge = 1000
    temp = 1000
    ans = 1000

    for i in range (-1,102):
        if i in p:
            continue
        else:
            p2.append(i)

    for j in p2:
        temp = abs(X - j)
        if temp < judge:
            judge = temp
            ans = j

    return ans

print(main())


Measured memory_bytes: 9192
#include <stdio.h>
using namespace std;
int main()
{
	int a,b,c;
	//freopen("lab.in","r",stdin);
	//freopen("lab.out","w",stdout);
	scanf("%d%d%d",&a,&b,&c);
	printf("%d%c%d%c%d",c,' ',a,' ',b);
	return 0;
}


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

using namespace std;

const int N = 1e5+15;

int par[N];

multiset<int> s[N];

int find(int a){
    if(par[a]==a)return a;

    return par[a]= find(par[a]);
}
void merge(int a,int b){
    a= find(a),b = find(b);

    if(a==b)return;
    
    par[b]= a;
}
int val[N];

int remain[N];
int main(){
    int n,m,i,a,b;

    cin>>n>>m;

    for(i=0;i<n;++i)par[i]= i,scanf("%d",&val[i]);

    for(i=0;i<m;++i){
        scanf("%d%d",&a,&b);
        merge(a,b);
    }
    
    int cc=0;
    vector<int> id;
    for(i=0;i<n;++i){
        s[find(i)].insert(val[i]);


        
        if(i==find(i))++cc,id.push_back(i);
    }
    
    int tot = 2*(cc-1);

    long long ret=0;
    
    --cc;
    priority_queue<pair<int,int>,vector<pair<int,int> >, greater<pair<int,int> > > q;
    for(i=0;i<id.size();++i){
        int u = id[i];
        
        remain[u]= min(cc,(int)s[u].size());
        
        if(remain[u]){
            --remain[u];
            ret+= *s[u].begin();
            s[u].erase(s[u].begin());

            if(remain[u])
                q.push(make_pair(*s[u].begin(),u));
            --tot;
        }
    }

    while(tot>0 && q.size()>0){
        ret += q.top().first;
        int u = q.top().second;
        q.pop();

        --remain[u];
        --tot;
        s[u].erase(s[u].begin());
        if(remain[u]){
            q.push(make_pair(*s[u].begin(),u));
        }
    }

    if(tot>0){
        printf("Impossible\n");
        return 0;
    }
    else
        cout<<ret<<endl;
}   


Measured memory_bytes: 11260
#include <stdio.h>
int main()
{
 long long i,j,a,b,c,k;
  scanf("%lld %lld %lld %lld",&a,&b,&c,&k);
  if(k)
  {
    if(k>=a)
    {
        k-=a;
    if(k>=b)
    {
        k-=b;
      printf("%lld\n",a-k);
    }
    else
      printf("%lld\n",a);
    }
    else
      printf("%lld\n",k);
  }
  else
    printf("0\n");
  return 0;
}


Measured memory_bytes: 2144
#include "bits/stdc++.h"
using namespace std;

int main() {
	int k, s;
	cin >> k >> s;

	int ans = 0;
	int v = min(s, k);

	for (int x = 0; x <= v; x++) {
		for (int y = 0; y <= v; y++) {
			int z = s - x - y;
			if (z <= v && z >= 0)	ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3596
#include <cstdio>
#include <cctype>

int main(){
	int i=0, a[26]={0};
	char ch;
	
	while( scanf("%c", &ch) != EOF ){
		if( isupper(ch) ) 
			ch = tolower(ch);
	
		if('a'<=ch && ch<='z') 
			++a[ ch-'a' ];
	
		++i;
	}

	for(int x=0; x<26; ++x)
		printf("%c : %d\n", 'a'+x, a[x]);

	return 0;
}



Measured memory_bytes: 2664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vrsort(v) sort((v).rbegin(), (v).rend())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 2000000009
#define MOD 1000000007
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  ll l,r;cin>>l>>r;
  //caricurate
  if((l%2019==0)||(r%2019==0)){cout<<0<<endl;return 0;}
  if((l%673)>=(r%673)){cout<<0<<endl;return 0;}
  if((r-l)>=673){cout<<0<<endl;return 0;}
  ll nw,ans;ans=2039;
  for(ll h=l;h<r;h++){
    for(ll f=h+1;f<r+1;f++){
      nw=(f*h)%2019;
      if(nw<ans){ans=nw;}
    }
  }
  //output
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007


string s,ans;
int main() {
	cin >> s;
	REP(i, s.size()) {
		if (s[i] == '0')ans.push_back('0');
		if (s[i] == '1')ans.push_back('1');
		if (s[i] == 'B' and ans.size() > 0)ans.erase(ans.size() - 1);
	}
	cout << ans << endl;
}



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

using namespace std;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	
	int a,b;
	cin >> a >> b;

	cout << (a + b + 2 - 1) / 2 << endl;

	return 0;
}

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

int n, m;
int start[200005], goal[200005];

int main(void){
  cin >> n >> m;
  for(int i = 0; i < m; i++){
    int s, t;
    cin >> s >> t;
    if(s == 1){
      start[t] = 1;
    }
    if(t == n){
      goal[s] = 1;
    }
  }
  for(int i = 0; i < n; i++){
    if(start[i] == 1 and goal[i] == 1){
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=200100;
const int md=1e9+7;
struct node{
	int x,v;
}a[maxn];
bool cmp(const node &A,const node &B){
	if(A.x==B.x) return A.v>B.v;
	return A.x<B.x;
}
struct Line{
	int l,r;
}b[maxn];
int c[maxn],tr[maxn];
int num;
void updata(int x,int v){
	while(x<=num){
		tr[x]=(tr[x]+v)%md;
		x+=x&(-x);
	}
}
int qury(int x){
	if(x<0) return 0;
	int res=1;
	while(x){
		res=(res+tr[x])%md;
		x-=x&(-x);
	}
	return res;
}
int main(){
//	freopen("E.in","r",stdin);
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&a[i].x,&a[i].v);

	for(int i=1;i<=n;i++)
		c[i]=a[i].v;
	sort(c+1,c+n+1);
	num=unique(c+1,c+n+1)-(c+1);
	for(int i=1;i<=n;i++)
		a[i].v=lower_bound(c+1,c+num+1,a[i].v)-c;

	sort(a+1,a+n+1,cmp);

	int mx=a[1].v,mn=a[n].v;
	for(int i=1;i<=n;i++)
	{
		if(a[i].v>mx) mx=a[i].v;
		b[i].r=mx;
	}
	for(int i=n;i>=1;i--)
	{
		if(a[i].v<mn) mn=a[i].v;
		b[i].l=mn;
	}

	int ans=0,res=0;
	for(int i=1;i<=n;i++){
		res=(qury(b[i].r)-qury(b[i].l-2)+md)%md;
		if(b[i].r==num) ans=(ans+res)%md;
		updata(b[i].r,res);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<int ,int >
#define F first
#define S second
#define mod 1000000007
///distance(s.begin(),s.lower_bound(101))
using namespace std;
ll add(ll a,ll b){
    return ((a%mod)+(b%mod))%mod;
}

ll mul(ll a,ll b){
    return ((a%mod)*(b%mod))%mod;
}
void topo(int i,vector<int>arr[],int vis[],stack<int >&s){
    vis[i]=1;
    for(auto x:arr[i]){
        if(vis[x]==0)
        topo(x,arr,vis,s);
    }
    s.push(i);
}
void topsort(int n,vector<int >arr[]){
    int vis[n]={0}; stack<int >s;
    for(int i=0;i<n;i++){
        if(vis[i]==0) topo(i,arr,vis,s);
    }
    int dp[n]={0};
    while(!s.empty()){
        for(auto x:arr[s.top()]){
            dp[x]=max(dp[x],dp[s.top()]+1);
        }
        s.pop();
    }
    cout <<*max_element(dp,dp+n);

}
int main(){
    int n,m;cin >>n >>m;
    vector<int > arr[n];
    for(int i=0;i<m;i++){
        int x,y;cin >>x>>y;
        x--;y--;
        arr[x].push_back(y);

    }
    topsort(n,arr);
}


Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int c=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[s.size()-1]=='s') c=1;
        else c=0;

    }
    if(c==1) cout<<s<<"es"<<endl;
    else cout<<s<<"s"<<endl;

}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define MOD 1000000007

int main() {
    int N, K;
    cin >> N >> K;
    vi V(52, 0);
    rep(i, N) cin >> V[i];
    vi S(52, 0), T(52, 0);
    rep(i, N) {
        S[i + 1] = S[i] + V[i];
        T[i + 1] = T[i] + V[N - 1 - i];
    }

    int ans = 0;
    for (int A = 0; A <= min(N, K); A++) {
        for (int B = 0; A + B <= min(N, K); B++) {
            vi X;
            rep(i, A) X.pb(V[i]);
            rep(i, B) X.pb(V[N - 1 - i]);
            sort(all(X));
            int fsum = 0, R  = K - A - B;
            rep(i, min(A + B, R)) {
                if (X[i] < 0) fsum += X[i];
                else break;
            }
            ans = max(ans, S[A] + T[B] - fsum);
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
from collections import defaultdict

N = int(input())

class BinomialCoefficient(object):

    def __init__(self, N=510000, MOD=10**9+7):
        self.fac = [1, 1]
        self.finv = [1, 1]
        self.inv = [0, 1]
        self.MOD = MOD
        for i in range(2, N + 1):
            self.fac.append((self.fac[-1] * i) % MOD)
            self.inv.append((-self.inv[MOD % i] * (MOD // i)) % MOD)
            self.finv.append((self.finv[-1] * self.inv[-1]) % MOD)

    def comb(self, n, r):
        if r < 0 or n < r or r < 0:
            return 0
        return self.fac[n] * self.finv[r] * self.finv[n - r] % self.MOD


bc = BinomialCoefficient(N)
d = dict()
for i in range(1, N + 1):
    key = str(i)[0] + str(i)[-1]
    if d.get(key) is None:
        d[key] = 1
    else:
        d[key] += 1

ans = 0
for k, v1 in d.items():
    v2 = d.get(k[1] + k[0])
    if v2 is not None:
        ans += v1 * v2

print(ans)


Measured memory_bytes: 81392
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
  int n , m ;
  cin >> n >> m ;
  vector<string> S ;
  rep(i,n){
    string t ;
    cin >> t ;
    S.push_back(t) ;
  }
  sort(S.begin(),S.end()) ;
  rep(i,n) cout << S.at(i);
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    char a,b;
    
    string n;
    cin >> n;
    if(n[0] == n[1] && n[1] == n[2] ){
        cout << "Yes" << endl;
    }else if( n[1] == n[2] && n[2] == n[3]   ){
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }

}


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

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    vector<int> a;
    int tmp;
    int num = 1;
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        a.emplace_back(tmp);
        if (tmp != num)
        {
            ans++;
        }else
        {
            num++;
        }
        
    }

    if (ans == N) ans = -1;

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

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

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

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

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

signed main(){
	int n,ans = 0;
	cin >> n;
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= n;j++){
			for(int k = 1;k <= n;k++) ans += gcd(i,gcd(j,k));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3636
import math

n = int(input())

soinsu = []

c = n
if (c % 2 == 0):
    while True:
        soinsu.append(2)
        c = c // 2
        if ( c % 2 != 0):
            break

len = int(math.sqrt(c)) + 1
for i  in range (3,len,2):
    while True:
        if ( c % i != 0):
            break
        soinsu.append(i)
        c = c // i
    if ( c == 1):
        break
if ( c != 1):
    soinsu.append(c)

d = n
for i in set(soinsu):
    d = d * (1-(1/i))
print (int(d))


Measured memory_bytes: 5664
#include <stdio.h>

int main(void)
{
	int n, sum;
	int score[6];
	
	sum = 0;
	for (n = 0; n < 5; n++) {
		scanf("%d", &score[n]);
		if (score[n] < 40) {
			score[n] = 40;
		}
		sum += score[n];
	}
	
	printf("%d\n", sum / 5);
	
	return (0);
}

Measured memory_bytes: 600
D = int(input())
c = [int(_) for _ in input().split()]
s = [[int(_) for _ in input().split()] for _ in range(D)]

sat = 0
last = [0] * 26
for d in range(D):
    v = -1000000
    for x in range(26):
        if v < d - last[x] + c[x]:
            j = x
            v = d - last[x] + c[x]
    last[j] = d + 1
    print(j+1)

    for i in range(26):
        sat -= (d + 1 - last[i]) * c[i]
    sat += s[d][j]
    # print(sat)


Measured memory_bytes: 9504
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int N;
vector<int> V[150010];
double ans[150010];
double s[150010];

void dfs(int p , int q){
	for(int u : V[q]){
		if(p == u) continue;
		dfs(q,u);
		if((int)V[u].size() > 1) s[q] += s[u] / (V[u].size()-1) + 1.0;
		else s[q] += 1.0;
	}
	//printf("  %d %f\n" , q , s[q]);
}

void dfs2(int p , int q){
	ans[q] = s[q] / V[q].size();
	//printf("    %d %f\n" , q , s[q]);
	for(int u : V[q]){
		if(p == u) continue;
		if((int)V[q].size() > 1) s[u] += (s[q] - ((int)V[u].size() > 1 ? s[u] / (V[u].size()-1) : 0.0) - 1.0) / (V[q].size()-1) + 1.0;
		else s[u] += 1.0;
		dfs2(q,u);
	}
}

int main(){
	scanf("%d" , &N);
	if(N == 1){
		printf("0.0\n");
		return 0;
	}
	repp(i,1,N){
		int a,b;
		scanf("%d%d" , &a , &b);
		V[a].PB(b);
		V[b].PB(a);
	}
	dfs(-1,1);
	dfs2(-1,1);
	repp(i,1,N+1){
		printf("%.9f\n" , ans[i]);
	}
	return 0;
}


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

using namespace std;

int main() {
	vector<bool> isprime(1300000, true);
	isprime[0] = isprime[1] = false;
	vector<int> prime;
	for (long long i = 2; i < 1300000; ++i) {
		if (isprime[i]) {
			prime.push_back(i);
			for (long long j = i * i; j < 1300000; j += i) isprime[j] = false;
		}
	}
	int k;
	while (cin >> k, k) {
		auto it = lower_bound(prime.begin(), prime.end(), k);
		if (*it == k) cout << 0;
		else cout << *it - *(it - 1);
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3392
#include <iostream>
using namespace std;
int main(void)
{
    int n, h, w;
    int tmp1 = 1;
    int tmp2 = 1;
    int ans;
    cin >> n >> h >> w;
    tmp1 += n - w;
    tmp2 += n - h;
    ans = tmp1 * tmp2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
    int main(){
        int a, b;
            cin >> a >> b;
                if(a == 1 || a == 3 || a == 5 || a == 7 || a == 8 || a == 10){
                    if(b == 3 || b == 5 || b == 7 || b == 8 || b == 10 || b == 12){
                        cout << "Yes" << endl;
                            return 0;
                    }else{
                        cout << "No" << endl;
                            return 0;
                    }
                }else if(a == 4 || a == 6 || a == 9){
                    if(b == 6 || b == 9 || b == 11){
                        cout << "Yes" << endl;
                            return 0;
                    }else{
                        cout << "No" << endl;
                            return 0;
                    }
                }else{
                    cout << "No" << endl;
                        return 0;
                }
    return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool is_palin(string a,int l,int h){
while(l<h)
{
    if(a[l++]!=a[h--]) return false;
}
return true;
}
int main(){
string a;
cin>>a;
int n=a.size();
if(is_palin(a,0,n-1) && is_palin(a,0,(n-1)/2-1) && is_palin(a,(n+3)/2-1,n-1))
        cout<<"Yes";
else cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int long long
 
// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// typedef
typedef std::vector<int> VI;
typedef std::vector<VI> VII;
typedef std::vector<bool> VB;
typedef std::vector<std::string> VS;

std::string yes = "Yes\n";
std::string no = "No\n";

void solve();

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

void solve() {
  std::string s;
  std::cin >> s;
  REP(i, 3) {
    if (s.at(i) == s.at(i+1)) {
      cout("Bad\n");
      return;
    }
  }
  cout("Good\n");
}

Measured memory_bytes: 256
# coding = SJIS

a, b = map(int, input().split())
s = str(input())

num = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]

for i in range(a):
    if s[i] not in num:
        print("No")
        exit()
if s[a] != "-":
    print("No")
    exit()
for i in range(b):
    if s[(-1) * i] not in num:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 9032
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int X = sc.nextInt();
		int[] C = new int[N];
		int[][] A = new int[N][M];
		for (int i = 0; i < N; i++) {
			C[i] = sc.nextInt();
			for (int j = 0; j < M; j++) {
				A[i][j] = sc.nextInt();
			}
		}
		int res = Integer.MAX_VALUE;
		loop: for (int i = 0; i < (1 << N); i++) {
			int[] dp = new int[M];
			int tmpRes = 0;
			for (int j = 0; j < N; j++) {
				if (((i >> j) & 1) == 1) {
					tmpRes += C[j];
					for (int j2 = 0; j2 < dp.length; j2++) {
						dp[j2] += A[j][j2];
					}
				}
			}
			for (int j2 = 0; j2 < dp.length; j2++) {
				if (dp[j2] < X) {
					continue loop;
				}
			}
			if (res > tmpRes) {
				res = tmpRes;
			}
		}
		if (res == Integer.MAX_VALUE) {
			System.out.println(-1);
		} else {
			System.out.println(res);
		}
	}
}


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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
//#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0,x=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000],c;

	int ara[n_size],ara2[n_size];

	cin>>n;
    cin>>s;

	stack<char>stk;


	f(i,0,n-1){
        if(s[i]=='('){
            stk.push('(');
        }
        if(s[i]==')'){
            if(stk.empty()) x++;
            if(stk.empty()==false) stk.pop();
        }
	}
    //cout<<stk.size()<<endl;


	f(i,1,x) cout<<"(";
	cout<<s;
    f(i,1,stk.size()) cout<<")";

    cout<<endl;
}


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

int main() {
  int N, K; cin >> N >> K;
  long long ans = 0;
  for(int b = 1; b <= N; ++b) {
    // cout << (N/b) * max(b-K, 0) << endl;
    // cout << max(0, (N%b)-K+1) << endl;
    ans += (N/b)*max(b-K, 0) + max(0, (N%b)-K+1);
  }
  if(K==0) ans -= N;
  cout << ans << endl;
}


Measured memory_bytes: 256
#参考
#https://atcoder.jp/contests/aising2019/submissions/3995168
 
import bisect
 
N,Q=map(int,input().split())
 
A=list(map(int,input().split()))
Asum=[0]*N
Asum2=[0]*N
total=0
 
for i in range(N):
  total+=A[i]
  Asum[i]=total
  if i>1:
    Asum2[i]=A[i]+Asum2[i-2]
  else:
    Asum2[i]=A[i]
 
X=[] 
for i in range(Q):
  X.append((int(input()),i))
X.sort(key=lambda x :x[0])
  
 
#yで高橋くんと青木くんの取りたいカードが初めて衝突すると考える。
#このようなyは半分より小さい所にはないので初期値を半分のところとする。
#yがNまで来た時は最初から交互に取る
#Xを小さい順から計算することで、yの値が単調増加になる
y=N//2-1
ans=[0]*Q
for x,i in X:
  #条件式はy<=N-1を最初に持ってこないとA[y]の参照でエラーの可能性
  while y<=N-1 and x>A[y]:
    y+=1
  while y<=N-1:
    takahashi=N-y
    aoki=y+1-bisect.bisect_left(A,x-(A[y]-x))
    if takahashi>aoki:
      y+=1
    else:
      break
  #右端からA[y]までは全て高橋くんが取る
  ans[i]+=Asum[N-1]-Asum[y-1]
  #青木くんはyからN-y個取っているので、その下のところから交互に取る
  if y-(N-y)-1<0:
    continue
  ans[i]+=Asum2[y-(N-y)-1]
 
for i in range(Q):
  print(ans[i])

Measured memory_bytes: 37268
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define MOD 998244353
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans = 1;
int N, maxVal = 0;
vi D;
map<ll, ll> mp;

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

void solve(){
    rep(i, N){
        if((i == 0 && D[i] != 0) || (i != 0 && D[i] == 0)){
            cout << 0 << endl;
            return;
        }
        mp[D[i]]++;
        maxVal = max(maxVal, D[i]);
    }

    int prev = 1;

    rep(i, maxVal+1){
        if(mp[i] == 0){
            cout << 0 << endl;
            return;
        }
        ans *= modpow(prev, mp[i], MOD);
        prev = mp[i];
        ans %= MOD;
    }

    cout << ans << endl;
}

int main(){
    cin >> N;
    D.resize(N);

    rep(i, N) cin >> D[i];

    solve();
}


Measured memory_bytes: 7032
using System;
using System.Linq;

namespace Volume0_0026
{
    class Program
    {
        static void Main(string[] args)
        {
            int[,] paper = new int[10,10];

            string input;
            while( ( input = Console.ReadLine() ) != null)
            {
                int[] inkData = input.Split(',').Select(s => Convert.ToInt32(s)).ToArray();
                InkBase ink;
                switch(inkData[2])
                {
                    case 1: ink = new InkSmall(paper); break;
                    case 2: ink = new InkMedium(paper); break;
                    case 3: ink = new InkLarge(paper); break;
                    default: throw new Exception();
                }
                ink.Apply(new Point(inkData[0], inkData[1]));
            }

            var result = paper.Cast<int>().ToList();
            Console.WriteLine(result.Where(i => i == 0).Count());
            Console.WriteLine(result.Max());
        }
    }

    public abstract class InkBase
    {
        protected int[,] Paper;
        protected int[,] Data { get; set; }

        public InkBase(int[,] paper)
        {
            Paper = paper;
        }

        public virtual void Apply(Point center)
        {
            int offsetX = center.X - Data.GetLength(1) / 2 < 0 ? Data.GetLength(1) / 2 - center.X : 0;
            int offsetY = center.Y - Data.GetLength(0) / 2 < 0 ? Data.GetLength(0) / 2 - center.Y : 0;

            int startX = Math.Max(center.X - Data.GetLength(1) / 2, 0);
            int endX = Math.Min(center.X + Data.GetLength(1) / 2 + 1, Paper.GetLength(1) );
            int startY = Math.Max(center.Y - Data.GetLength(0) / 2, 0);
            int endY = Math.Min(center.Y + Data.GetLength(0) / 2 + 1, Paper.GetLength(0) );

            for (int y = startY; y < endY; y++)
            {
                for (int x = startX; x < endX; x++)
                {
                    Paper[y, x] += Data[y - startY + offsetY, x - startX + offsetX];
                }
            }
        }
    }
    public class InkSmall : InkBase
    {
        public InkSmall(int[,] paper) : base(paper)
        {
            Data = new int[3, 3]
            {
                { 0,1,0 },
                { 1,1,1 },
                { 0,1,0 }
            };
        }
    }
    public class InkMedium: InkBase
    {
        public InkMedium(int[,] paper) : base(paper)
        {
            Data = new int[3, 3]
            {
                { 1,1,1 },
                { 1,1,1 },
                { 1,1,1 }
            };
        }
    }
    public class InkLarge : InkBase
    {
        public InkLarge(int[,] paper) : base(paper)
        {
            Data = new int[5, 5]
            {
                { 0,0,1,0,0 },
                { 0,1,1,1,0 },
                { 1,1,1,1,1 },
                { 0,1,1,1,0 },
                { 0,0,1,0,0 }
            };
        }
    }
    public class Point
    {
        public int X { get; set; }
        public int Y { get; set; }
        public Point(int x, int y)
        {
            X = x;
            Y = y;
        }
    }
}

Measured memory_bytes: 9552