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

using namespace std;

namespace {
constexpr size_t MX = 3001;
int64_t dp[4][MX][MX];
}

int main() {  
  int64_t R, C, K;
  cin >> R >> C >> K;

  vector<vector<int64_t>> values(R, vector<int64_t>(C));
  for (int64_t k = 0; k < K; ++k) {
    int64_t r, c, v;
    cin >> r >> c >> v;
    values[r-1][c-1] = v;
  }
  
  for (size_t r = 0; r < R; ++r) {
    for (size_t c = 0; c < C; ++c) {
      for (size_t k = 0; k < 4; ++k) {
        dp[k][r][c] = -1;
      }
    }
  }
  dp[0][0][0] = 0;
  for (int64_t r = 0; r < R; ++r) {
    for (int64_t c = 0; c < C; ++c) {
      int64_t value = values[r][c];
      int64_t next = 0;
      for (int64_t k = 3; k > 0; --k) {
        if (value != 0 && dp[k-1][r][c] >= 0) {
          dp[k][r][c] = max(dp[k][r][c], dp[k-1][r][c] + value);
        }
        if (c != C-1) dp[k][r][c+1] = dp[k][r][c];
        next = max(next, dp[k][r][c]);
      }
      if (c != C-1) dp[0][r][c+1] = max(dp[0][r][c+1], dp[0][r][c]);
      dp[0][r+1][c] = max(dp[0][r][c] + value, next);
    }
  }
  cout << dp[0][R][C-1] << endl;

  
  return 0;
}


Measured memory_bytes: 355076
program main
implicit none
integer :: i, j, k, a, b
character(10) :: s, t, u

read(*,*) s, t
read(*,*) a, b
read(*,*) u
if( s == u ) then
   a = a-1
else
   b = b-1
end if
write(*,'(i0, a1, i0)') a,'', b

end program main

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define ll long long int
#define Y printf("YES\n")
#define N printf("NO\n")
#define mp make_pair
#define pb push_back
#define tp make_tuple
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define pr(a) printf("%lld\n",a)
using namespace std;

