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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
	ll N;
	cin>>N;
	vector<ll> v(N);
	int in;
	cin>>v[0];
	FOR(i,1,N){
		cin>>in;
		v[i] = v[i-1] + in;
	}


	ll la,lb,ra,rb,res=1e9;
	ll L=0,R=2;
	vector<ll> key(4);
	FOR(i,2,N-1){
		while(abs(v[i-1]-v[L]-v[L])>abs(v[i-1]-v[L+1]-v[L+1])){
			L++;
		}
		while(abs(v[N-1]-v[R]-v[R]+v[i-1])>abs(v[N-1]-v[R+1]-v[R+1]+v[i-1])){
			R++;
		}
		rb=v[N-1]-v[R];
		ra=v[R]-v[i-1];
		lb=v[i-1]-v[L];
		la=v[L];

		key[0]=la;
		key[1]=lb;
		key[2]=ra;
		key[3]=rb;
		sort(key.begin(),key.end());
		if(key[3]-key[0]<res) res=key[3]-key[0];
		//cout<<"L="<<L<<" i="<<i<<" R="<<R<<endl;

		//cout<<la<<" "<<lb<<" "<<ra<<" "<<rb<<endl;

	}
	cout<<res<<endl;
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<functional>
#include<algorithm>
#include<stack>
#include<queue>
#include<iomanip>
#include<set>
#include<map>
#include<utility>
#include<string>
#include<vector>

using namespace std;

#define LL long long

set<string>dict;
int n;

int main() {
	cin>>n;
	for(int i=0;i<n;i++){
		string com,str;
		cin>>com>>str;
		if(com[0]=='i')dict.insert(str);
		else cout<<((dict.count(str)==1)?"yes":"no")<<endl;
	}

	return 0;
}




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

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

#define int long long int 
#define mp make_pair
#define pb push_back
#define f first
#define s second

const int N=1e5+5;

int a[N],freq[N];

int32_t main()
{
    
    int n;
    cin>>n;
   
    
    for(int i=1;i<=n;i++)
    {
         cin>>a[i];
    }
    
    vector < pair<int,int> > v,v1;
    
    for(int i=1;i<=n;i+=2)
    {
         freq[a[i]]++;
    }
    
    for(int i=1;i<=100000;i++)
    {
         if(freq[i]!=0)
         v.pb(mp(freq[i],i));
         freq[i]=0;
    }
    
    for(int i=2;i<=n;i+=2)
    {
         freq[a[i]]++;
    }
    
    for(int i=1;i<=100000;i++)
    {
         if(freq[i]!=0)
         v1.pb(mp(freq[i],i));
    }
    
    sort(v.begin(),v.end());
    sort(v1.begin(),v1.end());
    reverse(v.begin(),v.end());
    reverse(v1.begin(),v1.end());
    int num1=v[0].s;
    int num2=v1[0].s;
    int f1=v[0].f;
    int f2=v1[0].f;
    
    int ans=0;
    
    if(num1!=num2)
    {
         n/=2;
         ans=(n-f1)+(n-f2);
    }
    else
    {
         
         n/=2;
         int f3,f4;
         
         if(v.size()==1)
         {
              f3=0;
         }
         else
         {
              f3=v[1].f;
         }
         if(v1.size()==1)
         {
              f4=0;
         }
         else
         {
              f4=v1[1].f;
         }
          ans=min((n-f1)+(n-f4),(n-f3)+(n-f2));
    }
    
    cout<<ans;
    
}

Measured memory_bytes: 4084
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

f([_|Xs], [Y|Ys]) :- f(Xs, [Y|Ys]).
f([X], [Y|_]) :- X = Y.

main :-
    get_string(A),
    get_string(B),
    get_string(C),
    string_chars(A, A2),
    string_chars(B, B2),
    string_chars(C, C2),
    (f(A2, B2), f(B2, C2)) -> writeln("YES") ; writeln("NO").


