akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<bool> dp(k + 1, false);
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    for (int i = 0; i <= k; i++) {
        bool ok = false;
        for (int j = 0; j < n; j++) {
            if (i < a[j]) break;
            if (!dp[i - a[j]]) {
                ok = true;
                break;
            }
        }
        dp[i] = ok;
    }
    if (dp[k]) {
        cout << "First" << endl;
    } else {
        cout << "Second" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = (a);i < (b);++i)
#define FORR(i, b, a) for (int i = (b) - 1;i >= 0;--i)
#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = (n) - 1;i >= 0;--i)
#define ITER(itr, v) for(auto itr = v.begin();itr != v.end();++itr)
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

template<int p = 1000000007>
class Z {
	ll x;
public:
	Z(ll X) :x((X + p) % p) { ; }
	Z() :x(0) { ; }
	Z &operator=(ll y) { return *this = Z(y); }
	Z operator-() const { return Z(-x); }
	Z operator+(ll y) const { return Z(x + y); }
	Z &operator+=(ll y) { return *this = *this + y; }
	Z operator-(ll y) const { return Z(x - y); }
	Z &operator-=(ll y) { return *this = *this - y; }
	Z operator*(ll y) const { return Z(x * y); }
	Z &operator*=(ll y) { return *this = *this * y; }
	Z operator/(ll y) const { return *this * Z(y).pow(p - 2); }
	Z &operator/=(ll y) const { return *this = *this / y; }
	Z operator+(const Z &r) const { return *this + r.x; }
	Z &operator+=(const Z &r) { return *this += r.x; }
	Z operator-(const Z &r) const { return *this - r.x; }
	Z &operator-=(const Z &r) { return *this -= r.x; }
	Z operator*(const Z &r) const { return *this * r.x; }
	Z &operator*=(const Z &r) { return *this *= r.x; }
	Z operator/(const Z &r) const { return *this / r.x; }
	Z &operator/=(const Z &r) { return *this /= r.x; }
	Z pow(int i) {
		if (i == 0) return Z(1);
		if (i % 2) return *this * pow(i - 1);
		Z tmp = pow(i / 2);
		return tmp * tmp;
	}
	ll get() { return x; }
	friend istream &operator>>(istream &istr, Z &z) { return istr >> z.x; }
	friend ostream &operator<<(ostream &ostr, const Z &z) { return ostr << z.x; }
};

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

	int X, Y;
	cin >> X >> Y;
	int i = 2 * Y - X;
	int j = 2 * X - Y;
	Z<> res;
	if (i < 0 || j < 0 || i % 3 || j % 3) res = 0;
	else {
		i /= 3;
		j /= 3;
		vector<Z<>> fact(i + j + 1);
		fact[0] = 1;
		REP(k, i + j) {
			fact[k + 1] = fact[k] * (k + 1);
		}
		res = fact[i + j] / fact[i] / fact[j];
	}
	cout << res << endl;

	return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

const string YES = "Yes";
const string NO = "No";

int main(){
    string s;
    cin >> s;
    if (s.find("7") != string::npos) cout << YES << endl;
    else cout << NO << endl;
    return 0;
}


Measured memory_bytes: 3548
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * User: ngupta
 * Date: 4/5/2020 AD
 * Time: 23:41
 */
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("ABC".equals(sc.next()) ? "ARC" : "ABC");
    }
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n; cin >> n;
  vector<ll> a(n+1); for(int i = 1;i<=n;i++) cin >> a[i];
  ll MOD = 1000000000+7;

  vector<ll> mult(n+1,0);
  mult[n] = a[n]%MOD;
  for(int i = n;i>=1;i--){
    mult[i-1] = mult[i]+a[i-1];
    mult[i-1] %= MOD;
    //cout << "i-1: " << i-1 << " mult: " << mult[i-1] << endl;
  }

  ll ans = 0;
  for(int i = 1;i<=n-1;i++){
    ans += a[i]*mult[i+1];
    ans %= MOD;
    //cout << ans << endl;
  }
  
  cout << ans << endl;
  
  return 0;
}


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

// Replace function..
string replace(string word, string target, string replacement) {
    int len, loop = 0;
    string nword = "", let;
    len = word.length();
    len--;
    while (loop <= len) {
        let = word.substr(loop, 1);
        if (let==target) {
            nword = nword+replacement;
        }
        else {
            nword = nword+let;
        }
        loop++;
    }
    return nword;
}
//Main..
int main() {
  string word;
  cin >> word;
  cout << replace(word, ",", " ");
  
  return 0;
}

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

  int main() {
    string s; cin >> s;
    bool l[26];

    rep(i, 26) {
      l[i] = false;
    }

    rep(i, s.size()) {
      l[(int) s[i] - (int) 'a'] = true;
    }

    rep(i, 26) {
      if (!l[i]) {
        p((char) ('a' + i));
        return 0;
      }
    }

  p("None");
  }

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll an=max(a*c,b*d);
	an=max(an,a*d);
	an=max(an,b*c);
	cout<<an<<endl;
	return 0;
}

