akhauriyash/Code-Regression huggingface dataset:
/*
   Author A.G.Maruf
   9 th sem :P
   code written 2019-12-08-10.44()
*/
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cctype>
#define gc              getchar
#define pc              putchar
#define pb              push_back
#define Sort_arr(n,x)   sort(n,n+x);
#define Sortr_arr(arr,x)  sort(arr, arr+n,greater<int>());
#define SortS(s)        sort(s.begin(), s.end());
#define SortRS(s)       sort(s.rbegin(), s.rend());
#define all(s)          s.begin(), s.end()a
#define GCin(a)         getline(cin,a);
#define Sz(a)           a.size()
#define arr_rev(n)      sort(n.begin(), n.end(), greater<int>());
#define Gin(a)          getline(cin,a);
#define input(a)        scanf("%d",&a);
#define Sz(a)           a.size()
#define input2(a,b)     scanf("%d %d",&a,&b);
#define input3(a,b,c)   scanf("%d %d %d",&a,&b,&c);
#define input4(a,b,c,d) cin>>a>>b>>c>>d;
#define rep(n)          for(int i=1;i<n;i++)
#define Fast_read       ios_base::sync_with_stdio(false);
#define Unique(n)       sort(Search(n)),n.erase(unique(Search(n)),n.end());
#define PI              3.1415926535897932384626433832795l
#define Ignore          cin.ignor3e();
#define out(n)          cout<<n<<endl;
#define mem(n,i)        memset(n,i,sizeof n);
#define square(n)       (n*n)
#define cube(n)         (n*n*n)
#define F               first
#define S               second
#define mxin            -INFINITY
#define mnin            INFINITY
#define el              <<endl
#define MAXC 1000
//#define N 1000000
using namespace std;

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/
//ll gcd(ll a,ll b){while(b){ll x=a%b;a=b;b=x;}return a;}
//ll lcm(ll a,ll b){return a/__gcd(a,b)*b;}
//ll qpow(ll n,ll k) {ll ans=1;assert(k>=0);n%=mod;while(k>0){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans%mod;}

//typedef pair <ll, ll> pll;
typedef long long int ll;
const int Max = 1e4 + 10;
const int MOD = 1e9 + 7;


int main (){


    int a,b,c;
    cin>>a>>b>>c;

    if (a+b+c>=22)
        cout<<"bust\n";
    else cout<<"win\n";
}


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

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             5e13
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>
#define all(a)          a.begin(),a.end()
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);

LL k;
LL ara[100005];

LL check(LL x)
{
//   cout << x << endl;
   for(int i = 1;i <= k;i++){
      x = (x/ara[i])*ara[i];
   }
   return x == 2;
}
int main()
{
   cin >> k;
   FOR(i,1,k)cin >> ara[i];

   LL ans = 2;
   for(int i = k;i>=1;i--){

      if(ans % ara[i] != 0){
         LL rem = ara[i] - ans % ara[i];
         ans += rem;
      }
   }

   LL temp = ans;
   for(int i = 1;i <= k;i++){
      temp = (temp/ara[i])*ara[i];
   }
   if(temp != 2){
      cout << -1 << endl;
      return 0;
   }
   LL lo = ans , hi = 4e18 , mid, answer;

   while(lo <= hi)
   {
      mid = (lo + hi)/2;
      if(check(mid)){
         answer = mid;
         lo = mid + 1;
      }else{
         hi = mid - 1;
      }
   }
   cout << ans << " " << answer << endl;

}




Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int main() {
	char s[101]; cin >> s;

	int p = 0;
	rep(i, 0, 101) {
		if (s[i + 1] == '\0') {
			p = i;
			break;
		}
	}

	cout << s[0] << p - 1 << s[p] << endl;

	return 0;
}

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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

template<class M, class N>
constexpr std::common_type_t<M, N> gcd(M m, N n) {
    return n == 0 ? abs(m) : gcd(n, abs(m) % abs(n));
}

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

    int N;
    std::cin >> N;

    set<ll> set;
    REP(i, N) {
        ll t;
        std::cin >> t;
        set.insert(t);
    }

    ll ans = 1;
    for(const auto& v : set) {
        ans = (ans / (long double)gcd(ans, v)) * v;
    }

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

    return 0;
}


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

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

  std::priority_queue<size_t> a;
  for (size_t i = 0; i < n; ++i) {
    size_t ai;
    std::cin >> ai;
    a.push(ai);
  }

  for (size_t i = 0; i < m; ++i) {
    const auto x = a.top();
    a.pop();
    a.push(x / 2);
  }

  size_t sum = 0;
  while (!a.empty()) {
    sum += a.top();
    a.pop();
  }

  std::cout << sum << std::endl;
}

Measured memory_bytes: 1400
#include <iostream>
#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <unordered_map>
#include <string>
//typedef long long LL;
//typedef long double LD;
using namespace std;

//#define MOD 1000000007

int main() {
    int n;
    map<string, int> a;
    string tmp_a;
    bool different=true;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> tmp_a;
        a[tmp_a]=1;
    }
    if(a.size()==n){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }



    return 0;
}

