akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

int main(){
    int D;
    std::cin >> D;
    std::vector< int > C(26);
    std::vector< int > cur_bad(26);
    for(int i=0; i<26; i++){
        std::cin >> C[i];
        cur_bad[i] = C[i];
    }
    std::vector< std::vector< int > > S(D, std::vector< int >(26));
    for(int i=0; i<D; i++){
        for(int j=0; j<26; j++){
            std::cin >> S[i][j];
        }
    }
    std::vector< int > T(D);
    
    std::vector< int > qD_list;
    std::vector< int > Q_list;
    
    for(int i=0; i<D; i++){
        std::priority_queue< std::pair< int, int > > pq;
        for(int j=0; j<26; j++){
            int score = S[i][j] + cur_bad[j];
            std::pair< int, int > tmp;
            tmp.first = score;
            tmp.second = j;
            pq.push(tmp);
        }
        std::pair< int, int > tmp = pq.top();
        pq.pop();
        int max_index = tmp.second;
        T[i] = max_index + 1;
        cur_bad[max_index] = 0;
        for(int j=0; j<26; j++){
            cur_bad[j] += C[j];
        }
        
        for(int j=0; j<5; j++){
            tmp = pq.top();
            pq.pop();
            qD_list.push_back(i);
            Q_list.push_back(tmp.second);
        }
    }
    
    long long score = 0;
    std::vector< int > lasta(26, 0);
    for(int i=0; i<D; i++){
        score += S[i][T[i] - 1];
        lasta[T[i] - 1] = i + 1;
        for(int j=0; j<26; j++){
            score -= (i + 1 - lasta[j]) * C[j];
        }
    }
    
    for(int trial=0; trial<50; trial++){
        for(int q=0; q<qD_list.size(); q++){
            int qD = qD_list[q];
            int Q = Q_list[q] + 1;
            int pre = T[qD];
            
            T[qD] = Q;
            long long ans = 0;
            std::vector< int > last(26, 0);
            for(int i=0; i<D; i++){
                ans += S[i][T[i] - 1];
                last[T[i] - 1] = i + 1;
                for(int j=0; j<26; j++){
                    ans -= (i + 1 - last[j]) * C[j];
                }
            }
            if(score < ans){
                score = ans;
            }else{
                T[qD] = pre;
            }
        }
    }
    
    
    
    
    for(int i=0; i<D; i++){
        std::cout << T[i] << std::endl;
    }
    
    return 0;
}



Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/abc083_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N, A, B;
  cin >> N >> A >> B;
  
  ll ans = 0;
  rep(i, N + 1) {
    string s = to_string(i);
    int tmp = 0;
    rep(j, s.size()) { tmp += s[j] - '0'; }
    if (tmp >= A && tmp <= B) ans += i;
  }

  cout << ans << endl;
}

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

class C
{
	static void Main()
	{
		var h = Console.ReadLine().Split().Select(int.Parse).ToArray();
		var s = Console.ReadLine();
		var qs = new int[h[1]].Select(_ => Console.ReadLine()).ToArray();
		var n = h[0];

		Func<int, int> move = i =>
		{
			foreach (var q in qs)
			{
				if (s[i] != q[0]) continue;
				i += q[2] == 'L' ? -1 : 1;
				if (i < 0 || i >= n) break;
			}
			return i;
		};

		int ll = 0, lr = n;
		while (ll < lr)
		{
			var m = (ll + lr + 1) / 2;
			if (move(m - 1) == -1) ll = m;
			else lr = m - 1;
		}

		int rl = 0, rr = n;
		while (rl < rr)
		{
			var m = (rl + rr + 1) / 2;
			if (move(n - m) == n) rl = m;
			else rr = m - 1;
		}
		Console.WriteLine(n - ll - rl);
	}
}


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

using namespace std;

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

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

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

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

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

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

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

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

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

int a[4];
string s;
int dfs(int n,int num,string ss){
    if(n > 3){
	if(num == 7){
	    P(s[0] +  ss + "=7");
	    ret 1;
	}else ret 0;
    }

    int f = dfs(n+1,num+a[n],ss + "+" + s[n]);
    if( f == 1)ret 1;
    f = dfs(n+1,num-a[n],ss + "-" + s[n]);
    ret f;
}
int main(){
    cin >> s;
   
    rep(i,0,4)a[i] = int(s[i]-'0');

    dfs(1,a[0],"");
    
    return  0;
}


Measured memory_bytes: 256
#include<stdio.h>

main(){

    int w,h,x,y,r;
    int a,b;

    scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);

    a=x+r;
    b=y+r;

    if(w<a || x<r || h<b || y<r){
      puts("No");
    }else{
      puts("Yes");
    }

    return 0;

}

Measured memory_bytes: 1804
#include<bits/stdc++.h>
#define se second
#define fi first
#define pb push_back
#define cn cout<<"\n"
#define rep(i,a,b) for(int i = a; i < b; i++)
#define repr(i,a,b) for(int i = a; i >= b; i--)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