Measured memory_bytes: 3612
N = int(input())
S = [input() for i in range(N)]
S.sort()

ini = S[0]
l = [0]
for i in range(N):
    if ini != S[i]:
        # print(ini,S[i])
        ini = S[i]
        l.append(i)
l.append(N)
l_sabun = [l[i+1] - l[i] for i in range(len(l)-1)]
# print(l)
# print(l_sabun )

S_set = list(set(S))
S_set.sort()

# print(S_set)

m = max(l_sabun)
ans = [S_set[i] for i, x in enumerate(l_sabun) if x == m]

# print(m,ans)


# print("============")

for i in ans:
    print(i)

Measured memory_bytes: 39232
#include <iostream>
#include <algorithm>

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

int main () {
    lli A, B, N;
    cin >> N >> A >> B;
    cout << max(0LL, (N - 1) * B + A - (N - 1) * A - B + 1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1e9+7
#define PI acos(-1.0)
#define ll long long
#define INF 1000000001

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n,k;cin>>n>>k;
  int ans=0;
  REP(i,n){
    int x;cin>>x;
    ans+=min(2*x, 2*(k-x));
  }
  P(ans);
  return 0;
}


Measured memory_bytes: 256
/**
   _           _
  / /         \ \
 / /  _   _  _ \ \
< < (_) (_) (_) > >
 \ \           / /
  \_\         /_/

Nerede Gitsen Çukur Orda
**/

#include<bits/stdc++.h>
#include<fstream>
///#include "windows.h"
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define Zohiri_dzd cout.tie(NULL);
#define Belafz cin.tie(NULL);
#define CODER ios_base::sync_with_stdio(0)  ;
#define p_b pop_back
#define p_f pop_front
#define quluq return 0;
using namespace std ;

    const ll N = 1e4 + 0.000001 ;

int main ()
{
    Zohiri_dzd
    Belafz
    CODER
    ///freopen("input.txt" , "r" , stdin );
    ///freopen("output.txt", "w" , stdout );
    ///Author of the greatest code :: Murtazoev Alijon
    ///4294967295
    ll n ;
    cin >> n ;
    deque < ll > v;
    map < ll , ll > mp ;
    ll cnt = 0 ;
    for (ll i = 0 ; i < n ; i ++ )
    {
        ll a ;
        cin >> a ;
        v.pb(a) ;
        mp[a] ++ ;
        cnt += a ;
    }
    ll m ;
    cin >> m ;
    while (m -- )
    {
        ll l , r ;
        cin >> l >> r ;
        ll x = mp[l] ;
        ll y = mp[r] ;
        cnt -= x * l ;
        cnt += x * r ;
        mp[r] += mp[l] ;
        mp[l] = 0 ;
        cout << cnt << endl ;
    }
}
///Mavl studios
///Eco students


Measured memory_bytes: 10280
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
	int n, l, i, a[100003], mt;

	scanf("%d%d", &n, &l);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}

	for (i = 0; i < n - 1; i++) {
		if (a[i] + a[i + 1] >= l) {
			break;
		}
	}

	if (i == n - 1) {
		printf("Impossible\n");
		return 0;
	}

	printf("Possible\n");

	mt = i;
	for (i = 0; i < mt; i++) {
		printf("%d\n", i + 1);
	}
	for (i = n - 2; i >= mt; i--) {
		printf("%d\n", i + 1);
	}

	return 0;
}

Measured memory_bytes: 1152
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    //入力受付
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    int ab = a * b;
    
    
    //判定
    if(ab % 2 == 0){
      System.out.println("Even");
    }else{
      System.out.println("Odd");
  	}
}
}

Measured memory_bytes: 22868
#include "bits/stdc++.h"
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<pair<int,int> > a;

	for(int i=0;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		a.push_back({x,y});
	}

	bool flag=0;

	int count=0;

	for(int i=0;i<n;i++)
	{
		if(a[i].first==a[i].second)
		{
			count++;
			if(count==3)
			{
				flag=1;
				break;
			}
		}
		else
		{
			count=0;
		}
	}

	if(flag)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}

	return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;
 
public class Main {
	
	public static void main(String[] args) throws Exception{	
		Scanner sc = new Scanner(System.in);
		
		int ans = 1;
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		int t = k-1;
		
		
		for(int i=1; i<n; i++){
			ans *= t;
		}
		
		System.out.println(ans*k);
		
		
		
		sc.close();
	}
}

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

#define ll long long int
#define oo 1L<<60;

int N;
int happiness [100005][3];
ll memo [100005][3];

ll costo(){
	for(int i = 0; i<3;i++)
	memo[0][i] = happiness[0][i];
	for(int i = 1; i<N; i++)
		for(int j = 0; j<3;j++)
			memo[i][j] = happiness[i][j]+max(memo[i-1][(j+1)%3],memo[i-1][(j+2)%3]);
	return max(max(memo[N-1][0], memo[N-1][1]), memo[N-1][2]);
}

