akhauriyash/Code-Regression huggingface dataset:
use std::io;


fn read_line() -> String {
    let mut line = String::new();

    io::stdin().read_line(&mut line)
        .expect("Failed to read line");
    return line;
}
fn to_i(s: &str) -> i64 {
    return s.trim().parse()
        .expect("Please type a number!");
}
fn read_nums() -> Vec<i64>
{
    let line = read_line();
    let items: Vec<&str> = line.split(' ').collect();

    let mut nums: Vec<i64> = Vec::new();

    for item in items {
        nums.push(to_i(item));
    }
    return nums;
}


fn main() {
    //println!("start");
    let n: i64 = to_i( &read_line() );
    //println!("n:{}",n);
    let vv ;
    if n==1 {
        vv = vec![to_i( &read_line() )];
    } else {
        vv = read_nums();
    }
    let cc  ;
    if n==1 {
        cc = vec![to_i( &read_line() )];
    } else {
        cc = read_nums();
    }

    let mut ret = 0;
    for i in 0..n {
        let index = i as usize;
        let v = vv[index];
        let c = cc[index];
        if v>c {
            ret += v-c;
        }
    }



    print!("{}", ret);
}   

Measured memory_bytes: 4352
X = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(X[K - 1])


Measured memory_bytes: 38256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = (int) sc.nextLong();
		int q = (int) sc.nextLong();
		char[] acgt = sc.next().toCharArray();
		int[] cArray = new int[n];
		int count = 0;

		for (int i = 0; i < n - 1; i++) {
			if (acgt[i] == 'A' && acgt[i + 1] == 'C') {
				count++;
			}
			cArray[i + 1] = count;
		}

		for (int j = 0; j < q; j++) {
			int l = (int) sc.nextLong();
			int r = (int) sc.nextLong();
			System.out.println(cArray[r - 1] - cArray[l - 1]);
		}
	}
}

/**
 * from qiita
 */
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}


Measured memory_bytes: 56764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=(ll)(1e9+7);
ll run();

int main() {
#ifdef home
    freopen("i", "r", stdin);
    freopen("d", "w", stderr);
#endif
    cout.precision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    run();
    return 0;
}

ll run() {
    double a,b;
    cin>>a>>b;
    printf("%0.12f",(a/b));


}

























Measured memory_bytes: 256
#C
l,r = map(int,input().split())
tmp = []
if r*(r-1) < 2019:
    print(r*(r-1))
    
else:
    if r - l >= 2019 or l <= (r//2019) * 2019 <= r :
        print(0)       
    else:
        for i in range(l,r+1):
            for j in range(i+1,r+1):
                m = (i*j) % 2019
                tmp.append(m)
        print(min(tmp))
            

Measured memory_bytes: 75408
#include<iostream>
using namespace std;
int n,k,w[100000];
bool check(int P){
  int c=0,i;
  int f=1;
  for(i=0;i<n&&f;){
    int p=0;
    if(P<w[i]){f=0;break;}
    while(i<n&&p+w[i]<=P)p+=w[i++];
    c++;
  }
  return c<=k&&f&&i==n;
}
int main(){
  int l=0,m,r=1000000000;
  cin>>n>>k;
  for(int i=0;i<n;i++)cin>>w[i];
  while(l<r){
    m=(l+r)/2;
    if(check(m))r=m;
    else l=m+1;
  }
  cout<<r<<endl;
  return 0;
}

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

typedef long long ll;

int Len(ll x)
{
    int ans=0;
    while(x>0){
        ans+=1;
        x/=10;
    }
    return ans;
}

int main()
{
   ll x;
   cin>>x;
   ll ret=1e12;
   for(ll i=1;i*i<=x;i++){
        if(x%i==0)
            ret=min(ret,1LL*max(Len(i),Len(x/i)));
   }
   cout<<ret;


}


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

// {
#define debug(var)  do{ std::cout << #var << " : "; view(var); }while(0)
using ll = long long;
using ld = long double;
inline int num (const std::string& S, int idx) noexcept { return S.at(idx) - '0'; }
inline int ctoi(char c) noexcept { return c - '0'; }
inline bool isNumber(char c) noexcept { return ('0'<c && c<'9'? true : false); }
inline int safeCtoi(char c) { if(isNumber(c)) { return ctoi(c); } else { throw 1; } }
inline char itoc(int i) noexcept { return i + '0'; }
inline unsigned int bitMask(int i) noexcept { return (1 << i); }
inline bool isTrue(unsigned int bit, int i) noexcept { return bit & bitMask(i); }
inline bool isEven(int num) noexcept { return !num%2; }
inline bool isOdd(int num) noexcept { return num%2; }
template<typename T> inline short sgn(T num) noexcept { return (num==0? 0 : (num>0? 1 : -1) ); }
template<typename T> inline bool isZero(T num) noexcept { return (num==0? true : false); }
template<typename T> inline bool isPositive(T num) noexcept { return (num>0? true : false); }
template<typename T> inline bool isNegative(T num) noexcept { return (num<0? true : false); }
template<typename T> void view(T e) noexcept { cout << e; }
template<typename T> void view(std::vector<T> v) noexcept { for(const auto& e : v) cout << e << " "; }
template<typename T> void view(std::vector<std::vector<T>> vv) noexcept { for(const auto& v : vv) view(v); }
//}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s, t;
	cin >> s >> t;
	int diffCount = 0;
	for(size_t i=0; i<s.length(); ++i){
		if( s[i] != t[i] ){
			diffCount++;
		}
	}
	cout << diffCount << endl;
	return 0;
}