Measured memory_bytes: 24832
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1000000007;


int main(){
	ll X, Y;
	cin >> X >> Y;
	if(Y < X) swap(X, Y);

	if(X + 2 <= Y){
		cout << "Alice" << endl;
	}else{
		cout << "Brown" << endl;
	}

    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    try {
        val sc = Scanner(System.`in`)
        val n = sc.nextInt()
        val d = sc.nextInt()
        if (n < 1 || n > 20 || d < 1 || d > 20) {
            throw Exception("Unexpected input.")
        }
        val dd = 1 + 2 * d
        if ((n % dd) == 0) {
            println(n / dd)
        } else {
            println((n / dd) + 1)
        }
    } catch (e: Exception) {
        println(e)
    }
}

Measured memory_bytes: 29472
def solve(S):
    # N < 100

    pendings = 0
    prefix = 0
    for c in S:
        if c == '(':
            pendings += 1
        elif c == ')':
            pendings -= 1
        if pendings < 0:
            pendings = 0
            prefix += 1
    answer = '('*prefix + S
    if pendings > 0:
        answer += ')'*(pendings)
    print(answer)

N = int(input())
S = input()
solve(S)



Measured memory_bytes: 3060
import collections
N,M  = map(int,input().split())
mod = pow(10, 9) + 7

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def combination(n, r):
    ans = n
    for i in range(1, r):
        ans = ans * ((n - i) % mod) * pow(i + 1, mod - 2, mod)
        ans = ans % mod    
    return ans

c = collections.Counter(prime_factorize(M))

ans = 1
for num in c.values():
    ans = ans * combination(N - 1 + num, num)
    ans = ans % mod
print(ans)

Measured memory_bytes: 3316
#!/usr/bin/env python3
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    _ = int(readline())
    As = list(map(int, readline().split()))
    order = np.argsort(As)
    order = [str(o + 1) for o in order]
    print(' '.join(order))


if __name__ == '__main__':
    main()


