akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();

		System.out.print("ABC"+ N);
	}

}


Measured memory_bytes: 21716
def resolve():
    N, K, Q = map(int, input().split())
    A = [K-Q]*N
    for _ in range(Q):
        a = int(input())
        A[a-1] += 1
    for i in range(N):
        if A[i] > 0:
            print("Yes")
        else:
            print("No")
resolve()

Measured memory_bytes: 6740
#include <iostream>
#include <string.h>
#include <assert.h>
#include <vector>
#include <stdio.h>
#include <set>
using namespace std;

typedef long long LL;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef float fl;
typedef double ld;
typedef long double LD;
typedef pair<int,int> pii;
#define lld "%lld"
#define ui(n) ((unsigned int)(n))
#define LL(n) ((long long)(n))
#define ull(n) ((unsigned long long)(n))
#define fl(n) ((float)(n))
#define ld(n) ((double)(n))
#define LD(n) ((long double)(n))
#define char(n) ((char)(n))
#define Bool(n) ((bool)(n))
#define fixpoint(n) fixed<<setprecision(n)

const int INF=1061109567;
const LL LINF=4557430888798830399;
const ld eps=1e-15;
#define MOD (1000000007)
#define PI (3.1415926535897932384626433832795028841971)

#define MP make_pair
#define MT make_tuple
#define All(a) (a).begin(),(a).end()
#define pall(a) (a).rbegin(),(a).rend()
#define log2(x) log(x)/log(2)
#define Log(x,y) log(x)/log(y)
#define sz(a) ((int)(a).size())
#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 repa(i,a,n) for(int i=((int)(a));i<((int)(n));i++)
#define repa1(i,a,n) for(int i=((int)(a));i<=((int)(n));i++)
#define repd(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define repd1(i,n) for(int i=((int)(n));i>=1;i--)
#define repda(i,n,a) for(int i=((int)(n));i>((int)(a));i--)
#define repda1(i,n,a) for(int i=((int)(n));i>=((int)(a));i--)
#define FOR(i,a,n,step) for(int i=((int)(a));i<((int)(n));i+=((int)(step)))
#define repv(itr,v) for(__typeof((v).begin()) itr=(v).begin();itr!=(v).end();itr++)
#define repV(i,v) for(auto i:v)
#define repE(i,v) for(auto &i:v)
#define MS(x,y) memset(x,y,sizeof(x))
#define MC(x) MS(x,0)
#define MINF(x) MS(x,63)
#define SF scanf
#define PF printf
/************************************************************Begin************************************************************/
const int maxn=45;

int n,m,c[maxn],dist[maxn];
vector<int> e[maxn];
set<LL> vis[maxn];

inline int calc(LL cho)
{
	int res=0;
	rep1(i,n) if(cho&(1LL<<i)) res+=c[i];
	return res;
}

inline void dfs(int x,LL cho)
{
	vis[x].insert(cho);

	rep(_i,e[x].size())
	{
		int i=e[x][_i];

		LL ccho=cho;

		rep(_j,e[i].size())
		{
			int j=e[i][_j];
			ccho|=(1LL<<j);
		}
		ccho|=(1LL<<i);

		int cres=calc(ccho);
		if(cres<=dist[i])
		{
			dist[i]=cres;
			if(vis[i].find(ccho)==vis[i].end()) dfs(i,ccho);
		}
	}
}

int main()
{
	SF("%d%d",&n,&m);
	rep1(i,n) SF("%d",&c[i]);
	rep(i,m)
	{
		int a,b;SF("%d%d",&a,&b);
		e[a].push_back(b);
		e[b].push_back(a);
	}

	MINF(dist);
	dist[0]=0;

	e[0].push_back(1);
	dfs(0,0);

	PF("%d\n",dist[n]);

	return 0;
}
/*************************************************************End**************************************************************/


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    string s;cin>>s;
    int cnt=0,ans=0;
    rep(i,s.size()){
        if(s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G'){
            cnt++;
        }
        else{
            ans=max(ans,cnt);
            cnt=0;
        }
    }
    ans=max(ans,cnt);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int W,H,x,y,r;
  scanf("%d %d %d %d %d\n",&W,&H,&x,&y,&r);

if ((x+r)<=W && 0<=(x-r)) 
{
    if ((y+r)<=H && 0<=(y-r)) 
    {
      printf("Yes\n");
    }

    else
    {
        printf("No\n" );
    }

}

else
  {
    printf("No\n" );
  }
 
  
  return 0;
}


Measured memory_bytes: 2128
import java.util.*;
class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int man = 0;
        int ret = 0;
        for(int i =0 ; i < n ; i++){
            man = sc.nextInt();
            if(man >= k ){
                ret++;
            }
        }
        System.out.println(ret);
        sc.close();
    }
}


Measured memory_bytes: 48476
#include <bits/stdc++.h>
using namespace std;
int n,i;
int v[56]={11,31,41,61,71,101,131,151,181,191,211,241,251,271,281,311,331,401,421,431,461,491,521,541,571,601,631,641,661,691,701,751,761,811,821,881,911,941,971,991,1021,1031,1051,1061,1091,1151,1171,1181,1201,1231,1291,1301,1321,1361,1381,1451};
int main()
{
    cin>>n;
    for(i=0;i<n;++i)
        cout<<v[i]<<" ";
    return 0;
}