#define _ ios::sync_with_stdio(0); cin.tie(0);

#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define ll long long
#define vll vector<ll>
#define flush fflush(stdout)

const int INF = 1e8;
const ll MOD = 1e9 + 7;

using namespace std;

int main(){
	_

	int t = 1;

	//cin>>t;
	int a, b;
	vi v;
	rep(nc, 0, t){
		cin>>a>>b;
		v.pb(a);
		v.pb(b);
		v.pb(a - 1);
		v.pb(b - 1);
		sort(allr(v));
		cout<<v[0] + v[1]; cn;
	}

	return 0;
}

Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  ll n;
  cin >> n;
  for(int i=1000;;i+=1000){
    if(i>=n){
      cout << i-n << endl;
      break;
    }
  }
}


Measured memory_bytes: 3636
# -*- coding: utf-8 -*-

def main(N,M,A,B,C,D):
    for i in range(N):
        res = []
        for j in range(M):
            res.append(abs(A[i]-C[j])+abs(B[i]-D[j]))
        print(res.index(min(res))+1)
 
    
if __name__ == '__main__':
    N, M = map(int, input().split())
    A, B = [], []
    for i in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
    C, D = [], []
    for i in range(M):
        c, d = map(int, input().split())
        C.append(c)
        D.append(d)
    
    main(N,M,A,B,C,D)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String line = br.readLine();
		char[] c = line.toCharArray();
		for(int i = 0; i < c.length; i++){
			if( Character.isUpperCase(c[i]) ){
				c[i] = Character.toLowerCase(c[i]);
			}
			else if( Character.isLowerCase(c[i]) ){
				c[i] = Character.toUpperCase(c[i]);
			}
		}
		System.out.println(c);
	}
}

Measured memory_bytes: 24184
# -*- coding: utf-8 -*-

N,X,M=map(int,input().split())

A=[0]*(M+1)
A[0]=X
D=[0]*(M+1)

s=N
for i in range(1,N):
    a=A[i-1]**2%M
    if D[a] == 1:
        s=A.index(a)
        break
    else:
        A[i]=a
        D[a]=1

if s==N:
    ans=sum(A)
else:
    A=A[:i]
    
    ans=0
    l=len(A)-s
    ans+=sum(A[:s])
    S=sum(A[s:])
    T=(N-s)//l
    ans+=T*S
    K=N-s-l*T
    ans+=sum(A[s:(s+K)])


print(ans)


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

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i, n) cin >> x[i];
  int mn = (1e8);
  for (int i = 1; i <= 600; ++i) {
    int sum = 0;
    rep(j, n) sum += (x[j] - i) * (x[j] - i);
    mn = min(mn, sum);
  }
  cout << mn << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(){
  int count=0;;
  char s[101];
  int p[20],n;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&p[i]);
  }
  for(int j=0;j<n-2;j++){
    if((p[j]<p[j+1]&&p[j+1]<p[j+2])||(p[j]>p[j+1]&&p[j+1]>p[j+2]))
      {count++;}
  }

  printf("%d\n",count);
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std; 
#define all(c) c.begin(),c.end()
#define REP(i,a,b) for(int i=a;i<=b;++i)
#define tr(container,it) \
for(auto it=container.begin();it!=container.end();++it)
typedef long long ll ; 
typedef vector<int> vi;
#define mod 1000000007 
#define MAXN 200001
int n;
int best;
vector<int> g[MAXN] ;
bool used[MAXN] ;
vector<int> comp ;

void dfs(int v) {
    used[v] = true ;
    comp.push_back(v);
    for (size_t i = 0; i < (int) g[v].size(); ++i) {
        int to = g[v][i];
        if (!used[to])
            dfs(to);
    }
}

void find_comps() {
    for (int i = 0; i < n ; ++i)
        used [i] = false;
    for (int i = 0; i < n ; ++i)
        if (!used[i]) {
            comp.clear();
            dfs(i);
           // cout << "Component:" ;
           
            //for (size_t j = 0; j < comp.size(); ++j)
            //    cout << ' ' << comp[j];
            //cout << endl ;
            int val=comp.size();
            best=max(best,val);
        }
}

int main()
{
  //  freopen("input.txt","r",stdin);
   ios::sync_with_stdio(0);
   // cin.tie(0);
int m;
cin>>n>>m;
for(int i=1;i<=m;++i){
  int a,b;
  cin>>a>>b;
  g[a].push_back(b);
  g[b].push_back(a);
}
find_comps();
cout<<best;

    return 0;
}

Measured memory_bytes: 24692
from collections import deque

n = int(input())
q = deque(range(1, 10))
for _ in range(n - 1):
    x = q.popleft()
    r = x % 10
    y = 10 * x
    if r == 0:
        q.extend([y, y+1])
    elif r == 9:
        q.extend([y+8, y+9])
    else:
        q.extend([y+r-1, y+r, y+r+1])
print(q.popleft())

Measured memory_bytes: 18788
import java.util.*;
import java.lang.*;

