akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long 
#define sort(v) sort(v.begin(),v.end()) 
#define pb push_back
/*ll ar[1000000+9]={0}; 
void seiv() { 
ll n=1000000,i,j; 
ar[1]=1; 
for(i=4;i<=n;i+=2)ar[i]=1; 
for(i=3;i<=n;i+=2) 
{ if(ar[i]==0) 
{ for(j=i*i;j<=n;j+=i*2)ar[j]=1; }
 } 
*/
int main()
{
    
    ll a,b,c,d,e,i;
    cin>>a;
  if(a>=400&&a<=599)cout<<8<<endl;
if(a>=600&&a<=799)cout<<7<<endl;
if(a>=800&&a<=999)cout<<6<<endl;
if(a>=1000&&a<=1199)cout<<5<<endl;
    if(a>=1200&&a<=1399)cout<<4<<endl;
if(a>=1400&&a<=1599)cout<<3<<endl;
if(a>=1600&&a<=1799)cout<<2<<endl;
if(a>=1800&&a<=1999)cout<<1<<endl;



}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <vector>
#include <complex>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <stack>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <cassert>
 
using namespace std;
 
typedef long long ll;
typedef ll li;
typedef pair<int,int> PI;
#define EPS (1e-10L)
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define REP(i, n) rep (i, n)
#define F first
#define S second
#define mp(a,b) make_pair((a),(b))
#define list3(a,b,c) mp((a),mp((b),(c)))
#define list4(a,b,c,d) mp((a),list3((b),(c),(d)))
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(),a.end()
#define CLR(a) memset((a),0,sizeof(a))
#define FOR(it,a) for(__typeof(a.begin())it=a.begin();it!=a.end();++it)
template<typename T,typename U> ostream& operator<< (ostream& out, const pair<T,U>& val){return out << "(" << val.F << ", " << val.S << ")";}
template<class T> ostream& operator<< (ostream& out, const vector<T>& val){out << "{";rep(i,SZ(val)) out << (i?", ":"") << val[i];return out << "}";}
void pkuassert(bool t){t=1/t;};
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,-1,1,1,-1};

int vis[200][200];
vector<pair<int,PI> > G[200];
int m,n,l;

void solve(){
  rep(i,n) G[i].clear();
  CLR(vis);
  rep(i,m){
    int a,b,d,e;
    cin >> a >> b >> d >> e;
    --a,--b;
    G[a].pb(mp(b,mp(d,e)));
    G[b].pb(mp(a,mp(d,e)));
  }
  priority_queue<pair<int,PI > > q;
  q.push(mp(0,mp(0,0)));
  while(!q.empty()){
    int cc=-q.top().F;
    int cv=q.top().S.F;
    int us=q.top().S.S;
    q.pop();
    if(us>l) continue;    
    if(vis[cv][us]) continue;
    vis[cv][us]=true;

    if(cv==n-1){
      cout << cc << endl;
      return;
    }
    FOR(it,G[cv]){
      q.push(mp(-cc-it->S.S,mp(it->F,us)));
      q.push(mp(-cc,mp(it->F,us+it->S.F)));
    }
  }
}

int main(){
  while(cin >> n >> m >> l && n) solve();
}

Measured memory_bytes: 2028
//package Beginner122;

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int q = s.nextInt();
        String str = s.next();
        int[] ans = new int[n];
        ans[0] = 0;
        for (int i = 1; i < n; i++) {
            if(str.charAt(i) == 'C') {
                if(str.charAt(i - 1) == 'A') {
                    ans[i] = ans[i - 1] + 1;
                } else {
                    ans[i] = ans[i - 1];
                }
            } else {
                ans[i] = ans[i - 1];
            }
        }

        for (int i = 0; i < q; i++) {
            int from = s.nextInt() - 1;
            int to = s.nextInt() - 1;
            System.out.println(ans[to] - ans[from]);
        }
//        System.out.println(Arrays.toString(ans));
    }
}


Measured memory_bytes: 51128
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int sum_int(int n){
    int res = 0;
    while(n>0){
        res += n%10;
        n /= 10;
    }
    return res;
}
int main(){
    cout << fixed << setprecision(10);
    int n,a,b;
    cin >> n >> a >> b;
    int ans = 0;
    for(int i=1;i<=n;i++){
        if(sum_int(i) >= a && sum_int(i)<=b) ans+=i;
    }
    cout << ans << endl;
    return 0;
}

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

