akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <utility>

using namespace std;

#define int long long

class UnionFind
{
private:
    vector<int> v;
    vector<int> size;
    int npath;

public:
    UnionFind(int N) : size(N, 1)
    {
        npath = 0;
        for (int i = 0; i < N; i++)
        {
            v.push_back(i);
        }
    }

    int root(int x)
    {
        if (x == v[x])
        {
            return x;
        }
        else
        {
            return v[x] = root(v[x]);
        }
    }

    void unite(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
            return;
        npath += size[ry] * size[rx];
        size[ry] += size[rx];
        v[rx] = ry;
    }

    int get_npath()
    {
        return npath;
    }
};

signed main()
{
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> v(M);
    UnionFind u(N);

    for (int i = 0; i < M; i++)
    {
        cin >> v[i].first >> v[i].second;
        v[i].first--;
        v[i].second--;
        u.unite(v[i].first, v[i].second);
    }

    int n = u.get_npath();

    UnionFind u_(N);
    vector<int> ans(M);
    for (int i = M - 1; i >= 0; i--)
    {
        ans[i] = n - u_.get_npath();
        u_.unite(v[i].first, v[i].second);
    }

    for (int i = 0; i < M; i++)
    {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 6900
#!/usr/bin/env python3
n = int(input())
x = list(map(int,input().split()))
print(sum((i-round(sum(x)/n))**2 for i in x))
#x**2 - 2*x + p**2 をp で微分するとp 位置を動かしたときの増加量がわかる
# ２次方程式になっていて minは重心のとき round すれば良い

Measured memory_bytes: 2940
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#pragma endregion

inline ll digit_sum(ll a, ll b = 10)
{
  ll sum = 0;
  do
  {
    sum += a % b;
  } while (a /= b);
  return sum;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  ll n;
  cin >> n;
  Yes(n % digit_sum(n) == 0);

  return 0;
}


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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    vector<int> a(n);
    REP(i,n) cin>>a[i];
    sort(all(a));
    int score = accumulate(all(a),0);
    int amari = score%10;
    bool flag = false;
    if(amari!=0) print(score);
    else if(amari==0){
        REP(i,a.size()){
            if(((score-a[i])%10)!=0){
                score-=a[i];
                flag = true;
                break;
            }
        }
        if(flag) print(score);
        else print(0);
    } 
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    	int num = sc.nextInt();
    	if(num < 1200) {
          System.out.println("ABC");
        } else if(num < 2800) {
          System.out.println("ARC");
        } else {
          System.out.println("AGC");
        }
  }
}

Measured memory_bytes: 23892
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
void Rotation() {
	int row = 2;
	int col = 3;
	string s[2];
	cin >> s[0];
	cin >> s[1];
	for (size_t i = 0; i < row; i++)
	{
		for (size_t j = 0; j < col; j++)
		{
			if (s[i][j] != s[row - i - 1][col - j - 1]) {
				cout << "NO" << endl;
				return;
			}
		}
	}
	cout << "YES" << endl;
}
int main() {

	Rotation();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <fstream>
#include <iomanip>
//#include <unordered_map>
using namespace std;
#define dbg(x) cerr << #x " = " << x << endl;
typedef pair<int, int> P;
typedef long long ll;
#define FIN freopen("in.txt", "r", stdin);

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    n %= 10;
    switch (n)
    {
    case 2: case 4: case 5:case 7 :case 9: cout << "hon" << endl;
        break;
    case 0 : case 1 : case 6 :case 8 : cout << "pon" << endl; break;
    case 3 : cout << "bon" << endl; break;

    }
}

Measured memory_bytes: 3128
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	arr := make([]float64, n)
	for i := range arr {
		fmt.Scan(&arr[i])
	}

	var sum float64
	for i := 0; i < n; i++ {
		sum += 1/arr[i]
	}

	fmt.Println(1/sum)
}


Measured memory_bytes: 512
#include "bits/stdc++.h"

using namespace std;

const int INF = 1000000000;
int N, Ma, Mb;
vector<int> a, b, c;

int dp(int curr, int wa, int wb, vector<vector<vector<int>>>& memo) {
    if (wa > 0 && wb > 0 && wb * Ma == wa * Mb) {
        return 0;
    }
    if (curr == N) {
        return INF;
    }

    if (memo[curr][wa][wb] >= 0) {
        return memo[curr][wa][wb];
    }

    int skip = dp(curr + 1, wa, wb, memo);
    int take = dp(curr + 1, wa + a[curr], wb + b[curr], memo) + c[curr];
    int ret = min(skip, take);
    memo[curr][wa][wb] = ret;
    return ret;
}

void Main() {
    cin >> N >> Ma >> Mb;
    a = vector<int>(N, 0);
    b = vector<int>(N, 0);
    c = vector<int>(N, 0);
    for (int i = 0; i < N; ++i) {
        cin >> a[i] >> b[i] >> c[i];
    }

    vector<vector<vector<int>>> memo(N, vector<vector<int>>(410, vector<int>(410, -1)));
    int ans = dp(0, 0, 0, memo);
    if (ans == INF) {
        cout << -1 << endl;
    }
    else {
        cout << ans << endl;
    }
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 30712
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val n, m = in.nextInt
  val xs = Array.fill(m)(in.nextInt).sorted
  val spaces = xs.sliding(2).map(s => s.last - s.head).toList
  println(spaces.sorted.reverse.drop(n - 1).sum)
}