Measured memory_bytes: 25324
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll a,b,c,K; cin >> a >> b >> c >> K;
    ll ans = 0;
    rep(i,a+1){
        rep(j,b+1){
            rep(k,c+1){
                if(i*500+j*100+k*50==K) ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,q,a[123456],l,r,A;
int main(){
    cin>>n>>q;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<q;i++){
        A=0;
        cin>>l>>r;
        int left = -1,right =n;
        while (right - left > 1) {
            int mid = (right+left)/2;
            if (a[mid]>=l) right = mid;
            else left = mid;
        }
        A+=right;
        left = -1,right =n;
        while (right - left > 1) {
            int mid = (right+left)/2;
            if (a[mid]<=r)left= mid;
            else right = mid;
        }A=left-A+1;
        cout<<A<<endl;
    }
}



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

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll n;
ll a[100];
//<<-----Implement Functions Here---->>//


//<<-----Start of Main--------------->>//
void MAIN(){
		ll pos;
		for(ll i=0;i<5;i++){cin>>a[i];if(a[i]==0)pos = i+1;}
		cout<<pos<<endl;


}

int main(){
	fastio;randomINIT;

	//cin>>t;
	while(t--){
		MAIN();
	}

   
}

Measured memory_bytes: 5884
#include <iostream>
#include <vector>
#include <climits>

using namespace std;

int main() {
    long int n, W;
    cin >> n >> W;
    const long int inf = LONG_MAX, profit = 1e5;
    vector<int> w(n), v(n);
    for (int i = 0; i < n; ++i) {
        cin >> w[i];
        cin >> v[i];
    }
    vector<vector<long int>> KS(n + 1, vector<long int>(profit + 1));
    for (int i = 0; i <= n; ++i) {
        KS[i][0] = 0;
    }
    for (int j = 1; j <= profit; ++j) {
        KS[0][j] = inf;
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= profit; ++j)
            if (j >= v[i - 1] && KS[i - 1][j - v[i - 1]] != inf)
                KS[i][j] = min(KS[i - 1][j], KS[i - 1][j - v[i - 1]] + w[i - 1]);
            else
                KS[i][j] = KS[i - 1][j];

    }
    long int i = profit;
    for (; i >= 0; --i)
        if (KS[n][i] <=W)break;
    printf("%li", i);
}



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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
  ll N; cin >> N;
  
  if(N == 0){
    cout << 0 << endl;
    return 0;
  } 
  
  string ans = "";
  while(N != 0){
    if((N%2) == 0) {
      ans = '0' + ans;
    } else {
      ans = '1' + ans;
      N--;
    }
    N/= -2;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;

    vector<int> C(N - 1), S(N - 1), F(N - 1);

    rep(i, N - 1) {
        cin >> C[i] >> S[i] >> F[i];
    }

    rep(i, N - 1) {
        ll x = S[i] + C[i];
        repd(j, i + 1, N - 1) {
            if (x < S[j]) {
                x = S[j] + C[j];
            }
            else {
                if ((x - S[j]) % F[j] == 0) {
                    x += C[j];
                }
                else {
                    int d = (x - S[j]) / F[j];
                    if ((x - S[j]) % F[j] != 0) {
                        d++;
                    }
                    x = S[j] + F[j] * d;
                    x += C[j];
                }
            }
        }
        cout << x << endl;
    }

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

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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    
    int x = 0;
    int ans = 0;

    rep(i, n) {
        if(s[i] == 'I') x += 1;
        else if(s[i] == 'D') x -= 1;
        ans = max(x, ans);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;

void main() {
  int n;
  readf (" %d", &n);
  auto a = new long[n];
  foreach (t; 0 .. n) {
    readf (" %d", &a[t]);
  }
  auto c = new long[n+1];
  foreach (i; 1 .. n + 1) {
    c[i] = c[i-1] + a[i-1];
  }
  immutable s = c[n];
  debug stderr.writeln (c);
  long res = long.max;
  foreach (i; 0 .. n + 1) {
    long t1 = c[i];
    long t2 = s - t1;
    debug stderr.writeln ("t1 = ", t1, ", t2 = ", t2);
    res = min (res, abs (t1 - t2));
  }
  writeln (res);
}



Measured memory_bytes: 4348
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);


// 素数判定
bool is_prime(ll n) {
    for (int i = 2; i * i <= n; i++) if (n % i == 0) return false;
    return n != 1;
}


ll q;
vector<ll> l, r;
vector<ll> prime_count(half_inf + 1, 0);

void solve() {
    repone(i, half_inf) {
        if (is_prime(i) && is_prime((i + 1) / 2)) prime_count[i] = prime_count[i - 1] + 1;
        else prime_count[i] = prime_count[i - 1];
    }
    rep(i, q) {
        cout << prime_count[r[i]] - prime_count[l[i] - 1] << endl;
    }
}

int main() {
    cin >> q;
    l.resize(q), r.resize(q);
    rep(i, q) cin >> l[i] >> r[i];
    solve();
    return 0;
}

Measured memory_bytes: 2944
//													\[T]/ Praise
//													 (*)  The
//													 / \  Sun



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

typedef long long ll;
typedef long double dbl;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<long long> vl;
typedef vector< pair<int, int> > vii;
#define mp make_pair
#define pb push_back
#define prinvec(a, n) for(ll i = 0; i < n; i++) cout << a[i] << " "; cout << "\n";
#define invec(a, n) for(ll i = 0; i < n; i++) {cin >> a[i];}
#define rep(n) for(ll i = 0; i < n; i++)
#define fr(i,j,k) for(ll i = j; i < k; i++)
#define FR(i,j,k) for(ll i = j; i >= 0; i--)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define INF 1000000
#define xx first
#define yy second

void fast()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

int main()
{

	int n;
	cin >> n;

	while(n > 0)
	{
		if(n % 10 == 7)
		{
			cout << "Yes";
			return 0;
		}
		n = n / 10;
	}

	cout << "No";
	return 0;

}

Measured memory_bytes: 3632
n, m = gets.split.map(&:to_i)

accepted = Array.new(n + 1, false)
wa = Array.new(n + 1, 0)

m.times do |i|
  q, s = gets.split
  q = q.to_i

  if s == 'AC'
    accepted[q] = true
  else
    wa[q] += 1 unless accepted[q]
  end
end

point = 0
penalty = 0

0.upto(n) do |i|
  if accepted[i]
    point += 1
    penalty += wa[i] 
  end
end

puts "#{point} #{penalty}"


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  vector<int> x(n);
  for (int i = 0; i < n; i++) cin >> x[i];
  auto a = x;
  sort(a.begin(), a.end());
  int m = n / 2;
  int l = a[m-1], r = a[m];
  for (int i = 0; i < n; i++) {
    int res = (x[i] >= r) ? l : r;
    cout << res << '\n';
  }
  return 0;
}

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

#define int long long
#define INF 1e18

int const mod = 1e9+7;

int n;

int tab[22][22];

int memo[2097152][22];

int dp(int mask, int a){
    if(a == n) return 1;
    if(memo[mask][a] != -1) return memo[mask][a];
    memo[mask][a] = 0;
    for(int i = 0; i < n; i++){
        if(tab[a][i] && !((1<<i)&mask)){
            memo[mask][a]+=dp(mask|(1<<i), a+1);
            memo[mask][a]%=mod;
        }
    }
    return memo[mask][a];
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 0; i< n; i++){
        for(int j = 0; j < n; j++){
            cin >> tab[i][j];
        }
    }
    for(int i = 0; i < 2097152; i++){
        for(int j = 0; j < 22; j++){
            memo[i][j] = -1;
        }
    }
    cout << dp(0,0) << endl;
}


Measured memory_bytes: 360832
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt(); //n冊
		int m = stdIn.nextInt(); //アルゴリズム数
		
		int x = stdIn.nextInt(); 
		
		int[] c = new int[n];
		
		int[][] a = new int[n][m];
		
		for(int i = 0; i < n; i++) {
			c[i] = stdIn.nextInt();
			for(int j = 0; j < m; j++) {
				a[i][j] = stdIn.nextInt();
			}
		}
      
		//まず達成可能か見る
		boolean flag = true;
		int min = Integer.MAX_VALUE;
		int boolcheck = 0;
					
