akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define forsaken
#ifdef forsaken
  #define dbg(args...) do {cout << #args << " : "; err(args);} while (0)
#else
  #define dbg(...)
#endif
void err() {std::cout << std::endl;}
template<typename T, typename...Args>
void err(T a, Args...args){std::cout << a << ' '; err(args...);}
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const int inf=0x3f3f3f3f;
const int max_n=100005;
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
	inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
int n;
bool vis[105][105];
int main()
{
    scanf("%d",&n);
    int ans=n*(n-1)/2;
    int r=n%2;
    n-=r;
    for(int i=1;i<=n/2;i++)vis[i][n+1-i]=true,ans--;
    printf("%d\n",ans);
    for(int i=1;i<=n+r;i++)
    {
        for(int j=i+1;j<=n+r;j++)
        {
            if(!vis[i][j])printf("%d %d\n",i,j);
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    string s;
    cin >> s;
    int n = s.size();
    ll dp[n + 1][4] = {};
    dp[0][0] = 1;
    rep(i, 0, n) {
        rep(j, 0, 4) dp[i + 1][j] += dp[i][j];
        if (s[i] == 'A') dp[i + 1][1] += dp[i][0];
        if (s[i] == 'B') dp[i + 1][2] += dp[i][1];
        if (s[i] == 'C') dp[i + 1][3] += dp[i][2];
        if (s[i] == '?') {
            rep(j, 0, 4) dp[i + 1][j] *= 3;
            dp[i + 1][1] += dp[i][0];
            dp[i + 1][2] += dp[i][1];
            dp[i + 1][3] += dp[i][2];
        }
        rep(j, 0, 4) dp[i + 1][j] %= MOD;
    }
    /*rep(i, 1, n + 1) {
        cout << dp[i][0] <<  " " << dp[i][1] << " " << dp[i][2] << " " << dp[i][3] << endl;
    }*/
    cout << dp[n][3] << endl;
    return 0;
}


Measured memory_bytes: 3584
// Problem : A - Takahashikun, The Strider
// Contest : AtCoder - AtCoder Grand Contest 046
// URL : https://atcoder.jp/contests/agc046/tasks/agc046_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb push_back
#define mk make_pair
#define fast                    \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define rep(i, a, b) for (ll i = a; i < b; i++)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define sz(x) (int)x.size()
#define mem(a, val) memset(a, val, sizeof(a))
#define deci(x) cout << fixed << setprecision(x);
#define bitcount(x) __builtin_popcountll(x)

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

const long long int mod = 1e9 + 7;
const long double EPS = 1e-12;
const int N = 1e5 + 20;

void solve() {
  ll n;
  cin >> n;
  cout << ((n * 360) / __gcd(n, 360ll)) / n;
}
int main() {
  fast;
  ll t;
  t = 1;

  // cin>>t;

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

  return 0;
}


Measured memory_bytes: 3648
N, M = map(int, input().split())
ls = []
for i in range(N):
  A, B = map(int, input().split())
  ls += [(A,B)]
ls.sort(key=lambda x:x[0])
count = 0
ans = 0
for x in ls:
  a,b = x
  bcount = 0
  while count<M and bcount<b:
    count += 1
    bcount += 1
    ans += a
  if count==M:
    break
print(ans)

Measured memory_bytes: 18180
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	int n;
	int kari;

	while (1) {
		int a[10] = {0};
		cin >> n;
		if (n == 0) {
			break;
		} else {
			for (int i = 0; i < n; i++) {
				cin >> kari;
				a[kari]++;
			}
			for (int i = 0; i < 10; i++) {
				if (a[i] == 0) {
					cout << "-" << endl;
				} else {
					for (int j = 0; j < a[i]; j++) {
						cout << "*";
					} 
					cout << endl;
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;
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;}

int main() {
	char C;
	cin >> C;
    char ans = C + 1;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <complex>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef complex<double> CD;

//最大公約数
int gcd(int n, int m) {
	if (m == 0)return n;
	return gcd(m, n%m);
}

int main() {
	int w, h, c; cin >> w >> h >> c;

	cout << (w * h) / (gcd(w, h) * gcd(w, h)) * c << endl;
}


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

#define ll long long int

int main() {

    ll a, b, c;
    cin >> a >> b >> c;

    if (a%2 == 0 || b%2 == 0 || c%2 == 0) {
        cout << 0 << endl;
        return 0;
    }
    else {
        cout << (min(min(a*b, b*c), c*a)) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import math

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

c = math.ceil(b / 0.1)

for i in range(c, c + 10):
    if math.floor(i * 0.1) == b:
        if math.floor(i * 0.08) == a:
            print(i)
            sys.exit()

print(-1)

Measured memory_bytes: 9180
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
using namespace std;
 
 
 
int main() {
    int n,k;
    cin>>n>>k;
    ll h[n];
    pan(i,n) cin>>h[i];
    ll ans=0;
    sort(h,h+n);
    if(k>=n) ans=0;
    else{
        if(k!=0){
            pan(i,k){
                h[n-1-i]=0;
            }
            pan(i,n) ans+=h[i];
        }
        else{
            pan(i,n) ans+=h[i];
        }
    }
    cout<<ans;
}

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

int main(){
	int n,m,c;
	cin >> n >> m >> c;
	
	vector<int> b(m);
	rep(i,m) {
		cin >> b[i];
	}
	
	
	int ans = 0;
	rep(i,n){
		int count = 0;
		rep(j,m){
			int a;
			cin >> a;
			count += a*b[j];
		}
		count += c;
		if(count > 0){
			ans++;
		}
	}
	
	cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

/**
 * A - 500 Yen Coins
 * 高橋君は 500 円玉を K 枚持っています。
 * これらの総額が X 円以上である場合は Yes を、そうでない場合は No を出力してください。
 */
public class Main {

    public static void main( String[] args ) {

        // 入力値
        Scanner sc = new Scanner( System.in );
        int k = sc.nextInt();   // 所持している500円玉の枚数
        int x = sc.nextInt();   // 所持金額

        System.out.println( k * 500 >= x ? "Yes" : "No" );

        sc.close();
    }
}

Measured memory_bytes: 35652
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>

#define long long long int

using std::vector;
using std::map;
using std::string;
using std::pair;
using std::cin;
using std::cout;

// @author: pashka

int main() {
    std::ios::sync_with_stdio(false);

    long n;

    cin >> n;

    map<long, long> cnt;

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

    long res = 0;
    long max1 = 0;
    long max2 = 0;
    for (auto item : cnt) {
        long x = item.first;
        if (item.second >= 2) {
            if (x > max1) {
                max2 = max1;
                max1 = x;
            } else if (x > max2) {
                max2 = x;
            }
        }
        if (item.second >= 4) {
            res = std::max(res, x * x);
        }
    }
    res = std::max(res, max1 * max2);

    cout << res;

    return 0;
}

Measured memory_bytes: 6528
#include <stdio.h>
#include <string.h>
int main(){
   char s1[12];
   char s2[12];
   scanf("%s%s", s1, s2);
   for(int i=0; i<strlen(s1); i++){
      if(s1[i] != s2[i]){
         printf("No\n");
         return 0;
      }
   }
   printf("Yes\n");
   return 0;
}

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

using namespace std;

#define td typedef
td long long ll;

ll in()
{
    ll a;
    scanf("%lld",&a);
    return a;
}

int main()
{
    char s[20];
    int a=in(),b=in();
    bool hoise=1;
    scanf("%s",s);
    for(int i=0;i<strlen(s);i++)
    {
        if(i==a)
        {
            if(s[i]!='-')
                hoise=0;
        }
        else if(s[i]>'9'||s[i]<'0')
        {
            hoise=0;
        }
    }
    if(hoise)
        printf("Yes\n");
    else
        printf("No\n");
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;

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

    int n;
    cin >> n;

    int ans = 100100100;
    rep(i, n){
        int a;
        cin >> a;

        int cnt = 0;
        while(a % 2 == 0){
            a >>= 1;
            cnt++;
        }

        ans = min(ans, cnt);
    }

    cout << ans << endl;


    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define dbg_v(v) cout<<#v<<":";for(int i=0;i<(int)v.size();i++) cout<<" "<<v[i]; cout<<endl;
int main(){ 
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	
	int t=1;
	//cin>>t;
	while(t--){
		ll n,k;
		cin>>n>>k;
		ll a[n];
		for (int i = 0; i < n; i++)
		{
			cin>>a[i];
		}
		for(int i=k;i<n;i++){
			if(a[i]<=a[i-k])
				cout<<"No"<<endl;
			else
				cout<<"Yes"<<endl;
		}
	}
}



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

int getDigitSum(int n)
{
  int sum = 0;
  while(n != 0)
  {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main()
{
  int N, A, B;
  cin >> N >> A >> B;
  
  int sum = 0;
  for(int i = 1; i <= N; ++i)
  {
    if(getDigitSum(i) >= A && getDigitSum(i) <= B)
    {
      sum += i;
    }
  }
  
  cout << sum << endl;
  return 0;
}    

Measured memory_bytes: 256
d = dict()
while True:
    try:
        w, n = input().split()
    except:
        break
    n = int(n)
    if d.get(w):
        d[w].append(n)
    else:
        d[w] = []
        d[w].append(n)

for k in sorted(d.keys()):
    print(k)
    print( *sorted(d[k]) )



Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
//#define int long long
typedef pair<int,int> ii;
typedef tuple<int,int,int> iii;
#define ll long long
#define iiMPQ priority_queue<ii,vector<ii>,greater<ii> >
#define MPQ priority_queue<int,vector<int>,greater<int> >
#define PQ priority_queue<int>
#define iiPQ priority_queue<ii>
#define US unordered_set<int>
#define UMS unordered_multiset<int>
#define UM unordered_map<int>
#define iiUS unordered_set<ii>
#define ST stack<int>
#define MS multiset<int>
#define scan1(n) cin>>n
#define scan2(a,b) cin>>a>>b
#define scan3(a,b,c) cin>>a>>b>>c
#define print(n) cout<<n
#define println(n) cout<<n<<"\n"
#define vi vector<int>
#define vii vector<ii>
#define viii vector<iii>
#define fi first
#define se second
#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,s,e) for(int i=s;i<e;++i)
#define REPS(i,s,e,st) for(int i=s;i<e;i+=st)
#define rep(i,n) for(int i=n-1;i>=0;--i)
#define repr(i,s,e) for(int i=s;i>=e;--i)
#define reps(i,s,e,st) for(int i=s;i>=e;i-=st)
#define SET(arr,k) memset(arr,k,sizeof arr)
#define speed ios::sync_with_stdio(0); cin.tie(0);
#define mp make_pair
#define pb push_back
#define Qu queue
#define Vt vector
#define Dq deque
#define prints(n) cout << n << " ";

void m1(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  if(b <= a){
  	while(b <= a){
    	b *= 2;
      	--k;
    }
  }
  if(c <= b){
  	while(c <= b){
    	c *= 2;
      	--k;
    }
  }
  if(k >= 0) cout << "Yes";
  else cout << "No";
}
/* 
void m2(){
  int t; scan1(t);
  while(t--) m1();
}
*/
 
signed main(){
  speed;
  //freopen("in.txt","r",stdin);
  m1();
  //m2();
}

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

int main(){
    int a[3];
    scanf("%d%d%d", a, a + 1, a + 2);
    sort(a, a + 3);
    printf("%d\n", a[2] * 10 + a[1] + a[0]);
    return 0;
}


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


int main(){

ll n;
cin>>n;

    
    ll a[3];
    ll ans[3];
    ll ap[3];
    memset(ap,0,sizeof(ap));
    ans[0]=ans[1]=ans[2]=0;


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

            for(ll k =0; k<3;k++)
                for( ll j =0;j<3;j++)
                        if(k!=j)
                             ap[j] = max(ap[j],ans[k]+a[j]);
            
            
            ans[0]=ap[0];
            ans[1]=ap[1];
            ans[2]=ap[2];
            //ap[0] = ap[1] = ap[2] = 0;
        }

    
        cout<<max(ans[0],max(ans[1],ans[2]));


return 0;
}


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

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			int v=a[i]+a[j];
			int id=lower_bound(a.begin(),a.end(),v)-a.begin();
			ans+=id-(j+1);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define d(x) cerr<<#x<<"="<<x<<endl;

char a[1001][1001];
ll dp[1001][1001],h,w;

int main(void){
    cin>>h>>w;
    rep(i,h)rep(j,w)cin>>a[i][j];
    dp[0][0]=1;
    rep(i,h)rep(j,w){
        if(i==0 && j==0)continue;
        else if(a[i][j]=='#')continue;
        else if(i==0)dp[0][j]=dp[0][j-1];
        else if(j==0)dp[i][0]=dp[i-1][0];
        else if(a[i][j-1]=='#')dp[i][j]=dp[i-1][j]%(ll)(1e9+7);
        else if(a[i-1][j]=='#')dp[i][j]=dp[i][j-1]%(ll)(1e9+7);
        else dp[i][j]=(dp[i-1][j]+dp[i][j-1])%(ll)(1e9+7);
    }
    cout<<dp[h-1][w-1]%(ll)(1e9+7)<<endl;
    return 0;
}


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

int main()
{
  int h, w; cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];

  vector<vector<int>> d1(h, vector<int>(w, 0));
  vector<vector<int>> d2(h, vector<int>(w, 0));

  rep(i, h) rep(j, w) {
    if (s[i][j] == '#') continue;
    int k = 0;
    while (j+k < w && s[i][j+k]=='.') k++;
    for (int l=j+k; j<min(l,w); j++) d1[i][j] = k;
    j--;
  }

  rep(j, w) rep(i, h) {
    if (s[i][j] == '#') continue;
    int k = 0;
    while (i+k < h && s[i+k][j]=='.') k++;
    for (int l=i+k; i<min(l,h); i++) d2[i][j] = k;
    i--;
  }

  int ans = 0;
  rep(i, h) rep(j, w) {
    ans = max(ans, d1[i][j] + d2[i][j] - 1);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 35712
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<functional>
#include<stack>
#include<queue>
#include<cmath>
# define MOD 1000000000+7
# define INF 1e9
# define LINF 1e18
typedef long long ll;

using namespace std;
int gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
 
int n = 0, a = 0, b = 0, c = 0;
vector<int> v;

void dfs(ll num,int use,ll& counter) {

	if (num > n)return;//終了条件を書く
	if (use == 0b111) {
		counter++;
	}
	dfs(num * 10 + 7, use | 0b001, counter);
	dfs(num * 10 + 5, use | 0b010, counter);
	dfs(num * 10 + 3, use | 0b100, counter);

}

int main() {
	
	cin >> n;
	ll res = 0;
	dfs(0, 0, res);
	cout << res << endl;

}

Measured memory_bytes: 256
import java.util.Scanner
 
fun main(args: Array<String>) {  
  val scan = Scanner(System.`in`)
  val a = scan.nextInt()
  val b = scan.nextInt()
  val add = a + b
  val sub = a - b
  val mul = a * b
  val max = listOf(add, sub, mul).max()
  println("$max")
}

Measured memory_bytes: 35660
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
 int n;
  cin>>n;
  ll ans=0;
  vin a(n),b(n);
  rep(i,n){
   cin>>a[i];
  }
  rep(i,n){
   cin>>b[i];
  }
  rep(i,n){
   if(a[i]>b[i]) ans+=a[i]-b[i]; 
  }
  cout<<ans<<endl;
}








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

double heron(double a, double b, double c) {
  double s=(a+b+c)/2;
  return sqrt(s*(s-a)*(s-b)*(s-c));
}

int main() {
  double a,l,x;

  while(cin>>a>>l>>x)
    printf("%.6f\n", heron(a,l,l)+2*heron(l,(l+x)/2,(l+x)/2));
  
  return 0;
}

Measured memory_bytes: 1240
#include <stdio.h>
int main(){
  int i,m[17][17]={},j,cou,a;
  while(1){
    scanf("%d",&a);
    if(a==0)break;
    for(i=0;i<17;i++){
      for(j=0;j<17;j++){
      m[i][j]=0;
      }
    }
    cou=1;
    i=a/2+2;
    j=a/2+1;
    while(1){     
      m[i][j]=cou;
      cou++;
      if(cou>a*a)break;
      i++;
      j++;
      while(1){
	if(i==0)i=a;
	else if(i>a)i=1;
	if(j==0)j=a;	
	else if(j>a)j=1;
	if(m[i][j]!=0){
	  i++;
	  j--;
	}
	if(1<=i && i<=a && 1<=j && j<=a && m[i][j]==0)break;
      }
    }
    for(i=1;i<=a;i++){
      for(j=1;j<=a;j++){
	printf("%4d",m[i][j]);
      }
      printf("\n");
    }
  }
  return 0;
}

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

int main(){
  bool is_prime[50000];

  is_prime[0] = is_prime[1] = false;
  for(int i=2; i<50000; i++){
    is_prime[i] = true;
  }

  for(int i=2; i*i<50000; i++){
    if(is_prime[i]){
      for(int j=i*i; j<50000; j+=i){
	is_prime[j] = false;
      }
    }
  }

  while(true){
    int n;
    cin >> n;

    if(n==0)
      break;

    int cnt = 0;
    for(int i=2; i<=n/2; i++){
      if(is_prime[i] && is_prime[n-i]){
	cnt++;
      }
    }

    cout << cnt <<endl;
  }

  return 0;
}

    



Measured memory_bytes: 3128
n = int(input())
p = list(map(int,input().split()))
ans=0
for i in range(1,n-1):
    if p[i-1]>p[i] and p[i]>p[i+1] or p[i-1]<p[i] and p[i]<p[i+1]:
        ans += 1
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const int INF = 1e9+7;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;

template<typename Monoid>
struct SegmentTree
{
    using F = function<Monoid(Monoid, Monoid)>;

    int sz;
    vector<Monoid> seg;
    
    const F f;
    const Monoid M1;

    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1)
    {
        sz = 1;
        while(sz < n) sz <<= 1;
        seg.assign(2 * sz, M1);
    }

    void set(int k, const Monoid &x)
    {
        seg[k+sz] = x;
    }

    void build()
    {
        for (int k = sz-1;k>0;k--)
        {
            seg[k] = f(seg[2*k+0], seg[2*k+1]);
        }
    }

    void update(int k, const Monoid &x)
    {
        k += sz;
        seg[k] = x;

        while(k >>= 1)
        {
            seg[k] = f(seg[2*k+0], seg[2*k+1]);
        }
    }

    Monoid query(int a, int b)
    {
        Monoid L = M1, R = M1;
        for (a+=sz, b+=sz; a<b; a>>=1, b>>=1)
        {
            if (a&1) L = f(L, seg[a++]);
            if (b&1) R = f(seg[--b], R);
        }
        return f(L, R);
    }

    Monoid operator[](const int &k) const {
        return seg[k+sz];
    }

    // template< typename C>
    // int find_subtree(int a, const C &check, Monoid &M, bool type)
    // {
    //     while(a < sz)
    //     {
    //         Monoid nxt = type ? f(seg[2*a + type] ,M) : f(M, seg[2*a+type]);
    //         if (check(nxt)) a = 2*a + type;
    //         else M = nxt, a = 2*a + 1 - type;
    //     }
    //     return a - sz;
    // }
    
};

set<char> func(set<char> a, set<char> b)
{
    set<char> result;
    set_union(begin(a), end(a), begin(b), end(b), inserter(result, end(result)));

    return result;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,q;
    string s;
    cin >> n >> s >> q;

    // rep(i,q)
    // {
    //     cout << query[i][0] << " " << query[i][1] << " " << cq[i] << endl;
    // }

    set<char> st = {};
    SegmentTree< set<char> > seg(n, func, st);
    rep(i,n)
    {
        set<char> tmp_char_set = {s[i]};
        seg.set(i, tmp_char_set);
    }
    seg.build();

    // int query[q][3];
    // char cq[q];
    // rep(i,q) cin >> query[i][0] >> query[i][1] >> cq[i], query[i][0]--, query[i][1]--;


    rep(i,q)
    {
        int a,b;
        cin >> a >> b;
        b--;
        char c;
        int d;
        if (a == 1)
        {
            cin >> c;
            set<char> tmp_st = {c};
            seg.update(b, tmp_st);
        }
        else
        {
            cin >> d;
            cout << seg.query(b, d).size() << endl;
        }

            // set<char> tmp_st = seg.query(query[i][1], query[i][2]+1);
            // cout << "1 " << end_iter << endl;
    }
}




Measured memory_bytes: 190748
N, M, X = map(int, input().split())
books = [list(map(int, input().split())) for _ in range(N)]

p = []

for i in range(1, 2**N):
    buff = [0] * (M + 1)

    for j in range(N):
        if i >> j & 1:
            buff = [a + b for a, b in zip(buff, books[j])]

    for a in buff[1:]:
        if a < X:
            break
    else:
        p.append(buff[0])

if len(p) > 0:
    ans = min(p)
else:
    ans = -1

print(ans)


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

int n=0;
int st[4]={};
double dp[305][305][305]={};

double solve(int a, int b, int c){
	if(a+b+c == 0) return 0.0;
	
	if(dp[a][b][c] != -1)
		return dp[a][b][c];
		
	// probability of select dish having sushi
	double ks = (double)n/(a+b+c);
	double ans=0;
	if(a) {
			   // require draw dice * prob of select a, (a=no of dish having a sushi) 
		ans += ( solve(a-1, b, c) + ks ) * a/(a+b+c);
	}
	
	if(b) {
			   // require draw dice * prob of select a, (a=no of dish having a sushi) 
			   // a+1 remove 2's sushi do become 1
		ans += ( solve(a+1, b-1, c) + ks ) * b/(a+b+c);
	}
	
	if(c) {
			   // require draw dice * prob of select a, (a=no of dish having a sushi) 
		ans += ( solve(a, b+1, c-1) + ks ) * c/(a+b+c);
	}
	
	return dp[a][b][c] = ans;
}

void solve(){
	cin >> n;
	int x;
	for(int i=0; i<n; i++) {
		cin >> x;
		st[x]++;
	}
	
	for(int i=0; i<=n; i++)
		for(int j=0; j<=n; j++)
			for(int k=0; k<=n; k++)
				dp[i][j][k]=-1;
	
	double ans = solve(st[1], st[2], st[3]);	
	cout << setprecision(12) << fixed << ans << "\n";
}

int main(){
	solve();
}


Measured memory_bytes: 220912
using System;

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

        int LW = 0;
        int LB = 0;
        int RW = 0;
        int RB = 0;

        // 初期化
        for (int i = 0; i < N; i++)
        {
            if (S[i] == '.')
            {
                RW++;
            } else
            {
                RB++;
            }
        }

        int min = LB + RW;
        for (int i = 0; i < N; i++)
        {
            if (S[i] == '.' )
            {
                LW++;
                RW--;
            } else
            {
                LB++;
                RB--;
            }
            if (LB + RW < min)
            {
                min = LB + RW;
            }
        }

        Console.WriteLine(min);
        

    }
}

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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979323846

template<class T>bool ch1000000(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; }


const int MAX = 42;




int main() {

  ll N, D;
  cin >> N >> D;

  ll X, Y;

  int ans = 0;

  rep(i, 0, N){
    cin >> X >> Y;

    if(D*D >= X*X + Y*Y){
      ans++;
    }
  }

  cout << ans << endl;







  // cout << setprecision(8) << ans << endl;  // For double
}



Measured memory_bytes: 3632
import sys

import numpy as np


def main():
    sin = sys.stdin.buffer
    H, W = map(int, sin.readline().split())
    a = np.frombuffer(sin.read(H * (W + 1)), dtype="B") == ord(".")
    a = a.reshape((H, W + 1))[:, :-1]

    L = np.empty((H, W), dtype="i4")
    R = np.empty((H, W), dtype="i4")
    T = np.empty((H, W), dtype="i4")
    B = np.empty((H, W), dtype="i4")
    T[0] = a[0]
    for i in range(1, H):
        T[i] = (T[i - 1] + 1) * a[i]
    B[-1] = a[-1]
    for i in range(H - 2, -1, -1):
        B[i] = (B[i + 1] + 1) * a[i]
    L[:, 0] = a[:, 0]
    for i in range(1, W):
        L[:, i] = (L[:, i - 1] + 1) * a[:, i]
    R[:, -1] = a[:, -1]
    for i in range(W - 2, -1, -1):
        R[:, i] = (R[:, i + 1] + 1) * a[:, i]

    print((T + B + L + R - 3).max())


main()


Measured memory_bytes: 109956
r, g, b, n = gets.split.map(&:to_i)
ans = 0
0.upto(n) do |i|
  break if r * i > n
  0.upto(n) do |j|
    break if r * i + g * j > n
    c = n - r * i - g * j
    ans += 1 if c % b == 0 && c / b <= n;
  end
end
puts ans

Measured memory_bytes: 1788
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    int N;
    cin >> N;

    ll L[100];
    L[0] = 2;
    L[1] = 1;

    FOR(i, 2, 87){
        L[i] = L[i-1] + L[i-2];
    }

    p(L[N]);
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main {

   

    // static final Reader in = new Reader();
    static final Scanner in = new Scanner(System.in);
    static final PrintWriter out = new PrintWriter(System.out);
    static int N, W;
    static final long MOD = 1000000007;
    static char[][] a;
    static double[][] dp;
    static double[] p;
    static double[] pre;


    static double P() {
        
        for(int i = 0;i < N;i++)
            dp[i][0] = 1;

        for(int i = 0;i < N;i++)
            dp[i][i+1] = pre[i];   
        

            for(int i = 1;i < N;i++){
                for(int k = 1;k < i+1;k++){
                    double consider = dp[i - 1][ k - 1];
                    double ignore = dp[i - 1][k];

                    dp[i][k] = (consider * p[i]) + (ignore * (1 - p[i]));
                }   
            }
        
        
        return dp[N - 1][N / 2 + 1];

    }

    public static void main(String[] args) throws Exception {
        N = in.nextInt();
        p = new double[N];
        pre = new double[N];
        dp = new double[N+1][N+1];

        
        p[0] = in.nextDouble();
        pre[0] = p[0];
        Arrays.fill(dp[0], 0);
        for (int i = 1; i < N; i++) {
            p[i] = in.nextDouble();
            pre[i] = pre[i - 1] * p[i];
            Arrays.fill(dp[i], 0);
        }

        System.out.println(P());

        out.close();

    }

}


Measured memory_bytes: 145136
import sys
input = sys.stdin.readline
from collections import deque
class Unionfindtree:
    def __init__(self, number,L):
        self.par = [i for i in range(number)]
        self.rank = [0] * (number)
        self.count = L

    def find(self, x):  # 親を探す
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):  # x,yを繋げる
        px = self.find(x)
        py = self.find(y)
        if px == py:
            return
        if self.rank[px] < self.rank[py]:
            self.par[px] = py
            self.count[py]+=self.count[px]
        else:
            self.par[py] = px
            self.count[px]+=self.count[py]
        if self.rank[px] == self.rank[py]:
            self.rank[px] += 1

    def connect(self, x, y):  # 親が同じかみる
        return self.find(x) == self.find(y)



N,M=map(int,input().split())
X=[int(i) for i in input().split()]
que=[]
table=[[] for i in range(N)]
for i in range(M):
    a,b,c=map(int,input().split())
    a,b=a-1,b-1
    que.append((c,a,b))

que.sort()
T=Unionfindtree(N,X)
ok=deque()
for i in range(M):
    c,a,b=que[i]
    T.union(a,b)
    if T.count[T.find(a)]>=c:
        ok.append(i)

for i in range(M):
    c,a,b=que[i]
    table[a].append((b,c,i))
    table[b].append((a,c,i))

used=[0]*M
def dfs(i,lim):
    used[i]=1
    c,a,b=que[i]
    H=deque()
    H.append(b)
    H.append(a)

    while H:
        x=H.popleft()
        for y,c,i in table[x]:
            if used[i]==1:
                continue

            if c>lim:
                continue
            H.append(y)
            used[i]=1
    return

while ok:
    i=ok.pop()
    if used[i]==0:

        c,a,b=que[i]
        dfs(i,c)

print(M-sum(used))


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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.length()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>())
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////
	string a,b,c;
	cin >> a >> b >> c;
	cout << a[0] << b[0] << c[0] << endl;

	
//////////////////////////////////////////////
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 1e-8;

long long int N, M, K, H, W, L, R;

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

	cout << setprecision(15);
	long double ans = 0;
	long double d;
	cin >> d;
	cout << max((long double)((int)d + 1), d*sqrt((long double)2)) << endl;
	return 0;
}


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

int nrtaken[100010];
vector <pair <int, int>> v;
int viz[100010];
vector <int> per_comp[100010];
vector <int> adia[100010];
int cost[100010];

void dfs(int nod, int c)
{
    viz[nod] = 1;
    per_comp[c].push_back(cost[nod]);
    for (auto i : adia[nod])
        if (!viz[i])
            dfs(i, c);
}

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

    for (int i(0); i < n; i++)
        cin >> cost[i];

    while (m--) {
        cin >> a >> b;
        adia[a].push_back(b);
        adia[b].push_back(a);
    }

    int nrcomp(0);
    long long ans(0);
    int nrluat(0);

    for (int i(0); i < n; i++) {
        if (!viz[i]) {
            dfs(i, ++nrcomp);
            sort(per_comp[nrcomp].begin(), per_comp[nrcomp].end());
            ans += per_comp[nrcomp][0];
            nrluat++;
            nrtaken[nrcomp]++;
            for (int j(1); j < per_comp[nrcomp].size(); j++)
                v.push_back({ per_comp[nrcomp][j], nrcomp });
        }
    }

    if (nrcomp == 1) {
        cout << 0;
        return 0;
    }

    int nrtotal_de_luat = 2 * (nrcomp - 1);

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

    for (auto i : v) {
        if (nrluat == nrtotal_de_luat)
            break;
        if (nrtaken[i.second] + 1 <= nrtotal_de_luat / 2) {
            ans += i.first;
            nrtaken[i.second]++;
            nrluat++;
        }
    }

    if (nrluat < nrtotal_de_luat) {
        cout << "Impossible\n";
        return 0;
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 10492
#include<bits/stdc++.h>
using namespace std;
bool check[20];

int main() {
    int n, k;
    cin >> n >> k;
    int tmp;
    for(int i = 0; i < k; i++) {
        cin >> tmp;
        check[tmp] = 1;
    }
    while(true) {
        bool flag = true;
        int dig = n;
        while(dig > 0) {
            if(check[dig % 10]) {
                flag = false;
                break;
            }
            dig /= 10;
        }
        if(flag == true) break;
        n++;
    }
    cout << n;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<cmath>
using namespace std;
#define ll long long
ll a[200050],ans=0;
int field[1000050];
signed main(){
	ll n;
	cin>>n;
	memset(field,0,n);
	for(ll i=0;i<n;i++){ll v;cin>>v; a[i]=v; field[v]=1;
	}
    a[n]=10000000;
    bool check=0;
    for(ll i=0;i<n;i++){
    	if(check==1&&a[i]==1){cout<<0<<endl;return 0;
		}
    	if(a[i]==1){check=1;continue;}
    	ll t=a[i];
    	if(field[t]==3)continue;
    	if(field[t]==2){ans--;field[t]=3;continue;
	}    field[t]=3;
		bool flag=0;
		for(ll j=2;j*j<=t;j++){
			if(t%j==0){
				ll b=t/j;
				if(field[j]>=1||field[b]>=1){flag=1;break;
				}
			}
		}
		if(!flag){ans++;field[t]=2;
		}
	}
	if(check){cout<<1<<endl; return 0;
	}
	cout<<ans<<endl; return 0;
} 

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

int n,a,d,sum,l;

int main(){
	cin>>n>>a;
	for(int i = 1;i <= n;i++){
		cin>>l;
		d+=l;
		if(d > a){
			break;
		}else{
			sum++;
			continue;
		}
	}
	cout<<sum + 1<<endl;
}


Measured memory_bytes: 764
n = int(input())
b = [int(i) for i in input().split()]

ans = b[0]

for i in range(n-2):
    if b[i]<b[i+1]:
        ans = ans + b[i]
    else:
        ans = ans + b[i+1]

ans = ans + b[n-2]
print(ans)


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

#define N 100
#define W 100000
#define INF 1000000007
#define MIN(X,Y) ((X)<(Y)?(X):(Y))
#define MAX(X,Y) ((X)>(Y)?(X):(Y))
#define ABS(X) ((X)<0?-(X):(X))

long long dp[N+1][W+1];

int main(void){
  int n, wmax;
  int w[N+1], v[N+1];
  
  cin >> n >> wmax;
  for (int i=1; i<=n; i++)
    cin >> w[i] >> v[i];
  for (int i=0; i<=wmax; i++) dp[0][i] = 0;
  for (int i=0; i<=n; i++) dp[i][0] = 0;
  for (int i=1; i<=wmax; i++){
    for (int j=1; j<=n; j++){
      dp[j][i] = dp[j-1][i];
      if (w[j]<=i) dp[j][i] = MAX(dp[j][i], dp[j-1][i-w[j]]+v[j]);
    }
  }
  cout << dp[n][wmax] << endl;
  return 0;
}


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

vector<int> array;

int main()
{
	
	int a,b,n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		b=a;
		array.push_back(b);	
	}
	int v=0;
	for(int i=1;i<n;i++)
	{
		for(int k=0;k<n;k++)
	    {
		if(k<n-1)
		cout<<array[k]<<" "	;
		else
		cout<<array[k];	
	    }
	    cout<<endl;
	    
		v=array[i];
		int j=i-1;
		
		while(j >= 0 && array[j] > v )
		{
			array[j+1] = array[j];
			j--;	
		}
		
		array[j + 1] = v;

	}
	
	for(int i = 0; i < n; i++)
	    {
		if (i<n-1)
		cout<<array[i]<<" "	;	
		else 
		cout<<array[i];
	    }
	    cout<<endl;
	    
	return 0;
 } 


Measured memory_bytes: 3144
// AtCoder Templete
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

#define FOR(i,a) for(auto i:a)
#define pub push_back
#define pob pop_buck
#define all(in) in.begin(),in.end()

using ll = long long; // typedef long long ll; と同意
using ull = unsigned long long;
using namespace std;

int main(){
    string n; cin >> n;
  cout << n[0] << n[1] << n[2] << endl;
}


Measured memory_bytes: 3624
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using coord= pair<int, int>;

bool solve(const vector<string> &board, coord s, coord g){
  const char stone= '#';
  const int H= board.size();
  const int W= board.at(0).size();

  vector<int> rowN(H);
  vector<int> colN(W);
  for(int h=0; h<H; h++){
    for(int w=0; w<W; w++){
      if(board.at(h).at(w)==stone){
        rowN.at(h)++;
        colN.at(w)++;
      }
    }
  }

  vector<int> rowPick(H);
  vector<int> colPick(W);

  coord p= s;
  for(int h=0; h<H; h++){
    int w;
    tie(ignore, w)= p;
    if(board.at(h).at(w)==stone){
      rowPick.at(h)++;
      colPick.at(w)++;
    }
    
    while(w+1 < W && board.at(h).at(w+1)==stone){
      rowPick.at(h)++;
      colPick.at(w+1)++;
      w++;
    }

    p= make_pair(h+1, w);
  }

  bool ans= true;
  for(int h=0; h<H; h++){
    ans&= rowPick.at(h)==rowN.at(h);
  }
  for(int w=0; w<W; w++){
    ans&= colPick.at(w)==colN.at(w);
  }

  return ans;
}

int main(){
  int H,W;
  cin >> H >> W;

  coord s= make_pair(0, 0);
  coord g= make_pair(H-1, W-1);
  vector<string> board(H);
  for(int i=0; i<H; i++){
    cin >> board.at(i);
  }

  string ans= solve(board, s, g) ? "Possible"
                                 : "Impossible";

  cout << ans << endl;
}

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

int main(){
	int h1,s1,h2,s2;
	cin>>h1>>s1>>h2>>s2;
	int i=2;
	while(h1>0&&h2>0){
		if(i%2==0){//takshis  turn
			h2-=s1;
			i--;
		}
		else{
			h1-=s2;
			i++;
		}
	}
	if(h1<=0) cout<<"No"<<endl;
	 else cout<<"Yes"<<endl;
}

Measured memory_bytes: 3596
# B
s = list(input())

count = 0
l = []
for i in range(len(s)):
    if s[i] == 'A':
        count += 1
        continue
    elif s[i] == 'C':
        count += 1
        continue
    elif s[i] == 'G':
        count += 1
        continue
    elif s[i] == 'T':
        count += 1
        continue
    else:
        l.append(count)
        count = 0
l.append(count)

print(max(l))

Measured memory_bytes: 3060
// このサイトの解説が良い
// https://ferin-tech.hatenablog.com/entry/2017/01/24/184750

#include <bits/stdc++.h>

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;

int main(){
  int H,W,K;
  cin>>H>>W>>K;
  vector<string> C(H);
  for(int i(0);i<H;i++){
    cin>>C[i];
  }
  int ans(0);
  for(int bit(0);bit<(1<<(H+W));bit++){
    vector<string> x = C;
    string tmp(W,'.');

    for(int i(0);i<H;i++){
      if((bit>>i)&1){
        x[i] = tmp;
      }
    }

    for(int i(H);i<H+W;i++){
      if((bit>>i)&1){
        int w = i - H;
        for(int j(0);j<H;j++){
          x[j][w] = '.';
        }
      }
    }
    int cnt(0);
    for(int h(0);h<H;h++){
      for(int w(0);w<W;w++){
        //cout << x[h][w] << " ";
        if(x[h][w] == '#'){
          cnt++;
        }
      }
      //cout << endl;
    }
    //cout << cnt << endl;
    if(cnt == K) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
	int n, q; cin >> n >> q;
	vector<long long> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];

	for (int j = 0; j < q; j++) {
		long long x; cin >> x;  // クエリ入力

		/* 合計値 */
		long long res = 0; 

		int right = 0;
		long long sum = 0;
		for (int left = 0; left < n; left++) {
			while (right < n && sum + a[right] <= x) {
				sum += a[right];
				right++;
			}
			res += (right - left);

			if (right == left) right++;
			else sum -= a[left];
		}

		cout << res << endl;
	}
}



Measured memory_bytes: 3596
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
long dp[1<<17];
inline void solve(void){
  int N;in(N);
  fill(dp,dp+(1<<17),1L<<60);
  dp[0]=0;
  rep(i,N)for(int j=1;i+j<=N;j*=6)chmin(dp[i+j],dp[i]+1);
  rep(i,N)for(int j=1;i+j<=N;j*=9)chmin(dp[i+j],dp[i]+1);
  out(dp[N]);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll n,t[300000],u[300000],ans;
  ans=INF;
  string s;
  cin >> n >> s;
  t[0]=0;
  if(s[0]=='#')t[0]++;
  FOR(i,1,n){
    if(s[i]=='#')t[i]=t[i-1]+1;
    else t[i]=t[i-1];
  }
  rep(i,n)u[i]=2*t[i]-t[n-1]+n-i-1;
  rep(i,n)dump(u[i])
  rep(i,n)ans=min(ans,u[i]);
  printf("%lld",min(ans,n-u[n-1]));
}

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

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

    int cnt = 1;
    int r = 7;
    map<int,int> check;
    while (true) {
        if (r % k == 0) break;
        if (check[r] > 0) {
            cout << -1 << endl;
            return;
        }
        check[r]++;
        r = r * 10 + 7;
        r %= k;
        cnt++;
    }

    cout << cnt << endl;
}

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


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

bool cmp(string &s1,string &s2,int n,int ind)
{
    bool f=true;
    for(int i=0;i<n;i++)
    {
        if(s2[i]!=s1[(ind+i)%n])
        {
            f=false;break;
        }
    }
    return f;
}

int main()
{
   string s1,s2;cin>>s1>>s2;
   int n=s1.size();
   bool f=false;
   for(int i=0;i<n;i++)
   {
       f=f||cmp(s1,s2,n,i);
       if(f) break;
   }
   if(f) cout<<"Yes";
   else cout<<"No";

}


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

int main(){
  int m,d;
  int dom[12]={31,29,31,30,31,30,31,31,30,31,30,31};
  char w[7][10]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
  while(1){
    cin>>m>>d;
    if(m==0||d==0) break;
    int s=0;
    for(int i=0;i<m-1;i++) s += dom[i];
    cout<<w[(s+d)%7]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1156