Measured memory_bytes: 72468
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long 
#define endl "\n"
#define all(x) (x).begin(),(x).end()
const int MOD = 1e9+7;
const int mxN = 2e5+3;

void solve(){
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; ++i)cin >> a[i];
	sort(a, a+n, greater<int>());
	int ans = 0;
	for(int i = 2; i <= n; ++i){
		int tt = (i + 1)/2;
		tt--;
		ans += a[tt];
	}
	cout << ans << endl;
}

int32_t main(){
	IO;
	
	int nT = 1;
	//cin >> nT;
	for(int i = 1; i <= nT; ++i)
		solve();
	return 0;
}


Measured memory_bytes: 5200
import sys
sys.setrecursionlimit(100000)

def check(x, y):
	array[x][y] = "0"
	if array[x + 1][y] == "1" : check(x + 1, y)
	if array[x - 1][y] == "1" : check(x - 1, y)
	if array[x][y + 1] == "1" : check(x, y + 1)
	if array[x][y - 1] == "1" : check(x, y - 1)
	if array[x + 1][y + 1] == "1" : check(x + 1, y + 1)
	if array[x + 1][y - 1] == "1" : check(x + 1, y - 1)
	if array[x - 1][y + 1] == "1" : check(x - 1, y + 1)
	if array[x - 1][y - 1] == "1" : check(x - 1, y - 1)

while True:
	h,w = map(int, raw_input().split())
	if h == 0 and w == 0 : break

	array = []
	array.append(list("0" * (2 + h)))
	for i in range(0, w) : array.append(list("0" + raw_input().replace(" ", "") + "0"))
	array.append(list("0" * (2 + h)))
	
	count = 0
	for i in range(1, w + 1):
		for j in range(1, h + 1):
			if array[i][j] == "1":
				check(i, j)
				count += 1
				
	print count

Measured memory_bytes: 7868
#include<iostream>
int main(){for(int a,b,c,d,e,f;std::cin>>a>>b>>c;printf("%.2d:%.2d:%.2d\n",d,e,f)){if(a==-1)break;f=-c,e=-b,d=2-a;if(f<0)f+=60,e--;if(e<0)e+=60,d--;printf("%.2d:%.2d:%.2d\n",d,e,f);f*=3,e*=3,d*=3;if(f>59)e+=f/60,f%=60;if(e>59)d+=e/60,e%=60;}}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,b,t,ct,p;
    vector<int>v1;
    vector<int>v2;
    cin>>a;
    for(int i=0;i<a;i++) {cin>>p;v1.push_back(p);}
    for(int j=0;j<a;j++) {cin>>p;v2.push_back(p);}
    ct=0;
    for(int i=0;i<a;i++)
    {
        b=v1[i]; t=v2[i];
        if(b>t) ct+=b-t;
    }
    cout<<ct<<endl;
    return 0;
}





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

int main() {
	int n, x;
	long ans = 0;
	while (1) {
		(void)scanf("%d %d", &n, &x);
		if (!n && !x) break;
		for (int i = 1; i <= n-2; i++) {
			for (int j = i + 1; j <= n-1; j++) {
				for (int k = j + 1; k <= n; k++) {
					if (i + j + k == x) {
						ans++;
						break;
					}
				}
			}
		}
		printf("%ld\n", ans);
		ans = 0;
	}
	return 0;
}


Measured memory_bytes: 2664
from sys import stdin

def fun():
    n = int(input())
    total = 0

    for i in range(n):
        x, u = input().split()
        x = float(x)
        if u == 'JPY':
            total = total + x
        else:
            total = total + x*380000.0
    print(total)


if __name__ == '__main__':
    fun()


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

using namespace std;

void solve() {
	int n;
	cin>>n;
	int a[n+1];
	int count=0;
	for(int i=1;i<=n;i++) {
		cin>>a[i];
		if(i%2&&a[i]%2) count++; 
	}
	cout<<count<<endl;
}