class Mod{
    static final long MOD = 1000_000_007;
    static final long[] fact = makeFactorialArray(1000000);
    static final long[] factInv = makeInversedArray(fact);

    public static long add(long a, long b){
        long tmp = (a+b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long adds(long... ar){
        long ans=0;
        for(long x:ar) ans = Mod.add(ans, x);
        return ans;
    }
    public static long sub(long a, long b){
        return add(a,-b);
    }
    public static long mult(long a, long b){
        long tmp = (a*b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long mults(long... ar){
        long ans=1;
        for(long x:ar) ans = Mod.mult(ans, x);
        return ans;
    }
    public static long power(long a, long x){ //calculate a^x
        if(x<0)return 0;
        if(x==0)return 1;
        if(x%2==0) {
            long half = power(a,x/2);
            return mult(half,half);
        }
        return (a*power(a,x-1)) % MOD;
    }
    public static long inverse(long a){
        return power(a,MOD-2);
    }
    public static long div(long a, long b){
        return mult(a, inverse(b));
    }
    public static long[] makeFactorialArray(int size){
        long[] array = new long[size];
        array[0]=1;
        for(int i=1;i<size;i++){
            array[i]=mult(array[i-1],i);
        }
        return array;
    }
    public static long[] makeInversedArray(long[] original){
        long[] array = new long[original.length];
        for(int i=0;i<original.length;i++){
            array[i] = inverse(original[i]);
        }
        return array;
    }
    public static long combination(int n, int r){
        if(n<0 || r<0 || n<r) return 0;
        return mult(fact[n], mult(factInv[r],factInv[n-r]));
    }
    public static long gcd(long a, long b){
        if(a<b) return gcd(b,a);
        if(b==0) return a;
        if(a%b==0) return b;
        return gcd(b,a%b);
    }
    public static long lcm(long a, long b){
        return (a/gcd(a,b))*b;
    }

}

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long A = Mod.div(sc.nextInt(),100);
        long B = Mod.div(sc.nextInt(),100);
        long C = Mod.div(sc.nextInt(),100);

        A = Mod.div(A, 1-C);
        B = Mod.div(B, 1-C);

        long ans = 0;
        for(int x=0; x<N; x++){
            ans = Mod.add(ans, Mod.mults(N+x, Mod.combination(N+x-1,x), Mod.power(A,N), Mod.power(B,x)));
            ans = Mod.add(ans, Mod.mults(N+x, Mod.combination(N+x-1,x), Mod.power(A,x), Mod.power(B,N)));
        }

        ans = Mod.div(ans, 1-C);
        System.out.println(ans);

    }
}

Measured memory_bytes: 61012
using System;

namespace bla
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int n = int.Parse(s[0]);
            int k = int.Parse(s[1]);
            int ans = (n - 1) / (k - 1);
            if (ans * (k - 1) < (n - 1))
                ans++;
            Console.WriteLine(ans);
        }
    }
}


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

int main(){
  int N;
  cin >> N;
  int a[3][110];
  
  for(int i = 0;i < 2;i++){
    for(int j = 0;j < N;j++){
      cin >> a[i][j];
    }
  }
  
  vector<int> goukei(110);
  for(int i = 0;i < N;i++){
    int sumup = 0;
    int sumdown = 0;
    for(int j = 0;j <= i;j++){
      sumup += a[0][j];
    }
    for(int j = i;j < N;j++){
      sumdown += a[1][j];
    }
    goukei.at(i) = sumup + sumdown;
  }
  
  
  sort(goukei.begin(),goukei.end());
  reverse(goukei.begin(),goukei.end());
  cout << goukei.at(0) << endl;
}    

Measured memory_bytes: 256
def main():
    n = int(input())
    root = int(n ** (1 / 2)) + 1
    isPrime = [True] * (n + 3)
    for i in range(4, n + 3, 2):
        isPrime[i] = False
    
    ans = 0
    prePrime = -1
    for i in range(3, n + 3, 2):
        if isPrime[i]:
            if prePrime + 2 == i:
                ans += 2
                
            prePrime = i
            if i > root:
                continue
            for j in range(i * i, n + 3, i):
                isPrime[j] = False
    print(ans)

main()


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

#define REP(i,n) for(ll i=0; i < (n); ++i)
#define REPR(i,n) for(ll i=(n); i >= 0; --i)
#define FOR(i, m, n) for(ll i = (m); i < (n); ++i)

#define INF 1e9


