akhauriyash/Code-Regression huggingface dataset:
# C - Switches

import itertools

n, m = map(int, input().split())

ks = []
for i in range(m):
    ks.append(list(map(int, input().split())))

p = list(map(int, input().split()))

switch = ('0', '1')
ans = 0
for l in itertools.product(switch, repeat=n):
    for i, kslist in enumerate(ks):
        tmp = 0
        for j in range(1, (kslist[0])+1):
            tmp += int(l[kslist[j]-1])
        if (tmp%2)!=p[i]:
            break
    else:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
using namespace std;
const int INF = 1000000000000;
const int mod = 1000000007;
signed main() {
	int n, cnt = 0; cin >> n; int ng = n;
	if (ng % 2 == 0) { ng++; }
	for (int h = 1; h <= n; h++) {
		for (int i = h + 1; i <= n; i++) {
			if (h + i != ng) { cnt++; }
		}
	}
	cout << cnt << endl;
	for (int h = 1; h <= n; h++) {
		for (int i = h + 1; i <= n; i++) {
			if (h + i != ng) {
				cout << h << ' ' << i << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

struct State{
	int w, v;
	double cost;
	State(int w_, int v_){
		w = w_; v = v_; cost = (double)v_ / w_;
	}
	State(){}
};
bool operator<(const State& a, const State& b){
	return a.cost < b.cost;
}

int main(){
	int N, W;
	scanf("%d %d", &N, &W);
	
	double weight=0, value=0;
	vector<State> a;
	for(int i=0 ; i < N ; i++ ){
		int w_, v_;
		scanf("%d %d", &w_, &v_);
		if( w_ <= 0 && v_ >= 0 ){
			weight += w_;
			value += v_;
			continue;
		}else if( w_ >= 0 && v_ <= 0 ){
			continue;
		}else if( w_ <= 0 && v_ <= 0 ){
			weight += w_;
			value += v_;
			w_ *= -1;
			v_ *= -1;
		}
		a.push_back( State(w_, v_) );
	}
	sort(a.rbegin(), a.rend());
	N = a.size();
	for(int i=0 ; i < N ; i++ ){
		if( weight + a[i].w < W ){
			weight += a[i].w;
			value += a[i].v;
		}else{
			double x = (double)(W - weight) / a[i].w;
			weight += a[i].w * x;
			value += a[i].v * x;
			break;
		}
	}
	printf("%.8f\n", value);
}

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

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

  // Count OKs
  long Rs = 0;
  long Gs = 0;
  long Bs = 0;
  for (int i = 0; i < N; i++) {
    if(S[i]=='R') Rs++;
    if(S[i]=='G') Gs++;
    if(S[i]=='B') Bs++;
  }

  // Count NGs
  long ngCount = 0;
  for (int i = 0; i < N-1; i++) {
    char first = S[i];
    for (int j = i+1; j < N; j++) {
      char second = S[j];
      int distance = j-i;
      if (first != second && j+distance < N){
        char third = S[j+distance];
        if(third != first && third != second){
          ngCount++;
        }
      }
    }
  }
  
  long answer = Rs*Gs*Bs - ngCount;
  
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String Nam = sc.next();
		
		if(Nam.equals("SUN")){System.out.println(7);}
		if(Nam.equals("MON")){System.out.println(6);}
		if(Nam.equals("TUE")){System.out.println(5);}
		if(Nam.equals("WED")){System.out.println(4);}
		if(Nam.equals("THU")){System.out.println(3);}
		if(Nam.equals("FRI")){System.out.println(2);}
		if(Nam.equals("SAT")){System.out.println(1);}
    }
}


Measured memory_bytes: 23380
# include <iostream>
# include <cstdio>

using namespace std ;

const int MOD = 998244353 ;

int n , s , a[3005] ;
int dp[3005][3005] ;

int main()
{
	scanf("%d%d" , &n , &s) ;
	for ( int i = 1 ; i <= n ;i++ ) scanf("%d" , a + i) ;
	dp[0][0] = 1 ;
	for ( int i = 1 ; i <= n ; i++ )
	{
		for ( int j = 0 ; j <= s ; j++ )
		{
			dp[i][j] = dp[i - 1][j] * 2 % MOD ;
			if ( j >= a[i] )
			{
				dp[i][j] = ( dp[i][j] + dp[i - 1][j - a[i]] ) % MOD ;
			}
		}
	}
	printf("%d\n" , dp[n][s]) ;
	return 0 ;
}

Measured memory_bytes: 38996
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;

typedef long long LL;

const int N=200000;

int len,l1;
char la[5];
char s[N+5]; 

int main()
{
	scanf("%s",s+1);
	len=strlen(s+1);
	l1=2;
	int ans=0;
	for(int i=1;i<=len;i++)
	{
		if(l1 == 2 || la[0] != s[i])
		{
			la[0] = s[i];
			l1 = 1;
			la[1] = 0;
		}
		else
		{
			la[0] = s[i];
			if(i==len) break;
			la[1] = s[++i];
			l1 = 2;
		}
		ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

using namespace std;
using ll = long long;

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            ret.push_back(i);
            if (i != 1 && i*i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) { return toupper(c); }
};

struct ToLower {
    char operator()(char c) { return tolower(c); }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N, X;
    cin >> N >> X;
    vector<int>A(N);
    cin >> A;
    SORT(A);
    int ans = 0;
    REP(i, N) {
        X -= A[i];
        if (X >= 0)ans++;
        else break;
    }

    if (X > 0)ans--;
    cout << ans << endl;

    return 0;
}

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



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

	vector<int>dish(N);
	vector<int>B(N);
	vector<int>C(N);

	for (int i = 0; i < N; i++) {
		cin >> dish[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> B[i];
	}
	for (int i = 0; i < N - 1; i++) {
		cin >> C[i];
	}
	// 答え
	int ans = 0;
	int  tmp=0;
	for (int i = 0; i < N; i++) {
		ans += B[dish[i]-1];
		if (i!=0 && tmp+1 == dish[i]-1) {
			ans += C[tmp];
			
		}
		tmp = dish[i]-1;
		//cout << ans<<":" << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<complex>
using namespace std;
int main()
{
     int n;
    cin >> n;
    n%=10;
    switch (n)
    {
    case 3:
    cout << "b";
        break;
    case 0:
    case 1:
    case 6:
    case 8:
    cout << "p";
        break;
    default:
    cout << "h";
        break;
    }
    cout << "on";
    return 0;
}

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

int main(){
    string s;

    while(cin>>s){
        int ans = 700;
        for(int i=0; i<3; i++)
            if(s[i]=='o')
                ans+=100;
        cout<<ans<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long int
#define loop(i,a,b)           for(ll i=a;i<=b;++i)
#define pb                    push_back
#define F                     first
#define S                     second
#define mp                    make_pair
#define clr(x)                x.clear()
#define mod                   1000000007
#define itoc(c)               ((char)(((int)'0')+c))
#define vl                    vector<ll>
#define SZ(x)                 (x).size()
#define all(p)                p.begin(),p.end()
#define mid(s,e)              (s+(e-s)/2)
#define sv()                  ll t,n; scanf("%lld",&t);n=t; while(t--)
#define tcase()               ll t,n; cin>>t;n=t; while(t--)
#define iscn(num)             scanf("%d",&num);
#define scn(num)              scanf("%lld",&num);
#define scn2(num,num2)        scanf("%lld%lld",&num,&num2);
#define dbg(x)                cerr <<"( "<<#x << " = " << x << " )"<<endl
using namespace std;
const ll INF = 2e18 + 99;
typedef pair<ll,ll> Pair;
typedef vector<ll> vec;;
void FAST_IO();
void ara_read(vec &v,ll n);
////////////////////////

int main()
{
	ll n,m; scn2(n,m);
	vector<string> ara(n);
	for(int i=0; i< n; i++){
		cin>>ara[i];
	}
	ll dp[n][m];
	memset(dp,0,sizeof(dp));
	// let's make first row 
	for(int i=0; i< m ; i++){
		if(ara[0][i]=='#')
			break ;
		dp[0][i]=1;
	}
	// let's make first col
	for(int i=0; i< n; i++){
		if(ara[i][0]=='#')
			break ;
		dp[i][0]=1;
	}
	
	for(int i=1; i< n; i++){
		for(int j=1; j< m; j++){
		if(ara[i][j]=='#')
			continue ;
		dp[i][j]=dp[i-1][j]%mod+ dp[i][j-1]%mod;
		}
	}
	printf("%lld\n",dp[n-1][m-1]%mod);
    return 0;
}

void FAST_IO()
{
    // ios_base::sync_with_stdio(0);
    //cin.tie(NULL);
    //cout.tie(NULL);
    //cout.setf(ios::fixed);
    //cout.precision(2);

}
void ara_read(vec &v,ll n){
	ll temp;
	for(ll i=0; i<n; i++){
		scanf("%lld",&temp);
		v.emplace_back(temp);
	}
	
}


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

#define ll long long
#define vec vector<ll>
#define sortv(a); sort(a.begin(), a.end());
#define rev(a); reverse(a.begin(), a.end());
#define FOR(i,a,b) for (ll i = (ll)(a); i < (b); i++)
#define ROF(i,a,b) for (ll i = (ll)(b)-1; i >= (a); i--)

ll MOD = 1000000007;
ll INF = 1LL << 60;

int solve(ll n) {
	if (n==2) return 1;
	if (n==3) return 2;
	if (n==4) return 3;
	if (n==5) return 3;
	set<ll> out;
	out.insert((ll)(n));
	out.insert((ll)(n-1));
	for(ll i=2;i*i<=n;i++) {
		if (n%i==0) {
			ll temp=n;
			while (temp%i==0) {
				temp/=i;
			}
			if ((temp-1)%i==0) out.insert(i);
		}
	}
	for(ll i=2;i*i<=(n-1);i++) {
		if ((n-1)%i==0) {
			out.insert(i);
			out.insert(n/i);
		}
	}
	// for (const auto s : out) {
	// 	cout<<s<<endl;
	// }
	return out.size();
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	ll n;cin>>n;
	cout<<solve(n);
}

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

int main() {
    int n;
    cin >> n;
    int p[n];
    for(int i=0;i<n;i++)
        cin >> p[i];
    
    vector<int> v;
    int count = 0;
    for(int i=1;i<n-1;i++){
        int x = p[i];
        v.clear();
        v.push_back(p[i-1]);
        v.push_back(p[i]);
        v.push_back(p[i+1]);
        sort(v.begin(),v.end());
        if(v[1]==p[i])
            count++;
    }
    cout << count;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		
		Scanner stdIn = new Scanner(System.in);
		
		byte day = stdIn.nextByte();
		
		switch	(day) {
			case 22:
				System.out.println("Christmas Eve Eve Eve");
				break;
			case 23:
				System.out.println("Christmas Eve Eve");
				break;
			case 24:
				System.out.println("Christmas Eve");
				break;
			case 25:
				System.out.println("Christmas");
				break;
			}
		
	}
}

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

//カウントしていくだけの作業
//ただ、最後の試合はどちらが勝ったのか表記されないので注意

int main(){
	string game;
	while(cin >> game, game[0] != '0'){
		int a = 0; int b = 0;

		for(int i=1; i < game.length(); i++){
			if(game[i] == 'A') a++;
			else b++;
		}
		if(a < b) cout << a << " " << b+1 << endl;
		else cout << a+1 << " " << b << endl;
	}
}

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

using namespace std;
int a[500005];
int main()
{
    int n;
    cin>>n;
    while(n--)
    {
        int x;
        cin>>x;
        a[x]++;
        a[x-1]++;
        a[x+1]++;
    }
    int maxv=0;
    for(int i=0;i<=500000;i++)
        if(a[i]>maxv)
            maxv=a[i];
    cout<<maxv;
    return 0;
 } 

Measured memory_bytes: 640
/*
 *  AUTHOR : MANAV PATEl
*/
#include<bits/stdc++.h>
#include<functional>
//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

namespace fastio {

	template <class T> istream &operator>>(istream &os, vector<T> & vec) {
		for (auto &u : vec)os >> u;
		return os;
	}
	template <class T> ostream &operator<<(ostream &os, const vector<T> & vec) {
		for (auto &u : vec)os << u << " ";
		return os;
	}
	template<class T1, class T2> inline istream& operator>>(istream& os, pair<T1, T2>& p) {
		return os >> p.first >> p.second;
	}
	template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
		return os << p.first << " " << p.second;
	}
	template <class T> ostream &operator<<(ostream &os, set<T> & con) {
		for (auto &u : con) os << u << " ";
		return os;
	}
	void re() {}
	template <typename T, typename... args> void re(T& x, args&... tail) {
		cin >> x;
		re(tail...);
	}
	void pr() {}
	template <typename T> void pr(const T& x) {
		cout << x;
	}
	template <typename T, typename... args> void pr(const T& x, const args&... tail) {
		cout << x << " ";
		pr(tail...);
	}
	template <typename... args> void prln(const args&... tail) {
		pr(tail...);
		cout << "\n";
	}
}
using namespace fastio;

typedef long long int ll;
typedef long double ld;

const ll mod = 1e9+7;
const ll mod1 = 998244353;

#define fill(a)  memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back

int main()
{
	int n, j = 1, flag = 0;
	re(n);
	for(int i = 0; i < n; i++)
	{
		int x;
		re(x);
		if(x == j)
		{
			//cout << x <<"\n";
			flag = 1;
			j++;
		}
	}
	if(!flag) cout << -1 << "\n";
	else cout << n - j + 1<< "\n";
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Popular Vote
            var line = ReadLine();
            var N = line[0];
            var M = line[1];
            var A = ReadLine();

            A.Sort();
            A.Reverse();

            var m = A.Take(M).Last();
            double reference = A.Sum() / (4.0 * M);

            if (m >= reference)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13396
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,k = list(map(int, input().split()))
ans = 0
M = 10**9+7
for i in range(k, n+2):
    ans += (n-i+1+n)*(i)//2 - i*(i-1)//2 + 1
    ans %= M
#     print(i,ans)
print(ans%M)

Measured memory_bytes: 63800
/*
* Author. Silviase(@silviasetitech)
* For AtCoder
*/

import java.util.*;
import java.lang.*;
import java.math.*;


public class Main {

    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        int ans = 0;
        for (int i = 0; i < s.length(); i++) {
            if (i % 2 == 0) {
                if (s.charAt(i) == 'p') {
                    ans--;
                }
            } else {
                if (s.charAt(i) == 'g') {
                    ans++;
                }
            }
        }

        System.out.println(ans);
        sc.close();
    }


    private static long gcd(Long m, long n) {
        if(m < n) {
            return gcd(n, m);
        }
        if(n == 0){
            return m;
        } 
        return gcd(n, m % n);
    }

    private static long[][] Combination_nCk(long n, long k) {
        n++; k++;
        long[][] ans = new long[(int)n][(int)k];
        for (int i = 0; i < n; i++) {
            ans[i][0] = 1;
        }
        for (int i = 0; i < n-1; i++) {
            for (int j = 0; j < k-1; j++) {
                if (i < j) {
                    ans[i][j] = 0;
                }else{
                    ans[i+1][j+1] = ans[i][j] + ans[i][j+1];
                }
            }
        }
        return ans;
    }
    private static double[][] Probability_nCk(int n, int k) {
        n++; k++;
        double[][] ans = new double[n][k];
        for (int i = 0; i < n; i++) {
            if (i == 0) {
                ans[i][0] = 1;
            }else{
                ans[i][0] = ans[i-1][0]/2;
            }
        }
        for (int i = 0; i < n-1; i++) {
            for (int j = 0; j < k-1; j++) {
                if (i < j) {
                    ans[i][j] = 0;
                }else{
                    ans[i+1][j+1] = (ans[i][j] + ans[i][j+1])/2;
                }
            }
        }
        return ans;
    }
}

Measured memory_bytes: 24660
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    int answer = 0;
    int answerMemo = 0;

    for(int i = 1; i < n; i++)
    {
      if(nums[i] <= nums[i-1])
      {
        answerMemo++;
        if(answerMemo > answer) answer = answerMemo;
      }else answerMemo = 0;
    }    

		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 25436
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <cmath>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define step(i, f, n, a) for(int (i) = (f); (i) < (n); (i)+=a)
#define rstep(i, f, n, a) for(int (i) = (f); (i) >= (n); (i)-=a)
#define p(...) printf(__VA_ARGS__); cout << endl;
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](const a, const b){ return c ;}
#define key(t, x, compare) [](const t& a, const t& b){ return a x compare b x ;}

using namespace std;

using ll = long long;
using pii = pair<int, int>;

int main(){
	int n,m;
	gets(n) gets(m)
	char a[n][n], b[m][m];

	rep(i, n){
		rep(j, n){
			gets(a[i][j])
		}
	}

	rep(i, m){
		rep(j, m){
			gets(b[i][j])
		}
	}

	bool result = false;

	rep(i, n){ //大元のループずらしていく
		rep(j, n){
			if (i+m-1 == n || j+m-1 == n){ //端なら
				continue;
			}
			bool match = true;
			rep(k, m){
				rep(l, m){
					if (a[i+k][j+l] != b[k][l]){ //一致していないなら
						match = false;
					}
				}
			}
			if (match){
				result = true;
			}
		}
	}
	if (result){
		puts("Yes")
	}else{
		puts("No")
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
#define fin(ans) cout << (ans) << endl
const int INF = 1<<30;
const ll MOD = 1000000007;

int main() {
  ll A,B,C,X,Y;
  cin >> A >> B >> C >> X >> Y;
  
  ll min = A*X+B*Y, mp = std::max(X,Y);
  for(int i=mp*2; i>=0; i-=2){
      ll sum = C*i;
      if(X-i/2>0) sum+=A*(X-i/2);
      if(Y-i/2>0) sum+=B*(Y-i/2);
      min = std::min(min,sum);
      //cout << i << " " << sum << endl;
  }

  cout << min << endl;
  
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main
{

  final static int[] WEIGHT =
  { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 };

  public static void main(String[] args) throws NumberFormatException, IOException
  {
    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

    while (input.ready())
    {
      final int num = Integer.parseInt(input.readLine());

      System.out.println(solver(num));
    }

  }

  private static String solver2(int num)
  {
    final char[] bitFlag = Integer.toBinaryString(num).toCharArray();
    StringBuilder ret = new StringBuilder();

    int count = 0;
    for (int i = bitFlag.length - 1; i >= 0; i--)
    {
      if (bitFlag[i] == '1')
      {
        ret.append(WEIGHT[count]);
        ret.append(" ");
      }
      count++;
    }
    return ret.toString().trim();
  }

  private static String solver(int num)
  {
    final char[] bitFlag = Integer.toBinaryString(num).toCharArray();
    List<String> stringList = new ArrayList<>();

    int count = 0;
    for (int i = bitFlag.length - 1; i >= 0; i--)
    {
      if (bitFlag[i] == '1')
      {
        stringList.add(String.valueOf(WEIGHT[count]));
      }
      count++;
    }
    return String.join(" ", stringList);
  }
}

Measured memory_bytes: 24436
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

int main() {
  string a;
  cin >>a;
  
  cout << (a[0]==a[1] && a[1]==a[2]?"No":"Yes") << endl;
  
}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;

}

signed main() {
	string s;
	ll cnt = 0;

	cin >> s;

	REP(i, s.size()) {
		if (s[i] == 'o') {
			cnt++;
		}
	}

	if (cnt + 15 - s.size() >= 8) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

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

int main() {
	ll X, Y;
	cin >> X >> Y;
	if ((2 * X <= Y) && (Y <= 4 * X) && (Y % 2 == 0))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

int main(){
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	for(int i=0; i<h; i++)
		cin >> s[i];
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if(s[i][j] == '#'){
				bool judge = true;
				if(i!=0 && s[i-1][j]=='#')
					judge = false;
				if(j!=0 && s[i][j-1]=='#')
					judge = false;
				if(j!=w-1 && s[i][j+1]=='#')
					judge = false;
				if(i!=h-1 && s[i+1][j]=='#')
					judge = false;
				if(judge){
					cout << "No" << endl;
					return 0;
				}
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}


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

using namespace std;

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

  int n, k;
  cin >> n >> k;
  set<int> s;
  for (int i = 0; i < k; ++i) {
    int d;
    cin >> d;
    while (d--) {
      int x;
      cin >> x;
      s.insert(x);
    }
  }
  cout << n - (int)s.size();

  return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>

int main() {
	int A, B, C;
	int cnt = 0;

	scanf("%d %d %d", &A, &B, &C);
	while (C > 0) {
		C = C - A;
		cnt++;
		if (cnt % 7 == 0) {
			C = C - B;
		}
	}
	printf("%d\n", cnt);

	return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REP1(i,n) for(int i=1;i<=(int)(n);i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)

int main(){
int d;
int temp=0;
vector<int> c(26);
vector<int> ci(26);
cin >> d ;
REP(i,26)cin >> c.at(i);

REP(i,d){
	REP(i,26)cin >> ci.at(i);
	REP1(i,25)if(ci.at(temp)<ci.at(i))temp=i;
	cout << temp+1 << endl;
	temp=0;
	}
}

Measured memory_bytes: 3628
//coded b vishal mourya - the legendary coder
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define f(a,b) for(ll i = a ; i < b ; i++ )
#define fj(a,b) for(ll j = a ; j < b ; j++ )
#define fk(a,b) for(ll k = a ; k < b ; k++ )
#define fasthoja ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main(void){
    fasthoja;
    ll h; cin >> h;
    ll a; cin >> a;
    ll cnt = 0;
    while( h > 0 ) {
    	cnt++;
    	h -= a;
	}
	cout << cnt << "\n";

 return 0;
}


Measured memory_bytes: 3596
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}

use input::*;
use std::cmp;

fn p_fact(n: usize) -> Vec<(usize, usize)> {
    let mut v = Vec::new();
    let mut i = 1;
    while i <= ((n as f64).sqrt() as usize + 1) {
        if n % i == 0 {
            v.push((i, n / i));
        }
        i += 1;
    }
    v
}

fn f(a: usize, b: usize) -> usize {
    cmp::max(a.to_string().len(), b.to_string().len())
}

fn main() {
    let n: usize;
    input!(n);

    let v = p_fact(n);
    let mut ans = 9999999;
    for vv in v {
        ans = cmp::min(ans, f(vv.0, vv.1));
    }
    p(ans);
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <atcoder/mincostflow>

#define amax(a, b) a = max(a, b)
#define amin(a, b) a = min(a, b)

using ll = long long;

#define INF 1000

int main() {
    int n, m;
    std::cin >> n >> m;
    std::vector<std::string> s(n);
    atcoder::mcf_graph<int, int> graph(n * m + 2);
    int start = n * m, goal = n * m + 1;
    int ans = 0;
    for (int i=0; i<n; i++) {
        std::cin >> s[i];
        for (int j=0; j<m; j++) {
            if (s[i][j] == '#') continue;
            if (i > 0) graph.add_edge((i-1) * m + j, i * m + j, INF, 0);
            if (j > 0) graph.add_edge(i * m + (j-1), i * m + j, INF, 0);
            if (s[i][j] == 'o') {
                graph.add_edge(start, i * m + j, 1, 0);
                ans += (n-i) + (m-j);
            }
            graph.add_edge(i * m + j, goal, 1, (n-i) + (m-j));
        }
    }
    ans -= graph.flow(start, goal).second;
    std::cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 4152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int N; cin >> N;
    vector<vector<int>> F(N, vector<int> (10));
    vector<vector<int>> P(N, vector<int> (11));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> F[i][j];
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 11; j++) {
            cin >> P[i][j];
        }
    }

    int c, tmp;
    int ans = 0;
    ans -= inINF;
    for (int bit = 1; bit < (1<<10); bit++) {
        tmp = 0;
        for (int n = 0; n < N; n++) {
            c = 0;
            for (int i = 0; i < 10; i++) {
                if(F[n][i] == 1 && (bit & (1<<i))){
                    c++;
                }
            }
            tmp += P[n][c];
        }
        ans = max(tmp, ans);
    }

    printf("%d\n", ans);
}

Measured memory_bytes: 256
def main():
    from builtins import int, map, list, print, min
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    N, K = input_number_list()
    print(min((N % K), (-N % K)))



if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Control.Arrow

main :: IO ()
main = do
  getc solve >>= mapM_ putStrLn

solve :: [String] -> [String]
solve = map f
  where
    f :: String -> String
    f = concatMap g . map (head &&& length) . group
    g :: (Char,Int) -> String
    g (c,n)
      | c == '0' = replicate (n-1) ' '
      | c == '1' = ["'", ",", ".", "!", "?"] !! (n-1)
      | c == '2' = ["a", "b", "c", "A", "B", "C"] !! (n-1)
      | c == '3' = ["d", "e", "f", "D", "E", "F"] !! (n-1)
      | c == '4' = ["g", "h", "i", "G", "H", "I"] !! (n-1)
      | c == '5' = ["j", "k", "l", "J", "K", "L"] !! (n-1)
      | c == '6' = ["m", "n", "o", "M", "N", "O"] !! (n-1)
      | c == '7' = ["p", "q", "r", "s", "P", "Q", "R", "S"] !! (n-1)
      | c == '8' = ["t", "u", "v", "T", "U", "V"] !! (n-1)
      | c == '9' = ["w", "x", "y", "z", "W", "X", "Y", "Z"] !! (n-1)
      | otherwise = ""
        
getc :: ([String] -> a) -> IO a
getc f = f . lines <$> getContents

Measured memory_bytes: 4008
let N =
    stdin.ReadLine()
    |> int
let Mod = 1000000007L

let rec culc i value x =
    if i=N then value
    else culc (i+1) (value*x%Mod) x

((culc 0 1L 10L) - (culc 0 1L 9L) * 2L % Mod + (culc 0 1L 8L) + Mod) % Mod
|> stdout.WriteLine

Measured memory_bytes: 27876
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	VI N(4);
	REP(i, 4)cin >> N[i];
	SORT(N);
	if (N[0] == N[1] && N[2] == N[3])cout << "yes" << endl;
	else cout << "no" << endl;

	return 0;
}




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

using vi = vector<int>;

int main()
{
    ios_base::sync_with_stdio(0);

    int n; cin >> n;

    vi v(n + 1);

    for(int i = 1; i <= n; i++) cin >> v[i];

    int ans = 0;

    for(int i = 1; i <= n; i++) if(v[i] == i)
    {
        ans++;

        if(i > 1 && v[i - 1] == i - 1)
        {
            swap(v[i], v[i - 1]);
            continue;
        }
        else
        if(i < n && v[i + 1] == i + 1)
        {
            swap(v[i], v[i + 1]);
            continue;
        }

        if(i > 1)
        {
            swap(v[i], v[i - 1]);
        }
        else
        if(i < n)
        {
            swap(v[i], v[i + 1]);
        }
    }

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

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

ll INF;

struct LazySegmentTree {
public:
    ll n;
    vector<ll> node, lazy;
    vector<bool> lazyFlag;

public:
    LazySegmentTree(vector<ll> v) {
        ll sz = (ll)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, INF);
        lazyFlag.resize(2*n-1, false);

        for(ll i=0; i<sz; i++) node[i+n-1] = v[i];
        for(ll i=n-2; i>=0; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }

    void lazyEvaluate(ll k, ll l, ll r) {
        if(lazyFlag[k]) {
            node[k] = lazy[k];
            if(r - l > 1) {
                lazy[k*2+1] = lazy[k*2+2] = lazy[k];
                lazyFlag[k*2+1] = lazyFlag[k*2+2] = true;
            }
            lazyFlag[k] = false;
        }
    }

    void update(ll a, ll b, ll x, ll k=0, ll l=0, ll r=-1) {
        if(r < 0) r = n;
        lazyEvaluate(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[k] = x;
            lazyFlag[k] = true;
            lazyEvaluate(k, l, r);
        }
        else {
            update(a, b, x, 2*k+1, l, (l+r)/2);
            update(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = min(node[2*k+1], node[2*k+2]);
        }
    }

    ll find(ll a, ll b, ll k=0, ll l=0, ll r=-1) {
        if(r < 0) r = n;
        lazyEvaluate(k, l, r);
        if(b <= l || r <= a) return INF;
        if(a <= l && r <= b) return node[k];
        ll vl = find(a, b, 2*k+1, l, (l+r)/2);
        ll vr = find(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
};


int main() {
    ll n, q;
    cin >> n >> q;
    INF = n - 1;
    LazySegmentTree seg(vector<ll>(n, INF)), seg2(vector<ll>(n, INF));
    ll ans = (n - 2) * (n - 2);
    rep(i, q) {
        ll query, a;
        cin >> query >> a;
        if (query == 1) {
            a--;
            ll now = seg.find(a, a + 1);
            ans -= now - 1;
            if (seg2.find(1, 2) > a) {
                seg2.update(1, now + 1, a);
            }
        }
        if (query == 2) {
            a--;
            ll now = seg2.find(a, a + 1);
            ans -= now - 1;
            if (seg.find(1, 2) > a) {
                seg.update(1, now + 1, a);
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 21440
#include <stdio.h>
int main()
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if (a > b && c > b && c < a)
        printf("Yes\n");
    if (a > b && (c < b || c > a))
        printf("No\n");
    if (a < b && a < c && c < b)
        printf("Yes\n");
    if (a < b && (c < a || c > b))
        printf("No\n");
    return 0;
}


Measured memory_bytes: 128
import sys


def input():
    return sys.stdin.readline().strip()


def solve():
    N = int(input())
    inc_chunks = []
    dec_chunks = []
    for _ in range(N):
        depth = 0
        level = 0
        for c in input():
            if c == '(':
                level += 1
            else:
                level -= 1
                depth = min(depth, level)
        if depth >= 0 and level == 0:
            continue
        elif level > 0:
            inc_chunks.append((depth, level))
        else:
            dec_chunks.append((depth - level, -level))

    inc_chunks.sort(reverse=True)
    dec_chunks.sort(reverse=True)
    inc_level = 0
    for depth, level in inc_chunks:
        if inc_level + depth < 0:
            return 'No'
        inc_level += level
    dec_level = 0
    for depth, level in dec_chunks:
        if dec_level + depth < 0:
            return 'No' 
        dec_level += level
    if inc_level != dec_level:
        return 'No'
    return 'Yes'


print(solve())


Measured memory_bytes: 80364
#include<iostream>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;

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

if(x==1){
 cout << "Hello World" << endl ;
 return 0;
}else{
  int a,b ;
  cin >> a >> b ;
  cout << a+b << endl ;
  return 0;
}
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
using namespace std;

const long long mod = 998244353 ;



int main()
{
    int n;scanf("%d",&n);
    for (int i=1;i<=9;++i)
    for (int j=1;j<=9;++j)
    if (i*j==n){
        printf("Yes\n");return 0;
    }
    printf("No\n");


}


Measured memory_bytes: 128
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define I(n) scanf("%d", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#include <bits/stdc++.h>
using namespace std;

long long d[100001];
int k,m;

void check(int a, int ans, int mod){
    if (ans > 45 || d[a] & ((long long)1 << ans)){
        return;
    }
    d[a] |= (long long)1 << ans;
    if (a == 0 && 0 < ans && ans < m){ m = ans; }
    REP(i,10) check((a*10+i)%mod,ans+i,mod);
}

int main(){
    I(k);
    m = 10000;
    check(0,0,k);
    printf("%d\n",m);
}


Measured memory_bytes: 155648
#include<bits/stdc++.h>
#include<algorithm>
#include<functional>
#define len(a) sizeof(a)/sizeof(a[0])
#define sort_asc(a,b) sort(a,a+b)
#define sort_dsc(a,b,dataType) sort(a,a+b,greater<dataType>())
#define IN cin>>
#define OUT cout<<
#define PI 3.14159265358979323846D
#define forr(i,b,e) for(int (i)=(b); (i) <= (e); (i)++)
#define pb push_back
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define vi vector<int>
#define nl endl
typedef long long int ll;
using namespace std;
void f();
int main()
{
    int t=1;
    //IN t;
    for(int i=0;i<t;++i) {f(); if(i!=t-1) OUT endl; else continue;}
    //{OUT "Case "<<i<<":"<<f(); if(i!=t-1) OUT endl; else continue;}
    return 0;
}
void f()
{
   string s1,s2;
   int cnt=0;
   IN s1>>s2;
   forr(i,0,s1.length()-1)
        if(s2[i]==s1[i]) continue;
        else ++cnt;
    OUT cnt;
}


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

int main() {
	int x,n;
	cin >> x >> n;
	vector<int> vec(n);
	int a=0;

	for(int i=0; i<n; i++)
	cin >> vec.at(i);

	for(int i=0; i>=0; i++){

		a = 0;
		for(int j=0; j<n; j++){
			if(x-i == vec.at(j)){
				a++;
			}
		}
		if(a == 0){
			cout << x-i << endl;
			break;
		}

		a = 0;

		for(int j=0; j<n; j++){
			if(x+i == vec.at(j)){
				a++;
			}
		}
		if(a == 0){
			cout << x+i << endl;
			break;
	}
}
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
int main(){
    int a,b;
    cin>>a>>b;
    cout << (b-1+a-2)/(a-1) << endl;
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    int S;
    cin >> S;
    
    int h, m, s;
    h = S / 3600; 
    m = S / 60 - (60 * h);
    s = S - (h * 3600) - (m * 60);
    cout << h << ":" << m << ":" << s << endl;
}

Measured memory_bytes: 1168
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <stdio.h>
#include <string>

using namespace std;

long long gcd(long long a, long long b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
  long long g = gcd(a, b);
  return a / g * b;
}

void solve(int N, vector<long long> A) {
  long long ans = A[0];
  for (int i = 0; i < N; i++) {
    ans = gcd(ans, A[i]);
  }
  printf("%lld\n", ans);
}

int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  solve(N, A);
  return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
int main () {
    int n;
    cin >> n;
    vector<double> a(n);
    double p = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        p += 1/a[i];
    }
    cout << 1/p << endl;
}

Measured memory_bytes: 256
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

A, B = reads()
if A * B % 2 == 0:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 38384
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import Data.Bool

readIntsLine :: IO [Int]
readIntsLine = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

count :: [Int] -> (Int, Int, Int) -> (Int, Int, Int)
count [] b = b
count (a:as) (b1, b2, b4)
  | a `mod` 4 == 0 = count as (b1, b2, b4 + 1)
  | a `mod` 2 == 0 = count as (b1, b2 + 1, b4)
  | otherwise = count as (b1 + 1, b2, b4)

main :: IO ()
main = do
  getLine
  as <- readIntsLine
  let (b1, b2, b4) = count as (0, 0, 0)
  putStrLn $ if b1 <= b4 + bool 0 1 (b2 == 0) then "Yes" else "No"


Measured memory_bytes: 2940
#include <iostream>
#include <string>
using namespace std;
int main(){
	string S;
	string T = "";
	cin >> S;
	int n = S.length();
	for(int i = 0; i < n; i++){
		//cout << "x" << endl;
		T += "x";
	}

	//cout << S << endl;
	cout << T << endl;
	return 0;
}

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

#include <vector>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)

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

typedef long long ll;

const int D = 60;
const int MAX_N = 200005;
int to[D][MAX_N];

int main() {
    int N;
    ll K;
    cin >> N >> K;
    rep(i, N) {
        cin >> to[0][i];
        to[0][i]--;
    }
    rep(i, D - 1) {
        rep(j, N) {
            to[i + 1][j] = to[i][to[i][j]];
        }
    }

    int v = 0;
    for (int i = D - 1; i >= 0; i--) {
        ll l = 1ll << i;
        if (l <= K) {
            v = to[i][v];
            K -= l;
        }
    }
    cout << v + 1 << endl;
    return 0;
}


Measured memory_bytes: 50512
#include<bits/stdc++.h>
using namespace std;
int h,w,a[501][501];
struct node{
	int a,b,c,d;
};
vector<node>v;
int main(){
	cin>>h>>w;
	for(int i=1;i<=h;i++){ 
		for(int j=1;j<=w;j++)
			cin>>a[i][j];
	for(int j=1;j<w;j++)
		if(a[i][j]&1){
			a[i][j+1]++;
			v.push_back((node){i,j,i,j+1});
		}
	}	
	for(int i=1;i<h;i++)
		if(a[i][w]&1){
			a[i+1][w]++;
			v.push_back((node){i,w,i+1,w});
		}
	cout<<v.size()<<endl;
	for(int i=0;i<v.size();i++){
		cout<<v[i].a<<" "<<v[i].b<<" "<<v[i].c<<" "<<v[i].d<<endl;
	}
	return 0;
}


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

int main(void){
  int a, b, c, d, e;
  int k;
  cin >> a >> b >> c >> d >> e;
  cin >> k;
  string ret = "";
  if(e-a > k) ret += ":(";
  else ret += "Yay!";
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 256
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())
mid = (A1 - B1) * T1
end = mid + (A2 - B2) * T2
if end == 0:
	print("infinity")
elif mid*end > 0:
	print(0)
else:
	if mid % end == 0:
		print(-2*(int(mid/end)))
	else:
		print(1-2*(int(mid/end)))

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
long long n,S,w[1000],v[1000],F[101][100001];
using namespace std;
int main()
{
    //freopen("KNAPSACK1.INP","r",stdin);
    cin>>n>>S;
    for (long long i=1;i<=n;i++)
        cin>>w[i]>>v[i];
    for (long long i=1;i<=n;i++)
        for (long long j=1;j<=S;j++)
            if (w[i]<=j) F[i][j]=max(F[i-1][j-w[i]]+v[i],F[i-1][j]);
            else F[i][j]=F[i-1][j];
    cout<<F[n][S];
    return 0;
}


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

int main() {
    int n, l;
    string s;
    cin >> n >> l >> s;
    int k = l - 1;
    if (s.at(k) == 'A') s.at(k) = 'a';
    if (s.at(k) == 'B') s.at(k) = 'b';
    if (s.at(k) == 'C') s.at(k) = 'c';
    cout << s << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    n = II()
    t = input()
    conter = cl.Counter(t)
    num_w = conter["W"]
    num_r = conter["R"]
    w_in_r = 0
    r_in_r = 0
    for i in range(num_r):
        if t[i] == "W":
            w_in_r += 1
        else:
            r_in_r += 1
    r_in_w = num_r - r_in_r
    print(max(w_in_r, r_in_w))


main()


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

#define F first 
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 510, M = 35;

int n, m;
int g[N][N], f[M][M];
int c[3][M];

int main()
{
	cin >> n >> m;
	for (int i = 1; i <= m; i ++ )
		for (int j = 1; j <= m; j ++ )
			cin >> f[i][j];
	for (int i = 1; i <= n; i ++ )
		for (int j = 1; j <= n; j ++ )
		{
			cin >> g[i][j];
			c[(i + j) % 3][g[i][j]] ++ ;
		}
	
	int res = 0x3f3f3f3f;
	for (int i = 1; i <= m; i ++ )
		for (int j = 1; j <= m; j ++ )
			for (int k = 1; k <= m; k ++ )
				if (i == j || i == k || j == k) continue;
				else
				{
					int sum = 0;
					for (int v = 1; v <= m; v ++ )
					{
						sum += c[0][v] * f[v][i];
						sum += c[1][v] * f[v][j];
						sum += c[2][v] * f[v][k];
					}
					res = min(res, sum);
				}
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 4588