int main() {
//	freopen("input.txt","r",stdin);
	int t=1;
	//cin>>t;
	while(t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<string.h>

int main(){
	int k;
	char word[101];
	
	scanf("%d", &k);
	scanf("%s", &word);
	int len = strlen(word);
	
	if (len <= k){
		printf("%s", &word);
	}
	else {
		word[k] = '\0';
		printf("%s...", word);
	}
	return 0;
}

Measured memory_bytes: 1736
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> N, K;
  invec<ll> A(N);
  vector<ll> loop(N+1, -1), route({1});
  
  loop[1] = 0;
  
  ll cnt = 0, current = 1;
  for(;K > 0;) {
    current = A[current - 1];K--;
   if (loop[current] != -1 && K >= cnt + 1 - loop[current]) {
      K = K % (cnt + 1 - loop[current]);
    }
    else {
      loop[current] = ++cnt;
      route.push_back(current);
      
    }
  }
  

  return current;
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 8428
macro_rules! debug {
    ( $x:ident [ $i:expr ] ) => {
        if cfg!(debug_assertions) {
            println!("{}[{}] = {}", stringify!($x), $i, $x[$i]);
        }
    };
    ( $x:ident [ $i:expr ][ $j:expr ] ) => {
        if cfg!(debug_assertions) {
            println!("{}[{}][{}] = {}", stringify!($x), $i, $j, $x[$i][$j]);
        }
    };
    ( $x:expr ) => {
        if cfg!(debug_assertions) {
            println!("{}:{} {} = {:?}", line!(), column!(), stringify!($x), $x);
        }
    };
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin = my::io::InputReader::new(stdin.lock());

    let a: i32 = stdin.read();
    let b: i32 = stdin.read();
    let c: i32 = stdin.read();

    println!("{}", a * b / 2);
}

mod my {
    pub mod io {
        use std::io::{BufRead, ErrorKind, Result};
        use std::str::{FromStr, from_utf8};
        use std::fmt::Debug;

        pub fn read_word<R: BufRead>(r: &mut R, buf: &mut Vec<u8>)
                                              -> Result<usize> {
            let mut read = 0;
            loop {
                let (done, used) = {
                    let available = match r.fill_buf() {
                        Ok(n) => n,
                        Err(ref e) if e.kind() == ErrorKind::Interrupted => continue,
                        Err(e) => return Err(e)
                    };
                    match available.iter().position(|&x| x == b'\n' || x == b' ') {
                        Some(i) => {
                            buf.extend_from_slice(&available[..i]);
                            (true, i + 1)
                        }
                        None => {
                            buf.extend_from_slice(available);
                            (false, available.len())
                        }
                    }
                };
                r.consume(used);
                read += used;
                if done || used == 0 {
                    return Ok(read);
                }
            }
        }

        pub struct InputReader<R: BufRead> {
            reader: R,
            buf: Vec<u8>,
        }

        impl<R: BufRead> InputReader<R> {
            pub fn new(reader: R) -> InputReader<R> {
                InputReader {
                    reader: reader,
                    buf: Vec::<u8>::new(),
                }
            }

            pub fn read_word(&mut self) {
                read_word(&mut self.reader, &mut self.buf);
            }
            
            pub fn read<T>(&mut self) -> T
                where T: FromStr,
                      T::Err: Debug
            {
                self.buf.clear();
                self.read_word();
                from_utf8(&self.buf).unwrap().trim().parse().unwrap()
            }
        }
    }
}



Measured memory_bytes: 4352
//#define sort(nums) sort(nums.begin(),nums.end())
#include <bits/stdc++.h>
#define mod 1000000007
#define deb(x) cout<<#x<<" "<<x<<endl
using namespace std;
using ll = long long int;

void jets(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}


int main(){
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    jets();
    int m,n;
    cin>>m>>n;
    char grid[m][n];
    int dp[m][n];
    for(int i=0;i<m;i++){
    	for(int j=0;j<n;j++){
    		cin>>grid[i][j];
    		if(i==0 && j==0)
    			dp[i][j]=1;
    		else if(i==0){
    			if(grid[i][j]=='#')
    				dp[i][j]=0;
    			else
    				dp[i][j]=dp[i][j-1];
    		}
    		else if(j==0){
    			if(grid[i][j]=='#')
    				dp[i][j]=0;
    			else
    				dp[i][j]=dp[i-1][j];    		
    		}
    	}
    }
    for(int i=1;i<m;i++){
    	for(int j=1;j<n;j++){
    		if(grid[i][j]=='#')
    			dp[i][j]=0;
    		else
    			dp[i][j]=(dp[i-1][j] + dp[i][j-1])%mod;
    	}
    }
    cout<<dp[m-1][n-1]<<endl;


    return 0;
}

Measured memory_bytes: 8424
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define DEBUG(x)           cout << '>' << #x << ':' << x << endl;
#define forn(i,n)          for(int i=0;i<(int)n;++i)
#define for1(i,n)          for(int i=1;i<=(int)n;++i)
#define forr(i,n)          for(int i=(int)n-1;i>=0;--i)
#define forre(i,a,b)       for(int i=(int)b;i>=(int)a;--i)
#define fore(i,a,b)        for(int i=(int)a;i<=(int)b;++i)
#define input(arr,n)       for(int i=0;i<n;i++)cin>>arr[i]
#define output(arr,n)      for(int i=0;i<n;i++)cout<<arr[i]<<" "
#define for_each(arr)      for(auto& it:arr)cout<<it<<" "
#define ff                 first
#define ss                 second
#define PI                 acos(-1.0)
#define all(a)             a.begin(),a.end()
#define rall(a)            a.rbegin(),a.rend()
#define Unique(a)          sort(all(a)),a.erase(unique(all(a)),a.end())
#define pb(x)              push_back(x)
#define eb(x)              emplace_back(x) 
#define ppb(x)             pop_back(x)
#define pf(x)              push_front(x)
#define ppf(x)             pop_front(x)
#define in(x,y)            insert({x,y})
#define Sort(a)            sort(a.begin(),a.end())
#define mem(arr,a)         memset(arr,a,sizeof arr)
#define ins(a)             insert(a)
#define max2(a,b)          max(a,b)
#define max3(a,b,c)        max(a,max(b,c))
#define max4(a,b,c,d)      max(a,max3(b,c,d))
#define min2(a,b)          min(a,b)
#define min3(a,b,c)        min(a,min(b,c))
#define min4(a,b,c,d)      min(a,min3(b,c,d))
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<char> vc;
typedef vector<double> vd;
/*inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void Set(int & n, int b) { n |= two(b); }
inline void Reset(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }*/
/*int fx[]= {0,0,1,-1,-1,1,-1,1};
int fy[]= {1,-1,0,0,-1,1,1,-1};
int fx1[]={0,1,1,1,0,-1,-1,-1};
int fy1[]={1,1,0,-1,-1,-1,0,1};*/

ll a,b,c,n,ans,cn1,cn2,cn3,t;
string s,s1,s2;


int main()
{
    FIO;
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
  //  freopen("output.txt","w",stdout);
//    #endif
    char ch;
    cin>>ch;
    cout<<char(ch-'a'+1+'a')<<endl;

    

    
   	
    #ifdef ONLINE_JUDGE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    #endif
   return 0;
}
 

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

int main() {
  string s;
  cin >> s;
  bool b=true;
  if(s.at(2)!=s.at(3)) b=false;
  if(s.at(4)!=s.at(5)) b=false;
  if(b==false) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////
int N, Q;
vector<vector<int>>G;
vector<int>res;
int r[200100];
bool visited[200100];
ll ans[200100];
ll score[200100];
void dfs(int a) {
	for (auto i : G[a]) {
		if (!visited[i]) {
			visited[i] = true;
			ans[i] = ans[a] + score[i];
			dfs(i);
		}
	}
	return;
}

int main() {
	cin >> N >> Q;
	G.resize(N);
	for (int i = 0; i <= N; ++i) {
		visited[i] = false;
		score[i] = 0;
	}
	visited[0] = true;
	r[0] = 0;
	for (int i = 0; i < N - 1; ++i) {
		int a, b; cin >> a >> b;
		a--, b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	for (int i = 0; i < Q; ++i) {
		int p, x;
		cin >> p >> x;
		--p;
		score[p] += x;
	}
	ans[0] = score[0];
	dfs(0);
	for (int i = 0; i < N; ++i) {
		cout << ans[i] << " ";
	}
	return 0;
}

Measured memory_bytes: 23680
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int n = sc.nextInt();
			Set<Integer> a = new TreeSet<>();
			for(int i = 0; i < n; i++) {
				a.add(sc.nextInt());
			}
			int m = sc.nextInt();
			Set<Integer> b = new TreeSet<>();
			for(int i = 0; i < m; i++) {
				b.add(sc.nextInt());
			}

			Set<Integer> sum = new TreeSet<>(a);
			sum.addAll(b);
			Set<Integer> prod = new TreeSet<>(a);
			prod.removeIf((num) -> !b.contains(num));
			Set<Integer> prime = new TreeSet<>(sum);
			prime.removeIf(num -> prod.contains(num));

			prime.forEach(num -> System.out.println(num));
		}
	}
}


Measured memory_bytes: 215112
#include <cstdio>
#include <algorithm>
 
using namespace std;
 
#define iter(i, n) for (int i = 1; i <= n; ++i)
#define iter0(i, n) for (int i = 0; i < n; ++i)
char s[200][200];
int n, m, K, cnt[30];
int main() {
	scanf("%d%d%d", &n, &m, &K); bool can = false;
	iter(i, n) scanf("%s", s[i] + 1);
	iter(i, n) iter(j, m) ++cnt[s[i][j] - 'a'];
 
	int c1 = 0, c2 = 0;
	iter0(c, 26) {
		if (cnt[c] % 2 == 1) ++c1;
		if (cnt[c] % 4 > 1) ++c2;
	}
 
	bool valid;
	if (n % 2 == 0 && m % 2 == 0) {
		valid = (c1 == 0 && c2 == 0);
	} else if (n % 2 == 1 && m % 2 == 1) {
		//2k+1 * 2k+1
		//2k x 2
 
		valid = (c1 == 1 && c2 % 2 == (n/2 + m/2) % 2 && c2 <= (n/2 + m/2));
	} else {
		//2a+1 * 2b
		//b
 
		if (n % 2 == 1) swap(n, m);
		int b = n / 2;
		valid = (c1 == 0 && b % 2 == c2 % 2 && c2 <= b);
	}
 
	printf("%s\n", valid ? "Yes" : "No");
 
	return 0;
}

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

using namespace std;

// 多次元 mul_array<int, 1, 2, 3> a
template <typename T, std::size_t... Ns>
struct index_reverse_for_array;
template <typename T, std::size_t N, std::size_t... Ns>
struct index_reverse_for_array<T, N, Ns...> { using type = std::array< typename index_reverse_for_array<T, Ns...>::type, N>; };
template <typename T, std::size_t N>
struct index_reverse_for_array<T, N> { using type = std::array<T, N>; };
template <class T, std::size_t... Ns> using mul_array = typename index_reverse_for_array<T, Ns...>::type;

using u32 = uint32_t;
using s32 = uint32_t;
using u64 = uint64_t;
using s64 = uint64_t;

int main() {
    //cout << fixed << setprecision(10);

    int n;
    cin >> n;
    mul_array<int, 3> P;
    cin >> P[0] >> P[1];
    int counter = 0;
    for (int i = 2; i < n; i++) {
        cin >> P[i % 3];
        int c = i - 1;
        if ((P[(c - 1) % 3] < P[(c) % 3] && P[(c) % 3] < P[(c + 1) % 3]) || (P[(c + 1) % 3] < P[(c) % 3] && P[(c) % 3] < P[(c - 1) % 3])) {
            counter++;

        }
    }
    cout << counter << endl;

    return 0;
}





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

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

	int counter = 0;
	if(s[0] == '1'){counter++;}
	if(s[1] == '1'){counter++;}
	if(s[2] == '1'){counter++;}

	cout << counter << endl;
 	return 0;
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X;
    cin >> X;
    if (X == 3 || X == 5 || X == 7) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 896
from collections import defaultdict
from bisect import bisect_right


def main():
    s = input()
    t = input()
    N = len(s)
    idx = defaultdict(list)
    for i in range(N):
        c = s[i]
        idx[c].append(i)
    pos = -1
    ans = 0
    for c in t:
        if c not in idx:
            print(-1)
            return
        n = bisect_right(idx[c], pos)
        if n == len(idx[c]):
            ans += N + idx[c][0] - pos
            pos = idx[c][0]
        else:
            ans += idx[c][n] - pos
            pos = idx[c][n]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 45808
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <math.h>
#include <string.h>
#include <map>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#define INF 1000000
#define MAX 500000
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long int ll;
typedef vector <ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
vector <vi> adj(MAX);
vi col;
 ll n;
 vi dfs_num,dfs_parent,dfs_low,vertex;
int dfsnumcnt=0,dfsRoot,rootChildren=0;

int main()
{
 //  freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
ll m,n,ans;
cin>>n>>m;
ans=min(n,m/2);
n-=ans;
m-=2*ans;
if(m!=0)
ans+=m/4;
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 11904
def gen(n):
    x = n
    d = 2
    cnt = 0
    while x % d == 0:
        x //= d
        cnt += 1
    yield cnt

    d = 3
    while d * d <= n:
        cnt = 0
        while x % d == 0:
            x //= d
            cnt += 1
        yield cnt
        d += 2

    if x > 1:
        yield 1


def main():
    MOD = 10 ** 9 + 7

    N, M = map(int, input().split())

    ans = 1
    for cnt in gen(M):
        for d in range(cnt):
            ans = (ans * (N - 1 + cnt - d) % MOD) * pow(d + 1, MOD - 2, MOD) % MOD
            
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
typedef long long ll;

int main(){
    int n[3];
    cin>>n[0]>>n[1]>>n[2];
    sort(n,n+3);
    cout<<n[2]*10+n[1]+n[0]<<endl;
}


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

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

    if(a>0) cout<<"Positive"<<endl;
    else if(a<=0&&b>=0) cout<<"Zero"<<endl;
    else{
        if((b-a)%2) cout<<"Positive"<<endl;
        else cout<<"Negative"<<endl;
    }

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <unordered_map>

#define rep(i, a, b) for (ll i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef unordered_map<string, ll> u_map;

// input
void input() {}
template <class Head, class... Tail>
void input(Head &&a, Tail &&... b)
{
    cin >> a;
    input(forward<Tail>(b)...);
}

template <class V>
void input(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &i) { input(i); });
}

