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

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;


int main(){
  string s;
  cin >> s;
  vector<ll> mod(2019, 0);
  ll n = s.size();
  ll a = 0;
  ll digit = 1;
  mod[0]++;
  rep(i, s.size()){
    // cout << s[n-i-1] << endl;
    a = (a + digit * (s[n-i-1]-'0') % 2019) % 2019;
    // cout << a << endl;
    digit = (digit * 10) % 2019;
    mod[a]++;
  }
  ll ans = 0;
  for(auto m : mod){
    ans += m*(m-1)/2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3372
require "pp"
map = Array.new()
10.times do |i|
  map << Array.new(10,0)
end

while line = gets
  x,y,size  = line.split(",").map(&:to_i)  
  map[x][y] += 1
  map[x+1][y] += 1 if x < 9
  map[x-1][y] += 1 if x > 0
  map[x][y+1] += 1 if y < 9
  map[x][y-1] += 1 if y > 0
  next if size == 1
  map[x+1][y+1] += 1 if x < 9 && y < 9
  map[x+1][y-1] += 1 if x < 9 && y > 0
  map[x-1][y+1] += 1 if x > 0 && y < 9
  map[x-1][y-1] += 1 if x > 0 && y > 0
  next if size == 2
  map[x+2][y] += 1 if x < 8
  map[x-2][y] += 1 if x > 1
  map[x][y+2] += 1 if y < 8
  map[x][y-2] += 1 if y > 1
end
c = 0
deep = 0
map.each do |row|
  max = row.max
  deep = max if max > deep
  c += row.count(0)
end
puts c
puts deep

Measured memory_bytes: 6236
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
map<int,ll> mp;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,x;
cin>>n>>x;
if(x==1||(x>2*n-2)){
    cout<<"No"<<endl;
    return 0;
}
cout<<"Yes"<<endl;
if(x==2&&n==2){
    cout<<1<<" "<<2<<" "<<3<<endl;
    return 0;
}
vector<bool> used(2*n,false);
vector<int> a(2*n-1,0);
int mid=(2*n-1)/2;
if(x!=2){
    x--;
for(int i=mid-1;i<mid+3;i++){
    if(i==mid+2){
        a[i]=x-4;
    used[x-4]=true;
        break;
    }
    a[i]=x;
    used[x]=true;
    x++;
}
}
else{
    a[mid-1]=x+1;
    a[mid]=x;
    a[mid+1]=x-1;
    a[mid+2]=x+2;
    used[x+1]=true;
    used[x]=true;
    used[x-1]=true;
    used[x+2]=true;
}
int j=1;
for(int i=0;i<2*n-1;i++){
    if(a[i]!=0)continue;
    while(used[j])j++;
    a[i]=j;
    j++;
}
for(int i=0;i<2*n-1;i++)cout<<a[i]<<" ";
cout<<endl;
}

Measured memory_bytes: 2304
#include <iostream>
#include <fstream>
#include <cstring>
#include <queue>

using namespace std;
long long n,i,j,a,b,fr[30],l,ok,v[100001],s,nrtotal;

bool check(long long ans)
{
    long long i,ans2=0,mustadd;
    for(i=1;i<=n;i++)
    {
        mustadd=(v[i]-ans*b+(a-b)-1)/(a-b);
        ans2+=max(0LL,mustadd);
    }
    if(ans2<=ans) return 1;
    return 0;
}

long long cautbin()
{
    long long rez=0, pas=1LL<<33;
    while(pas)
    {
        if(rez+pas<=1000000000 && !check(rez+pas)) rez+=pas;
        pas/=2;
    }
    return rez+1;
}

int main()
{
    cin>>n>>a>>b;
    for(i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    nrtotal=cautbin();
    cout<<nrtotal<<'\n';
}


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

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <list>
#include <iomanip>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())


void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str="";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}

int main() {
	Int a, b; cin>> a >> b;
	Int ans = 1;
	if (a == b) {
		for (int i = 1; i <= a; i++) {
			ans = ans * i % MOD;
		}
		cout << (Int)ans * ans * 2 % MOD;
	}
	else if(max(a,b)-min(a,b)==1){
		for (int i = 1; i <= a; i++) {
			ans = ans * i % MOD;
		}
		for (int i = 1; i <= b; i++) {
			ans = ans * i % MOD;
		}
		cout << (Int)ans % MOD;
	}
	else {
		cout << 0;
	}
	


	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n,m,x;
  cin >> n >> m >> x;
  vector<bool> a(110,false);
  
  rep(i,m){
    int b;
    cin >> b; 
    a[b] = true;
  }
  int costL = 0;
  int costR = 0;
  
  for(int i = x-1; i >=0; i--){
    if(a[i]) costL++;
  }
  for(int i = x+1; i <= n; i++){
    if(a[i]) costR++;
  }
  
  cout << min(costL,costR);
  
  return 0;
}

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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()


const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int arr[N];

void solve()
{
	int k; cin >> k;
	arr[1] = 7;
	int f = 0;
	lop(i, 1, N)
	{
		arr[i] = (arr[i - 1] * 10 + 7) % k;
		if ( !arr[i] and !f ) f = i;
	}
	if ( !f ) f = -1;
	cout << f << endl;



}

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

	int test = 1;
	// cin >> test;
	while (test--)solve();


}





















