akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

int n, i, x;
int cnt;

int main()
{
  //  freopen("test.in","r",stdin);

    scanf("%d", &n);
    for (i = 1; i <= n; i++) {
        scanf("%d", &x);
        cnt ^= x;
    }

    if (cnt & 1)
        printf("NO\n");
    else
        printf("YES\n");


    return 0;
}


Measured memory_bytes: 256
fn main() {
    let n: u64 = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).ok();
        buf.trim().parse().ok().unwrap()
    };
    let mut ans: u64 = 1;
    for i in 1..n + 1 {
        ans = ans * i % 1000000007;
    }
    println!("{}", ans);
}


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

int k,t,a[105],tot;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> k >> t;
	for (int i=1;i<=t;i++){
		cin >> a[i];
	}
	sort (a+1,a+t+1);
	for (int i=1;i<t;i++){
		tot+=a[i];
	}
	cout << max(0,
	a[t]-(tot+1)) << "\n";
}

Measured memory_bytes: 256
a=int(input())
b=int(input())
if a==1:
  if b==2:
    print(3)
  elif b==3:
    print(2)
elif a==2:
  if b==1:
    print(3)
  elif b==3:
    print(1)
else:
  if b==1:
    print(2)
  elif b==2:
    print(1)

Measured memory_bytes: 3060
#include<bits/stdc++.h> 
using namespace std;
int n,k,a[60],s;
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=n;i>=n-k+1;i--) s+=a[i];
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
H = [int(num) for num in input().split()]
ans = [1] * N

for i in range(M):
    A, B = map(int, input().split())
    if(H[A-1] > H[B-1]):
        ans[B-1] = 0
    elif(H[B-1] > H[A-1]):
        ans[A-1] = 0
    else:
        ans[A-1] = 0
        ans[B-1] = 0

print(sum(ans))

Measured memory_bytes: 20112
from bisect import bisect_right

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort()
B.sort()
C.sort()

CI = []
for b in B:
    ci = bisect_right(C, b)
    CI.append(N-ci)

CII = CI[::-1]
D = []
d = 0
for cii in CII:
    d += cii
    D.append(d)

D = D[::-1]

ans = 0
for a in A:
    bi = bisect_right(B, a)
    if bi == N:
        continue
    ans += D[bi]
print(ans)

Measured memory_bytes: 25972
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;
constexpr double EPS = 1e-9;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
  }
} initializer;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &pa) {
  return os << "(" << pa.first << ", " << pa.second << ")";
}

template<typename Tuple, size_t N>
struct TuplePrinter {
  static void print(const Tuple &t) {
    TuplePrinter<Tuple, N-1>::print(t);
    cout << ", " << get<N-1>(t);
  }
};

template<typename Tuple>
struct TuplePrinter<Tuple, 1> {
  static void print(const Tuple &t) {
    cout << get<0>(t);
  }
};