// output
template <class V>
void output(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &x) { cout << x << " "; });
    cout << endl;
}

// math functions
ll mpow(ll a, ll n, ll p)
{
    ll x = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            x = a * x % p;
        }
        a = a * a % p;
        n >>= 1;
    }

    return x;
}

ll mfact(ll n, ll p)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
    {
        res = res * i % p;
    }
    return res;
}

ll mcomb(ll n, ll r, ll p)
{
    if (n == 0 && r == 0)
    {
        return 1;
    }
    if (n < r || n < 0 || r < 0)
    {
        return 0;
    }

    ll a = mfact(n, p);
    ll b = mfact(n - r, p);
    ll c = mfact(r, p);
    return (((a * mpow(b, p - 2, p)) % p) * mpow(c, p - 2, p)) % p;
}

ll gcd(ll a, ll b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

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

int main()
{
    int X, Y, Z;
    input(X, Y, Z);

    printf("%d %d %d\n", Z, X, Y);
    return 0;
}

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

int main() {
	int n;
	cin>>n;
	long long a=2,b=1,c;
	for(int i=0;i<n-1;i++){
		c=a+b;
		a=b;
		b=c;
		}
 if(n==1)cout<<"1"<<endl;
 else cout<<c<<endl;
  return 0;
  }

Measured memory_bytes: 256
#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)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int ok = 1000000005, ng = 0;

    auto check = [&](int x) {
        int cnt = 0;
        rep(i, n) {
            int now = (a[i] + x - 1) / x - 1;
            cnt += now;
        }
        return cnt <= k;
    };
    
    while (ok - ng > 1) {
        int mid = (ok + ng) >> 1;
        if (check(mid)) ok = mid;
        else ng = mid;
    }
    
    cout << ok << endl;
}


