akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int sx,sy,tx,ty; cin >> sx >> sy >> tx >> ty;
  int h = ty - sy, w = tx - sx;
  cout << string(h,'U') + string(w,'R') + string(h,'D') + string(w+1,'L') + string(h+1,'U') + string(w+1,'R') + "D" + "R" + string(h+1,'D') + string(w+1,'L') + 'U' << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define fo(i,j,k) for(int i=j;i<=k;++i)
#define fd(i,j,k) for(int i=j;i>=k;--i)
using namespace std;
typedef long long ll;
const int N=2e5+10;
char s[N];
int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1),t=0;
	ll ans=0;
	fd(i,n,1) if(s[i]=='W') t++;
	else ans+=t;
	printf("%lld",ans);
}


Measured memory_bytes: 384
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=998244353
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  a,b,m=LI()
  la=LI()
  lb=LI()
  l=[LI() for _ in range(m)]

  ans=min(la)+min(lb)
  for x,y,c in l:
    x-=1
    y-=1
    _ans=la[x]+lb[y]-c
    ans=min(ans,_ans)

  return ans

# main()
print(main())


Measured memory_bytes: 34548
//abc155_d.cpp
//Tue Apr  7 22:17:34 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 2000000000000000000
#define MOD 1000000007

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

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

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

	sort(a.begin(),a.end());

	ll high = LLINF;
	ll low = LLINF*(-1);
	while (abs(high-low)>1){
		ll mid = (high+low)/2;
		ll count = 0;
		for (ll i=0;i<n;i++){
			if (a[i]==0){
				if (mid>=0){
					count += n;
				}
			}else if (a[i]>0){
				ll high2 = n;
				ll low2 = -1;
				while (abs(high2-low2)>1){
					ll mid2 = (high2+low2)/2;
					if (a[mid2]*a[i]>mid){
						high2 = mid2;
					}else {
						low2 = mid2;
					}
				}
				count += low2+1;
			}else {
				ll high2 = n;
				ll low2 = -1;
				while (abs(high2-low2)>1){
					ll mid2 = (high2+low2)/2;
					if (a[mid2]*a[i]>mid){
						low2 = mid2;
					}else {
						high2 = mid2;
					}
				}
				count += n-high2;
			}
			if (a[i]*a[i]<=mid){
				count--;
			}
		}
		count = count/2;
		if (count>=k){
			high = mid;
		}else {
			low = mid;
		}
	}

	cout << high << endl;

}

Measured memory_bytes: 2420
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInt2() (int, int) {
	return nextInt(), nextInt()
}

func nextInt3() (int, int, int) {
	return nextInt(), nextInt(), nextInt()
}

func nextInt4() (int, int, int, int) {
	return nextInt(), nextInt(), nextInt(), nextInt()
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()
	a := nextInts(n)

	s := make([]int, n+1)
	for i := 1; i <= n; i++ {
		s[i] = s[i-1] + a[i-1]
	}

	mp := map[int]int{}
	ans := 0
	for i := range s {
		ans += mp[s[i]]
		mp[s[i]]++
	}

	puts(ans)
}


Measured memory_bytes: 15540
#include <iostream>

using namespace std;

#define YES(n) cout << (n?"YES":"NO")<<endl;
#define Yes(n) cout << (n?"Yes":"No")<<endl;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    YES((a * 100 + b * 10 + c) % 4 == 0);
}

Measured memory_bytes: 256
L = gets.chomp
MOD = 10**9 + 7
dpr = [1]*(10**5+1)

dpr[1] = 3
(10**5).times do |i|
  dpr[i+2] = dpr[i+1] * 3
  dpr[i+2] %= MOD
end

len = L.length
l = 1
ans = 0
len.times do |i|
  c = L[i]
  if c == "1"
    ans += (dpr[len-i-1] * l) % MOD
    ans %= MOD
    l = (l*2) % MOD
  end
end
ans += l
p ans % MOD


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