Measured memory_bytes: 27064
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int N,P;cin>>N>>P;
  int zero=0,one=0,a;
  REP(i,0,N){
    cin>>a;
    (a%2==1?one:zero)++;
  }
  if(one==0){
    if(P==0)print((int)pow(2,N));
    else print(0);
    re 0;
  }
  print((int)pow(2,N-1));


}


Measured memory_bytes: 256
import heapq
N = int(input())
graph = [[] for _ in range(N)]
for _ in range(N-1):
  a, b = map(lambda x:int(x)-1, input().split())
  graph[a] += [[b,1]]
  graph[b] += [[a,1]]

def dijkstra(s):
  # numは最短経路の数
  dist = [float('inf')]*N
  dist[s] = 0
  num = [0]*N
  num[s] = 1
  q = [[0, s]]
  pre = [0]*N
  heapq.heapify(q)
  while q:
    c, u = heapq.heappop(q)
    if dist[u] < c:
      continue
    for v, weight in graph[u]:
      if dist[v] > dist[u] + weight:
        dist[v] = dist[u] + weight
        num[v] = num[u]
        heapq.heappush(q, [dist[v], v])
        pre[v] = u
      elif dist[v] == dist[u] + weight:
        num[v] += num[u]
  return dist, num, pre

d1, _, pre1 = dijkstra(0)
d2, _, pre2 = dijkstra(N-1)

a1 = 0
a2 = 0
for i in range(N):
  if d1[i] <= d2[i]:
    a1 += 1
  else:
    a2 += 1

if a1 <= a2:
  print('Snuke')
else:
  print('Fennec')

Measured memory_bytes: 121784
/*
    Problem 64
    https://onlinejudge.u-aizu.ac.jp/problems/GRL_2_A
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* class */
class DisjointSet {
public:
    vector<int> d;
    DisjointSet () {}
    DisjointSet (int len) { d.assign(len, -1); }

    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)];}
};
class Edge {
public:
    int u, v, w;
    Edge () {}
    Edge (int u, int v, int w) : u(u), v(v), w(w) {}
    bool operator < (const Edge &e) const {
        return w < e.w;
    }
};
/* global variables */
int V, E;
/* function */
/* main */
int main(){
    cin >> V >> E;

    vector<Edge> edges;
    for (int i = 0; i < E; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        edges.push_back(Edge(u, v, w));
    }
    sort(edges.begin(), edges.end());

    DisjointSet ds = DisjointSet(V);
    int ans = 0;
    for (Edge e : edges) {
        if (ds.unite(e.u, e.v))
            ans += e.w;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 4452
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define x_ real()
#define y_ imag()
#define cross(a, b) (conj(a)*(b)).imag()
#define dot(a, b) (conj(a)*(b)).real()
#define PI acos(-1)
#define F first
#define S second
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL)
#define fileIO freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define ordered_set tree<pair<int, int>, null_type,less<pair<int, int>>, rb_tree_tag,tree_order_statistics_node_update>
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef complex<ld> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
typedef pair<double, double> pd;
pair<int, int> dirs[] = { {1, 2}, {-1, 2}, {2, 1}, {2, -1}, {-2, 1}, {-2, -1}, {1, -2}, {-1, -2} };
const ld eps = 1e-6;
const int N = 1e5 + 7;


int main() {
	fastIO;
	int n;
	cin >> n;
	vector<int> v, s;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		v.push_back(x);
	}
	s = v;
	sort(s.begin(), s.end());
	if (v == s) {
		cout << "YES";
		return 0;
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			swap(v[i], v[j]);
			if (v == s) {
				cout << "YES";
				return 0;
			}
			swap(v[i], v[j]);
		}
	}
	cout << "NO";

}