namespace ConsoleApp11
{
    class Class1
    {
        public static void Main()
        {
            string[] S = Console.ReadLine().Split();
            double a = double.Parse(S[0]);
            double b = int.Parse(S[1]);
            double x = int.Parse(S[2]);
            double ans=-1;

            double xb = x / (a * a);

            if (xb >= b / 2)
            {
                ans = Math.Atan(2 * (b-xb) / a);
                ans = ChangeRad(ans);
            }
            else
            {
                double xa = 2 * x / (a * b);
                ans = Math.Atan((xa / b));
                ans = ChangeRad(ans);
                ans = 90 - ans;
            }
            Console.WriteLine(ans.ToString("0.0000000000"));
        }

        public static double ChangeRad(double ans)
        {
            ans *= 180 / Math.PI;
            return ans;
        }
    }
}


Measured memory_bytes: 11092
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<limits>
#include<ctime>
#include<stack>
#include<bits/stdc++.h>
#define long long
using namespace std;

int main(){
	int a,b,c,sum=3;
	cin>>a>>b>>c;
	if(a==b){
		sum--;
		if(a==c){
			sum--;
		}
	}
	else{
		if(b==c){
			sum--;
		}
		if(a==c){
			sum--;
		}
	}
	cout<<sum;
}


Measured memory_bytes: 3464
N = gets.to_i
S = gets.chomp

p = N - 1
(N - 1).downto(0) do |i|
  p = i
  if S[i] == '.'
    break
  end
end

bc = 0
wc = 0
ans = 0

(p).downto(0) do |i|
  if S[i] == '#'
    bc += 1
  else
    wc += 1
  end

  if bc > wc
    ans += wc
    bc = 0
    wc = 0
  end
end

puts ans + [bc, wc].min

Measured memory_bytes: 2172
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
ll from, to, cost;
bool operator<(const E &b) const { return cost < b.cost; }
bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
		h = "";
		i = j + 1;
	}
	return vec;
}
template<typename T>
void print_vec(vector<T>a) {
	for (int i = 0; i < a.size(); i++) {
		cout << (i == 0 ? "" : " ") << a[i];
	}
	cout << endl;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n, m;
string s, t;
int dp[3002][3002];
signed main() {
	int n, m;
	cin >> s >> t;
	n = s.size(), m = t.size();
	s = " " + s, t = " " + t;
	//i文字目、j文字目までの最長の共通部分列の長さ
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			if (s[i] == t[j]) {
				dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
			}
		}
	}
	int k = dp[n][m], r = dp[n][m];
	string ans = "";
	for (int z = 0; z < r; z++) {
		for (int i = n; i > 0; i--) {
			for (int j = m; j > 0; j--) {
				if (dp[i][j] == k && dp[i - 1][j - 1] == k - 1 && dp[i - 1][j] == k - 1 && dp[i][j - 1] == k - 1) {
					ans = s[i] + ans;
					n = i - 1, m = j - 1;
					k--;
					goto loop;
				}
			}
		}
	loop:;
	}
	cout << ans << endl;
}

Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fr(i,k,n) for(ll i = k;i<n;i++)
#define mo map<ll,ll> 
#define mod 1000000007
int main(){
	 ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   ll n;
   cin>>n;
   ll arr[n+2];
   fr(i,0,n){
   	cin>>arr[i];
   }
   ll suf[n+4];
   memset(suf,0,sizeof(suf));
 for(ll i = n-1;i>=0;i--){
 	suf[i] += suf[i+1];
 	suf[i] += arr[i];
 }
 ll ans = 0;
 fr(i,0,n){
ans += ((arr[i]%mod)*((suf[i+1])%mod))%mod;

 }
 ans %= mod;
 cout<<ans<<"\n";
}

Measured memory_bytes: 6768
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define pii pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
typedef long long ll;
typedef double db;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const int N = 1e4 + 5;
int n, m, k, pos;
char s[N];

int main(){
    scanf("%d", &n);
    scanf("%s", s+1);
    int len = strlen(s+1);
    rep(i,1,len){
        int ch = s[i] - 'A';
        ch += n;
        ch %= 26;
        putchar(ch+'A');
    }
    puts("");
    return 0;
}
/*

*/


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

def solveDp():
    POS, NEG = 0, 1
    dp = [[0 for _ in range(n + 1)] for _ in range(2)]
    dp[NEG][0] = -float('inf')
    for i in range(n):
        dp[POS][i + 1] = max(dp[POS][i] + a[i], dp[NEG][i] - a[i])
        dp[NEG][i + 1] = max(dp[POS][i] - a[i], dp[NEG][i] + a[i])
    print(dp[POS][n])

def solve():
    nNegative = 0
    total = 0
    minVal = float('inf')
    for num in a:
        if num < 0:
            num *= -1
            nNegative += 1
        minVal = min(minVal, num)
        total += num
    print(total if nNegative & 1 == 0 else total - 2 * minVal)

solveDp()