Measured memory_bytes: 3792
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define F first
#define S second
#define pss pair<string,string>
#define pcc pair<char,char>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define vs vector<string>
#define vl vector<ll>
#define vs vector<string>
#define vll vector<pll>
#define vss vector<pss>
#define vcc vector<pcc>
#define MP make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=n-1;i>=0;i--)
#define Very_fast std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int N = 1e5+5;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
inline ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll lowbit(ll x){return (x&-x);}
inline ll kissme(ll x,ll y)
{
	ll res=1;
	if(x==0)return 1;
	if(x==1)return y;
	res=kissme(x/2,y);
	res=res*res%mod;
	if(x%2==1)res=res*y%mod;
	return res;
}
int n;
ll ans;
map<ll,ll>mp;
signed main()
{
	Very_fast;
	cin>>n;
	rep(i,n){
		int x;
		cin>>x;
		ans+=mp[i+1-x];
		mp[i+x+1]++;
	}
	cout<<ans<<"\n";
	return 0;
}

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

int main()
{
	static int n;
	scanf( "%d", &n );
	
	int now_time, now_x, now_y;
	now_time = now_x = now_y = 0;
	int t, x, y, dis;
	for( int i = 1; i <= n; i ++, now_x = x, now_y = y, now_time = t )
	{
		scanf( "%d%d%d", &t, &x, &y );
		
		dis = abs( x - now_x ) + abs( y - now_y );
		if( ( t - now_time - dis ) %2 == 0 && t - now_time - dis >= 0 ) 
			continue;
		
		printf( "No\n" ); return 0; 
	}
	
	printf( "Yes\n" );
	
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
H = [int(input()) for _ in range(N)]
H.sort()

ans = 10**18
for i in range(N - K + 1):
    ans = min(ans, abs(H[i] - abs(H[i + K - 1])))

print(ans)


Measured memory_bytes: 7384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 1001001001;

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

    int ans = 0;
    for(int i=0;i<=100;i++){
        if(i>a&&i<=b&&i>c&&i<=d) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto rd = readln.split.to!(size_t[]), n = rd[0], t = rd[1];
  auto a = readln.split.to!(int[]);

  auto b = new int[](n-1), m = a[0];
  foreach (i; 0..n-1) {
    b[i] = a[i+1] - m;
    m = min(m, a[i+1]);
  }

  auto c = b.reduce!max;
  writeln(b.count(c));
}


Measured memory_bytes: 4404
use std::cmp;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let m: usize = sc.read();
    let x: Vec<usize> = sc.read_vec(n);
    let max: usize = x.iter().map(|&x| x).max().unwrap();
    let mut count = vec![0; max + 1];
    for &x in &x {
        count[x] += 1;
    }

    let mut mod_count = vec![0; m];
    let mut pair_count = vec![0; m];
    for i in 0..(max + 1) {
        mod_count[i % m] += count[i];
        pair_count[i % m] += count[i] / 2;
    }

    let mut ans = 0;
    for i in 1..m {
        if i * 2 == m {
            continue;
        }
        let p = cmp::min(mod_count[i], mod_count[m - i]);
        ans += p;
        mod_count[i] -= p;
        mod_count[m - i] -= p;
    }

    if m % 2 == 0 {
        ans += mod_count[m / 2] / 2;
        mod_count[m / 2] %= 2;
    }

    for i in 1..m {
        ans += cmp::min(mod_count[i] / 2, pair_count[i]);
    }
    ans += mod_count[0] / 2;

    println!("{}", ans);
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read_vec<T>(&mut self, n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        (0..n).map(|_| self.read()).collect()
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


Measured memory_bytes: 6396
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n,m;cin>>n>>m;
  rep(i,0,m){
    ll x;cin>>x;
    n-=x;
  }

  if(n<0)cout<<-1<<ENDL;
  else cout<<n<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 3644
import java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

@SuppressWarnings("unchecked")
class MinCostTree{

    int N;
    class Edge{
        int from,to;
        long w;
        Edge(int from,int to,long w){this.from=from;this.to=to;this.w=w;}
    }
    List<Edge> edges[];
    List<Edge> minedge[];
    void add_edge(int u,int v,long w){
        edges[u].add(new Edge(u,v,w));
        edges[v].add(new Edge(v,u,w));
    }
    MinCostTree(int N){
        this.N=N;
        edges = new ArrayList[N];
        minedge = new ArrayList[N];
        for(int i=0;i<N;++i)edges[i]=new ArrayList<>();
        for(int i=0;i<N;++i)minedge[i]=new ArrayList<>();
    }
    long mincost(){
        PriorityQueue<Edge> que = new PriorityQueue<>((a,b)->a.w<b.w ? -1:1);
        boolean used[] = new boolean[N];
        used[0]=true;
        long res = 0;
        for(Edge e : edges[0])que.add(e);
        while(!que.isEmpty()){
            Edge e = que.poll();
            if(used[e.to])continue;
            used[e.to]=true;
            minedge[e.from].add(e);
            res += e.w;
            for(Edge ed : edges[e.to])que.add(ed);
        }
        return res;
    }
}

class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        MinCostTree mct = new MinCostTree(n);
        for(int i=0;i<n;++i){
            for(int j=0;j<n;++j){
                long a = scan.nextLong();
                if(i>j && a>=0)mct.add_edge(i, j, a);
            }
        }
        System.out.println(mct.mincost());
    }


}