Measured memory_bytes: 256
N, K = [int(i) for i in input().split()]
mod = 10 ** 9 + 7
gcd_comb = [0]*(K+1)
for i in range(K, 0, -1):
    gcd_comb[i] = pow(K // i, N, mod)
    gcd_comb[i] -= sum(gcd_comb[i + i : K + 1 :i])
    gcd_comb[i] %= mod
ans = 0
for i, n in enumerate(gcd_comb):
    if not i:
        continue
    ans = (ans + i * n) % mod
print(ans)

Measured memory_bytes: 70072
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#define PI 3.14159265359
typedef long long ll;
const int MOD = 1e9+7;
const ll LLINF = 7e18;
using namespace std;


ll llmin(ll x_ll, ll y_ll){
	if (x_ll < y_ll) return x_ll;
	return y_ll;
}

ll llmax(ll x_ll, ll y_ll){
	if (x_ll > y_ll) return x_ll;
	return y_ll;
}

vector<int> graph[100001];
bool is_reached[100001];

pair<int, int> bfs(int blk, int whi){
	int b_ans = 1, w_ans = 1;
	queue<pair<int, int> > que_b, que_w;
	que_b.push(make_pair(blk, 1));
	que_w.push(make_pair(whi, 1));
	is_reached[blk] = true;
	is_reached[whi] = true;
	int coun = 0;
	while(1){
		coun++;
		while(1){
			auto b = que_b.front();
			if (b.second != coun) break;
			que_b.pop();
			for (auto ne : graph[b.first]){
				if (!is_reached[ne]){
					is_reached[ne] = true;
					que_b.push(make_pair(ne, coun+1));
					b_ans++;
				}
			}
		}
		while(1){
			auto w = que_w.front();
			if (w.second != coun) break;
			que_w.pop();
			for (auto ne : graph[w.first]){
				if (!is_reached[ne]){
					is_reached[ne] = true;
					que_w.push(make_pair(ne, coun+1));
					w_ans++;
				}
			}
		}
		if (que_b.empty() && que_w.empty()) break;
	}
	return make_pair(b_ans, w_ans);
}


int main(){
	int n;
	cin >> n;
	for (int i = 1; i < n; i++){
		int a, b;
		cin >> a >> b;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	auto ans = bfs(1, n);
	if (ans.first > ans.second) cout << "Fennec" << endl;
	else cout << "Snuke" << endl;
	return 0;
}

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

using namespace std;

int cnt[27];
bool check(string ne) {
  for (int i = 0; i < 26; ++i) {
    cnt[i] = 0;
  }
  for (int i = 0; i < ne.size(); ++i) {
    if(0 > ne[i]-'a' || ne[i]-'a' >= 26) return false;
    cnt[ne[i]-'a']+=1;
  }
  for (int i = 0; i < 26; ++i) {
    if(cnt[i]>=2)return false;
  }
  return true;
}

int main() {
  string a;
  cin >> a;
  set <char> st;
  for (int i = 0; i < 26; ++i) {
    st.insert('a'+i);
  }
  for (int i = 0; i < a.size(); ++i) {
    if(st.find(a[i]) != st.end()){
      st.erase(a[i]);
    }
  }
  if(!st.empty()){
    cout << a << *st.begin() << endl;
  }
  else {
    //cout << "wtf" << endl;
    int ok = 1;
    for (int i = 0; i < a.size(); ++i) {
      if(a[i] != 'z'-i){
	ok = 0;
      }
    }
    vector <string> v;
    string at = "";
    if(ok == 1)puts("-1");
    else{
      for (int i = 0; i < 26; ++i) {
	st.insert('a'+i);
      }   
      for (int i = 0; i < a.size(); ++i) {

	string ne = at+(*st.lower_bound(a[i]+1));
	//cout << ne << endl;
        if(check(ne)){
	  v.push_back(ne);

	}
	at += (char)a[i];
	if(st.find(a[i]) != st.end()){
	  st.erase(a[i]);
	}
      }
      sort(v.begin(), v.end());
      cout << *lower_bound(v.begin(), v.end(), at) << endl;
    }
    
    
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	long long n,input,max = 1e18,flag = 0,zero = 0,total = 1;
	scanf("%lld",&n);
	while(n--)
	{
		scanf("%lld",&input);
		flag = (input > max) ? 1 : flag;
		total *= input; 
		if(input == 0) zero = 1;
		else max /= input;
	}
	(zero == 1) ? printf("0\n") : (flag == 1) ? printf("-1\n") : printf("%lld\n",total);
}

Measured memory_bytes: 2012
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;
using MIte = multimap<long, long, greater<long> >::iterator;


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

	// long long?
	string S;
	cin >> S;

	if (S == "Sunny") {
		cout << "Cloudy" << endl;
	}
	else if (S == "Cloudy") {
		cout << "Rainy" << endl;
	}
	else if (S == "Rainy") {
		cout << "Sunny" << endl;
	}



	return 0;

}

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

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    cout << (n-a)%b << endl;

    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
X = list(map(int, input().split()))

ans = 0
if N >= M:
	pass
else:
	X.sort()
	# print(X)
	Y = [0]*(M-1)
	for i in range(M-1):
		Y[i] = X[i+1] - X[i]
	Y.sort(reverse=True)
	# print(Y)
	L = 0
	for i in range(N-1):
		L += Y[i]
	ans = X[M-1] - X[0] - L
print(ans)


Measured memory_bytes: 13960
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int n, q;
pair<int, pair<int, string> > eras[1000];

void solve(int x) {
	for (int i = 0; i < n; i++) {
		if (eras[i].first < x && x <= eras[i].second.first) {
			cout << eras[i].second.second << ' ' << x - eras[i].first << endl;
			return;
		}
	}
	cout << "Unknown" << endl;
}

int main () {
	while (cin >> n >> q, n || q) {
		for (int i = 0; i < n; i++) {
			string name;
			int eby, wy;
			cin >> name >> eby >> wy;
			eras[i] = make_pair(wy - eby, make_pair(wy, name));
		}
		sort(eras, eras + n);
		for (int i = 0; i < q; i++) {
			int x;
			cin >> x;
			solve(x);
		}
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) {
   cin >> a.at(i);
  }
  
  int count = 0;
  rep(i,n) {
   if(a.at(i) % 2 == 0) {
    count++;
   }
  }
  
  int check = 0;
  rep(i,n) {
   if(a.at(i) % 6 == 0 || a.at(i) % 10 == 0) {
     check++;
    }
   
  }
  
  if (count == check) {
  cout << "APPROVED";
  }
  else {
   cout << "DENIED";
  }
  
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <functional>
#include <set>
#include <ctime>
#include <random>
#include <bitset>
using namespace std;

class UnionFindTree{
	typedef struct {
		int parent;
		int rank;
	}base_node;
	
	vector<base_node> node;
public:
	UnionFindTree(int n){
		node.resize(n);
		for(int i=0; i<n; i++){
			node[i].parent=i;
			node[i].rank=0;
		}
	}

	int find(int x){
		if(node[x].parent == x) return x;
		else{
			return node[x].parent = find(node[x].parent);
		}
	}
	
	bool same(int x, int y){
		return find(x) == find(y);
	}

	void unite(int x, int y){
		x = find(node[x].parent);
		y = find(node[y].parent);
		if(x==y) return;
		if(node[x].rank < node[y].rank){
			node[x].parent = y;
		}else if(node[x].rank > node[y].rank){
			node[y].parent = x;
		}else{
			node[x].rank++;
			unite(x,y);
		}
	}
};

int main_(){
	int n,m,p;
	cin >> n >> m >> p;

	UnionFindTree uft(n);

	vector<int> u(m),v(m);
	vector<int> e(m);
	vector<vector<int>> g(n);
	//vector<int> g(n);
	for(int i=0; i<m; i++){
		cin >> u[i] >> v[i];
		u[i]--; v[i]--;
		//g[u[i]] |= 1<<v[i];
		//g[v[i]] |= 1<<u[i];
		g[u[i]].push_back(v[i]);
		g[v[i]].push_back(u[i]);
		//e[i] = (1<<u[i]) | (1<<v[i]);
		uft.unite(u[i], v[i]);
	}
	bool connected = true;
	for(int i=1; i<n; i++){
		connected = connected && uft.same(0,i);
	}
	if(connected == false){
		printf("0.000000000000000000\n");
		return 0;
	}
/*
	vector<int> edge_cnt(1<<n, 0);
	for(int i=0; i<(1<<n); i++){
		for(int j=0; j<m; j++){
			if((i>>u[j])&(i>>v[j])&1){
				edge_cnt[i]++;
			}
		}
	}
*/
	vector<double> prob(1<<n, -1);
	prob[1] = 1;

	function<double(int)> dfs = [&](int s){
		if(prob[s] != -1) return prob[s];
		double res = 1.0;
		int s_ = s-1;
		for(int x=s_; x>=0; x=(x-1)&s_){
			int y = x|1;
			if(y==s) continue;
			double q = dfs(y);
			double tmp = 1.0;
			
			for(int i=0; i<m; i++){
				if( (((1<<u[i])&y) && ((1<<v[i])&(s^y))) or (((1<<v[i])&y) and ((1<<u[i])&(s^y))) ){
					tmp *= 0.01 * p;
				}
			}
			
			//tmp = pow(0.01*p, edge_cnt[s] - edge_cnt[y] - edge_cnt[s^y]);

			res -= q * tmp;

			if(x==0) break;
		}
		return prob[s] = res;
	};

	double ans = dfs((1<<n)-1);
	printf("%.18f\n", ans);
	return 0;
}


int main(){
	auto start = clock();
	main_();
	//cerr << clock()-start << endl;
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int N, M; cin >> N >> M;
    cout << (1800 * M + 100 * N) * pow(2, M) << endl;
    return 0;
}

Measured memory_bytes: 4040
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;
int main() {
	int i, j,k=0;
	int X;
	int beki[10000] = {};
	int bekimax = 99999;
	cin >> X;


		for (i = 2; i < 33; ++i) {
			for (j = 2; j < 11; ++j) {
				beki[k] = pow(i, j);
				if (beki[k] > 1000) {
					break;
				}
				//cout << beki[k]<<endl;
				++k;
			}
		}
		for (i = 0; i < 1000; ++i) {
			if (X >= beki[i]&&beki[i]>0) {
				bekimax = min( bekimax , (X - beki[i]));
			}
		}
		if (X != 1) {
			cout << X - bekimax << endl;
		}
		else {
			cout << 1 << endl;
		}





}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int x=0;int y=0;int t=0;
    for(int i=0;i<N;i++){
        int nt,nx,ny;
        cin >> nt >> nx >> ny;
        int dis = abs(x-nx)+abs(y-ny);
        int dt=(nt-t);
        if(dis>dt||(dis-dt)%2!=0){
            cout << "No" << endl;
            return 0;
        }
        x=nx;y=ny;t=nt;
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main() {
    int a, b;
    while (scanf("%d%d", &a, &b) != EOF) {
        int k = a+b, ans = 0;
        do {
            ans++;
            k /= 10;
        } while(k);
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 0
# -*- Coding: utf-8 -*-
n = int(input())
dict = {}
for i in range(n) :
    s = input()
    if(s in dict.keys()) :
        dict[s]+=1
    else :
        dict[s] = 1
m = int(input())
for i in range(m):
    t = input()
    if(t in dict.keys()) :
        dict[t]-=1
    else :
        dict[t] = -1
print(max(0,max(dict.values())))


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<long,long>
#define INF 1000000000000000000
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<int, int> mp;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
class Union_Find {
private:
	vector<int> par;
	vector<int> rank;
public:
	Union_Find(int n) {
		rep(i, n) {
			par.push_back(i);
			rank.push_back(0);
		}
	}
	int find(int x) {
		if (par.at(x) == x) return x;
		else return par.at(x) = find(par.at(x));
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (rank.at(x) < rank.at(y)) {
			par.at(x) = y;
		}
		else {
			par.at(y) = x;
			if (rank.at(x) == rank.at(y)) rank.at(x)++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	int a[100000];
	rep(i, n) {
		cin >> a[i];
	}
	map<int, int> mp;
	rep(i, n) {
		mp[a[i]]++;
	}
	int ans = 0;
	for (auto p : mp) {
		int x = p.first;
		int n = p.second;
		if (n < x) ans += n;
		else ans += n - x;
	}

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

Measured memory_bytes: 7040
#include<iostream>
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
int main()
{
	char c1,c2;
	cin>>c1>>c2;
	if(c1=='H')
	cout<<c2<<"\n";
	else if(c1=='D'&&c2=='H')
	cout<<"D";
	else if(c1=='D'&&c2=='D')
	cout<<"H";
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DMakeThemEven solver = new DMakeThemEven();
        solver.solve(1, in, out);
        out.close();
    }

    static class DMakeThemEven {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int h = in.nextInt();
            int w = in.nextInt();
            int[][] n = new int[h][w];
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    n[i][j] = in.nextInt();
                }
            }

            int cnt = 0;
            ArrayList<Pair> bef = new ArrayList<>();
            ArrayList<Pair> aft = new ArrayList<>();
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w - 1; j++) {
                    if (n[i][j] % 2 != 0) {
                        cnt++;
                        bef.add(new Pair(i + 1, j + 1));
                        aft.add(new Pair(i + 1, j + 2));
                        n[i][j]--;
                        n[i][j + 1]++;
                    }
                }
            }

            for (int i = 0; i < h - 1; i++) {
                if (n[i][w - 1] % 2 != 0) {
                    cnt++;
                    bef.add(new Pair(i + 1, w));
                    aft.add(new Pair(i + 2, w));
                    n[i][w - 1]--;
                    n[i + 1][w - 1]++;
                }
            }

            out.println(cnt);
            for (int i = 0; i < cnt; i++) {
                out.println(bef.get(i).toSimpleStr() + " " + aft.get(i).toSimpleStr());
            }

        }

    }

    static class Pair {
        public long x;
        public long y;

        public Pair(long x, long y) {
            this.x = x;
            this.y = y;
        }

        public String toString() {
            return "Pair{" +
                    "x=" + x +
                    ", y=" + y +
                    '}';
        }

        public String toSimpleStr() {
            return x + " " + y;
        }

    }
}



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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;cin>>n;
  vector<int> a(n),b(n),c(n);
  rep(i,n)cin>>a[i];
  rep(i,n)cin>>b[i];
  rep(i,n)cin>>c[i];
  sort(all(a));
  sort(all(b));
  sort(all(c));
  ll tot=0;
  rep(i,n){
      auto ci=upper_bound(all(c),b[i]);
      auto ai=lower_bound(all(a),b[i]);
      ll k1=c.end()-ci;
      ll k2=ai-a.begin();
      tot+=k1*k2;
  }
  cout<<tot<<endl;
  return 0;
  }


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define forn for(int i=0;i<n;i++)
#define form for(int j=0;j<m;j++)
#define pb push_back
#define s second
#define f first
int main()
{
   int a,b;
   cin>>a>>b;
   int maxx=max(a+b,a-b);
   cout<<max(maxx,a*b);
   return 0;
				
}

Measured memory_bytes: 256
#include <stdio.h>
int main(int argc, char const *argv[]) {
  int n,a,b;
  scanf("%d%d%d",&n,&a,&b);
  a=a*n;
  if (a<b) {
    printf("%d\n",a );
    return 0;
  }
  printf("%d\n",b );
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>



/*以下便利なマクロを定義する。*/

#define refor(i, min, max) for(i=min; i<=max; i=i+1)



#define if_forall(i, min, max, prop)\
	bool if_forall_condition=1;\
\
	for(i=min; i<=max; i=i+1)\
	{\
		if(!(prop))\
		{\
			if_forall_condition=0;\
			break;\
		}\
	}\
\
	if(if_forall_condition==1)\



#define if_exists(i, min, max, prop)\
	bool if_exists_condition=0;\
\
	for(i=min; i<=max; i=i+1)\
	{\
		if(prop)\
		{\
			if_exists_condition=1;\
			break;\
		}\
	}\
\
	if(if_exists_condition==1)\











/*以下便利な関数を定義する。*/



void ini_int(int a[], int num)
{
	int i=0;

	for(i=0; i<=num; i=i+1)
	{
		a[i]=0;
	}

}



void ini_char(char array[], int num)
{
	int i=0;

	for(i=0; i<=num; i=i+1)
	{
		array[i]='\0';
	}

}



int powi(int base, unsigned int exponent)
{
	int answer=1;

	answer=(int)pow((double)base, (double)exponent);

	return answer;
}



void sort_asc_int(int a[], int min, int max)
{
	int i, j;
	int dumy;

	for(i=min; i<=max; i=i+1)
	{
		for(j=i+1; j<=max; j=j+1)
		{
			if(a[i]>a[j])
			{
				dumy=a[i];
				a[i]=a[j];
				a[j]=dumy;
			}
		}
	}
}



void sort_des_int(int a[], int min, int max)
{
	int i, j;
	int dumy;

	for(i=min; i<=max; i=i+1)
	{
		for(j=i+1; j<=max; j=j+1)
		{
			if(a[i]<a[j])
			{
				dumy=a[i];
				a[i]=a[j];
				a[j]=dumy;
			}
		}
	}
}



int max_int(int a[], int min, int max)
{
	int i;
	int answer;

	answer=a[min];

	for(i=min+1; i<=max; i=i+1)
	{
		if(answer<a[i])
		{
			answer=a[i];
		}
	}

	return answer;
}



int min_int(int a[], int min, int max)
{
	int i;
	int answer;

	answer=a[min];

	for(i=min+1; i<=max; i=i+1)
	{
		if(answer>a[i])
		{
			answer=a[i];
		}
	}

	return answer;
}



bool containelement_int(int array[], int min, int max, int element)
{
	int i;
	bool answer=0;

	if_exists(i, min, max, array[i]==element)
	{
		answer=1;
	}

	return answer;
}



int count_differentelement_int(int array[], int min, int max)
{
	int i=min;
	int pickup[max];
	ini_int(pickup, max);
	int answer=0;

	for(i=min; i<=max; i=i+1)
	{
		if(containelement_int(pickup, 0, answer-1, array[i])==0)
		{
			pickup[answer]=array[i];
			answer=answer+1;
		}
	}

	return answer;
}



int count_equalelement_int(int array[], int min, int max, int element)
{
	int i;
	int answer=0;

	for(i=min; i<=max; i=i+1)
	{
		if(array[i]==element)
		{
			answer=answer+1;
		}
	}

	return answer;
}











int main()
{

	int i=1;
	int N;
	int sum=0;
	scanf("%d", &N);

	refor(i, 1, N)
	{
		sum=sum+i;
	}

	printf("%d\n", sum);

	return 0;

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.20f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

int ok[1000000];
int main() {
	int n;
	cin >> n;

	for (int x = 1; x <= 105; x++) for (int y = 1; y <= 105; y++) for (int z = 1; z <= 105; z++) {
		ok[x* x + y * y + z * z + x * y + y * z + z * x]++;
	}
	
	for (int i = 1; i <= n; i++) cout << ok[i] << endl;
	return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <cstring>
#include <algorithm>
#include <math.h>
#define MOD 1000000007
using namespace std;

int main()
{
	int d, n,ans;
	int t[202],a[202],b[202],c[202];
	int dp[202][202] = {};
	cin >> d >> n;
	int i,j,k;
	for (i = 0; i < d; i++){
		cin >> t[i];
	}
	for (i = 0; i < n; i++){
		cin >> a[i] >> b[i] >> c[i];
	}
	for (i = 0; i < d - 1; i++){
		for (j = 0; j < n; j++){
			for (k = 0; k < n; k++){
				if (a[k] <= t[i] && b[k] >= t[i] && a[j] <= t[i + 1] && b[j] >= t[i + 1] && dp[i + 1][j] <= dp[i][k] + abs(c[k] - c[j])){
					dp[i + 1][j] = dp[i][k] + abs(c[k] - c[j]);
				}
			}
		}
	}
	ans = 0;
	for (i = 0; i < n; i++){
		ans = max(ans, dp[d - 1][i]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
long long n;
long long solve(long long x){
	if (x==1) return 1LL;
	return (1LL+2LL*solve(x/2));
}
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
cout << solve(n);
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define eps 1e-9
using namespace std;
typedef complex<double> point;
typedef pair<point, point> line;
typedef pair<double, double> pii;
typedef struct edge{
  int to;
  double cost;
}edge;

//b??????a??????????????????
double dis(point a, point b){
  return abs(a - b);
}

//??????
double dot(point a, point b){
  return a.real()*b.real() + a.imag()*b.imag();
}

//??????
double cross(point a, point b){
  return imag(conj(a) * b);
}

//counter clock wise
int ccw(point a, point b, point c){
  if(cross(b - a, c - a) >  eps)return  1;//??????ab????????´
  if(cross(b - a, c - a) < -eps)return -1;//??????ab????????´
  if(dot(b - a, c - a) < -eps)return 2;//??´???ab??????a???????????????
  if(abs(b - a) + eps < abs(c - a))return -2;//??´???ab??????b???????????????
  return 0;//??´???ab???
}

bool is_cross(line a, line b){
  if(ccw(a.first, a.second, b.first) *
     ccw(a.first, a.second, b.second) <= 0 &&
     ccw(b.first, b.second, a.first) *
     ccw(b.first, b.second, a.second) <= 0){
    return true;
  }
  return false;
}

double dijkstra(vector<point> &a, vector<point> &b){
  line la = line(a[0], a[1]);
  int n = b.size();
  vector<edge> g[n];
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if(is_cross(la, line(b[i], b[j])))continue;
      double d = dis(b[i], b[j]);
      g[i].push_back((edge){j, d});
      g[j].push_back((edge){i, d});
    }
  }
  double dp[n];
  priority_queue<pii, vector<pii>, greater<pii> > que;
  for (int i = 0; i < n; i++) dp[i] = 1e9;
  dp[0] = 0;
  que.push(pii(0, 0));
  while(not que.empty()){
    double c = que.top().first;
    int v = que.top().second;
    que.pop();

    for (int i = 0; i < g[v].size(); i++) {
      double nc = c + g[v][i].cost;
      int nv = g[v][i].to;
      if(dp[nv] > nc){
        dp[nv] = nc;
        que.push(pii(nc, nv));
      }
    }
  }
  return dp[1] + dis(a[0], a[1]);
}

int main(){
  int na, nb;
  std::cin >> na >> nb;
  vector<point> a(na), b(nb);
  double x, y;
  for (int i = 0; i < na; i++) {
    std::cin >> x >> y;
    a[i] = point(x, y);
  }
  for (int i = 0; i < nb; i++) {
    std::cin >> x >> y;
    b[i] = point(x, y);
  }
  double ans = 1e9;
  ans = min(ans, dijkstra(a, b));
  ans = min(ans, dijkstra(b, a));
  if(ans != 1e9)printf("%.12lf\n", ans);
  else std::cout << -1 << std::endl;
  return 0;
}

Measured memory_bytes: 18856
#include <stdio.h>
#include <stack>
#include <math.h>

using namespace std;

long long calc(long long x,long long y){
	if(y == 0){
		return x;
	}else{
		return calc(y,x%y);
	}
}

struct Student{
	long long int distance,speed;
};

int main(){

	int n;
	long long int c_speed,c_distance,work;
	Student students[10];

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		for(int i= 0; i < n; i++){
			scanf("%lld %lld",&students[i].distance,&students[i].speed);
			//?´??????????
			if(students[i].distance > students[i].speed){
				work = calc(students[i].distance,students[i].speed);
			}else{
				work = calc(students[i].speed,students[i].distance);
			}
			students[i].distance /= work;
			students[i].speed /= work;
		}

		//?????????????°???¬?????°????±???????<??????????????????:??????????????¢????????????????????????????????§??????>

		//???????????¢???????°???¬?????°????±???????
		for(int i=0; i < n; i++){
			if(i == 0){
				c_distance = students[i].distance;
			}else{
				if(c_distance >= students[i].distance){
					work = calc(c_distance,students[i].distance);
					c_distance = ((c_distance/work)*students[i].distance);
				}else{
					work = calc(students[i].distance,c_distance);
					c_distance = ((c_distance/work)*students[i].distance);
				}
			}
		}

		//??????????????????????????????????????????
		for(int i=0; i < n; i++){
			students[i].speed *= (c_distance/students[i].distance);
		}

		//??????????????§??¬?´???°????±???????<?????????????????°??????>
		for(int i=0; i < n; i++){
			if(i == 0){
				work = students[i].speed;
			}else{
				if(work > students[i].speed){
					work = calc(work,students[i].speed);
				}else{
					work = calc(students[i].speed,work);
				}
			}
		}

		for(int i=0; i < n; i++){
			printf("%lld\n", students[i].speed/work);
		}
	}

    return 0;
}

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

int main() {
  int64_t n;
  std::cin >> n;
  std::vector<int64_t> a(n);

  int64_t m = 0;
  bool zero = false;

  for (auto &i : a) {
    std::cin >> i;
    if (i < 0) {
      m++;
      i = -i;
    } else if (i == 0) {
      zero = true;
    }
  }

  const auto sum = std::accumulate(a.cbegin(), a.cend(), 0ll);
  if (m % 2 == 0 || zero) {
    std::cout << sum << std::endl;
  } else {
    const auto min = *std::min_element(a.cbegin(), a.cend());
    std::cout << sum - 2 * min << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

R, C, K = map(int, input().split())
V = [[0] * C for _ in [None] * R]
for _ in [None] * K:
    r, c, v = map(int, input().split())
    V[r - 1][c - 1] = v

dp = [[[-1] * C for _ in [None] * R] for _ in [None] * 4]

dp[0][0][0] = 0
for r in range(R):
    for c in range(C):
        v = V[r][c]
        for i in range(4):
            if dp[i][r][c] > -1:
                if r < R - 1:
                    dp[0][r + 1][c] = max(dp[0][r + 1][c], dp[i][r][c])
                if c < C - 1:
                    dp[i][r][c + 1] = max(dp[i][r][c + 1], dp[i][r][c])
                if i < 3 and v:
                    if r < R - 1:
                        dp[0][r + 1][c] = max(dp[0][r + 1][c], dp[i][r][c] + v)
                    if c < C - 1:
                        dp[i + 1][r][c + 1] = max(dp[i + 1][r][c + 1], dp[i][r][c] + v)

v = V[R - 1][C - 1]
ans = dp[3][R - 1][C - 1]
for i in range(3):
    ans = max(ans, dp[i][R - 1][C - 1] + v)
print(ans)

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

int main(){

    int N, X, Y;
    cin >> N >> X >> Y;

    vector<int> records(N);
    X--;
    Y--;

    for (int i = 0; i < N; i++)
        for (int j = i+1; j < N; j++) {

            int m1 = j - i;
            int m2 = abs(i-X)+1+abs(Y-j);
            int m3 = abs(i-Y)+1+abs(X-j);

            int minimum = min({m1,m2,m3});
            records[minimum]++;
        }

    for (int i = 1; i < N; i++)
        cout << records[i] << " ";
    cout << "\n";

    return 0;
}


Measured memory_bytes: 384
n = int(input())
d = 2
ans = 0

while d ** 2 <= n:
    if n % d != 0:
        d += 1
        continue
    z = d
    while n % z == 0:
        n //= z
        z *= d
        ans += 1
    
    while n % d == 0:
        n //= d

if n != 1:
    ans += 1

print(ans)

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

ll modinv(ll a,ll m){
   ll b=m,u=1,v=0;
   while(b){
      ll t=a/b;
      a-=t*b; 
      swap(a,b);
      u-=t*v; 
      swap(u,v);
   }
   u%=m;
   if(u<0) u+=m;
   return u;
}

ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}



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

   int a[n+1];
   a[0]=0;
   for(int i=1;i<n+1;i++){
      cin>>a[i];
   }
   int b[n+1];
   memset(b,0,sizeof(b));
   b[1]++;
   int now=1;
   int next=a[1];
   int count=0;
   do{
      
      count++;
      now=next;
      b[now]++;
      next=a[now];
      if(now==2){
         cout<<count;
         break;
      }
      if(b[now]==2) {
         cout<<-1;
         break;
      }
      

   }while(1);
   return 0;
}



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

int main() {
  int n;
  cin>>n;
  ll a[n];
  int odd=0;
  for(int i=0;i<n;i++) {
    cin>>a[i];
    if(a[i]%2==1) odd++;
  }
  if(odd%2==0) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 1024
fun main(args: Array<String>) {

    val pairList = arrayListOf<Pair<Int, Int>>()

    while (true) {

        val input = readLine()?.split(" ") ?: return
        val list = arrayListOf<Int>()
        input.forEach { list.add(it.toInt()) }

        if (list[0] == 0 && list[1] == 0) break
        pairList.add(Pair(list[0], list[1]))
    }

    for (pair in pairList) {
        for (h in 0 until pair.first) {
            for (w in 0 until pair.second) {
                print("#")
            }
            println()
        }
        println()
    }
}


Measured memory_bytes: 42028
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
#include<cstdlib>
#include <queue>
#include <cmath>
#include <iomanip>
#include<list>
#include <utility>
#include <functional>
#include<map>
#include<stack>
#define T long long


int main(){
	T n,k;
	std::cin >> n>>k;
	std::vector<T>a,b;
	a.resize(n);
	b.resize(n);
	for(int i=0;i<n;i++){
		std::cin >> a[i];
		b[i] = -1;
	}
	int town = 1;
	for(T i=0;i<k;i++){
		if(b[town-1]==-1){
			b[town-1] = i;
		}else{
			T diff = (k-i)%(i-b[town-1]);
			for(T j=0;j<diff;j++){
				town = a[town-1];
			}
			break;
		}
		town = a[town-1];
	}
	std::cout << town <<std::endl;
}


Measured memory_bytes: 6424
import java.util.*

val sc = Scanner(System.`in`)
val S: String = sc.next()

fun main(args: Array<String>) {
    println(if (judge(S)) "AC" else "WA")
}

fun judge(s: String): Boolean {
    if (s[0] != 'A') {
        return false
    }
    var flg = false
    for (i in 1 until s.length) {
        if (s[i].isUpperCase()) {
            if (s[i] != 'C' || i == 1 || i == s.length - 1 || flg) {
                return false
            }
            flg = true
        }
    }
    return flg
}


Measured memory_bytes: 31388
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

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;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	int a, b,c; cin >> a >>b;
	//string s; cin >> s;
	cout << (a - 1) * (b - 1);
	


	cout << endl;
	return 0;
}

Measured memory_bytes: 256
x, k, d = map(int, input().split())

if -d*k+x < 0:
    t = d*k-x
    p = t//(2*d)
    l = []
    #print(p)
    for i in range(-1, 2):
        s = p+i
        if 0 <= s <= k:
            #print(p+i, abs(2*d*s-d*k+x))
            l.append(abs(2*d*s-d*k+x))
    if len(l) > 0:
        ans = min(l)
    else:
        ans = abs(2*d*k-d*k+x)

else:
    ans = -d*k+x
print(ans)


Measured memory_bytes: 61696
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define all(x) begin(x),end(x)
#define oo(i,a) for (int i = 0; i < (a); i++)
#define ooo(i,a,b) for (int i = a; i < (b); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const char newl = 10;
const int MOD = 998244353;
const int N = 100005;
// set N | watch out for overflow | n == 1 |
void run(){
   int x;
   cin >> x;
   cout <<( (x / 500) * 1000) + ( (x%500) / 5 ) * 5 << newl; 
   return ;
}
int main(){
   ios_base::sync_with_stdio(0);
   cout.tie(0);cin.tie(0);
   int t = 1;
   // cin >> t;
   for (int tc = 1; tc <= t; tc++) {
      // cout << "Case #" << tc << ": ";
      run();
   }
   return 0;
}

Measured memory_bytes: 256