template<typename... T>
ostream &operator<<(ostream &os, const tuple<T...> &tup) {
  os << "(";
  TuplePrinter<decltype(tup), sizeof...(T)>::print(tup);
  return os << ")";
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> &se) {
  os << "{";
  for (auto it = se.begin(); it != se.end(); ++it) {
    if (it != se.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &ma) {
  os << "{";
  for (auto it = ma.begin(); it != ma.end(); ++it) {
    if (it != ma.begin()) os << ", ";
    os << it->first << ": " << it->second;
  }
  return os << "}";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }


int main() {
  int n, m; cin>>n>>m;
  vector<vector<int>> g(n);
  rep(i, m) {
    int a, b; cin>>a>>b;
    --a; --b;
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }
  vector<int> prev(n, -1);
  prev[0] = 0;

  queue<int> q;
  q.push(0);
  while (!q.empty()) {
    int cur = q.front(); q.pop();
    for (auto nx: g[cur]) {
      if (prev[nx] == -1) {
        prev[nx] = cur;
        q.push(nx);
      }
    }
  }
  print("Yes");
  REP(i, 1, n) {
    print(prev[i] + 1);
  }

  return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    for (int i = 0; i < n; i++)cin >> x[i];

    int ret = 1145141919;
    for (int i = 0; i <= 200; i++) {
        int now = 0;
        for (int j = 0; j < n; j++)now += (i - x[j]) * (i - x[j]);
        ret = min(ret, now);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
/* in the name of allah */
#include<bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;
int n, a[N], b[N], c[N], dp[N][3];

void readInput() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i] >> b[i] >> c[i];
}

void solve() {
	dp[0][0] = a[0], dp[0][1] = b[0], dp[0][2] = c[0];
	for (int i = 1; i < n; i++) {
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
		dp[i][2] = max(dp[i - 1][1], dp[i - 1][0]) + c[i];
	}
	cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
}

int main() {
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	readInput(), solve();
	return 0;
}


Measured memory_bytes: 2560
N, K = map(int, input().split())
A = [[-1] * (N + 1) for i in range(100)]
A[0] = [0] + list(map(int, input().split()))


# nowから2**i先まで移動したとこ
def double(now, i):
    global A
    if A[i][now] != -1:
        return A[i][now]
    # nowから2**(i-1)移動して、そこからさらに2**(i-1)移動する
    A[i][now] = double(double(now, i - 1), i - 1)
    return A[i][now]


# nowからk移動した場所を求める
def rec(now, k):
    if k == 0:
        return now
    log2k = len(bin(k)) - 3
    return rec(double(now, log2k), k - 2 ** log2k)

print(rec(1, K))


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

int main(int argc, char const *argv[]) {
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  int sum=0;
  for(int i=0;i<n-1;i++){
    sum+=a[i];
  }
  if(a[n-1]<sum){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


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

int main() {
  
  int A, B, C, D;
  cin >> A >> B >> C >> D;
 
  if ((A + B) > (C + D)) {
	cout << "Left" << endl;
  }
  else if ((A + B) < (C + D)) {
	cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}


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

const int N = 305;
double dp[N][N][N];
int n;

double rec(int i, int j, int k) {
  if (dp[i][j][k] != -1) return dp[i][j][k];
  if (i == 0 && j == 0 && k == 0) return dp[0][0][0] = 0;
  double res = n;
  if (i) res += i * rec(i-1, j+1, k);
  if (j) res += j * rec(i, j-1, k+1);
  if (k) res += k * rec(i, j, k-1);
  res /= i + j + k;
  return dp[i][j][k] = res; 
}

int main() {
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> cnt(4);
  rep(i, n) cnt[a[i]]++;
  rep(i, n+1) rep(j, n+1) rep(k, n+1) dp[i][j][k] = -1;
  double ans = rec(cnt[3], cnt[2], cnt[1]);
  printf("%.9f\n", ans);
  return 0;
}

Measured memory_bytes: 220860
#include <iostream>
#include <vector>
#include <map>
#include <stack>
using namespace std;

#define null -1

void DFS(vector<int> rVal[], int uColor_m[], int idOrSs) {
	stack<int> stack;
	stack.push(idOrSs);
	uColor_m[idOrSs] = idOrSs;

	while (!stack.empty()) {
		int curUVal = stack.top();
		stack.pop();
		for (int i = 0; i < (signed)rVal[curUVal].size(); i++) {
			int curV = rVal[curUVal][i];
			if (uColor_m[curV] != null) continue;
			uColor_m[curV] = idOrSs;
			stack.push(curV);
		}
	}
}

void assignColor(int uNum, vector<int> rVal[], int uColor_m[]) {
	for (int i = 0; i < uNum; i++)
		uColor_m[i] = null;
	for (int i = 0; i < uNum; i++) {
		if (uColor_m[i] == null) DFS(rVal, uColor_m, i);
	}
}

int main() {
	int userNum;
	int relationNum;
	int uColor_map[100000]; //<?????????, ??°??????????????????>
	//??????????????¨????????????
	vector<int> relationVal[100000];
	//int userColor[100000];

	cin >> userNum >> relationNum;
	for (int i = 0; i < relationNum; i++) {
		int userVal1, userVal2;
		cin >> userVal1 >> userVal2;
		relationVal[userVal1].push_back(userVal2);
		relationVal[userVal2].push_back(userVal1);
		uColor_map[i] = null;
	}

	assignColor(userNum, relationVal, uColor_map);

	int qNum;
	cin >> qNum;
	for (int i = 0; i < qNum; i++) {
		int uV1, uV2;
		cin >> uV1 >> uV2;
		if (uColor_map[uV1] == uColor_map[uV2])
			cout << "yes" << endl;
		else
			cout << "no" << endl;
	}
	return 0;
}

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

typedef long long ll;
ll MOD = 1000000007;

int main()
{
    int N, S = 0;
    cin >> N;
    vector <int> A(N, 0), X(N, 0);
    for (int i = 0; i < N; i++) cin >> A[i];

    for (int i = 0; i < N; i++) {
        if (i%2) X[0] -= A[i];
        else X[0] += A[i];
    }

    for (int i = 1; i < N; i++) {
        X[i] = 2*A[i-1] - X[i-1];
    }

    for (int i = 0; i < N; i++) {
        cout << X[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

int gcd(int a ,int b){
    if(b == 0)
        return a;
    return gcd(b,a%b);
}


int main(){
    FIO
   int n;
   cin>>n;
   int flag=0;
   for(int i=9;i>0;i--){
       if(n/i <=9 && i<=9 && n%i==0){
        flag=1;
       }
   }
   
   if(flag)
    cout<<"Yes";
    else
    cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 2e4;
const lli INF = 1e18+10;
const lli MOD = 1e9+7;
const ld EPS = 1e-9;


// ---- コーディングはここから！ ('-')7




int main(){_
	int n,m; cin>>n>>m;
	vvi v(n+1);
	fore(i,0,m){
		int a,b; cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
	}
	queue<int>q; q.push(1);
	vi vis(n+1,0); vis[1]=1;
	while(!q.empty()){
		int a = q.front(); q.pop();
		for(auto i:v[a]){
			if(!vis[i]){
				q.push(i);
				vis[i]=a;
			}
		}
	}
	fore(i,1,n+1)if(!vis[i]){
		cout<<"No"<<ENDL;
		return 0;
	}
	cout<<"Yes"<<ENDL;
	fore(i,2,n+1)cout<<vis[i]<<ENDL;


}


Measured memory_bytes: 10148
fn main() {
    let n: i64;
    let d: i64;
    let mut x: Vec<i64>;
    let mut y: Vec<i64>;
    // 【入力段ここから】
    // 定型句 bufにstdinから1行読み込む。読み込んだ後、CRLFが入りっぱなしになっている点に注意。
    let mut buf: String;
    buf = String::new();
    let stdin_obj = std::io::stdin();
    stdin_obj.read_line(&mut buf).ok();
    // 定型句 buf（Str）に読み込んだ文字列をi64にパースしてnに代入。
    let tmp_collect: Vec<&str> = buf.trim().split_whitespace().collect();
    n = tmp_collect[0].trim().parse().ok().unwrap();
    d = tmp_collect[1].trim().parse().ok().unwrap();
    x = Vec::<i64>::with_capacity(n as usize);
    y = Vec::<i64>::with_capacity(n as usize);
    for _ in 0..n {
        buf = String::new();
        stdin_obj.read_line(&mut buf).ok();
        let tmp_collect: Vec<&str> = buf.trim().split_whitespace().collect();
        x.push(tmp_collect[0].trim().parse().ok().unwrap());
        y.push(tmp_collect[1].trim().parse().ok().unwrap());
    }
    // 【入力段ここまで】
    let mut counter = 0;
    for i in 0..n {
        if ((x[i as usize].pow(2) + y[i as usize].pow(2)) as f64).sqrt() > d as f64 {
            continue;
        } else {
            counter += 1;
            continue;
        }
    }
    println!("{}", counter);
}


Measured memory_bytes: 5200
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
def do():
    a,b,c=STRM()
    if a[-1]==b[0] and b[-1]==c[0]:
        print('YES')
    else:
        print('NO')
if __name__ == '__main__':
    do()

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cmath>
//#include<array>
#include<algorithm>
//#include<deque>
#include<vector>
//#include<utility>
#include<set>
//#include<map>
//#include<list>

using namespace std;
using LLI = long long int;
vector<int>dir_x = {0,0,1,1,1,-1,-1,-1};
vector<int>dir_y = {1,-1,1,0,-1,1,0,-1};
vector<int>dir_x2 = {0,0,1,-1};
vector<int>dir_y2 = {1,-1,0,0};

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//int gcd(int x, int y) {
//	int tmp, r;
//	if (x < y) {
//		tmp = x;
//		x = y;
//		y = tmp;
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//long nCr(int n,int r) {
//	long ans = 1;
//	for (int i = n; i > n - r;i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1;i++) {
//		ans = ans / i;
//	}
//	return ans;
//}

int main(void) {
	int H, W;
	bool res = true, judge = true;
	cin >> H >> W;
	vector<string>vec(H + 2,".");
	string a;
	for (int i = 0; i < W + 1;i++) {
		vec[0].append(".");
	}
	for (int i = 1; i < H + 1;i++) {
		cin >> a;
		vec[i].append(a);
		vec[i].append(".");
	}
	for (int i = 0; i < W + 1; i++) {
		vec[H + 1].append(".");
	}

	for (int i = 1; i < H + 1;i++) {
		for (int j = 1; j < W + 1;j++) {
			if (vec[i][j] == '#') {
				judge = false;
				for (int k = 0; k < 4;k++) {
					if (vec[i + dir_x2[k]][j + dir_y2[k]] == '#') {
						judge = true;
					}
				}
			}
			if (judge == false) {
				res = false;
			}
		}
	}
	if (res) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W,T;
ll mo=1000000007;

ll modpow(ll a, ll n = mo-2) {
	ll r=1;a%=mo;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

ll hoge(int H,int W) {
	ll ret=0;
	ret=modpow(2,H)+modpow(2,W)+mo-1;
	ret+=modpow(2,__gcd(H,W))+mo-2;
	return ret%mo;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W>>T;
	ll HP=__gcd(T,H);
	ll WP=__gcd(T,W);
	
	ll ret=hoge(H/HP,W/WP);
	ret=modpow(ret,HP*WP)%mo;
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main() {
	
	long long int n,sum=0; cin>>n;
	int a[n+1],b[n];
	for(int i=0;i<n+1;i++) cin>>a[i];
	for(int i=0;i<n;i++) {
		cin>>b[i];
	}
	for(int i=0;i<n;i++) {
		if(a[i]>b[i]) { sum+=b[i]; }	//Remove Equal to
		else {
			b[i]-=a[i];
			sum+=a[i];
			if(a[i+1]>b[i])  { //Remove Equal to
				a[i+1]-=b[i]; 
				sum+=b[i];
			}
			else {
				sum+=a[i+1]; 
				a[i+1]=0;
			}	
		}
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 1024
#include <cmath>
#include <cstdlib>
#include <iostream>


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

  int a, b, c, d;
  std::cin >> a >> b >> c >> d;
  std::cout << std::max(a * b, c * d) << std::endl;

  return EXIT_SUCCESS;
}


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

using namespace std;

int main()
{
    int n;

    cin >> n;

    int a[n];

    int i;

    int cnt=0;

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

        if(i>1)
        {
            if(a[i]<=a[i-1])
            {
                cnt++;
            }
            else
            {
                a[i]=a[i-1];
            }
        }
    }



    cout << ++cnt<< endl;

    return 0;
}


Measured memory_bytes: 4316
#include <iostream>

using namespace std;

int route = 0;
int a, b, n;
bool road[17][17];

void dfs(int x, int y) {
	if (x == a && y == b) {
		route++;
		return;
	}
	if (x > a || y > b) return;
	if (road[y][x]) return;
	dfs(x + 1, y);
	dfs(x, y + 1);
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (cin >> a >> b, a, b) {
		cin >> n;
		for (int y = 0; y < 17; y++)
			for (int x = 0; x < 17; x++)
				road[y][x] = false;
		while (n-- > 0) {
			int x, y;
			cin >> x >> y;
			road[y][x] = true;
		}
		route = 0;
		dfs(1, 1);
		cout << route << endl;
	}
}

Measured memory_bytes: 1192
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for i in range(a+1):
   for j in range(b+1):
      for k in range(c+1):
         if 500*i + 100*j + 50*k == x:
            cnt += 1

print(cnt)

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

const int N = 2e5 + 10;
struct node
{
	int id;
	int num;
} a[N];
int b[N];
bool cmp(node x,node y)
{
	return x.num < y.num;
}
int main()
{
	int n;
	scanf("%d",&n);
	for (int i = 0;i < n;i++)
	{
		scanf("%d",&a[i].num);
		a[i].id = i;
	} 
	sort(a,a+n,cmp);
	for (int i = 0;i < n;i++)
	{
		int id = a[i].id;
		if (i >= n / 2) b[id] = a[n/2-1].num;
		else b[id] = a[n/2].num;
	}
	for (int i = 0;i < n;i++) printf("%d\n",b[i]);
	return 0;
}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
int f[310][310],g[310][310],c[310][310];
#define re register
int main()
{
	re int n,mod,k;
	scanf("%d%d%d",&n,&k,&mod);
	for(re int i=1;i<=k+1;i++)g[0][i]=k-i+2,f[0][i]=1;
	for(re int i=0;i<=n;i++)
	{
		c[i][0]=1;
		for(re int j=1;j<=i;j++)c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
	}
	for(re int i=1;i<=n;i++)
	{
		for(re int j=1;j<=k;j++)
		{
			for(re int i1=0;i1<i;i1++)
			{
				f[i][j]=(f[i][j]+(long long)g[i1][j+1]*f[i-i1-1][j]%mod*c[i-1][i1])%mod;
			}
		}
		for(re int j=k;j;j--)g[i][j]=(g[i][j+1]+f[i][j])%mod;
	}printf("%d",f[n][1]);
}

Measured memory_bytes: 1280
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		int[][]x = new int[n][d];

		for(int i=0; i<n; i++) {
		for(int j=0; j<d; j++) {
			x[i][j] = sc.nextInt();	
		}
		}
		int cou = 0;
		for(int i=0; i<n-1;i++) {
		for(int j=i+1; j<n; j++) {
			int kyori = 0;
			for(int k=0; k<d; k++) {
				kyori +=  (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
		}
			for(int l=0; l<=kyori; l++) {
				if(kyori == l*l) {
					cou++;
				}
		}
		}
		}
			System.out.println(cou);
		}
	}


Measured memory_bytes: 36684
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;
int gcd(Int a, Int b) {
 return b != 0 ? gcd(b, a % b) : a;
}
int lcm(Int a, Int b) {
 return a / gcd(a, b)*b;
}
int main(){
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  const int dx=tx-sx,dy=ty-sy;

  cout << string(dy,'U') << string(dx,'R');

  cout << string(dy,'D') << string(dx,'L');

  cout << 'L' <<  string(dy+1,'U') << string(dx+1,'R') << 'D';

  cout << 'R' << string(dy+1,'D') << string(dx+1,'L') << 'U';
  cout << endl;
}


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


#define rep(i,n) for (int i=0; i<(n); i++)
const ll INF =2*1e9+2;
const ll BIG = 1e9+7;
const double PI = 3.141592653589793;

int main(){
    int n;
    cin >> n;
    vector<int> ans(4,0);
    rep(i, n) {
        string s;
        cin >> s;
        if(s=="AC") ans[0]++;
        else if(s=="WA") ans[1]++;
        else if(s=="TLE") ans[2]++;
        else ans[3]++;
    }
    rep(i,4){
        if(i==0) cout << "AC x " << ans[i] << endl;
        else if(i==1) cout << "WA x " << ans[i] << endl;
        else if(i==2) cout << "TLE x " << ans[i] << endl;
        else cout << "RE x " << ans[i] << endl;
    }
}

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


class Program {

	static long mod = 998244353;
	static void Main(string[] args) {

		char[] cs = new char[] { ' ' };
		//char[] cs = new char[] { ' ', ',' };

		//int n = int.Parse(Console.ReadLine());
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//string res="";
		//int res = 0;
		
		int res = 0;
		int pre = 0;
		int suf = 0;
		int dob = 0;

		int n = int.Parse(Console.ReadLine());
		string[] strs = new string[n];

		for ( int i = 0; i < n; i++ ) {
			string s = Console.ReadLine();
			strs[i] = s;
			if ( s[0] == 'B' && s[s.Length - 1] == 'A' ) { dob++; } else if ( s[0] == 'B' ) { pre++; } else if ( s[s.Length - 1] == 'A' ) { suf++; }
			res+=(s.Length - s.Replace("AB", "").Length)/2;

		}


		if ( pre == 0 && suf == 0 ) { if ( dob > 1 ) { res += dob - 1; } } 
		else { 
		
		res += Math.Min(pre,suf);
		int sa = Math.Abs(pre - suf);
		if ( sa < dob ) { res += dob; } else { res += dob; }

		
		}


			Console.WriteLine(res);


		return;

	}

	public static int CountChar(string s, char c) {
		return s.Length - s.Replace(c.ToString(), "").Length;
	}

	//	文字列strをindex番目からdで上書き
	static string strOverWrite(string str, int i, string s) {
		return str.Remove(i, s.Length).Insert(i, s);
	}

	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = long.Parse(str[i]); }
		return nums;
	}

	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { re[i] = str[i].ToString(); }
		return re;
	}

}

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

char s[101];
char t[101];

int main() {
  scanf("%s", s);
  scanf("%s", t);

  for (int i=0; i<strlen(s); i++) {
    bool match = true;
    for (int j=0; j<strlen(s); j++) {
      int x = j+i;
      if (x >= strlen(s)) {
        x -= strlen(s);
      }
      if (s[x] != t[j]) {
        match = false;
        break;
      }
    }
    if (match) {
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
}



Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;

int main() {
    ll h, w, a;
    cin >> h >> w;

    vector<Pii> nums(h*w+1, {-1, -1});
    bool ok = true;
    for(int i=0;i<h;++i) {
        cin >> a;
        if(nums[a].first != -1) ok = false;
        nums[a].first = i;
    }
    for(int i=0;i<w;++i) {
        cin >> a;
        if(nums[a].second != -1) ok = false;
        nums[a].second = i;
    }

    if(!ok) {
        cout << 0 << endl;
        return 0;
    }

    int used_line[h], used_row[w];
    ll line_cnt = 0, row_cnt = 0;
    fill(used_line, used_line+h, 0);
    fill(used_row, used_row+w, 0);

    ll ans = 1LL;
    for(ll i=h*w;i>=1;--i) {
        // cerr << i << ": " << nums[i].first << ", " << nums[i].second  << "\t";
        if(nums[i].first != -1) {
            ++used_line[nums[i].first];
            if(used_line[nums[i].first] == 1) {
                ++line_cnt;
            }
        }
        if(nums[i].second != -1) {
            ++used_row[nums[i].second];
            if(used_row[nums[i].second] == 1) {
                ++row_cnt;
            }
        }
        if(nums[i].first == -1 && nums[i].second == -1) {
            ans *= ((row_cnt*line_cnt) - (h*w - i));
        } else if(nums[i].first == -1) {
            ans *= line_cnt;
        } else if(nums[i].second == -1) {
            ans *= row_cnt;
        }
        ans %= MOD;

        if(ans <= 0) {
            ans = 0;
            break;
        }
    }

    cout << ans << endl;

    return 0;    
}

    

Measured memory_bytes: 8064
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    N, Ma, Mb = map(int, input().split())
    a_w = []
    b_w = []
    costs = []

    for i in range(N):
        a, b, c = map(int, input().split())
        a_w.append(a)
        b_w.append(b)
        costs.append(c)

    dp = [[[-1]*(10*N + 1) for j in range(10*N + 1)]
            for k in range(2)]

    dp[0][0][0] = 0
    dp[1][0][0] = 0

    for i in range(N):
        for a in range(10*N + 1):
            for b in range(10*N + 1):
                if a - a_w[i] >= 0 and b - b_w[i] >= 0:
                    if dp[0][a - a_w[i]][b - b_w[i]] >= 0:
                        if dp[1][a][b] == -1:
                            dp[1][a][b]= dp[0][a - a_w[i]][b - b_w[i]] + costs[i]
                        else:
                            min_ = min(dp[1][a][b],
                                       dp[0][a - a_w[i]][b - b_w[i]] + costs[i])
                            dp[1][a][b] = min_
        
        for k in range(10*N + 1):
            dp[0][k] = dp[1][k][:]

        # for i in range(10*N + 1):
            # print(*dp[0][i], file=sys.stderr)


    min_cost = float('inf')

    for a in range(10*N + 1):
        for b in range(10*N + 1):
            if a != 0 and b != 0:
                if a * Mb == b * Ma and dp[1][a][b] > 0:
                    min_cost = min(min_cost, dp[1][a][b])

    if min_cost == float('inf'):
        ans = -1
    else:
        ans = min_cost

    print(ans)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 60764
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    long long n; cin >> n;
    vector<long long> prime_factor;
    long long nn = n;
    for(long long i=2; i*i <= n; ++i) {
        if(n % i == 0) {
            prime_factor.push_back(i);
            while(n % i == 0) n /= i;
        }
    }
    if(n != 1) prime_factor.push_back(n);

    int N = (int)prime_factor.size();
    int ans = 0;
    for(int bit = 0; bit < (1<<N); ++bit) {
        int cnt = __builtin_popcount(bit);
        int product = 1;
        for(int i = 0; i < N; ++i) {
            if(bit & (1<<i)) product *= prime_factor[i];
        }
        if(product == 1) continue;
        if(cnt & 1) ans += nn / product;
        else ans -= nn / product;
    }

    cout << nn - ans << '\n';        
    return 0;
}


Measured memory_bytes: 3208
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<vs> vvs;

typedef vector<pair<int, int>> vpi;
typedef vector<tuple<int, int, int>> vti;


int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, i;
    string s;
    cin >> s;
    n = s.size();
    vi res(n, 0);
    int cnt=0;
    for (i=0;i<n;i++){
        if (s[i] == 'R'){
            cnt++;
        }else{
            int v = (cnt / 2);
            if (cnt%2==0) res[i-1] += v;
            else res[i-1] += v + 1;
            res[i] += v;
            cnt = 0;
        }
    }

    cnt = 0;
    for (i=n-1;i>=0;i--){
        if (s[i] == 'L'){
            cnt++;
        }else{
            int v = (cnt / 2);
            if (cnt%2==0) res[i+1] += v;
            else res[i+1] += v + 1;
            res[i] += v;
            cnt = 0;
        }
    }
    for (int t: res) cout << t << " ";
    cout << endl;

}


Measured memory_bytes: 1104
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    
    vector<ll> v(n), w(n);
    
    for ( ll i = 0; i < n; i++ )
        cin >> v[i];
    
    w[0] = v[0];
    for ( ll i = 1; i < n; i++ )
        w[i] = w[i-1] + v[i];
    
    ll ele = 10005;
    for ( ll i = 0; i < n; i++ )
        ele = min(ele, w[i] > w[n-1] - w[i] ? 2 * w[i] - w[n-1]: w[n-1] - 2 * w[i]);
    
    cout << ele << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 const int MAX_N=10000+5;
 int n;
 int par[MAX_N];
 int rank[MAX_N];
 
   void init()
   {
     for(int i=0;i<n;i++)
     {
       par[i]=i;
       rank[i]=0;        
     }     
   }
   
   int find(int x)
   {
     if(par[x]==x) return x; 
     else return par[x]=find(par[x]);    
   }
   
   void unite(int x,int y)
   {
     x=find(x);
     y=find(y);
     if(x==y) return;
     if(rank[x]<rank[y]) par[x]=y;
     else
     { 
       par[y]=x;
       if(rank[x]==rank[y]) rank[x]++;
     }     
   }
   
   bool same(int x,int y)
   {
     //cout<<find(x)<<" "<<find(y)<<endl;
     return find(x)==find(y);     
   }

  int main()
 {
   int q;
   cin>>n>>q;
   init();
   while(q--)
   {
     int a,b,c;
     cin>>a>>b>>c;
     if(a==0) unite(b,c);
     else
     {
       if(same(b,c)) cout<<"1"<<endl;
       else cout<<"0"<<endl;    
     }            
   }
    //while(1);
    return 0;
 }

 
 

Measured memory_bytes: 3180
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
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;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  ll a=0;
  FOR(i,0,1000000000){
    a++;
  }
  co(3*n*n)
}

Measured memory_bytes: 1024
#include <iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<limits.h>

#define MOD 1000000007


using namespace std;

long long int modpow(long long int a, int n) {

	if (n == 0)return 1;
	if (n == 1) return a;

	long long int wk = modpow(a, n / 2);

	long long int ret = 0;
	if (n % 2 == 0) {
		ret = 1;
	}
	else {
		ret = a;
	}

	return (((ret * wk) % MOD) * wk) % MOD;

}

long long int gcd(long long int a, long long int b) {
	long long int tmp;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	long long int r = a % b;

	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

long long int lcm(long long int a, long long int b) {

	long long int wk_int;

	wk_int = (a * b) % MOD;
	
	long long int ret;

	ret = (wk_int * modpow(gcd(a, b), MOD - 2)) % MOD;

	return ret;

}

bool isPrime(int n) {
	if (n == 1)return false;
	if (n == 2)return true;

	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}

	return true;
}








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

	vector<int> a(n);
	vector<int> b(n);
	int maxA = 0;

	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		if (maxA < a[i])maxA = a[i];
	}
	
	//dp[i] は体力をi減らすために消耗するMPの最小値
	//0減らすためにはMP0でよいので初期化。それ以外はでかい数字入れておく。
	//h + maxA な理由は、（ｈ－１）＋(maxA）でdp[h+maxA-1]までアクセスされうるから。
	vector<int> dp(h + maxA);
	dp[0] = 0;
	for (int i = 1; i < dp.size(); i++) {
		dp[i] = INT_MAX;
	}

	//配るDP
	for (int i = 0; i < h; i++) {

		//更新されていないDPテーブルからは更新が発生しない。
		if (dp[i] == INT_MAX)continue;

		int wkIndex;
		int wkCost;

		for (int j = 0; j < n; j++){
			wkIndex = i + a[j];
			wkCost = dp[i] + b[j];

			if (wkCost < dp[wkIndex]) {
				dp[wkIndex] = wkCost;
			}
		}
	}

	long long int ans = INT_MAX;

	for (int i = h; i < h + maxA; i++) {
		if (dp[i] < ans)ans = dp[i];
	}

	cout << ans << endl;




	return 0;

}



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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

int hamming(string& a,string& b){
	int dist = 0;
	for(int i=0,ei=a.size();i<ei;i++){
		dist += (a[i]+b[i])%2;
	}
	return dist;
}

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

	string S=in<string>();
	string A(S.size(),'0'),B(S.size(),'0');
	for(int i=0;i<S.size();i+=2){
		A[i] = '1';
	}
	for(int i=1;i<S.size();i+=2){
		B[i] = '1';
	}

	cout << min(hamming(S,A),hamming(S,B)) << endl;
	return 0;
}


Measured memory_bytes: 592
import java.util.*;
public class Main{
   public static void main(String[] args) {
     Scanner sc = new Scanner(System.in);
     String s = sc.next();
     boolean flag=true;
     for(int i=0;i<s.length()-1;i++){
       if(s.charAt(i)==s.charAt(i+1)){
         System.out.println("Bad");
         flag = false;
         break;
       }
     }
     if(flag){
       System.out.println("Good");
     }
   }
}


Measured memory_bytes: 21588
#include <iostream>
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  a = a - c;
  a >= 0 ? a : a = -1 * a;
  if(a >= 2*d) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}


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

using namespace std;
using ll = long long;


int main(){
  int N;
  cin >> N;
  int ans = 0;
  rep(i, N){
    int a;
    cin >> a;
    while(a%2==0){
      a /= 2;
      ans++;
    }
  }
  cout << ans << endl;
}
   
      
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define in_range(x, y, r, c) (x <= r && y <= c && x >= 0 && y >= 0)
#define MAXN 200100
#define ff first
#define ss second
using namespace std;
const int mod = 1e9+7;

int solve(string s){
    int base = 1, r = 0, tam = s.size(), ans = 0;
    map<int, int> hist;

    for (int i=tam-1; i>=0; --i){

        r = (r + base*(s[i] - '0'))%2019;

        if (r == 0) ans++;
        ans += hist[r];
        ++hist[r];

        base = (base * 10) %2019;
    }

    return ans;
}


int main(){
    string s;

    cin >> s;
	
    auto ans  = solve(s);

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

Measured memory_bytes: 3928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



int main(){fastio
    ll n;cin>>n;
    rep(i,0,n-1){
        cout<<"ACL";
    }
    cout<<endl;
    
    return 0;
}





Measured memory_bytes: 3632
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

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

int main() {
	LL a,b;
	cin >> a >> b;
	if(abs(a-b)<=1){
		cout << "Brown" << endl;
	}
	else{
		cout << "Alice" << endl;
	}

	return 0;
}



Measured memory_bytes: 384
import java.util.*;
class Main{
    public static void main(String[] args){
	Scanner stdIn = new Scanner(System.in);
	String S = stdIn.next();
	int N = S.length();
	String mae = S.substring(0,N/2);
	String ato = S.substring(N/2+1,N);
	if(mae.equals(ato)){
	    System.out.println("Yes");
	}else{
	    System.out.println("No");
	}
    }
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll dp[2020][2020][2];
ll mo=1000000007;
int N,K;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	dp[N][0][0]=1;
	for(i=N;i>=1;i--) {
		for(j=N;j>=0;j--) {
			(dp[i-1][j][0]+=dp[i][j][0]+dp[i][j][1])%=mo;
			(dp[i-1][j+1][1]+=dp[i][j][0]+dp[i][j][1])%=mo;
			if(j) (dp[i][j-1][0]+=dp[i][j][0])%=mo;
		}
	}
	ll ret=(dp[1][N-K][0]+dp[1][N-K][1])%mo;
	FOR(i,N-K-1) (ret*=2)%=mo;
	cout<<ret<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 63744
#include<bits/stdc++.h> 
using namespace std;
string st,xst;
int main()
{
    cin>>st;
    for(int i=0;i<st.size();i++)
        if(st[i]=='0'||st[i]=='1') xst+=st[i];
        else
            if(xst.size()>0) 
            xst.erase(xst.size()-1,1);
    cout<<xst;
    return 0; 
}

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

typedef pair<int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l4;

#define mp make_pair
#define pb push_back

const int maxn = 1e5+10;
int n, cnt[maxn];

int main()
{
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    {
      int a;
      scanf("%d", &a);
      for (int k = a-1; k <= a+1; ++k)
	cnt[1+k]+=1;
    }
  printf("%d\n", *max_element(cnt, cnt+maxn));
}


Measured memory_bytes: 640
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
		//Implement solution here.
		int r = ni();
		System.out.println(3 * (int)Math.pow(r, 2));
	}

	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 22612
defmodule Main do
  def main do
    [n, d] = IO.gets("")
             |> String.trim()
             |> String.split()
             |> Enum.map(&String.to_integer/1)

    xy = IO.read(:all) |> String.split() |> Stream.chunk_every(2)

    xy
    |> Stream.map(fn [x, y] -> [String.to_integer(x), String.to_integer(y)] end)
    |> Enum.reduce(0, fn [x, y], acc -> if :math.sqrt(x*x+y*y) <= d, do: 1+acc, else: acc end)
    |> IO.puts()
  end
end


Measured memory_bytes: 97956
use whiteread::parse_line;

fn main() {
    let n: usize = parse_line().unwrap();
    let (mut tp, mut xp, mut yp): (u32, u32, u32) = (0, 0, 0);
    let mut ans = "Yes";

    for _ in 0..n {
        let (tn, xn, yn): (u32, u32, u32) = parse_line().unwrap();
        let remainder = (tn - tp) % 2;
        if tn - tp < (xp.max(xn) - xp.min(xn)) + (yp.max(yn) - yp.min(yn)) {
            ans = "No";
            break;
        }
        if ((xp + yp).max(xn + yn) - (xp + yp).min(xn + yn)) % 2 != remainder {
            ans = "No";
            break;
        }
        tp = tn;
        xp = xn;
        yp = yn;
    }
    println!("{}", ans);
}


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

count = 0

d = []
for i in range(N):
    d1, d2 = map(int, input().split())
    d.append([d1, d2])

for i in range(len(d)):
    d1, d2 = d[i]
    if d1 == d2:
        count += 1
        if count == 3:
            break
    else:
        count = 0

if count == 3:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9180