Measured memory_bytes: 45564
#include<iostream>
#include<string>
#include <vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
const ll MOD = 1e9 + 7;

int main() {
	int n;
	cin >> n;
	vector<ll> a(3*n);
	rep(i, 3*n) cin >> a[i];
	vsort(a);
	ll sum = 0;
	for(int i=n;i<3*n;i+=2) sum += a[i];
	cout << sum << endl;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

int n;
int main()
{
 //freopen("in.txt","r",stdin);
 //freopen("out.txt","w",stdout);
	cin>>n;
	cout<<"ABC";
	cout<<n<<endl;
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>
#define ALL(V) V.begin(),V.end()
#define f1(a,b) for(int a=1;a<=b;a++)
#define f0(a,b) for(int a=0;a<b;a++)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define de(x) cout<<#x<<": "<<x<<endl
using namespace std;
const LL N=1e6+69, base=1024*1024,mod=1e9+7;
LL a[N],b[N],n;
pll w;
int32_t main(void) {
    boost;
    cin>>n;
    f0(i,n) cin>>a[i];
    f0(i,n) cin>>b[i];
    f0(i,n) {
        if(a[i]>b[i]) w.s+=-(b[i]-a[i]);
        if(a[i]<b[i]) {
            int zm=(b[i]-a[i]);
            if(zm%2==0) w.f+=(zm/2);
            else {
                w.f+=(zm/2)+1;
                w.s++;
            }
        }
    }
    //cout<<w.f<<" "<<w.s<<endl;
    if(w.f>=w.s) cout<<"Yes\n";
    else cout<<"No\n";
}


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

int main() {
  int l,r,d;
  cin >> l >> r >> d;
  int ans = 0;
  
  for(int i=l;i<=r;i++){
    if(i%d == 0){
      ans ++;
    }
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;
void swap(ll &a,ll &b){
    ll temp=a;
    a=b;
    b=temp;
}
ll gcd(ll a,ll b){
    while(b){
        a%=b;
        swap(a,b);
    }
    return a;
}

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




int main(){
    int N;
    cin>>N;
    vi vt(N);
    F0R(i,N){
        cin>>vt[i];
    }
    int curr=1;
    for(int i=0;i<N;i++){
        int flag=1;
        while(vt[i]!=curr){
            i++;
            if(i>=N){
                flag=0;
                break;
            }
        }
        if(flag){
            curr++;
        }else{
            break;
        }
    }
    if(curr==1){
        out(-1);
    }else{
        out(vt.size()-(curr-1));
    }

    return 0;
}


Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
pre = -2
for i in range(n):
    curr = a[i] - 1
    ans += b[curr]
    if curr == pre + 1:
        ans += c[pre]
    pre = a[i] - 1
print(ans)


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int tax(int rate,int price_without_tax){
    int price_with_tax;
    price_with_tax = price_without_tax * (100 + rate) / 100;
    return price_with_tax;
}

int main(){
    int x,y,s;
    int maxPrice = 0;
    while(cin >> x >> y >> s && x > 0)
    {
        maxPrice = 0;
        for(int i = 1; i < s; ++i)
        {
            for(int j = i; j < s; ++j)
            {
                if(tax(x,i)+tax(x,j) == s)
                {
                    maxPrice = max(maxPrice, tax(y,i)+tax(y,j));
                }
            }
        }
        cout << maxPrice << endl;
    }
    return 0;
}


Measured memory_bytes: 3040
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())


int main(){
	int a,b; cin >> a >> b;
	if(a<=9 && b<=9) cout << a*b << endl;
	else cout << -1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

const ll mod = 1e9 + 7;


map<pair<int,int>, int> mp;


int main()
{
    FASTIO
     /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    // cin >> T;
    T = 1;
    for(int cs = 1; cs <= T; cs++)
    {
        // dream, dreamer, erase, eraser
        string s;
        cin >> s;
        int l = s.length();
        int i = l - 1;
        while(i >= 0)
        {
            if(i< 4)
            {
                cout << "NO\n";
                return 0;
            }
            if(s[i - 2] == 'e')  // dream
            {
                if(s[i - 4] == 'd' && s[i - 3] == 'r' && s[i - 1] == 'a' && s[i] == 'm') i -= 5;
                else
                {
                    cout << "NO\n";
                    return 0;
                }
            }

            else if(s[i - 2] == 'a')  // erase
            {
                if(s[i - 4] == 'e' && s[i - 3] == 'r' && s[i - 1] == 's' && s[i] == 'e') i -= 5;
                else
                {
                    cout << "NO\n";
                    return 0;
                }
            }
            else if(i < 5)
            {
                cout << "NO\n";
                return 0;
            }

            else if(s[i - 2] == 's')  // eraser
            {
                if(s[i - 5] == 'e' && s[i - 4] == 'r' && s[i - 3] == 'a' && s[i - 1] == 'e' && s[i] == 'r') i -= 6;
                else
                {
                    cout << "NO\n";
                    return 0;
                }
            }

            else if(i < 6)
            {
                cout << "NO\n";
                return 0;
            }

            else if(s[i - 2] == 'm')  // dreamer
            {
                if(s[i - 6] == 'd'&& s[i - 5] == 'r' && s[i - 4] == 'e' && s[i - 3] == 'a' && s[i - 1] == 'e' && s[i] == 'r') i -= 7;
                else
                {
                    cout << "NO\n";
                    return 0;
                }
            }
          else {
          cout << "NO\n";
            return 0;
          }


        }
        cout << "YES\n";
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
char a[3];
cin >> a;
if(a[0]==a[2]) {
  cout << "Yes" << endl;
} else {
  cout << "No" << endl;
}
return 0;
}


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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

int main() {
  ll n, i;
  cin >> n >> i;

  cout << n - i + 1 << endl;
}

Measured memory_bytes: 3600
#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 ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N,M; cin >> N >> M;
    vector<int> A(M,0);
    REP(k,N){
        int K; cin >> K;
        REP(i,K){
            int a; cin >> a; a--;
            A[a]++;
        }
    }

    int ans = 0;
    REP(i,M){  
        if(A[i] == N) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3572
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.stream.Stream;
import java.util.TreeSet;

public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String S = br.readLine();
        int N = S.length();
        
        int[] childrenNum = new int[N];
        TreeSet<Integer> RLnoRnoIndex = new TreeSet<>();
        
        for(int i = 0; i < N - 1; i++){
            if ( S.charAt(i) == 'R' && S.charAt(i+1) == 'L' ) {
                RLnoRnoIndex.add(i);
            }
        }
        
        //Rについて最初からループ
        for(int i = 0; i < N - 1; i++){
            if ( S.charAt(i) == 'R' && S.charAt(i+1) == 'R' ) {
                int RIndex = RLnoRnoIndex.higher(i);
                if ( (RIndex - i) % 2 == 0){
                    childrenNum[RIndex]++;
                } else {
                    childrenNum[RIndex+1]++;
                }
            }
            
            if ( S.charAt(i) == 'R' && S.charAt(i+1) == 'L' ) {
                childrenNum[i]++;
            }
        }
        
        //Lについて最後からループ
        for(int i = N - 1; i >= 1; i--){
            if ( S.charAt(i) == 'L' && S.charAt(i-1) == 'L' ) {
                int RIndex = RLnoRnoIndex.lower(i);
                if ( (i - RIndex) % 2 == 0 ){
                    childrenNum[RIndex]++;
                } else {
                    childrenNum[RIndex+1]++;
                }
            }
            
            if ( S.charAt(i) == 'L' && S.charAt(i-1) == 'R' ) {
                childrenNum[i]++;
            }
        }
        
        StringBuilder sb = new StringBuilder();
        
        for(int i = 0; i < N; i++){
            sb.append(String.valueOf(childrenNum[i]));
            if ( i != N - 1 ) sb.append(" ");
        }
        
        System.out.println(sb);
    }
}


Measured memory_bytes: 32252
#include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;
#define REP(i,n)for(int i = 0;i<(n);i++)
const int INF = 1e9;
 
int H,W;
string s[50];
string order;
int ct;
 
vector<char> COND{'~','N','E','S','W','C','T'};
vector<char> MOVE{'^','v','<','>'};
map<char,int> mp;
int dy[4] = {-1,0,1,0},dx[4] = {0,1,0,-1};
 
int stepped[1000][50][50][4];
bool goaled;
int y,x,dir;
 
bool regionCheck(int y,int x){
  return 0<=x&&x<W&&0<=y&&y<H&&s[y][x]!='#';
}
 
bool goalCheck(int y,int x){
  return s[y][x]=='g';
}

int search(int order_i){
  int start_i = order_i;
  while(order_i < order.size()){//end check
    int condition = 1;
 
    //stepped?
    if(stepped[order_i][y][x][dir]==2){goaled = false;
      return INF;
    }else stepped[order_i][y][x][dir]++;
 
    //is condition?
    for(auto o:COND){
      if(order[order_i]==o){condition=-1;break;}
    }
 
    //condition check
    if(condition ==-1){
      bool reverse = false;
      if(order[order_i]=='~'){reverse=true;order_i++;}
 
      if(order[order_i] == 'C'){
				if(s[y + dy[dir]][x + dx[dir]] == '#')condition = 1;
				else condition = 0;
      }else if(order[order_i] == 'T')condition = 1;
      else if(mp[order[order_i]]==dir)condition = 1;
      else condition = 0;
       
      if(reverse)	{
				if(condition)condition = 0;
				else  condition= 1;//reverse
			}
      order_i++;
    }
     
		//execute move order
    if(condition==1){
      while(true){
				//is move order?
				bool canMove = false;
				for(auto m:MOVE)if(order[order_i]==m){canMove=true;break;}
				if(!canMove)break;
 
				//move
				ct++;
				if(order[order_i] == '^'){
					if(regionCheck(y+dy[dir],x+dx[dir])){
						y += dy[dir];x+=dx[dir];
					}
					if(goalCheck(y,x)){goaled = true;return INF;}
				}else if(order[order_i] == 'v'){
					if(regionCheck(y-dy[dir],x-dx[dir])){
						y -= dy[dir];x-=dx[dir];
					}
					if(goalCheck(y,x)){goaled = true;return INF;}
				}else if(order[order_i] == '<'){
					dir = (dir-1 + 4)%4;
				}else{
					dir = (dir+1 + 4)%4;
				}
 
				order_i++;
      }
    }else{
			//proceed index
			int bracket = 0,brace = 0;
			do{
				if(order[order_i] == '['){bracket++;
				}else	if(order[order_i] == ']'){bracket--;
				}else if(order[order_i] == '}'){brace--;
				}else if(order[order_i] == '{'){brace++;
				}
				if(bracket < 0 || brace < 0)break;
			}while(++order_i);
		}
    if(order[order_i] == '['||order[order_i]=='{'){
      order_i += search(order_i + 1);
		}
    else if(order[order_i] == '}'&&condition==1){
      order_i = start_i;
    }
    else if(order[order_i] == ']' || order[order_i] == '}'){
      return order_i - start_i + 2;
    }
  }
}
int main(){
  cin>>H>>W;
  REP(i,H)cin>>s[i];
  cin>>order;
  mp['N'] = 0;
  mp['E'] = 1;
  mp['S'] = 2;
  mp['W'] = 3;
  REP(i,H){
    REP(j,W){
      if(s[i][j]== 's'){
				y = i;x = j;
				s[i][j] = '.';
				break;
      }
    }
  }
  search(0);
  if(goaled) cout << ct << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 29116
N, M = map(int, input().split())
SC = []
for _ in range(M):
    s, c = map(int, input().split())
    SC.append((s - 1, c))

for n in range(1000):
    s = str(n)
    if len(s) == N and all(int(s[i]) == c for i, c in SC):
        print(n)
        break
else:
    print(-1)

Measured memory_bytes: 38384
n, a, b = map(int, input().split())

mod = 10 ** 9 + 7
N = min(n, 2 * 10**5)
fac = [1, 1]
finv = [1, 1]
inv = [0, 1]

def comb(n, r):
  return fac[n] * ( finv[r] * finv[n-r] % mod ) % mod
 
for i in range(2, N + 1):
  fac.append( ( fac[-1] * i ) % mod )
  inv.append( mod - ( inv[mod % i] * (mod // i) % mod ) )
  finv.append( finv[-1] * inv[-1]  % mod )

def frac_rev(n, r):
  x = 1
  for i in range(n, n-r, -1):
    x = x * i % mod
  return x

if n <= 2 * 10**5:
  print(( pow(2, n, mod) - 1 - comb(n, a) -comb(n, b) ) % mod)
else:
  print(( pow(2, n, mod) - 1 - frac_rev(n, a) * finv[a] % mod - frac_rev(n, b) * finv[b] % mod) % mod)

Measured memory_bytes: 32848
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int n;
int main(){
	scanf("%d",&n);
	printf("%d",!n);
}

Measured memory_bytes: 1732
#include <iostream> 
#include <cmath>

using namespace std;





int main() {

	int A, B, K;
	cin >> A >> B >> K;


	for (int i = 100; i >= 1; i--) {
		if ((A % i == 0) && (B % i == 0)) {
			K--;
			if (K == 0) {
				cout << i << endl;
				return 0;
			}
		}


	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    { 
        static void Main(string[] args)
        {
            //[summary]A - AtCoder Crackers
            var line = ReadLine();
            int n = line[0];
            int k = line[1];

            if (n % k == 0)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(1);
            }
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine().TrimEnd();
            var array = line.Split(' ');
            var numbers = new List<int>();

            foreach (var s in array)
            {
                int num = int.Parse(s);
                numbers.Add(num);
            }

            return numbers;
        }
    }
}

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

int main(void)
{
	string a, b, c;

	int n = 0;

	cin >> a >> b >> c;

	if (a[a.length() - 1] == b[0]) {
		n++;
	}

	if (b[b.length() - 1] == c[0]) {
		n++;
	}

	if (n == 2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return (0);


}

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

int main(){
  int n,m,c;
  cin >> n >> m >> c;
  int b[m];
  for(int i=0;i<m;i++){
    cin >> b[i];
  }
  int a[n][m];
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin >> a[i][j];
    }
  }
  int count = 0;
  for(int i= 0;i<n;++i){
    int ans = 0;
    for(int j=0;j<m;++j){
      ans += b[j]*a[i][j];
      //cout << b[j] << endl;
     // cout << a[i][j] <<" ";
    }
    //cout << endl;
    ans +=c;
    //cout << "ans:" << ans << endl;
    if(ans > 0){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

const ll INF = 1e17;

ll t[100005];
ll a[100005];
ll ans;
int main()
{
    int n;
    cin >> n;

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

    if (n == 0 && a[0] == 1)
    {
        cout << 1 << endl;
        return 0;
    }

    if (a[0] != 0)
    {
        cout << -1 << endl;
        return 0;
    }
    for (int i = 1; i <= n; i++)
    {
        t[i] = t[i - 1] * 2;
        if (t[i] >= INF)
            t[i] = INF;
        t[i] -= a[i];
        if (t[i] < 0)
        {
            cout << -1 << endl;
            return 0;
        }
    }

    ll m = a[n];
    ans = m;
    for (int i = n; i > 0; i--)
    {

        m = min(m, t[i - 1]);
        m += a[i - 1];
        ans += m;
    }

    cout << ans << endl;
}

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

int main(){
    int N, K;  cin >> N >> K;
    vector<ll> a(N+1);
    for(int i=1; i<=N; i++)  cin >> a[i];
    
    vector<ll> S1(N+1,0), S2(N+1,0);
    for(int i=1; i<=N; i++){
        S1[i] = S1[i-1] + a[i];
        S2[i] = S2[i-1] + max(a[i], (ll)0);
    }

    ll ans = 0;
    for(int i=1; i<=N-K+1; i++){
        ll tmp = S1[i+K-1] - S1[i-1];
        if(tmp<0) tmp = 0;

        tmp += S2[i-1] + (S2[N] - S2[i+K-1]);
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}


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


void solve(std::string S){
    if(S[1] == 'R'){
        if(S[0] == 'R' && S[2] == 'R') cout << 3 << endl;
        else if (S[0] == 'R' || S[2] == 'R') cout << 2 << endl;
        else cout << 1 << endl;
    }else{
        if (S[0] == 'R' || S[2] == 'R') cout << 1 << endl;
        else cout << 0 << endl;
    }
    return;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  i64 N, K;
  cin >> N >> K;
  vi64 A(N);
  cin >> A;
  sort(all(A));
  i64 ok = 1e18 + 1, ng = -1e18 - 1;
  while (ok - ng > 1) {
    i64 m = (ok + ng) / 2;
    i64 cnt = 0;
    rep(i, N) {
      if (A[i] < 0) {
        int ok = N, ng = i;
        while (ok - ng > 1) {
          int j = (ok + ng) / 2;
          (A[i] * A[j] <= m ? ok : ng) = j;
        }
        cnt += N - ok;
      } else {
        int ok = i, ng = N;
        while (ng - ok > 1) {
          int j = (ok + ng) / 2;
          (A[i] * A[j] <= m ? ok : ng) = j;
        }
        cnt += ok - i;
      }
    }
    (cnt >= K ? ok : ng) = m;
  }
  cout << ok << endl;
}


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

#define ll long long int
#define ull unsigned long long int
#define db double
#define ld long double
#define MOD 1000000007
#define inf (1LL << 62)
#define pi acos(-1.0)
#define si(a) scanf("%lld",&a)
#define sd(n) scanf("%lf", &n)
#define for1(i, stop) for(ll i = 1; i <= stop; i++)
#define for0(i, stop) for(ll i = 0; i < stop; i++)
#define rep1(i, start) for(ll i = start; i >= 1; i--)
#define rep0(i, start) for(ll i = (start-1); i >= 0; i--)
#define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
#define pb(v,a) v.push_back(a)
#define pll pair <ll, ll>
#define mp make_pair
#define pbp(v,a,i) v.push_back(make_pair(a,i))
#define srt(v) sort(v.begin(),v.end())
#define rv(v) reverse(v.begin(),v.end())
#define ms(n, i) memset(n, i, sizeof(n))
#define debug printf("Debug\n");
#define en '\n'



#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
/*typedef tuple<ll,ll,ll>tpl;

ll bigmod(ll n,ll pow)
{
    if(pow==0)
        return 1;
    if(pow==1)
        return n%MOD;

    ll ans=bigmod(n,pow/2);
    ans=(ans*ans)%MOD;

    if(pow%2==1)
    {
        ans=(ans*n)%MOD;
    }
    return ans%MOD;
}

ll fact[1000005];

ll nCr(ll n,ll r)
{

    ll ans=fact[n];
    ans=(ans*bigmod(fact[r],MOD-2))%MOD;
    ans=(ans*bigmod(fact[n-r],MOD-2))%MOD;
    return ans;
} */

int main()
{
    _fastio
   ll n,a,cn=0;
   vector<ll>v;
   cin>>n;
   for1(i,n)
   {
    cin>>a;
    pb(v,a);
   }
   srt(v);
   for(ll i=0;i<n;i++)
   {
    for(ll j=i+1;j<n;j++)
    {
        for(ll k=j+1;k<n;k++)
        {
          
            if(v[i]+v[j]>v[k] && v[i]!=v[j] && v[j]!=v[k] && v[k]!=v[i])
            {
              //cout<<v[i]<<" "<<v[j]<<" "<<v[k]<<en;
                cn+=1;
            }
        }
    }
   }
   cout<<cn<<en;
}


Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

vector<int> tree[200000];
ll cnt[200000], ans[200000];

void dfs(int v, int before, ll c) {
    c += cnt[v];
    ans[v] = c;
    for (int t : tree[v]) {
        if (t != before) dfs(t, v, c);
    }
}

int main() {
    int N, Q;
    cin >> N >> Q;
    REP(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    REP(i, Q) {
        int p, x;
        cin >> p >> x;
        cnt[p - 1] += x;
    }
    dfs(0, -1, 0);
    REP(i, N) cout << ans[i] << " "; cout << endl;
    return 0;
}

Measured memory_bytes: 25600
#include <bits/stdc++.h>  // ver1.9.5
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a[a.size()-1]<<endl
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

bool prime(int n)  //  素数判定
{if(n<2)return false;else if(n==2)return true;else if(n%2==0)return false;
double s=sqrt(n);for(int i=3;i<=s;i+=2){if(n%i==0){return false;}}return true;}


signed main() {
  cout << fixed << setprecision(8);
  Vi a(100005);
  a[0]=0;
  rep(i,1,100003){
    a[i] = a[i-1];
    if(prime(i) && prime((i+1)/2)) a[i]++;
  }
  
  int n;
  cin >> n;
  int qw,er;
  rep(i,0,n){
    cin >> qw >> er;
    qw--;
    cout << a[er]-a[qw] << endl;
  }
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
#define f(i,a,b) for (ll i=(a); i<(b);i++)
#define frr(i,a,b) for(ll i=(a-1);i>=(b);i--)
#define pb push_back
#define ppb pop_back()
#define pf push_front
#define ppf pop_front()
#define F first
#define S second
#define pii pair<int,int> 
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.begin(),a.end(),greater<int>())
#define mem(a,n) memset(a,n,sizeof a)
#define ln(a) a.length()
#define sz(a) (ll)a.size()
#define endl "\n"
#define pi 3.14159265358979

const ll M=1e9+7;
const int P=31;
const int MaxM=200005;
/*__________________________________________________________________________________________________________________*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);  
    
   
      
  int n,m;cin>>n>>m;
  int tar;cin>>tar;
  int row[n+1]={},col[m+1]={};
  map<pair<int,int>,int>mp;
  int mxcol,mxrow;
  int mxr=0,mxc=0;
  for(int i=0;i<tar;i++)
  {
    int x,y;cin>>x>>y;
    mp[{x,y}]++;
    row[x]++;
    if(mxr<row[x])mxr=row[x],mxrow=x;
    col[y]++;
    if(mxc<col[y])mxc=col[y],mxcol=y;
  }
  int ans=0;
  for(int i=1;i<=m;i++)
  {
    int val=mxr+col[i];
    if(mp.find({mxrow,i})!=mp.end())val--;
    ans=max(val,ans);
  }
  for(int i=1;i<=n;i++)
  {
    int val=mxc+row[i];
    if(mp.find({i,mxcol})!=mp.end())val--;
    ans=max(val,ans);
  }
  cout<<ans<<endl;
} 


Measured memory_bytes: 24640
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
using namespace std;

int main(){
    int A,B;
    cin>>A>>B;
    if(A>=13)cout<<B<<endl;
    else if(A>=6 && A<=12)cout<<B/2<<endl;
    else cout<<0<<endl;

    return 0;
}

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

int main() {
	int H, W;
	cin >> H >> W;
	map<int, int> mp;
	multiset<int> multi_set;
	for (int i=1;i<=W;i++) {
		mp[i] = i;
		multi_set.insert(0);
	}

	for (int i=0;i<H;i++) {
		int A, B;
		cin >> A >> B;
		map<int, int>::iterator iter = mp.lower_bound(A);
		int right_most = -1;
		vector<int> erase_vec;
		// while (iter != mp.end()) {
		while (true) {
			if (iter == mp.end()) {
				break;
			}
			if (iter->first > B+1) {
				break;
			}
			right_most = max(right_most, iter->second);
			multi_set.erase(multi_set.find(iter->first-iter->second));
			erase_vec.push_back(iter->first);
			// cout << i << " first, second" << endl;
			// cout << iter->first << " " << iter->second << endl;
			// if (iter == mp.end()) {
				// break;
			// }
			// cout << mp.end()->first << " " << mp.end()->second << endl;
			iter = next(iter);
		}
		for (auto val : erase_vec) {
			mp.erase(val);
		}
		if (right_most != -1 && B != W) {
			mp[B+1] = right_most;
			multi_set.insert(B+1-right_most);
		}

		// cout << "map: " << i << endl;
		// for (auto p : mp) {
		// 	cout << p.first << " " << p.second << endl;
		// }
		// cout << "###" << endl;

		// cout << "multiset " << i << endl;
		// for (auto val : multi_set) {
		// 	cout << val << endl;
		// }
		// cout << "###" << endl;

		if (multi_set.size() == 0) {
			cout << -1 << endl;
		} else {
			cout << (i+1)+*multi_set.begin() << endl;
		}
	}
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<ll> b(n + 1);
    int mod = 1000000007;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        b[i + 1] = b[i] + a[i];
    }
    
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ll sum = (b[n] - b[i + 1]) % mod;
        ans += a[i] * sum;
        ans %= mod;
    }
    
    cout << ans << endl;
}



Measured memory_bytes: 5584
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};



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

  int a=pow(2,M);
  int sum=1900*M+100*(N-M);
  int ans=a*sum;

  cout<<ans<<"\n";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
bool pd(int x){
	double k=sqrt(x);
	int kk=k;
	if((double)kk==k)return 1;
	return 0;
}
int read(){
	char a[5],b[5];
	cin>>a>>b;
	int x=0;
	for(int i=0;i<strlen(a);i++)x=x*10+a[i]-'0';
	for(int i=0;i<strlen(b);i++)x=x*10+b[i]-'0';
	//cout<<x<<endl;
	return x;
}
int main(){
	if(pd(read()))cout<<"Yes";
	else cout<<"No";
} 

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

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

    int cnt = 0;
    for (int i = 1; i < s.size(); i++) {
        if (s[i] != s[i - 1]) {
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 512