int main(){
  int N;
  cin >> N;
  vector<pair<int, int>> A(N);
  REP(i, N){
    cin >> A[i].first;
    A[i].second = i+1;
  }
  sort(A.begin(), A.end());
  REP(i, N){
    cout << A[i].second << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 1536
#include <iostream>

signed main() {
  std::string s;
  std::cin >> s;

  int max = 0, count = 0;
  for(int i = 0; i < s.length(); i++) {
    if(s[i] == 'R') {
      count++;
      max = std::max(max, count);
    }
    else
      count = 0;
  }

  std::cout << max << std::endl;

  return 0;
}


Measured memory_bytes: 3184
#include "bits/stdc++.h"
#define double long double
#define int long long
#define mii map<int,int>
#define low lower_bound
#define upp upper_bound
#define inf 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define sort(vec) sort(all(vec));
#define rever(vec) reverse(all(vec));
#define unsort(vec) sort(vec); rever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
int gcd(int a,int b) {
  if(b==0) return a;
  return gcd(b,a%b);
}
signed main() {
  int n;
  cin>>n;
  int a[n];
  int mi=inf;
  rep(i,n) cin>>a[i];
  rep(i,n-1) {
    mi=min(mi,gcd(a[i],a[i+1]));
  }
  cout<<mi<<endl;
}


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

 int main()
 {
  int A, B, C, D;
  cin>>A>>B>>C>>D;

  int X=(A+D-1)/D;
  int Y=(C+B-1)/B;

  if(X>=Y){cout<<"Yes";}
  else {cout<<"No";}

 return 0;
 }


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  long sum = 0;
  rep(i, M)
  {
    cin >> A[i];
    sum += A[i];
  }
  if(sum > N){
    cout << -1 << endl;
    return 0;
  }
  else{
    cout << N-sum << endl;
    return 0;
  }
}

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

int main(){
	
	int N;
	cin>>N;
	
	vector<int> D(N+1);
	D[N]=0;
	for(int i=0;i<N;i++){
		cin>>D[i];
	}
	
	map<int,int> mp;
	for(int i=0;i<=N;i++){
		mp[D[i]]++;
	}
	
	if(mp[0]>=2){
		cout<<0<<endl;
		return 0;
	}
	if(mp[12]>=2){
		cout<<0<<endl;
		return 0;
	}
	
	vector<int> A;
	for(int i=0;i<=12;i++){
		if(mp[i]>=3){
			cout<<0<<endl;
			return 0;
		}
		for(int j=0;j<mp[i];j++){
			A.push_back(i);
		}
	}
	if(A.size()>=13){
		cout<<1<<endl;
		return 0;
	}
	int ans = 0;
	for(int i=0;i<(1<<A.size());i++){
		vector<int> B(A.size());
		for(int j=0;j<A.size();j++){
			if((i>>j)&1){
				B[j] = A[j];
			}
			else{
				B[j] = 24-A[j];
			}
		}
		sort(B.begin(),B.end());
		int k = 99;
		for(int j=0;j<B.size();j++){
			if(j==0){
				k = min(k,24-B[B.size()-1]);
			}
			else{
				k = min(k,B[j]-B[j-1]);
			}
		}
		ans = max(k,ans);
	}
	
	cout<<ans<<endl;
	
	
	
	
	return 0;
}


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

int main()
{
	string S;
	int i, n = 0, sub[2];
	cin >> S;
	sub[0] = 0;
	sub[1] = 0;
	for (i = 0; i < (S.length()); i++) {
		n += 1;
		if (n % 2 == 0) {
			if (S[i] == '1')
				sub[0] += 1;
			if (S[i] == '0')
				sub[1] += 1;
		}
		else if (n % 2 == 1) {
			if (S[i] == '0')
				sub[0] += 1;
			if (S[i] == '1')
				sub[1] += 1;
		}
	}
		if (sub[0] > sub[1])
			cout << sub[1];
		else
			cout << sub[0];
	return 0;
}

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

int main()
{
//	ifstream cin("input.txt");
	int A[100][2];
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			cin >> A[i][j];
		}
	}
	int con = 0;
	for (int i = 0; i < n; i++)
	{
		if (A[i][0] == A[i][1])
		{
			//cout << A[i][0] << endl;
			con++;
			if (con == 3)
			{
				cout << "Yes" << endl;
				exit(0);
			}
		}
		else
		{
			con = 0;
		}
	}
	cout << "No" << endl;

	return 0;
}


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

int main(){
  int N;
  cin >> N;
  if(N == 1){
    cout << "0" << endl;
    return 0;
  }
  map<int, int> m;
  for(int i = 2; i <= N ; i++){
    int n = i;
    for(int j = 2; j <= i; j++){
      while(!(n % j)){
        m[j]++;
        n /= j;
      }
    }
  }
  int l = 0, k = 0, s = 0, t = 0, r = 0;
  for(auto x : m){
    if(x.second >= 2) l++;
    if(x.second >= 4) k++;
    if(x.second >= 14) s++;
    if(x.second >= 24) t++;
    if(x.second >= 74) r++;
  }
  int ans = (l-k)*k*(k-1)/2 + k*(k-1)*(k-2)/2 + (k-s)*s + s*(s-1) + (l-t)*t + t*(t-1) + r;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll n;
	cin >> n;
	ll a[n], ma[n];
	for (ll i = 0; i < n; i++) cin >> a[i];
	fill(ma, ma + n, 1000);
	for (ll i = 0; i < n; i++){
		if (i > 0) ma[i] = max(ma[i], ma[i - 1]);
		for (ll j = i; j < n; j++){
			for (ll k = j + 1; k < n; k++){
				ma[k] = max(ma[k], ma[i] / a[j] * a[k] + ma[i] % a[j]);
			}
		}
	}
	printf("%lld\n", ma[n - 1]);
}