Measured memory_bytes: 16800
import sys
while 1:
  H, W = map(int, raw_input().split())
  if H==0 and W==0:
    break
  for i in range(H):
    for j in range(W):
      if i==0 or i==H-1 or j==0 or j==W-1:
        sys.stdout.write('#')
      else:
        sys.stdout.write('.')
    sys.stdout.write('\n')
  print ''

Measured memory_bytes: 6364
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	sc := newScanner()
	var n = sc.readString()
	var ans string
	if strings.HasSuffix(n, "s") {
		ans = n + "es"
	} else {
		ans = n + "s"
	}

	fmt.Println(ans)

}

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

func abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func pow(base, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent (%d) should not be a minus", exponent))
	}

	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func ceil(divident, dividor int) int {
	if dividor == 0 {
		panic("dividor should not be 0")
	}

	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func reverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func reverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type scanner struct {
	bufScanner *bufio.Scanner
}

func newScanner() *scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &scanner{bufSc}
}

func (sc *scanner) readString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *scanner) readInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func (sc *scanner) readInt64() int64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseInt(text, 10, 64)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 1780
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
 
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
 
 
 
using namespace std;
void file(){
	#ifndef ONLINE_JUDGE
    	freopen("tst.txt", "r", stdin);
	#endif
}
int tc;
const int N=1e6+7,M=3e5+5,MOD=1e9+7;

int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();
	
	string a;

	cin>>a;
	int ans = 0;
	for(int i=0;i<sz(a)/2;i++)if(a[i]!=a[sz(a)-i-1])ans++;

	cout<<ans<<endl; 
}


Measured memory_bytes: 256
def main():
    A, B, C = map(int, input().split())
    K = int(input())
    while (A >= B):
        K -= 1
        B *= 2
    while (B >= C):
        K -= 1
        C *= 2
        
    if K >= 0:
        print("Yes")
    else:
        print("No")
if __name__ == "__main__":
    main()

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