int main() {
  int X, x=0, m=0;
  cin >> X;
  x += X;
  
  for(;X >= 1; X /= 10){
    m += X%10;
  }
  if(x % m == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define vii vector<ll> 
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
const int MOD = 1e9 + 7, N = 1e4 + 3;

int main(){
    fast;
    ll n;
    cin >> n;
    ll a[n], sum = 0;;
    for(int i = 0; i < n; ++i)
        cin >> a[i];
    sort(a, a+n, greater<>());
    sum += a[0];
    ll k = 1;
    int i = 1;
    while(k != (n-1)){
        sum += a[i];
        ++k;
        if(k%2 != 0)
            ++i;
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 5208
#include<iostream>
using namespace std;
#include<cstdio>
int main()
{
	bool a=1;char c;
	while(scanf("%c",&c)==1)
	{
		if(a)printf("%c",c);
		a=!a;
	}
	printf("\n");
	return 0;
}//3.21 18:12

Measured memory_bytes: 256
import math

MAX_INT = 1001
(d, g) = list(map(int, input().split()))
g = g // 100
arr = [[0, 0] for i in range(d+1)]
for i in range(1, d+1):
    tmp = list(map(int, input().split()))
    arr[i][0] = tmp[0]
    arr[i][1] = tmp[1] // 100

res = MAX_INT
dp = [[MAX_INT for i in range(g+1)] for k in range(d+1)]
for diff in range(1, d+1):
    e = arr[diff]
    for score in range(1, g+1):
        if score / diff <= e[0]:
            dp[diff][score] = math.ceil(score/diff)
        elif score <= diff * e[0] + e[1]:
            dp[diff][score] = e[0]
        else:
            dp[diff][score] = dp[diff-1][score - (diff * e[0] + e[1])] + e[0]
        dp[diff][score] = min(dp[diff][score], dp[diff-1][score])
# for diff in range(1, d+1):
#     print(*dp[diff])

print(dp[d][g])


Measured memory_bytes: 24136
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;

int main()
{
    int n, m;
    cin >> n >> m;
    ll dd = n;
    vector<ll> a(n);
    vector<pair<ll, ll>> bc(m + n);
    for (int i = 0; i < n; i++)
    {
        bc[i].second = 1;
        cin >> bc[i].first;
    }
    for (int i = n; i < m + n; i++)
    {
        cin >> bc[i].second >> bc[i].first;
    }
    sort(rall(bc));
    //for (int i = 0; i < m + n; i++)
    //{
      //  cout << bc[i].first;
        //cout<<" "<<bc[i].second<<endl;
    //}
    ll count = 0;
    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        count += bc[i].second;
        if (count < n)
        {
            ans += bc[i].first * bc[i].second;
        }
        else
        {
            count -= bc[i].second;
            for (int j = 0; j < 100000; j++)
            {
                ans += bc[i].first;
                count++;
                if (count == n)
                {
                    break;
                }
            }
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
int main()
{
  string s; getline(cin, s);
  rep(i,s.size())
  {
    if(isalpha(s[i])&&isupper(s[i])) cout << (unsigned char)(s[i]+32);
    else if(isalpha(s[i])&&islower(s[i])) cout << (unsigned char)(s[i]-32);
    else cout << s[i];
  }
  cout << "\n";
}


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

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str = br.readLine();
			String[] a = str.split(" ", 0);
			int N = Integer.parseInt(a[0]);
			int K = Integer.parseInt(a[1]);
			str = br.readLine();
			a = str.split(" ", 0);
			int[] n = new int[N];
			for(int i = 0; i< N; i++) {
				n[i] = Integer.parseInt(a[i]);
			}
			Arrays.sort(n);
			int ans = 0;
			for(int i=0;i<K;i++) {
				ans += n[N-1-i];
			}
			System.out.println(ans);

		}catch (Exception e) {
			System.exit(0);
		}
	}
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) std::cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) std::cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) std::cout << x << endl;
#define println(x) std::cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    ll n;
    cin >> n;

    vector<vector<ll> > dp(61, vector<ll>(3));
    dp[60][0] = 1;

    ll mod = 1e9+7LL;

    for (int d=59; d >= 0; d--) {
        rep(s, 3) rep(k, 3) {
            ll s2 = min(2LL, 2 * s + ((n >> d) & 1) - k);
            if (s2 >= 0) {
                dp[d][s2] += dp[d+1][s];
                dp[d][s2] %= mod;
            }
        }
    }

    ll res = (dp[0][0] + dp[0][1] + dp[0][2]) % mod;
    put(res);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define p_b push_back
#define pl pair<ll,ll>
#define m_p make_pair
#define MOD 1000000007
#define F(i,a,b) for(i=a;i<b;i++)
#define RF(i,a,b) for(i=a;i>=b;i--)
#define nfs ios_base::sync_with_stdio(false);cin.tie(NULL)


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b;
    cin >> a >> b;
    ll cnt = 0;
    ll tot = 1;
    while(tot < b)
    {

        cnt++;
        tot-= 1;
        tot += a;

    }
    cout << cnt << endl;

    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
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; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    cout << min((N+A-1)/A*B,(N+C-1)/C*D) << endl;
    return 0;
}


Measured memory_bytes: 3208
#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>;

const int mod = 2019;

