akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define maxn	500005
#define mod		int(1e9+7)
#define db		double
#define ll		long long
#define si 		stack<int>
#define qi 		queue<int>
#define vi 		vector<int>
#define pi 		pair<int, int>
ll powmod(ll a, ll b) {
	ll res = 1; a %= mod;
	for (; b; b >>= 1)
		res = (res * ((b & 1) ? a : 1)) % mod,
		a = a * a % mod;
	return res;
}
ll gcd(ll a, ll b) {
	return b ? gcd(a, b) : a;
}
/** GRAPH
int edgenum, head[maxn], vet[2 * maxn], nxt[2 * maxn], wt[2 * maxn];
void addedge(int u, int v) {
	edgenum ++;
	vet[edgenum] = v;
	nxt[edgenum] = head[u];
	head[u] = edgenum;
}
void addedge(int u, int v, int w) {
	edgenum ++;
	vet[edgenum] = v;
	nxt[edgenum] = head[u];
	head[u] = edgenum;
	wt[edgenum] = w;

}
GRAPH **/

using namespace std;
int main() {
	int k, a, b;
	cin >> k >> a >> b;
	for(int i = a; i <= b; i ++) {
		if(i % k == 0) {
			cout << "OK";
			return 0;
		}
	}
	cout << "NG";
	return 0;
}

Measured memory_bytes: 3636
package main

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

var (
	// ReadString returns a WORD string.
	ReadString func() string
)

func init() {
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
}

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt64() int64 {
	n, _ := strconv.ParseInt(ReadString(), 10, 64)
	return n
}

func readInt() int {
	return int(readInt64())
}

// 10 11 12 => [10, 11, 12]
func readIntSlice(size int) []int {
	a := make([]int, size)
	for i := 0; i < size; i++ {
		a[i] = readInt()
	}
	return a
}

func get2byte(size int) [][]byte {
	a := make([][]byte, size)
	for i := 0; i < size; i++ {
		var low string
		fmt.Scan(&low)
		a[i] = []byte(low)
	}
	return a
}

func transpose(a [][]int) {
	n := len(a)
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			a[i][j], a[j][i] = a[j][i], a[i][j]
		}
	}
}

func fact(n, m int) int {
	res := 1
	for i := m + 1; i <= n; i++ {
		res *= i
	}
	return res
}

func perm(n, r int) int {
	if r > n {
		return 0
	}
	return fact(n, n-r)
}