Measured memory_bytes: 3656
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define ll           long long
#define all(v)       (v).begin() , (v).end()
#define vi           vector <ll>
#define vii          vector <pair<ll,ll>>
#define ii           pair<ll,ll>
#define sz(v)	     ((int)((v).size()))
#define lp(i,a,b)    for(int i=a;i<b;i++)
#define pb           push_back
#define pf           push_front
#define F            first
#define S            second
#define endl         "\n"
#define IOS          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const double PI = 3.14159265358979323846;
const ll inf=1e18,MOD=1e9+7,MAX=1e5+2;




int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    IOS
    int n;
    cin>>n;
    ll a[n];
    ll sum=1000,cnt=0;
    lp(i,0,n)
        cin>>a[i];
    lp(i,1,n){
        if(a[i]>a[i-1]){
            ll x=sum/a[i-1];
            sum-=a[i-1]*x;
            cnt+=x;
            sum+=cnt*a[i];
            cnt=0;
        }
    }
    cout<<sum;
}

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

void print_list(int a[], int n) {
  cout << a[0];
  for (int i = 1; i < n; ++i) {
    cout << ' ' << a[i];
  }
  cout << endl;
}

int main() {
  ios::sync_with_stdio(false);
  int n, key;
  cin >> n;
  int a[105];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  print_list(a, n);
  for (int i = 1; i < n; ++i) {
    key = a[i];
    int j = i - 1;
    while (j >= 0 && a[j] > key) {
      a[j+1] = a[j];
      --j;
    }
    a[j+1] = key;
    print_list(a, n);
  }
  return 0;
}


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

int main() {
int N;
cin>>N;
string S;
cin >> S;
bool a=true;
if(S.size()%2==1){
cout << "No" << endl;}
else {
for(int i=0;i<N/2;i++){
if(S.at(i)==S.at(N/2+i)){
a =true;}else{a=false;break;}
}
if(a){cout << "Yes" <<endl;}
else{cout << "No" << endl;
}


}
}

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

int main(){
  int A,B;
  int a,b;
  cin>>A>>B;
  if(A<B){
    a = A;
    b = B;
    B = a,A = b;
  }
  if(B==1){
    if(A==2){
      cout<<3<<endl;
    }
    else{
      cout<<2<<endl;
    }
  }
  else{
    cout<<1<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;}
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 const INF = 1001001001;


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

ll n;
cin >> n;
ll res = 0;
rrep(i,n) {
    res += i*(n-i+1);
}
rep(i,n-1) {
    ll u,v;
    cin >> u >> v;
    if(v < u) swap(u,v);
    res -= u*(n-v+1);
}
cout << res << endl;
return 0;
}

Measured memory_bytes: 3624
N = int(input())
a = list(map(int, input().split()))

d = dict()
d[0] = 1

res = 0
t = 0
for i in range(N):
    t += a[i]

    s = d.get(t, 0)
    res += s
    d[t] = s + 1

print(res)


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