int main(){
    int n;
    cin >> n;
    for(int t=0;t<n;t++){
        vector<int> v(3);
        for(int i=0;i<3;i++)cin >> v[i];
        sort(v.begin(), v.end());
        if(v[0] * v[0] + v[1] * v[1] == v[2] * v[2]){
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1200
using System;
using System.Linq;
using static System.Console;

static class Extensions {
   public static int ToInt(this string str) {
      return int.Parse(str);
   }
}

class Program {
   public static void Main(string[] args) {
      var arr = ReadLine().Split(' ').Select(x => x.ToInt()).ToArray();
      var n = arr[0];
      var y = arr[1];

      for (int i = 0; i <= n; i++) {
         for (int j = 0; j + i <= n; j++) {
            var k = n - i - j;
            var sum = 10000 * i + 5000 * j + 1000 * k;
            
            if (sum == y) {
               WriteLine($"{i} {j} {k}");
               return;
            }
         }
      }
      
      WriteLine("-1 -1 -1");
   }
}


Measured memory_bytes: 13396
// C - Maximal Value
#include <stdio.h>

int main(void){
    int i, n, ans=0;
    int b[100];
    scanf("%d", &n);
    for(i=0; i<n-1; i++)scanf("%d", &b[i]);
    ans+=b[0];
    for(i=1; i<n-1; i++){
        ans += b[i-1]<b[i] ? b[i-1] : b[i];
    }
    ans+=b[n-2];
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x, y;
    cin >> x >> y;
    for (int i = 0; i <= x ; i++)
    {
        if((x-i)*2+i*4==y){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    
}

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

int k;
int a[500];
int main()
{
	scanf("%d",&k);
	if(k == 1) {
		printf("1\n1\n");
		return 0;
	}
	int n = ((k+3)/4)*2;
	printf("%d\n", n);
	for(int i = 0;i < n;++i) {
		for(int j = 0;j < n;++j) {
			int x = (i+j)%n;
			if(i%2==1 && x+n<k) x+=n;
			printf("%d ",x+1);
		}
		printf("\n");
	}
}


Measured memory_bytes: 1280
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    let mut s1: String;
    let mut s2: String;
    input! {
        s1: String,
        s2: String,
    }

    let s2_prepare = &s2[0..s1.len()];
    // println!("{}", s1_prepare);

    if &s1 == s2_prepare {
        println!("Yes")
    } else {
        println!("No")
    }
}


Measured memory_bytes: 2124
package main

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

var (
	sc = bufio.NewReader(os.Stdin)
)

func main() {
	X := abs(scanInt())
	K := scanInt()
	D := scanInt()

	KK := X / D
	if KK > K {
		fmt.Println(abs(X - K*D))
	} else {
		A := abs(X - KK*D)
		K -= KK
		if K%2 == 0 {
			fmt.Println(A)
		} else {
			fmt.Println(abs(A - D))
		}
	}
}

func abs(a int) int         { return int(math.Abs(float64(a))) }
func scan(a ...interface{}) { _, err := fmt.Fscan(sc, a...); pnc(err) }
func scanStr() (s string)   { scan(&s); return }
func scanInt() int          { i, err := strconv.Atoi(scanStr()); pnc(err); return i }
func scanFloat() float64    { f, err := strconv.ParseFloat(scanStr(), 64); pnc(err); return f }
func pnc(err error) {
	if err != nil {
		panic(err)
	}
}


Measured memory_bytes: 1840
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ

int main()
{
    int a, b;
    cin >> a >> b;
    if (b % a == 0)
    {
        cout << a + b;
    }
    else
    {
        cout << b - a;
    }
}

Measured memory_bytes: 256
N,M=map(int,input().split())
num=[1]*N
ex=[0]*N
ex[0]=1
P=[]
ans=1
for i in range(M):
    x,y=map(int,input().split())
    num[x-1]-=1
    num[y-1]+=1
    if ex[x-1]==1 and ex[y-1]==0:
        ex[y-1]=1
    if num[x-1]==0:
        ex[x-1]=0
print(sum(ex))

Measured memory_bytes: 10308
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define mem0(s) memset(s,0,sizeof(s))
#define meminf(s) memset(s,0x3f,sizeof(s))
#define mp_insert(a,b,c) mp.insert(map<pair<int,int>,int>::value_type(make_pair(a,b),c))
double pi=acos(-1);
typedef long long ll;
typedef unsigned long long ull;
inline ll lowbit(ll x){return x&(-x);}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll max(ll a,ll b){return a>b?a:b;}
const int INF=0x3f3f3f3f,max_n=200005;
const int mod=998244353;
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
inline ll pow(ll a,ll b,ll mod){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int a,b;
int data1[105];
int vis[105];
int main()
{
	int n,x;
	cin>>n>>x;
	for(int i=1;i<=x;i++)
	{
		cin>>a>>b;
		if(a==1&&b==0&&n!=1)
		{
			cout<<"-1";return 0;
		}
		else if(a==1&&b==0&&n==1)
		{
			cout<<"0";return 0;
		}
		if(vis[a]==1)
		{
			if(data1[a]!=b)
			{
				cout<<"-1";return 0;
			}
		}
		else if(vis[a]==0)
		{
			data1[a]=b;
			vis[a]=1;
		}
	}
	if(n==1&&x==0)
	{
		cout<<'0';return 0;
	}
	for(int i=1;i<=n;i++)
	{
		if(vis[i]==1)
		{
			cout<<data1[i];
		}
		else if(vis[i]!=1&&i!=1)
		{
			cout<<'0';
		}
		else cout<<'1';
	}
}


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

int main() {
    int N; cin >> N;
    vector<pair<int,int>> v;
    pair<int,int> p, q;
    int nowr = 1<<30;
    int nowl = 0;
    int max_len = 0;
    REP(i,N) {
        int l, r; cin >> l >> r; r++;
        if(l>nowl) {
            p = make_pair(l,r);
            nowl = l;
        }
        if(r<nowr) {
            q = make_pair(l,r);
            nowr = r;
        }
        max_len = max(max_len,r-l);
        v.push_back(make_pair(l,r));
    }
    int ans = max(0, nowr-nowl) + max_len;
    sort(all(v), [](const pair<int,int>&x, const pair<int,int>&y){
        if(x.second!=y.second)return x.second<y.second;
        return x.first>y.first;
    });
    vector<int> rui(N+1,0);
    REP(i,N){
        rui[i+1] = max(rui[i],v[i].first);
    }
    REP(i,N-1){
        ans = max(ans,max(0,nowr-rui[i+1])+max(0,v[i+1].second-nowl));
    }
    //REP(i,N) cout << v[i].first << ' ' << v[i].second << endl;
    //REP(i,N+1) cout << rui[i] << ' '; cout << endl;
    cout << ans << endl;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORC(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define dd long double
#define mod 1000000007
const ll N=2e6+10;
ll dp[N];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    dp[0]=0;
    for(ll i=1;i<N;i++){
        dp[i]=dp[i-1]+i;
    }
    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=2;i*i<=n;i++){
        ll temp=0;
        if(n%i==0){
            while(n%i==0){
                temp++;
                n/=i;
            }
            ll x=upper_bound(dp,dp+N,temp)-dp;
            x--;
            ans+=x;
        }

    }
    if(n>1){
        ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 19244
#include <bits/stdc++.h>
using namespace std;
#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 fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}


const int n_max = 5005;
int n,k;
int A[n_max];
int dp[n_max];

bool solve(int id){
    if(A[id] >= k) return true;
    REP(i,k+1) dp[i] = false;
    dp[0] = true;
    REP(i,n){
        if(i == id) continue;
        REPR(j,k){
            if(j - A[i] < 0) break;
            if( dp[j - A[i]] ) dp[j] = true;
        }
    }
    bool res = false;
    FOR(i,k - A[id],k){
        res |= dp[i];
    }
    return res;
}

signed main(){
    cin >>  n >> k;
    REP(i,n) cin >> A[i];
    sort(A,A+n);

    int l = -1;
    int r = n;
    while(l + 1 < r){
        int mid = (l + r) / 2;
        if(solve(mid)) r = mid;
        else l = mid;
    }

    cout << l + 1 << endl;
    return 0;



}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int n, k;
    cin >> n >> k;
    double ans = 0;
    for(int i = 1; i <= n; i++){
        int num = i;
        double win = 1.0;
        while(num < k){
            num *= 2;
            win /= 2.0;
        }
        ans += win;
    }
    ans /= n;
    printf("%.12f\n", ans);
    return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FOR(i,j,n,m) for(int i=j;i<n;i+=m)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.F<<","<<_p.S<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}

template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=5e2+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=(ll)1e18;

ll n,c;
ll w[30][30];
ll d[3][30];
ll id(int i,int j){return (i+j)%3;}
ll cal(ll a,ll b){
  ll ret = 0;
  REP(i,c) ret+=d[a][i]*w[i][b];
  return ret;
}
int main(){
  IOS();
  cin>>n>>c;
  REP(i,c)REP(j,c) cin>>w[i][j];
  REP(i,n)REP(j,n){
    ll tmp;
    cin>>tmp;
    tmp--;
    d[id(i,j)][tmp]++;
  }
  ll ans = INF;
  REP(i,c)REP(j,c)REP(k,c){
    if(i==j || j==k || i==k) continue;
    ll tp = cal(0,i) + cal(1,j) + cal(2,k);
    chkmin(ans,tp);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
<?php
    /*
        Problem URL : http://arc070.contest.atcoder.jp/tasks/arc070_a

        Score  :
        Result :
        Time   : ms
        Memory : KB
     */

    ini_set('error_reporting', E_ALL & ~E_NOTICE);

    define('DEBUG', false);

    fscanf(STDIN, "%d\n", $X);

    for ($i = 1; $i < PHP_INT_MAX; $i++) {
        $a += $i;
        if ($a >= $X) {
            echo $i . PHP_EOL;
            exit;
        }
    }



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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  if (a == 2 || b == 2) cout << "No\n";
  else cout << "Yes\n";
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[],int n,int left, int mid, int right) {
  int i, j, k;
  int n1 = mid -left;
  int n2 = right - mid;
  for(i=0;i<n1;i++) L[i] = A[left + i];
  for(i=0;i<n2;i++) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  i=0, j=0;
  for(k=left; k<right; k++) {
    cnt++;
    if(L[i]<=R[j]) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(int A[],int n,int left,int right) {
  int mid;
  if(left+1 < right) {
    mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}

int main(void) {
  int A[MAX], n, i;
  cnt = 0;

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

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

  return 0;
}


Measured memory_bytes: 5604
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
//No change above here

const ll maxi = 2 * 1e5 + 5;
ll mod = 5;
double pi = 3.141592653589793238;

//function for power
ll power(ll x, ll n) {
	ll res = 1;
	x %= mod;
	while (n) {
		if (n & 1)
			res = (res * x) % mod;
		x = (x * x) % mod;
		n >>= 1;
	}
	return res;
}

ll sum_digits(ll n)
{
	ll ret = 0;
	while (n)
	{
		ret += n % 10;
		n /= 10;
	}
	return ret;
}

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

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

ll max_subarray(vector<int>& v)
{
	if (v.empty())
		return 0;
	ll glob = v[0], loc = v[0];
	for (int i = 1; i < v.size(); ++i)
	{
		loc = max(v[i] + 0LL, loc + v[i]);
		glob = max(loc, glob);
	}
	return glob;
}

long long num_digits(long long x)
{
	long long ans = 0;
	while (x)
	{
		++ans;
		x /= 10;
	}
	return ans == 0 ? 1 : ans;
}

vector<int> topological_sort(vector<vector<int>>& graph, int n, vector<int>& indegree)
{
	vector<int> ans;
	stack<int> s;
	for (int i = 0; i < n; ++i)
		if (indegree[i] == 0)
			s.push(i);
	while (!s.empty())
	{
		int x = s.top();
		s.pop();
		ans.push_back(x);
		for (auto& adj : graph[x])
			if (--indegree[adj] == 0)
				s.push(adj);
	}
	return ans;
}

ll dir[4][2] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

ll p, q;
bool valid(ll i, ll j) { return i >= 1 && i <= p && j >= 1 && j <= q; }


//declare needed things here


int main()
{
	IOS;
	ll n;
	cin >> n;
	string s;
	cin >> s;
	ll numr = 0, numw = 0;
	for (int i = 0; i < n; ++i)
	{
		if (s[i] == 'R')
			numr++;
		else
			numw++;
	}
	ll ans = min(numr, numw);
	ll c = 0;
	for (int i = numr; i < n; ++i)
		if (s[i] == 'R')
			c++;
	ans = min(ans, c);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int[] masu = new int[n];
		for (int i = 0; i < n; i++) {
			masu[i] = sc.nextInt();
		}
		int[] dp = new int[n];
		
		for (int i = 1; i < n; i++) {
			if (masu[i] <= masu[i-1]) {
				dp[i] = dp[i-1] + 1;
			}
		}
		
		int res = 0;
		
		
		for (int h: dp) {
			res = Math.max(res, h);
		}
		
		System.out.println(res);
	}

    static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


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

int main() {
  string s[3];
  cin >> s[0] >> s[1] >> s[2];
  char ans[4];
  ans[0] = s[0][0] - 32;
  ans[1] = s[1][0] - 32;
  ans[2] = s[2][0] - 32;
  ans[3] = '\0';
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
class Dice2{
public:
    Dice2(){
        number = new int[6];
        relative = new int[55];
        relative[31] = relative[43] = relative[24] = relative[12] = 0;
        relative[3] = relative[20] = relative[52] = relative[35] = 1;
        relative[1] = relative[40] = relative[54] = relative[15] = 2;
        relative[4] = relative[10] = relative[51] = relative[45] = 3;
        relative[2] = relative[30] = relative[53] = relative[25] = 4;
        relative[21] = relative[42] = relative[34] = relative[13] = 5;
    };
    ~Dice2(){
        delete[] number;
        delete[] relative;
    };
 
    void setNumber(int index,int num){
        number[index] = num;
    };
 
    int returnRight(int top,int front){
        int top_index,front_index;
        for(int i = 0; i < 6; i++){
            if(number[i] == top)
                top_index = i;
            if(number[i] == front)
                front_index = i;
        }
        return number[relative[10*top_index+front_index]];
    }
private:
    int* number;
    int* relative;
};
 
int main(){
    Dice2 dice2;
    int x,q,top,front;
    for(int i = 0; i < 6; i++){
        scanf("%d",&x);
        dice2.setNumber(i,x);
    }
    scanf("%d",&q);
    for(int i = 0; i < q; i++){
        scanf("%d %d",&top,&front);
        printf("%d\n",dice2.returnRight(top,front));
    }
}




Measured memory_bytes: 2724
import java.util.*;

public class Main{
    void run(){
        Scanner sc = new Scanner(System.in);
        while(true){
            int m = sc.nextInt();
            if(m==0){
                break;
            }
            int[] value = new int[m];
            int[] num = new int[m];
            for(int i = 0; i < m; i++){
                value[i] = sc.nextInt();
                num[i] = sc.nextInt();
            }
            int[] dp = new int[1001];
            dp[0] = 1;
            for(int i = 0; i < m; i++){
                for(int ii = 1000 - value[i]; ii >= 0; ii--){
                    for(int v = value[i]; v <= value[i] * num[i]; v += value[i]){
                        if(ii + v <= 1000){
                            dp[ii + v] += dp[ii];
                        }
                    }
                }
            }
            /*
              System.out.println(Arrays.toString(dp));
              for(int i = 0; i < 100; i++){
              System.out.println(i + " : " + dp[i]);
              }
            */
            int g = sc.nextInt();
            for(int i = 0; i < g; i++){
                System.out.println(dp[sc.nextInt()]);
            }
        }
    }
    public static void main(String[] args){
        new Main().run();
    }
}

Measured memory_bytes: 20752
#include <bits/stdc++.h>
#define int long long
using namespace std;
int32_t main() {
    int n,w;
    cin>>n>>w;
    vector<pair<int,int>>v(n+1);
    for(int i=0;i<n;i++)
    {
        int a;
        int b;
        cin>>a>>b;
        v[i+1]=make_pair(a,b);
    }
    int k[n+1][w+1]={0};
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=w;j++)
        {
            if(i==0 || j==0)
            k[i][j]=0;
            else if(v[i].first<=j)
            {
                k[i][j]=max(k[i-1][j],k[i-1][j-v[i].first]+v[i].second);
            }
            else
            k[i][j]=k[i-1][j];
        }
    }
    cout<<k[n][w]<<endl;
}


Measured memory_bytes: 79104
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

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

int main() {
	ll H,W, K;
	cin >> H >> W >> K;
	vector<vector<char>> c(H, vector<char>(W));
	rep(i, H)rep(j, W) cin >> c[i][j];

	ll ans = 0;

	rep(x, 1 << H)rep(y, 1 << W) {
		ll cnt = 0;
		rep(i, H)rep(j, W) {
			if (((x >> i) & 1) && ((y >> j) & 1) && c[i][j] == '#') { cnt++; }
		}
		if (cnt == K) {ans++; }
	}

	cout << ans << endl;

}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 3e5 + 10, mod = 1e9 + 7;
struct node {
  int x, y, w, tag;
} e[N];
struct data {
  int nt, to, w;
} a[N << 1];
int head[N], f[N], cnt = 0;
 
void add(int x, int y, int w) {
  a[++cnt].to = y;
  a[cnt].w = w;
  a[cnt].nt = head[x];
  head[x] = cnt;
}
 
bool cmp(node A, node B) {
  return A.w < B.w;
}
 
void Add(int &x, int y) {
  x = (x + y) % mod;
}
 
int sub(int x, int y) {
  return (x -= y) < 0 ? x + mod : x;
}
 
int mul(int x, int y) {
  return 1ll * x * y % mod;
}
 
void Mul(int &x, int y) {
  x = mul(x, y);
}
 
int q_pow(int x, int y) {
  int ans = 1;
  for(; y; y >>= 1) {
    if(y & 1) Mul(ans, x);
    Mul(x, x);
  }
  return ans;
}
 
int find(int k) {
  return f[k] == k ? f[k] : f[k] = find(f[k]);
}
 
const int LOG = 20;
int dep[N], g[N][LOG + 1], mx[N][LOG + 1];
 
void dfs(int u, int fa) {
  dep[u] = dep[fa] + 1, g[u][0] = fa;
  for(int i = 1; i <= LOG; ++i) {
    g[u][i] = g[g[u][i - 1]][i - 1];
    mx[u][i] = max(mx[u][i - 1], mx[g[u][i - 1]][i - 1]);
  }
  for(int i = head[u]; i; i = a[i].nt) {
    int to = a[i].to;
    if(to == fa) continue;
    mx[to][0] = a[i].w;
    dfs(to, u);
  }
}
 
int GetMx(int A, int B) {
  if(A == B) return 0;
  if(dep[A] > dep[B]) swap(A, B);
  int ans = 0;
  for(int i = LOG; i >= 0; --i) {
    if(dep[g[B][i]] >= dep[A]) {
      ans = max(ans, mx[B][i]);
      B = g[B][i];
    }
  }
  if(A == B) return ans;
  for(int i = LOG; i >= 0; --i) {
    if(g[A][i] != g[B][i]) {
      ans = max(ans, max(mx[A][i], mx[B][i]));
      A = g[A][i], B = g[B][i];
    }
  }
  return max(max(mx[B][0], mx[A][0]), ans);
}
 
ll val[N];
 
int main() {
  int T;
//  scanf("%d", &T);
//  for(int o = 1; o <= T; ++o) {
/*    cnt = 0;
    memset(head, 0, sizeof head);
    memset(g, 0, sizeof g);
    memset(mx, 0, sizeof mx);
    memset(dep, 0, sizeof dep);
    memset(val, 0, sizeof val);*/
    int n, m;
    ll z;
    scanf("%d%d%lld", &n, &m, &z);
    for(int i = 1; i <= m; ++i) {
      e[i].tag = 0;
      scanf("%d%d%d", &e[i].x, &e[i].y, &e[i].w);
    }
    for(int i = 1; i <= n; ++i) f[i] = i;
    sort(e + 1, e + 1 + m, cmp);
    ll now = 0;
    for(int i = 1; i <= m; ++i) {
      int fx = find(e[i].x), fy = find(e[i].y);
      if(fx != fy) {
        f[fx] = fy;
        now += 1ll * e[i].w;
        e[i].tag = 1;
        add(e[i].x, e[i].y, e[i].w);
        add(e[i].y, e[i].x, e[i].w);
      }
    }
    now = z - now;
    int ans = 0;
    if(now < 0) {
      puts("0");
      return 0;
    } else if(!now) {
      ans = mul(sub(q_pow(2, n - 1), 2), q_pow(2, m - n + 1));
    }
    dfs(1, 0);
    int res = 0;
    for(int i = 1; i <= m; ++i) {
      if(e[i].tag) continue;
      val[++res] = e[i].w - GetMx(e[i].x, e[i].y);
    }
    sort(val + 1, val + 1 + res);
    for(int i = 1; i <= res; ++i) {
      if(val[i] == now) {
        Add(ans, q_pow(2, res - i + 1));
      }
    }
    printf("%d\n", ans);
//  }
  return 0;
}

Measured memory_bytes: 10496
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

#define MOD 1000000007

int n;
string mas[2];

int main() {

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

    long long ans = 1;
    int y, x;
    if(mas[0][0] == mas[1][0]){
        y = 0, x = 1;
        ans *= 3;
    }
    else {
        y = 0, x = 2;
        ans *= 6;
    }
    while(x < n) {
        if(y == 0) {
            if(mas[0][x] == mas[1][x]) { // tate
                // left
                if(mas[0][x - 1] == mas[1][x - 1]) { // tate
                    ans = ans * 2 % MOD;
                }
                y = 0, x++;
            } else { // yoko
                if(mas[0][x - 1] != mas[1][x - 1]) { // tate
                    ans = ans * 3 % MOD;
                }
                else ans = ans * 2 % MOD;
                x += 2;
            }
        }
    }
    cout << ans << endl;
}


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

int main() {
  int n;
  cin >> n;
  int a = n/1000;
  int b = (n -a*1000)/100;
  int c = (n - a*1000 - b*100)/10;
  int d = n - a*1000 - b*100 - c*10;
  if((a==b && a==c) || (b==c && b==d)){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
N, K = map(int,input().split())
D = list(map(int,input().split()))
ans = N
while True:
    str_a = str(ans)
    OK = True
    for s in str_a:
        if int(s) in D:
            OK = False
            break
    if OK:
        break
    ans += 1
print(ans)

Measured memory_bytes: 40796
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int H,N,i,sum=0;
    scanf("%d %d",&H,&N);
    int A[N];
    for (i=0;i<N;i++)
    {
        scanf("%d",&A[i]);
        sum+=A[i];
    }
    if (sum>=H)
        printf("Yes");
    else
        printf("No");
    return 0;
}


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

template<class Type> inline bool chmax(Type& a, Type b) { if (a < b) { a = b; return 1; } return 0; }
template<class Type> inline bool chmin(Type& a, Type b) { if (a > b) { a = b; return 1; } return 0; }

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n)
	{
		if (n & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y)
	{
		swap(x, y);
	}

	while (0 < y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
bool isPrime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2)
	{
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++)
	{
		if (isPrime[i])
		{
			Type j = i + i;
			while (j <= n)
			{
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binarySearchJudge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binarySearch(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok))
	{
		int mid = (ng + ok) / 2;
		if (binarySearchJudge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

double dist(vector<int> x, vector<int> y, int i, int j)
{
	return sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
}

int main()
{
	int a, b, c;
	cin >> a >> b >> c;

	int h = max(a, b);
	h = max(h, c);
	int l = min(a, b);
	l = min(l, c);
	int m = a + b + c - h - l;

	if ((h - m + h - l) % 2 == 0)
	{
		cout << (h - m + h - l) / 2 << endl;
	}
	else
	{
		cout << (h - m + h - l) / 2 + 2 << endl;
	}
}

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


int x[110000]={},y[110000]={};


int main(){
  int n,W,H;
  scanf("%d%d%d",&n,&W,&H);
  for(int i=0;i<n;i++){
    int xw,yw,w;
    scanf("%d%d%d",&xw,&yw,&w);
    x[max(0,xw-w)]=max(x[max(0,xw-w)],min(xw+w,W));
    y[max(0,yw-w)]=max(y[max(0,yw-w)],min(yw+w,H));
  }
  bool xyes=false;
  int mx=x[0];
  for(int i=0;i<=mx;i++){
    mx=max(mx,x[i]);
    if(mx>=W){xyes=true; break;}
  }
  bool yyes=false;
  mx=y[0];
  for(int i=0;i<=mx;i++){
    mx=max(mx,y[i]);
    if(mx>=H){yyes=true; break;}
  }


  
  bool yes=true;
  if(!xyes && !yyes){yes=false;}
  if(yes){
    printf("Yes\n");
  }
  else{printf("No\n");}

  return 0;
}



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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int a, p; cin >> a >> p;
    p += a * 3;
    cout << p / 2 << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 3620
#include"stdio.h"
int main(){
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    int f[n];
    for(int i=0;i<n;i++) f[i]=0;
    int cnt=1,k=a[0];
    f[0]=1;
    while(1){
        if(k==2)  break;
        k=a[k-1];
        f[k-1]++;
        if(f[k-1]==2){
            printf("-1\n");
            return 0;
        }
        cnt++;
    }
    printf("%d\n",cnt);
}


Measured memory_bytes: 2496
#include <stdio.h>
int main(void){
  
  int h,w;
  int i,j;
  
  while(1){
    
    scanf("%d %d",&h,&w);
    if(h==0&&w==0)break;
  

    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	printf("#");
      }
      printf("\n");    
    }
    printf("\n");
    
  }
  return 0;
}

Measured memory_bytes: 1000