akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;

P calc(P a,P b,P c,P d){
  a-=d;b-=d;c-=d;
  double A=imag(a/c),B=imag(b/c);
  return d+a+(b-a)*A/(A-B);
}

int main(){
  int n;
  double ax,ay,bx,by,cx,cy,dx,dy;
  scanf("%d",&n);
  while(n--){
    scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&ax,&ay,&bx,&by,&cx,&cy,&dx,&dy);
    P ans=calc(P(ax,ay),P(bx,by),P(cx,cy),P(dx,dy));
    printf("%.8f %.8f\n",ans.real(),ans.imag());
  }
  return 0;
}

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

// a^nを計算　O(log n)
long long int powint(long long int a, long long int n) {
    if (n == 0) {
        return 1;
    } else {
        long long int temp = powint(a, n / 2);
        if (n % 2 == 0) {
            return temp * temp;
        } else {
            return temp * temp * a;
        }
    }
}

//小数部の長さ
//小数じゃないなら-1
int decimal_length(string& s) {
    int n = s.length();
    int res = -1;
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == '.') {
            res = n - 1 - i;
            break;
        }
    }
    return res;
}

lint num(string s) {
    int decimal_len = decimal_length(s);
    if (decimal_len == -1) {
        return stoll(s);
    } else {
        int n = s.length();
        s.erase(n - 1 - decimal_len, 1);
        return stoll(s);
    }
}
lint den(string s) {
    int decimal_len = decimal_length(s);
    if (decimal_len == -1) {
        return 1;
    } else {
        return powint(10, decimal_len);
    }
}

//分数にする
//分子、分母
pair<lint, lint> quotient(string s) {
    lint d = den(s);
    lint n = num(s);
    return {n, d};
}

// xのpの指数
int val(lint x, lint p) {
    int res = 0;
    while (x % p == 0) {
        x /= p;
        res++;
    }
    return res;
}

// 2,5のindex
pair<int, int> indice(string s) {
    auto q = quotient(s);
    lint num = q.first;
    lint den = q.second;
    int index_2 = val(num, 2) - val(den, 2);
    int index_5 = val(num, 5) - val(den, 5);
    return {index_2, index_5};
}

//二次元累積和
struct cumulative_sum_2d {
    using lint = long long int;
    int sz;
    vector<vector<lint>> data;
    vector<vector<lint>> sum;
    cumulative_sum_2d(const int _sz) : sz(_sz) {
        data.assign(sz, vector<lint>(sz));
        sum.assign(sz + 1, vector<lint>(sz + 1));
    }
    vector<lint>& operator[](const int k) {
        return data[k];
    }
    void build() {
        for (int i = 0; i < sz; i++)
            for (int j = 0; j < sz; j++)
                sum[i + 1][j + 1] = sum[i + 1][j] + sum[i][j + 1] - sum[i][j] + data[i][j];
    }
    //[a,b)×[c,d)の和を計算
    lint query(const int a, const int b, const int c, const int d) const {
        return sum[b][d] - sum[b][c] - sum[a][d] + sum[a][c];
    }
};

const int offset = 100;

int main() {
    int n;
    cin >> n;
    vector<string> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<pair<lint, lint>> indices(n);
    for (int i = 0; i < n; i++) {
        indices[i] = indice(a[i]);
    }
    cumulative_sum_2d cum(offset * 2);
    for (int i = 0; i < n; i++) {
        cum[indices[i].first + offset][indices[i].second + offset]++;
    }
    cum.build();
    lint ans = 0;
    //おおまかに
    for (int i = 0; i < n; i++) {
        int index_2 = indices[i].first;
        int index_5 = indices[i].second;
        ans += cum.query(offset - index_2, offset * 2, offset - index_5, offset * 2);
    }
    //自身とのパターンを引く
    for (int i = 0; i < n; i++) {
        if (indices[i].first >= 0 && indices[i].second >= 0) {
            ans--;
        }
    }
    ans /= 2;
    cout << ans << endl;
}

Measured memory_bytes: 13264
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	string s;
	cin >> s;
	set<char> num = { '0' , '1' , '2' , '3' , '4' , '5','6' , '7' , '8' , '9' };
	if (s.length() != a + b + 1) {
		cout << "No" << endl;
		return 0;
	}
	for (int i = 0; i < a; i++) {
		if (!num.count(s.at(i))) {
			cout << "No" << endl;
			return 0;
		}
	}
	if (s.at(a) != '-') {
		cout << "No" << endl;
		return 0;
	}
	for (int i = 0; i < b; i++) {
		if (!num.count(s.at(a+1+i))) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    int counter=0;
    string s;
    std::cin >> s;
    for(;;){
        string ss;
        std::cin >> ss;
        if(ss=="END_OF_TEXT")break;
        rep(i,ss.size()){
            if(ss[i]-'A'<=25&&ss[i]-'A'>=0)ss[i]+=32;
        }
        
        if(ss==s)counter++;
    }
    std::cout << counter << std::endl;
}


Measured memory_bytes: 3208
#include <iostream>
#include <vector>

using namespace std;

int main(){
  int N,T;
  cin >> N >> T;
  vector<int> c(N);
  vector<int> t(N);
  for(int i = 0; i < N; i++){
  cin >> c[i] >> t[i];
  }
  int minc = 10000;
  for(int i = 0; i < N; i++){
    if(minc > c[i]){
      if(t[i] > T) continue;
      else minc = c[i];
    }
  }
  if(minc < 10000){
  cout << minc;
  }else{
  cout << "TLE";
  }
}


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

typedef long long ll;

int n, m, q;
int a[55], b[55], c[55], d[55], ans = 0;