int main() {
	cin>>N;
	for(int i = 0; i<N;i++)
		cin>>happiness[i][0]>>happiness[i][1]>>happiness[i][2];
	cout<<costo()<<endl;
	return 0;
}

Measured memory_bytes: 7096
N, M = map(int, input().split())
ans = {}
ac = 0
wa = 0
flag = False
for i in range(M):
    p, s = input().split()
    if p not in ans:
        if s == "AC":
            ans[p] = []
            ans[p].append("AC")
        else:
            ans[p] = []
            ans[p].append("WA")
    else:
            if s == "WA":
                ans[p].append("WA")
            elif s == "AC":
                ans[p].append("AC")
for val in ans.values():
    count = 0
    for i in val:
        if flag != True:
            if i == "WA":
                count += 1
            if i == "AC":
                ac += 1
                wa += count
                flag = True
    flag = False
print(ac, wa)



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

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

const int N = 110;
vector<int> vrt[N];

void solve() {
  int n; cin >> n;
  int diam = 0, mn = 1e9;
  for (int v = 1; v <= n; v++) {
    int a; cin >> a; vrt[a].push_back(v);
    diam = max(diam, a); mn = min(mn, a);
  }
  if (diam % 2 == 0 && (vrt[diam / 2].size() != 1 || mn < diam / 2)) {
    cout << "Impossible"; return;
  }
  if (diam % 2 == 1 && (vrt[(diam + 1) / 2].size() != 2 || mn < (diam + 1) / 2)) {
    cout << "Impossible"; return;
  }
  for (int dst = diam, l = 0, r = diam; l <= r; dst--, l++, r--) {
    if (l == r && vrt[dst].size() < 1 || l != r && vrt[dst].size() < 2) {
      cout << "Impossible"; return;
    }
  }
  cout << "Possible";
}

// CHECK LIMITS (n <= 10^5)
// CHECK CORNER CASES (n == 1)

int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(20);
  //cout << 1.0 * clock() / CLOCKS_PER_SEC << endl;
  solve();
}


Measured memory_bytes: 3668
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        final int n = Integer.parseInt(line[0]);
        final int m = Integer.parseInt(line[1]);
        final int l = Integer.parseInt(line[2]);
        int[][] A = new int[n][m];
        int[][] B = new int[m][l];
        long[][] C = new long[n][l];
        
        for (int i=0; i<n; i++){
            String[] tmp= br.readLine().split(" ");
            for (int j=0; j<m; j++){
                int num = Integer.parseInt(tmp[j]);
                A[i][j] = num;
            }
        }
        for (int i=0; i<m; i++){
            String[] tmp= br.readLine().split(" ");
            for (int j=0; j<l; j++){
                int num = Integer.parseInt(tmp[j]);
                B[i][j] = num;
            }
        }
        for (int i=0; i<n; i++){
            for (int j=0; j<m; j++){
                for (int k=0; k<l; k++){
                    C[i][k] += A[i][j]*B[j][k]; 
                }
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i=0; i<n; i++){
            for (int j=0; j<l-1; j++){
                sb.append(C[i][j]);
                sb.append(" ");
            }
            sb.append(C[i][l-1]);
            sb.append("\n");
        }
        System.out.print(sb.toString());
    }
}

Measured memory_bytes: 27084
#include<bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define per(i,n,k) for(int i=n;i>=k;i--)
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define ll long long
using namespace std;
const int maxn=3005;
ll f[maxn][maxn],a[maxn],n,j;
int main()
{
	scanf("%lld",&n);
	rep(i,1,n) scanf("%lld",a+i),f[i][i]=a[i];
	rep(len,1,n)
	{
		rep(i,1,n)
		{
			j=i+len-1;
			if(j>n) break; else f[i][j]=max(a[i]-f[i+1][j],a[j]-f[i][j-1]);
		}
	}
	printf("%lld",f[1][n]);
	return 0;
}

Measured memory_bytes: 70144
s = list(input())
i = 1
count = 0
while i != len(s):
  if i == 0:
    i += 1
  elif s[i-1] != s[i]:
    del s[i]
    del s[i-1]
    i -= 1
    count += 2
  else:
    i += 1

print(count)