Measured memory_bytes: 3948
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("trapv")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 69;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll B = 31 + (rng()%100), pw[100];
ll hsh(string &s) {
	ll ans = 0;
	for(int i = 0; i < s.size();i++)
		ans = (ans + pw[i]*s[i])%mod;
	return ans;
}
map<pi, ll> cnt[20];
int main() { //DINIC ORZ
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	pw[0] = 1;
	for(int i = 1; i < 100; i++) pw[i] = (pw[i-1]*B)%mod;
	int n;
	string s;
	cin >> n >> s;
	for(int msk = 0; msk < 1<<n; msk++) {
		string r, b;
		for(int i = 0; i < n; i++) {
			if((msk>>i)&1)
				r.pb(s[i]);
			else
				b.pb(s[i]);
		}
		cnt[r.size()][{hsh(r),hsh(b)}]++;
	}
	ll ans = 0;
	for(int msk = 0; msk < 1<<n; msk++) {
		string r, b;
		for(int i = 0; i < n; i++) {
			if((msk>>i)&1)
				r.pb(s[n+i]);
			else
				b.pb(s[n+i]);
		}
		reverse(all(b));
		reverse(all(r));
		ans += cnt[b.size()][{hsh(b),hsh(r)}];
	}
	cout << ans;
}


