akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n); for(ll i = 0; i < (ll)n; i++)

int main() {
  ll n,m; cin >> n >> m;
  vector<bool> b(n,true);
  vector<ll> ans(n,0);
  
  rep(j, m){
    ll s,c; cin >> s >> c;
    if(n != 1 && s == 1 && c == 0){
      cout << -1 << endl; return 0;}
    if(b[s-1]){
      b[s-1] = false; ans[s-1] = c;}
    else if(!b[s-1] && ans[s-1] != c){
      cout << -1 << endl; return 0;}
  }
  
  if(n == 2 && ans[n-2]==0)
    ans[n-2]++;
  if(n == 3 && ans[n-3]==0)
    ans[n-3]++;
  rep(i, n)
    cout << ans[i];
  cout << endl;
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif
vector<int> getDivisors(int n) 
{   
    vector<int>v;
    for (int i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            if (n/i == i){
                v.push_back(i);
            }else{
                 v.push_back(i);
                 v.push_back(n/i);
            }
        } 
    }
    return v; 
}
bool check(int x,int y){
    if(y == 1) return false;
    while(x % y == 0){
        x /= y;
    }
    return x%y == 1;
} 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<int>v = getDivisors(n-1);
    int x = getDivisors(n-1).size() - 1;
    int y = 0;
    for(int i=1;i*i<=n;i++){
        if(n % i == 0){
            if(n / i == i){
                y += check(n,i);
            }else{
                y += check(n,i);
                y += check(n, n / i);
            }
        }
    }
    cout<<x+y;
    return 0;
    
}



Measured memory_bytes: 256
/*#include <bits/stdc++.h>
using namespace std;
string ans,s[3055][3055],s1,s2;
int dp[3055][3055],n,m,ma;
int main()
{

    cin>>s1>>s2;
    if (s1.size()>s2.size()) swap(s1,s2);
    n=s1.size();
    m=s2.size();
    for (int i=0;i<n;i++)
    {
        for (int j=0;j<m;j++)
        {
            dp[i+1][j+1]=dp[i][j+1];
            s[i+1][j+1]=s[i][j+1];
            if (s1[i]==s2[j])
            {
                    dp[i+1][j+1]++;
                    s[i+1][j+1]=s[i+1][j+1]+s1[i];
            }
            if (dp[i+1][j+1]<=dp[i+1][j])
            {
                s[i+1][j+1]=s[i+1][j];
                dp[i+1][j+1]=dp[i+1][j];
            }
            //cout<<s[i+1][j+1]<<dp[i+1][j+1]<<" ";
        }

    }
    for (int i=0;i<=m;i++)
    {
        if (dp[n][i]>ma)
        {
            ma=dp[n][i];
            ans=s[n][i];
        }
    }
    cout<<ans;
}*/
#include<bits/stdc++.h>
using namespace std;
int n;
bool vis[3009][3009];
long double p[3009],dp[3009][3009],ans;
int main()
{

    cin>>n;
    for (int i=0;i<n;i++)
    {
        cin>>p[i];
    }
    dp[0][0]=1-p[0];
    dp[0][1]=p[0];
    vis[0][0]=true;
    vis[0][1]=true;
    for (int i=1;i<n;i++)
    {
        for (int j=0;j<=i+2;j++)
        {
            if (j==0) dp[i][j]=dp[i-1][j]*(1-p[i]);
            else dp[i][j]=dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i];
        }
    }
    for (int i=n/2+1;i<=n;i++)
    {
       ans+=dp[n-1][i];
    }
    cout<<fixed<<setprecision(15)<<ans;
}


Measured memory_bytes: 141696
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
    int a,b,k,m;
    scanf("%d %d",&a,&b);
    m=abs(a-b) % 2;
    if(m==1){
        printf("IMPOSSIBLE");
        return 0;
    };
    k=(a+b)/2;
    printf("%d",k);
    return 0;
};

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

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

  int min=10010;

  int arr[n+10];

  int s1=n/2;
  int s2=(n/2);

  bool bolehloop=false;


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

  for(int i=0;i<n;i++){
    int Total=0,Total1=0;
    if(bolehloop==false){
      if(s1==0){
        bolehloop=true;
      }  
      for(int j=0;j<=s1;j++){
        Total+=arr[j];
      }
      for(int j=s1+1;j<n;j++){
        Total1+=arr[j];
      }
      if(abs(Total-Total1)<=min){
        min=abs(Total-Total1);
      }
      s1--;
    }
    Total=0;
    Total1=0;
    if(bolehloop==true){
      for(int j=0;j<=s2;j++){
        Total+=arr[j];
      }
      for(int j=s2+1;j<n;j++){
        Total1+=arr[j];
      }
      if(abs(Total-Total1)<min){
        min=abs(Total-Total1);
      }
      s2++;
    }
  }

  cout << min << endl;

}

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

int main() {
  	int c;
	string a;
  	cin >> a;
  	if(a[0] == '1')
      c++;
  	if(a[1] == '1')
      c++;
  	if(a[2] == '1')
      c++;
  	cout << c;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int c[3][3];
  REP(i, 3)REP(j, 3)cin>>c[i][j];
  bool ans=true;
  REP(i, 2){
    if(c[0][0] -c[i+1][0] != c[0][1]-c[i+1][1]) ans=false;
    if(c[0][0] -c[i+1][0] != c[0][2]-c[i+1][2]) ans=false;
  }
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;


  return 0;
}


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