Outer:	for(int bit = 0; bit < (1 << n); bit++) {
			int[] check = new int[m];
			int ans = 0;
			
			for(int j = 0; j < n; j++ ) {
				if(((bit>>j)&1)==1){
					ans += c[j];
					
					
					for(int k = 0; k < m; k++) {
						check[k]+= a[j][k];
					}
					
					
				}
				
				
			}
			
			for(int k = 0; k < m; k++) {
				if(check[k] < x) {
					boolcheck++;
					continue Outer;
				}
			}
			
			min = Math.min(ans, min);
			
			
			
		}
		
		if(boolcheck==(1<<n)) {
			System.out.println(-1);
		}else {
			System.out.println(min);
		}		
	}

}


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

using p_int = pair<int, int>;
bool comp_sec(p_int p, p_int q) {
    return p.second < q.second;
}

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

    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> c[n + 1];

    int p, y;
    int p_nums[m];
    for (int i = 1; i <= m; ++i) {
        cin >> p >> y;
        c[p].emplace_back(i, y);
        p_nums[i - 1] = p;
    }

    for (int i = 1; i <= n; ++i) {
        if (c[i].empty()) continue;
        sort(c[i].begin(), c[i].end(), comp_sec);
        int num = 1;
        for (auto &e: c[i]) {
            e.second = num++;
        }
    }
    for (int i = 1; i <= n; ++i) {
        if (c[i].empty()) continue;
        sort(c[i].begin(), c[i].end());
    }
    int c_ix[n + 1];
    fill(c_ix, c_ix + n + 1, 0);
    for (auto p_num: p_nums) {
        printf("%06d", p_num);
        printf("%06d\n", c[p_num][c_ix[p_num]++].second);
    }


    return 0;
}


Measured memory_bytes: 7808
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	int k, t;
	cin >> k >> t;
	int m = 0;
	rep(i, t) {
		int ki;
		cin >> ki;
		m = max(m, ki);
	}
	int n = k - m;
	if (n >= m - 1) {
		cout << 0 << endl;
	}
	else {
		cout << m - n - 1 << endl;
	}
}

Measured memory_bytes: 256
N, K = [ int(i) for i in input().strip().split(' ')]
count = 0
for k in range(K, N+2):
    count += 1/2*N*(N+1)-1/2*(N-k)*(N-k+1) - 1/2*k*(k-1) + 1
print(int(count) % (10**9+7))

Measured memory_bytes: 9152
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd (a, b)


A,B,C,D = map(int,input().split())
total = B - A + 1

tmp = lcm(C,D) 


C_1 = B//C
C_2 = (A-1)//C
C_total = C_1 - C_2

D_1 = B//D
D_2 = (A-1)//D
D_total = D_1 - D_2

tmp_1 = B//tmp
tmp_2 = (A-1)//tmp
tmp_total = tmp_1 - tmp_2
cnt = C_total + D_total - tmp_total
print(total-cnt)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	static Scanner scanner = new Scanner(System.in);
	static int[] dx = {0, 1, 0, -1};
	static int[] dy = {-1, 0, 1, 0};
	
	public static void main(String[] args) {
		int h = scanner.nextInt();
		int w = scanner.nextInt();
		char[][] map = new char[h + 2][w + 2];
		for (int i = 1; i < h + 1; i++) {
			String s = scanner.next();
			for (int j = 0; j < w; j++) {
				map[i][j + 1] = s.charAt(j);
			}
		}
		
		boolean isAchievable = true;
		loop: for (int i = 1; i < h + 1; i++) {
			for (int j = 1; j < w + 1; j++) {
				if (map[i][j] =='#') {
					boolean isBlack = false;
					for (int k = 0; k < 4; k++) {
						if (map[i + dy[k]][j + dx[k]] == '#') {
							isBlack = true;
						}
					}
					if (!isBlack) {
						isAchievable = false;
						break loop;
					}
				}
			}
		}
		
		System.out.println(isAchievable?"Yes" : "No");
		
		scanner.close();
	}
}


Measured memory_bytes: 21712
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;


int main(){
   string s;
   cin >> s;
   if(s=="Sunny") out("Cloudy");
   else if(s=="Cloudy") out("Rainy");
   else out("Sunny");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int val[N],n,cnt1,cnt2,x;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&val[i]);
		if(val[i]==1)cnt1++;
		else cnt2++;
		x|=val[i];
	}
	if(x%2==1)cout<<"first"<<endl;
	else cout<<"second"<<endl;
	return 0;
}
/*
1 1 1 1 1 
2 2

a 1
b !=1

*/

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

char S[111][111];