func comb(n, m int) int {
	if m > n {
		return 0
	}
	return fact(n, n-m) / fact(m, 0)
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

func min64(integers ...int64) int64 {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

func max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

func main() {
	x, k, d := readInt64(), readInt64(), readInt64()
	fmt.Println(solve(x, k, d))
}

func solve(x, k, d int64) int64 {
	np := (k - x/d) / 2
	nm := (k + x/d) / 2
	if np < 0 {
		return int64(math.Abs(float64(x - k*d)))
	} else if nm < 0 {
		return int64(math.Abs(float64(x + k*d)))
	}
	var res []int64
	for i := -1; i <= 1; i++ {
		xp := np + int64(i)
		if xp < 0 {
			continue
		}
		xm := k - xp

		if xm < 0 {
			continue
		}
		res = append(res, int64(math.Abs(float64(x+(xp-xm)*d))))
	}
	for i := -1; i <= 1; i++ {
		xm := nm + int64(i)
		if xm < 0 {
			continue
		}
		xp := k - xm
		if xp < 0 {
			continue
		}
		res = append(res, int64(math.Abs(float64(x+(xp-xm)*d))))
	}
	return min64(res...)
}


Measured memory_bytes: 1780
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define int long long
#define F(i,L,R) for(int i=L;i<R;++i)
#define FE(i,L,R) for(int i=L;i<=R;++i)
#define getI(a) scanf("%lld",&a)
#define getII(a,b) scanf("%lld%lld",&a,&b)
#define getIII(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define VgetI(n) int (n); scanf("%lld",&(n))
#define VgetII(n,m) int (n),(m); scanf("%lld%lld",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define qq cout<<"QQ\n";
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define INF 2000000000
int c[5];
char check[]="AWTR";
string verdict[]={"AC","WA","TLE","RE"};
main(){
	int n;
	while(~getI(n)){
		F(i,0,5) c[i]=0;
		F(i,0,n){
			string s;
			cin>>s;
			F(j,0,4) if(s[0]==check[j]) c[j]++;
		}
		F(i,0,4)
			cout<<verdict[i]<<" x "<<c[i]<<"\n";
	}
}


Measured memory_bytes: 3708
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long int

int main() {
  int n, k;
  std::cin >> n;
  std::vector<int> v;
  for(int i = 0; i < n; i++) {
    std::cin >> k;
    v.push_back(k);
  }
  std::sort(v.begin(), v.end());
  
  std::cout << v.at(n/2) -  v.at(n/2-1) << std::endl;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long int n;
    cin>>n;
    int a[n];
    int x[200005]={0};

    long long int sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
        x[a[i]]++;
    }
    int q;
    cin>>q;
    while(q--)
    {
        int b,c;
        cin>>b>>c;
        int d=x[b];
        x[c]+=d;
      x[b]=0;
       sum+=(c-b)*d;
        cout<<sum<<endl;

    }
    return 0;
}


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

using namespace std;

int main() {
    int group[13] = {0, 1, 2, 1, 3, 1, 3, 1, 1, 3, 1, 3, 1};
    int x, y;
    cin >> x >> y;
    if (group[x] == group[y]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

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

int main(){
  string S;
  cin >> S;
  int N = S.size();
  int zero, one;
  zero = one = 0;
  rep(i, N) {
    if(S.at(i) == '0') zero++;
    else one++;
  }
  cout << 2*min(zero, one) << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<math.h>
#include<set>
#define ll long long int
#define mod 1000000007
#define MAX 10000003
#define pb push_back
#define mem(x,y) memset(x,y,sizeof(x))
#define loop(i,x,y) for(ll i=x;i<y;i++)
#define rloop(i,x,y) for(ll i=x-1;i>=y;i--)
using namespace std;
vector<vector<ll> > vec2d;
vector<pair<ll, ll> > vec_pair;
multiset<ll> node[200003];
// vector<pair<ll, ll> > vec_pair;
int main()
{
    string str;
    cin>>str;
    ll arr[27];
    for(ll i=0;i<26;i++)
        arr[i]=0;
    ll n=str.size(),a,b;
    for(ll i=0;i<n;i++)
    {
        a=(int)str[i]-65;
        b=arr[a];
        b++;
        arr[a]=b;
    }
    ll t=0;
    for(ll i=0;i<26;i++)
    {
        if(arr[i]==2)
            t++;
    }
    if(t==2)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 9600
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifdef LOCAL
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#else
#define debug(x) ;
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

ll dp[22][1<<22];

int main(){
  int n;
  int a[21][21];

  scanf("%d", &n);

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

  dp[0][0] = 1;

  for(int i=0;i<n;i++){
    for(int j=0;j<(1<<n);j++){
      if(__builtin_popcount(j) != i) continue;

      for(int k=0;k<n;k++){
        if(j>>k&1) continue;
        if(a[i][k]) (dp[i+1][j + (1<<k)] += dp[i][j]) %= mod;
      }
    }
  }

  cout << dp[n][(1<<n)-1] << endl;

  return 0;
}


Measured memory_bytes: 321920
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  std::map<std::string,int> MAP;
  int N;
  cin >> N;
  string a;
  
  rep(i, N){
  cin >> a;
    MAP[a]=0;
  }
  cout << MAP.size()<<endl;

}

Measured memory_bytes: 19124
def fee(w):
    if w>30:
        return (w-30)*160+10*140+10*125+1150
    if w>20:
        return (w-20)*140+10*125+1150
    if w>10:
        return (w-10)*125+1150
    return 1150

prev_m=4280
while True:
    W=int(input())
    if W==-1:
        break
    print(prev_m-fee(W))
    # prev_m=fee(W)



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

using namespace std;
using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<vector<bool>> l(n, vector<bool>(10)), r(n, vector<bool>(10));
    l[0][s[0] - '0'] = true;
    for(int i=1;i<n;i++){
        for(int j=0;j<10;j++){
            l[i][j] = l[i-1][j];
        }
        l[i][s[i] - '0'] = true;
    }
    r[n-1][s[n-1] - '0'] = true;
    for(int i=n-2;i>=0;i--){
        for(int j=0;j<10;j++){
            r[i][j] = r[i+1][j];
        }
        r[i][s[i] - '0'] = true;
    }

    set<int> ans;
    for(int c = 1; c < n-1;c++){
        int cc = s[c] - '0';
        for(int ll=0;ll<10;ll++){
            for(int rr=0;rr<10;rr++){
                if(l[c-1][ll] && r[c+1][rr]){
                    ans.insert(ll * 100 + cc * 10 + rr);
                } 
            }
        }
    }
    // for(auto&& x:ans)cerr << setw(3) << setfill('0') << x << endl;
    cout << ans.size() << endl;
    return 0;
}

Measured memory_bytes: 7488
import math
from statistics import mean
# a=int(input())
b=int(input())
# c=[]
# for i in b:
#     c.append(i)
#e1,e2 = map(int,input().split())
f = list(map(int,input().split()))
#j = [input() for _ in range(3)]

mea = mean(f)
lis=[]

if mea in f :
    print(f.index(mea))
else:
    for i in range(len(f)):
        lis.append(abs(mea-f[i]))
    print(lis.index(min(lis)))

Measured memory_bytes: 10980
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx,avx2")
#pragma GCC optimize ("trapv")

#include <bits/stdc++.h>
using namespace std;

#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (x).size()
#define what_is(x) cerr << #x << " is " << x << endl;
#define wis cout<<endl<<"I already speak english, bitch"<<endl<<endl;
 
typedef long long int lli;
typedef vector<lli> vi;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef pair<ii,lli> iii;
typedef long double C; 

#define trace(args...) { string  _s =#args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
void err(istream_iterator<string> it){}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args){
    cerr <<  *it  << " : " << a << endl;
    err(++it, args...);
}

set<int> s;

bool des(int n){
	bool chi=true;
	while(n!=0){
		int dig=n%10;
		n/=10;
		if(s.count(dig)) return false;
	}
	return true;
}


int main(){
	fastio;
	int n,k; cin>>n>>k;
	rep(i,0,k){
		int foo; cin>>foo;
		s.insert(foo);
	}
	while(1){
		if(des(n)){
			cout<<n<<endl;
			break;
		}
		n++;
	}
	return 0;
}

/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do smth instead of nothing and stay organized
*/


Measured memory_bytes: 256
# coding:utf-8
import sys
def call(n):
    i = 1
    sys.stdout.write(' ')
    while i <= n:
        x = i
        if x % 3 == 0:
            print i, 
            if i <= n:
                i += 1
                continue
        while x != 0:
            if x % 10 == 3:
                print i,
                if i <= n:
                    break
            x = int(x / 10)
        i += 1
    else:
        print
n = input()
call(n)



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

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  map<long long, long long> cnt;
  long long sum = 0;
  for (int i = 0; i <= n; ++i) {
    sum += a[i];
    ++cnt[sum];
  }
  long long ans = 0;
  for (auto it : cnt) {
    ans += it.second * (it.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 13568
import java.io.*;
import java.lang.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;
import java.math.BigInteger;

public class Main {
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int op = in.nextInt();
        long sum = a+b+c;
        while(op-->0){
            int val = Math.max(a,Math.max(b,c));
            if(a==val){
                sum+=a;
                a = a * 2;
            }
            else if(b==val) {
                sum+=b;
                b = b * 2;
            }
            else {
                sum+=c;
                c = c * 2;
            }
        }
        out.println(sum);
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext() {
            String next = null;
            try {
                next = reader.readLine();
            } catch (Exception e) {
            }
            if (next == null) {
                return false;
            }
            tokenizer = new StringTokenizer(next);
            return true;
        }

        public BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
    }
}



Measured memory_bytes: 32740
//#define _GRIBCXX_DEBUG
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;


// 基本テンプレート
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<double> vd;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<long, long> pil;


// Effective std
template<typename C, typename T>
constexpr int count(C& c, T t) { return count(ALL(c), t); }

template<typename C, typename F>
constexpr int count_if(C& c, F f) { return count_if(ALL(c), f); }

template<typename C, typename T, typename U>
constexpr void replace(C& c, T t, U u) { replace(ALL(c), t, u); }

template<typename C, typename F, typename U>
constexpr void replace_if(C& c, F f, U u) { (ALL(c), f, u); }

template<typename C>
constexpr void sort(C& c) { sort(ALL(c)); }

template<typename C, typename Pred>
constexpr void sort(C& c, Pred p) { sort(ALL(c), p); }


// グラフテンプレート
typedef int Weight;

struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) {}
};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight :
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

const ll  MOD = 1000000007;
 
ll ans=0;
ll k_table[200100];
ll pow(ll x, ll n){
  ll ret = 1;
  while(n>0){
    if(n & 1){
      ret = (ret * x) % MOD;
    }
    x = (x*x) % MOD;
    n >>= 1;
  }
  return ret;
}
int main(){
  ll H,W,A,B;
  cin >> H >> W >> A >> B;
  H--;
  W--;
  A--;
  B--;
  k_table[0] = 1;
  for(ll i=1;i<=200000;i++){
    k_table[i] = (k_table[i-1] * i) % MOD;
  }
  ll hab = k_table[(H-A)+B];
  ll wab = k_table[A+(W-B)];
  ll m = min(W-B,H-A);
  for(ll i=0;i<m;i++){
    //cout << (hab*h_ab)%MOD << endl;
    //cout << (wab*w_ab)%MOD << endl;
    ll h_ab = pow( (k_table[H-A-1-i]*k_table[B+1+i])%MOD , MOD-2);
    ll w_ab = pow( (k_table[A+1+i]*k_table[W-B-1-i])%MOD , MOD-2);
    ans = (ans + (((hab*h_ab)%MOD) * ((wab*w_ab)%MOD))%MOD)%MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

#ifdef DEBUG
#else
    #define cerr if (false) cerr
#endif

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

#define int long long

main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector <int> a(n);
    cin >> a;
    auto check = [&](int m) {
        int ans = 0;
        forn (i, 0, n)
            ans += (a[i] - 1) / m;
        return ans;
    };
    int l = 0, r = 1e18;
    while (r - l > 1) {
        int m = l + r >> 1;
        if (check(m) <= k)
            r = m;
        else
            l = m;
    }
    cout << r;
    return 0;
}

Measured memory_bytes: 4748
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

struct Node
{
    vector<int> edges;
    int64_t counter = 0;
};

using Graph = vector<Node>;

void FindCounters(Graph &g, int node, int father = -1)
{
    for (const auto &next : g[node].edges) {
        if (next != father) {
            g[next].counter += g[node].counter;
            FindCounters(g, next, node);
        }
    }
}

int main()
{
    int nodes, ops;
    cin >> nodes >> ops;

    Graph graph(nodes);
    for (auto i = 1; i < nodes; i += 1) {
        int a, b;
        cin >> a >> b;
        graph[a - 1].edges.push_back(b - 1);
        graph[b - 1].edges.push_back(a - 1);
    }

    for (auto i = 0; i < ops; i += 1) {
        int64_t node, value;
        cin >> node >> value;
        graph[node - 1].counter += value;
    }

    FindCounters(graph, 0);

    for (const auto &node : graph) {
        cout << node.counter << " ";
    }
    cout << "\n";

    return 0;
}


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

int main() {
	int64_t N;
	cin >> N;

	int64_t i=1;
	int64_t maxi = 0;
	while (i*i<=N) {
		if (N%i==0){
			maxi = i;
		}
		i++;
	}
	int64_t ans = maxi + N/maxi -2;

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set1;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int main() 
{
	i_os;
    ll t;
    cin>>t;
    while(t--){
    	ll n;
    	cin>>n;
    	ll arr[n];
    	REP(i,0,n){
    		cin>>arr[i];
    	}
    	string s;
    	cin>>s;
    	vector<ll> st;
    	// st.insert(0);
    	bool f = 0;

    	REPI(i,0,n){
    		ll v = arr[i];
    		for(auto it:st){
    			v = min(v,v ^ it);
    		}
    		if(v){
    			if(s[i] == '1'){
	    			cout<<1<<endl;
	    			f = 1;
	    			break;
	    		}
	    		else {
	    			st.push_back(v);
	    		}
    		}
    	}
    	if(f == 0){
    		cout<<0<<endl;
    	}
    }
	return 0;
}

Measured memory_bytes: 3592
N=int(input())
Z=[list(map(int,input().split())) for i in range(N)]
A,B=zip(*Z)
A=list(A[::-1])
B=list(B[::-1])
ans=0
for i in range(N):
  A[i]+=ans
  if A[i]%B[i]!=0:
    a=B[i]-(A[i]%B[i])
    ans+=a
print(ans)

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

int main(){
    int N;
    cin >> N;
    string s;
    cin >> s;
    for(int i = 0; i < N && i < s.length();i++){
        cout << s[i];
    }
    if(s.length() > N) cout << "...";
    return 0;
}


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

int main()
{
	int n, m;
	cin >> n >> m;
	int l, r;
	int ruiseki[110000] = {};
	for (int i = 0; i < m; ++i)
	{
		cin >> l >> r;
		++ruiseki[l];
		--ruiseki[r + 1];
	}
	int ans = 0;
	for (int i = 1; i < n + 1; ++i)
	{
		ruiseki[i] += ruiseki[i - 1];
		ans += (ruiseki[i] == m);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <utility>
#include <cstdio>
using namespace std;

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

const int N = 1000001;
int hamming[N];

int main() {
    rep(i, N) hamming[i] = true;

    hamming[0] = false;
    rep(i, N) {
        if(!hamming[i]) continue;
        if(i == 1 || i % 2 == 0 || i % 3 == 0 || i % 5 == 0) continue;

        for(int j = i * 1; j < N;j += i) {
            hamming[j] = false;
        }
    }

    //rep(i, 50) printf("%d %d\n", i, hamming[i]);

    while(1) {
        int m, n;
        cin >> m;
        if(!m) break;
        cin >> n;

        int ans = 0;
        for(int i = m;i <= n;i++) {
            if(hamming[i]) ans++;
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 5064
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, a;
    while (cin >> n) {
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            cin >> a;
            if (i & 1) {
                ans += a % 2;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3672
#include<iostream>
#include<vector>
#define MAX 100000
using namespace std;

int dp[MAX]; //dp[k]:kにたどり着くまでの最小コスト

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> h(n + 1);
    for(int i = 1;i <= n;i++){
        cin >> h.at(i);
    }
    /**/
    dp[1] = 0;
    dp[2] = abs(h.at(2) - h.at(1));
    
    for(int i = 3;i <= n;i++){
        dp[i] = INT_MAX;
        for(int j = 1;(j <= k)&&(i - j > 0);j++){
           dp[i] = min(dp[i],dp[i - j] + abs(h.at(i) - h.at(i - j)));
        }
    }
    

    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,a,b;
    scanf("%lld%lld%lld",&n,&a,&b);
    if(a==b)
       printf("1\n");
    else if(a>b)
      printf("0\n");
    else if(n==1)
      printf("0\n");
    else
      printf("%lld\n",(n-2)*(b-a)+1);
    return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
typedef long long ll; 
 
using namespace std;
using P = pair<int, int>;

bool comp(const P& v1, const P& v2) {
	if (v1.first == v2.first) { return v1.second < v2.second; }
	else return v1.first < v2.first;
}

int main() {
	int N;
	cin >> N;
	vector<P> re(N);
	vector<P> bl(N);
	for (int i = 0; i < N; ++i) {
		int a, b;
		cin >> a >> b;
		re[i] = P(a, b);
	}
	for (int i = 0; i < N; ++i) {
		int c, d;
		cin >> c >> d;
		bl[i] = P(c, d);
	}

	sort(re.begin(), re.end(), comp);
	sort(bl.begin(), bl.end(), comp);
	vector<bool> used(N, false);
	int res = 0;
	for (int i = 0; i < N; ++i) {
		int x = bl[i].first, y = bl[i].second;
		int ry = -1, it = -1;
		for (int j = 0; j < N; ++j) {
			if (used[j]) { continue; }
			if (re[j].first > x) { break; }

			if (re[j].second < y) {
				if (re[j].second > ry) {
					ry = re[j].second;
					it = j;
				}
			}
		}
		if (it >= 0) {
			++res;
			used[it] = true;
		}
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
import numpy as np
import math

def func(x, y, z):
    return x ** 2 + y ** 2 + z ** 2 + x*y + y*z + z*x

def count_xyz(n):
    counts = np.zeros(n + 1, dtype=int)
    for x in range(1, math.ceil(math.sqrt(n)) + 1):
        if func(x, x, x) > n:
                break
        for y in range(x, math.ceil(math.sqrt(n)) + 1):
            if func(x, y, y) > n:
                    break
            for z in range(y, math.ceil(math.sqrt(n)) + 1):
                if func(x, y, z) > n:
                    break
                if len({x, y, z}) == 1:
                    counts[func(x, y ,z)] += 1
                elif  len({x, y, z}) == 2:
                    counts[func(x, y ,z)] += 3
                else:
                    counts[func(x, y ,z)] += 6
    
    return counts


def main():
    N = int(input())
    counts = count_xyz(N)
    for i in range(1, N + 1):
        print(counts[i])

if __name__ == "__main__":
    main()

Measured memory_bytes: 27412
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
//#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
//#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

//using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;


/*binary_search(vc.begin(), vc.end(),X)
or
binary_search(all(vector),X)
で、ソート済み配列に対してXが存在するか返す。
使用例
if((binary_search(all(S), a))ans++;
*/


int main() {
	int N;
	cin>>N;
	vector<int> S(N);
	rep(i,N)cin>>S[i];
	int q;cin>>q;
	vector<int> T(q);
	rep(i,q)cin>>T[i];
	int ans = 0;
	rep(i,q){
		if(binary_search(all(S),T[i])){
			ans++;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3268
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for(auto &number : a) cin >> number;
	for(auto &number : b) cin >> number;
	int aa = 0, bb = 0;
	while(!is_sorted(a.begin(), a.end()))
	{
		++aa;
		prev_permutation(a.begin(), a.end());
	}
	while(!is_sorted(b.begin(), b.end()))
	{
		++bb;
		prev_permutation(b.begin(), b.end());
	}
	cout << abs(aa - bb) << '\n';
}

Measured memory_bytes: 3640
N = int(input())
A =list(map(int,input().split()))
num = 0
for i in range(N):
    if A[i] == 0:
       num = - float('inf')
       break
    elif A[i] < 0:
        num += 1

A = [abs(A[i]) for i in range(N)]
if num < 0 or num % 2  == 0:
    print(sum(A))

else:
    print(sum(A)-2*min(A))

    



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

#define dump(x) cout << (x) << endl
#define Int int64_t
#define fi first
#define se second

Int INF = 1e9;
Int mod = 1e9+7;

int main() {
    Int a, b;
    cin >> a >> b;
    dump((a < 10 && b < 10) ? a * b : -1);
    return 0;
}

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

using ll=long long;
const ll MOD=1000000007;

int main() {
  int K,s,cnt;
  cin >> K >> s;
  for(int i=0;i<=K;i++){
    for(int j=0;j<=K;j++){
      int t=s-i-j;
      if(0<=t&&t<=K){
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}


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

using namespace std;

const int N   = 1e5 + 5;
const int INF = 2e9;

int jump[N];
int h[N];
int n;


main(){

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

    for(int i = 0 ; i < n ; i ++){
            jump[i] = INF;
    }

    jump[0] = 0;
    for(int i = 0 ; i < n ; i ++){

            jump[i + 1] = min(jump[i + 1] , abs(h[i] - h[i+1]) + jump[i]);

            if(i + 2 < n) {
                    jump[i + 2] = min(jump[i + 2] , abs(h[i] - h[i+2]) + jump[i]);
            }
    }

    printf("%d\n" , jump[n-1]);

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
#include<utility>
#include<queue>
#include <map>

using namespace std;

int main(){

	string s;
	cin>>s;
	if(s=="AAA" || s=="BBB")cout<<"No";
	else cout<<"Yes";
	cout<<endl;

	return 0;
}


Measured memory_bytes: 256
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int sx, sy, tx, ty;

void solve()
{
    string s;
    int dx = tx - sx;
    int dy = ty - sy;
    REP(i, dx) s += 'R';
    REP(i, dy) s += 'U';
    REP(i, dx) s += 'L';
    REP(i, dy) s += 'D';
    s += 'D';
    REP(i, dx+1) s += 'R';
    REP(i, dy+1) s += 'U';
    s += 'L';
    s += 'U';
    REP(i, dx+1) s += 'L';
    REP(i, dy+1) s += 'D';
    s += 'R';
    cout << s << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> sx >> sy >> tx >> ty;
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    // 数値の配列を作る
    const numList0 = input[0].split(' ').map(x => parseInt(x, 10));
    const N = numList0[0];
    const aList = input[1].split(' ').map(x => parseInt(x, 10));
    const bList = input[2].split(' ').map(x => parseInt(x, 10));
    const cList = input[3].split(' ').map(x => parseInt(x, 10));

    var total = 0;
  	var before = -10000;
    for (var i = 0; i < N; i++) {
        var currentIndex = aList[i];
        total += bList[currentIndex - 1];
        if (before + 1 === currentIndex) {
            total += cList[before - 1];
        }
      	before = currentIndex;
    }

    console.log(total);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
using namespace std;
const int maxn = 40005;
const long long p = 1e14 + 7;
char a[maxn], b[maxn];
int num[26], tmp, l1, l2;
inline long long H() {
	long long hash = 0;
	for (int i = 0; i < 26; i ++)
		hash = (hash * 6887 + num[i]) % p;
	return hash;
}
long long f[maxn];
inline long long erfen(long long x) {
	int l = 1, r = tmp;
	while (l < r) {
		int mid = l + r >> 1;
		if (f[mid] >= x) r = mid;
		else l = mid + 1;
	}
	return f[l];
}
inline int work() {
	for (int len = min(l1, l2); len >= 1; len --) {
		tmp = 0;
		memset(num, 0, sizeof(num));
		for (int i = 1; i <= len; i ++) num[a[i] - 'a'] ++;
		for (int j = len; j <= l1; j ++) {
			long long hash = H();
			f[++ tmp] = hash;
			num[a[j + 1] - 'a'] ++; num[a[j - len + 1] - 'a'] --;
		}
		sort(f + 1, f + 1 + tmp);
		memset(num, 0, sizeof(num));
		for (int i = 1; i <= len; i ++) num[b[i] - 'a'] ++;
		for (int j = len; j <= l2; j ++) {
			long long hash = H();
			if (erfen(hash) == hash) return len;
			num[b[j + 1] - 'a'] ++; num[b[j - len + 1] - 'a'] --;
		}
	}
	return 0;
}
int main() {
	while (scanf("%s %s", a + 1, b + 1) != EOF) {
		l1 = strlen(a + 1); l2 = strlen(b + 1);
		printf("%d\n", work());
	}
	return 0;
}

Measured memory_bytes: 3340
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  string a,b,c;
  cin >> s;
  a = "Sunny";
  b = "Cloudy";
  c = "Rainy";
  if(s == a)
    cout << "Cloudy";
  else if(s == b)
    cout << "Rainy";
  else if(s == c)
    cout << "Sunny";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define N (ll)(1e17+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
ll n;
ll dp[100005][3];
vector <ll> v[100005];
ll f(ll pos,ll sel)
{
    ll i,mx=-1;
    if(dp[pos][sel]!=-1)
     return dp[pos][sel];
    if(pos==n-1)
     {

         for(i=0;i<3;i++)
         {
             if(i!=sel)
             {
                 mx=max(mx,v[pos][sel]);
             }
         }
         return dp[pos][sel]=mx;
     } 
     for(i=0;i<3;i++)
     {
         if(i!=sel)
         {
             mx=max(mx,v[pos][sel]+f(pos+1,i));
         }
     }
     return dp[pos][sel]=mx;
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll t=1;
   //cin>>t;
   while(t--)
   {    
       ll i,a,b,c,ans;
       memset(dp,-1,sizeof(dp));
       cin>>n;
       for(i=0;i<n;i++)
       {
           cin>>a>>b>>c;
           v[i].pb(a);
           v[i].pb(b);
           v[i].pb(c);
       }
       ans=max(f(0,0),max(f(0,1),f(0,2)));
       cout<<ans<<"\n";
   }
}

Measured memory_bytes: 17408
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int a[100];

int main()
{
	int N;
	int Alice = 0, Bob = 0;

	cin >> N;
	rep(i, N) cin >> a[i];

	sort(a, a + N);

	rep(i, N) {
		if (i % 2 == 0) Alice += a[N - 1 - i];
		else Bob += a[N - 1 - i];
	}

	cout << Alice - Bob << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <random>
#include <utility>
#include <cmath>
#include <set>
#include <map>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};

ll i,j,k;
ll n,mae,ans=0;
ll a[100005]; 
ll aga=0,saga=0;
bool b[100005];


int main(){
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=0;i<n-1;i++){
		if(a[i+1]>a[i]){
			aga=1;
		}else if(a[i+1]<a[i]){
			saga=1;
		}else{
			continue;
		}if(aga+saga==2){
			ans++;
			aga=saga=0;
			continue;
		}
	}

	
	cout<<ans+1<<endl;
	return 0;
}

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

int main()
{
    int N, M;
    bool a[200000] = {false}, b[200000] = {false};

    cin >> N >> M;
    for (int i = 0; i < M; i++)
    {
        int x, y;
        cin >> x >> y;
        if (x == 1)
        {
            a[y - 1] = true;
        }
        else if (y == N)
        {
            b[x - 1] = true;
        }
    }

    for (int i = 0; i < N; i++)
    {
        if (a[i] && b[i])
        {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;

    return 0;
}

Measured memory_bytes: 640
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;//例: VVI dp(10, vector<int>(10, INF);
typedef priority_queue<int, vector<int>, less<int> > QUE_int;
const int INF = pow(10, 5) + 1;//+1しないとREになる(out of rangeになるんかな?? )

vector<int> dx = { -1, 0, 1, 0, -1, -1, 1, 1 };
vector<int> dy = { 0, -1, 0, 1, -1, 1, -1, 1 };


ll ll_ceil(ll a, ll b) {//divide a by b 切り上げ
	return (a + (b - 1)) / b;
}

int main(void) {
	ll N, D, A;
	cin >> N >> D >> A;
	vector<pair<ll, ll>> enemy(N);
	for (ll i = 0; i < N; i++) cin >> enemy[i].first >> enemy[i].second;

	sort(enemy.begin(), enemy.end());//firstを見て，昇順ソート
	//for (int i = 0; i < N; i++) cout << enemy[i].first << " " << enemy[i].second << endl;
	
	ll ans = 0;
	ll bomb_range = 2 * D;
	ll total_damage = 0;
	queue<pair<ll, ll>> q;//first: 爆弾が有効な位置の右端x, second: iで使った爆弾の個数*A  
	for (ll i = 0; i < N; i++) {
		ll x = enemy[i].first;
		ll h = enemy[i].second;
		
		while (q.size() && q.front().first < x) {
			total_damage -= q.front().second;
			q.pop();
		}
		h -= total_damage;
		if (h > 0) {
			ll num_attack = ll_ceil(h, A);
			total_damage += num_attack * A;
			q.emplace(pair<ll, ll>(x + bomb_range, num_attack*A));
			ans += num_attack;
		}
	}


	/* TLE出る解法
	ll ans = 0;
	ll bomb_range = 2 * D;
	for (ll i = 0; i < N; i++) {
		if (enemy[i].second <= 0) continue;
		ll x = enemy[i].first;
		ll num_attack = ll_ceil(enemy[i].second, A);
		ans += num_attack;
		//enemy[i].first = 0;
		for (int j = i; j < N; j++) {
			if (enemy[j].first > x + bomb_range) break;
			enemy[j].second -= num_attack * A;
		}
	}
	*/
	cout << ans << endl;

}


Measured memory_bytes: 4992
#include <bits/stdc++.h> 
using namespace std; 
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
map<string,set<int>>gg;
int main()
{
    flash;
	int n;
	cin>>n;
	string hey;
	cin>>hey;
	int low=0;
	int high=hey.size()-1;
	int ans=0;
	while(low<=high)
	{
		int mid=(low+high)/2;
		gg.clear();
		string init = hey.substr(0,mid);
		gg[init].insert(0);
		bool ka=false;	
		for (int i = 1; i < (hey.size()-mid+1); ++i)
		{
			string dal = hey.substr(i,mid);
			//debug(dal);
			if(i>=((*gg[dal].begin())+mid) && (!gg[dal].empty())){ka=true;break;}
			gg[dal].insert(i);	
		}
		//debugs(mid,ka);
		//debugs(low,high);
		if(ka)
		{
			low=mid+1;
			ans=max(ans,mid);
		}
		else
		{
			high=mid-1;
		}
	}
	cout<<ans;
  return 0;
}
//code the AC sol !
// BS/queue/map


Measured memory_bytes: 6844
from sys import stdin

N,K = map(int,stdin.readline().split())

P = list(map(int,stdin.readline().split()))
C = list(map(int,stdin.readline().split()))
end = [-1] * N
sc = [0] * N
for i in range(N):
    P[i] -= 1



ans = max(C)
for i in range(N):

    now = i
    nsum = 0
    lis = [0]
    cnt = None

    for j in range(min(N,K)):
        now = P[now]
        nsum += C[now]
        ans = max(ans , nsum)
        lis.append(nsum)

        if i == now and nsum > 0:
            ans = max(ans , nsum*(K//(len(lis)-1)) + max(lis[:K%(len(lis)-1)+1]))
            cnt = j+1
            break

    if cnt == None:
        continue
    
    loopnum = K // cnt
    if loopnum > 0:
        loopnum -= 1
    loopscore = loopnum * lis[-1]
    rem = K - cnt * loopnum

    now = i
    nsum = loopscore

    #print (lis,loopscore,cnt)

    for j in range(rem):
        now = P[now]
        nsum += C[now]
        ans = max(ans , nsum)

print (ans)

Measured memory_bytes: 80444
#include<stdio.h>
#include<algorithm>
using namespace std;

int main()
{
    long long a,b,c;
    scanf("%lld %lld %lld", &a, &b, &c);
    if(a%2==0||b%2==0||c%2==0){
        printf("0\n");
        return 0;
    }
    else{
        printf("%lld\n", min(min(a*b,b*c),c*a));
        return 0;
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <valarray>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;

bool search(string s, string p){
	int s_size = s.size();
	int p_size = p.size();
	if(s_size == 0 || p_size == 0) return false;
	bool flag = false;
	char head = p[0];
	for(int i = 0; i < s_size; i++){
		if(s[i] == head){
			int j;
			for(j = 0; j < p_size; j++)
				if(s[(i+j)%s_size] != p[j]) break;
			if (j == p_size){
				flag = true;
				continue;
			}
		}
	}
	return flag;
}

int main(){
	string s, p;
	cin >> s >> p;
	cout << (search(s,p)? "Yes" : "No") << endl;
}

Measured memory_bytes: 1188
import math 

divisor = (10 ** 9) + 7

N, M = [int(i) for i in input().split()]

output = 0

n_fact = math.factorial(N) 
m_fact = math.factorial(M) 

diff = abs(N-M)

if diff == 0 :
    output = n_fact * m_fact * 2 % divisor
elif diff == 1:
    output = n_fact * m_fact % divisor 

print(output)

Measured memory_bytes: 5184
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

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

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int t,a;
    cin >> t >> a;
    double h[n];
    rep(i,n){
        cin >> h[i];
    }
    int dd=INF;
    int ans=0;
    rep(i,n){
        if(abs(1000*t-h[i]*6-a*1000)<dd){
            dd=abs(1000*t-h[i]*6-a*1000);
            ans=i+1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256