void go(vector<int> A) {
    if(A.size() == n) {
        int cur = 0;

        for(int i = 0; i < q; i++) {
            if(A[b[i]] - A[a[i]] == c[i]) cur += d[i];
        }

        ans = max(ans, cur);

        return;
    }

    for(int i = A.back(); i <= m; i++) {
        A.push_back(i);

        go(A);

        A.pop_back();
    }
}

int main() {
    ios_base::sync_with_stdio(false);

    cin >> n >> m >> q;

    for(int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--;
    }

    for(int i = 1; i <= m; i++) {
        go({i});
    }

    cout << ans << endl;
}


Measured memory_bytes: 3604
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define ET cout << "\n"
#define MEM(i,j) memset(i,j,sizeof i)
#define ALL(v) v.begin(),v.end()
#define DB(a,s,e) {for(int i=s;i<e;++i) cerr << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

string s;

int main()
{jizz
	int n,k;
	cin >> n >> s >> k;
	for(auto &c:s)
		if(c!=s[k-1])
			c='*';
	cout << s << "\n";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, int num=0){
  if(num == 0) num = (int)v.size();
  if(is_reverse) for(int i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<" ";}
  else for(int i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<" ";}
  cout << endl;
}

template <typename T>
void print_pairvec(const vector<T> &v, int num=0){
  if(num == 0) num = (int)v.size();
  cout << endl;
  for(int i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
}


template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

int main(){
	int N;
	cin >> N;
	const int DAYS = 10;
	vector<vector<int>> F(N, vector<int>(DAYS));
	for(int i=0; i<N; i++){
		for(int j=0; j<DAYS; j++) cin >> F[i][j];
	}

	vector<vector<ll>> P(N, vector<ll>(DAYS+1));
	for(int i=0; i<N; i++){
		for(int j=0; j<DAYS+1; j++) cin >> P[i][j];
	}


	//bit全探索
	const ll INF = 10e18;
	ll ans = -INF;
	for(int i=0; i<(1<<DAYS); i++){ 
		bitset<10> bit(i);		//開ける日を1とする
		if(bit.count() == 0) continue;// 店は一回以上開かないといけない
		
		vector<int> num(N, 0);// num[i]: 店iと 自分の店が営業する日数
		for(int j=0; j<DAYS; j++){			
			if(bit[j]){  	// 自分の店を開けるなら
				for(int shop=0; shop<N; shop++){
					if(F[shop][j]) num[shop]++;
				}
			}
		}
		// cout << "  num: "; print_vec(num);
		ll yen = 0;
		for(int shop=0; shop<N; shop++){
			yen += P[shop][num[shop]];
		}
		
		ans = max(ans, yen);
	}
	

	cout << ans << endl;
	
}



Measured memory_bytes: 3588
# ABC075B - Minesweeper
import sys
input = sys.stdin.readline

def check_neighbors(i: int, j: int) -> int:
    # count the number of landmines adjacent to S[i][j]
    ret = 0
    for x, y in neighbors:
        a, b = i + x, j + y
        if 0 <= a < H and 0 <= b < W:
            ret += 1 if S[a][b] == "#" else 0
    return ret


def main():
    global H, W, S, neighbors
    H, W = tuple(map(int, input().split()))
    S = tuple(input().rstrip() for _ in range(H))
    neighbors = [(-1, -1), (-1, 0), (-1, 1), (0, -1)]
    neighbors += [(0, 1), (1, -1), (1, 0), (1, 1)]
    A = [""] * H
    for i, s in enumerate(S):
        for j, a in enumerate(s):
            if a == "#":
                A[i] += "#"
            else:
                cnt = check_neighbors(i, j)
                A[i] += str(cnt)
    print(*A, sep="\n")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

mod = 10**9+7

n = int(input())
g = [[] for _ in range(n)]

pow2 = [0 for _ in range(n+1)]
pow2[0] = 1
for i in range(n):
    pow2[i+1] = pow2[i]*2 %mod

for _ in range(n-1):
    a,b = map(int, input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

depth = [-1]*n
ko_all = [0 for _ in range(n)]
ko_only =[0 for _ in range(n)]

def dfs(v,d):
    depth[v] = d
    for w in g[v]:
        if depth[w] == -1:
            dfs(w,d+1)
            ko_all[v] += ko_all[w]+1
            ko_only[v] += pow2[ko_all[w]+1]-1

dfs(0,0)

cnt = 0

for i in range(n):
    tmp = pow2[n-1]-1-(pow2[n-1-ko_all[i]]-1) - ko_only[i]
    tmp %=mod
    cnt += tmp
    cnt %= mod

def inv(a,mod):
    r = [1,0,a]
    w = [0,1,mod]
    while w[2]!=1:
        q = r[2]//w[2]
        r_new = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = w
        w = r_new
    x,y = w[0],w[1]    # a*x+y*mod = 1
    return (mod+x%mod)%mod

print(inv(pow2[n],mod)*cnt %mod)


Measured memory_bytes: 184256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

ll M, K;
int main(){
  cin >> M >> K;
  ll N = ll(pow(2, M));
  if(N <= K) {
    cout << -1 << endl;
    return 0;
  }
  if(M == 1 && K == 1) {
    cout << -1 << endl;
    return 0;
  }
  if(M == 1 && K == 0) {
    cout << "1 0 0 1" << endl;
    return 0;
  }

  REP(i, N) {
    if(i == K) continue;
    cout << i << " ";
  }
  cout << K  << " ";
  RREP(i, N) {
    if(i == K) continue;
    cout << i << " ";
  }
  cout << K << endl;

  return 0;
}


Measured memory_bytes: 1792
def examA():
    S = SI()
    ans = "Good"
    for i in range(len(S)-1):
        if S[i+1]==S[i]:
            ans = "Bad"
    print(ans)
    return

def examB():
    N, L = LI()
    ans = 0
    if L>=0:
        for i in range(N - 1):
            ans += (L + i + 1)
    else:
        for i in range(N):
            ans += (L+i)
        if L+N-1<0:
            ans -=(L+N-1)
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examB()


Measured memory_bytes: 38384
package main

import "fmt"

func main() {
	var n, k int
	var r, s, p int
	var T string
	fmt.Scan(&n, &k)
	fmt.Scan(&r, &s, &p)
	fmt.Scan(&T)

	dp := make([][]int, 3)
	for i := 0; i < 3; i++ {
		dp[i] = make([]int, n)
	}

	sum := 0
	for i := 0; i < k; i++ {
		var last int
		for j := i; j < n; j += k {
			// score
			if i != j {
				dp[0][j] = max(dp[1][j-k], dp[2][j-k])
				dp[1][j] = max(dp[2][j-k], dp[0][j-k])
				dp[2][j] = max(dp[0][j-k], dp[1][j-k])
			}
			switch T[j] {
			case 'r':
				dp[2][j] += p
			case 's':
				dp[0][j] += r
			case 'p':
				dp[1][j] += s
			}
			last = j
		}
		sum += max(dp[0][last], max(dp[1][last], dp[2][last]))
	}
	fmt.Println(sum)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);



int main()
{
    fastInp;
    
    vector<ll> pw;
    pw.push_back(1);
    for (int i = 0; i < 13; i++) pw.push_back(pw.back() * 10);
    
    ll d;
    ll k;
    cin >> d >> k;
    vector<bool> bad(10);
    for (int i = 0; i < k; i++) {
        ll a;
        cin >> a;
        bad[a] = 1;
    }

    for (int i = 0; i < d * 100; i++) {
        string s = to_string(i);
        bool flag = false;
        for (auto cur : s) {
            if (bad[cur - '0']) flag = true;
        }

        if (!flag && i >= d) {
            cout << i;
            return 0;
        }
    }
    return 0;
}

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

using namespace std;

#define ll long long

int main(){
    int n;
    cin >> n;
    if (n % 1000 == 0){
        cout << 0;
    }
    else if (n % 1000 > 0){
        cout << 1000 - (n % 1000);
    }
}

Measured memory_bytes: 3608
from math import ceil
h,w=map(int,input().split())

word={}
A=[list(input()) for _ in range(h)]
for i in A:
    for j in i:
        if j not in word:word[j]=1
        else:word[j] +=1

D=[0]*5
if h%2==0 and w%2==0:
    D[4]=(h*w)//4
elif (h%2==0 and w%2==1) or (h%2==1 and w%2==0):
    if h%2==1:
        D[2]=w//2
        D[4]=w*(h-1)//4
    else:
        D[2]=h//2
        D[4]=h*(w-1)//4
else:
    D[2]=(h+w-2)//2
    D[4]=(h-1)*(w-1)//4
    D[1]=1

P=[0]*5
for i in word.values():
    P[4] +=i//4;i %=4
    P[2] +=i//2;i %=2
    P[1] +=i

for i in (4,2,1):
    if D[i]==P[i]:continue
    elif D[i]<P[i]:
        P[i//2] +=(P[i]-D[i])*2
    else:print("No");exit()
print("Yes" if P[0]==0 else "No")

Measured memory_bytes: 39152
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#define ri register int
 
using namespace std;
 
const int mx = 10000007;
 
typedef long long lo;
 
inline char gch()
{
    static char buf[100010], *h = buf, *t = buf;
    return h == t && ((t = (h = buf) + fread(buf, 1, 100000, stdin), t == h)) ? EOF : *h ++;
}
 
inline void re(int &x)
{
    x = 0;
    char a = gch(); bool b = 0;
    while(a < '0' || a > '9')
    {
        if(a == '-')
            b = 1;
        a = gch();
    }
    while(a >= '0' && a <= '9')
        x = (x << 3) + (x << 1) + a - '0', a = gch();
    if(b == 1)
        x *= -1;
}
 
int n, tot = -1, de[500], ans, ret, head[500], q[100010], ta, he;
 
struct in
{
	int x, y;
}r[110], b[110]; 
 
struct es
{
	int to, ne, co;
}ter[30030];
 
inline void build(int f, int l, int c)
{
	ter[++ tot] = (es){l, head[f], c}, head[f] = tot;
	ter[++ tot] = (es){f, head[l], 0}, head[l] = tot;
}
 
inline bool bfs()
{
	ta = he = 1;
	memset(de, 0, sizeof(de));
	de[0] = 1, q[he] = 0;
	while(he <= ta)
	{
		int qaq = q[he ++];
		for(ri i = head[qaq]; i != -1; i = ter[i].ne)
		{
			int to = ter[i].to;
			if(ter[i].co && !de[to])
				de[to] = de[qaq] + 1, q[++ ta] = to;
		}
	}
	return ((de[300] > 0) ? 1 : 0);
}
 
int dfs(int no, int fl)
{
	if(no == 300)
		return fl;
	for(ri i = head[no]; i != -1; i = ter[i].ne)
	{
		int to = ter[i].to;
		if(de[to] == de[no] + 1 && ter[i].co > 0)
		{
			int re = dfs(to, min(fl, ter[i].co));
			if(re > 0)
			{
				ter[i].co -= re, ter[i ^ 1].co += re; return re;
			}
		}
	}
	return 0;
}
 
int main()
{
	memset(head, -1, sizeof(head));
	re(n);
	for(ri i = 1; i <= n; i ++)
		re(r[i].x), re(r[i].y), build(0, i, 1);
	for(ri i = 1; i <= n; i ++)
		re(b[i].x), re(b[i].y), build(i + n, 300, 1);
	for(ri i = 1; i <= n; i ++)
		for(ri j = 1; j <= n; j ++)
			if(r[i].x < b[j].x && r[i].y < b[j].y)
				build(i, j + n, 1);
	while(bfs())
		while(ret = dfs(0, 1000000007))
			ans += ret;
	printf("%d", ans); 
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
	int N,d[50];
	long sum=0;
	cin >> N;
	for(int i=0;i<N;i++)cin >> d[i];
	for(int i=0;i<N-1;i++){
		for(int j=i+1;j<N;j++){
			sum+=d[i]*d[j];
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
//libraries
#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>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//define
#define inp(X) cin>>X;
#define inp_long(X) long long X; cin>>X;
#define inp_arr(A,N) long long A[N]; for(long long int i=0;i<N;i++) {cin>>A[i];}
#define sz(A) A.size()
#define pb push_back
#define pf push_front
#define fi first
#define se second
//#define endl '\n'
#define vect(A) vector<long long> A;
#define inp_vect(A,N); vect(A);for(long long i=0;i<N;i++){long long q; cin>>q; A.push_back(q);}
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define forde(i,a,b) for(long long i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);

ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2) % MOD;
    p = (p * p) % MOD;

    return (y%2 == 0)? p : (x * p) % MOD;
}
ll modInverse(ll a)
{
   return power(a,MOD-2);
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 

//ll z[1000001]={0};

int main()
{
    /*
    #ifndef ONLINE_JUDGE
       freopen ("input.txt" , "r" , stdin);
		// freopen ("OUTPUT.txt" , "w" , stdout);
	#endif
    */
    fio;
    ll a,b;
    cin>>a>>b;
    ll c=a^b;
    cout<<c<<endl;
}

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

int main()
{
	int n, k;
	cin >> n >> k;
	auto x = vector<long long int>(n);
	int p = -1;
	for(auto& y : x) cin >> y;
	long long int ans = 1LL << 60;
	for(auto i = 0; i < n - k + 1; ++i){
		if(x[i + k - 1] <= 0){
			ans = min(ans, -x[i]);
		}else if(x[i] >= 0){
			ans = min(ans, x[i + k - 1]);
		}else{
			ans = min({ans, x[i + k - 1] * 2 - x[i], x[i + k - 1] - x[i] * 2});
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
import collections
n = int(input())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

c = collections.Counter(prime_factorize(n))
ans = 0
for v in c.values():
    prev = 1
    while v >= prev:
        v -= prev
        prev += 1
        ans += 1
    
    
    
print(ans)

Measured memory_bytes: 9460
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		 switch (a) {
	        case 3:
	            System.out.println("YES");
	            break;
	        case 5:
	            System.out.println("YES");
	            break;
	        case 7:
	            System.out.println("YES");
	            break;
	        default:
	        	System.out.println("NO");
	        	break;
	        }
	}
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];

    ll ans = 0;
    for (int j = 0; j < 30; j++) {
        vector<int> c(b);
        ll cnt = 0;
        int mask = (1 << j);
        int mod = (1 << (j + 1));
        for (int i = 0; i < n; i++) {
            c[i] %= mod;
        }
        sort(c.begin(), c.end());
        for (int i = 0; i < n; i++) {
            int tar = a[i] % mod;
            if (tar & mask) {
                cnt += lower_bound(c.begin(), c.end(), mask - tar % mask) - c.begin();
                cnt += c.end() - lower_bound(c.begin(), c.end(), mod - tar % mask);
            } else {
                cnt += lower_bound(c.begin(), c.end(), mod - tar % mask) - lower_bound(c.begin(), c.end(), mask - tar % mask);
            }
        }
        if (cnt & 1) ans |= mask;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2672
#include <algorithm>
#include <iostream>
#include <vector>
#include <utility>
#include <climits>
#include <cassert>

using std::max;
using std::vector;
using std::pair;

int N = 100000;

vector<int> tree(N*4, INT_MAX);

int gcd(int smaller, int larger)
{
  if (smaller > larger) {
    return gcd(larger, smaller);
  }
  if (larger == INT_MAX) {
    return smaller;
  }
  if (smaller == 0) {
    return larger;
  }
  return gcd(larger % smaller, smaller);
}

void fill_segtree(int root)
{
  if (tree.at(root*2) == 0) {
    fill_segtree(root*2);
  }
  if (tree.at(root*2+1) == 0) {
    fill_segtree(root*2+1);
  }
  tree.at(root) = gcd(tree.at(root*2), tree.at(root*2+1));
}

bool has_target(int root, int target)
{
  while (0 < target) {
    if (root == target) {
      return true;
    }
    target /= 2;
  }
  return false;
}

int calc_gcd(int n, int target, int root)
{
  if (root == target) {
    return INT_MAX;
  } else if (has_target(root, target)) {
    return gcd(calc_gcd(n, target, root*2), calc_gcd(n, target, root*2+1));
  } else {
    return tree.at(root);
  }
}

int main()
{
  int n;
  std::cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    std::cin >> v.at(i);
  }
  for (int i = 0; i < n; i++) {
    tree.at(i) = 0;
  }
  for (int i = n; i < n*2; i++) {
    tree.at(i) = v.at(i-n);
  }
  fill_segtree(1);
  assert(tree.at(0) == 0);
  assert(tree.at(1) != 0);
  int res = 1;
  for (int i = 0; i < n; i++) {
    res = max(res, calc_gcd(n, n+i, 1));
  }
  std::cout << res << '\n';
  return 0;
}


Measured memory_bytes: 2176
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  int n,k,h,ans1,ans;
  ans1=0;
  vector<int> a;
  vector<int> b(200002,0); 
  scanf("%d%d",&n,&k);
  for(int i=0;i<n;i++)
    {
      cin>>h;
      a.push_back(h);
      b[a[i]]++;
    }
  sort(b.begin(),b.end(),greater<int>());
  for(int i=0;i<k;i++)
    {
      ans1=ans1+b[i];
    }
  ans=n-ans1;
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 2168
N = int(input()) 
S = input() 
 
#.......######
# a[n] = n個目より左にある#の数
# b[n] = n個目より右にある.の数
 
a = [0] * (N+2)
b = [0] * (N+2)
 
cnt = 2
for x in S:
    if x == "#":
        a[cnt] = a[cnt-1] + 1
    else:
        a[cnt] = a[cnt-1] 
    cnt += 1
 
cnt =N
Sinv = S[::-1]
for x in Sinv:
    if x == ".":
        b[cnt] = b[cnt+1] + 1
    else:
        b[cnt] = b[cnt+1] 
    cnt -= 1
 
 
 
c = []
 
for index in range(N+2):
    c.append(a[index] + b[index])
c[0] = 999999
 
print(min(c))


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



int n;
string s;
vector<int> ind[26];



struct BIT {
    vector<ll> t;
    int n;
    int init_calls=0;
    BIT() { init_calls = 0; }
    void init(int n) {
	assert( ++init_calls == 1);
	this->n = n;
	t.resize(n+10);
    }
    void clear() {
	init_calls = 0;
	n = 0;
	t.clear();
    }
    ll get(int i) {
	ll res = 0;
	while (i>0) {
	    res += t[i];
	    i-=i&-i;
	}
	return res;
    }
    void update(int i, ll dx) {
	while (i<=n) {
	    t[i] += dx;
	    i+=i&-i;
	}
    }
};

BIT bit;

//0-indexed rangeQuery
ll rangeQuery(int l, int r) {
    if (l>r) return 0;
    return bit.get(r + 1) - bit.get(l-1 + 1);
}

//0-indexed update
void update(int i, ll dx) {
    bit.update(i+1, dx);
}


int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>s;
    n = s.length();

    bit.init(n+10);
    

    for (int i=0; i<n; i++) {
	ind[s[i]-'a'].push_back(i);
    }

    int odd=-1;
    for (int i=0; i<26; i++) {
	if (int(ind[i].size())%2) {
	    if (odd!=-1) out(-1);
	    odd = i;
	}
    }

    ll ans = 0;

    if (odd != -1) {
	int mid = ind[odd][int(ind[odd].size()) / 2];
	for (int c=0; c<26; c++) {
	    int len = ind[c].size();
	    for (int i=0; i<len/2; i++) {
		int a = ind[c][i];
		int b = ind[c][len-i-1];
		if (a > mid) ans++;
		if (b < mid) ans++;
	    }
	}
    }

    vector<pair<int,int>> ev;
    for (int c=0; c<26; c++) {
	int len = ind[c].size();
	for (int i=0; i<len/2; i++) {
	    int a = ind[c][i];
	    int b = ind[c][len-i-1];
	    ev.push_back({a,b});
	}
    }


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

    for (auto p: ev) {
	int l = p.first; int r = p.second;
	ans += 2LL*rangeQuery(0, l);
	//previous r_elems on the way to the right will pass l and r.
	//passing l is obvious because r_elem needs to get to the right of l
	//passing r will occur because our r is more left than r_elem.

	ans += rangeQuery(l+1, r);
	//r_elem will only pass r.

	update(r, +1);	
    }



    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 4620
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll> 
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

ll n,A,B,C,inf=1e9;
vector<ll> bmb(n);

ll dfs(ll x,ll a,ll b,ll c) {
  if(x==n) {
    if(min({a,b,c})>0) return abs(A-a)+abs(B-b)+abs(C-c)-30;
    else return inf;
  }
  ll ret0=dfs(x+1,a,b,c);
  ll ret1=dfs(x+1,a+bmb[x],b,c)+10;
  ll ret2=dfs(x+1,a,b+bmb[x],c)+10;
  ll ret3=dfs(x+1,a,b,c+bmb[x])+10;
  return min({ret0,ret1,ret2,ret3});
}


int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin>>n>>A>>B>>C;
  bmb.resize(n);rep(i,n) cin>>bmb[i];
  print(dfs(0,0,0,0));
  return 0;
}

Measured memory_bytes: 256
package main

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

var (
	scanner = bufio.NewScanner(os.Stdin)
	w       = bufio.NewWriter(os.Stdout)
)

func readInt() (read int) {
	scanner.Scan()
	read, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return
}

func Max(x, y, z int) int {
	if x > y && x > z {
		return x
	} else if y > x && y > z {
		return y
	}
	return z
}

func main() {
	scanner.Split(bufio.ScanWords)
	defer w.Flush()

	n := readInt()

	l := make([]int, n)

	for i := 0; i < n; i++ {
		l[i] = readInt()
	}

	ans := 0

	for i := 0; i < n; i++ {
		for j := i; j < n; j++ {
			for k := j; k < n; k++ {
				if l[i] == l[j] {
					continue
				}
				if l[i] == l[k] {
					continue
				}
				if l[k] == l[j] {
					continue
				}
				if l[i]+l[j]+l[k] <= Max(l[i], l[j], l[k])*2 {
					continue
				}
				ans++
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1780
c = [list(map(int,input().split())) for k in range(3)]
A = [sum(a) for a in c]
B = [0,0,0]
AB = 0
for y in range(3):
    for x in range(3):
        if x == y:
            AB += c[y][x]
        B[x] += c[y][x]

for k in range(3):
    t = (A[k]+B[k]-AB)
    if t >= 0 and t%3 == 0:
        pass
    else:
        print("No")
        exit(0)
print("Yes")


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
    int N;
    cin >> N;
    ll A[110000], B[110000];
    for (int i=0; i<=N; i++) {
        if (i==0) A[i] = 0;
        else cin >> A[i];
    }
    
    ll S=0;
    for (int i=0; i<=N; i++) {
        if (i == N) B[i] = A[i] - A[0];
        else B[i] = A[i] - A[i+1];
        S += abs(B[i]);
    }

    for (int i=1; i<=N; i++) {
        ll res=S;
        res += abs(A[i-1]-A[i+1]) - abs(B[i-1]) - abs(B[i]);
        cout << res << endl;
    }

}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    ll h = a[n-1];
    ll res = 0;
    ll ans = 0;
    for(int i=n-2;i>=0;i--){
	if(h <= a[i]){
	    res ++ ;
	    h = a[i];
	    ans = max(res,ans);
	}else{
	    res = 0;
	    h = a[i];
	    ans = max(res,ans);
	}
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define debug(x) cerr<<#x<<" "<<x<<endl;
#define f(i,n) for(ll i=0; i<n; i++)
#define f1(i,n) for(ll i=1; i<=n; i++)
#define fr(i,n) for(ll i=n-1; i>=0; i--)
#define f1r(i,n) for(ll i=n; i>0; i--)
#define mst(arr,val) memset(arr,val,sizeof(arr))
#define all(x) x.begin(),x.end()

typedef long long int ll;
typedef pair<ll,ll> pii;
ll M=1e9+7;
ll M2=998244353;
void show(vector<ll> v)
{
    for(int i=0; i<v.size(); i++)
        cout<<v[i]<<" ";
    cout<<"\n";
}
void showrev(vector<ll> v)
{
    for(int i=0; i<v.size(); i++)
        cout<<v[v.size()-i-1]<<" ";
    cout<<"\n";
}
void showarr(ll arr[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<arr[i]<<" ";
    cout<<"\n";
}
void showpv(vector<pair<ll,ll> > v)
{
    f(i,v.size())
        cout<<"("<<v[i].ff<<","<<v[i].ss<<")"<<" ";
    cout<<"\n";
}
void showmap(map<ll,ll> m)
{
    for(auto i:m)
        cout<<" ("<<i.ff<<","<<i.ss<<") ";
    cout<<"\n";
}
int main()
{
    IOS
    ll T = 1,Q=1;
    //cin>>T;

    while(T--)
    {
        ll n;   cin>>n;
        ll a[n];
        f(i,n)
            cin>>a[i];
        ll dp[n+1][n+1];
        ll pre[n+1]; pre[0] = 0;
        f(i,n)
            pre[i+1] = pre[i] + a[i];
        f(i,n+1)
        {
            f(j,n+1)
            {
                if(i == j)
                    dp[i][j] = 0;
                else dp[i][j] = 1e18;
            }
        }

        for(ll len = 1; len<n; len++)
        {
            for(ll i = 1; i+len<=n; i++)
            {
                ll j = i+len;
                ll sum = pre[j]-pre[i-1];
                for(ll k=i; k<j; k++)
                    dp[i][j] = min(dp[i][j],dp[k+1][j]+dp[i][k]+ sum);
            }
        }
        /*f1(i,n)
        {
            f1(j,n)
                cout<<dp[i][j]<<" ";
            cout<<"\n";
        }*/
        cout<<dp[1][n];
    }
    return 0;
}


Measured memory_bytes: 1536
import java.util.Scanner;


public class Main{

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner kb=new Scanner(System.in);
		int x[]=new int[20000];
		x[0]=kb.nextInt();
		int h=0;
		int i=0;
		while(x[h]!=0){
			h++;
			x[h]=kb.nextInt();

		}

		while(x[i]!=0){
			System.out.printf("Case %d: %d\n",i+1,x[i]);
			i++;
		}

	}
}

Measured memory_bytes: 64288
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    ll n;
    cin >> n;
    vector<pair<int,int>> v(n);
    rep(i, 0, n)
    {
        int a, b;
        cin >> a >> b;
        v[i] = {b, a};
    }
    ll time = 0;
    sort(begin(v), end(v));
    bool y = true;
    rep(i, 0, n)
    {
        time += v[i].second;
        if (time > v[i].first)
            y = false;
    }
    cout << (y?"Yes":"No");    
    return 0;
}

Measured memory_bytes: 1792
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int stack[1000],top;
void push(int x)
{
	stack[++top]=x;
}
int pop()
{
	top--;
	return stack[top+1];
}
int main()
{
	int a,b,k,c=0;
	top=0;
	char s[1000];
	fgets(s,1000,stdin);k=0;
	for(int i=0;i<strlen(s);i++)
	{
		if(s[i]=='+')
		{
			 a=pop();
			 b=pop();
			 push(a+b);
		} 
	    else if(s[i]=='-')
	    {
	    	b=pop();
	    	a=pop();
	    	push(a-b);
		}
		else if(s[i]=='*')
		{
			a=pop();
			b=pop();
			push(a*b);
		}
		else
		{
			
			if(s[i]!=' ')
			{
				c=(s[i]-'0')+c*10;
				k=1;
			}
			else if(s[i]==' '&&k)
			{
				push(c);
				k=0;
				c=0;
			}
		}
	}
	printf("%d\n",pop());
	return 0;
}


Measured memory_bytes: 2140
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
typedef long long ll;

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

    ll m = 0 ,a = 0 ,r = 0 ,c = 0 ,h = 0;
    ll D[5];

    int P[10] = {0,0,0,0,0,0,1,1,1,2};
    int Q[10] = {1,1,1,2,2,3,2,2,3,3};
    int R[10] = {2,3,4,3,4,4,3,4,4,4};

    string s;
    for (int i = 0; i < n; i++) {
        
        cin >> s;
        if(s[0] == 'M') m++;
        if(s[0] == 'A') a++;
        if(s[0] == 'R') r++;
        if(s[0] == 'C') c++;
        if(s[0] == 'H') h++;
    }

    D[0] = m ,D[1] = a ,D[2] = r ,D[3] = c ,D[4] = h;
    ll res = 0;

    for (int i = 0; i < 10; i++) {

        res += D[P[i]] * D[Q[i]] * D[R[i]];
    }

    cout << res << endl;    
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll inf=1e18L+5;
struct block{
int w,s;ll v;
};
int main()
{
    int n;
    cin>>n;
    vector<block> vec(n);
    int max_w=0;
    for(int i=0;i<n;i++)
    {
        cin>>vec[i].w>>vec[i].s>>vec[i].v;
        max_w+=vec[i].w;
    }
    sort(vec.begin(),vec.end(),[](block a,block b){
        return a.w+a.s<b.w+b.s;
    });
    //dp[i] max value with total weight i so far
    vector<ll> dp(max_w+5);
    for(int i=0;i<n;i++)
    {
        for(int j=min(vec[i].s,max_w-vec[i].w);j>=0;j--)
        {            
                dp[j+vec[i].w]=max(dp[j+vec[i].w],dp[j]+vec[i].v);
        }
    }
    ll ans=-1;
    for(int j=max_w;j>=0;j--)
    {
        ans=max(ans,dp[j]);
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;cin >> n;
    vl l(n),r(n);
    rep(i,n)cin >> l[i] >> r[i];
    sort(all(l));sort(all(r));
    if(n%2==0){
        double t=l[n/2-1]+l[n/2];
        t/=2;
        double k=r[n/2-1]+r[n/2];
        k/=2;
        //cout << t <<" " << k <<endl;
        ll x=(k-t)/0.5;
        cout << x+1 <<endl;
    }
    else{
        cout << r[n/2]-l[n/2]+1 <<endl;
    }
}

Measured memory_bytes: 6360
# coding=utf-8
from copy import deepcopy

rooms = dict(zip(range(1, 11), [0] * 10))
building = dict(zip(range(1, 4), [deepcopy(r) for r in [rooms]*3]))
buildings = dict(zip(range(1, 5), [deepcopy(b) for b in [building]*4]))

# input
n = input()
for _ in xrange(n):
    b, f, r, v = map(int, raw_input().split())
    buildings[b][f][r] += v

# print result
for b in range(1, 5):
    for f in range(1, 4):
        rooms = buildings[b][f]
        print ' ' + ' '.join(map(str, [rooms[i] for i in xrange(1, 11)]))
    if b != 4:
        print '#' * 20

Measured memory_bytes: 4292
package main

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

func main() {
	w := ReadString()
	m := make(map[byte]int)
	for _, c := range []byte(w) {
		m[c]++
	}
	for c := byte('a'); c <= 'z'; c++ {
		if m[c]%2 == 1 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1844
import java.util.Scanner;
// ABC 083
public class Main {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int sums = 0;
        for(int i = 1; i <= n; i++) {
            int sum = 0;
            int j = i;
            while(j > 0) {
                sum += j % 10;
                j /= 10;
            }
            if(a <= sum && sum<= b) sums += i;
        }
        
        System.out.println(sums);
    }
}

Measured memory_bytes: 23508
def f(minutes, first = true)
  if minutes.size == 1
    return [(minutes[0] * 0.1).ceil * 10]
  else
    result = []
    minutes.each.with_index { |m, i|
      a = minutes.dup
      m = a.delete_at(i)
      result << f(a, false).map { |x|
        r = if first then (x + m) else ((x + m) * 0.1).ceil * 10 end
        r
      }
    }
    return result.flatten
  end
end

cooking_minutes = STDIN.read.split(/\s+/).map(&:to_i)
puts f(cooking_minutes).min

Measured memory_bytes: 1916
N,A,B,C,D = list(map(int,input().split()))

E = B-A

flag=False

for i in range(N):
    if E>=i*C-(N-i-1)*D and E<=i*D-(N-i-1)*C:
        flag=True

if flag:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 39024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n+1];
		int[] b = new int[n];
		for(int i = 0; i <= n; i++) {
			a[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++) {
			b[i] = sc.nextInt();
		}
		sc.close();
		long ans = 0;
		for(int i = 0; i < n; i++) {
			int left = Math.min(a[i], b[i]);
			ans += left;
			a[i] -= left;
			b[i] -= left;
			int right = Math.min(a[i+1], b[i]);
			ans += right;
			a[i+1] -= right;
			b[i] -= right;

		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 64104
#include<stdio.h>
#define maxn 105
int flag[maxn];
int main(){
	int n,k,d,m;
	scanf("%d %d",&n,&k);
	for (int i =1; i <= k; i++){
		scanf("%d",&d);
		for(int j = 1; j <= d; j++){
			scanf("%d",&m);
			flag[m]++;
		}
	}
	int cnt = 0;
	for(int i = 1; i<=n;i++){
		if(flag[i] == 0){
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
} 

Measured memory_bytes: 1724
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>

#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;

using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }

int main() {
  string s;
  cin >> s;
  ull result = 0;
  ull tmp = 0;

  each(i, s.size()) {
    if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
      tmp++;
    } else {
      result = max(result, tmp);
      tmp = 0;
    }
  }
  result = max(result, tmp);

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define MOD 1000000007
#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef long long ll;
typedef pair<ll,ll> PP;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false




signed main(void){
    int N,M,a;
    vector<int> A,B;
    cin >> N >> M;
    REP(i,M){
        cin >> a;a--;
        A.push_back(a);
        cin >> a;a--;
        B.push_back(a);
    }
    
    vector<int> G[214514];
    REP(i,M){
        G[A[i]].push_back(B[i]);
        G[B[i]].push_back(A[i]);
    }
    
    vector<int> Ans(N,-1);
    queue<int> Q;
    Ans[0]=0;
    Q.push(0);
    
    while(!Q.empty()){
        int q = Q.front();
        Q.pop();
        REP(i,G[q].size()){
            if(Ans[G[q][i]]==-1){
                Q.push(G[q][i]);
                Ans[G[q][i]]=q;
            }
        }
    }
    
    REP(i,N){
        if(i==0)continue;
        if(Ans[i]==-1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    REP(i,N){
        if(i==0)continue;
        cout << Ans[i]+1 << endl;
    }
    
    return 0;
}




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

const int N = 200005;

int a[N], n;

bool check(int mid) {
	for (int i = 1; i < n; ++i) {
		if ((a[n - i] >= mid) == (a[n - i + 1] >= mid)) return a[n - i] >= mid;
		if ((a[n + i] >= mid) == (a[n + i - 1] >= mid)) return a[n + i] >= mid;
	}
	return a[1] >= mid;
}

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n;
	for (int i = 1; i < 2 * n; ++i)
		std::cin >> a[i];
	int L = 1, R = 2 * n - 1, ans;
	while (L <= R) {
		int mid = L + R >> 1;
		if (check(mid)) ans = mid, L = mid + 1;
		else R = mid - 1;
	}
	std::cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define endl ("\n")
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ms memset
#define MOD 1000000007
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#define fr(i,n) for(i=0;i<n;i++)
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>	vi;
typedef vector<ll>	vl;
typedef vector<pii>	vpii;
typedef vector<pl>	vpl;
typedef vector<vi>	vvi;
typedef vector<vl>	vvl;
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);

ll expo (ll x, ll y) {ll res = 1; while (y) {if (y & 1)res = res * x; res %= MOD; y = y >> 1; x = x * x; x %= MOD;} return res;}
ll dp[101][100001];
ll A[101][2];
ll fun(ll ind, ll wet)
{
    if(ind==0||wet<=0)
    return 0;
    if(dp[ind][wet]!=-1)
    return dp[ind][wet];
    
    if(A[ind][0]<=wet)
    {
        return dp[ind][wet]=max(fun(ind-1,wet),fun(ind-1,wet-A[ind][0])+A[ind][1]);
    }
    return dp[ind][wet]=fun(ind-1,wet);
    
}
void solve()
{   
   ll i,j;
   ll n,wt;
   cin>>n>>wt;
   for(i=1;i<=n;i++)
   cin>>A[i][0]>>A[i][1];
   for(i=0;i<=n;i++)
   {
    for(j=0;j<=wt;j++)
    dp[i][j]=-1;
   }
    cout<<fun(n,wt)<<endl;

}

int main() 
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout);
#endif
    fast;
    // Fuck Ratings, I'm in Love with Experience. 
    int t = 1;
    //cin >> t;
    while(t--) {
      solve();
    }
    return 0;
}



Measured memory_bytes: 82528
#include <stdio.h>
#include <math.h>

int main() {
	int x,A,B;
	scanf("%d %d %d", &x, &A, &B);
	int da = abs(A-x);
	int db= abs(B-x);
	
	
	if(da < db){
		printf("A");
	}
	else{
		printf("B");
	}
	
	return 0;
}
	

Measured memory_bytes: 1612
#include<stdio.h>
int main(){

unsigned int num;
unsigned int s=0,m=0,h=0;

	scanf("%d",&num);

	s = num%60;
	h = num/3600;
	m = num/60-h*60;

	printf("%d:%d:%d\n",h,m,s );
	


return 0;
}

Measured memory_bytes: 1804
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <utility>
#include <numeric>
#include <map>
#include <iomanip>
#define LARGE 1000000007
using namespace std;

int mypow(int a, int b){
	if(b <= 0) return 1;
	return a * mypow(a, b - 1);
}

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

	vector<vector<int>> dp(H+1, vector<int>(W, 0));
	dp[0][0] = 1;

	for(int i = 1; i <= H; i++){
		for(int j = 0; j < (1 << W - 1); j++){
			int check = 0;
			int num = j;
			bool bad = false;
			for(int d = 0; d < W - 1; d++){
				if(num % 2 == 1){
					if(check == 1) bad = true;
					else check = 1;
				}else{
					check = 0;
				}
				num /= 2;
			}
			if(bad) continue;
			for(int k = 0; k < W; k++){
				//from k
				if(k == 0){
					if(!(j & (1 << W - k - 2))){
						dp[i][k] += dp[i-1][k];
					}
				}else if(k == W - 1){
					if(!(j & (1 << W - k - 1))){
						dp[i][k] += dp[i-1][k];
					}
				}else{
					if(!(j & (1 << W - k - 1)) && !(j & (1 << W - k - 2))){
						dp[i][k] += dp[i-1][k];
					}
				}

				//from k-1
				if(k > 0){
					if(j & (1 << W - k - 1)){
						dp[i][k] += dp[i-1][k-1];
					}
				}

				//from k+1
				if(k < W - 1){
					if(j & (1 << W - k - 2)){
						dp[i][k] += dp[i-1][k+1];
					}
				}
				dp[i][k] %= LARGE;
			}
		}
	}

	cout << dp[H][K] << endl;
}

Measured memory_bytes: 384
character(10**5) S
integer ans
read*,S
if( len_trim(s)==1)then
  print"(i0)",0
  stop
end if
ans=0
do i=2,len_trim(S)
  if(S(i:i)/=S(i-1:i-1))ans=ans+1
end do
print"(i0)",ans
end

Measured memory_bytes: 700
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

typedef long long ll;

ll gcd(ll x, ll y) {
    if (y == 0) return x;
    return gcd(y, x % y);
}

int main() {
    int X, A, B;
    cin >> X >> A >> B;
    if (B <= A) cout << "delicious" << endl;
    else if (B - A > X) cout << "dangerous" << endl;
    else cout << "safe" << endl;
}

Measured memory_bytes: 256