Measured memory_bytes: 33024
import qualified Data.ByteString.Char8 as BS

readString = map BS.unpack . BS.words

getString = readString <$> BS.getLine

searchC :: String -> Int -> Bool
searchC [] n
  | n == 1 = True
  | otherwise = False
searchC (y : ys) n
  | y == 'C' = searchC ys (n + 1)
  | y >= 'a' && y <= 'z' = searchC ys n
  | otherwise = False

main = do
  [s] <- getString
  if head s == 'A' && head (tail s) >= 'a' && head (tail s) <= 'z' && searchC (init (tail s)) 0 && last s >= 'a' && last s <= 'z'
    then putStrLn "AC"
    else putStrLn "WA"


Measured memory_bytes: 380
def find_cost(n, a, b):
    if n % a == 0:
        return b * (n // a)
    else:
        return b * ((n // a) + 1)

n, a, b, c, d = map(lambda x: int(x), input().split(" "))
ans = 1e9
ans = min(ans, find_cost(n, a, b))
ans = min(ans, find_cost(n, c, d))
print(ans)


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

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

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

    sort(a, a + n);
    
    int ans = 0;
    for(int i = 0; i < n - 1; i++){
        if(a[i] > x){
            break;
        }else{
            ans++;
            x -= a[i];
        }
    }

    if(a[n - 1] == x){
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P  = pair<int, int>;
int main() {
    long double a, b, h, m;
    cin >> a >> b >> h >> m;
    long double th = abs((h + m / 60.0) / 12.0 * 360 - m / 60.0 * 360), thr;
    //th = h/12+m/60/12-m/60
    thr = th / 180.0 * M_PI;
    cout << setprecision(20) << sqrt(a * a + b * b - 2.0 * a * b * cosl(thr));
    return 0;
}

Measured memory_bytes: 4156
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, x;
    cin >> n >> x;
    if(x == 1 || x == 2 * n - 1) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    vector<int> ans(2 * n - 1, 0);
    set<int> se;
    for(int i = 1; i <= 2 * n - 1; i++) {
        se.insert(i);
    }
    for(int i = -1; i <= 1; i++) {
        ans[n - 1 + i] = x + i;
        se.erase(x + i);
    }
    for(int i = 0; i < 2 * n - 1; i++) {
        if(ans[i] == 0) {
            cout << *se.begin() << endl;
            se.erase(se.begin());
        } else {
            cout << ans[i] << endl;
        }
    }
}

Measured memory_bytes: 11648
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  var splitInput = input.split(" ");

  var a = parseInt(splitInput[0], 10);
  var b = parseInt(splitInput[1], 10);

  if (a % b) {
    console.log(1);
  } else {
    console.log(0);
  }
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
DP2 = lambda d1, d2: [[INIT_VAL]*d2 for _ in range(d1)]
DP3 = lambda d1, d2, d3: [[[INIT_VAL]*d3 for _ in range(d2)] for _ in range(d1)]
## math
DIVC = lambda x, y: -(-x//y)
DIVF = lambda x, y: x//y

def main():
    n = II()
    aa_1 = MII()
    aa_2 = MII()
    maxv = 0
    for i in range(n):
        sumv_1 = sum(aa_1[:i+1])
        for j in range(i, n):
            sumv = sumv_1 + sum(aa_2[j:])
            maxv = max(maxv, sumv)
    print(maxv)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>

using namespace std;
int l[200000 + 5],r[200000 + 5],ans[505][505];
int n,m,Q,p,q;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m >> Q;
	for(int i = 1;i <= m;++i){
		cin >> l[i] >> r[i];
		ans[1][r[i]]++;ans[l[i] + 1][r[i]]--;
	}
	for(int i = 1;i <= n;++i)
		for(int j = 1;j <= n;++j)
			ans[i][j] += ans[i - 1][j] + ans[i][j - 1] - ans[i - 1][j - 1];
	while(Q--){
		cin >> p >> q;
		cout << ans[p][q] << endl;
	}
	return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
int main()
{
    vector<vector<bool>>arr(3,vector<bool>(3));
    vector<vector<int>>arr2(3,vector<int>(3));
    for(int i =0;i<3;i++)
    {
        for(int j =0;j<3;j++)    
        {
            cin >> arr2[i][j];
        }
    }
    int N;cin >> N;
    for(int k = 0;k<N;k++)
    {
        int a;cin >> a;
        for(int i =0;i<3;i++)
        {
            for(int j =0;j<3;j++)    
            {
                if(arr2[i][j] == a)
                {
                    arr[i][j]=true;    
                }
            }
        }
    }
    if(arr[0][0] ==true && arr[0][1] == true && arr[0][2] == true)
    {
        cout << "Yes" << endl;
    }
    else if(arr[1][0] ==true && arr[1][1] == true && arr[1][2] == true)
    {
        cout << "Yes" << endl;
    }
    else if(arr[2][0] ==true && arr[2][1] == true && arr[2][2] == true)
    {
        cout << "Yes" << endl;
    }
    else if(arr[0][0] ==true && arr[1][0] == true && arr[2][0] == true)
    {
        cout << "Yes" << endl;
    }
    else if(arr[0][1] ==true && arr[1][1] == true && arr[2][1] == true)
    {
        cout << "Yes" << endl;
    }
    else if(arr[0][2] ==true && arr[1][2] == true && arr[2][2] == true)
    {
        cout << "Yes" << endl;
    }
    else if(arr[0][0] ==true && arr[1][1] == true && arr[2][2] == true)
    {
        cout << "Yes" << endl;
    }
    else if(arr[0][2] ==true && arr[1][1] == true && arr[2][0] == true)
    {
        cout << "Yes" << endl;
    }
    else{
        cout << "No"<< endl;
    }
}

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

int main(){
  int H,N; cin >> H >> N;
  bool win = false;
  int a;
  REP(i,N){
    cin >> a;
    H -= a;
    if(H<=0){
      win = true;
      break;
    }
  }
  cout << (win? "Yes\n":"No\n");
}
  

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
int main(){
  ll n,k;
  cin>>n>>k;
  priority_queue<ll> pque;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    pque.push(a);
  }
  ll ans=0;
  while(!pque.empty()){
    ll a=pque.top();
    pque.pop();
    if(k>0) k--;
    else ans+=a;
  }
  cout<<ans<<endl;
}


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

int main() {
    ll n;
    cin >> n;    
    vector<ll> a(n);
    map<ll, ll> m;
    rep(i, n) {
        cin >> a[i];
        m[a[i]]++;
    }

    ll sum = 0;
    rep(i, n+1) {
        if (m[i] > 0) sum += ((m[i] * (m[i]-1)) / 2);
    }
    rep(i, n) {
        cout << sum-m[a[i]]+1 << endl;
    }

    return 0;
}



Measured memory_bytes: 16640
#include <iostream>

using namespace std;

int main() {
  int N, M;

  cin >> N >> M;

  int s[M];
  int c[M];
  int ret[N];
  for (int i = 0; i < N; ++i)
    ret[i] = -1;
  for (int i = 0; i < M; ++i) {
    cin >> s[i];
    cin >> c[i];
  }

  for (int i = 0; i < M; ++i) {
    if (ret[s[i] - 1] != -1 && ret[s[i] - 1] != c[i]) {
      cout << -1 << endl;
      return 0;
    }
    if (N > 1 && s[i] == 1 && c[i] == 0) {
      cout << -1 << endl;
      return 0;
    }
    ret[s[i] - 1] = c[i];
  }
//ToT
  if (N == 1 && (ret[0] == 0 || ret[0] == -1)) {
    cout << 0 << endl;
    return 0;
  }

  for (int i = 0; i < N; ++i) {
    if (ret[i] == -1 && i == 0)
      ret[0] = 1;
    else if (ret[i] == -1)
      ret[i] = 0;
  }

  for (int i = 0; i < N; ++i)
    cout << ret[i];
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int saidaikouyakusuu(int a,int b){
    if(b==0) return a;
    return saidaikouyakusuu(b,a%b);
}
int saisyoukoubaisuu(int a,int b){
    return a*b/saidaikouyakusuu(a,b);
}
int n,m,cnt=0,aa[220000],ab[110000],o,p;
pair<int,int> pp[220000];
string s,ss[220000];
char c;
queue<int> que;
signed main(){
    cin>>n;
    rep(i,n){
        cin>>aa[i];
        ab[aa[i]]++;
        cnt+=aa[i];
    }
    cin>>m;
    rep(i,m){
        cin>>pp[i].first>>pp[i].second;
    }
    rep(i,m){
        cnt+=(pp[i].second-pp[i].first)*ab[pp[i].first];
        ab[pp[i].second]+=ab[pp[i].first];
        ab[pp[i].first]=0;
        cout<<cnt<<endl;
    }
}

Measured memory_bytes: 13536
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.LinkedHashMap;
import java.math.BigDecimal;

public class Main {
    public static Scanner sc;
    public static LinkedHashMap<String, BigDecimal> map;
    public static ArrayList<Data> list;
    public static void main(String[] args) throws Exception {
        sc = new Scanner(System.in);
        
        BigDecimal bd = new BigDecimal(1000000);
        
        while (sc.hasNext()) {
            int n = sc.nextInt();
            if (n == 0) break;
            
            list = new ArrayList<Data>();
            
            for (int i = 0; i < n; i++) {
                String s = sc.next();
                BigDecimal cost = new BigDecimal(sc.nextLong() * sc.nextLong());
                
                if (list.size() == 0) {
                    list.add(new Data(s, cost));
                } else {
                    boolean b = false;
                    int t = -1;
                    for (int j = 0; j < list.size(); j++) {
                        if (list.get(j).number.equals(s)) {
                            b = true;
                            t = j;
                        }
                    }
                    if (b) {
                        BigDecimal now = list.get(t).cost;
                        list.get(t).cost = cost.add(now);
                    } else {
                        list.add(new Data(s, cost));
                    }
                }
            }
            
            boolean isShow = false;

            for (int i = 0; i < list.size(); i++) {
                String s = list.get(i).number;
                if (list.get(i).cost.compareTo(bd) >= 0) {
                    System.out.println(s);
                    isShow = true;
                } 
            }
            
            if (!isShow) {
                System.out.println("NA");
            }
        }
    }
}

class Data {
    public String number;
    public BigDecimal cost;
    public Data(String s, BigDecimal bd) {
        number = s;
        cost = bd;
    }
}

Measured memory_bytes: 37344
ADJ = 10**2
n = int(input())
ts = list(map(int, input().split()))
vs = list(map(int, input().split()))
for i in range(n):
    ts[i] *= ADJ
    vs[i] *= ADJ
tt = sum(ts)
vss = [0]*tt
j = 0
cnt = 0
for i in range(tt):
    vss[i] = vs[j]
    cnt += 1
    if cnt == ts[j]:
        j += 1
        cnt = 0
#print(vss)
max_speed = 1
max_speeds = [0]*tt
for i in reversed(range(tt-1)):
    max_speeds[i] = min(max_speed,vss[i],vss[i+1],max_speeds[i+1]+1)
    max_speed += 1
#print(max_speeds)
cv = 0
for i in range(tt):
    if cv < max_speeds[i]:
        cv += 1
    elif cv == max_speeds[i]:
        pass
    else:
        cv -= 1
    vss[i] = cv
#print(vss)
res = 0
for i in range(tt):
    if i == 0:
        res += vss[i] / 2
    else:
        if vss[i] >= vss[i-1]:
            res += vss[i-1] + (vss[i] - vss[i-1]) / 2
        else:
            res += (vss[i-1] - vss[i]) / 2 + vss[i]
    #print()
    #print(str(i)+" "+str(res))
print(res/ADJ/ADJ)

Measured memory_bytes: 105152
def main():
    n = int(input())
    l = list(map(int,input().split(' ')))
    ans = 0
    for i in range(n-2):
        if l[i]<l[i+1]<l[i+2] or l[i+2]<l[i+1]<l[i]:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
def is_good(m):
    for i in range(2):
        a = m % 10
        m //= 10
        b = m % 10
        if a != b:
            return False
    return True

n = int(input())
while True:
    if is_good(n):
        print(n)
        break
    n += 1
    

Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0335
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(RInt() * 32);
        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int n, m;
    cin >> n >> m;
    cout << n - m + 1 << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 101

int x, p[N], m[N][N];

void matrixChainOrder(){
  
  int i, j, k, l, n, q;
  
  n = x;
  
  for(i = 1; i <= n; i++) m[i][i] = 0;
  
  for(l = 2; l <= n; l++){
    for(i = 1; i <= n-l+1; i++){
      j = i + l - 1;
      m[i][j] = 1000000;
      for(k = i; k <= j-1; k++){
	q = m[i][k] + m[k+1][j] + p[i] * p[k+1] * p[j+1];
	if(q < m[i][j]) m[i][j] = q; 
      }
    }
  }

  printf("%d\n", m[1][x]);
  
}

int main(){
  
  int i, a;
  
  scanf("%d", &x);
  
  for(i = 1; i <= x; i++) scanf("%d %d",&p[i], &a);
 
  p[i] = a;

  matrixChainOrder();
  
  return 0;
}

Measured memory_bytes: 636
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <queue>
#include <vector>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    ll x;
    cin >> x;
    ll sum = 100;
    ll count = 0;
    while(sum < x){
        sum *= 1.01;
        count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3636
s = input()
n = len(s)

flag = True
# 回分チェック
if not s[:int(n/2)] == s[int(n/2)+1:][::-1]:
    flag = False

# 2チェック
chk = s[:int((n-1)/2)]
len_ = len(chk)
if not len_ % 2 == 0:
    a = chk[:int(len_/2)]
    b = chk[int(len_/2)+1:]
else:
    a = chk[:int(len_/2)]
    b = chk[int(len_/2):]
len_ = len(chk)
if not a == b[::-1]:
    flag = False
# 3チェック
chk = s[int((n+3)/2)-1:]

len_ = len(chk)
if not len_ % 2 == 0:
    a = chk[:int(len_/2)]
    b = chk[int(len_/2)+1:]
else:
    a = chk[:int(len_/2)]
    b = chk[int(len_/2):]

len_ = len(chk)
if not a == b[::-1]:
    flag = False
if flag:
    print('Yes')
else:
    print('No')

#kkkkkkkkkkdkkkkkkkkkk
#21
#abcdeefghiAihgfeedcba

Measured memory_bytes: 3064