Measured memory_bytes: 256
import math
a,b,h,m = map(int,input().split())
x_h = a * math.sin(math.radians(0.5 * (60 * h + m)))
y_h = a * math.cos(math.radians(0.5 * (60 * h + m)))
x_m = b * math.sin(math.radians(6 * m))
y_m = b * math.cos(math.radians(6 * m))

print(math.sqrt((x_h-x_m)**2 + (y_h-y_m)**2))

Measured memory_bytes: 9516
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scan = new Scanner(System.in);
        
        int suri = scan.nextInt();
        int miseA = scan.nextInt();
        int miseB = scan.nextInt();
        
        int ans1 = miseA - suri;
        int ans2 = miseB - suri;
        
        if (ans1 < 0){
            ans1 = ans1 * -1;
        }
        
        if (ans2 < 0){
            ans2 = ans2 * -1;
        }
        
        if (ans1 > ans2){
            System.out.println("B");
        }else{
            System.out.println("A");
        }
        
    }
}

Measured memory_bytes: 22868
import java.io.*;
import java.util.Arrays;

class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in),1);
		int[] arrays = new int[10];
		String str = br.readLine();
		for (int i = 0; i < arrays.length; i++) {
			arrays[i] = Integer.parseInt(str);
			str = br.readLine();
		}
		Arrays.sort(arrays);
		for (int i = 1; i <= 3; i++) {
			System.out.println(arrays[arrays.length - i]);
		}
	}
		
}

Measured memory_bytes: 24084
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    int a, b, c; cin >> a >> b >> c;
    if (a != b && a != c && b != c) {
        cout << "No" << endl;
    }else if (a == b && a != c) {
        cout << "Yes" << endl;
    } else if (a == c && a != b) {
        cout << "Yes" << endl;
    } else if (b == c && b != a) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("trapv")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