int main() {
    ll l, r;
    cin >> l >> r;
    ll ans = mod;
    if (r-l+1<mod) {
        for (ll i = l; i <= r-1; i++) for (ll j = i+1; j <= r; j++) {
            ans = min(ans,((i%mod)*(j%mod))%mod);
        }
    } else {
        for (ll i = 0; i <= mod-2; i++) for (ll j = i+1; j <= mod-1; j++) {
            ans = min(ans,((i%mod)*(j%mod))%mod);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
using namespace std;
int main() {

  int e,x;
  while(1){
    int min=0;
  cin>>e;
  if (e==0) break;
  for (int z=0; z*z*z<=e; ++z){
    for (int y=0; y*y+z*z*z<=e; ++y){
      x=e-y*y-z*z*z;
      if (min>x+y+z||min==0) min=x+y+z;
    }
  }
  cout<<min<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
def resolve():
    N = int(input())
    A = sorted(list(map(int, input().split())))
    start, end = min(A), max(A)
    mincost = float("inf")
    for i in range(start, end+1):
        _cost = 0
        for a in A:
            _cost += abs(a-i)**2
        mincost = min(mincost, _cost)
    print(mincost)


if '__main__' == __name__:
    resolve()



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <cstdio>
#define fastio {ios_base::sync_with_stdio(false); cin.tie(NULL);}
#define nln cout << '\n'
#define ll long long int
#define INF (ll)1e+12
#define MAX 300100
#define mp(i, j) make_pair(i, j)
#define here cout  << "here";nln;
#define mul(a, b, mod) (((a % mod) * (b % mod)) % mod)
#define add(a, b, mod) (((a % mod) + (b % mod)) % mod)
#define inf 100000
#define M 1000000000LL

using namespace std;

ll a[100100];
ll b[100100];

int main()
{
    ll n, i, ans = 0;

    cin >> n;

    for(i = 0; i < n; i++)cin >> a[i] >> b[i];

    for(i = n-1; i >= 0; i--){
        ans += b[i]-(((a[i]+ans)%b[i] == 0LL)?b[i]:(a[i]+ans)%b[i]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 1792
N = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr

# print(factorization(N))

count = 0

for i in factorization(N):

    # print(i, count)
    if i[0] != 1:
        minus = 1
        while i[1] > 0:
            i[1] -= minus
            if i[1] < 0:
                break
            minus += 1
            count += 1
    # print(i, count)
print(count)

Measured memory_bytes: 63364
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, long long b) {
  if(b==0)return 1;
  if (a==0)return 0;
  Num x = 1;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

using ll=long long;
using i64=std::int_fast64_t;
using u64=std::uint_fast64_t;

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

  std::string s;
  std::cin>>s;

  ll n=s.size();

  rep(i,0,n-1){
    if(s[i]==s[i+1]){
      std::cout<<i+1<<" "<<i+2<<"\n";
      return 0;
    }
  }

  rep(i,0,n-2){
    if(s[i]==s[i+2]){
      std::cout<<i+1<<" "<<i+3<<"\n";
      return 0;
    }
  }

  std::cout<<"-1 -1\n";
  
  return 0;
}

Measured memory_bytes: 3736
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,W=map(int,input().split())
    w=[0]*(n+1)
    v=[0]*(n+1)
    for i in range(1,n+1):
        w[i],v[i]=map(int,input().split())
    dp=[0]*(W+1)
    for i in range(1,n+1): # i番目を見る
        newdp=dp[:]
        for j in range(W+1):
            if(j+w[i]<=W):
                newdp[j+w[i]]=max(newdp[j+w[i]],dp[j]+v[i])
        dp=newdp
    print(dp[-1])
resolve()

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

map<string, int> mp;
int n;
vector<pair<string, string>> p;
string st, go;

int solve();
string make(string s, int x);

int main() {
  while(1) {
    cin >> n;
    if(n == 0) break;
    for(int i = 0; i < n; ++i) {
      string s, t;
      cin >> s >> t;
      p.push_back(make_pair(s, t));
    }
    cin >> st >> go;
    cout << solve() << endl;
    mp.erase(mp.begin(), mp.end());
    p.erase(p.begin(), p.end());
  }
  return 0;
}

int solve() {
  queue<string> qu;
  qu.push(st);
  mp[st] = 0;
  while(qu.size() > 0) {
    string now = qu.front(), nexts;
    qu.pop();
    if(now.size() >= go.size()) continue;
    for(int i = 0; i < n; ++i) {
      nexts = make(now, i);
      if(mp.find(nexts) == mp.end()) {
        mp[nexts] = mp[now] + 1;
        qu.push(nexts);
      }
      if(nexts == go) return mp[now] + 1;
    }
  }
  return -1;
}

string make(string s, int x) {
  string nexts;
  for(int i = 0; i < s.size(); ++i) {
    int k;
    for(k = 0; k < p[x].first.size() && k + i < s.size();
        ++k)
      if(p[x].first[k] != s[k + i]) break;
    if(k == p[x].first.size()) {
      nexts += p[x].second;
      i += k - 1;
    }
    else
      nexts += s[i];
  }
  return nexts;
}


Measured memory_bytes: 3384
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()

ans = n//2
if n % 2 == 1:
    ans += 1
print(ans)

Measured memory_bytes: 31292
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int wa=0,tle=0,re=0,ac=0;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        if(s=="AC")
            ac++;
        else if(s=="TLE")
            tle++;
        else if(s=="WA")
            wa++;
        else
            re++;
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;
}

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

int main()
{
  string s;
  cin >> s;
  
  if(s[0] == '0' || s.back() == '1')
  {
    cout << -1 << endl;
    return 0;
  }
  
  while(true)
  {
    if(s.back() == '0')
    {
      s.erase(s.end()-1);
    }
    else break;
  }
  
  int n = s.size();
  rep(i,n)
  {
    if(s[i] != s[n-1-i])
    {
      cout << -1 << endl;
      return 0;
    }
  }
  
  
  vector<P> edge;
  int left = 0;
  for(int i = 1; i < n; i++)
  {
    if(s[i] == '1')
    {
      for(int j = left; j < i; j++)
      {
        edge.push_back(P(j, i));
      }
      left = i;
    }
  }
  edge.push_back(P(left, n));
  
  //cout << (int)edge.size() << endl;
  for(auto x : edge) cout << x.first + 1 << " " << x.second + 1 << endl;
  
  
  return 0;
}

Measured memory_bytes: 4396
#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;

int main(void){
  int n; cin >> n;
  string s; cin >> s;
  for(int i =0; i < s.size(); i++){
    for(int j = 1; j <= n; j++){
      if(s.at(i) != 'Z') s.at(i)++;
      else s.at(i) = 'A';
    }
  }
  cout << s << endl;
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool check(char S) {
    return S == 'R' || S == 'U' || S == 'D';
}

bool check2(char S) {
    return S == 'L' || S == 'U' || S == 'D';
}

int main() {
    string S; cin >> S;
    bool puede = true;
    for(int i = 0; i < S.length(); i++) {
        if((i+1)%2 != 0) {
            if(!check(S[i])) puede = false;
        }

        if((i+1)%2 == 0) {
            if(!check2(S[i])) puede = false;
        }
    }

    if(puede) cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256
def c_string_transformation():
    from collections import defaultdict
    S,T = input(),input()
    dict_s_to_t = defaultdict(set)
    dict_t_to_s = defaultdict(set)
    for c1, c2 in zip(S, T):
        dict_s_to_t[c1].add(c2)
        dict_t_to_s[c2].add(c1)
    # ディクショナリの各要素について，値の長さが 2 以上だと，
    # ある英小文字と 2 つ以上の英小文字との間に対応がある (全単射でない)
    # そうなると，S を T に一致させることはできない
    # 全単射であることを調べるため，両方のディクショナリを検査する
    for v in list(dict_s_to_t.values()) + list(dict_t_to_s.values()):
        if len(v) != 1:
            return 'No'
    return 'Yes'

print(c_string_transformation())

Measured memory_bytes: 4144
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    string s, t; cin>>s>>t;
    string ans;

    for(int i=0; i<n; i++){
        ans += s[i];
        ans += t[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<int>p(n);
    REP(i,n)cin>>p[i];
    int ans=0;
    if(p[0]==1){
        swap(p[0],p[1]);
        ans++;
    }
    for(int i=1;i<n;i++){
        if(p[i]==i+1){
            swap(p[i],p[i+1]);
            ans++;
        }
    }
    cout<<ans<<endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define INF 2e8
#define all(a) a.begin(), a.end()
#define maxel max_element
#define minel min_element

int main() {
  int nInput;
  scanf("%d", &nInput);
  string szInput = to_string(nInput);
  vector<int> vcInput;
  transform(all(szInput), back_inserter(vcInput),
            [](char c) { return c - 48; });
  puts(nInput % accumulate(all(vcInput), 0) ? "No" : "Yes");
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int n;
 cin >> n;
 if(n<105){
   cout << 0;
}
 else if(n<135){
   cout << 1;
}
 else if(n<165){
   cout << 2;
}
 else if(n<189){
   cout << 3;
}
 else if(n<195){
   cout << 4;
}
 else if(n<201){
   cout << 5;
}
}

Measured memory_bytes: 256
#include <iostream>

#include <cstdio>
#include <cstring>
#include <ctime>

using namespace std;

int main(){

  int n;

  cin >> n;

  int puzzle[n][9][9];
  bool cpuzzle[n][9][9];
  
  // Init flag
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 9; j++){
      for(int k = 0; k < 9; k++){
	cpuzzle[i][j][k] = false;
      }
    }
  }    

  // Loop
  for(int i = 0; i < n; i++){
    // Input
    for(int j = 0; j < 9; j++){
      for(int k = 0; k < 9; k++){
	cin >> puzzle[i][j][k];
      }
    }
    // Check
    for(int j = 0; j < 9; j++){
      for(int k = 0; k < 9; k++){
	// Check line1
	for(int l1 = 0; l1 < 9; l1++){
	  if(l1 != k){
	    if(puzzle[i][j][k] == puzzle[i][j][l1]){
	      cpuzzle[i][j][k] = true;
	    }
	  }
	}
	// Check line2
	for(int l2 = 0; l2 < 9; l2++){
	  if(l2 != j){
	    if(puzzle[i][j][k] == puzzle[i][l2][k]){
	      cpuzzle[i][j][k] = true;
	    }
	  }
	}
	// Check area
	for(int a1 = 0; a1 < 3; a1++){
	  for(int a2 = 0; a2 < 3; a2++){
	    // Area1
	    if(j >= 0 && j <= 2 && k >= 0 && k <= 2){
	      if(a1 != j && a2 != k){
		if(puzzle[i][j][k] == puzzle[i][a1][a2]){
		  cpuzzle[i][j][k] = true;
		}
	      }
	    }
	    // Area2
	    if(j >= 3 && j <= 5 && k >= 0 && k <= 2){
	      if(a1+3 != j && a2 != k){
		if(puzzle[i][j][k] == puzzle[i][a1+3][a2]){
		  cpuzzle[i][j][k] = true;
		}
	      }
	    }
	    // Area3
	    if(j >= 6 && j <= 8 && k >= 0 && k <= 2){
	      if(a1+6 != j && a2 != k){
		if(puzzle[i][j][k] == puzzle[i][a1+6][a2]){
		  cpuzzle[i][j][k] = true;
		}
	      }
	    }
	    // Area4
	    if(j >= 0 && j <= 2 && k >= 3 && k <= 5){
	      if(a1 != j && a2+3 != k){
		if(puzzle[i][j][k] == puzzle[i][a1][a2+3]){
		  cpuzzle[i][j][k] = true;
		}
	      }
	    }
	    // Area5
	    if(j >= 3 && j <= 5 && k >= 3 && k <= 5){
	      if(a1+3 != j && a2+3 != k){
		if(puzzle[i][j][k] == puzzle[i][a1+3][a2+3]){
		  cpuzzle[i][j][k] = true;
		}
	      }
	    }
	    // Area6
	    if(j >= 6 && j <= 8 && k >= 3 && k <= 5 ){
	      if(a1+6 != j && a2+3 != k){
		if(puzzle[i][j][k] == puzzle[i][a1+6][a2+3]){
		  cpuzzle[i][j][k] = true;
		}
	      }
	    }
	    // Area7
	    if(j >= 0 && j <= 2 && k >= 6 && k <= 8){
	      if(a1 != j && a2+6 != k){
		if(puzzle[i][j][k] == puzzle[i][a1][a2+6]){
		  cpuzzle[i][j][k] = true;
		}
	      }
	    }
	    // Area8
	    if(j >= 3 && j <= 5 && k >= 6 && k <= 8){
	      if(a1+3 != j && a2+6 != k){
		if(puzzle[i][j][k] == puzzle[i][a1+3][a2+6]){
		  cpuzzle[i][j][k] = true;
		}
	      }
	    }
	    // Area9
	    if(j >= 6 && j <= 8 && k >= 6 && k <= 8){
	      if(a1+6 != j && a2+6 != k){
		if(puzzle[i][j][k] == puzzle[i][a1+6][a2+6]){
		  cpuzzle[i][j][k] = true;
		}
	      }
	    }
	  }
	}
      }
    }
    // Output
    for(int j = 0; j < 9; j++){
      for(int k = 0; k < 9; k++){
	if(cpuzzle[i][j][k]){
	  cout << "*";
	} else {
	  cout << " ";
	}
	cout << puzzle[i][j][k];
      }
      cout << endl;
    }
    if(i < n-1)cout << endl;
  }
  
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i, n) cin >> x[i];

  int ans = 1e9;
  for (int i = 1; i <= 100; i++) {
    int cost = 0;
    rep(j, n) { cost += (x[j] - i) * (x[j] - i); }
    ans = min(ans, cost);
  }

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

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

using namespace std;

int main(){
    int n, m;
    while(cin >> n, n){
        vector<pair<int, int> > v;
        for(int i=0; i< n; i++){
            int h, r;
            cin >> h >> r;
            v.push_back(make_pair(h, r));
        }
        cin >> m;
        for(int i=0; i< m; i++){
            int h, r;
            cin >> h >> r;
            v.push_back(make_pair(h, r));
        }
        sort(v.begin(), v.end());
        int count = 0;
        int dp[200] = {};
        for(int i=0; i < v.size(); i++){
            for(int j=0; j < i; j++){
                if(v[j].first < v[i].first && v[j].second < v[i].second){
                    dp[i] = max(dp[i], dp[j]+1);
                }
            }
            count = max(dp[i], count);
        }
        cout << count+1 << endl;
    }
}

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

int main() {
  int H,W; cin >>H >>W;

  rep(i,0,H) {
    string C; cin >>C;
    cout <<C <<endl;
    cout <<C <<endl;
  }
  return 0;
}


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

template <typename T>
vector<T> make_vector(int sz)
{
	return vector<T>(sz);
}

template <typename T, typename... U>
auto make_vector(int sz, U... tails)
{
	return vector<decltype(make_vector<T>(tails...))>(sz, make_vector<T>(tails...));
}

template <typename T>
void fill_vector(vector<T> &v, T init)
{
	fill(v.begin(), v.end(), init);
}

template <typename T, typename U>
void fill_vector(vector<U> &vec, T init)
{
	for (auto &&v : vec)
	{
		fill_vector(v, init);
	}
}

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

	auto f = [](char c) {
		for (int i = 0; i < 3; i++)
		{
			if (c == "RGB"[i])
			{
				return i;
			}
		}
		return -1;
	};

	auto cnt = make_vector<int64_t>(3, n + 1);
	for (int64_t i = 0; i < 3; i++)
	{
		for (int64_t j = 0; j < n; j++)
		{
			cnt[i][j + 1] = cnt[i][j] + (f(s[j]) == i);
		}
	}

	int64_t ans = 0;
	for (int64_t i = 0; i < n; i++)
	{
		for (int64_t j = i + 1; j < n; j++)
		{
			if (f(s[i]) == f(s[j]))
			{
				continue;
			}

			int64_t x = 3 - (f(s[i]) ^ f(s[j]));

			ans += cnt[x][n] - cnt[x][j + 1];
			if (j + (j - i) < n && f(s[j + (j - i)]) == x)
			{
				ans--;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
	int n,m;
	cin>>n>>m;
	int a[n];
	LL total_votes = 0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		total_votes += a[i];
	}
//	sort(a,a+n);
	LL barrier = 4*m;
	int res = 0;
	for(int i=0;i<n;i++){
		if(a[i]*barrier>=total_votes) res++;
		if(res>=m) break;
	}
	if(res>=m) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun Jul  1 20:09:43 2018
ABC102B
@author: maezawa
"""

n = int(input())
a = list(map(int, input().split()))

d = 0
for i in range(n):
    for j in range(i+1, n):
        dij = abs(a[i]-a[j])
        if dij > d:
            d = dij

print(d)

Measured memory_bytes: 3060
#include <stdio.h>

int main()
{
  int i, j, minj, tmp, numdata, swapcount = 0, data[100];

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

  for(i = 0; i <= numdata - 1; i++) {
    minj = i;
    for(j = i; j <= numdata - 1; j++) {
      if(data[j] < data[minj]) {
	minj = j;
      }
    }
    tmp = data[i];
    data[i] = data[minj];
    data[minj] = tmp;
    if(data[i] != data[minj]) swapcount++;
  }

  for(i = 0; i < numdata; i++) {
    if(i) printf(" ");
    printf("%d",data[i]);
  }
  printf("\n%d\n",swapcount);

  return 0;
}



Measured memory_bytes: 2048
#include <iostream>
#include <math.h>
#include <algorithm>

using namespace std;

int main(){
  string s,t;
  int ans = 0;
  cin >> s >> t;
  for(int i=0; i<=s.size() - t.size(); i++){
    int cnt = 0;
    for(int j=0;  j<t.size();  j++){
      if(s[i+j] == t[j]) cnt++;
    }
    ans = max(ans,cnt);
  }
  cout << t.size() - ans ;
  return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int gcd(int a, int b) {  
  return b != 0 ? gcd(b, a % b) : a;
}//MAX
int lcm(int a, int b) { 
   return a * b / gcd(a, b);
   }
//MIN
 main() {
int c [3][3];
vector<int>a(3,100000),b(3,10000);
for(int i=0;i<3;i++){
  int che = 10e4;
  for(int j=0;j<3;j++){
    cin >> c[i][j];
    che = min(che,c[i][j]);
  }
  a.at(i)=che;
}
b.at(0)=c [0][0]-a.at(0);
b.at(1)=c [0][1]-a.at(0);
b.at(2)=c [0][2]-a.at(0);
  bool ans = true;
  int z = 0;
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      if(c[i][j]!=a.at(i)+b.at(j))ans = false;
    }
 }
 if(ans)cout <<"Yes"<<endl;
 else cout <<"No"<<endl;
 }
 


Measured memory_bytes: 256
#include<iostream>

using namespace std;
const int limit = 50;

 int n, m;
 int a[limit], b[limit];

 bool graph[limit][limit];
  bool visited[limit];

 void dfs(int v) {
 visited[v] = true;
 for (int v2 = 0; v2 < n; ++v2) {
 if (graph[v][v2] == false) continue;
 if (visited[v2] == true) continue;
 dfs(v2);
 }
 }

int main(void) {

 cin >> n >> m;

 for (int i = 0; i < m; ++i) {
 cin >> a[i] >> b[i];
 a[i]--, b[i]--;
 graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
 }

 int ans = 0;

 for (int i = 0; i < m; ++i) {
 graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

 for (int j = 0; j < n; ++j) visited[j] = false;

 dfs(0);

 bool bridge = false;
 for (int j = 0; j < n; ++j) if (visited[j] == false) bridge = true;
 if (bridge) ans += 1;

 graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
 }

 cout << ans << endl;

 return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int base = 0;
		int n = sc.nextInt();
		int[] b = new int[n];
		for (int i = 0; i < n; ++i) {
			b[i] = sc.nextInt();
			if (b[i] == 0)
				++base;
		}
		int Q = sc.nextInt();
		int[][] q = new int[Q][2];
		for (int i = 0; i < Q; ++i) {
			q[i][0] = sc.nextInt();
			q[i][1] = sc.nextInt();
		}
		Arrays.sort(q, new Comparator<int[]>() {
			@Override
			public int compare(int[] o1, int[] o2) {
				return Integer.compare(o1[0], o2[0]);
			}
		});
		RMQ rmq = new RMQ(n + 1);
		rmq.set(0, 0);
		int p = 0;
		for (int i = 0; i < Q; ++i) {
			while (q[i][0] - p > 1) {
				int c = b[p] == 1 ? 1 : -1;
				rmq.set(p + 1, Math.min(c + rmq.query(p, p + 1), rmq.query(p + 1, p + 2)));
				++p;
			}
			rmq.set(q[i][1], rmq.query(p, q[i][1] + 1));
		}
		while (n - p > 0) {
			int c = b[p] == 1 ? 1 : -1;
			rmq.set(p + 1, Math.min(c + rmq.query(p, p + 1), rmq.query(p + 1, p + 2)));
			++p;
		}
		System.out.println(base + rmq.query(n, n + 1));
	}

	class RMQ {
		int n;
		int[] v;

		public RMQ(int n_) {
			n = 1;
			while (n < n_)
				n *= 2;
			v = new int[2 * n - 1];
			Arrays.fill(v, Integer.MAX_VALUE / 3);
		}

		void add(int k, int val) {
			k += n - 1;
			v[k] += val;
			while (k > 0) {
				k = (k - 1) / 2;
				v[k] = Math.min(v[2 * k + 1], v[2 * k + 2]);
			}
		}

		void set(int k, int val) {
			k += n - 1;
			v[k] = val;
			while (k > 0) {
				k = (k - 1) / 2;
				v[k] = Math.min(v[2 * k + 1], v[2 * k + 2]);
			}
		}

		int query(int a, int b) {
			return query(a, b, 0, n, 0);
		}

		int query(int a, int b, int l, int r, int k) {
			if (r <= a || b <= l)
				return Integer.MAX_VALUE / 3;
			else if (a <= l && r <= b)
				return v[k];
			else
				return Math.min(query(a, b, l, (l + r) / 2, 2 * k + 1), query(a, b, (l + r) / 2, r, 2 * k + 2));
		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 163024
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

uint_fast32_t scan(){
    uint_fast32_t a{};
    int c;
    while((c=getchar_unlocked()-'0')>=0) a*=10,a+=c;
    return a;
}

uint_fast64_t scan64(){
    uint_fast64_t a{};
    int c;
    while((c=getchar_unlocked()-'0')>=0) a*=10,a+=c;
    return a;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n;
    ll k;
    n=scan();k=scan64();
    vector<int> a(n),f(n);
    for(auto&i:a) i=scan();
    for(auto&i:f) i=scan();
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    sort(f.begin(),f.end());
    ll l=-1,r=1e18,m;
    while(r-l>1){
        m=(l+r)>>1;
        ll s=0;
        fr(i,n) if(a[i]>m/f[i]) s+=a[i]-m/f[i];
        if(s>k) l=m;
        else r=m;
    }
    cout<<r<<endl;
}


Measured memory_bytes: 1792
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		pr.printf("%d %d%n", Math.min(a, b), Math.max(0, a + b - n));
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21204
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;

int a,b;

int main()
{
	cin>>a>>b;
	if (a>9||b>9) cout<<"-1";
	else
	{
		cout<<a*b;
	}
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
import sys

def tree_path_dict():
    sys.setrecursionlimit(100000)
    n = int(input())
    edge = defaultdict(lambda: defaultdict(lambda: float("inf")))

    for _ in range(n - 1):
        u, v, w = map(int, input().split())
        edge[u][v] = w
        edge[v][u] = w

    d = [-1] * (n + 1)

    def walk(i, c):
        if d[i] == -1:
            d[i] = c
            for node, dist in edge[i].items():
                walk(node, c + dist)

    walk(1, 0)
    for i in d[1:]:
        print(i % 2)

        
tree_path_dict()

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

using LL = long long;
const LL INF = 1e18;

int W, H;
vector<vector<LL>> S;

LL score(int i, int j) {
  auto L = S[i+1][j] - S[i+1][0];
  auto R = S[i+1][W] - S[i+1][j];
  return ((i + j) & 1) ? L - R : R - L ;
}

LL dfs(int i, int j) {
  static vector<vector<LL>> memo(H + 1, vector<LL>(W + 1, INF));
  if(memo[i][j] != INF) return memo[i][j];
  if(i == H) return memo[i][j] = 0;
  if(j == W) return memo[i][j] = score(i, j) - dfs(i + 1, j);
  return memo[i][j] = max(-dfs(i, j + 1), score(i, j) - dfs(i + 1, j));
}

int main() {
  cin >> W >> H;
  S.assign(H + 1, vector<LL>(W + 1));
  for(auto i = 1; i <= H; ++i) for(auto j = 1; j <= W; ++j) cin >> S[i][j], S[i][j] += S[i][j - 1];
  cout << abs(dfs(0, 0)) << endl;
}

Measured memory_bytes: 18660
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if ((a + b) % 2 == 0) {
            System.out.println((a + b) / 2);
        } else {
            System.out.println("IMPOSSIBLE");
        }
        sc.close();
    }
}

Measured memory_bytes: 23124
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define reads(s) string s; cin >> s;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define setprec(x) cout << fixed << setprecision(x)
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 

     
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    //start from here

    readc(n, m, x);

    int c[n + 1], a[n + 1][m + 1];

    fori (i, 1, n)
    {
    	cin >> c[i];
    	fori (j, 1, m) cin >> a[i][j];
    }

    int mn = INF;

    for (int i = 0; i < (1 << n); i++)
    {
    	int skill[m+1] = {}, cost = 0;

    	fori (j, 0, n-1)
    	{
    		if(i & (1 << j))
    		{
    			cost += c[j+1];
    			fori (k, 1, m) skill[k] += a[j+1][k];
    		}
    	}

    	bool flag = true;
    	fori (k, 1, m) if(skill[k] < x) flag = false;

    	if(flag) mn = min(mn, cost);
    }

    if(mn == INF) cout << -1;
    else cout << mn;

    return 0;
}


Measured memory_bytes: 3656
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	s := getNextString(scanner)
	n := len(s)
	dp := make([][13]int, n+1)

	dp[0][0] = 1

	mod := int(1e9 + 7)
	mm := [6]int{
		1, 10, 9, 12, 3, 4,
	}

	di := n - 1

	var md [6][10]int
	for i := 0; i < 6; i++ {
		for ii := 0; ii < 10; ii++ {
			md[i][ii] = (mm[i] * ii) % 13
		}
	}

	for i := 0; i < n; i++ {
		for iii := 0; iii < 13; iii++ {
			if s[i] == '?' {
				for iiii := 0; iiii <= 9; iiii++ {
					m := (md[di%6][iiii] + iii) % 13
					dp[i+1][m] = (dp[i+1][m] + dp[i][iii]) % mod
				}

				continue
			}
			m := (md[di%6][int(s[i]-'0')] + iii) % 13
			dp[i+1][m] = (dp[i+1][m] + dp[i][iii]) % mod
		}
		di--
	}
	fmt.Fprintln(writer, dp[n][5])
	writer.Flush()
}


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

int main(void) {
    vector<char> color(101);
    for (size_t i = 0; i < 3; i++)
    {
        int IN;
        cin >> IN;
        color[IN]++;
    }

    int count = 0;
    for (char ex : color) {
        if (ex) count++;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int n,p,x,Gcd,a[N];
int main(){
	scanf("%d%d",&n,&p);
	for (int i=1;i<=n;i++)scanf("%d",&a[i]),Gcd=__gcd(Gcd,a[i]);
	sort(a+1,a+n+1);
	if (p%Gcd!=0||p>a[n]){
		puts("IMPOSSIBLE");
		return 0;
	}
	if (n==1&&a[1]!=p){
		puts("IMPOSSIBLE");
		return 0;
	}
	puts("POSSIBLE");
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
    int a, b;
    string date[7] = { "Wednesday", "Thursday", "Friday", "Saturday",
        "Sunday", "Monday", "Tuesday",};
    int day[12] = {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335};

    cin >> a >> b;

    while (a != 0 && b != 0) {
        b += day[a-1];
        cout << date[b%7] << endl;
        cin >> a >> b;
    }

    return 0;
}

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

#define N 100
#define INFF 100.0

double f(int x1, int y1, int x2, int y2, int X1, int Y1, int X2, int Y2) {
	if( (Y1-Y2)*(x1-x2)==(X1-X2)*(y1-y2) ) return INFF;
	return (double)( (X1-X2)*(y2-Y2)-(Y1-Y2)*(x2-X2) )/(double)( (Y1-Y2)*(x1-x2)-(X1-X2)*(y1-y2) );
}

int main() {
	int nn, n, xa, ya, xb, yb, p, ans;
	int xs, ys, xt, yt, o, l;
	map<double, int> tl; double t1, t2;
	map<double, int>::iterator it;
	cin >> nn;
	for(int q=0; q<nn; ++q) {
		cin >> xa >> ya >> xb >> yb >> n;
		tl.clear(); ans = 0;
		for(int i=0; i<n; ++i) {
			cin >> xs >> ys >> xt >> yt >> o >> l;
			t1 = f(xa, ya, xb, yb, xs, ys, xt, yt);
			t2 = f(xs, ys, xt, yt, xa, ya, xb, yb);
			if(0.000000<=t1&&t1<=1.000000&&0.000000<=t2&&t2<=1.000000) {
				tl[t1] = (o==1?l:1-l);
			}
		}
		if(tl.size()>1) {
			it = tl.begin(); p = (*it).second;
			for(++it; it!=tl.end(); ++it) {
				if((*it).second!=p) {
					ans++; p = (*it).second;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

macro_rules! echo {
    ($($e:expr),+) => ( { $(println!("{}", $e))+ } );
}

fn main() {
    input! {
        n: usize,
        k: usize,
    }

    let mut all = vec![false; n];

    for _ in 0..k {
        input! {
            d: usize,
            ts: [Usize1; d],
        }

        for t in ts {
            all[t] = true;
        }
    }

    let mut result = 0;
    for e in all {
        if e {
            continue;
        }

        result += 1;
    }

    echo!(result);
}


Measured memory_bytes: 2176
/*

	Code Author : ACID RAIN

*/
#include<bits/stdc++.h> 
using namespace std;
 
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<bool> vb;
typedef std::vector<string> vs;
typedef std::vector<double> vd;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<int> > vvi;
typedef vector<vvi> vvvi;
typedef vector<vll> vvll;
typedef std::vector<std::pair<int, int> > vpi;
typedef vector<vpi> vvpi;
typedef std::pair<int, int> pi;
typedef std::pair<ll, ll> pll;
typedef std::vector<pll> vpll;
 
const long long mod = 1000000007;
const int inf = 1e9 + 5;
const int nax = 1005;
  
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define forn(i, a, b) for(int i = a; i < b; i++)
#define ABS(a)		((a)>0?(a):-(a)) 
#define pb push_back
#define mp make_pair


string n;
long long ans =0;
void fun(string n,int idx,int sum)
{
	if(idx>=n.size())
	{
		return;
	}
	long long temp = 0;
	for(int i=idx;i<n.size();i++)
	{
		temp = temp*10 + n[i] - '0';
		fun(n, i+1 , sum + temp);
	}
	ans += sum + temp;
}




int main() {
	string n;
	cin>>n;
	fun(n,0,0);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256