int main() {
  int A, B, C, X;
  scanf("%d",&A);
  scanf("%d",&B);
  scanf("%d",&C);
  scanf("%d",&X);
  int ans=0;
  for (int i=0; i<=A; i++) {
    for (int j=0; j<=B; j++) {
      for (int k=0; k<=C; k++) {
        if (500*i+100*j+50*k==X) {
          ans++;
        }
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}



Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;


fn main() {
  let s = read::<String>();
  let mut dist: HashMap<char, i64> = HashMap::new();

  for c in s.chars() {
    let current = dist.entry(c).or_insert(0);
    *current += 1;
  }

  if dist.len() == 3
    && dist.get(&'a').unwrap() == &1
    && dist.get(&'b').unwrap() == &1
    && dist.get(&'c').unwrap() == &1
  {
    println!("Yes");
  } else {
    println!("No");
  }
}



Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int n,a;
    cin>>n>>a;
    cout<<n*n-a<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
	    Scanner std = new Scanner(System.in);
	    int time = Integer.parseInt(std.next());
	    int s = time%60;
	    int m = (time / 60) % 60;
	    int h = (time / 3600);
	    System.out.println(h+":"+m+":"+s);
	}
}

Measured memory_bytes: 25980
N, M = map(int, input().split())

if N % 2 == 0:
    N -= 1

li = []
i, j = 1, (N + 1) // 2
while i < j:
    li.append((i, j))
    i += 1
    j -= 1
i, j = N, (N + 3) // 2
while i > j:
    li.append((j, i))
    i -= 1
    j += 1

for m in range(M):
    print(li[m][0], li[m][1])

Measured memory_bytes: 74076
#include<stdio.h>
long long gcd(long long a,long long b)
{
	return b?gcd(b,a%b):a;
}
long long lcm(long long a,long long b)
{
	return a/gcd(a,b)*b;
}

long long n,x,y,t;
int main()
{
	scanf("%lld%lld",&n,&x);
	n--;
	while(n--)
	{
		scanf("%lld",&y);
		x=lcm(x,y);
	}
	printf("%lld\n",x);
}


Measured memory_bytes: 128
h,w = map(int,input().split())
si = [input() for i in range(h)]

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.size = [1 for _ in range(n+1)]
 
    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
 
    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
 
    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)
    
ki = UnionFind(h*w)

vx = [0,1,0,-1]
vy = [1,0,-1,0]

for i in range(h):
    for j in range(w):
        if si[i][j] == '#':
            for k in range(4):
                ny = i + vy[k]
                nx = j + vx[k]
                if ny >= 0 and ny < h and nx >= 0 and nx < w:
                    if si[ny][nx] == '.':
                        #if ki.same_check(i*w+j,ny*w+nx) == True:
                        #    continue
                        ki.union(i*w+j,ny*w+nx)
ans = 0

li = [0]*(h*w+1)

for i in range(h):
    for j in range(w):
        if si[i][j] == '.':
            li[ki.find(i*w+j)] += 1

for i in range(h):
    for j in range(w):
        if si[i][j] == '#':
            ans += li[ki.find(i*w+j)]
            
print(ans)

Measured memory_bytes: 67592
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

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

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
    double a, b, c ,d, ans;
    scanf("%lf%lf%lf%lf", &a, &b, &c, &d);
    printf("%.15f\n", sqrt((a-c)*(a-c)+(b-d)*(b-d)));
    return 0;
}