int main()
{
    ll n,i,j,k,l,p,q,t,x,y;

    sc(n);

    k=0;

    for(i=0;i<n;i++){

        cin>>x;
        k+=(x-1);
    }

    cout<<k<<endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

const i64 MOD = 1e9 + 7;

i64 mpow(i64 x, i64 n)
{
  i64 ret = 1;
  while (n > 0)
  {
    if (n & 1)
      ret = ret * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return ret;
}

int main()
{
  i64 N;
  cin >> N;
  vector<i64> A(N), B(N);
  for (i64 i = 0; i < N; i++)
    cin >> A[i] >> B[i];
  map<pair<i64, i64>, i64> m;
  for (i64 i = 0; i < N; i++)
  {
    i64 g = gcd(A[i], B[i]);
    if (B[i] < 0)
    {
      A[i] *= -1;
      B[i] *= -1;
    }
    if (g == 0)
    {
      g = 1;
    }
    if (A[i] / g == -1 && B[i] / g == 0)
      A[i] *= -1;
    m[{A[i] / g, B[i] / g}]++;
  }
  vector<i64> tmp;
  for (pair<pair<i64, i64>, i64> i : m)
    if (0 < i.second && i.first != make_pair(0LL, 0LL))
    {
      tmp.push_back((mpow(2, i.second) - 1 + mpow(2, m[{-i.first.second * (0 < i.first.first ? 1 : -1), abs(i.first.first)}]) - 1) % MOD);
      m[{-i.first.second * (0 < i.first.first ? 1 : -1), abs(i.first.first)}] = -1;
    }
  i64 ans = 1;
  for (i64 i : tmp)
    ans = (ans * i + ans) % MOD;
  cout << (ans - 1 + MOD + m[{0, 0}]) % MOD << endl;
  return 0;
}


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

int main() {
    string s;
    cin >> s;
    bool flag = 1;
    for (int i=0;i<s.size();i++) {
        if (i%2 == 0) {
            if (s[i] == 'L') flag = 0;
        } else {
            if (s[i] == 'R') flag = 0;
        }
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
main()
{
	int w=0,x=0,p=0,len,i,y=0,z=0,cnt=0,c,cex=0;
	char s[10000];
	scanf("%s",s);
	len=strlen(s);
	if(s[0]=='A')
	{
		w=1;
	}
	for(i=2;i<len-1;i++)
	{
		if(s[i]>='A' && s[i]<='Z')
		{
			cnt++;
			c=i;
		}
	}

	if(cnt==1 && s[c]=='C')
	{
		x=1;
	}
	if(s[len-1]=='C' || (s[len-1]>='a' && s[len-1] <='z'))
	{
		y=1;
	}
	for(i=1;i<len-1;i++)
	{
		if(i!=c){
		if(s[i]>='a' && s[i]<='z' )
		{
			z=1;
		}
		else if(s[i]<'a' || s[i]>'z'){
		break;}}
	}
	if(w==1 && x==1 && y==1 && z==1)
	{
		printf("AC\n");
	}
	else printf("WA\n");
	//printf("%d%d%d%d",w,x,y,z);
}

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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL(x) memset(x,0,sizeof(x))


using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

int main()
{
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  
  priority_queue<ll> p,q,r;
  rep(i, A)
    {
      ll tmp;
      cin >> tmp;
      p.push(tmp);
    }

   rep(i, B)
    {
      ll tmp;
      cin >> tmp;
      q.push(tmp);
    }
   
   rep(i, C)
    {
      ll tmp;
      cin >> tmp;
      r.push(tmp);
    }

   ll ans=0;

   rep(i, X)
     {
       if(p.top()>r.top())
	 {
	   //	   cout << p.top() << endl;
	   ans += p.top();
	   p.pop();
	 }
       else
	 {
	   //cout << r.top() << endl;
	   ans+=r.top();
	   r.pop();
	   r.push(p.top());
	   p.pop();
	 }
     }

   rep(i, Y)
     {
       if(q.top()>r.top())
	 {
	   //cout << q.top() << endl;
	   ans += q.top();
	   q.pop();
	 }
       else
	 {
	   //cout << r.top() << endl;
	   ans+=r.top();
	   r.pop();
	   r.push(q.top());
	   q.pop();
	 }
     }

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


//cout << setprecision(13);
//next_permutation();
//__gcd();
//reverse();
//set ,tuple ,pair;
//bitset
//vector.find
//vector.count



Measured memory_bytes: 3316
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

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

typedef long long ll;

int main()
{
   ll n,s;
   cin>>n>>s;
   if(n>s)
   cout<<"safe";
   else
   cout<<"unsafe";

    return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
typedef long long ll;
using namespace std;

int main(){
    int n;cin>>n;
    ll ans=0;
    string s;cin>>s;
    vector<int> r(n,0);
    vector<int> g(n,0);
    vector<int> b(n,0);
    for(int i=0;i<n;i++){
        if(s[i]=='R') r[i]++;
        else if(s[i]=='G') g[i]++;
        else b[i]++;
        if(i!=0){
            r[i]+=r[i-1];
            g[i]+=g[i-1];
            b[i]+=b[i-1];
        }
    }
    for(int i=0;i<n-2;i++){
        for(int j=i+2;j<n;j++){
            if((s[i]=='R'&&s[j]=='G')or(s[i]=='G'&&s[j]=='R')){
                ans+=b[j-1]-b[i];
                if((j+i)%2==0){
                    if(s[(j+i)/2]=='B') ans--;
                }
            }
            else if((s[i]=='R'&&s[j]=='B')or(s[i]=='B'&&s[j]=='R')){
                ans+=g[j-1]-g[i];
                if((j+i)%2==0){
                    if(s[(j+i)/2]=='G') ans--;
                }
            }
            else if((s[i]=='B'&&s[j]=='G')or(s[i]=='G'&&s[j]=='B')){
                ans+=r[j-1]-r[i];
                if((j+i)%2==0){
                    if(s[(j+i)/2]=='R') ans--;
                }
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3620
/*  
    |\_/|
    |* *|
    \_+_/
*/
#include<bits/stdc++.h>

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  int a[3];

  for(int i=0;i<3;i++){
    cin>>a[i];
  }

  sort(a,a+3);

  cout<<a[0]+a[1]<<endl;
  
  
  return 0;

}




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

#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[n]; rep(i,n){ gets(x[i]);}
#define ll long long

int main(){
  int a, b, x;
  cin >> a >> b >> x;
  if (x >= a && a+b >= x) {
    puts("YES")
  }else{
    puts("NO")
  }
}


Measured memory_bytes: 256
function Main(input) {
	input = input.split("\n");
	var count = input[0]-0;
  var values = input[1].split(" ");
  
	for(var i = 0; i < count; i++) values[i] = values[i] - 0;
  
  values.sort(function(a,b){ return a - b; });
  
  var previous = values[0];
	for(var i = 1; i < count; i++) {
		previous = (previous + values[i]) / 2;
	}
	console.log(previous);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
// AOJ 2603 TiMe Table
// 2018.3.19 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// [library]
//#define getchar_unlocked()  getchar()
int in()	// get non-negative integer from stdin
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}
// [\library]  

int t[2002], x[2002];
int w[2002][2002];
int dp[2002][2002];
int minima[2002];

int cmp(int *a, int *b) { return *a - *b; }

void cminima(int d,int ia,int ib,int ja,int jb)
{
	int j, id, mn, tmp, im;

	if (ia > ib) return;
	if (ia == ib) {
		mn = 0, id = -1;
		for (j = ja; j <= jb; j++) {
			tmp = dp[j][d] + w[j+1][ia];
			if (id < 0 || mn > tmp) id = j, mn = tmp;
		}
		minima[ia] = id;
		return;
	}
	im = (ia + ib)/2;
	cminima(d, im, im, ja, jb);
	cminima(d, ia, im-1, ja, minima[im]);
	cminima(d, im+1, ib, minima[im], jb);
}

int main()
{
	int S, N, M, tm, p, i, d, k, ans;
	int lo, hi;

	S = in(), N = in(), M = in();
	if (M >= N) { puts("0"); return 0; }
	for (i = 1; i <= S; i++) x[i] = in();
	for (i = 0; i < N; i++) {
		tm = in(), p = in();
		t[i] = tm - x[p];
	}
	qsort(t, N, sizeof(int), cmp);
	if (M == 1) {
		tm = t[N-1], ans = 0;
		for (i = 0; i < N; i++) ans += tm - t[i];
		printf("%d\n", ans);
		return 0;
	}

	memset(dp, 0x30, sizeof(dp));
	for (hi = 0; hi < N; hi++) {
		for (lo = hi-1; lo >= 0; lo--) w[lo][hi] = w[lo+1][hi] + t[hi]-t[lo];
	}
	for (i = 0; i < N; i++) dp[i][0] = w[0][i];
	M--; for (d = 1; d <= M; d++) {
		cminima(d-1, 0, N-1, 0, N-1);
		for (i = 0; i < N; i++) k = minima[i], dp[i][d] = dp[k][d-1]+w[k+1][i];
	}
	printf("%d\n", dp[N-1][M]);
	return 0;
}


Measured memory_bytes: 31300
n,m = map(int,input().split())
h = list(map(int,input().split()))
route = []
lower = []
cnt = 0
for i in range (m):
    s = list(map(int,input().split()))
    if h[s[0]-1] > h[s[1]-1]:
        lower.append(s[1])
    elif h[s[1]-1] > h[s[0]-1]:
        lower.append(s[0])
    elif h[s[1]-1] == h[s[0]-1]:
        lower.append(s[0])
        lower.append(s[1])
low = list(set(lower))
cnt =n-len(low)
print(cnt)


Measured memory_bytes: 20172
//By Zank100
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define din(t) long long t;cin>>t;
#define in(t) cin>>t;
ll mul(ll a, ll b)
{
    return(((a%mod)*(b%mod))%mod);
}
ll modexp(ll b, ll e){
	ll res = 1;
	for(; e; b = b * b % mod, e >>= 1) if(e & 1) res = res * b % mod;
	return res;
}
ll modinv(ll a){
    ll x=mod-2;
	return modexp(a,x);
}
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	char c;
	in(c);
	if(c<'a')cout<<"A\n";
	else cout<<"a\n";
	/*while(t--)
	{
        din(d);

    }*/
	return 0;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    for(int i=k;i<n;i++){
        if(a[i]>a[i-k]) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}



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

int main() {
	int N;
	cin >> N;
	vector<int> X(N);

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

	int ans;
	for (int i = 1; i < 101; i++) {
		int sum = 0;
		for (int j = 0; j < N; j++) {
			sum += (X[j] - i) * (X[j] - i);
		}
		if (i == 1) {
			ans = sum;
		}
		else {
			if (sum < ans) {
				ans = sum;
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)

#include <algorithm>
int main(){
	int n,k,l[51],ans=0;
	cin >> n >> k;
	FOR(i,0,n) cin >> l[i];
	sort(l,l+n);
	FOR(i,0,k) ans += l[n-1-i];
	cout << ans;
	return 0;
}

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

bool match(std::string&, std::string&, unsigned int);

int main()
{
	std::string t, p;
	std::cin >> t >> p;
	std::vector<int> ans;
	for (unsigned int t_i{}; t_i + p.size() <= t.size(); t_i++)
		if (match(p, t, t_i))
			ans.push_back(t_i);
	for (auto& e: ans)
		printf("%d\n", e);

	return 0;
}

bool match(std::string& p, std::string& t, unsigned int begin_i)
{
	for (unsigned int p_i{}; p_i < p.size(); p_i++)
		if (p[p_i] != t[begin_i + p_i])
			return false;
	return true;
}


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

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on

ll H, W;
int x, y;

int main(void)
{
  cin >> W >> H >> x >> y;
  printf("%lf %d\n", (double)W * (double)H / 2, (x + x == W && y + y == H));
  return 0;
}


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

ll dp[105][100005];
int N,W;
ll w[105];
ll v[105];
const ll INF = 1e14;
int main() {
  cin >> N >> W;
  for(int i = 0; i < N; i++) {
    cin >> w[i] >> v[i];
  }

  for(int i = 0; i <= N; i++) {
    fill(dp[i],dp[i]+N*1000+1,INF);
  }
  dp[0][0] = 0;
  dp[0][v[0]] = w[0];

  for(int i = 1; i < N; i++) {
    for(int j = 0; j <= (i + 1) * 1000; j++) {
      if(dp[i-1][j] == INF) continue;
      dp[i][j] = min(dp[i][j],dp[i-1][j]);
      dp[i][j+v[i]] = min(dp[i][j+v[i]],dp[i-1][j] + w[i]);
    }
  }

  for(int i = N * 1000; i >= 0; i--) {
    if(dp[N-1][i] <= W) {
      cout << i << endl;
      return 0;
    }
  }
}
  


Measured memory_bytes: 80128
#include <cstdio>
#include <algorithm>

#define MAX_N (4000)

using namespace std;

typedef long long lint;

int main()
{
	int N;
	lint w[MAX_N], rSum[MAX_N];
	static lint dp[MAX_N][MAX_N];
	static int pos[MAX_N][MAX_N];
	
	scanf("%d", &N);
	
	for (int i = 0; i < N; i++){
		scanf("%lld", w + i);
		rSum[i] = i ? rSum[i - 1] + w[i] : w[i];
	}
	
	for (int i = 0; i < N; i++){
		for (int j = 0; j < N; j++){
			dp[i][j] = (lint)1e16;
		}
		dp[i][i] = 0;
		pos[i][i] = i;
	}
	
	for (int w = 1; w < N; w++){
		for (int i = 0, j; (j = i + w) < N; i++){
			for (int k = pos[i][j - 1]; k <= pos[i + 1][j]; k++){
				lint nc = dp[i][k] + dp[k + 1][j] + rSum[j] - (i ? rSum[i - 1] : 0);
				if (nc < dp[i][j]){
					dp[i][j] = nc;
					pos[i][j] = k;
				}
			}
		}
	}
	
	printf("%lld\n", dp[0][N - 1]);
	
	return (0);
}

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

long long N, Q;
//              X　　           移動後の start, end
vector<pair<long long, pair<long long, long long> > > ST;
//               場所 , index
set<pair<long long, long long> >D;
long long ans[200005];

int main(){
	cin >> N >> Q;
	for(long long i = 0; i < N; i++){
		long long s,t,x;
		cin >> s >> t >> x;
		ST.push_back(make_pair(x, make_pair(s-x, t-x)));
	}
	for(long long i = 0; i < Q; i++){
		long long d;
		cin >> d;
		D.insert(make_pair(d, i));
	}

	sort(ST.begin(), ST.end());
	
	for(long long i = 0; i < ST.size(); i++){
		long long start = ST[i].second.first;
		long long end = ST[i].second.second;
		long long x = ST[i].first;
		//cout << ST[i].first.first << "," << ST[i].first.second << endl;
		//cout << ST[i].second.first << ",,,," << ST[i].second.second << endl;

		auto it = D.lower_bound(make_pair(start, -1));
		while(it != D.end() && (*it).first < end){
			ans[(*it).second] = x;
			D.erase(it++);
		}
	}
	for(long long i = 0; i < Q; i++){
		if(ans[i] != 0){
			cout << ans[i] << endl;
		}else{
			cout << -1 << endl;
		}
	}
}



Measured memory_bytes: 21740
package main
  
import (
    "fmt"
    "math"
)

func main() {
    var a, b int
    fmt.Scan(&a, &b)

    var sum int
    for i := 0; i < 45; i++ {
        k := int(math.Pow(2, float64(i)))
        bb := calc(b, k)
        ba := calc(a-1, k)
        sum += k * (bb ^ ba)
    }
    fmt.Println(sum)
}

func calc(n, k int) int {
    if n < 0 {
        n = 0
    }
    if k == 1 {
        switch n % 4 {
        case 1, 2:
            return 1
        default:
            return 0
        }
    }
    r := (n % (k * 2)) - k
    if r >= 0 {
        return 1 - (r % 2)
    }
    return 0
}


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

int main(){
    double pai=3.141592653589;
    char s[100], p[100];
    string scp,s2,chk;
    scanf("%s %s",&s,&p);
    scp=s;
    chk=p;
    s2=scp+scp;
    if(s2.find(p) != string::npos){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 3264
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
       
using namespace std;
       
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
 
// #define MAX 100010
 
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
        // freopen("input.txt","r",stdin);
        // freopen("output.txt","w",stdout);
    // #endif
    int n;
    cin>>n;
    long long int ans = (n*800) - ((n/15)*200);
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    
    int n,d,x;
    cin >> n >> d >> x;
    vector<int> a(n+10,0);
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int ans = x;
    int k;
    for(int i = 1; i <= n; i++){
        k = 0;
        while(1){
            if(k*a[i]+1 <= d){
                ans++;
            }else{
                break;
            }
            k++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m,k,cnt[31],ans,a;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	for (int i=0;i<n;i++)
	{
		cin>>k;
		for (int j=0;j<k;j++) cin>>a,cnt[a]++;
	}
	for (int i=1;i<=m;i++) if (cnt[i]==n) ans++;
	cout<<ans;
	return 0;
}

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

int main(){
  int a, b;
  cin >> a >> b;
  
  if (a <= b){
    
    for (int i = 0; i < b; i++){
      cout << a;
    }
  }
  else{
    
    for (int j = 0; j < a; j++){
      cout << b;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
int judge(int i){
    int tmp=i,sum=0;
    while(tmp){
        tmp/=10;
        sum++;
    }
    return sum;
}
int main()
{
    int n,sum=0;
    cin>>n;
    for(int i=n;i>=0;i--){
        if(judge(i)%2==1)sum++;
    }
    cout<<sum<<endl;
    return 0;
}


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

int f(vector<vector<int>> &v, vector<bool> &visited, vector<int> &dp, int &n, int cvor)
{
	if (visited[cvor])
		return dp[cvor];
	visited[cvor] = true;
	int mxduzina = 1;
	for (auto x : v[cvor])
		mxduzina = max(mxduzina, 1 + f(v, visited, dp, n, x));
	return dp[cvor] = mxduzina;
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n, w, a, b, mx = 0;
	cin >> n >> w;
	vector<vector<int>> v(n+1);
	vector<bool> visited(n + 1, false);
	vector<int> dp(n + 1, 0);
	for (int i = 0; i < w; i++)
	{
		cin >> a >> b;
		v[a].push_back(b);
	}
	for (int i = 1; i <= n; i++)
		if (visited[i] == false)
			mx=max(mx,f(v, visited, dp, n, i));
	cout << mx-1;
}

Measured memory_bytes: 9600
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

int main()
{
    ll p[3];
    vector<ll> hash(105, 0);

    rep(i, 0, 3) cin >> p[i];

    rep(i, 0, 3)
        hash[p[i]] = 1; 

    cout << count_if(hash.begin(), hash.end(), [](ll x){return x > 0;}) << endl;

    return 0;
}


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

signed main(){
    int n;
    cin >> n;
    string s[n];
    REP(i,n){
        cin >> s[i];
    }
    ll ans = 0;
    map<string, int> mp;
    REP(i,n){
        sort(ALL(s[i]));
        ans += mp[s[i]];
        mp[s[i]]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 18176
import math
ND=input().split()
N=int(ND[0])
D=int(ND[1])
cont=0

for i in range(N):
  XY=input().split()
  X=int(XY[0])
  Y=int(XY[1])

  d= math.sqrt(pow(X,2) + pow(Y,2) )

  if d<D or d==D:
    cont+=1  
  
print(cont)

Measured memory_bytes: 9104
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	string s[100],t[100];
	vector<string> v;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s[i];
		v.push_back(s[i]);
	}
	cin>>m;
	for(int i=0;i<m;i++){
		cin>>t[i];
		v.push_back(t[i]);
	}
	v.erase(unique(v.begin(),v.end()),v.end());
	int cnt=0;
	for(int i=0;i<v.size();i++){
		int tmp=0;
		for(int j=0;j<n;j++) if(s[j]==v[i]) tmp++;
		for(int j=0;j<m;j++) if(t[j]==v[i]) tmp--;
		cnt=max(tmp,cnt);
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((size_t *)a) < *((size_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

int main(void) {
	size_t N, T;
	size_t minCost = (size_t)UINT32_MAX;

	scanf("%zu %zu\n", &N, &T);
	for (size_t idx = 0; idx < N; idx++) {
		size_t c, t;
		scanf("%zu %zu", &c, &t);
		if (idx < N - 1) {
			scanf("\n");
		}

		if (t <= T && c < minCost) {
			minCost = c;
		}
	}

	if (minCost == (size_t)UINT32_MAX) {
		puts("TLE");
	}
	else {
		printf("%zu", minCost);
	}

	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
using namespace std;
typedef long long ll;
const int maxn = 105;

string s;
int dfs(int l,int r){
  if(l>=r)return 0;
  if(s[l]==s[r])return dfs(l+1,r-1);
  if(s[l]!='x'&&s[r]!='x')return -1;
  if(s[l]=='x'){
    int tt=dfs(l+1,r);
    if(tt==-1)return -1;
    return tt+1;
  }
  int tt=dfs(l,r-1);
  if(tt==-1)return -1;
  return tt+1;
}

int main() {
#ifdef suiyuan2009
  freopen("in.cpp","r",stdin);
#endif // suiyuan2009
  cin>>s;
  cout<<dfs(0,s.size()-1)<<endl;
  return 0;
}



Measured memory_bytes: 5120
#include "iostream"
using namespace std;

int LinearSearch(int x, int S[], int N) {
	S[N] = x;
	for (int i = 0; ; i++) {
		if (S[i] == x)
			if (i < N) {
				return 1;
			}
			else
				return 0;
	}
}

int main()
{
	int h[6] = { 1 };
	int w;
	while (1) {
		for (int i = 0; i < 5; i++) {
			cin >> h[i];
			if (h[i] == 0)
				break;
		}
		if (LinearSearch(0, h, 5))
			break;
		if (LinearSearch(1, h, 5))
			if (LinearSearch(2, h, 5)) {
				if (LinearSearch(3, h, 5))
					w = 4;
				else
					w = 1;
			}
			else {
				if (LinearSearch(3, h, 5))
					w = 3;
				else w = 4;
			}
		else if (LinearSearch(2, h, 5)) {
			if (LinearSearch(3, h, 5))
				w = 2;
			else
				w = 4;
		}
		else
			w = 4;
		for (int i = 0; i < 5; i++) {
			if (w == 4)
				cout << 3 << endl;
			if (w == 1)
				if (h[i] == 1)
					cout << 1 << endl;
				else
					cout << 2 << endl;
			if (w == 2)
				if (h[i] == 2)
					cout << 1 << endl;
				else
					cout << 2 << endl;
			if (w == 3)
				if (h[i] == 3)
					cout << 1 << endl;
				else
					cout << 2 << endl;
		}
	}
}

Measured memory_bytes: 3036
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <limits.h>
#include <map>
#include <numeric>

namespace test {
	std::string to_string (char val) {
		return std::string (1, val);
		// return std::string{val};
	}
	//if( str.find ("r") != string::npos)
}

using namespace std;
typedef long long int llint;

int main (void) {
	int n,l; cin >> n >> l; vector<string> a; stringstream ss;
	for (int i = 0; i < n; i++) {
		string tmp; cin >> tmp; a.push_back(tmp);
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < n;i++) {
		ss << a[i];
	}
	cout << ss.str() << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<string>
#include <ios>     
#include <iomanip> 
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const llong MOD = 1000000007;

llong gcd(llong a, llong b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}

llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}

//ここまで共通

int main() {
	int X, A;
	cin >> X >> A;
	if (X < A) cout << 0;
	else cout << 10;
}

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

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    ll n; cin >> n;
    for (ll h = 1; h <= 3500; ++h) {
        for (ll w = 1; w <= 3500; ++w) {
            ll p = n * h * w;
            ll q = 4 * h * w - n * w - n * h;
            if (q != 0 && p % q == 0 && p / q >= 1) {
                cout << h << " " << (p / q) << " " << w << endl;
                return 0;
            }
        }
    }
    assert(false);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define deb(x) cout << #x << " " << x << "\n";
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)
#define endl "\n"
#define ll long long
#define vi vector<int>
 
// memset(arr, value, size);
 
int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
 
	int t;
	cin >> t;
	cout << (t >= 30 ? "Yes" : "No");
 
	return 0;
}

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

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

int N;
int dp[4010][4010];
int A[4010][4010];
int W[4010];
int S[4010];
signed main(){
    scanf("%lld",&N);
    rep(i,N)scanf("%lld",&W[i]);
    rep(i,N)S[i+1]=S[i]+W[i];

    for(int len=1;len<=N;len++){
        for(int i=0;i+len<=N;i++){
            int j=i+len;
            if(len==1){
                dp[i][j]=0;
                A[i][j]=i;
                continue;
            }
            dp[i][j]=1001001001001001001ll;
            for(int k=A[i][j-1];k<=A[i+1][j];k++){
                if(i==k||k==j)continue;
                if(dp[i][j]>dp[i][k]+dp[k][j]){
                    dp[i][j]=dp[i][k]+dp[k][j];
                    A[i][j]=k;
                }
            }
            dp[i][j]+=S[j]-S[i];
        }
    }
    cout<<dp[0][N]<<endl;
    return 0;
}

Measured memory_bytes: 158324
BIG_NUM = 2000000000
 
N = int(input())
 
table = list(map(int,input().split()))
 
maximum = -BIG_NUM
minimum = BIG_NUM
total = 0
 
for x in table:
    if maximum < x:
        maximum = x
    if minimum > x:
        minimum = x
    total += x
 
print("%d %d %d"%(minimum,maximum,total))


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

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		int a_in;
		cin >> a_in;
		a.at(i) = a_in;
	}
	vector<int> b(n);
	for (int i = 0; i < n; i++) {
		int b_in;
		cin >> b_in;
		b.at(i) = b_in;
	}
	vector<int> c(n - 1);
	for (int i = 0; i < n - 1; i++) {
		int c_in;
		cin >> c_in;
		c.at(i) = c_in;
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += b.at(a.at(i) - 1);
		if (i != 0) {
			if (a.at(i) - 1 == a.at(i - 1)) {
				ans += c.at(a.at(i - 1) - 1);
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	char S[3],T[3];
	int i;
	int j=0;
		scanf("%s",S);
		scanf("%s",T);
		for(i=0;i<3;i++){
				if(S[i]==T[i]){
					j+=1;
				}
			}
		printf("%d",j);
	return 0;
}		

Measured memory_bytes: 128
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){
  ios::sync_with_stdio(false);
  int N, ptr, res;
  int A[100000];
  cin >> N;
  for(int i = 0; i<N;i++) {
    cin >> A[i];
  }
  sort(A, A+N);

  while(ptr < N) {
    int cc = A[ptr], f=0;
    while(ptr < N && A[ptr] == cc) f++,ptr++;
    res += f%2;
  }

  cout << res;
  return 0;
}


Measured memory_bytes: 640
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
//#include <chrono> //1e+9で割る auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
ll N,A,B;
ll ans[300000];
ll now;
ll cost;
int main()
{
	cin>>N>>A>>B;
	if(A+B>N+1||A>N||B>N){
		puts("-1");
		return 0;
	}
	else if(A+B==N+1){
		for(int i=0;i<A;i++){
			ans[i]=i+(N-A+1);
		}
		for(int i=0;i<N-A;i++){
			ans[i+A]=(N-A)-i;
		}
	}
	else{
		if( B<((N-1)/A)+1 ){
puts("-1"); return 0;}
		else{
			now=N+1;
			int id=0;
			int cost=N-B;
			for(id=0;id<A;id++){
				ans[id]=now-A+id;
			}
			now=now-A;
			cost-=(A-1);
			int x;
			while(id<N){
				x=min((int)A,cost+1);
				for(int i=0;i<A;i++){
					if(i==0){
						ans[id]=now-x;
						id++;
					}
					else{
						if(cost==0) break;
						else{
							ans[id]=now-x+i;
							cost--;
							id++;
						}
					}
				}
				now-=x;
			}
		}
	}
	rep(i,N-1) cout<<ans[i]<<" ";
	cout<<ans[N-1]<<endl;
}



Measured memory_bytes: 4480
def fctr1(n): 
    f=[]
    c=0
    r=int(n**0.5)
    for i in range(2,r+2):
        while n%i==0:
            c+=1
            n=n//i
        if c!=0:
            f.append([i,c])
            c=0
    if n!=1:
        f.append([n,1])
    return f

def main():
    N, P = map(int, input().split())
    if N == 1:
        print(P)
        exit()
    if P == 1:
        print(1)
        exit()
    A = fctr1(P)
    cnt = 1
    for i, j in A:
        if j >= N:
            cnt *= i ** (j // N)

    print(cnt)


if __name__ == "__main__":
    main()

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

int main()
{
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  int flag = 0;
  while( (a > 0) && (c > 0) ){
    c -= b;
    if(c <= 0){
      flag = 1;
      break;
    }
    a -= d;
    if(a <= 0){
      break;
    }
  }//while
  
  if(flag == 1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N;
    cin >> N;
    int k=(N+1)/2;
    printf("%.8f\n",(double)k/N);
    return 0;
}



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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

void solve(){
    int n,ans=0;
    cin>>n;
    rep(i,1,n+1){
        int x;
        cin>>x;
        if(i%2 and x%2) ans++;
    }
    cout<<ans<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF LLONG_MAX/10
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n;
    cin>>n;
    int a[n],b=INF,ans=0;
    rep(i,n){
        cin>>a[i];
        b=min(a[i],b);
        if(b==a[i]){
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include<stdio.h>

int main(void){
    int i,N,flag = 0;
    char S;
    scanf("%d",&N);
    for(i = 0;i < N;i++){
        scanf("%c",&S);
        if(S == 'Y') flag = 1;
        if(S == ' ') i--;
    }

    if(flag == 1){
        printf("Four");
        return 0;
    }

    printf("Three");
    return 0;
    
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>

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

using namespace std;
int mod = 1000000007;

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

  vector<int> a(N);
  int amin = INT_MAX;
  int minpos = -1;
  int amax = INT_MIN;
  int maxpos = -1;
  rep(i, N) {
    cin >> a.at(i);
    if (a.at(i) < amin) {
      amin = a.at(i);
      minpos = i;
    }
    if (a.at(i) > amax) {
      amax = a.at(i);
      maxpos = i;
    }
  }

  cout << 2*N-1 << endl;
  if (abs(amin) > abs(amax)) {
    rep(i, N) {
      cout << minpos+1 << ' ' << i+1 << endl;
    }
    for (int i=N; i>1; i--) {
      cout << i << ' ' << i-1 << endl;
    }
  } else {
    rep(i, N) {
      cout << maxpos+1 << ' ' << i+1 << endl;
    }
    for (int i=1; i<N; i++) {
      cout << i << ' ' << i+1 << endl;
    }
  }
}

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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

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

    vector<int> v(n);
    int ans(0);
    rep(i,n){
        cin >> v[i];
        ans++;
        x -= v[i];
    }

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

    if(v[0]<=x){
        while(1){
            x -= v[0];
            if(x<0){
                break;
            }
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3600
def CountBomb(box, line, row):
    count = 0
    for i in range(-1, 2):
        for j in range(-1, 2):
            if line+i < 0 or line+i >= len(box) or row+j < 0 or row+j >= len(box[0]):
                continue
            else:
                cell = box[line+i][row+j]
                if cell == "#":
                    count += 1
    return count

def resolve():
    h, w = map(int, input().split())
    box = list()
    for i in range(h):
        a = input()
        b = list()
        for i in range(len(a)):
            b.append(a[i])
        box.append(b)
    
    for line in range(h):
        for row in range(w):
            if box[line][row] == ".":
                box[line][row] = CountBomb(box, line, row)
    
    for line in range(h):
        for row in range(w):
            a = box[line][row]
            print(a, end="")
        print()
resolve()

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


template<typename T>
struct WarshallFloyd {
    vector<vector<T>> d;
    WarshallFloyd() = default;
    WarshallFloyd(int n) : d(n, vector<T>(n, numeric_limits<T>::max())){
        for(int i = 0;i < n;++i) d[i][i] = 0;
    }
    void addEdge(int u, int v, T c){
        d[u][v] = c;
    }
    void build(){
        int n = d.size();
        for(int k = 0;k < n;++k) for(int i = 0;i < n;++i) for(int j = 0;j < n;++j)
            if(d[i][k] != numeric_limits<T>::max() and d[k][j] != numeric_limits<T>::max()) d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
    }
    const vector<T>& operator[](int n) const { return d[n]; }
    bool negativeCycle(){
        int n = d.size();
        for(int i = 0;i < n;++i) if(d[i][i] < 0) return true;
        return false;
    }
};


int V, E;
WarshallFloyd<int> G;


signed main(){
    cin >> V >> E;
    G = WarshallFloyd<int>(V);
    for(int i = 0;i < E;++i){
        int s, t, d;
        cin >> s >> t >> d;
        G.addEdge(s, t, d);
    }

    G.build();

    if(G.negativeCycle()) cout << "NEGATIVE CYCLE" << endl;
    else {
        for(int i = 0;i < V;++i){
            for(int j = 0;j < V;++j){
                if(G[i][j] != numeric_limits<int>::max()) cout << G[i][j];
                else cout << "INF";
                if(j != V-1) cout << ' ';
            }
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin>>N;
    
    vector<long long> a(N);
    long long count=0;
    for(int i=0;i<N;i++){
        cin>>a[i];
        while(a[i]%2==0){
            a[i]/=2;
            count++;
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std ;

long long int factorial(int n)
{
	long long int ret = 1 ;

	for(int i = 1 ; i <= n ; i++)ret = (ret*i)%MOD ;

	return ret ;
}

int main()
{
	int n , m ;

	cin >> n >> m ;

	if(abs(n-m) > 1){
		printf("0\n") ;
		return 0 ;
	}

	long long int ans ;

	if(n == m)ans = (long long)2*factorial(n)*factorial(m)%MOD ;
	else ans = (long long)factorial(n)*factorial(m) ;

	printf("%lld\n", ans%MOD) ;

	return 0 ;
}

Measured memory_bytes: 256
n = int(input())
s = input()
l = ['SS','SW','WS','WW']

for i in range(n):
  for j in range(len(l)):
    l[j] += 'SW'[::-1 if s[i]=='o' else 1][l[j][i]==l[j][i+1]]
for i in range(len(l)):
  if l[i][0]==l[i][n] and l[i][1]==l[i][n+1]:
    print(l[i][1:n+1])
    exit()
print(-1)


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

int main() {
  string s;
  cin>>s;
  
  if(s.at(0)!=s.at(1)) cout << "Yes" << endl;
  else if(s.at(1)!=s.at(2)) cout << "Yes" << endl;
  else cout << "No" << endl;
    
}

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

signed main(){
  int X,Y;
  cin>>X>>Y;
  int ans=1;
  while(true){
    X*=2;
    if(X<=Y)ans+=1;
    else break;
  }
  cout<<ans<<endl;
}

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

int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	int arr[n];
	for(int i=0;i<n;i++){
		scanf("%d",&arr[i]);
	}
	long long dp[2][k+5]; dp[0][0]=1; dp[1][0]=0;
	for(int i=1;i<=k;i++){dp[0][i]=0; dp[1][i]=0;}
	long long pref[k+5]; for(int i=0;i<=k;i++)pref[i]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<=k;j++){
			int x=max(-1,j-arr[i]-1);
			dp[1][j]=pref[j]-(x>=0?pref[x]:0);
			dp[1][j]%=1000000007;
			dp[1][j]+=1000000007;
			dp[1][j]%=1000000007;
		}
		for(int j=0;j<=k;j++){
			dp[0][j]=dp[1][j];
			if(j==0)pref[0]=dp[0][0];
			else pref[j]=dp[0][j]+pref[j-1];
			pref[j]%=1000000007;
			pref[j]+=1000000007;
			pref[j]%=1000000007;
		}
	}
	printf("%lld",dp[0][k]);
}

Measured memory_bytes: 2560
#include<iostream>
using namespace std;
int main(){
	int N,M,X,Y;
	int x[100],y[100];
	cin>>N>>M>>X>>Y;
	for(int i=0;i<N;i++)cin>>x[i];
	for(int i=0;i<M;i++)cin>>y[i];
	int max_x=X;
    int min_y=Y;
    for(int i=0;i<N;i++)if(x[i]>max_x)max_x=x[i];
    for(int i=0;i<M;i++)if(y[i]<min_y)min_y=y[i];
    if(max_x<min_y)cout<<"No War"<<endl;
	else cout<<"War"<<endl;
	return 0;
}

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

const long long MOD = 1e9 + 7;
const int MAX_N = 21;

int n, a[MAX_N][MAX_N];
long long dp[MAX_N][1 << MAX_N];

long long f(int i, int mask) {
    if (i == -1) return 1;
    if (dp[i][mask] == -1) {
        dp[i][mask] = 0;
        for (int j = 0; j < n; j++) if (a[i][j] && (mask >> j & 1))
            dp[i][mask] += f(i - 1, mask ^ 1 << j);
        dp[i][mask] %= MOD;
    }
    return dp[i][mask];
}

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

    cin >> n;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            cin >> a[i][j];

    memset(dp, -1, sizeof dp);
    cout << f(n - 1, (1 << n) - 1) << "\n";

    return 0;
}


Measured memory_bytes: 344320
S = input()
K = int(input())

output = ''

if len(S) <= K:
    for letter in S:
        if letter != '1':
            output = letter
            break
else :
    for i in range(K):
        if S[i] != '1':
            output = S[i]
            break

if output:
    print(output)
else :
    print('1')

Measured memory_bytes: 3060
import sys
for line in sys.stdin:
    n, x = map(int, line.split())
    if n == x == 0:
        sys.exit()

    cnt = 0
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            if j < x-i-j <= n:
                cnt += 1

    print(cnt)



Measured memory_bytes: 5596
#include <stdio.h>
#include <string.h>
int main()
{
    int n;
    scanf("%d", &n);

    char s[n][102];
    int t[n];

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

    char x[102];
    scanf("%s", &x);
    int sf = 0, sum = 0;
    for(int i=0;i<n;i++){
        if(strcmp(s[i], x) == 0){
          sf = 1; continue;
        }
        if(sf == 1){
            sum += t[i];
        }
    }
    printf("%d", sum);
    return 0;
}


Measured memory_bytes: 128
using System;
using System.IO;

namespace ABC123C
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                Console.SetIn(new StreamReader(args[0]));
            }

            new Program().Solve();
        }

        void Solve()
        {
            // 一番狭いところだけ考えればいいのかな
            var N = long.Parse(Console.ReadLine());
            var capacity = long.MaxValue;

            for (int i = 0; i < 5; i++)
            {
                var temp = long.Parse(Console.ReadLine());
                if (temp < capacity)
                {
                    capacity = temp;
                }
            }

            var ans = N / capacity + 5;

            if (N % capacity == 0)
            {
                ans--;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long MX = 1e9;

#include <math.h>
#define PI 3.14159265358979323846264338327950L

long long gcd(long long a, long long b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
long long lcm(long long a, long long b) {
    return (a * b) / gcd(a, b);
}
long long digits(long long m) {
    long long cnt = 0;
    while (m) {
        cnt++;
        m /= 10;
    }
    return cnt;
}



int main() {
    long long n;
    cin >> n;
    cout << n * n;


    return 0;
}

Measured memory_bytes: 3636
io = STDIN
n=io.gets.to_i
a=io.gets.split.map(&:to_i)
ar= a.map.with_index(1){|x,i|x-i}
sort=ar.sort
mid1=sort[n/2]
mid2=sort[n/2]-1

ans=Float::INFINITY
[mid1,mid2].each do |b|
  abs=ar.map{|i|(i-b).abs}.inject(:+)
  ans=[abs,ans].min
end
puts ans


Measured memory_bytes: 22256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    
    string s;
    cin >> s;
    if((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3]))Yes;
    else No;
    return  0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ans;
string s,a = "CODEFESTIVAL2016";
int main() {
	ios::sync_with_stdio(false);
	cin >> s;
	for(int i = 0; i < s.size(); i++)
		ans += s[i] != a[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256