int main(void)
{
	int A, B;
	cin >> A >> B;
	for (int i = 0; i < 100; ++i) {
		for (int j = 0; j < 50; ++j) {
			S[i][j] = '.';
		}
		for (int j = 50; j < 100; ++j) {
			S[i][j] = '#';
		}
	}
	for (int i = 0; i < 100; ++i) {
		for (int j = 0; j < 25; ++j) {
			if (i % 2 == 0 && j % 2 == 0) {
				if (B > 1) {
					S[i][j] = '#';
					--B;
				}
			}
		}
	}
	for (int i = 0; i < 100; ++i) {
		for (int j = 75; j < 100; ++j) {
			if (i % 2 == 0 && j % 2 == 0) {
				if (A > 1) {
					S[i][j] = '.';
					--A;
				}
			}
		}
	}
	cout << "100 100\n";
	assert(A == 1 && B == 1);
	for (int i = 0; i < 100; ++i) {
		cout << S[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N,P,answer = 1,frequency;
  cin >> N >> P;
  if (N == 1) {
    cout << P;
    return 0;
  }
  for (int i = 2; 1ll*i*i <= P; i++) {
    for (frequency = 0; !(P%i); frequency++, P /= i);
    answer *= (long long)pow(i,frequency/N);
  }
  cout << answer;
}

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

using namespace std;
string s,t;
int dp[3005][3005];
int Rec(int i,int j){
if(i==s.length() || j==t.length())
    return 0;

if(dp[i][j]+1)
    return dp[i][j];
    long long Res=-2e9,Res1=-2e9,Res2=-2e9;
if(s[i]==t[j])
    Res=1+Rec(i+1,j+1);
else
{
    Res1=Rec(i+1,j);
    Res2=Rec(i,j+1);

}

return dp[i][j]=max(max(Res,Res1),Res2);

}





int main()
{
    cin>>s>>t;
    memset(dp,-1,sizeof(dp));
    Rec(0,0);
    for(int i=0,j=0; i<s.length() && j<t.length();)
                if(dp[i][j]==dp[i][j+1])
            j++;
        else if(dp[i][j]==dp[i+1][j])
            i++;
        else
        {
            if(s[i]==t[j])  cout<<s[i];
            i++;j++;
        }




    return 0;
}


Measured memory_bytes: 35840
/**
     **author : _KMS_
     **created : 17-03-2020
**/
#include<bits/stdc++.h>
using namespace std;
const long long M =1e6+100,MOD=2e9;
typedef long long ll;
map<int,int>mp;
int remov=0;
int main() 
{ 
      
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin>>n;
for(int i=0;i<n;i++){int a;cin>>a;mp[a]++;}
for(auto x : mp)
{
      if(x.first!=x.second)
      {
            if(x.second>x.first)remov+=(x.second-x.first);
            else remov+=x.second;
      }
}
cout<<remov<<"\n";


	return 0; 
} 

Measured memory_bytes: 4736
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let s: String = read(&mut stdin_lock, &mut buf, b'\n');
    let mut cs: Vec<char> = s.chars().collect();
    cs[3] = '8';
    let ans: String = cs.into_iter().collect();
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define MAX_V 1000000
#define INF 10000000
struct edge{int to,cap ,rev;};
vector<edge> G[MAX_V];
int level[MAX_V];//sからの距離
int iter[MAX_V];//どこまで調べ終わったか

void add_edge(int from ,int to, int cap){
    G[from].push_back((edge){to, cap, static_cast<int>(G[to].size())});
    G[to].push_back((edge){from, 0, static_cast<int>(G[from].size()-1)});
}

void bfs(int s){
    memset(level,-1,sizeof(level));
    queue<int> que;
    level[s] = 0;
    que.push(s);
    while(!que.empty()){
        int v = que.front();que.pop();
        for(int i = 0; i < G[v].size(); ++i){
            edge &e = G[v][i];
            if(e.cap > 0 && level[e.to] < 0){
                level[e.to] = level[v] + 1;
                que.push(e.to);
            }
        }
    }
}

int dfs(int v, int t, int f){
    if( v == t )return f;
    for(int &i = iter[v]; i < G[v].size(); ++i){
        edge &e = G[v][i];
        if(e.cap > 0 && level[v] < level[e.to]){
            int d = dfs(e.to, t, min(f,e.cap));
            if(d>0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}


int max_flow(int s, int t){
    int flow = 0;
    for(;;){
        bfs(s);
        if(level[t] < 0) return flow;
        memset(iter, 0, sizeof(iter));
        int f;
        while((f = dfs(s,t,INF)) > 0){
            flow += f;
        }
    }
}

int main(){
    int n;
    cin >> n;
    vector<int>a(n),b(n),c(n),d(n);
    rep(i,n){
        cin >> a[i] >> b[i];
    }
    rep(i,n){
        cin >> c[i] >> d[i];
    }
    rep(i,n){
        add_edge(2*n,i,1);
        add_edge(i+n,2*n+1,1);
        rep(j,n){
            if(a[i] < c[j] and b[i] < d[j]){
                add_edge(i,j+n,1);
            }
        }
    }
    cout << max_flow(2*n,2*n+1) << endl;
}

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

using namespace std;

#define rep(i,n) for(long i=0;i<n;i++)

int main(){
  long n,m;
  cin >> n >> m;
  long a[m],b[m],c[m];
  const long inf=100000000000000;
  rep(i,m){ 
    cin >> a[i] >> b[i] >> c[i];
    c[i]=-1*c[i];
    a[i]--;
    b[i]--;
  }  
   
  
  long dist[n];
   rep(i,n) dist[i]=inf;
  dist[0]=0;
  
  rep(j,n-1){
   rep(i,m){
    if(dist[a[i]]==inf) continue;
     dist[b[i]]=min(dist[b[i]],dist[a[i]]+c[i]);
   }
  }
  
 
  bool flag[n];
  rep(i,n) flag[i]=false;
  
  rep(j,n){
   rep(i,m){
    if(dist[a[i]]==inf) continue;
     if(dist[b[i]]>dist[a[i]]+c[i]){
      dist[b[i]]=dist[a[i]]+c[i];
       flag[b[i]]=true;
     }
     if(flag[a[i]]==true) flag[b[i]]=true;
     
   }
  
  }
  
  if(flag[n-1]) cout << "inf" << endl;
  else cout << -1*dist[n-1] << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  	long long n, k;
  	cin >> n >> k;
  	long long a[n], ans = 0;
  	for(int i = 0; i < n; i++) {
      	cin >> a[i];
    }
  	sort(a, a + n);
  	for(long long i = 0; i < (n - k); i++) {
      	ans += a[i];
    }
  	cout << ans << endl;
  	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <math.h>
#include <ctype.h>

using namespace std;

int main() {

    int n;
    cin>>n;

    n%=10;

    switch(n) {
        case 0:
        case 1:
        case 6:
        case 8: cout<<"pon"; break;
        case 2:
        case 4:
        case 5:
        case 7: 
        case 9: cout<<"hon"; break;
        case 3: cout<<"bon"; break;
    }

    

}



Measured memory_bytes: 3596
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>

using namespace std;

int main() {

	int n;
	cin>>n;
	string s;
	cin>>s;
	int64_t counter=1;
	char ch;
	char ex_ch;
	int ex_mode=0;
	bool beginning=true;
	for(int i=0;i<n;i++){
		ch=s.at(i);
		if(beginning){
			if(i<(n-1)&&s.at(i+1)==ch){
				counter=(counter*6)%1000000007;
				ex_mode=1;
				i++;
			}else{
				counter=(counter*3)%1000000007;
				ex_mode=0;
			}
			beginning=false;
		}else{
			if(i<(n-1)&&s.at(i+1)==ch){
				if(ex_mode==0){
					counter=(counter*2)%1000000007;
				}else{
					counter=(counter*3)%1000000007;
				}
				ex_mode=1;
				i++;
			}else{
				if(ex_mode==0){
					counter=(counter*2)%1000000007;
					ex_mode=0;
				}else{
					ex_mode=0;
				}
			}
		}

	}
	cout<<counter<<endl;



	return 0;

}


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

int main()
{
	int w, h, x, y, r;
	
	cin >> w >> h >> x >> y >> r;
	
	if(x>=r && x<=(w-r) && y>=r && y<=(h-r))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	
	return 0;
}



Measured memory_bytes: 3084
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

const ll mod = 1e9 + 7;

int main() {
  ll w, h;
  while (true) {
    cin >> w >> h;
    if (w == 0 && h == 0) break;
    vvll mp(h, vll(w, -1));
    vvll mk(h, vll(w, -1));
    rep(i, h) rep(j, w) cin >> mp[i][j];

    ll ans = 0;
    queue<P> que;
    bool pushcond;
    rep(i, h) {
      rep(j, w) {
        pushcond = mk[i][j] == -1 && mp[i][j] == 1;
        if (pushcond) {
          ans++;
          mk[i][j] = ans;
          que.emplace(i, j);
        }
        while (!que.empty()) {
          ll x, y;
          tie(y, x) = que.front();
          que.pop();
          mk[i][j] = ans;
          rep(k, 9) {
            ll nx = x + dx[k];
            ll ny = y + dy[k];
            bool insidecond = 0 <= nx && nx < w && 0 <= ny && ny < h;
            if (!insidecond) continue;
            pushcond = mk[ny][nx] == -1 && mp[ny][nx] == 1;
            if (pushcond) {
              mk[ny][nx] = ans;
              que.emplace(ny, nx);
            }
          }  // k
        }    // while
      }      // j
    }        // i

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



Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define endl '\n'
#define line cout<<"----------------------"<<endl
#define mp make_pair
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
const ll  mx=2000009;
ll  ara[101];
ll  ans[100009];
int main()
{
    ll  n,k;
    cin>>n>>k;
    for(ll  i=0;i<n;i++) cin>>ara[i];
    ans[0]=0;
    for(int i=1;i<=k;i++)
    {
        ll  maxi=INT_MAX;
        for(int j=0;j<n and ara[j]<=i;j++)
        {
            maxi=min(maxi,ans[i-ara[j]]);
        }
        if(maxi==0) ans[i]=1;

    }
    if(ans[k]) cout<<"First"<<endl;
    else cout<<"Second"<<endl;


}





Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000


int main(){

	int N;
	cin>>N;
	
	int k = -1;
	
	for(int i=1;i<=1000;i++){
		if((i-1)*i/2==N){
			k = i;
			break;
		}
	}
	
	if(k==-1){
		cout<<"No"<<endl;
		//cout<<-1<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	cout<<k<<endl;
	
	vector<vector<int>> ans(k,vector<int>());
	
	int now = 0;
	
	for(int i=0;i<k;i++){
		for(int j=0;j<k-1-i;j++){
			ans[i].push_back(now);
			now++;
		}
	}
	
	for(int i=0;i<k-1;i++){
		for(int j=0;j<k-1-i;j++){
			ans[i+1+j].push_back(ans[i][j]);
		}
	}
	
	for(int i=0;i<k;i++){
		cout<<k-1;
		for(int j=0;j<k-1;j++){
			cout<<' ';
			cout<<ans[i][j]+1;
		}
		cout<<endl;
	}
	
	
	
	return 0;
}

Measured memory_bytes: 2304
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner stdIn = new Scanner(System.in);
        int N = stdIn.nextInt();
        String S = stdIn.next();
        String answer = "Yes";

        if (N % 2 != 0) {
            System.out.println("No");
            System.exit(0);
        }

        for (int i = 0; i < N / 2; i++) {
            if (S.charAt(i) != S.charAt(N / 2 + i)) {
                System.out.println("No");
                System.exit(0);
            }
        }

        System.out.println(answer);
    }
}

Measured memory_bytes: 21844
import sys
from io import StringIO
import unittest
import os
import copy

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr


# 実装を行う関数
def resolve(test_def_name=""):
    n = int(input())
    a_s = list(map(int, input().split()))

    input_fact_s = []
    need_s = {}
    # 最小公倍数(素因数)割り出し
    for a in a_s:
        aaa = factorization(a)
        input_fact_s.append(aaa)
        for fact in aaa:
            need_s[fact[0]] = max(fact[1], need_s.get(fact[0], 0))
    lcm = 1
    for val, cnt in need_s.items():
        lcm = (lcm * pow(val, cnt))

    ans = 0
    for a in a_s:
        ans += lcm // a

    print(ans % (pow(10, 9) + 7))

    # テストクラス


class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """3
2 3 4"""
        output = """13"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """5
12 12 12 12 12"""
        output = """5"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """3
1000000 999999 999998"""
        output = """996989508"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


Measured memory_bytes: 82600
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
struct Node{
  int no;
  int par;
  int in_num;
  vector<Node*> child;
  void build(int i){
    no=i;par=i;in_num=0;
  }
};
signed main(){
  int n,m;cin>>n>>m;
  vector<Node> node(n+1);
  rep(i,n+1){
      node[i].build(i);
  }
  rep(i,n+m-1){
      int a,b;cin>>a>>b;
      node[a].child.push_back(&node[b]);
      node[b].in_num++;
  }
  vector<int> res(n+1,0);
  int root=0;
  rep1(i,n){
      if(node[i].in_num==0){
          root=i;
          break;
      }
  }
  queue<Node*> que;
  que.push(&node[root]);
  while(!que.empty()){
      Node* buf=que.front();que.pop();
      int num=buf->child.size();
      rep(i,num){
          buf->child[i]->in_num-=1;
          if(buf->child[i]->in_num==0){
              node[buf->child[i]->no].par=buf->no;
              res[buf->child[i]->no]=buf->no;
              que.push(buf->child[i]);
          }
      }
  }
  rep1(i,n){
      cout<<res[i]<<"\n";
  }
  return 0;
}

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

int main() {
  int N, A , B;
  
  cin >> N  >> A >> B;

 if(N*A> B){
 cout << B << endl;
 }
  else if(N*A == B){
  cout << B << endl;
  }
  else {
    cout << N*A << endl;
  }
  
  
}

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



int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif
    int n, k;
    cin >> n >> k;
    if (k == 1) cout << 0;
    else cout << n - k << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            string[] input = Console.ReadLine().Split(' ');

            int[] p = new int[N];

            for(int i = 0; i < N; i++)
            {
                p[i] = int.Parse(input[i]); //string型をint型に変更
            }


            int ans = 0;
            int t = 0;

            for(int i = 0; i < N; i++)
            {
               


                if(p[i] == i + 1)
                {
                   if(i < N - 1)
                    {
                        t = p[i + 1];
                        p[i + 1] = p[i];
                        p[i] = t;

                        ans++;
                    }
                    else //Pn=Nのとき
                    {
                        t = p[i - 1];
                        p[i - 1] = p[i];
                        p[i] = t;

                        ans++;
                    }
                }
            }

            Console.WriteLine(ans);
        }
    }
}


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

bool check(string str){
  stack<char> par;
  for(char c : str) {
    if(c == '(' or c == '[') {
      par.push(c);
    }else if(c == ')') {
      if(par.empty() or par.top() != '(') {
	return false;
      }
      par.pop();
    }else if(c == ']'){
      if(par.empty() or par.top() != '[') {
	return false;
      }
      par.pop();
    }
  }

  return par.empty();
}

int main() {
  string str;
  while(true) {
    getline(cin, str);
    if(str == ".") break;

    if(check(str)) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }
}

Measured memory_bytes: 3156
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;

ll pascal[61][61] = { { 0ll } };

int main(){
	for(int i = 0; i <= 60; ++i){
		pascal[i][0] = 1;
		for(int j = 1; j <= i; ++j){
			pascal[i][j] = pascal[i - 1][j - 1] + pascal[i - 1][j];
		}
	}
	while(true){
		int n, x;
		ll m;
		cin >> n >> m;
		if(n == 0 && m == 0){ break; }
		--m;
		if(m == 0){
			cout << string(n, '0') << endl;
			continue;
		}
		for(x = 0; x < n; ++x){
			if(m >= pascal[n][x]){
				m -= pascal[n][x];
			}else{
				break;
			}
		}
		string answer(n, '0');
		for(int y = x - 1, z = n; y > 0; --y){
			for(int w = y; w < z; ++w){
				if(m >= pascal[w][y]){
					m -= pascal[w][y];
				}else{
					answer[w] = '1';
					z = w;
					break;
				}
			}
		}
		answer[m] = '1';
		reverse(answer.begin(), answer.end());
		cout << answer << endl;
	}
	return 0;
}

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

int main(){
  int N;
  cin>>N;
  int A[N];
  int P[N];
  for(int i=0;i<N;i++){
    cin>>A[i];
    P[A[i]-1]=i;
  }
  int ans=1,cnt=1;
  for(int i=0;i<N-1;i++){
    if(P[i]<P[i+1]){
      cnt++;
    }
    else{
      cnt=1;
    }
    ans=max(ans,cnt);
  }
  /*int cnt2=1;
  for(int i=N-1;i>=1;i--){
    if(P[i]>P[i-1]){
      cnt2++;
    }
    else break;
  }*/
  cout<<N-ans<<endl;
  return 0;
}

  

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

int main(){
    int n, k;
    string a;
    cin >> n >> k;
    cin >> a;
    char a2 = a[k - 1];
    a[k - 1] = (a2 - 'A') + 'a';
    cout << a;
}


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

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int N, X, Y;
  cin >> N >> X >> Y, --X, --Y;
  vector<int> ans(N - 1, 0), dis(N, 0);
  for (int i = 0; i < N; ++i) {
    fill(begin(dis), end(dis), 0);
    for (int j = i + 1, d = 0; j < N; ++j)dis[j] = ++d;
    for (int j = i - 1, d = 0; j >= 0; --j)dis[j] = ++d;
    if (dis[X] > dis[Y])swap(X, Y);
    dis[Y] = min(dis[Y], dis[X] + 1);
    for (int j = Y + 1, d = dis[Y]; j < N; ++j)dis[j] = min(dis[j], ++d);
    for (int j = Y - 1, d = dis[Y]; j >= 0; --j)dis[j] = min(dis[j], ++d);
    for (int j = i + 1; j < N; ++j)++ans[dis[j] - 1];
  }
  for (auto& e : ans)cout << e << "\n";
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stack>
#include <math.h>

using namespace std;


int main(){

	int n,checkTable[6];

	double height;
	scanf("%d",&n);

	for(int i=0; i < 6; i++)checkTable[i] = 0;

	for(int i=0; i < n; i++){
		scanf("%lf",&height);

		if(height >= 185){
			checkTable[5]++;
		}else if(height >= 180){
			checkTable[4]++;
		}else if(height >= 175){
			checkTable[3]++;
		}else if(height >= 170){
			checkTable[2]++;
		}else if(height >= 165){
			checkTable[1]++;
		}else{
			checkTable[0]++;
		}
	}

	for(int i=0; i < 6; i++){
		printf("%d:",i+1);
		for(int k=0; k < checkTable[i]; k++){
			printf("*");
		}
		printf("\n");
	}

    return 0;
}

Measured memory_bytes: 2568
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

if sum(a) < sum(b):
    print(-1)
else:
    cnt = 0
    total = 0
    c = []
    for i in range(n):
        if a[i] < b[i]:
            cnt += 1
            total += (b[i]-a[i])
        else:
            c.append(a[i]-b[i])
    
    if cnt == 0:
        print(0)
    else:
        c.sort(reverse=True)
        d = 0
        for i in range(len(c)):
            d += c[i]
            if d >= total:
                print(cnt+i+1)
                break

Measured memory_bytes: 19508
import math
def solve(line):
    a = line[0]
    b = line[1]
    ans1 = math.floor(a/b)
    ans2 = a%b
    ans3 = round((a/b),6)
    print("{0} {1} {2}".format(ans1,ans2,ans3))

def answer():
    line = list(map(int,input().split()))
    solve(line)

if __name__ =='__main__':
    answer()


Measured memory_bytes: 5680