Measured memory_bytes: 2744
$n = <>;
if($n < 10){
	print $n;
}elsif($n < 100){
	print 9;
}elsif($n < 1000){
	print $n-99+9;
}elsif($n < 10000){
	print 909;
}elsif($n < 100000){
	print $n-9999+909;
}else{
	print 90909;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	ll N; cin >> N;
	ll now = 1;
	for (int i = 0; i < N;i++) {
		ll T; cin >> T;
		now = lcm(now, T);
	}
	cout << now << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;

#define rep(i,s,n) for(ll (i)=(s);(i)<(n);(i)++)
#define repd(i,s,n) for(ll (i)=(n-1);(i)>=(s);(i)--)
#define FOR(i,s,n) for(ll (i)=(s);(i)<=(n);(i)++)
#define all(x) x.begin(),x.end()
#define size(x) ((ll)(x).size()
#define PB push_back

int main(){
   ll n;
   int count = 0;
   string s;
   cin >> n >> s;
   
   FOR(i,1,n){
       if(s[i]!=s[i-1])
          count++;
       
   }
   cout << count << endl;

   return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  int n;
  scanf("%d",&n);
  std::vector<int > p(n);
  for (int i=0; i<n; i++){
    scanf("%d",&p[i]);
  }
  int ans = 0;
  for (int i=1; i<n-1; i++){
    if (((p[i-1]<p[i])&&(p[i]<p[i+1])) ||
        ((p[i-1]>p[i])&&(p[i]>p[i+1])) ){
      ans++;
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::string S;
  std::cin >> N >> S;

  i64 answer = 0;
  for (i64 i = 1; i < N; ++i) {
    const std::string X = S.substr(0, i);
    const std::string Y = S.substr(i, N - i);
    std::set<char> X_set(X.begin(), X.end());
    std::set<char> Y_set(Y.begin(), Y.end());
    std::set<char> intersection;
    std::set_intersection(X_set.begin(), X_set.end(), Y_set.begin(), Y_set.end(), std::inserter(intersection, intersection.end()));
    answer = std::max<i64>(answer, intersection.size());
  }

  std::cout << answer << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

string a, b;

int main() {

	cin >> a >> b;

	string ans = "No";
	int c = stoi(a + b);
	
	if (sqrt(c) == int(sqrt(c))) {
		ans = "Yes";
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Arrays;
import java.util.Collections;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> timelist = new ArrayList<>();
        ArrayList<Integer> firstdigits = new ArrayList<>();
        int tempval = 0;
        int amountOfTime = 0;
        boolean lastOrder = false;
        int lastOrderTime = 0;
        
        for(int i=0; i<5; i++){
            tempval = sc.nextInt();
            firstdigits.add(tempval%10);
            timelist.add(tempval);
        }
        Collections.sort(firstdigits);
        
        loop:for(int i=0; i<5; i++){
            if(firstdigits.get(i)!=0){
                lastOrderTime = firstdigits.get(i);
                break loop;
            }        
        }
        
        for(int i=0; i<5; i++){
            if(lastOrder==false && (timelist.get(i)%10==lastOrderTime)){
                lastOrder = true;
                amountOfTime += timelist.get(i);
            }
            else if(timelist.get(i)%10!=0){
                amountOfTime += (timelist.get(i) + (10-timelist.get(i)%10));
            }
            else{
                amountOfTime += timelist.get(i);
            }
        }
        System.out.println(amountOfTime);
    }
}

Measured memory_bytes: 25172
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(void) {
	while(true) {
		int n, m;
		cin>>n>>m;
		if(n == 0 && m == 0) break;
		int s, g;
		cin>>s>>g;
		--s;
		--g;
		vector<vector<pair<ll, P> > > p(n);
		vector<vector<vector<double> > > d(n, vector<vector<double> >(n, vector<double>(31, INF)));
		REP(i, m) {
			int x, y, d, c;
			cin>>x>>y>>d>>c;
			--x;
			--y;
			p[x].pb({y, P(d, c)});
			p[y].pb({x, P(d, c)});
		}
		priority_queue<pair<pair<double, ll>, P>, vector<pair<pair<double, ll>, P> >, greater<pair<pair<double, ll>, P> > > q;
		d[s][s][1] = 0;
		q.push({{0, s}, {s, 1}});
		while(!q.empty()) {
			pair<pair<double, ll>, P> np = q.top();
			q.pop();
			if(d[np.first.second][np.second.first][np.second.second] != np.first.first) continue;
			FOR(i, -1, 2) {
				ll ns = np.second.second + i;
				if(np.first.second == s && np.second.first == s) {
					if(ns != 1) continue;
				}
				if(ns <= 0) continue;
				REP(j, p[np.first.second].size()) {
					ll next = p[np.first.second][j].first;
					if(next == np.second.first) continue;
					if(p[np.first.second][j].second.second < ns) continue;
					if(d[next][np.first.second][ns] > d[np.first.second][np.second.first][np.second.second] + p[np.first.second][j].second.first / (double)ns) {
						d[next][np.first.second][ns]  = d[np.first.second][np.second.first][np.second.second] + p[np.first.second][j].second.first / (double)ns;
						q.push({{d[next][np.first.second][ns], next}, {np.first.second, ns}});
					}
				}
			}
		}
		double ans = INF;
		REP(i, n) {
			ans = min(ans, d[g][i][1]);
		}
		if(ans != INF) cout<<fixed<<showpoint<<setprecision(39)<<ans<<endl;
		else cout<<"unreachable"<<endl;
	}
}

Measured memory_bytes: 3960
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void print() { cout << "\n"; }
template <class T, class... Args>
void print(const T &x, const Args &... args) { cout << x << " "; print(args...);}
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  cin >> n;
  vector<ll> a(n);
  unordered_map<ll, ll> mp;
  vector<ll> b(n), c(n);
  rep(i,n) {
    cin >> a[i];
    b[i] = a[i]-i;
    c[i] = -a[i]-i;
    debug(a[i]-i, -a[i]-i);
  }
  sort(all(c));
  rep(i,n) {
    int itr1 = lower_bound(all(c), b[i]) - c.begin();
    int itr2 = lower_bound(all(c), b[i]+1) - c.begin();
    // debug("a", itr2 - itr1, b[i]);
    if (itr2 - itr1 > 0) {
      if (mp.count(b[i]) == 0) mp[b[i]] = 0;
      mp[b[i]] += itr2 - itr1;
    }
  }
  ll ans = 0;
  for (auto p : mp) {
    ans += p.second;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 11452
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

int main(){
    int x,y,z,a,b,c;
    cin >> x >> y >> z;
    a = x;
    b = y;
    c = z;
    y = a;
    x = b;
    a = x;
    b = y;
    c = z;
    x = c;
    z = a;
    cout << x << ' ' << y << ' ' << z << endl;
    
}

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


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

   int digit[5];
   digit[0] = A % 10;
   digit[1] = B % 10;
   digit[2] = C % 10;
   digit[3] = D % 10;
   digit[4] = E % 10;

   int min = 10;
   int minDigit;
   for(int i = 0; i < 5; i++)
   {
       if(digit[i] == 0)continue;

       if(min > digit[i])
       {
           min = digit[i];
           minDigit = i;
       }
   } 

   
   for(int i = 0; i < 5; i++)
   {
       if(i == minDigit)continue;
       if(digit[i] == 0)continue;
       
       switch(i)
       {
           case 0:
           A += 10;
           A -= digit[0];
           break;

           case 1:
           B += 10;
           B -= digit[1];
           break;

           case 2:
           C += 10;
           C -= digit[2];
           break;

           case 3:
           D += 10;
           D -= digit[3];
           break;

           case 4:
           E += 10;
           E -= digit[4];
           break;
       }
   }

   cout << A + B + C + D + E << endl;

   
}




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


int main() {
    char c;
    cin >> c;
    string v="aeiou";
    if(v.find(c) != string::npos){
       cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }
    return 0;
}


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

using namespace std;

const int MAX = 1e4 + 9;
int digit[11] = {2, 5, 5, 4, 5, 6, 3, 7, 6}, dp[MAX], n, m;
vector<pair<int, int>> stick;

bool cmp(const pair<int, int> &a, const pair<int, int> &b) {
	if (a.first < b.first) {
		return true;
	} else {
		if (a.first == b.first) {
			if (a.second > b.second) return true;
			return false;
		}
		return false;
	}
}

void print_dp() {
	for (int i = 0; i <= n; i++) {
		cout << dp[i] << ' ';
	}
}

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

	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a;
		cin >> a; 
		stick.push_back(make_pair(digit[a-1], a));
	}
	sort(stick.begin(), stick.end(), cmp);
	dp[0] = 1;
	for (int i = 0; i <= n; i++) {
		for (auto p : stick) {
			if (i - p.first < 0) continue;
			if (dp[i - p.first] > 0) dp[i] = max(dp[i], dp[i - p.first] + 1);
			//print_dp();
			//int n;
			//cin >> n;
		}
	}
	int len = dp[n];
	string s;
	while (n) {
		vector<int> tmp;
		for (auto p : stick) {
			if (n - p.first < 0) continue;
			if (dp[n - p.first] == len - 1) {
				tmp.push_back(p.second);
			}
		}
		sort(tmp.begin(), tmp.end());
		reverse(tmp.begin(), tmp.end());
		s.push_back(tmp[0] + '0');
		n -= digit[tmp[0] - 1];
		len--;
	}
	cout << s << '\n';
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  int N;
  int A;
  int B;
  cin >> N>>A>>B;
  int y=N*A;
  cout<< min(y,B) << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
o =a[::2]
e =a[1::2]
if len(a)%2==0:
    ans = e[::-1]+o
elif len(a)==1:
    ans = a
else:
    ans = o[::-1]+e
print(' '.join(map(str,ans)))

Measured memory_bytes: 31172
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;

public class Main {
	public static void main(String[] args) {
		FastReader r = new FastReader();		
		int[] arr = r.ria();
		int[][] pairs = new int[arr[1]][2];
		for(int i = 0;i<pairs.length; i++)
			pairs[i] = r.ria();
		Map<Integer,Integer> map = new TreeMap<>();
		for(int i = 0; i<pairs.length; i++)
		{
			if(pairs[i][0] == pairs[i][1]) continue;
			map.put(pairs[i][0], map.getOrDefault(pairs[i][0], 0)+1);
			map.put(pairs[i][1], map.getOrDefault(pairs[i][1], 0)+1);
		}
		for(int i = 1; i<=arr[0]; i++)
			print(map.getOrDefault(i, 0));
	}

	public static void rolling(int[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}
	
	public static void rolling(long[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}

	public static void reverse(int[] arr) {
		for (int i = 0; i < arr.length / 2; i++) {
			int temp = arr[i];
			arr[i] = arr[arr.length - 1 - i];
			arr[arr.length - 1 - i] = temp;
		}
	}
	
	public static String al(String s) {
		return s + "\n";
	}

	public static void print(String s) {
		System.out.println(s);
	}

	public static void print(long s) {
		System.out.println(s);
	}

	public static void print(int s) {
		System.out.println(s);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		int ri() {
			return Integer.parseInt(str());
		}

		long rl() {
			return Long.parseLong(str());
		}

		double rd() {
			return Double.parseDouble(str());
		}

		String str() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		String[] rsa() {
			return str().split(" ");
		}

		int[] ria() {
			String[] s = rsa();
			int[] arr = new int[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(s[i]);
			return arr;
		}

		long[] rla() {
			String[] s = rsa();
			long[] arr = new long[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(s[i]);
			return arr;
		}

		char[] rca() {
			String s = str();
			char[] arr = new char[s.length()];
			for (int i = 0; i < arr.length; i++)
				arr[i] = s.charAt(i);
			return arr;
		}
		
		String[] rsaml(int m) {
			String[] arr = new String[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = str();
			return arr;
		}

		int[] riaml(int m) {
			int[] arr = new int[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(str());
			return arr;
		}

		long[] rlaml(int m) {
			long[] arr = new long[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(str());
			return arr;
		}
	}
}

class Node {
	public int val;
	public boolean visited;
	public Node(int v) { val=v; }
}

Measured memory_bytes: 21332
n, k = map(int, input().split(" "))
ps = list(map(int, input().split(" ")))
k_sum = sum(ps[:k])
tmp_max = k_sum

for next_idx in range(k, n):
    rm = next_idx - k
    val_rm = ps[rm]
    val_add = ps[next_idx]
    k_sum = k_sum - val_rm + val_add
    tmp_max = max(tmp_max, k_sum)
print((tmp_max + k) / 2)



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


int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		vector<int>vs(N);
		for (int i = 0; i < N; ++i)cin >> vs[i];
		int K; cin >> K;
		int amin = 0;
		int amax = N-1;
		int ans = 0;
		while (amin <=amax) {
			ans++;
			const int amid = (amin + amax) / 2;
			if (vs[amid] < K) {
				amin = amid+1;
			}
			else if (vs[amid] == K) {
				break;
			}
			else {
				amax = amid-1;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<=k;i++)
using namespace std;
int main(){
    long long n,m,ans=0;
    cin>>n>>m;
    f(i,m,n+1){
        ans+=i*(n-i+1)+1;
    }
    cout<<ans%1000000007<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define N 100005
using namespace std;
int n,dp[N],h[N],s,cm;
vector<int> g[N];
void dfss(int p,int curr)
{
    if(cm<h[curr])
        cm=h[curr],s=curr;
    for(auto &it : g[curr])
        if(it!=p){
            h[it]=h[curr]+1;
            dfss(curr,it);
        }
}
int dfs(int p,int curr)
{
    int res=0,ct=0;
    if(p!=0&&g[curr].size()==1)
        return 0;
    for(auto &it : g[curr]){
        if(it!=p){
            int t=dfs(curr,it);
            res+=t;
            if(!t)
                ct++;
        }
    }
    if(p!=0){
        /*if(g[curr].size()-2&&g[curr].size()-2-ct>0){
            printf("%d : %d %d\n",curr-1,res,res+g[curr].size()-2-ct);
            return res+g[curr].size()-2-ct;
        }
        printf("%d : %d nominus \n",curr-1,res);
        return res;*/
        return res+max(0,ct-1);
    }
    //printf("%d : %d\n",curr-1,res+1);
    return res+1;
    //return res+g[curr].size()-1;
}
int main()
{
    scanf("%d",&n);
    for(int i=2;i<=n;i++){
        int x,y;
        scanf("%d %d",&x,&y);
        x++;y++;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    dfss(0,1);
    printf("%d",dfs(0,s));
    return 0;
}

Measured memory_bytes: 12416
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
int main() {
    int N, ans = 0;
    cin >> N;
    vector<int> h(N);
    for (auto& i : h) cin >> i;
    while (any_of(h.begin(), h.end(), [](int i) { return i != 0; })) {
        int t = (h[0] > 0);
        for (int i = 1; i < N; i++) if (h[i] > 0 && h[i - 1] == 0) t++;
        ans += t;
        for (int i = 0; i < N; i++) if (h[i] > 0) {
            h[i]--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mk make_pair
using namespace std;
const int N = 4e4 + 5;
int n, m, cnt; 
struct line {
	long double a, b, c;
	line() {}
	void input() {
		scanf("%LF %LF %LF", &a, &b, &c);
	}
	long double calx(long double x) {
		return (c - a * x) / b;
	}
	long double caly(long double y) {
		return (c - b * y) / a;
	}
	bool operator < (const line &l) const {
		return a / -b < l.a / -l.b;
	}
} L[N];
bool cmp(line A, line B) {
	return A.b / -A.a < B.b / -B.a;
} 
long double V[N];
int B[N];
inline void Ins(int x) {
	if (x <= 0) return;
	while (x <= n) {
		++B[x];
		x += x & -x;
	}
}
inline int Query(int x) {
	int res = 0;
	while (x) {
		res += B[x];
		x -= x & -x;
	}
	return res;
}
int check(long double x) {
	int res = 0;
	for (int i = 0; i <= n; i++) B[i] = 0;
	for (int i = 1; i <= n; i++) V[i] = L[i].calx(x);
	sort(V + 1, V + 1 + n);
	m = unique(V + 1, V + 1 + n) - V - 1;
	for (int i = 1; i <= n; i++) {
		int p = lower_bound(V + 1, V + 1 + m, (L[i].calx(x))) - V;
		res += Query(p);
		Ins(p);
	} 
	return res;
}
int check1(long double y) {
	int res = 0;
	for (int i = 0; i <= n; i++) B[i] = 0;
	for (int i = 1; i <= n; i++) V[i] = L[i].caly(y);
	sort(V + 1, V + 1 + n);
	m = unique(V + 1, V + 1 + n) - V - 1;
	for (int i = 1; i <= n; i++) {
		int p = lower_bound(V + 1, V + 1 + m, (L[i].caly(y))) - V;
		res += Query(p);
		Ins(p);
	} 
	return res;
}
int main() {
	cin >> n;
	cnt = n * (n - 1) / 2;
	cnt = (cnt + 1) / 2;
	for (int i = 1; i <= n; i++) 
		L[i].input();
	sort(L + 1, L + 1 + n);
	long double mid, l = -2e8, r = 2e8;
	while (r - l > 1e-11) {
		mid = (l + r) / 2;
		if (check(mid) >= cnt)
			r = mid;
		else
			l = mid;
	}
	printf("%.13f ", (double)l);
	sort(L + 1, L + 1 + n, cmp);
	l = -2e8, r = 2e8;
	while (r - l > 1e-11) {
		mid = (l + r) / 2;
		if (check1(mid) >= cnt)
			r = mid;
		else
			l = mid;
	}
	printf("%.13f ", (double)l);
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,l,r,mx=-1,mn=2000000,i,a=0;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>l>>r;
        mx=max(mx,l);
        mn=min(mn,r);
    }
    cout<<(mn<mx?a:mn-mx+1)<<endl;
}


Measured memory_bytes: 3584
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include <fstream>
using namespace std;
typedef long long ll;
const ll INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int mod = 1e9+7;
const int maxn = 2000005;
int T,n,m;
ll fac[maxn],inv[maxn];
ll pow_mod(ll a,ll n)
{
    ll ret =1;
    while(n)
    {
        if(n&1) ret=ret*a%mod;
          a=a*a%mod;
          n>>=1;
    }
    return ret;
}
void init()
{
    fac[0]=1;
    for(int i=1;i<maxn;i++)
    {
        fac[i]=fac[i-1]*i%mod;
    }
}
ll Cc(ll x, ll y)
{
    return fac[x]*pow_mod(fac[y]*fac[x-y]%mod,mod-2)%mod;
}
int main() { 
	cin>>n>>m;
	init();
	if((n+m)%3==0&&n>=((n+m)/3)&&m>=((n+m)/3)){
		int x = (n+m)/3;
		int y = n-x;
		cout<<Cc(x,y)<<endl;
		
	}
	else {
		cout<<0<<endl;
	}
    return 0;
}



Measured memory_bytes: 17152
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>
#include <random>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

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

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

random_device seed_gen;
mt19937 engine(seed_gen());
// 0, 1, 2 のどれかが得られる一様分布
// uniform_int_distribution<> dist(0, 2);
// cout << dist(engine) << endl;
// みたいに、先に確率分布を宣言して、そこにengineを与えて使う。

// =========ここまでテンプレ============

int main()
{
  vector<bool> aho(60000000000);
    ll n, x, t;
    cin >> n >> x >> t;
    ll m = n / x;
    if (n % x != 0)
    {
        ++m;
    }
    cout << t * m << endl;
    return 0;
}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char s;
	int m,n,t;
	cin>>m>>n;
	int a[m][n],b[m]={0};
	for(int i=0;i<m;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>s;
			if(s=='#') a[i][j]=0;
			else a[i][j]=1;
		}
	}
	for(int i=0;i<m;i++)
	{
		t=0;
		for(int j=0;j<n;j++)
		{if(a[i][j]==1) t++;}
		if(t==n)
		{
			for(int j=0;j<n;j++)
			{a[i][j]=2;}
			b[i]=1;
		}
	}
	for(int j=0;j<n;j++)
	{
		t=0;
		for(int i=0;i<m;i++)
		{if(a[i][j]==1||a[i][j]==2) t++;}
		if(t==m)
		{
			for(int i=0;i<m;i++)
			{a[i][j]=2;}
		}
	}
	for(int i=0;i<m;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(a[i][j]==0) cout<<"#";
			else if(a[i][j]==1) cout<<".";
		}
		if(b[i]==0) cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
import numpy as np

def main():
	n=int(input())
	A= np.array(read().split(), np.int64)
	nega=len(A[A<0])
	B=abs(A)
	ans=np.sum(B)
	
	if nega%2:
		ans-=2*np.min(B)
	
	print(ans)
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 18660
import std.stdio;
import std.conv;
import std.string;
import std.algorithm;
import std.range;
import std.functional;
import std.math;
import core.bitop;

void main()
{
    /// ABC089_D
    auto input = readln.chomp.split.to!(long[]);
    long a = input[0];
    long b = input[1];
    long k = input[2];

    if (b - a < k * 2)
    {
        foreach (i; iota(a, b).chain(only(b)))
            writeln(i);
    }
    else
    {
        foreach (i; a .. a + k)
            writeln(i);
        foreach (i; b - k .. b)
            writeln(i + 1);
    }

    // iota(min, max).chain(only(max));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t; int a,b; string u;
  cin >> s >> t >> a >> b >> u;
  if ( s == u ){
    cout << a-1 << " " << b << endl;
  }
  if ( t == u ){
    cout << a << " " << b-1 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define de cout<<"debuglandınız\n";
#define md 1000000007
ll int a;
double u;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >> a;
	u=((a+1)/2)/float(a);
	cout << u;
	return 0;
}

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

int main (){
    ll N;
    cin>>N;
    vector<vector<int>> Wood(N), Cost(N);
    for(int i=0; i<N-1; i++){
        ll A, B, C;
        cin>>A>>B>>C;
        A--;
        B--;
        C%=2;
        Wood.at(A).push_back(B);
        Wood.at(B).push_back(A);
        Cost.at(A).push_back(C);
        Cost.at(B).push_back(C);


    }
    queue<ll> Jun;
    vector<ll> Ans(N, -1);
    Ans.at(0)=0;
    Jun.push(0);
    while(!(Jun.size()==0)){
        ll Key=Jun.front();
        Jun.pop();
        for(int i=0; i<Wood.at(Key).size(); i++){
            if(Ans.at(Wood.at(Key).at(i))==-1){
                Jun.push(Wood.at(Key).at(i));
                Ans.at(Wood.at(Key).at(i))=(Ans.at(Key)+Cost.at(Key).at(i))%2;
            }
        }
    }
    for(int i=0; i<N; i++){
        cout<<Ans.at(i)<<endl;
    }

  
}




Measured memory_bytes: 12288
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mkp make_pair
#define rep(i,s,f) for(i=s;i<f;i++)
#define db cout<<'h'<<'i'<<endl 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 100005
#define lg 18
//<<fixed << setprecision(9)


ll EE(ll a, ll b, ll *x, ll *y)
{
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    ll x1, y1;
    ll gcd = EE(b%a, a, &x1, &y1); 
  
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
}

ll inverse(ll a, ll m)
{
    ll x,y;
    EE(a,m,&x,&y);
    if(x<0) x += m;
    return x;
}

ll choose(ll n,ll k)
{
	ll i;
	ll num=1,den=1;
	for(i=2;i<=k;i++)
	{
		den*=i;
		den%=mod;
	}
	for(i=n-k+1;i<=n;i++)
	{
		num*=i;
		num%=mod;
	}
	
	i=num*inverse(den,mod);
	i%=mod;
	return i;
}

int main()
{
    int n,i,j,t;
    boost;
    int k;
    cin>>n>>k;

    int l=n-k+1;

    rep(i,1,k+1)
    {
        if(i>l)cout<<"0\n";
        else
        {
            ll ans=choose(l,i)*choose(k-1,i-1);
            ans%=mod;
            cout<<ans<<'\n';
        }
    }

    return 0;
}



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

#define int ll
#define pb push_back
#define DBGB if (false)

using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;
using vi=vector<int>;
using vvi=vector<vi>;
using vpii=vector<pii>;
using vvpii=vector<vpii>;
using E=array<int,3>;
using ve=vector<E>;

template<typename A, typename B> ostream& operator<<(ostream& out, const pair<A, B>& p) { return out << "(" << p.first << ", " << p.second << ")"; }
template<typename Ch, typename Tr, typename C> basic_ostream<Ch, Tr>& operator<<(basic_ostream<Ch, Tr>& out, const C& xs) { out << "["; for (const auto& x: xs) out << x << ", "; out << "]"; }


const int MOD = 1e9 + 7;

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, k;
  cin >> n >> k;
  vi as(n);
  for (int i=0; i<n; ++i) {
    cin >> as[i];
  }
  int globinv = 0;
  for (int i=0; i<n; ++i) {
    int leearl=0;
    for (int j=0; j<i; ++j)
      leearl += (as[j] < as[i]);
    int lela=0;
    for (int j=i+1; j<n; ++j)
      lela += (as[j] < as[i]);
    DBGB { cerr << "DBG " << leearl << " " << lela << endl; }
    globinv += (k-1)*k/2%MOD*leearl;
    globinv %= MOD;
    globinv += (k+1)*k/2%MOD*lela;
    globinv %= MOD;
  }
  cout << globinv%MOD << endl;
}


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

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define MP make_pair
#define PB push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	VI h, w;
	while (true) {
		int x, y;
		cin >> x >> y;
		if (x == 0 && y == 0)break;
		h.PB(x); w.PB(y);
	}
	rep(i, SZ(h)) {
		int x = h[i], y = w[i];

		rep(j, x) {
			rep(k, y) {
				cout << "#";
			}
			puts("");
		}
		puts("");
	}
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int main(){
	int N;
	cin>>N;
	const int X = 100000;
	int cnt[X]={};
	rep(i,N){
		int x;
		cin>>x;
		cnt[x]++;
	}
	int ans = 0;
	rep(i,X-2){
		int tmp = cnt[i]+cnt[i+1]+cnt[i+2];
		ans = max(ans,tmp);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define MAX_N 201000

int bit[MAX_N], m;

int sum(int i){
	int sum = 0;
	while(i > 0){
		sum += bit[i];
		i -= i & -i;
	}
	return sum;
}

void add(int i, int x){
	while(i <= m){
		bit[i] += x;
		i += i & -i;
	}
}

int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	bool ok = true;
	rep(i, n){
		cin>>a[i];
		a[i]--;
		if(a[i]%3==1) ok = false;
		if(a[i]/3%2!=i%2) ok = false;
	}
	rep(i, n){
		int b;
		cin>>b;
		b--;
		if(a[i]/3!=b/3 || b%3!=1) ok = false;
	}
	rep(i, n){
		int c;
		cin>>c;
		c--;
		if(a[i]/3!=c/3) ok = false;
	}
	int o1 = 0, o2 = 0;
	rep(i, n){
		if(a[i]%3==2){
			if(i%2) o1 ^= 1;
			else o2 ^= 1;
		}
	}
	{
		m = n+10;
		ll r = 0;
		for(int i = 0; i < n; i+=2){
			cerr<<i<<endl;
			r += i/2-sum(a[i]/3+1);
			add(a[i]/3+1, 1);
		}
		o1 ^= r&1;
		r = 0;
		mset(bit, 0);
		for(int i = 1; i < n; i+=2){
			r += i/2-sum(a[i]/3+1);
			add(a[i]/3+1, 1);
		}
		o2 ^= r&1;
	}
	if(o1||o2) ok = false;
	//cerr<<o1<<" "<<o2<<endl;
	cout<<(ok?"Yes":"No")<<endl;
	return 0;
}


Measured memory_bytes: 1536
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
const int maxn = 107;
char s[maxn][maxn];
bool row[maxn], col[maxn];
int main(){
    int h, w;
    scanf("%d%d", &h, &w);
    for(int i = 1; i <= h; ++i){
        scanf("%s", s[i] + 1);
    }
    for(int i = 1; i <= h; ++i){
        for(int j = 1; j <= w; ++j){
            if(s[i][j] == '#'){
                row[i] = true;
                break;
            }
        }
    }
    for(int i = 1; i <= w; ++i){
        for(int j = 1; j <= h; ++j){
            if(s[j][i] == '#'){
                col[i] = true;
                break;
            }
        }
    }
    for(int i = 1; i <= h; ++i){
        if(!row[i])continue;
        for(int j = 1; j <= w; ++j){
            if(!col[j])continue;
            printf("%c", s[i][j]);
        }
        printf("\n");
    }
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 100005;
struct Edge{
	int to,next;
}e[MAXN<<1];
int head[MAXN],cnt,s[MAXN],n,m,sx,sy,fa[MAXN];
inline void insert(int u,int v)
{
	e[++cnt].to=v,e[cnt].next=head[u],head[u]=cnt;
	e[++cnt].to=u,e[cnt].next=head[v],head[v]=cnt;
}
int color[MAXN],t[MAXN],tot;
int dep[MAXN];
inline void bicolor(int x,int fa)
{
	tot+=color[x];	
	for(int i=head[x];i;i=e[i].next){
		int v=e[i].to;
		if(v==fa)continue;
		dep[v]=dep[x]+1;
		color[v]=-color[x];
		bicolor(v,x);
	}
}
int ans=0;
void solve(int x,int fa)
{
	for(int i=head[x];i;i=e[i].next){
		int v=e[i].to;
		if(v==fa)continue;
		solve(v,x);
		color[x]+=color[v];
	}
}
int k[MAXN];
void getk(int x,int fa)
{
	for(int i=head[x];i;i=e[i].next){
		int v=e[i].to;
		if(v==fa)continue;
		getk(v,x);
		k[x]+=k[v];
	}
}
inline int getan(int x)
{
	return x==fa[x]?x:fa[x]=getan(fa[x]);
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)fa[i]=i;
	for(int i=1,u,v,x,y;i<=m;++i){
		scanf("%d%d",&u,&v);
		x=getan(u),y=getan(v);
		if(x!=y){
			fa[x]=y;
			insert(u,v);
		}else{
			sx=u,sy=v;
		}
	}
	color[1]=1;
	bicolor(1,0);
	if(m==n-1){
		if(tot){puts("-1");return 0;}
		else{
			solve(1,0);
			for(int i=1;i<=n;++i)
				ans+=abs(color[i]);
			cout<<ans<<endl;
		}
	}else{
		int size=abs(dep[sx]-dep[sy])+1;
		if(size&1){
			if(tot%2){puts("-1");return 0;}
			else{
				color[sx]+=-tot/2,color[sy]+=-tot/2;
				solve(1,0);
				for(int i=1;i<=n;++i)
					ans+=abs(color[i]);
				cout<<ans+abs(tot/2)<<endl;
			}
		}else{
			if(tot){puts("-1");return 0;}
			k[sx]=-1,k[sy]=1;
			getk(1,0);		  
			solve(1,0);
			for(int i=1;i<=n;++i){
				if(!k[i])ans+=abs(color[i]);
				else{
					t[++tot]=-k[i]*color[i];
				}
			}
			sort(t+1,t+tot+1);
			int x=t[(tot+1)/2];
			for(int i=1;i<=n;++i){
				if(k[i])ans+=abs(k[i]*x+color[i]);
			}
			cout<<ans+abs(x)<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    ll A,B,C;
    cin >> A >> B >> C;

    ll ans = B;

    if (A+B+1 >= C) {
        ans += C;
        cout << ans << endl;
        return;
    } else {
        ans += A + B + 1;
        cout << ans << endl;
    }


    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256