Measured memory_bytes: 8060
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
void main() {
    alias Tuple!(int, "x", int, "y") P;
    const id = [
        '5': P(0, 0), 
        '8': P(0, -1),
        '6': P(1, 0),
        '4': P(-1, 0),
        '2': P(0, 1),
    ];
    const dy = [1, 0, -1, 0],
          dx = [0, 1, 0, -1];

    int H, W;
    string[] F;
    string Pat;
    bool input() {
        scanf("%d %d\n", &H, &W);
        if (H == 0 && W == 0) return false;
        F = new string[H];
        foreach (i; 0 .. H) {
            F[i] = readln.chomp;
        }
        Pat = readln.chomp;
        return true;
    }

    void solve() {
        int[][] X = new int[][](H, W);
        foreach (i; 0 .. H) X[i][] = int.max;
        
        P find(char c) {
            foreach (i; 0 .. H)
                foreach (j; 0 .. W) 
                    if (F[i][j] == c) return P(j, i);
            assert(false);
        }

        P s = find('A');
        struct S {
            P p;
            int t;
        }
        DList!S Q;
        Q.insert(S(s, 0));
        X[s.y][s.x] = 0;
        while (!Q.empty) {
            S c = Q.front; Q.removeFront;
            foreach (i; 0 .. 4) {
                int ny = c.p.y + dy[i],
                    nx = c.p.x + dx[i],
                    nt = c.t + 1;
                if (ny < 0 || ny >= H) continue;
                if (nx < 0 || nx >= W) continue;
                if (F[ny][nx] == '#') continue;
                if (X[ny][nx] <= nt) continue;
                X[ny][nx] = nt;
                Q.insert(S( P(nx, ny), nt ));
            }
        }

        P g = find('B');
        int t = 0;
        while (true) {
            foreach (c; Pat) {
                t++;
                if (t > H * W * Pat.length) {
                    writeln("impossible");
                    return;
                }
                P d = id[c];
                int ny = g.y + d.y,
                    nx = g.x + d.x;
                if (ny < 0 || ny >= H) ny = g.y;
                if (nx < 0 || nx >= W) nx = g.x;
                if (X[ny][nx] <= t) {
                    writefln("%d %d %d", t, ny, nx);
                    return;
                }
                g.y = ny;
                g.x = nx;
            }
        }
    }

    while (input()) solve();
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
static const int MAX_N = 100000;

set<int> S;
int N; 
int a;

int main(void){
	cin >> N;
	for(int i = 1; i <= N; i++){
		cin >> a;
		S.insert(a);
	}
	if(S.size() % 2 == 1) cout << S.size() << endl;
	else cout << S.size() - 1 << endl;
	return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

int main() {

	vector<string> S(3, "");

	for (long long i = 0; i < S.size(); i++) {
		cin >> S[i];
	}

	vector<list<long long>> v(3, list<long long>());

	for (long long i = 0; i < v.size(); i++) {
		for (long long j = 0; j < S[i].length(); j++) {
			if (S[i][j] == 'a') {
				v[i].push_back(0);
			}
			else if (S[i][j] == 'b') {
				v[i].push_back(1);
			}
			else {
				v[i].push_back(2);
			}
		}
		v[i].push_back(-1);
	}

	long long val = 0;
	long long dval = 0;
	while (v[0].size() * v[1].size() * v[2].size() != 0) {
		dval = v[val].front();
		v[val].pop_front();
		val = dval;
	}

	for (long long i = 0; i < v.size(); i++) {
		if (v[i].size() == 0) {
			if (i == 0) {
				cout << "A" << endl;
				break;
			}
			else if (i == 1) {
				cout << "B" << endl;
				break;
			}
			else {
				cout << "C" << endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3604
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#H = int(input())
H, W = map(int, input().split())
A = []
for _ in range(H) :
  A.append(list(str(input())))
#print (A)

for i in range(H) :
  wcnt = 0
  for j in range(W) :
    if A[i][j] == "." :
      wcnt += 1
  if wcnt == W :
    for j in range(W) :
      A[i][j] = "0"
#print (A)

for j in range(W) :
  wcnt = 0
  for i in range(H) :
    if A[i][j] == "." or A[i][j] == "0":
      wcnt += 1
  if wcnt == H :
    for i in range(H) :
      A[i][j] = "0"
#print (A)

for i in range(H) :
  ans = ""
  for j in range(W) :
    if A[i][j] != "0" :
      ans += A[i][j]
  if ans != "" :
    print (ans)


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

using namespace std;
string a[10005];
int check[10005],n;
void DFS(int i,long long &res,int start){
	int chon=0;
    for(int j=1;j<=n;j++){

        if(check[j]==0){
            //cout<<i<<" "<<start<<" "<<j<<" "<<a[i][a[i].size()-1]<<" "<<a[j][0]<<endl;
            if(start==0){
            	if((a[i][a[i].size()-1]=='A')&&((a[j][0]=='B'))){
                    res++;
                    check[j]=1;
	                chon=j;

	                break;
                }


            }
            else{
                if((a[i][0]=='B')&&((a[j][a[j].size()-1]=='A'))){
                    res++;
                    check[j]=1;
	                chon=j;
	                //cout<<i<<" "<<start<<" "<<j<<endl;
	                break;
                }
            }
        }
    }
    if(chon!=0){
    	//cout<<i<<" "<<chon<<endl;
    	DFS(chon,res,start);
    }
}
int main()
{
    long long ans=0;
    cin>>n;
    vector<int>v;
    int start=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if((a[i][a[i].size()-1]=='A')||(a[i][0]=='B')){
            v.push_back(i);
        }
        if((a[i][a[i].size()-1]=='A')&&(a[i][0]=='B')){
            start=i;
        }
        for(int j=1;j<a[i].size();j++){
            if((a[i][j]=='B')&&(a[i][j-1]=='A')){
                ans++;
            }
        }
    }
    if(start!=0){
        check[start]=1;
        DFS(start,ans,0);
        DFS(start,ans,1);
    }
    //cout<<start<<endl;
    int kt=0;

	for(int i=0;i<v.size();i++){
		start=v[i];
        if(check[start]==0){
        	check[start]=1;
        	int temp=ans;
        	/*if(kt==0){
                if((a[start][a[start].size()-1]=='A')&&(a[start][0]=='B'))
                DFS(start,ans,0);
                if(ans==temp){
                    check[start]=0;
                }
                DFS(start,ans,1);
                if(ans==temp){
                    check[start]=0;
                }
                kt=1;
                continue;
        	}*/
            if(a[start][a[start].size()-1]=='A'){
                DFS(start,ans,0);
                if(ans==temp){
                    check[start]=0;
                }
                //continue;
            }
            if(a[start][0]=='B'){
                DFS(start,ans,1);
                if(ans==temp){
                    check[start]=0;
                }
               // continue;
            }

        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  string s; cin >> s;
  int sz = s.size();
  vi num(sz);
  rep(i,sz) {
    string t;
    t.push_back(s[i]);
    num[i] = stoi(t);
  }
  reverse(all(num));

  ll ans = 0;
  rep(i,sz) {
    ans += (1 << (sz-1) ) * num[i];
    ll power = 1;
    rep(j,i) {
      ans += 9 * power * (1 << (sz-2-j) ) * num[i];
      power *= 10;
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define MAX_N 100'000

using namespace std;

int B[MAX_N]{};

int main() {
  int N, K, Q;
  cin >> N >> K >> Q;
  for (int i = 0; i < Q; ++i) {
    int b;
    cin >> b;
    ++B[b - 1];
  }
  for (int i = 0; i < N; ++i) {
    if (B[i] + K - Q <= 0) {
      printf("No\n");
    } else {
      printf("Yes\n");
    }
  }
}

Measured memory_bytes: 3472
#include <stdio.h>
#include <string.h>
int main(){
    char a[11],b[11],c[11];
    int alen,blen,clen;
    scanf("%s %s %s",a,b,c);
    alen = strlen(a);
    blen = strlen(b);
    clen = strlen(c);
    if(a[alen-1]==b[0] && b[blen-1]==c[0]){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
    if (v.size() == 0) return (os);
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

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


void Main() {
    int N; cin >> N;
    vint A(N+1);
    for (int i = 1; i <= N; i++) cin >> A[i];
    vector<bool> used(N+1, false);
    
    for (int i = N; i > 0; i--) {
        int cnt = 0;
        for (int j = i+i; j <= N; j += i) {
            if (used[j]) cnt++;
        }
        if ((cnt + A[i]) % 2 == 1) {
            used[i] = true;
        } 
    }
    vint ans;
    for (int i = 1; i <= N; i++) {
        if (used[i]) ans.push_back(i);
    }
    cout << ans.size() << endl;
    cout << ans << endl;
}

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

Measured memory_bytes: 4588
// be name khoda
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

const int N = 2e5 + 10;

int n, q, p[N], ans[N];
vector <int> adj[N];

void dfs(int a, int d) {
	ans[a] = ans[d] + p[a];
	for (auto x: adj[a])
		if (x != d)
			dfs(x, a);
}

int main() {
	ios_base :: sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
	cin >> n >> q;
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		a-- , b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	for (int i = 0; i < q; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		p[a] += b;
	}
	dfs(0, 0);
	for (int i = 0; i < n; i++)
		cout << ans[i] << " ";
	return 0;
}

Measured memory_bytes: 24192
#include <bits/stdc++.h>
using namespace std;
#define MAX_SIZE 10000

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;

const ll MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-8;
const int MAXN = 1e7;

int main(int argc, char const *argv[]){
    string s;
    cin>>s;
    int len=(int)s.length();
    int ans=0;
    int t=0;
    for(int i=0;i<len;i++){
        int n=s[i]-'0';
        if(n>0){
            ans=max(ans,t+(n-1)+(len-1-i)*9);
        }
        t+=n;
    }
    ans=max(ans,t);
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  int n; cin>>n;
  vector<pii> p(n);
  rep(i,n){
    cin>>p.at(i).first;
    p.at(i).second=i;
  }
  sort(p.begin(),p.end());
  rep(i,n){
    cout<<p.at(i).second+1<<" ";}
}

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

typedef unsigned long long ull;

#define REP(i, N) for (int i = 0; i < N; i++)
#define REP1(i, N) for (int i = 1; i < N; i++)
#define ANS(a) cout << a << endl;
#define SORT(V) sort(V.begin(), V.end())
#define RSORT(V) sort(V.rbegin(), V.rend())

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

  vector<int> L;
  vector<int> R;
  L.emplace_back(0);
  if  (S[0] == '0') R.emplace_back(0);
  REP1(i, N) {
    if (S[i-1] == S[i]) continue;
    if (S[i] == '1') L.emplace_back(i); else R.emplace_back(i);
  }
  if (S[N-1] == '0') L.emplace_back(N);
  R.emplace_back(N);

  int ans = 0;
  for(auto l: L) {
    int ir = 0;
    while (l > R[ir] && ir < R.size()) ir++;
    
    ir += K;
    if (R.size() <= ir) ir = R.size() - 1;
    
    ans = max(ans, R[ir] - l);
  }

  ANS(ans);

  return 0;
}


Measured memory_bytes: 1020
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0060
{
    class Program
    {
        static void Main(string[] args)
        {
            string temp = "";
            int[] cardSet = new int[10] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            int[] card = new int[3];

            while ((temp = Console.ReadLine()) != null)
            {
                card = temp.Split(' ').Select(int.Parse).ToArray();
                int count = 0;

                for (int i = 0; i < 10; i++)
                {
                    if (cardSet[i] == card[0] || cardSet[i] == card[1] || cardSet[i] == card[2])
                    {
                    }
                    else if (cardSet[i] + card[0] + card[1] <= 20)
                    {
                        count += 1;
                    }
                }
                if (count >= 4)
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
        }
    }
}



Measured memory_bytes: 18340
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using namespace std;
using ll = long long;
typedef std::pair<ll,ll> P;
//#include <boost/multiprecision/cpp_int.hpp>
//using bint = boost::multiprecision::cpp_int;


int main(){
    vector<int> f = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << f[k-1];
}


Measured memory_bytes: 256
h, w = list(map(int, input().split()))
n = int(input())
ans = [[0 for i in range(w)] for j in range(h)]
dec = 1
p = 1
cnt = 0
index = 0
a = list(map(int, input().split()))
for i in range(h):
    while 0 <= index < w:
        if cnt == a[p-1]:
            p += 1
            cnt = 0
        ans[i][index] = p
        cnt += 1
        index += dec
    dec *= (-1)
    index += dec
for i in range(h):
    for j in range(w):
        print("{} ".format(ans[i][j]), end = '')
    print()
    

Measured memory_bytes: 3956
from sys import stdin

n = int(input())
S = list(map(int,stdin.readline().split()))
q = int(input())
T = list(map(int,stdin.readline().split()))

def binary_search(num,L):
    left = 0
    right = n
    while left != right:
        middle = (left+right)//2
        if L[middle] == num:
            return True
        elif L[middle] < num:
            left = middle+1
        else:
            right = middle

count = 0
for a in T:
    if binary_search(a,S):
        count += 1

print(count)


Measured memory_bytes: 16180
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String[] list;
//		while(sc.hasNextLine()){
			list =sc.nextLine().split(" ");
//		}
		int a=Integer.parseInt(list[0]);
		int b=Integer.parseInt(list[1]);
		int c=Integer.parseInt(list[2]);
		
		int count=0;
		for(int i=a;i<=b;i++){
			if(c%i==0){
				count++;
			}
		}
		System.out.println(count);
	}
}

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

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& vec) {
    out << "[";
    for (int x : vec) out << x << ", ";
    out << "]";
    return out;
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file
    #define dbg_var(x) cerr << #x << ": " << x << endl;
#endif


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); 
    
    int n, k;
    cin >> n >> k;
    int ans = (n-1+k-2)/(k-1);
    cout << ans << '\n';
    return 0;
}


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

signed main(void)
{
	string s, t;
	int cnt;
	cin >> s;
	t = "CODEFESTIVAL2016";
	cnt = 0;
	rep(i, s.size())
	{
		if (s[i] != t[i])
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}


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

int main(){
	int n,max=-1,num=-1,a[20],v[20];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i]>>v[i];
		if(max<v[i] && max!=v[i]){
			num=a[i];
			max=v[i];
		}else if(max==v[i] && num>a[i]){
			num=a[i];	
		}
	}
	cout<<num<<" "<<max<<endl;

		return 0;
}

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

int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
vector<long long int> adj[200001];
bool vis[200001];
#define ll long long int
#define ull unsigned long long int
#define MAX 1000000007
#define MOD 998244353

#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST ll t;cin>>t;while(t--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define pi acos(-1.0)
ll arr[201];
ll sizes[201];
vector<pair<ll,pll> > edge;
ll power(ll a,ll b){
    ll ans=1;
    while(b){
        if(b&1) ans=ans*a;
        b/=2;
        a=a*a;
    }
    return(ans);
}

int main(){
    IO
    double a,b,h,m;
    cin>>a>>b>>h>>m;

    double theta2=m*6.0;
    double theta1=h*30.0+m*0.5;
    double theta=abs(theta2-theta1);
    double c=a*a+b*b;
  //  cout<<c<<endl;
    c-=2*a*b*cos(theta*pi/180.0);
   // cout<<c;
    cout<<setprecision(25)<<sqrt(c);
    return(0);
}

Measured memory_bytes: 8900
import java.util.*;

public class Main{  
   
    public static void main(String args[]) {
       int a,b,c,D,x,y,z,n;
       Scanner scn = new Scanner(System.in);
       a=scn.nextInt();
       b=scn.nextInt();
       c=scn.nextInt();
       D=a+b+c;
       x=D-a;
       y=D-b;
       z=D-c;
       if(x<=y){
           n=x;
       }else{
         n=y;  
       }
       
       if(n>=z){
           n=z;
       }
       System.out.println(n);
    }

}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
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 argc, char const *argv[]) {
  int n, x, y;
  cin >> n >> x >> y;
  vector<int> G[n];
  vector<vector<int>> dist(n,vector<int>(n,-1)); // dist[i][j]:iからjへの距離
  x--, y--;
  G[x].pb(y);
  G[y].pb(x);
  rep(i, n - 1) { 
    G[i].pb(i + 1);
    G[i + 1].pb(i);
  }
  rep(s,n) {
    dist[s][s] = 0;
    queue<int> q;
    q.push(s);
    while(!q.empty()){
      int now = q.front();
      q.pop();
      for (auto nx : G[now]) {
        if (dist[s][nx] != -1) continue;
        dist[s][nx] = dist[s][now] + 1;
        q.push(nx);
      }
    }
  }
  vector<int> ans(n,0);
  rep(i, n) rep(j, n) ans[dist[i][j]]++;
  for (int i = 1; i < n; i++){
    cout << ans[i]/2 << endl;
  }
  return 0;
}

Measured memory_bytes: 19376
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#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 repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	string s;
	ll ans=0;
	cin >>s;
	int as=0;
	int bs=0;
	char last='0';
	string box="";
	rep(i,s.size()){
	//	clog<<last<<endl;
		if(last=='A'){
			box+='a';
			last=s[i];
		}else if(last=='B' and s[i]=='C'){
			box+='b';
			last='0';
		}else if(last=='0'){
			last=s[i];
		}else{
			box+='0';
			last=s[i];
		}
	}
	if(last=='A'){
		box+='a';
	}
	rep(i,box.size()){
		switch(box[i]){
			case 'a':
			as++;
			break;
			case 'b':
			bs++;
			ans+=as;
		//	clog<<as<<endl;
			break;
			case '0':
			as=0;
			bs=0;
			break;
		}
	}
	clog<<box<<endl;
	cout<<ans<<endl;
}

Measured memory_bytes: 900
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int func(int n,int k){
    int res=0;
    while(n>0){
        res+=n%k;
        n/=k;
    }
    return res;
}

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

    int ans=N;
    for(int i=0;i<=N;i++){
        int t=func(i,6)+func(N-i,9);
        ans=min(ans,t);
    }
    cout<<ans<<endl;
 
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
#include<bits/stdc++.h>
#define ll long long 
#define dd double
using namespace std;
const ll MOD = 1e9 + 7; 
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n;
  cin>>n;
  int v[n],c[n];
  int i;
  for(i=0;i<n;i++){
  	cin>>v[i];
  }
  for(i=0;i<n;i++){
  	cin>>c[i];
  }
  
  int sum=0;
  int sub=0;
  for(i=0;i<n;i++){
  	if(v[i]>=c[i]){
  		sum=sum+v[i];
  		sub=sub+c[i];
	  }
  }
  
  cout<<sum-sub<<endl;
  
  return 0;
}

Measured memory_bytes: 3652
// Copyright 2020 yaito3014
#include <bits/stdc++.h>

int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  constexpr int MOD = 1000000007;
  auto mod_pow = [&](long long int a, int n) -> int {
    long long int res = 1;
    for (; n > 0; n /= 2) {
      if (n % 2)
        res = res * a % MOD;
      a = a * a % MOD;
    }
    return res;
  };
  auto mod_inverse = [&](int n) -> int { return mod_pow(n, MOD - 2); };

  int N, K;
  cin >> N >> K;

  vector<long long> mod_factorials(N + 1, 1);
  for (int i = 0; i < N; ++i)
    mod_factorials[i + 1] = mod_factorials[i] * (i + 1) % MOD;
  auto mod_combination = [&](int n, int r) -> long long {
    return mod_factorials[n] *
           mod_inverse(mod_factorials[n - r] * mod_factorials[r] % MOD) % MOD;
  };
  for (int i = 1; i <= K; ++i) {
    cout << (i <= N - K + 1 ? mod_combination(N - K + 1, i) *
                                  mod_combination(K - 1, i - 1) % MOD
                            : 0)
         << '\n';
  }
}


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



int main()
{
    string s,t;
    int cnt=0;
    cin>>s>>t;
    for(int i=0; i<s.size(); i++)
    {
        if(s[i]!=t[i])
            cnt++;
    }

    cout<<cnt<<endl;
}




Measured memory_bytes: 3848
n, m = gets.chomp.split.map(&:to_i)
k = []
s = []
m.times do |i|
  s[i] = gets.chomp.split.map(&:to_i)
  k[i] = s[i].shift
end
p = gets.chomp.split.map(&:to_i)

ans = 0
# スイッチの組み合わせ全てを試す　最大で2^10 = 1024回
[0,1].repeated_permutation(n) do |a|
  flag = false
  # 電球全てを巡回
  m.times do |i|
    tmp = 0
    # 電球に繋がっているスイッチを巡回
    s[i].each do |t|
      # スイッチがオンになっているとき、tmpに１を足す
      tmp += a[t-1]
    end
    # ついている電球を２で割った値が、p[i]と一致していないとき、すなわち電球がついていないときflagをtrueに
    if tmp % 2 != p[i]
      flag = true
      break
    end
  end
  # flagがtrueの時、すなわち電球がついていない時にans += 1を実行せず次に進む　
  # 電球がついている時、flag=falseの時ans += 1を実行する
  next if flag
  ans += 1
end

puts ans

Measured memory_bytes: 1916
while 1:
    k=[]
    l=input()
    if l==".":break
    f=False
    for i in l:
        if f:break
        if i=="[" or i=="(":
            k.append(i)
        elif i=="]":
            try:
                if k.pop()!="[":
                    f=True
            except:
                f=True
        elif i==")":
            try:
                if k.pop()!="(":
                    f=True
            except:
                f=True
    if not k and not f:print("yes")
    elif k or f:print("no")



Measured memory_bytes: 5576
s = input()
n = len(s)
INF = 10**9
ans = [INF] * (n+1)


memo = {}
if s[0] == "<":
    ans[0] = 0
    memo[0] = 1 
if s[n-1] == ">":
    ans[n] = 0
    memo[n] = 1
for i in range(n-1):
    if s[i] == ">" and s[i+1] == "<":
        ans[i+1] = 0
        memo[i+1] = 1
        

for i in memo:
    cnt = 1
    tmp = i - 1
    while True:
        if tmp >= 0 and s[tmp] == ">":
            ans[tmp] = cnt
            cnt += 1
            tmp -= 1
        else:
            break
    cnt = 1
    tmp = i
    while True:
        if tmp < n and s[tmp] == "<":
            ans[tmp+1] = cnt
            cnt += 1
            tmp += 1
        else:
            break

for i in range(n-1):
    if s[i] == "<" and s[i+1] == ">":
        ans[i+1] = max(ans[i], ans[i+2]) + 1
print(sum(ans))

Measured memory_bytes: 55244
n, d, a = map(int, input().split())
XH = [tuple(map(int, input().split())) for i in range(n)]
XH.sort()
X = [x for x, h in XH]
H = [h for x, h in XH]
X.append(10**10)
H.append(0)
j = 0
S = [0]*(n+1)
ans = 0
for i in range(n):
    H[i] = max(0, H[i]-S[i])
    c = -(-H[i]//a)
    while X[j] <= X[i] + 2*d:
        j += 1
    S[i+1] += S[i] + a*c
    S[j] -= a*c
    ans += c
print(ans)


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

using namespace std;

int main()
{
    int n,a,b,ans1,ans2;
    cin>>n>>a>>b;
    ans1=(a+b)-n;
    if(ans1<0)
        ans1=0;
    ans2=min(a,b);
    cout<<ans2<<" "<<ans1;

    return(0);
}


Measured memory_bytes: 256
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;
use std::io::Write;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let n: usize = read();
    let mut a: Vec<usize> = readnc();
    a.sort();

    let mut last = 0;
    let mut lose = true;
    let mut ans = true;
    for i in 0..n {
        let mut x = (n-i);
        let to = a[i];
        if last < to {
            if last < x && x <= to {
                let diff = to - x;
                if diff % 2 == 0 {
                    ans = false;
                }
            } else if last == x {
                if !lose && (to - x) % 2 == 0 {
                    ans = false;
                }
            }
            last = to;
            lose = true;
        } else {
            lose = !lose;
            if lose && last == x {
                ans = false;
            }
        }
    }

    if ans {
        println!("First");
    } else {
        println!("Second");
    }
}

Measured memory_bytes: 8444
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second


ll N, M;
vector<ll> S[10];
vector<ll> P;

bool chk(ll x) {
    rep (m, M) {
        ll cnt = 0;
        for (auto s : S[m]) {
            if (x & (1 << s)) {
                ++cnt;
            }
        }
        if (cnt % 2 != P[m]) {
            return false;
        }
    }
    return true;
}

int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    cin >> N >> M;
    rep (m, M) {
        ll K;
        cin >> K;
        rep (k, K) {
            ll s;
            cin >> s;
            S[m].pb(s - 1);
        }
    }
    rep (m, M) {
        ll p;
        cin >> p;
        P.pb(p);
    }
    ll ans = 0;
    for (ll x = 0; x < (1 << N); ++x) {
        if (chk(x)) {
            ++ans;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 632
#include <bits/stdc++.h>
using namespace std;
#define debug(...) { printf("#  "); printf(__VA_ARGS__); puts(""); }
#define fi first
#define se second
#define endl "\n" 
using ll = long long;
using pII = pair <int, int>;
using pLL = pair <ll, ll>;
using VI = vector <int>;
using VL = vector <ll>;
constexpr int mod = 1e9 + 7;
template <class T1, class T2> inline void chadd(T1 &x, T2 y) { x += y; if (x >= mod) x -= mod; else if (x < 0) x += mod; } 
template <class T1, class T2> inline void chmax(T1 &x, T2 y) { if (x < y) x = y; }
template <class T1, class T2> inline void chmin(T1 &x, T2 y) { if (x > y) x = y; }
inline int rd() { int x; cin >> x; return x; }
template <class T> inline void rd(T &x) { cin >> x; }
template <class T> inline void rd(vector <T> &vec) { for (auto &it : vec) cin >> it; }
template <class T> inline void out(T s) { cout << s << "\n"; }
template <class T> inline void out(vector <T> &vec) { for (auto &it : vec) cout << it << " "; cout << endl; } 
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll qpow(ll base, ll n) { ll res = 1; while (n) { if (n & 1) res = res * base % mod; base = base * base % mod; n >>= 1; } return res; }
constexpr int N = 1e5 + 10;
int n, a[N], b[N], c[N]; 
void run() {
	for (int i = 1; i <= n; ++i) cin >> a[i];
	for (int i = 1; i <= n; ++i) cin >> b[i];
	for (int i = 1; i < n; ++i) cin >> c[i];
	int res = 0;
	for (int i = 1; i <= n; ++i) {
		res += b[a[i]];
		if (i > 1 && a[i] == a[i - 1] + 1)
			res += c[a[i - 1]];
	}
	cout << res << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	cout << fixed << setprecision(20);
	while (cin >> n) run();
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int H , W;
  while(1){
    cin >> H >> W;
    if (H == 0 && W == 0) break;
    
    for (int i = 0; i < H; i++ ){
      for (int j = 0; j < W; j++ ) {
        cout << "#";
      }
      cout << "\n";
    }
    cout << endl;
  }
  
    return 0;
}


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


int main() {
int A,B,C;
cin >> A >> B >> C;
if (A == 5 && B == 5 && C == 7 || A == 5 && B == 7 && C == 5 || A == 7 && B == 5 && C == 5) {
    cout << "YES" << endl;

} else cout << "NO" << endl;




return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N,kazu,naga,onp;
char moto[50],saga[150];
int main(){
    cin>>N;
    scanf("%s",&moto);
    onp=strlen(moto);
    for(int i=0;i<N;i++){
        scanf("%s",saga);
        naga=strlen(saga);
        for(int j=0;j<naga;j++){
            int aho=0;
            if(saga[j] == moto[0]){
                for(int k=1;k<naga;k++){
                    for(int l=1;l<naga;l++){
                        if(j+(k*l)>=naga)break;
                        if(saga[j+(k*l)]!=moto[l])break;
                        if(l==onp-1){
                            kazu++;
                            aho=1;
                        }if(aho==1)break;
                    }if(aho==1)break;
                }if(aho==1)break;
            }if(aho==1)break;
        }
    }
    cout<<kazu<<endl;
}

Measured memory_bytes: 3152
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll A, ll B) {
  cout << (A+B)%24 << endl;
}

int main() {
  ll A;
  cin >> A;
  ll B;
  cin >> B;
  solve(A, B);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
#include <algorithm>
#include <numeric>
//#include <queue>
//#include <math.h>
#include <vector>
//#include <string>
//typedef long long LL;
using namespace std;

int main(){
    int n;
    int tmp;
    int ans;
    vector<int> a;
    vector<int> b;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> tmp;
        a.push_back(tmp);
        b.push_back(0);
    }    
    for(int i=n-1; i>=0; i--){
        ans = 0;
        for(int j=i; j<n; j=j+(i+1)){
            ans += b[j];
        }
        if(a[i]==1 && ans%2==0){
            b[i]=1;
        }else if(a[i]==0 && ans%2==1){
            b[i]=1;
        }
    }
    ans = accumulate(b.begin(),b.end(),0);
    cout << ans << endl;
    for(int i=0; i<n; i++){
        if(b[i]==1){
            cout << (i+1) << " ";
        }
    }
    if(ans!=0){
        cout << endl;
    }
}

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

using ll = long long;

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)

using namespace std;

//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);

void solve()
{
    int n, a, b;
    cin >> n >> a >> b;
    int ans = min(a*n, b);
    cout << ans << "\n";
}

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

Measured memory_bytes: 384
def check(a, b, c, s):
    if((s[a]!=s[b])and(s[a]!=s[c])and(s[b]!=s[c])):
        return True
    else:
        return False

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

    n_r = 0
    n_g = 0
    n_b = 0

    for i in range(n):
        if(s[i]=='R'):
            n_r = n_r + 1
        elif(s[i]=='G'):
            n_g = n_g + 1
        elif(s[i]=='B'):
            n_b = n_b + 1

    ans = n_r * n_g * n_b

    for i in range(n-2):
        for j in range(i,n-1):
            k = 2*j - i
            if((j<k<n)and(check(i,j,k,s))):
                ans = ans - 1

    print(ans)

main()


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

int main()
{
	string str;
	while (getline(cin, str)) {
		if (str == ".") {
			break;
		}
		stack<char> s;
		bool balanced = true;
		for (int i = 0; i < str.length(); ++i) {
			char c = str[i];
			switch (c) {
				case '(':
				case '[':
					s.push(c);
					break;
				case ')':
				case ']':
					if (s.empty()) {
						balanced = false;
					} else {
						char open = c == ')' ? '(' : '[';
						if (s.top() != open) {
							balanced = false;
						}
						s.pop();
					}
					break;
				default:
					break;
			}
		}
		if (!s.empty()) {
			balanced = false;
		}
		cout << (balanced ? "yes" : "no") << endl;
	}
}

Measured memory_bytes: 1176
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> d(n, 0);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    d[--a]++;
    d[--b]++;
  }
  for (int i = 0; i < n; ++i) cout << d[i] << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100000

int partition(int*,int,int);


int main(){
  
  int A[N];
  int n, q;
  int i;
  
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
  q = partition(A, 0, n-1);

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

  return 0;
}

int partition(int A[], int p, int r){
  
  int x;
  int i, j;
  int t;
  
  x = A[r];
  i = p - 1;
  
  for ( j = p; j < r; j++ ){
    
    if ( A[j] <= x ){
      
      i++;
      
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  t = A[i+1];
  A[i+1] = A[r];
  A[r] = t;
  
  return i+1;
}

Measured memory_bytes: 996
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int n;
	cin>>n;
	for(int i=1; i<10; i++){
		for(int j=1; j<10; j++){
			if(n==j*i){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
typedef priority_queue<p> pq;
typedef priority_queue<p, vector<p>, greater<p>> gpq;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);

    double a, b, x;
    cin >> a >> b >> x;

    double a2, b2;
    if(2 * x >= a * a * b)
    {
        a2 = b - x / (a * a);
        b2 = a / 2;
    }
    else
    {
        a2 = b;
        b2 = 2 * x / (a * b);
    }
    
    double radian = atan(a2 / b2);
    double degree = radian * 180.0 / PI;

    cout << degree << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	int a,b,c;
	int ans=0;
	
	cin>>a>>b>>c;
	if(a+b==c || b+c==a || a+c==b)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <string>
#include <string.h>

using namespace std;

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

    size_t i = 0;
    while (i < S.size()) {
        if (strncmp(S.c_str() + i, "dreamera", 8) == 0) { // dream
            i += 5;
        } else if (strncmp(S.c_str() + i, "dreamer", 7) == 0) {
            i += 7;
        } else if (strncmp(S.c_str() + i, "eraser", 6) == 0) {
            i += 6;
        } else if (strncmp(S.c_str() + i, "dream", 5) == 0 || strncmp(S.c_str() + i, "erase", 5) == 0) {
            i += 5;
        } else {
            break;
        }
    }

    cout << (i == S.size() ? "YES" : "NO") << endl;

    return 0;
}

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

int main() {
	ll n;
	cin >> n;
	vector<P> ab(n);
	rep(i,n) {
		cin >> ab[i].second >> ab[i].first;
	}
	sort(ab.begin(),ab.end());
	ll time = 0;
	int ju = 1;
	for(auto p:ab){
		time += p.second;
		if(time > p.first){
			ju = 0;
			break;
		}
	}
	if(ju) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 1792
N = int(input())
S = input()

MOD = 2 ** 61 - 1
root = 10000

rhs = [0]
for h in map(ord, S):
    rhs.append((root * rhs[-1] + h) % MOD)

pws = [1]
for i in range(N):
    pws.append(pws[-1] * root % MOD)

ok = 0
ng = N
while ng - ok > 1:
    mid = (ok + ng) // 2
    hashes = dict()
    flg = False
    for i in range(N - mid + 1):
        hashofsub = (rhs[i+mid] - rhs[i] * pws[mid]) % MOD
        if hashofsub in hashes:
            if i >= hashes[hashofsub] + mid:
                flg = True
                break
        else:
            hashes[hashofsub] = i
    
    if flg:
        ok = mid
    else:
        ng = mid

print(ok)

Measured memory_bytes: 10224
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <iomanip>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define ls ro<<1
#define fi first
#define se second
#define rs ro<<1|1
#define ll long long
#define pb push_back
#define vi vector<int>
#define lowbit(x) x&(-x)
#define pii pair<int,int>
#define lson ro<<1,l,mid
#define umap unordered_map
#define uset unordered_set
#define rson ro<<1|1,mid+1,r
#define mem(a,b) memset(a,b,sizeof(a))
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);

using namespace std;

const int INF = 0x3f3f3f3f;
const int N=1e5+10;


int a[N],b[N],f[N];
int main() {
	IOS;
	int h,n;
	cin>>h>>n;
	mem(f,INF);
	int ma=-INF;
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
		ma=max(ma,a[i]);
	}
	f[0]=0;
	for(int i=0;i<n;i++){
		for(int j=a[i];j<=h+ma;j++){
			f[j]=min(f[j],f[j-a[i]]+b[i]);
		}
	}
	int ans=INF;
	for(int i=h;i<=h+ma;i++)
		ans=min(ans,f[i]);
	cout<<ans<<endl;
	







	return 0;
}


Measured memory_bytes: 640