Measured memory_bytes: 3956
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#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++)
#define INF 1e9 + 7
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    int d, t, s;

    cin >> d >> t >> s;
    if (d <= s * t)
    {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define N 500005
using namespace std;
int n,L,a[N],ans[N];
int main(){
	scanf("%d%d",&n,&L);int sta=0;
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<n;i++)
		if (a[i]+a[i+1]>=L){sta=i;break;}
	if (!sta) return puts("Impossible"),0;
	else puts("Possible");
	int cnt=n-1;ans[cnt]=sta;
	for (int i=sta+1;i<n;i++) ans[--cnt]=i;
	for (int i=sta-1;i;i--) ans[--cnt]=i;
	for (int i=1;i<n;i++) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
int num[4];
int main()
{
	int n,d1,d2;
	scanf("%d%d%d",&n,&d1,&d2);
	int num1=0,num2=0;
	while((d1&1)==0)
	{
		num1++;
		d1>>=1;
	}
	while((d2&1)==0)
	{
		num2++;
		d2>>=1;
	}
	for(int i=0;i<(n<<1);i++)
	{
		for(int j=0;j<(n<<1);j++)
		{
			int tp1,tp2;
			if(num1&1)
			{
				tp1=((i>>(num1>>1))&1);
			}
			else
			{
				tp1=(((i>>(num1>>1))+(j>>(num1>>1)))&1);
			}
			if(num2&1)
			{
				tp2=((i>>(num2>>1))&1);
			}
			else
			{
				tp2=(((i>>(num2>>1))+(j>>(num2>>1)))&1);
			}
			num[tp1+tp1+tp2]++;
		}
	}
	int wz;
	for(wz=0;wz<4;wz++)
	{
		if(num[wz]>=n*n)
		{
			break;
		}
	}
	int rm=n*n;
	for(int i=0;i<(n<<1);i++)
	{
		for(int j=0;j<(n<<1);j++)
		{
			int tp1,tp2;
			if(num1&1)
			{
				tp1=((i>>(num1>>1))&1);
			}
			else
			{
				tp1=(((i>>(num1>>1))+(j>>(num1>>1)))&1);
			}
			if(num2&1)
			{
				tp2=((i>>(num2>>1))&1);
			}
			else
			{
				tp2=(((i>>(num2>>1))+(j>>(num2>>1)))&1);
			}
			if(tp1+tp1+tp2==wz)
			{
				printf("%d %d\n",i,j);
				rm--;
				if(rm==0)
				{
					return 0;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() { // 問題文はしっかり読め!!!
	int n, k; string s;
	cin >> n >> k >> s;
	s[--k] += 32;
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
# include <stdio.h>
# include <iostream>
using namespace std;
int a[103], b[103];

int main()

{

    int p1=0, p2=0, m=100;

    long long n;

    scanf("%lld",&n);

    n++;

    while(n > 1)

    {

        if(n&1) a[++p1] = m--, --n;

        else b[++p2] = m--, n>>=1;

    }

    printf("%d\n",p1+p2<<1);

    for(int i=1; i<=p1; ++i)

        printf("%d ",a[i]);

    for(int i=p2; i>=1; --i)

        printf("%d ",b[i]);


    for(int i=101-p1-p2; i<=100; ++i)

        printf("%d ",i);

    puts("");

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    typedef long long LL;
     
    LL ce(LL a,LL b){
    	if(b==1)return a;
    	if(b==0)return 1e16;
    	return(a+b-1)/b;
    	}
    int main(){
    	LL n;
    	cin>>n;
    	LL a,b;
    	cin>>a>>b;
    	for(int x=1;x<n;x++){
    		LL c,d;
    		cin>>c>>d;
    		LL ca,da;
    		ca=ce(a,c);
    		da=ce(b,d);
    		LL m=max(ca,da);
    		a=c*m;
    		b=d*m;
    		}
    		cout<<a+b<<endl;
    		return 0;
    	}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using ll = long long;

int main() {
  std::string N;
  std::cin >> N;
  bool f{false};

  for(auto&& v:N){
    if (v == '7') f = true;
  }
  std::cout << (f?"Yes":"No") << std::endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int main(){
    ll n; cin>>n;
    cout<<n*800 - (n/15)*200<<endl;
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i

ff = []
n.times {ff << gets.split.map(&:to_i)}

pp = []
n.times {pp << gets.split.map(&:to_i)}

ans = -(1 << 40)
1.upto(2 ** 10 - 1) do |i|
    sum = 0
    ff.each.with_index do |f, j|
        sum += pp[j][10.times.count {|k| i[k] & f[k] == 1}]
    end
    ans = sum if ans < sum
end

puts ans

Measured memory_bytes: 3964
k, s = map(int, input().split())

#.
ans = 0

#.
for x in range(k+1):
    for y in range(k+1):
        #.
        des_v = s - x - y

        #.
        if des_v >= 0 and des_v <= k:
            ans += 1

print(ans)

Measured memory_bytes: 9180
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100000;

int main() {
	int n, k;
	cin >> n >> k;
	int v[50];
	rep(i, n) cin >> v[i];

	int ans = -INF;
	vi tmp_v;
	for(int i = 0; i <= min(n, k); i++) {
		for(int l = 0; l <= i; l++) {
			int r = i - l;
			int tmp_ans = 0;
			int remain = k - i;
			tmp_v.clear();
			for(int j = 0; j < l; j++) {
				tmp_v.push_back(v[j]);
			}
			for(int j = 0; j < r; j++) {
				tmp_v.push_back(v[n - 1 - j]);
			}
			sort(tmp_v.begin(), tmp_v.end());
			for(auto j : tmp_v) {
				if(j < 0 && remain > 0) {
					remain--;
					continue;
				}
				tmp_ans += j;
			}
			ans = max(tmp_ans, ans);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
h, w, k = map(int, input().split())
s = [list(map(int, input())) for _ in range(h)]
ans = (h - 1) * (w - 1)  #INF
for bitseed in range(2 ** (h - 1)):
    i2cell = [0]
    accum_temp = 0
    for _ in range(h - 1):
        accum_temp += bitseed % 2
        i2cell.append(accum_temp)
        bitseed //= 2
    #accum_temp == horizontal cut num
    cell2whitenum = [0] * (accum_temp + 1)
    v_cut_num = 0
    for j in range(w):
        for i in range(h):
            cell2whitenum[i2cell[i]] += s[i][j]
        if max(cell2whitenum) > k:
            v_cut_num += 1
            cell2whitenum = [0] * (accum_temp + 1)
            for i in range(h):
                cell2whitenum[i2cell[i]] += s[i][j]
            if max(cell2whitenum) > k:
                v_cut_num = (h - 1) * (w - 1)  #INF
    if accum_temp + v_cut_num < ans:
        ans = accum_temp + v_cut_num
print(ans)

Measured memory_bytes: 44124
#include<cstdio>
#include<algorithm>
using namespace std;
static const int MAX_W = 10;
static const int MAX_D = 10;
static const int MAX_H = 20;

int w, d;
int h1[MAX_W], h2[MAX_D];

int num[MAX_H + 1], num2[MAX_H + 1];

int main(){
	for(;;){
		scanf("%d %d", &w, &d);
		if(w == 0 && d == 0) break;
		for(int i = 0; i < w; i++) scanf("%d", &h1[i]);
		for(int i = 0; i < d; i++) scanf("%d", &h2[i]);
		fill(num, num + MAX_H + 1, 0);
		fill(num2, num2 + MAX_H + 1, 0);
		for(int i = 0; i < w; i++) num[h1[i]]++;
		for(int i = 0; i < d; i++) num2[h2[i]]++;
		int res = 0;
		for(int i = 1; i <= MAX_H; i++) res += i * max(num[i], num2[i]);
		printf("%d\n", res);
	}
	return 0;
}



Measured memory_bytes: 2604
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] in = Stream.of(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		
		List<List<Long>> studentCoordinateList = new ArrayList<>();
		List<List<Long>> pointCoordinateList = new ArrayList<>();
		
		for (int i = 0; i < in[0]; i++) {
			studentCoordinateList.add(getInputValue(sc));
		}
		for (int i = 0; i < in[1]; i++) {
			pointCoordinateList.add(getInputValue(sc));
		}
		
		List<List<Long>> indexList = new ArrayList<>();
		for (int i = 0; i < in[0]; i++) {
			List<Long> tmpList = new ArrayList<>();
			
			for (int j = 0; j < in[1]; j++) {
				long val = 0;
				for (int k = 0; k < 2; k++) {
					val += Math.abs(studentCoordinateList.get(i).get(k) - pointCoordinateList.get(j).get(k));
				}
				tmpList.add(val);
			}
			indexList.add(tmpList);
		}
		
		List<Long> countList = new ArrayList<>();
		for (List<Long> index : indexList) {
			long count = 1;
			long min = Long.MAX_VALUE;
			
			for (int i = 0; i <index.size(); i++) {
				
				long diff = Math.abs(0 - index.get(i));	
				if (diff < min) {
					count = i+1;
					min = diff;
				}
			}
			countList.add(count);
		}
		
		countList.forEach(c -> System.out.println(c));
				
	}
	
	private static List<Long> getInputValue(Scanner sc) {
		List<Long> tmp = new ArrayList<>();
		Stream.of(sc.nextLine().split(" ")).mapToLong(Long::parseLong).forEach(n -> tmp.add(n));
		return tmp;
	}
}


Measured memory_bytes: 28624
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;

struct ninja
{
	int b, f, c;
	ninja(int b, int f, int c)
		: b(b), f(f), c(c){}
};
int main()
{
	int n;
	while (scanf("%d", &n), n)
	{
		int wall[2][101];
		for (int i = 0; i < 2*n; ++i)
			scanf("%d", &wall[i/n][i%n]);
		wall[0][n] = wall[1][n] = 0;

		int res = -1;
		bool visit[2][100];
		memset(visit, 0, sizeof(visit));
		queue<ninja> q;
		q.push(ninja(0, 0, 0));
		q.push(ninja(1, 0, 0));
		while (!q.empty())
		{
			ninja nin = q.front(); q.pop();
			int b = nin.b; int f = nin.f;
			if (wall[b][f] == 1)
				while (wall[b][f] == 1 && wall[b][f+1] == 1)
					++f;
			else if (wall[b][f] == 2)
				while (wall[b][f] == 2)
					--f;

			if (visit[b][f])
				continue;

			visit[b][f] = true;
			if (f == n-1)
			{
				res = nin.c;
				break;
			}

			for (int i = 0; i <= 2 && f+i < n; ++i)
				q.push(ninja(b^1, f+i, nin.c + 1));
		}
		if (res != -1)
			printf("%d\n", res);
		else
			puts("NA");
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>]
#include <map>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;

bool check(string s){
    char x=s[0];
    for(int i=0;i<s.length();i++)if(x!=s[i])return false;
    return true;
}

int main(){
string s;cin>>s;
if(check(s.substr(0,3))||check(s.substr(1,3)))cout<<"Yes";
else cout<<"No";

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,k,a[110];
int b[100001];
int f(int x){
    if(b[x]==0||b[x]==1)return b[x];
    bool flag=false;
    rep(i,n){
        if(x-a[i]>=0){
            if(f(x-a[i])==false)flag=true;
        }
    }
    if(flag)b[x]=1;
    else b[x]=0;
    return flag;
}
signed main(){
    cin>>n>>k;
    rep(i,n)cin>>a[i];
    fill(b,b+100001,2);
    b[0]=0;
    if(f(k))puts("First");
    else puts("Second");
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
#define PI 3.14159265358979
using namespace std;

int main() {
    double a,b,x,ans;
    cin >> a >> b >> x;

    
    if (x > a*a*b/2){
        ans = atan((a*a*b-x)/(a*a*a)*2.0)*180/PI;
    }
    else{
        ans = atan((a*b*b)/(2.0*x))*180/PI;
    }

    cout << fixed << setprecision(10) << ans;

    return 0;
}

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

#include <vector>
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  t = t.substr(0, s.length());
  string result = s == t ? "Yes" : "No";
  cout << result << endl;
}

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

int main(){
    ll N;
    cin >> N;
    //vector<ll> F(N+1);
    ll ans = 0;
    for(int i=1;i<=N;i++){
        for(int j=i;j<=N;j+=i){
            ans+=j;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>

using namespace std;
const int N = 1e5+5;
typedef long long ll;
int n;
ll lx[N],rx[N],ly[N],ry[N];
struct node {
	ll l,r;
}a[N];
bool cmp(node a,node b){
	return a.l<b.l;
}

int main(){
	cin>>n;
	ll maxx=0,minn=1e18,ans1,maxlen=0;
	for(int i=1;i<=n;i++){
		cin>>a[i].l>>a[i].r;
		maxx=max(a[i].l,maxx);
		minn=min(a[i].r,minn);
		maxlen=max(a[i].r-a[i].l+1,maxlen);
	}
	ans1=maxlen+max(minn-maxx+1,0ll);
	sort(a+1,a+n+1,cmp);
	lx[1]=a[1].l;rx[1]=a[1].r;
	ll rq=a[1].r;
	for(int i=2;i<=n;i++){
		lx[i]=max(lx[i-1],a[i].l);
		rx[i]=min(rx[i-1],a[i].r);
//		rq=min(rq,a[i].r);
	}
	ry[n]=a[n].r;ly[n]=a[n].l;
	ll lp=a[n].l;
	for(int i=n-1;i>=1;i--){
		ry[i]=min(a[i].r,ry[i+1]);
		ly[i]=max(a[i].l,ly[i+1]);
//		lp=max(lp,a[i].l);
	}
//	cout<<ans1<<endl;
	ll ans2=0;
	for(int i=1;i<=n-1;i++){
		ans2=max(ans2,max(rx[i]-lx[i]+1,0ll)+max(ry[i+1]-ly[i+1]+1,0ll));
	}
//	cout<<ans2<<endl;
	cout<<max(ans1,ans2)<<endl;
	
	return 0;
}

Measured memory_bytes: 4992
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner sc = new Scanner(System.in);
    String s = sc.next();

    Map<String, Integer> m = new HashMap<String, Integer>();
    for (int i = 0; i < s.length(); i++) {
      Integer cnt = m.get(String.valueOf(s.charAt(i)));
      if (cnt != null) {
        cnt = cnt + 1;
      } else {
        cnt = 1;
      }
      m.put(String.valueOf(s.charAt(i)), cnt);
    }

    boolean isBreak = false;
    for (Map.Entry<String, Integer> entry : m.entrySet()) {
      if (entry.getValue() % 2 != 0) {
        isBreak = true;
        break;
      }
    }
    if(isBreak) {
      System.out.println("No");
    } else {
      System.out.println("Yes");
    }
  }
}


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

#define fi first
#define sd second
#define lson (nd<<1)
#define rson (nd<<11)
#define PB push_back
#define mid (l+r>>1)
#define MP make_pair
#define SZ(x) (int)x.size()

using namespace std;

typedef long long LL;

typedef vector<int> VI;

typedef pair<int,int> PII;

inline int read(){
    int res=0, f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){res=res*10+ch-'0';ch=getchar();}
    return res*f;
}

const int MAXN = 200'005;

const int MOD = 1000000007;

int main(){
    double x;
    cin>>x;
    printf("%.7f",(x/3.0)*(x/3.0)*(x/3.0));

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  
  int i,j,v,N,a;
  scanf("%d",&N);
  int A[N];

  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }

  for(i=1;i<=N;i++){
    for(a=0;a<N;a++){
    printf("%d",A[a]);
    if(a < N -1){
      printf(" ");
    }
    }
    printf("\n");
    v = A[i];
    j = i -1;
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
  }
  return 0;
}
      
  



Measured memory_bytes: 2072
N,M,C=map(int, input().split())
B=list(map(int, input().split()))
ans=0
for i in range(N):
    A=list(map(int, input().split()))
    tmp=0
    for j in range(M):
        tmp+=A[j]*B[j]
    if tmp+C>0:
        ans+=1
print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

ll dp[1 << 17][13];
ll cop[13];
void solve() {
	string s; cin >> s;
	int n = s.length();
	dp[0][0] = 1;
	rep(i, n) {
		cop[13] = {};
		rep(j, 13) {
			cop[(j * 10) % 13] = dp[i][j];
		}
		rep(j, 13)dp[i][j] = cop[j];
		if (s[i] != '?') {
			int z = s[i] - '0';
			rep(j, 13) {
				(dp[i + 1][(j + z) % 13] += dp[i][j]) %= mod;
			}
		}
		else {
			rep(j, 13) {
				rep(k, 10) {
					(dp[i + 1][(j + k) % 13] += dp[i][j]) %= mod;
				}
			}
		}
	}
	cout << dp[n][5] << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(10);
	//cout << pow(1/6000.0, 1.0 / 25) << endl;
	//init();
	solve();
	//cout << "finish" << endl;
	//stop
	return 0;
}

Measured memory_bytes: 10704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef priority_queue<double, vector<double>, less<double> > QUE_double;
typedef priority_queue<int, vector<int>, less<int> > QUE_int;//lessは大きい順にならべるよ
const int MAX = pow(10, 5)+1;//+1しないとREになる(out of rangeになるんかな?? )



bool IsPrime(int num)//https://qiita.com/asksaito/items/76b71602dd956b79dbf7
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main(){
  int X;
  cin >> X;
  while(IsPrime(X)==false) X++;
  cout << X << endl;
}


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

int main() {
	int ans[100010];
	int sum = 0;
	int n;
	int a[100010];
	cin >> n;
	a[0] = 0;
	a[n + 1] = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		sum += abs(a[i - 1] - a[i]);
	}
	sum += abs(a[n] - a[n + 1]);

	for (int i = 1; i <= n; i++) {
		cout << sum - abs(a[i] - a[i - 1]) - abs(a[i] - a[i + 1]) + abs(a[i - 1] - a[i + 1]) << endl;
	}
	return 0;
}

Measured memory_bytes: 1664
n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = [0 for i in range(a[n-1]+2)]
for i in a:
    ans[i] += 1
    ans[i+1] += 1
    if i-1 > 0:
        ans[i-1] += 1
ans.sort()
print(ans[len(ans)-1])

Measured memory_bytes: 14008
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		var a=Enumerable.Repeat(-1,s[0]).ToArray();
		for(int i = 0;i<s[1];i++) {
			var e=sc.Ia;
			if(a[e[0]-1]==-1){
				a[e[0]-1]=e[1];
			}
			else if(a[e[0]-1]!=e[1]){
				Console.WriteLine(-1);
				return;
			}
		}
		if(a[0]==-1){
			a[0]=s[0]!=1?1:0;
		}
		for(int i = 1;i<s[0];i++) {
			if(a[i]==-1){a[i]=0;}
		}
		if(a[0]==0&&s[0]!=1){
			Console.WriteLine(-1);
			return;
		}
		Console.WriteLine("{0}",String.Join("",a));
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13396
def main():
  n, w = map(int, input().split())
  
  value = []
  weight = []
  num = []
  
  for _ in range(n):
    vi, wi, ni = map(int, input().split())
    value.append(vi)
    weight.append(wi)
    num.append(ni)
  
  def to_digit(x):
    acc = 1
    ret = [0]
    while x >= acc:
      ret.append(acc)
      x -= acc
      acc *= 2
    if x:
      ret.append(x)
    return ret
  
  num = list(map(to_digit, num))
  
  dp = [0 for _ in range(w + 1)]
  for i in range(n):
    vi = value[i]
    wi = weight[i]
    numsi = num[i]
    for k in numsi:
      wik = wi * k
      vik = vi * k
      for j in range(w, wik - 1, -1):
        dp[j] = max(dp[j], dp[j - wik] + vik)
  
  print(dp[w])

main()


Measured memory_bytes: 5988
import math
 
n=int(input())
arr=list(map(int,input().split()))
if 0 in arr:
  print("0")
  exit()
ans=1
for i in range(n):
  ans *= arr[i]
  if math.log10(ans) >= 18 and ans!=1000000000000000000:
    print("-1")
    exit()
print(ans)

Measured memory_bytes: 22440
N = int(input())
A = list(map(int, input().split()))
  
def solve(N, A):
  
  if N == 0 and A[0] > 1 or N > 0 and A[0] > 0:
    print(-1)
    return

  total = sum(A[1:])
  #t = A[-1] + A[-2]
  par = 1 - A[0]
  rt = 1
  for i, a in enumerate(A[1:]):
    total -= a
    max_node = par * 2
    cur = max_node - a
    if cur < 0:
      print(-1)
      return
    cur = min(total, cur)
    #print(i+1, a, cur)
    rt += a
    if i + 1 < N:
      rt += cur
    par = cur  
   
  print(rt)
  
solve(N, A)



Measured memory_bytes: 20120
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>

using namespace std;

const int MOD = 1000000007;
typedef long long ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin>>S;
  int a,b,c,d;
  a=S[0]-48;
  b=S[1]-48;
  c=S[2]-48;
  d=S[3]-48;

  if(a+b+c+d==7){
    cout<<a<<'+'<<b<<'+'<<c<<'+'<<d<<"=7"<<endl;
  }else if(a+b+c-d==7){
    cout<<a<<'+'<<b<<'+'<<c<<'-'<<d<<"=7"<<endl;
  }else if(a+b-c+d==7){
    cout<<a<<'+'<<b<<'-'<<c<<'+'<<d<<"=7"<<endl;
  }else if(a-b+c+d==7){
    cout<<a<<'-'<<b<<'+'<<c<<'+'<<d<<"=7"<<endl;
  }else if(a+b-c-d==7){
    cout<<a<<'+'<<b<<'-'<<c<<'-'<<d<<"=7"<<endl;
  }else if(a-b+c-d==7){
    cout<<a<<'-'<<b<<'+'<<c<<'-'<<d<<"=7"<<endl;
  }else if(a-b-c+d==7){
    cout<<a<<'-'<<b<<'-'<<c<<'+'<<d<<"=7"<<endl;
  }else if(a-b-c-d==7){
    cout<<a<<'-'<<b<<'-'<<c<<'-'<<d<<"=7"<<endl;
  }

}


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

 #  define REP(i,s,n) for(int i=s;i<n;i++)
   # define rep(i,n) REP(i,0,n)
 #    define EPS (1e-5)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

double T,D,tA,tB,dA,dB;

int main(){
  cin >> T >> D >> tA >> tB >> dA >> dB;
  double maxi = -1e30;
  for(double vA=0;LTE(vA,D);vA+=dA){
    for(double vB=0;LTE(vB,D);vB+=dB){
      if( LT(vA+vB,1) ) continue;
      if( !LTE(vA+vB,D) ) break;
      if( equals(vA,0.0) && equals(vB,0.0) ) continue;
      double tmp = ( tA * vA + tB * vB ) / ( vA + vB);
      if( LT(abs(tmp-T),abs(maxi-T)) ) maxi = tmp;
    }
  }
  printf("%.10f\n",abs(T-maxi));
  return 0;
}

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

const int MAXW = 1e5 + 10;

long long knapsack[MAXW];


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

	for(int i = 1;i<=n;i++){
		int wt,val;
		cin >> wt >> val;
		for(int j = totWt; j>=wt; j--) 
		    knapsack[j] = max(knapsack[j-wt] + val,knapsack[j]);
	}

	long long maxVal = 0;
	for(int i = 0; i<=totWt; i++) 
	    maxVal = max(maxVal,knapsack[i]);
	cout << maxVal << endl;

	return 0;

}

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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int parent[100009];

void make_set(int v) {
    parent[v] = v;
}

int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b)
        parent[b] = a;
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int N, M;
    cin >> N >> M;
    VI A(N+2);
    FOR(i, 1, N) {
        make_set(i);
        cin >> A[i];
    }
    REP(i, M) {
        int x, y;
        cin >> x >> y;
        union_sets(x, y);
    }
    int ans = 0;
    FOR(i, 1, N) {
        if (find_set(A[i]) == find_set(i)) {
            ans++;
        }
    }
    cout << ans << endl;

}


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

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VC vector<char>
#define VS vector<string>
#define FOREACH(x,a) for(auto& (x) : (a) )
using namespace std;

int main() {
	int n;
	cin >> n;
	if (n % 111) cout << n / 111 * 111 + 111 << endl;
	else cout << n << endl;

	return 0;
}

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

using namespace std;



int main()
{
    int x,y,z;
    cin>>x>>y>>z;
    if((y-x+1)<=z)
    {
        for(int i=x;i<=y;i++)
        cout<<i<<endl;
    }
    else
    {
        vector<int>v;
        for(int i=0;i<z;i++)
        v.push_back(x+i);
        for(int i=0;i<z;i++)
        v.push_back(y-i);
        sort(v.begin(),v.end());
        for(int i=0;i<v.size();i++)
        {
            if(v[i+1]!=v[i])
            cout<<v[i]<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256