const ll mod = 7 * 17 * (1 << 23) + 1;
const ll inf = 1e18;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int get(int x) {
	string s = to_string(x);
	x = 0;
	for(auto i : s) x+=i-'0';
	return x;
}
int main() { //DINIC ORZ
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin >> n;
	int ans = 10000;
	for(int a = 1; a<n; a++)
		ans = min(get(a)+get(n-a), ans);
	cout << ans;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        int n = in.nextInt();
        HashMap<String, HashMap<Integer, Integer>> map = new HashMap<>();
        for(int i=0;i<n;i++){
            String s = in.next();
            int point = in.nextInt();
            if(!map.containsKey(s)){
                map.put(s, new HashMap<>());
            }
            map.get(s).put(point,i+1);
        }
        Object str[] = map.keySet().toArray();
        Arrays.sort(str);
        for(Object s:str){
            Object score[] = map.get(s).keySet().toArray();
            Arrays.sort(score);
            for(int i=score.length-1;i>=0;i--){
                out.println(map.get(s).get(score[i]));
            }
        }
    }
    
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 21204
using System;
class Program {
    static void Main(string[] args){
        string input = Console.ReadLine();
        int n1 = int.Parse(input.Substring(0, 2));
        int n2 = int.Parse(input.Substring(2));
        bool b1 = n1 >= 1 && n1 <= 12;
        bool b2 = n2 >= 1 && n2 <= 12;
        if(b1 && b2) Console.WriteLine("AMBIGUOUS");
        else if(b1) Console.WriteLine("MMYY");
        else if(b2) Console.WriteLine("YYMM");
        else Console.WriteLine("NA");
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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;}


int main() {
    int a,b;
    cin >> a >> b;
    if(a > b) swap(a,b);
    if(a==1 && b == 2) {
        cout << 3 << endl;
    } else if(a == 1 && b == 3) {
        cout << 2 << endl;
    } else if(a==2 && b == 3) {
        cout << 1 << endl;
    } 
}

Measured memory_bytes: 3616
/*https://atcoder.jp/contests/abc171/tasks/abc171_b*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int a,sum=0;
	vector <int> v;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		v.push_back(a);
	}	
	sort(v.begin(),v.end());
	for(int i=0;i<k;i++)
		sum+=v[i];
	cout<<sum;
}

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

int main() {
  int64_t N, K, s = 0;
  cin >> N >> K;
  for(int i=K;i<=N+1;i++)
    s += (i*(N-i+1)+1);
  cout << s%1000000007 << endl;
}

Measured memory_bytes: 3636
#include <iterator>
#include <iostream>
#include <random>
#include<vector>
#include<algorithm>

using namespace std;


int main() {
	string S;
	cin >> S;
	if (S[2] == S[3] && S[4] == S[5])
		cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#define f first
#define s second
#define loop(a,b) for(int i=a;i<b;i++)
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define ll long long
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define loop2(a,b) for(int j=a;j<b;j++)
#define str_in cin.ignore(numeric_limits<streamsize>::max(), '\n')
#define sz(a) int(a.size())
#define displaymatrix(a,m,n) for(int i=0;i<m;i++)\
{for(int j=0;j<n;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define printarray(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}nl;
#define vinput(a,n) vl a(n);loop(0,n)cin>>a[i]
#define ainput(a,n) loop(0,n)cin>>a[i]

//#define all(c) c.begin(),c.end()
#define tr(container,it)\
for(__typeof(container.begin()) it=container.begin();it!=container.end();it++)
#include<bits/stdc++.h>

using namespace std;
int visited[200005];
int parent[200005];
queue<int> bfsq;

const int mod=1e+9+7;

void bfs(vvi& g, int node){
    bfsq.push(node);
    visited[node] = 1;
    while(sz(bfsq) > 0){
        int q = bfsq.front();
        bfsq.pop();
        for (auto x:g[q]){
            if (visited[x]) continue;
//            cout << q << " " << x << " ";
            bfsq.push(x);
            visited[x] = 1;
            parent[x] = q;
        }
//        printf("\n");
    }
}

void solve(){
    int n,m;cin>>n>>m;
    memset(visited,0,n);
    memset(parent,-1,n);
    vi a;
    vvi g = vvi(n,a);
    loop(0,m){
        int e1,e2;cin>>e1>>e2;
        g[e1-1].pb(e2-1);g[e2-1].pb(e1-1);
    }
    bfs(g,0);
    cout << "Yes\n";
    loop(1,n) cout << parent[i]+1 << "\n";
//    printf("\n");
}

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



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

ll a, b, h, m;

int main() {
	cin>>a>>b>>h>>m;
	double mins=m*2*M_PI;
	mins/=60;
	double hour=h*2*M_PI;
	hour/=12;
	double add=m*M_PI;
	add/=360;
	hour+=add;
	double x;
	if (hour>mins) x=hour-mins;
	else x=mins-hour;
	double ans=a*a+b*b-2*a*b*cos(x);
	cout<<fixed<<setprecision(20)<<sqrt(ans)<<endl;
}



Measured memory_bytes: 4228
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 1000011

int n, i, sum, ans;
char s[maxN];

int main()
{
  //  freopen("test.in","r",stdin);

    scanf("%s", s + 1);
    n = strlen(s + 1);

    for (i = 1; i <= n; i++) {
        if (s[i] == 0) continue;
        ans = max(ans, sum + (s[i] - '0' - 1) + 9 * (n - i));
        sum += s[i] - '0';
    }

    ans = max(ans, sum);
    cout << ans;


    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

const ll INF = 1e15;
const double eps = 1e-6;
const ll MOD = 1000000007;

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

int main() {
	ll N;
	cin >> N;
	vector<ll> a(N);
	ll sum = 0;
	for (int i = 0;i < N;i++) {
		cin >> a[i];
		sum -= a[i];
	}
	vector<ll> b(N);
	for (int i = 0;i < N;i++) {
		cin >> b[i];
		sum += b[i];
	}
	ll minia = 0;
	ll minib = 0;
	for (int i = 0;i < N;i++) {
		minia += max((ll)0, (b[i] - a[i] + 1) / 2);
		minib += max({ (ll)0, a[i] - b[i] , (ll)(a[i] % 2 != b[i] % 2)});
	}
	if (sum >= 0 && minia <= sum && minib <= sum)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 384
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-8;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

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

    int n, k;
    cin >> n >> k;

    string s;
    cin >> s;
    s.insert(s.begin(), 'R');
    s.push_back('L');

    int ans = 0;
    reps(i, n){
        if(s[i] == 'L' && s[i - 1] == 'L' || s[i] == 'R' && s[i + 1] == 'R'){
            ++ans;
        }
    }

    int cnt = 0;
    reps(i, n - 1){
        if(s[i] == 'R' && s[i + 1] == 'L'){
            ++cnt;
        }
    }

    ans += min(cnt, k) * 2;
    k -= cnt;

    if(k > 0 && s[1] == 'L'){
        ++ans;
        --k;
    }
    if(k > 0 && s[n] == 'R'){
        ++ans;
    }

    chmin(ans, n - 1);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define re return
#define pb push_back
#define po pop_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define ss second.second
#define sf second.first
#define ff first.first
#define fs first.second
#define si size
#define sqrt(x) sqrt(abs(x))
#define mp make_pair
#define pi 3.14159265359
#define er erase
#define in insert
#define em empty
#define ft front
#define fo(i,n) for(i = 0; i < n; i++)
#define ro(i,n) for(i = n - 1; i >= 0; i--)
#define fr(i,j,n) for(i = j; i < n; i++)
#define rf(i,j,n) for(i=n-1;i>=j;i--)
typedef std::vector<int> vi;
typedef std::vector<vi> vvi;
typedef std::pair<int,int> ii;
typedef std::vector<ii> vii;
typedef std::vector<std::string> vs;
typedef double dl;
typedef long double ld;
typedef long long ll;
typedef std::pair<ll, ll> pll;
typedef std::vector<ll> vll;
#define filename ""
using namespace std;
    int a[100],b[100];
int main()
{
    /*
	freopen(filename".in","r",stdin);
	freopen(filename".out","w",stdout);
	*/
	/*
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    */
    int n,i,o=0;
    cin>>n;
    fo(i,n)
    {
        scanf("%d",&a[i]);
        if (i) a[i]+=a[i-1];
    }
    fo(i,n)
    {
        scanf("%d",&b[i]);
    }
    ro(i,n-1)
    {
        b[i]+=b[i+1];
    }
    fo(i,n)
    {
        o=max(o,a[i]+b[i]);
    }
    cout<<o<<'\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
struct Node{
	int x,type;
	bool operator < (const Node &b)const{
		return x>b.x;
	}
}a[N*3]; 
int main(){
	int x,y,z=0,A,b,c,si=0;scanf("%d%d%d%d%d",&x,&y,&A,&b,&c);
	for(int i=0;i<A;i++)scanf("%d",&a[si].x),a[si++].type=1;
	for(int i=0;i<b;i++)scanf("%d",&a[si].x),a[si++].type=2;
	for(int i=0;i<c;i++)scanf("%d",&a[si++].x);
	sort(a,a+si);
	long long ans=0;
	for(int i=0;i<si;i++){
		 if(a[i].type==1&&x)x--,ans+=a[i].x;
		 else if(a[i].type==2&&y)y--,ans+=a[i].x;
		 else if(a[i].type==0&&x+y+z>0)z--,ans+=a[i].x;
		 if(x+y+z==0)break;
	}
	printf("%lld",ans);
	return 0;
}

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

int main() {
  map<string,int> m;
  int n;
  cin >> n;
  for(int i=0; i<n;i++){
    string s;
    cin >> s;
    m[s]++;
    }
  int ma=-1;
  for(auto q: m){
    ma = max(ma, q.second);
    }
  for(auto q: m) {
    if(q.second==ma)
      cout << q.first << "\n";
    }
  
return 0;
  
}


Measured memory_bytes: 25216
#include <stdio.h>

#define N 100

void trace(int A[], int n){
  int i;
  for (i=0;i < n;i++){
    if (i > 0) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

void swap(int *a,int *b){
  int temp;
  temp = *a;
  *a = *b;
  *b = temp;
}

int main(){
  int A[N];
  int n=0;
  int i,j;
  int count=0;
  int mini=0;
  int c;
  
  scanf("%d",&n);
  
  if(n > 100 || n < 0){
    return 0;
  }
  
  for(i=0;i < n;i++){
    scanf("%d",&A[i]);
  }
  
  for(i=0;i < n;i++){
    mini = i;
    c=0;
    for(j=i;j < n;j++){
      if(A[j] < A[mini]){
	mini = j;
	c++;
      }
    }
    if(c > 0) {
      count++;
    }
    swap(&A[i],&A[mini]);
  }
  trace(A,n);
  printf("%d\n",count);
  
  return 0;
}

Measured memory_bytes: 604
#include<iostream>

using namespace std;
int prime[1000000];

int main(){
	
    prime[0]=-1;
    prime[1]=-1;
    
    for(int i=2;i<1000000;i++){ 
    
        if( prime[i] == 0 ){
        	
            prime[i] = 1;
            for(int j=i*2;j<1000000;j+=i)
			prime[j] = -1 ;
			
        }
        
    }
    int a;
    while( cin >> a ){
    	
        int count = 0;
        
        for(int i=1;i<a+1;i++)
		if(prime[i] == 1)
		count++;
		
        cout << count << "\n";
    }
    return 0;
}


Measured memory_bytes: 6992
#include<stdio.h>
#include<math.h>

int n, x, c=0;

int isprime(int x){
    if(x==2)            return 1;
    if(x<2 || x%2==0)   return 0;
    for(int i=3 ; i<=sqrt(x) ; i+=2){
        if(x%i==0)      return 0;
    }
    return 1;
}

int main(void){
    scanf("%d", &n);
    for(int i=0 ; i<n ; i++){
        scanf("%d", &x);
        c += isprime(x);
    }
    printf("%d\n", c);
}


Measured memory_bytes: 2040
N=int(input())
l=list(map(int,input().split()))
s=[]
flag=1
while len(l)!=0:
    flag=0
    for i in range(len(l),0,-1):
        if i==l[i-1]:
            p=l[i-1]
            s.append(p)
            l.pop(i-1)
            flag=1
            break
    if flag==0:
        ans=-1
        break

if flag==1:
    ans=reversed(s)
    ans=list(ans)
    for i in ans:
        print(i)
else:
    print(ans)

Measured memory_bytes: 3064
x,y = gets.chomp.split(' ').map(&:to_i)
if x==2 || y==2 || x == 12 || x == 11
	puts 'No'
else
	a = [1,3,5,7,8,10,12]
	b = [4,6,9,11]
	if a.include?(x) && a.include?(y)
		puts 'Yes'
	elsif b.include?(x) && b.include?(y)
		puts 'Yes'
	else
		puts 'No'
	end
end

Measured memory_bytes: 1916
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };

ll so[10] = { 2,3,5,7,11,13,17,19,23,29 };
ll n, cnt = 0;
vector<ll>list(10000, 0);

bool IsPrime(ll num)
{
	cnt %= MOD;

	if (num < 2) return true;
	else if (num == 2) {
		n /= 2;
		list[2]++;
		//cnt++;
		cnt += 2;
		return true;
	}
	else if (num % 2 == 0) {
		n /= 2;
		//cnt++;
		list[2]++;
		cnt += 2;
		return false; // 偶数はあらかじめ除く
	}

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			//cout << "i->" << i << endl;
			list[i]++;
			n /= i;
			//cnt++;
			cnt += 2;
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

signed main() {

	cin >> n;
	ll n2 = n;

	for (ll i = 2; i < n2; i++) {
		n *= i;

		while (n> 1)
		{
			bool flag = false;

			for (int j = 0; j < 10; j++) {
				if (n % so[j] == 0) {
					list[so[j]]++;
					n /= so[j];
					flag = true;
					break;
				}
			}

			if (flag == false)break;
		}

		//if (flag == false) {
			if(IsPrime(n) == true) {
				//break;
			}
		//}

	}

	while (true)
	{
		bool flag = false;

		if (IsPrime(n) == true) {
			list[n]++;
			break;
		}

	}

	ll sum = 1;

	for (int i = 2; i < list.size(); i++) {
		if (list[i] > 0) {
			sum = sum * (list[i] + 1);
			sum %= MOD;
		}
	}

	cout << sum << endl;


	return 0;
}

Measured memory_bytes: 384
import fractions

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

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

# 個数
#(b-a+1)

# aからbまでの間のcの倍数の個数
x = (b//c)-(a//c)
if a%c == 0:
    x += 1

# aからbまでの間のdの倍数の個数
y = (b//d)-(a//d)
if a%d == 0:
    y += 1

# aからbまでの間のaとbの公倍数の個数
z = (b//lcm(c,d))-(a//lcm(c,d))
if a%(c*d) == 0:
    z += 1

print ((b-a+1)-((x+y)-z))

Measured memory_bytes: 5560
fun main(args:Array<String>) {
	val abc = readLine()!!.split(" ").map{ it.toInt() }
	val sum= abc.sum()
	val max=abc.max()!!
	
	if(sum%2==max%2) {
		println( (3*max-sum)/2 )
	}else{
		println( (3*(max+1)-sum)/2 )
	}
}

Measured memory_bytes: 37624
#include <iostream>
using namespace std;
int main()
{
	int A[4] = {}, B[4] = {};
	int hit, blow;
	while (cin >> A[0] >> A[1] >> A[2] >> A[3] >> B[0] >> B[1] >> B[2] >> B[3]){
		hit = blow = 0;
		for (int i = 0; i < 4; ++i){
			if (A[i] == B[i]){
				++hit;
				continue;
			}
			for (int j = 0; j < 4; ++j){
				if (i == j) continue;
				if (A[i] == B[j]) ++blow;
			}
		}
		cout << hit << " " << blow << "\n";
	}
	return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <functional>

using namespace std;

typedef long long ll;

int main() {
    int a, b, c, i = 1;
    cin >> a >> b >> c;
    while(1){
        if(a*i%b==c){
            cout << "YES" << endl;
            break;
        }
        if(i==b){
            cout << "NO" << endl;
            break;
        }
        i++;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string x;
    cin>>x;
    for(int i=1;i<x.length()+1;i++)
    {
        if(i%2==1)
        {
            cout<<x[i-1];
        }
    }
    cout<<endl;
}

Measured memory_bytes: 512
// Problem : H - Grid 1
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_h
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define nl cout<<"\n"
#define endl "\n"
#define all(c) (c).begin(),(c).end()
#define trav(a,x) for(auto a = x.begin() ; a != x.end() ; a++)
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define vll vector<ll>
#define f first
#define s second
typedef long long ll;
typedef unsigned long long ull ;
typedef long double ld;

inline ll max(ll a,ll b) {return ((a>b)?a:b);}
inline ll min(ll a,ll b) {return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b) {if(b==0) return a; a%=b;return gcd(b,a);}
ll power(ll x, ll y){if(y == 0) return 1; ll a = power(x,y/2);if (y % 2 == 0) return a * a; else return x * a * a; }
ll powermod(ll x, ll ex , ll md) {ll ans = 1ll;while (ex > 0) {if (ex & 1ll) ans = (ans * x) % md; ex >>= 1ll;x = (x * x) % md;}return ans;}

const ll inf = 1e18 + 9;
const ll mod = 1e9 + 7;
const ld PI = acos(-1);
const ld eps = 1e-9;

const ll N = 1e3 + 11;
string s[N];
ll dp[N][N]; // dp[i][j] no. of ways to reach (i , j) from (0 , 0	)
ll n , m;
vector<pll> v;
bool vis[N][N];
void dfs(ll x , ll y){
	vis[x][y] = 1;
	if(x + 1 < n){
		if(s[x + 1][y] == '.'){
			if(!vis[x + 1][y]) dfs(x + 1 , y);
		}
	}
	if(y + 1 < m){
		if(s[x][y + 1] == '.'){
			if(!vis[x][y + 1]) dfs(x , y + 1);
		}
	}
	v.pb(make_pair(x , y));
}
void solve(){
	cin >> n >> m;
	rep(i , n) cin >> s[i];
	dfs(0 , 0);	
	reverse(all(v));
	ll len = v.size();
	dp[0][0] = 1;
	for(ll i = 0 ; i < len ; i++){
		ll x = v[i].f;
		ll y = v[i].s;
		if(x + 1 < n){
			if(s[x + 1][y] == '.') {
				dp[x + 1][y] += dp[x][y] ;
				dp[x + 1][y] %= mod;
			}
		} 
		if(y + 1 < m){
			if(s[x][y + 1] == '.') {
				dp[x][y + 1] += dp[x][y] ;
				dp[x][y + 1] %= mod;
			}
		}
	}
	cout << dp[n - 1][m - 1] << endl;
}
int main(){
    IOS;
    cout << fixed << setprecision(20);
    ll NTC=1;
    // cin>>NTC;
    ll PTC=0;
    while(PTC++<NTC){
        // cout<<"Case #"<<PTC<<":"<<' ';
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 26468
// https://atcoder.jp/contests/abc177/tasks/abc177_c
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
// using cpp_dec = boost::multiprecision::cpp_dec_float_50;
using cpp_int = boost::multiprecision::cpp_int;

using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)
const int MOD = 1e9 + 7;

// 参考
// https://atcoder.jp/contests/abc177/submissions/16384020
void solve() {
    int N;
    cin >> N;
    cpp_int x = 0, y = 0;
    REP(i, N) {
        cpp_int t;
        cin >> t;
        x += t;
        y += t * t;
    }
    // (A + B + C)^2 = A^2 + B^2 + C^2 + 2*AB + 2*AC + 2*BC
    // 2*AB + 2*AC + 2*BC = (A + B + C)^2 - (A^2 + B^2 + C^2)

    // AB + AC + BC
    // = ((A + B + C)^2 - (A^2 + B^2 + C^2)) / 2
    // = (x^2 - y) / 2
    cout << (x * x - y) / 2 % MOD << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 3752
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iterator>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define PB push_back
#define rep(i, a) for (int i = 0; i < a; i++)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define mp make_pair
#define INT int_64
const ll INF = (1<<30);
const ll NEGA=-INF*10000; 


ll ans = 0;
int p[200000];
int n,m;
int cnt=0;

int isPrime(int x) {
	int i;
	if (x < 2) return 0;
	else if (x == 2) return 1;
	if (x % 2 == 0) return 0;
	for (int i = 3; i*i <= x; i += 2)
		if (x%i == 0) return 0;
	return 1;
}

int main() 
{
    int a,b;
    cin>>a>>b;
    int po=a;
    if(a>b) po--;
    cout<<po<<endl;
	return 0;
}


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

int main() {
	// your code goes here
	int n, m;
	cin >> n >> m;
	vector<vector<int>> graph(n);
	vector<bool> vis(n);
	vector<int> dp(n);
	function<void (int u)> dfs = [&](int u) {
		vis[u] = true;
		for (int &x : graph[u]) {
			if (!vis[x]) {
				dfs(x);
				
				
			}
			dp[u] = max(dp[u], dp[x] + 1);
		}
		return;
	};
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		a--, --b;
		graph[a].push_back(b);
	}
	for (int i = 0; i < n; ++i) {
		if (!vis[i])
			dfs(i);
	}
	cout << *max_element(dp.begin(), dp.end());
	return 0;
}

Measured memory_bytes: 11924
#include <iostream>
#include <algorithm>
#include <vector>

#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
using namespace std;
const int INF = 1e9 + 5;

signed main() {
    FAST_IO;

    int n, k;
    cin >> n >> k;
    vector<int> stones(n);
    for (int i = 0; i < n; i++) cin >> stones[i];

    vector<int> dp(n, INF); // dp[i] : Minimum cost to reach stone i.
    dp[0] = 0; // Base case, we start on the first stone so cost to reach it is 0.

    for (int i = 0; i < n; i++) { // i represents the stone the frog is currently at.
        for (int j = i + 1; j <= i + k; j++) { // j represents a potential stone for the frog to jump to.
            if (j < n)
                // Storing the total minimum cost to reach stone j from stone i.
                dp[j] = min(dp[j], dp[i] + abs(stones[j] - stones[i]));
        }
    }
    cout << dp[n - 1];
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i,n) for(int i=0; i<n; i++)
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
 
#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9

using namespace std;
typedef long long ll;

ll gcd(ll m, ll n){
	while (m!=n){
		if (m>n) m = m-n;
		else n = n-m;
	}
	return m;
}

ll lcm(ll m, ll n){
	return ((m/gcd(m,n)) * n);
}

int main(){
	ll n1, m1, l, n, m;
	string s1, t1, s, t;
	
	cin >> n1 >> m1 >> s1 >> t1;
	
	n = n1>=m1 ? n1 : m1;
	m = n1>=m1 ? m1 : n1;
	s = n1>=m1 ? s1 : t1;
	t = n1>=m1 ? t1 : s1;
	
	l = lcm(n, m);
	
	for (int i=0; i<gcd(n, m); i++){
		if (s[i*l/m]!=t[i*l/n]){
			cout << -1 << endl;
			return 0;
		}
	}
	
	cout << l << endl;
	
	return 0;
}


Measured memory_bytes: 888
n,y = map(int,input().split())
for i in range(n+1):
    for j in range(n - i +1):
        k = n - i - j
        if (i*10000 + j*5000 + k*1000) == y:
            print(i,j,k)
            exit()
print('-1 -1 -1')

Measured memory_bytes: 3060
import collections
n = int(input())
s = input()
ans = 0
for i in range(1,n):
    cnt = 0
    c1 = collections.Counter(s[:i])
    c2 = collections.Counter(s[i:])
    for x in c1.keys():
        if c2[x]: cnt+=1
    ans = max(cnt, ans)
print(ans)

Measured memory_bytes: 9420
/*  5_3
    Y_Aizaki    */

#include <stdio.h>
#define LIM 100

int main(void){
    int row, col;
    // 行数、列数

    int matrix[LIM][LIM] = {0};
    // マス目入力を受け取る配列

    int midway[LIM][LIM] = {0};
    // マス目入力を行ごとに見て白いマスを消した配列

    int last[LIM][LIM] = {0};
    // マス目入力を列ごとに見て白いマスを消した配列

    int row_count = 0;
    // その行の'.'の数を数え上げる
    int col_count = 0;
    // その列の'.'と消した要素（0）を数え上げる

    char test;
    // 文字型の一時的な格納場所
    // '.'を1,'#'を2へと変換する

    scanf("%d%d", &row, &col);

    for (int i = 0; i < row; i++){
        for (int j = 0; j < col; j++){
            // matrixに'.','#'に応じた数字を入力するループ

            scanf(" %c", &test);
            if (test == '.'){
                matrix[i][j]=1;
            }
            else if (test == '#'){
                matrix[i][j]=2;
            }
        }
    }

    for (int i = 0; i < row; i++){
        // 列を消すループ
        // midwayを作成

        for (int j = 0; j < col; j++){
            if (matrix[i][j] == 1){
            row_count += 1;
            }
        }

        if (row_count != col){
            // 1のみで構成された列以外を移す
            for (int j = 0; j < col; j++){
                midway[i][j] = matrix[i][j];
            }
        }

        row_count = 0;
    }

    for (int j = 0; j < col; j++){
        // 行を消すループ
        // lastを作成

        for (int i = 0; i < row; i++){
            if (midway[i][j] == 1 || midway[i][j] == 0){
                col_count += 1;
            }
        }

        if (col_count != row){
            // 1のみで構成された行以外を移す
            for (int i = 0; i < row; i++){
                last[i][j] = midway[i][j];
            }
        }

        col_count = 0;
    }

    for (int i = 0; i < row; i++){
        for (int j = 0; j < col; j++){
            // lastを出力するループ

            if (last[i][j] == 1){
                printf(".");
            }
            else if (last[i][j] == 2){
                printf("#");
            }
        }

        for (int j = 0; j < col; j++){
            if (last[i][j] == 1 || last[i][j] == 2){
                printf("\n");
                break;
            }

        }
    }

    return 0;

}



Measured memory_bytes: 256
n = int(input())
s = [input() for _ in range(n)]

ans, cnt = 0, [0, 0, 0]
for i in s:
    ans += i.count('AB')
    if i[0] == 'B' and i[-1] == 'A':
        cnt[0] += 1
    elif i[0] == 'B':
        cnt[1] += 1
    elif i[-1] == 'A':
        cnt[2] += 1

if cnt[1] + cnt[2] == 0:
    print(ans + max(cnt[0] - 1, 0))
else:
    print(ans + min(cnt[1], cnt[2]) + cnt[0])


Measured memory_bytes: 9576
from itertools import product
N = int(input())
S = input()
MODN = int(10 ** 9 + 7)

'''
keys = list("abcdefghijklmnopqrstuvwxyz")
values = [0] * 26
D = dict(zip(keys, values))

print(D)
exit(0)
'''

D = {}

for ch in S:
  if ch in D:
    D[ch] += 1
  else:
    D[ch] = 1
    
V = list(D.values())
M = len(V)

ans = 1
for i in range(M):
  ans = ans * (V[i]+1) % MODN
  
print(ans - 1)

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

void Main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < k; i++)
    {
        vector<int> p1(n), p2(n+1);
        for (int j = 0; j < n; j++)
        {
            p1[max(0, j - a[j])] += 1;
            p2[min(j + a[j] + 1, n)] += 1;            
        }
        for (int j = 1; j < n; j++)
        {
            p1[j] = p1[j-1] + p1[j];
            p2[j] = p2[j-1] + p2[j];            
        }
        for (int j = 0; j < n; j++)
        {
            a[j] = p1[j] - p2[j];
        }
        
        int finish = 1;
        for (int i = 0; i < n; i++)
        {
            if(a[i] < n) finish = 0;
        }
        if(finish){
            break;
        }
    }
    
    for (int i = 0; i < n; i++)
    {
        cout << a[i] << " ";
    }
    cout << endl;
    
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


Measured memory_bytes: 5644
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();

        int price = 0;

        if (N <= K) {
            price = X * N;
        } else if (N > K) {
            price = Y * (N - K) + X * K;
        }

        System.out.println(price);
    }
}

Measured memory_bytes: 9940
//%std
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out = 0, fh = 1;
	char jp = getchar();
	while ((jp > '9' || jp < '0') && jp != '-')
		jp = getchar();
	if (jp == '-')
		fh = -1, jp = getchar();
	while (jp >= '0' && jp <= '9')
		out = out * 10 + jp - '0', jp = getchar();
	return out * fh;
}
const int N = 100 + 10;
int n, m, dp[N][N], a[N][N];
char buf[N];
int main()
{
	n = read(), m = read();
	for (int i = 1; i <= n; ++i)
	{
		scanf("%s", buf + 1);
		for (int j = 1; j <= m; ++j)
			a[i][j] = buf[j] == '#';
	}
	dp[1][1] = a[1][1];
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
		{
			if (i == 1 && j == 1)
				continue;
			int val = n * m;
			if (i > 1)
				val = min(val, dp[i - 1][j] + (a[i][j] == 1 && a[i - 1][j] == 0));
			if (j > 1)
				val = min(val, dp[i][j - 1] + (a[i][j] == 1 && a[i][j - 1] == 0));
			dp[i][j] = val;
		}
	printf("%d\n", dp[n][m]);
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main() {
    int a,b,c,tmp,i,j;
    long int tmpsum,sum=0;
    scanf("%d %d %d",&a,&b,&c);
    int arr[b];
    for(i=0; i<b; i++)
        scanf("%d",&arr[i]);
    for(i=0; i<a; i++) {
        tmpsum=0;
        for(j=0; j<b; j++) {
            scanf("%d",&tmp);
            tmpsum+=arr[j]*tmp;
        }
        tmpsum+=c;
        if(tmpsum>0) sum++;
    }
    printf("%ld",sum);
    return 0;
}


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

int main()
{
	long long n;
	cin >> n;

	int s = 0;
	{
		long long nc = n;
		int temp = 0;
		for (int i = 9; 0 <= i; --i) {
			long long p1 = pow(10, i + 1);
			nc -= p1 * temp;
			long long p2 = pow(10, i);
			temp = nc / p2;
			s += temp;
		}
	}

	if (n % s == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int h, w;
string s;

int main() {
	cin >> h >> w;
	inc(i, h) {
		cin >> s;
		cout << s << "\n";
		cout << s << "\n";
	}
	
	return 0;
}


Measured memory_bytes: 256
#print(-10%3)



def main():
    n = int( input() )

    i = 0
    ans = '' if n!=0 else '0'
    while n != 0:
        rem = n % ( 2**(i+1) )
#        print((n,i, rem))
  
        ans += '1' if rem>0 else '0'

        n += rem * ( -1 if i%2==0 else 1)
        i += 1
#        if i>10:
#            break
    print(ans[::-1])


main()

Measured memory_bytes: 3060
from sys import stdin
#n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
k,x = map(int, stdin.readline().rstrip().split())
#S = [list(map(int, stdin.readline().rstrip().split())) for _ in range(h)]#hの定義を忘れずに

if k*500 >= x:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<set>

using namespace std;
using ll = long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int w, d;
  while(cin >> w >> d && w && d){
    multiset<int> h_w;
    int ans = 0;
    for(int i = 0; i < w; i++){
      int t; cin >> t;
      h_w.insert(t);
    }
    for(int i = 0; i < d; i++){
      int t; cin >> t;
      auto it = h_w.find(t);
      if(it != h_w.end()) h_w.erase(it);
      ans += t;
    }
    for(auto i : h_w) ans += i;
    cout << ans << endl;
}
  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}



Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<long long,long long> > vpll;
typedef vector<vector<ll> > vvll;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 

bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 
int main() {
	string s,s1;ll i,c=0;
	cin>>s>>s1;
fr(i,0,3)
{
	if(s[i]==s1[i])
	{
		c++;
	}
}
cout<<c;
	return 0;
}


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

constexpr int mod = 1e9 + 7;
struct Mint {
  int v;
  Mint(long long a = 0) : v((a %= mod) < 0 ? a + mod : a) {}
  Mint& operator*=(Mint r) { v = (long long)v * r.v % mod; return *this; }
  Mint& operator/=(Mint r) { return *this *= r.inv(); }
  Mint& operator+=(Mint r) { if ((v += r.v) >= mod) v -= mod; return *this; }
  Mint& operator-=(Mint r) { if ((v -= r.v) < 0) v += mod; return *this; }
  friend Mint operator*(Mint l, Mint r) { return l *= r; }
  friend Mint operator/(Mint l, Mint r) { return l /= r; }
  friend Mint operator+(Mint l, Mint r) { return l += r; }
  friend Mint operator-(Mint l, Mint r) { return l -= r; }
  Mint pow(long long n) const {
    Mint res = 1;
    for (Mint t = *this; n; t *= t, n >>= 1) if (n & 1) res *= t;
    return res;
  }
  Mint inv() const { return pow(mod - 2); }
  friend string to_string(Mint a) { return to_string(a.v); }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<long long> c(60);
  for (int i = 0; i < n; ++i) {
    long long a;
    cin >> a;
    for (int k = 0; k < 60; ++k) {
      c[k] += a >> k & 1;
    }
  }
  Mint res;
  for (int k = 0; k < 60; ++k) {
    res += c[k] * (n - c[k]) * Mint(2).pow(k);
  }
  cout << res.v << '\n';
}


Measured memory_bytes: 256