int main(){
  long long int n,ans;
  cin >> n;
  ans = 0;
  for(long long int i=1;i<=n;i++){
    if(i%3 != 0 and i%5 != 0){
      ans += i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3620
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define fr(i,x,n) for(int i=x;i<=n;i++)
#define rf(i,n,x) for(int i=n;i>=x;i--)
#define mst(x,i) memset(x,i,sizeof(x))
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define PB push_back
#define X first
#define Y second
using namespace std;
typedef long long LL;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int maxn=1E5+5;
const int maxm=1E5+5;
const int inf=0x3f3f3f3f;
const LL INF=0x3f3f3f3f3f3f3f3f;
const LL mod=1E9+7;
const double eps=1E-6;
const double PI=acos(-1.0);
template<class T>
bool scan(T &ret){
    char c;int sgn;
    if(c=getchar(),c==EOF) return 0;
    while(c!='-'&&(c<'0'||c>'9')) c=getchar();
    sgn=(c=='-')?-1:1;
    ret=(c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
    ret*=sgn;
    return 1;
}
template<class T>
T gcd(T a,T b){
    return b==0?a:gcd(b,a%b);
}
template<class T>
T qpow(T a,T b,T mod){
    T ret=1;
    a%=mod;
    while(b){
        if(b&1) ret=(a*ret)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return ret%mod;
}
void solve(){
    LL n;cin>>n;
    LL ans=(n-1)*n/2;
    cout<<ans<<endl;
}
int main(){
#ifdef LOCAL
    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif
    IOS;
    int T=1;
    //cin>>T;
    while(T--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
from itertools import groupby

N, K = [int(i) for i in input().split()]
S = input()

A = [(k, len(tuple(v))) for k, v in groupby(S)]
M = len(A)

ans, count = 0, 0
l, r = 0, 0
while l < M:
    bound = 2 * K + int(A[l][0] == '1')
    while r < M and r - l < bound:
        count += A[r][1]
        r += 1
    ans = max(ans, count)
    count -= A[l][1]
    l += 1

print(ans)

Measured memory_bytes: 10484
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def read_a_int(): return int(read())


def read_ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

print(input()[:3])


Measured memory_bytes: 65240
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int A, B, C;
    cin >> A >> B >> C;
    
    int sum = A;
    bool flag;
    int amari_box[B];
    int count = 0;
    
    while(true){
        int amari = sum % B;
        for(int i = 0; i < count; i++){
            if(amari == amari_box[i]){
                flag = false;
                goto LABEL;
            }
        }
        amari_box[count] = amari;
        if(amari == C){
            flag = true;
            break;
        }
        sum += A;
        count++;
    }
    
LABEL:
    if(flag)cout << "YES" << endl;
    else cout << "NO" << endl;
}


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

int main(){
    int N,K,R,S,P;
    string T;
    cin >> N >> K >> R >> S >> P;
    cin >> T;
    // 勝てるところで勝てばよい
    vector<char> Hand(N);
    ll ans = 0;
    rep(i,N){
        if(T[i]=='r'){
            if(i>=K){
                if(Hand[i-K]!='p'){
                    ans+=P;
                    Hand[i]='p';
                }else{
                    Hand[i]='X';
                }
            }else{
                ans+=P;
                Hand[i]='p';
            }
        }else if(T[i]=='s'){
            if(i>=K){
                if(Hand[i-K]!='r'){
                    ans+=R;
                    Hand[i]='r';
                }else{
                    Hand[i]='X';
                }
            }else{
                ans+=R;
                Hand[i]='r';
            }
        }else{
            if(i>=K){
                if(Hand[i-K]!='s'){
                    ans+=S;
                    Hand[i]='s';
                }else{
                    Hand[i]='X';
                }
            }else{
                ans+=S;
                Hand[i]='s';
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define ld long double
using namespace std;
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;


int main(){
	fast;
	ll n, ans = 0;
	cin >> n;
	ll k = 0, mod = n;
	for(int i = 0; i < 1e6; ++i){
		k = ((k*10)+7)%mod;
		++ans;
		if(k == 0)
			break;
	}
	if(ans == 1e6) cout << "-1";
	else cout << ans;
	return 0;
}


Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main()
{
    long n, m; cin >> n >> m;
    long ans = 0;

    if (m > n * 2) {
        m -= n * 2;
        ans += n;
    } else {
        ans += m / 2;
        m = 0;
    }
    ans += m / 4;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
    int N,A; //合計N円，1円硬貨A枚
    cin >> N >> A;
    
    if(N % 500 <= A){
        cout << "Yes" << endl;   
    } else{
        cout << "No" << endl;   
    }
    
    return 0;
}

Measured memory_bytes: 3492
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n; cin >> n;
	vector<string> s(n);
	REP(i,n) cin >> s[i];
	sort(ALL(s));
	int ans=1;
	REP(i,n-1){
		if(s[i]!=s[i+1])
			ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 9544
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long A,B,K;
  cin>>A>>B>>K;
  if(K>=A+B){
    cout<<0<<" "<<0<<endl;
  }
  else if(K>=A){
    cout<<0<<" "<<A+B-K<<endl;
  }
  else{
    cout<<A-K<<" "<<B<<endl;
  }
}

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

int main() {
  int n,k;
  cin >> n>> k;
  ll sum=1;
  rep(i,n-1){
    sum *= k-1;
  }
  cout << k*sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
using namespace std;
#define MAX 51
typedef pair<double,double> P;

int main(){
  int n,t = 1;

  while(cin >> n,n){
    vector<P> v;
    double ans = 0, x ,y;
    for(int i = 0 ; i < n ; i++){
      cin >> x >> y;
      v.push_back(P(x,y));
    }  
    for(int i = 1; i < n+1 ; i++){
      ans += (v[i%n].first-v[i-1].first)*(v[i%n].second+v[i-1].second);
    }
    ans /= 2.0;
    printf("%d %.1f\n" ,t++ ,abs(ans));
  }

  return 0;
}

Measured memory_bytes: 1248
import java.util.*;

public class Main {
	
	static int gcd(int x, int y) {
		if(x < y) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		while(y > 0) {
			int r = x % y;
			x = y;
			y = r;
		}
		return x;
	}
	
	static int bipartiteMatching(boolean[][] can) {
		// 0..m-1 blue
		// m..m+n-1 red
		int m = can.length; // number of blue
		int n = can[0].length; // number of red
		int s = n + m, t = s+1;
		initGraph(m+n+2);
		// s to blue
		for(int i=0; i<m; i++) {
			addEdge(s, i, 1);
		}
		// red to t
		for(int i=0; i<n; i++) {
			addEdge(m+i, t, 1);
		}
		// blue to red
		for(int i=0; i<m; i++) {
			for(int j=0; j<n; j++) {
				if(can[i][j]) {
					addEdge(i, m+j, 1);
				}
			}
		}
		return maxFlow(s, t);
	}
	
	// from MaxFlowFordFulkerson.java
	static int MAX_V = 2000;
	static int INF = 10000000;
	static ArrayList<ArrayList<Edge>> G = new ArrayList<ArrayList<Edge>>(MAX_V);
	static boolean[] used = new boolean[MAX_V];
	
	static void addEdge(int from, int to, int cap) {
		G.get(from).add(new Edge(to, cap, G.get(to).size()));
		G.get(to).add(new Edge(from, 0, G.get(from).size()-1));
	}
	
	static int dfs(int v, int t, int f) {
		if(v==t) return f;
		used[v] = true;
		for(int i=0; i<G.get(v).size(); i++) {
			Edge e = G.get(v).get(i);
			if(!used[e.to] && e.cap > 0) {
				int d = dfs(e.to, t, Math.min(f, e.cap));
				if(d>0) {
					e.cap -= d;
					G.get(e.to).get(e.rev).cap += d;
					return d;
				}
			}
		}
		return 0;
	}
	
	static int maxFlow(int s, int t) {
		int flow = 0;
		for(;;) {
			Arrays.fill(used, false);
			int f = dfs(s, t, INF);
			if(f==0) return flow;
			flow += f;
		}
	}
	
	static void initGraph(int maxV) {
		for(int i=0; i<maxV; i++) {
			G.add(new ArrayList<Edge>());
		}
	}
	
	static void resetGraph() {
		G = new ArrayList<ArrayList<Edge>>(MAX_V);
		used = new boolean[MAX_V];
	}
	
	static class Edge {
		int to, cap, rev;
		Edge(int to, int cap, int rev) {
			this.to = to; this.cap = cap; this.rev = rev;
		}
	}
	
	static public void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		int n = sc.nextInt();
		String ans = "";
		int cnt = 0;
		while(!(n==0 && m==0)) {
			boolean[][] can = new boolean[m][n];
			int[] b = new int[m];
			int[] r = new int[n];
			for(int i=0; i<m; i++) b[i] = sc.nextInt();
			for(int i=0; i<n; i++) r[i] = sc.nextInt();
			for(int i=0; i<m; i++) {
				for(int j=0; j<n; j++) {
					if(gcd(b[i], r[j]) > 1) can[i][j] = true;
					else can[i][j] = false;
				}
			}
			ans += (bipartiteMatching(can)) + "\n";
			resetGraph();
			m = sc.nextInt(); n = sc.nextInt(); cnt++;
		}
		System.out.print(ans);
	}
}



Measured memory_bytes: 78940
import bisect
n=1000000
p=[1]*(n+1)
p[0],p[1]=0,0
for i in range(2,int(n**0.5)+1):
    if p[i]:        
        for j in range(i*i,n+1,i):
            p[j]=0
p=[i for i in range(n+1) if p[i]==1]
while 1:
    n=int(input())
    ans=-n
    if n==0:break
    while n:
        n-=1
        a,m=map(int,input().split())
        ans+=bisect.bisect_left(p,a+m+1)-bisect.bisect_left(p,a-m)
    print(ans)

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

int a[2010], b[2010][2010];
signed main(void)
{
  int n, x;
  cin >> n >> x;
  REP(i, n) {
    cin >> a[i];
  }

  REP(i, n) REP(j, n) b[i][j] = INF;
  REP(i, n) b[0][i] = a[i];

  FOR(i, 1, n) {
    REP(j, n) {
      int tmp = j-i;
      if(tmp < 0) tmp = (tmp+n)%n;
      b[i][j] = min(b[i-1][j], a[tmp]);
    }
  }

  ll ret = (ll)INF*INF;
  REP(i, n) {
    int tmp = 0;
    REP(j, n) {
      tmp += b[i][j];
    }
    tmp += i*x;
    //cout << tmp << endl;
    ret = min(ret, tmp);
  }

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


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

int main(){
  int n,i;
  cin >> n;
  vector<int> a(n);
  for(i=0;i<n;++i){
    cin >> a[i];
  }
  int ans=0;
  for(i=0;i<n;++i){
    while(i+1<n && a[i]==a[i+1]) i++;


    if(i+1<n && a[i]<a[i+1]){
      while(i+1<n && a[i]<=a[i+1]){
        i++;
      }
    }else if(i+1<n && a[i]>a[i+1]){
      while(i+1<n && a[i]>=a[i+1]){
        i++;
      }
    }
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
/*---------------Go Code GO---------------*/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

template<typename T>
using Order_Set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;
//(order) Set.order_of_key(); (pointer) Set.find_by_order();

#define     PI              acos(-1.0)
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define     precision(a)    fixed<<setprecision(a)
#define     endl            '\n'
#define     Flush           cout<<flush
#define     LLMX            0x3fffffffffffffff




int main()
{
    long long i,j,k,l,tst=0,ans=0, csno=0, N,M;
    cin>>N>>M;
    k = N+M;
    k = k*(k-1);
    k/=2;
    k-=N*M;
    cout<<k<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    string s; cin >> s;
    vector<pair<char, int>> v;
    v.push_back(make_pair(s.front(), 1));
    for(int i = 1; i < n; i++)
    {
        if(s[i] == v.back().first)
        {
            v.back().second++;
        }
        else
        {
            v.push_back(make_pair(s[i], 1));
        }
    }
    //for(auto x : v) cout << x.first << " " << x.second << endl;
    int pos = 1;
    while(k > 0)
    {
        if(pos >= v.size()) break;
        v[pos].first = v.front().first;
        pos += 2;
        k--;
    }
    vector<pair<char, int>> target;
    target.push_back(v.front());
    for(int i = 1; i < v.size(); i++)
    {
        if(v[i].first == target.back().first)
        {
            target.back().second += v[i].second;
        }
        else
        {
            target.push_back(v[i]);
        }
    }
    int ans = 0;
    //cout << endl;
    //for(auto x : target) cout << x.first << " " << x.second << endl;
    for(int i = 0; i < target.size(); i++)
    {
        ans += target[i].second - 1;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 2628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
static const int INFTY = (1 << 30);
int X, N;
void func()
{
    cin >> X >> N;
    int min(INFTY), ans;
    bool p[102] = {};
    rep(i, 0, N)
    {
        int tmp;
        cin >> tmp;
        p[tmp] = true;
    }
    rep(i, 0, 102)
    {
        if (p[i] == false)
        {
            if (abs(i - X) < min)
            {
                min = abs(i - X);
                ans = i;
            }
        }
    }
    cout << ans << endl;
}
int main()
{
    func();
}

Measured memory_bytes: 3628
n, k = map(int, input().split())
a = list(map(int, input().split()))

dp = [0] * (k + 1)  #-1=lose,1=win

for i in range(k + 1):
    list = [j for j in a if i >= j]
    if any(dp[i - j] == -1  for j in list):
        dp[i] = 1
    else:
        dp[i] = -1
print('First' if dp[k] == 1 else 'Second')

Measured memory_bytes: 44892
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define ll long long
#define mod (1000000007)
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
const ll inf = 1e9;

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

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

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    rep1(i, k)r = r * n-- / i;
    return r;
}

struct UnionFind {
    vector<ll> par;

    UnionFind(ll N) : par(N) {
        rep0(i, N) par[i] = i;
    }

    ll root(ll x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main(){
    int n,a;
    bool f = true;
    cin >> n;
    rep0(i, n){
        cin >> a;
        if(a % 2 == 0 && a % 3 != 0 && a % 5 != 0)f = false;
    }
    if(f)pf("APPROVED");
    else pf("DENIED");
    return 0;
}


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

int GCD(int m, int n)
{
	if (n == 0)return m;
	return GCD(n, m % n);
}

int main()
{
	int a, b, c, lcm, n, res = -1;
	cin >> a >> b >> c;
	lcm = 60*(a+b)/GCD(60,a+b);
	n = lcm*c/GCD(lcm,c);
	for (int i = 0; i < n; i++) {
		if ((c + 60 * i) % (a + b) >= 0 && (c + 60 * i) % (a + b) <= a) {
			res = c + 60 * i;
			break;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1164
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const pi = math.Pi

var A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z int
var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans int

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	A, _ := strconv.Atoi(read())
	B, _ := strconv.Atoi(read())

	fmt.Println(min(A*N, B))
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i] > a[j] }

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
using Graph = vector<vector<int>>;
using Graph_Wei = vector<vector<pair<int,int>>>;
using ll = long long;
const long long INF = 1LL<<60; // 仮想的な無限大の値
vector<bool> seen;

Graph G;

const int num = 3;
int main() {
    
    int c[num][num];
    //入力行列
    for(int i=0;i<num;i++){
        for(int j=0;j < num;j++){
            cin >> c[i][j];
        }
    }

    int a[3];
    int b[3];
    //a,b作成
    a[0] = 0;
    for(int i=0;i < num;i++) b[i] = c[0][i];
    a[1] = c[1][0] - b[0];
    a[2] = c[2][0] - b[0];

    bool good = true;
    //check
    for(int i=0;i< num;i++){
        for(int j=0;j < num;j++){
            if(c[i][j] == a[i] + b[j]);
            else{
                good = false;
                break;
            }

        }
        if(!good) break;
    }
    if(good) cout << "Yes" << endl;
    else cout << "No" << endl;
    


    return 0;

}

Measured memory_bytes: 256
def main():
    N,M=map(int,input().split())
    s=[0]*M
    for i in range(M):
        li=list(map(int,input().split()))
        s[i]=set(li[1:])
    p=list(map(int,input().split()))
    

    count=0
    for i in range(1<<N):
        flag=True
        output=set()
        for j in range(N):
            if(i>>j)&1:
                output.add(j+1)
        for j in range(M):
            if len(output&s[j])%2!=p[j]:
                flag=False
            if flag==False:
                break
        if flag:
            count+=1
    
    print(count)

if __name__=="__main__":
    main()

Measured memory_bytes: 3064