akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<vector>
#define MaxN 20000+100
using namespace std;
vector<int> g10[MaxN];
vector<int> g5[MaxN];
int main()
{
	int N;
	int H;
	scanf("%d %d",&N,&H);
	for(int i=0;i<=2000;i++)
		for(int k=0;k<=2000;k++)
		{
			int sum=10*i+5*k;
			if(sum<MaxN)
			{
				g10[sum].push_back(i);
				g5[sum].push_back(k);
			}
		}
	H/=1000;
	int i;
	for(i=0;i<=N;i++)
	{
		int sum=H-i;
		if(g10[sum].size()!=0)
		{
			int p;
			for(p=0;p<g10[sum].size();p++)
			{
				if(i+g10[sum][p]+g5[sum][p]==N)
				{
					printf("%d %d %d\n",g10[sum][p],g5[sum][p],i);
					break;
				}
			}
			if(p!=g10[sum].size())
				break;
		}
	}
	if(i==N+1)
		printf("-1 -1 -1\n") ;
	return 0;
 } 

Measured memory_bytes: 28288
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int main()
{
    int N, K;
    cin >> N >> K;

    char* str = new char[N];
    cin >> str;

    str[K - 1] = std::tolower(str[K - 1]);
    cout << str << endl;

    delete [] str;
    return 0;
}

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

int main() {
    int ans = 0;
    int N;
    string S;
    cin >> N >> S;
    for(int i = 1; i < N; i++) {
        int len = 1;
        for(int j = 0; i + j < N; j++) {
            if(S[j] == S[i + j]) {
                ans = max(ans, min(i, len));
                len++;
            } else
                len = 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
const int MOD = 1e9 + 7;
using namespace std;
ll func(int bit,ll a)
{
  return ((a >> bit) & 1);
}
int main() 
{
  int n;
  cin >> n;
  ll A[n+1];
  for (int i = 0; i < n; ++i)
  {
    cin >> A[i];
  }
  ll ans = 0;
  for (int bit = 0; bit < 60; ++bit)
  {
    ll tmp = (1ll << bit)%MOD;
    int num_ones = 0;
    for (int i = 0; i < n; ++i)
    {
      num_ones += func(bit, A[i]);
    }
    ll tmp2 = (1ll * num_ones * (n - num_ones))%MOD;
    ans = (ans + (tmp * tmp2)%MOD)%MOD;
    // cout << ans << "\n";
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;
typedef unsigned long long BITMASK; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<double, double> pdd; typedef pair<long long, long long> pll;
#define has_bit(bit_mask, x) ((bit_mask) & (1ULL << (x)))
#define turn_on_bit(bit_mask, x) (bit_mask |= (1ULL << (x)))
#define turn_off_bit(bit_mask, x) (bit_mask &= (~(1ULL << (x))))
#define smallest_on_bit(bit_mask) (__builtin_ctzint((bit_mask) & (-(bit_mask))))
#define CLOCK_START clock_t chrono_clk_beg = clock()
#define CLOCK_END clock_t chrono_clk_end = clock(); cerr << (double(chrono_clk_end - chrono_clk_beg) / CLOCKS_PER_SEC) << " sec"
#define bug(args ...) cerr << __LINE__ << ">> ", err(new istringstream(string(#args)), args), cerr << '\n'
#define decToBin(name, num) string name = bitset<8>(num).to_string();
#define binToDec(name, binary) unsigned long name = bitset<8>(binary).to_ulong();
#define radToDeg(name, radians) double name = radians * 180 / M_PI;
#define all(x) x.begin(), x.end()
#define mapfind(mp, x) (mp.find(x) != mp.end())
#define arrfind(arr, x) (find(all(arr), x) != arr.end())
#define removeDuplicates(vec) sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define printMat(mat) for (auto &x : mat) { for (auto &y : x) cout << y << " "; cout << '\n'; }
#define printArr(arr) for (auto &x : arr) cout << x << " "; cout << '\n';
#define arrReplace(arr, from, to) for (auto &x : arr) if (x == from) x = to;
#define INF (1LL<<30)
#define INF32 (1LL<<62)
#define F first
#define S second
#define M_PI 3.14159265358979323846
inline int ceil(int a, int b) { return (a+b-1)/b; }
void err(istringstream *iss) {} template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) { string _name; *iss >> _name; if (_name.back()==',') _name.pop_back(); cerr << _name << " = " << _val << "; ", err(iss, args ...); }
int str_replace(string& str, const string& from, const string& to, int limit = -1) { if(from.empty()) return 0; size_t start_pos = 0; int cnt = 0; while((start_pos = str.find(from, start_pos)) != std::string::npos) { str.replace(start_pos, from.length(), to); start_pos += to.length(); cnt++; if (cnt == limit) break; } return cnt; }
#define MOD 1000000007

signed main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, k;
	cin >> n >> k;
	string str;
	cin >> str;
	str[k-1] = tolower(str[k-1]);
	cout << str << '\n';
	return 0;
}

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int S(int n) {
    int ret = 0;
    while (n) {
        ret += n % 10;
        n /= 10;
    }
    return ret;
}

int K;
signed main() {
    cin >> K;
    vint cand;
    int bai = 1;
    rep(i, 10) {
        rep(j, 1000000) {
            cand.push_back(j * bai + bai - 1);
        }
        bai *= 10;
    }
    sort(all(cand));
    uniq(cand);
    vint sn;
    pint p = {1, 0};
    for (int i = cand.size() - 1; i > 0; i--) {
        int s = S(cand[i]);
        if (cand[i] * p.second <= p.first * s) {
            p = {cand[i], s};
            sn.push_back(cand[i]);
        }
    }
    reverse(all(sn));
    rep(i, K) { cout << sn[i] << endl; }
}


Measured memory_bytes: 133084
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <ctype.h>
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <fstream>
#include <sstream>
#include <queue>
#include <exception>
#include <cmath>
#include <numeric>
#include <map>
#include <algorithm>
#include <bitset>
#include <set>
#include <functional>

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

using namespace std;
typedef long long int lint;

bool AOJ0134()
{
	int n;
	cin >> n;
	vector<lint> val(n);
	REP(i, n) {
		cin >> val[i];
	}
	cout << accumulate(val.begin(), val.end(), (lint)0) / n << endl;
	return true;
}

int main()
{
	AOJ0134();

	return 0;
}

Measured memory_bytes: 3136
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int w = sc.nextInt();
        Map<Long, List<Long>> map = new HashMap<>();
        List<Long> wList = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            long weight = sc.nextLong();
            long value = sc.nextLong();
            if (!map.containsKey(weight)) {
                map.put(weight, new ArrayList<>());
            }
            if (i == 0) {
                wList.add(weight);
            }
            map.get(weight).add(value);
        }

        List<Integer> wCnt = new ArrayList<>();
        for (int i = 0; i < 4; i++) {
            long x = wList.get(0) + i;
            if (!map.containsKey(x)) {
                wCnt.add(0);
                continue;
            }
            wCnt.add(map.get(x).size());
        }

        for (int i = 1; i < 4; i++) {
            wList.add(wList.get(0) + i);
        }

        // System.out.println(map);
        // System.out.println(wList);
        // System.out.println(wCnt);
        for (Map.Entry<Long, List<Long>> entry : map.entrySet()) {
            Collections.sort(entry.getValue(), Collections.reverseOrder());
        }
        //System.out.println(map);

        long ans = 0;
        for (int w1 = 0; w1 <= wCnt.get(0); w1++) {
            for (int w2 = 0; w2 <= wCnt.get(1); w2++) {
                for (int w3 = 0; w3 <= wCnt.get(2); w3++) {
                    for (int w4 = 0; w4 <= wCnt.get(3); w4++) {
                        // System.out.printf("w1 %d w2 %d w3 %d w4 %d %n", w1, w2, w3, w4);
                        long wsum = w1 * wList.get(0) + w2 * wList.get(1) + w3 * wList.get(2)
                            + w4 * wList.get(3);
                        if (wsum > w) {
                            continue;
                        }
                        ans = Math.max(ans, solve(map, wList, w1, w2, w3, w4));
                    }
                }
            }
        }
        System.out.println(ans);
    }
    public static long solve(
        Map<Long, List<Long>> map, List<Long> wList, int w1, int w2, int w3, int w4) {
        long ans = 0;

        for (int i = 1; i <= w1; i++) {
            ans += map.get(wList.get(0)).get(i - 1);
        }
        for (int i = 1; i <= w2; i++) {
            ans += map.get(wList.get(1)).get(i - 1);
        }
        for (int i = 1; i <= w3; i++) {
            ans += map.get(wList.get(2)).get(i - 1);
        }
        for (int i = 1; i <= w4; i++) {
            ans += map.get(wList.get(3)).get(i - 1);
        }
        return ans;
    }
}


Measured memory_bytes: 24700
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 2e5+5




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

       int h;
       cin >> h;
       int x=log2(h);
       int ans=pow(2,x+1)-1;
       cout << ans << '\n';
        
        

}

Measured memory_bytes: 384
n = int(input())
ps = [int(elem) for elem in input().split()]

cnt = 0
for a, b, c in zip(ps[:-2], ps[1:-1], ps[2:]):
    lst = sorted([a, b, c])
    if lst[1] == b:
        cnt += 1
    else:
        pass
print(cnt)

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

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  for (int i = 0; i < N; ++i) cin >> a.at(i);
  
  for (int i = 0; i < N-1; ++i) {
    for (int j = i+1; j < N; ++j) {
      if (a.at(i) < a.at(j)) {
        int tmp = a.at(i);
        a.at(i) = a.at(j);
        a.at(j) = tmp;
      }
    }
  }

  int alice = 0, bob = 0;
  for (int i = 0; i < N; ++i) {
    if (i % 2 == 0) alice += a.at(i);
    else bob += a.at(i);
  }
  
  if (alice > bob) cout << alice - bob << endl;
  else cout << bob - alice << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
   public static void main(String args[]){
Scanner sc=new Scanner(System.in);
  int N =sc.nextInt();
if(N==1){
System.out.println("Hello World");
  }
else{
int a=sc.nextInt();
int b=sc.nextInt();
System.out.println(a+b);
}
 }
  }

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

const int INF=1e9;
struct R2{int y,x,UDLW;};

signed main(){
  int h,w,k;cin>>h>>w>>k;
  vector<vector<int>> d(h,vector<int>(w,INF));
  queue<R2>que;
  int x1,y1,x2,y2;cin>>y1>>x1>>y2>>x2;y1--;x1--;y2--;x2--;
  int sy,sx,gy,gx;
  if(rand()&1)sy=y1,sx=x1,gy=y2,gx=x2;
  else sy=y2,sx=x2,gy=y1,gx=x1;
  d[sy][sx]=0;que.push({sy,sx,0});
  vector<string> s(h);
  for(int i=0;i<h;i++)cin>>s[i];
  while(que.size()){
    R2 p=que.front();que.pop();
    if(p.UDLW!=1)
      for(int i=1;i<=k;i++){
        if(p.y+i>=h||s[p.y+i][p.x]=='@')break;
        if(d[p.y+i][p.x]>d[p.y][p.x]+1){
          d[p.y+i][p.x]=d[p.y][p.x]+1;
          que.push({p.y+i,p.x,2});
        }
      }
    if(p.UDLW!=2)
      for(int i=1;i<=k;i++){
        if(p.y-i<0||s[p.y-i][p.x]=='@')break;
        if(d[p.y-i][p.x]>d[p.y][p.x]+1){
          d[p.y-i][p.x]=d[p.y][p.x]+1;
          que.push({p.y-i,p.x,1});
        }
      }
    if(p.UDLW!=4)
      for(int i=1;i<=k;i++){
        if(p.x+i>=w||s[p.y][p.x+i]=='@')break;
        if(d[p.y][p.x+i]>d[p.y][p.x]+1){
          d[p.y][p.x+i]=d[p.y][p.x]+1;
          que.push({p.y,p.x+i,3});
        }
      }
    if(p.UDLW!=3)
      for(int i=1;i<=k;i++){
        if(p.x-i<0||s[p.y][p.x-i]=='@')break;
        if(d[p.y][p.x-i]>d[p.y][p.x]+1){
          d[p.y][p.x-i]=d[p.y][p.x]+1;
          que.push({p.y,p.x-i,4});
        }
      }
    if(d[gy][gx]!=INF)break;
  }
  cout<<(d[gy][gx]==INF?-1:d[gy][gx])<<endl;
}


Measured memory_bytes: 11180
/*Allah Vorosha*/
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define n_p next_permutation
#define p_p prev_permutation
#define in insert
#define rev reverse
#define pf push_front
#define pob pop_back
#define uniq(v)         v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define all(x) (x).begin(),(x).end()
#define pof pop_front
#define ios ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define scn scanf
#define prt printf
#define rep(i, a, n) for(int i = a; i < n; i++)
#define mod 720720
#define yes cout << "Yes\n"
#define no cout << "NO\n";
#define take for(auto &it : a) cin >> it;
#define out cout << a << "\n";
#define l_b lower_bound
#define u_b upper_bound
#define Max 100005
template<typename T> T mymax(T x, T y) {
    return (x > y ? x : y);
}

using namespace std;

const int N = 100005;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<ll> a(n);
    take;
    sort(all(a));
    ll ans = 0;
    priority_queue<ll> pq;
    for(ll x : a) {
        pq.push(x);
    }
    while(1) {
        ll top = pq.top();
        pq.pop();
        top /= 2;
        m--;
        pq.push(top);
        if(!m) {
            break;
        }
    }
    while(!pq.empty()) {
        ans += pq.top();
        pq.pop();
    }
    cout << ans << '\n';
    return;
}

int main() {
    /*int tc;
    scanf("%d", &tc);
    while(tc-- > 0)*/
    solve();
    return 0;
}


Measured memory_bytes: 5084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
const ll INF=1e9+7;
const ll N = 200002;
string s;
string ans[5];
set<string> se;
ll k;

void cange(string q){
	if(se.count(q)==1)return;
	se.insert(q);
	if(q<ans[0]){
		ans[4]=ans[3];
		ans[3]=ans[2];
		ans[2]=ans[1];
		ans[1]=ans[0];
		ans[0]=q;
	}else if(ans[1]>q){
		ans[4]=ans[3];
		ans[3]=ans[2];
		ans[2]=ans[1];
		ans[1]=q;
	}else if(ans[2]>q){
		ans[4]=ans[3];
		ans[3]=ans[2];
		ans[2]=q;
	}else if(ans[3]>q){
		ans[4]=ans[3];
		ans[3]=q;
	}else if(ans[4]>q){
		ans[4]=q;
	}
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>s>>k;
	FOR(i,0,5){
		ans[i]="zzzzz";
	}
	FOR(i,0,s.size()){
		FOR(j,1,6){
			if(i+j<=s.size()){
				cange(s.substr(i,j));
			}
		}
	}
	cout<<ans[k-1]<<endl;
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 220000
#define mod 1000000007
#define pi 3.141592653589793238
#define sin(s) scanf("%lld",&s);
#define sout(s) printf("%lld\n",s);
#define in(s) cin>>s
#define in2(a,b) cin>>a>>b
#define in3(a,b,c) cin>>a>>b>>c
#define vll vector<ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define sp ' '
#define gear_change ios_base::sync_with_stdio(false),cin.tie(0)
#define nfl(i,n) for(i=0;i<n;i++)
#define sfl(i,s,e) for(i=s;i<e;i++)
#define ufl(i,n) for(i=n-1;i>=0;i--)
ll power(ll x,ll y){
    ll ret=1;
    while(y>0){
        if(y&1)
            ret=(ret*x);
        y/=2;
        x=(x*x);
    }
    return ret;
}
vector<ll> divs(ll n){
	vector<ll>ret;
	for(int i=1;i*i<=n;i++){
		if(n%i==0){
			if(i*i==n){
				ret.push_back(i);
			}
			else{
				ret.push_back(i);
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}
vector<ll>vec(100);
ll get(ll i,ll n){
	if(i==0){
		if(vec[i]<vec[i+1]){
			return 0;
		}
	}
	if(i==n-1){
		return -1;
	}
	ll j;
	for(j=i;j<n;j++){
		if(vec[j]<=vec[j+1] && vec[j]<=vec[j-1]){
			return j;
		}
	}
	return -1;
}
ll get2(ll i,ll n){
	if(i==n-1){
		if(vec[i]>vec[i-1]){
			return n-1;
		}
	}
	if(i==0){
		return -1;
	}
	ll j;
	for(j=i;j<n;j++){
		if(vec[j]>=vec[j+1] && vec[j]>=vec[j-1]){
			return j;
		}
	}
	return -1;
}
void solve(){
	ll n,i,j;
	string s,t;
	cin>>s>>t;
	ll ans=INT_MAX;
	for(i=0;i<s.length()-t.length()+1;i++){
		ll temp=0;
		for(j=0;j<t.length();j++){
			temp+=s[i+j]!=t[j];
		}
		ans=min(ans,temp);
	}
	cout<<ans<<endl;
}	
int main(){
	gear_change;
	ll test=1;
	// in(test);
	while(test--){
		solve();
	}
}	


Measured memory_bytes: 3600
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
#define ll long long int
using namespace std;

int main() {
	int n;
	int a, b;
	a = b = 0;
	int x[100];
	cin >> n;
	lp(n)
		cin >> x[i];
	sort(x, x + n);
	for (int i = n - 1; i >= 0; i--) {
		if (i % 2 == (n - 1) % 2)a += x[i];
		else b += x[i];
	}
	cout << a - b << endl;
	return 0;
}

Measured memory_bytes: 256
L = input()
L_bi = L
keta = len(L)
mod = 1000000007

dp = [[0 for _ in range(2)] for _ in range(1000002)]
dp[0][1]=1

for i in range(len(L_bi)):
    for j in range(2):
        if j == 1:
            scale = 2
        else:
            scale = 1
        dp[i+1][0] = (dp[i+1][0] + scale*dp[i][0])%mod
        if int(L_bi[i]) > j:
            dp[i+1][0] = (dp[i+1][0] + scale*dp[i][1])%mod
        elif int(L_bi[i]) == j:
            dp[i+1][1] = (dp[i+1][1] + scale*dp[i][1])%mod
print((dp[len(L_bi)][0]+dp[len(L_bi)][1])%mod)

Measured memory_bytes: 243500
a,b,c,x = map(int,[input() for i in range(4)])
ans = 0
for i in range(a+1):
  for j in range(b+1):
    for k  in range(c+1):
      if i *500 + j *100 +k*50 ==x:
        ans += 1             
print(ans)

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



int main() {
ll N, K;
cin >> N >> K;
vector<ll> tree(N);

for(int i = 0; i < N; i++){
cin >> tree[i];
}
sort(tree.begin(),tree.end());
reverse(tree.begin(),tree.end());
ll mi = 1000000000009;
for(int i = 0; i < N-K+1; i++){
ll kari = tree[i] - tree[i+K-1];
mi = min(mi, kari);

}
cout << mi << endl;

}


Measured memory_bytes: 1024
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

[[maybe_unused]] constexpr ll LL_MAX = numeric_limits<ll>::max();
[[maybe_unused]] constexpr ll LL_MIN = numeric_limits<ll>::min();
[[maybe_unused]] constexpr ull ULL_MAX = numeric_limits<ull>::max();

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

template <typename T>
void chmin(T& x, T y) {
    x = min(x, y);
}

template <typename T>
void chmax(T& x, T y) {
    x = max(x, y);
}

ll csum(ll x, ll y) {
    if (x > 0 && y > 0 && x > LL_MAX - y) {
        return LL_MAX;
    }
    if (x < 0 && y < 0 && x < LL_MIN - y) {
        return LL_MIN;
    }
    return x + y;
}

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

int main() {
    ll K;
    cin >> K;
    ll A, B;
    cin >> A >> B;
    rep(i,A,B+1) {
        if (i % K == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}


Measured memory_bytes: 3068
#include<vector>
#include<iostream>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

const int N = 100000;
const int inf = 2*N;
int dp[2][9][9][N];//left,right,now

int isok(int l,int r){
  return l%3 <= r%3;
}

int solve(int prev,int l,int r,int now,const string &in){
  if (now == in.size())return 0;
  int &ret = dp[prev][l][r][now];
  if (ret != -1)return ret;
  ret=inf;
  int pl=now==0?0:(prev==0?1:0);//
  int pr=now==0?0:(prev==1?1:0);
  if (isok(in[now]%3,r%3)){
    ret=min(ret,pl+solve(0,in[now],r,now+1,in));
  }
  if (isok(l%3,in[now]%3)){
    ret=min(ret,pr+solve(1,l,in[now],now+1,in));
  }
  //cout << prev <<" " << 1+l<<" " << 1+r << " " << now <<" " << (int)1+in[now] << " " << 
  //pl <<" " << pr <<" " << ret << endl;
  return ret;
}

main(){
  string in;
  while(cin>>in){
    if (in=="#")break;
    rep(i,in.size())in[i]=in[i]-1-'0';
    rep(ii,2)rep(i,9)rep(j,9)rep(k,in.size())dp[ii][i][j][k]=-1;
    int ans = N;

    rep(i,9){
      rep(j,9){
	if (isok(i%3,j%3)){
	  ans=min(ans,solve(0,i,j,0,in));
	  ans=min(ans,solve(1,i,j,0,in));
	}
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        int c = stdIn.nextInt();
        if(a==7&&b==5&&c==5) {
            System.out.println("YES");
        } else if (a==5&&b==7&&c==5) {
            System.out.println("YES");
        } else if (a==5&&b==5&&c==7) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 26908
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
typedef long long ll;
const int N =1e5+6;
const int mod = 1e9+7;
ll po(ll a,ll b){
    if(b==0)return 1;
    ll x = po(a,b/2);
    x = (x*x)%mod;
    if(b&1)x = (x*a)%mod;
    return x;
}
void solve(){
   ll n,a,b;;
   cin>>n>>a>>b;
   ll ans = po(2,n);
   ll trt1 = 1;
   for(int i=0;i<a;i++){
        trt1*=(n-i);
        trt1%=mod;
   }
   ll trt2 = 1;
   for(int i=1;i<=a;i++){
        trt2*=(i);
        trt2%=mod;
   }
   trt2 = po(trt2,mod-2);
   trt1 = (trt1*trt2)%mod;
   ans = ((ans-trt1)%mod+mod)%mod;
   trt1 = 1;
   for(int i=0;i<b;i++){
        trt1*=(n-i);
        trt1%=mod;
   }
   trt2 = 1;
   for(int i=1;i<=b;i++){
        trt2*=(i);
        trt2%=mod;
   }
   trt2 = po(trt2,mod-2);
   trt1 = (trt1*trt2)%mod;
   ans = ((ans-trt1-1)%mod+mod)%mod;
   cout<<ans<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t = 1;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 3608
from collections import deque

H, W = map(int, input().split())
field = [input() for _ in range(H)]
MOVE = [(0, 1), (0, -1), (1, 0), (-1, 0)]

def dfs(h, w):
    q = deque([(0, (h, w))])
    visited = [[-1] * W for _ in range(H)]
    count = -1
    
    while q:
        count, (y, x) = q.popleft()
        # 訪問済みならskip
        if visited[y][x] != -1:
            continue
        # 訪問済みにする
        visited[y][x] = count

        for a, b in MOVE:
            next_x = x + a
            next_y = y + b
            # グリッドの外ならskip
            if next_x < 0 or next_x >= W or next_y < 0 or next_y >= H:
                continue
            # 訪問済みならskip
            if visited[next_y][next_x] != -1:
                continue
            # # 壁ならskip
            if field[next_y][next_x] == '#':
                continue
            q.append((count + 1, (next_y, next_x)))
    return count


def solve():
    ans = 0
    for h in range(H):
        for w in range(W):
            if field[h][w] == '#':
                continue
            count = dfs(h, w)
            ans = max(ans, count)
    return ans

print(solve())



Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int X;
  int ans = 0;

  cin >> X;

  if(X == 3 || X == 5 || X == 7){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;

  }

}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
dic={}
for i in a:
	if i-1 in dic:
		dic[i-1]+=1
	else:
		dic[i-1]=1
	if i in dic:
		dic[i]+=1
	else:
		dic[i]=1
	if i+1 in dic:
		dic[i+1]+=1
	else:
		dic[i+1]=1
print(max(dic.values()))

Measured memory_bytes: 61676
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <numeric>
#include <iterator>
#include <fstream>

#define SIZE 100005
#define MOD 1000000007

using namespace std;

#define p pair<int64_t, int64_t>

class BRobotArms {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int64_t n;
    cin >> n;
    vector<pair<int64_t, int64_t>> v;
    for (int i = 0; i < n; ++i) {
      int x, l;
      cin >> x >> l;
      v.emplace_back(x, l);
    }
    sort(v.begin(), v.end(), [](p a, p b) { return a.first < b.first; });
    int64_t prev = v[0].first + v[0].second;
    int count = n;
    for (int i = 1; i < n; ++i) {
      int64_t now = v[i].first - v[i].second;
      if (prev > now) {
        count--;
        prev = min(prev, v[i].first + v[i].second);
      }else{
        prev = max(prev, v[i].first + v[i].second);
      }
    }
    cout << count << endl;

  }
};


int main() {
    BRobotArms solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 2420
n = int(input())
s = list()
for i in range(n):
    s.append(input())

ans = ""
for c in "abcdefghijklmnopqrstuvwxyz":
    c_min = list()
    for ss in s:
        cnt = 0
        for cc in ss:
            if cc == c:
                cnt += 1
        c_min.append(cnt)
    ans += c*min(c_min)
    
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <map>

using namespace std;

main(){
  while(1){
    map<char,char> m;
    int n;

    char a,b;
    scanf("%d", &n);

    if(n==0) break;

    for(int i=0;i<n;i++){
      scanf(" %c %c", &a, &b);
      m.insert(pair<char,char>(a,b));
    }

    scanf("%d", &n);

    for(int i=0;i<n;i++){
      scanf(" %c", &a);
      if(m.find(a) != m.end()){
        printf("%c", m[a]);
      }else{
        printf("%c", a);
      }
    }

    puts("");
  }
}

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

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

int F[100][10];
int P[100][11];
bool OPEN[10] = { false };

int main()
{
	int N, ans = -1000000000;

	(void)scanf("%d", &N);
	rep(i, N) rep(j, 10) (void)scanf("%d", &F[i][j]);
	rep(i, N) rep(j, 11) (void)scanf("%d", &P[i][j]);

	while (true) {
		int sum = 0;
		bool end = true;

		rep(i, 10) {
			if (OPEN[i]) OPEN[i] = false;
			else {
				OPEN[i] = true;
				break;
			}
		}
		rep(i, 10) if (!OPEN[i]) end = false;

		rep(i, N) {
			int cnt = 0;
			rep(j, 10) if (F[i][j] == 1 && OPEN[j]) cnt++;
			sum += P[i][cnt];
		}

		ans = max(ans, sum);
		if (end) break;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class169
    {
        static void Main()
        {
            var NK = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = NK[0], K = NK[1];
            var RSP = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int R = RSP[0], S = RSP[1], P = RSP[2];
            string T = Console.ReadLine();

            long ans = 0;
            char[] dp = new char[N];
            for(int i = 0; i < N; i++)
            {
                if (T[i] == 'r')
                {
                    if (i - K >= 0)
                    {
                        if (dp[i - K] == 'p')
                        {
                            dp[i] = 'f';
                            continue;
                        }
                    }
                    ans += P;
                    dp[i] = 'p';
                }
                if (T[i] == 's')
                {
                    if (i - K >= 0)
                    {
                        if (dp[i - K] == 'r')
                        {
                            dp[i] = 'f';
                            continue;
                        }
                    }
                    ans += R;
                    dp[i] = 'r';
                }
                if (T[i] == 'p')
                {
                    if (i - K >= 0)
                    {
                        if (dp[i - K] == 's')
                        {
                            dp[i] = 'f';
                            continue;
                        }
                    }
                    ans += S;
                    dp[i] = 's';
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13664
/**
 * @Author:      H S-J
 * @DateTime:    2017-11-04 20:01:08
 * @Description: 
 */
#include <bits/stdc++.h>
using namespace std;
#define MST(a, b) memset(a, b, sizeof(a));
#define CLR(a) MST(a, 0);
#define DBG(x) cout << '#' << " = " << (x) << endl;
#define ALL(x) x.begin(), x.end()
#define INS(x) inserter(x, x.begin())
#define lson(x) (x) << 1
#define rson(x) (x) << 1|1
#define pb push_back
#define rep(x, y, z) for (int x = y; x < z; ++x)
#define ech(x, y, z) for (auto x = z.begin(), y = z.end(); x != y; ++x)
#define lowbit(x) (x & (-x))
#define opr operator
#define _st first
#define _nd second
#define prior_q1(x) priority_queue<x>
#define prior_q2(x) priority_queue<x, vector<x>, greater<x> >
typedef long long LL;
typedef stringstream strstm;
struct FastIO {
    static const int S = 1310720;
    int wpos;
    char wbuf[S];
    FastIO() : wpos(0) {}
    inline int xchar() {
        static char buf[S];
        static int len = 0, pos = 0;
        if (pos == len)
            pos = 0, len = fread(buf, 1, S, stdin);
        if (pos == len) return -1;
        return buf[pos ++];
    }
    inline int xuint() {
        int c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x;
    }
    inline int xint() {
        int s = 1, c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        if (c == '-') s = -1, c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x * s;
    }
    inline LL xlongint() {
        LL s = 1, c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        if (c == '-') s = -1, c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x * s;
    }
    inline void xstring(char *s) {
        int c = xchar();
        while (c <= 32) c = xchar();
        for (; c> 32; c = xchar()) * s++ = c;
        *s = 0;
    }
    inline void wchar(int x) {
        if (wpos == S) fwrite(wbuf, 1, S, stdout), wpos = 0;
        wbuf[wpos ++] = x;
    }
    inline void wint(LL x) {
        if (x < 0) wchar('-'), x = -x;
        char s[24];
        int n = 0;
        while (x || !n) s[n ++] = '0' + x % 10, x /= 10;
        while (n--) wchar(s[n]);
    }
    inline void wstring(const char *s) {
        while (*s) wchar(*s++);
    }
    ~FastIO() {
        if (wpos) fwrite(wbuf, 1, wpos, stdout), wpos = 0;
    }
} io;
char s[11][11];
bool cmp() {
    if(s[1][1] != s[2][3]) return false;
    if(s[2][1] != s[1][3]) return false;
    if(s[1][2] != s[2][2]) return false;
    return true;
}
int main(int argc, char const *argv[]) {
	ios::sync_with_stdio(0);cin.tie(0);
	while (cin >> s[1]+1 >> s[2]+1) {
        if(cmp()) cout << "YES" << endl;
        else cout << "NO" << endl;
	}
	return 0;
}

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

using namespace std;

struct StringPermutation {
    vector<long long> fact;

    StringPermutation() {
        fact.resize(21);
        fact[0] = 1;
        for (int i = 1; i <= 20; i++)
            fact[i] = fact[i-1] * i;
    }

    long long query_multiple_combination_value(const vector<int>& A) {
        int total = 0;
        for (auto a: A)
            total += a;
        long long ans = fact[total];
        for (auto a: A)
            ans /= fact[a];
        return ans;
    }

    long long query_string_combination_value(const string& str, int left, int right) {
        map<char, int> M;
        vector<int> A;
        for (int i = left; i <= right; i++)
            M[str[i]]++;
        for (auto p: M)
            A.push_back(p.second);
        return query_multiple_combination_value(A);
    }

    string query_kth_string(string str, long long m) {
        int n = str.size();
        long long cnt = 0;
        vector<long long> A(n);
        for (int i = 0; i < n; i++) {
            sort(str.begin() + i, str.end());
            for (int j = i; j < n; j++) {
                if (j == i || str[j] != str[j-1]) {
                    swap(str[i], str[j]);
                    long long val = query_string_combination_value(str, i + 1, n - 1);
                    A[j] = val;
                    swap(str[i], str[j]);
                } else {
                    A[j] = 0;
                }
            }
            for (int j = i + 1; j < n; j++) {
                A[j] += A[j-1];
            }
            auto itr = lower_bound(A.begin() + i, A.end(), m - cnt);
            int j = itr - A.begin();
            if (str[j] != str[i])
                cnt += A[j-1];
            swap(str[i], str[j]);
        }
        return str;
    }

    long long query_string_index(string str) {
        long long ans = 1;
        int n = str.size();
        for (int i = 0; i < n; i++) {
            set<char> S;
            for (int j = i + 1; j < n; j++) {
                if (str[j] < str[i]) {
                    S.insert(str[j]);
                }
            }
            for (int j = i + 1; j < n; j++) {
                if (S.count(str[j])) {
                    swap(str[i], str[j]);
                    ans += query_string_combination_value(str, i + 1, n - 1);
                    swap(str[i], str[j]);
                    S.erase(str[j]);
                }
            }
        }
        return ans;
    }
};

StringPermutation string_perm;

int solve(string& str1, string& str2) {
    int a = string_perm.query_string_index(str1);
    int b = string_perm.query_string_index(str2);
    return abs(a - b);
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    string str1, str2;
    cin >> n;
    for (int i = 0; i < n; i++) {
        char ch;
        cin >> ch;
        str1.push_back(ch);
    }
    for (int i = 0; i < n; i++) {
        char ch;
        cin >> ch;
        str2.push_back(ch);
    }
    cout << solve(str1, str2) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

const int N = (int)1e6 + 77;
char s[N];
int n;

void fix(int &l1, int &r1, int &l2, int &r2, int B) {
	l1 = max(l1, 0);
	l2 = max(l2, 0);
	r1 = min(r1, B);
	r2 = min(r2, B);
	if (l1 % 2 != 0) l1++;
	if (l2 % 2 != 1) l2++;
	if (r1 % 2 != 0) r1--;
	if (r2 % 2 != 1) r2--;
}

bool solve(int B) {
	int l1 = 0, l2 = 0, r1 = B, r2 = B;
	fix(l1, r1, l2, r2, B);
	for (int i = 0; i < n; i++) {
		fix(l1, r1, l2, r2, B);
		if (l1 > r1) {
			l1 = N;
			r1 = -N;
		}
		if (l2 > r2) {
			l2 = N;
			r2 = -N;
		}
		fix(l1, r1, l2, r2, B);
		swap(l1, l2);
		swap(r1, r2);
		if (s[i] == '0') {
			l1--;
			l2--;
			r1--;
			r2--;
		} else if (s[i] == '1') {
			l1++;
			l2++;
			r1++;
			r2++;
		} else if (s[i] == '?') {
			l1--;
			l2--;
			r1++;
			r2++;
		} else throw;
	}
	fix(l1, r1, l2, r2, B);
	return l1 <= r1 || l2 <= r2;
}

int main()
{
	startTime = clock();
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%s", s);
	n = strlen(s);
	int l = -1, r = n;
	while(r - l > 1) {
		int x = (l + r) / 2;
		if (solve(x))
			r = x;
		else
			l = x;
	}
	printf("%d\n", r);

	return 0;
}


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

int main() {
  int n, m;
  map<string, int> mp;

  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    mp[s]++;
  }

  cin >> m;
  for (int i = 0; i < m; i++) {
    string t;
    cin >> t;
    mp[t]--;
  }

  int max = 0;
  for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
    if (itr->second > max) {
      max = itr->second;
    }
  }

  cout << max << endl;
  return 0;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
  
  //スペース区切り　input[0] が tmp[0], tmp[1],...
	tmp = input[0].split(" ");
  
  //この時点では全部文字列（数値に変換しないといけない）

	//文字列から10進数に変換するときはparseIntを使います
	var r = parseInt(tmp[0], 10);
	var g = parseInt(tmp[1], 10);
	var b = parseInt(tmp[2], 10);
	var s = 100*r + 10*g + b; 
	//出力
    if(s%4 == 0){
      console.log('%s', 'YES');
    }else{
      console.log('%s', 'NO');
    }
  
  //%は符号付き10進数, %sは文字列
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
# -*- coding: utf-8 -*-
import sys
from math import sqrt
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    s=set()
    for i in range(1,int(sqrt(N))+1):
        if (N-1)%i==0:
            s.add(i)
            s.add((N-1)//i)
        else:
            if N%i==0:
                tmp=N
                while True:
                    if tmp%i==0:
                        tmp//=i
                    else:
                        tmp-=tmp//i*i
                    if tmp==1:
                        s.add(i)
                        break
                    if tmp<i:
                        break
    print(len(s))

if __name__ == '__main__':
    main()


Measured memory_bytes: 39536
#include <stdio.h>

int main(int argc, char **argv)
{
    int x, a, b;
    scanf("%d %d %d", &x, &a, &b);

    if (b-a < 1) {
        puts("delicious");
    } else {
        if (b-a > x) {
            puts("dangerous");
        } else {
            puts("safe");
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
string s,t, u;
int a,b;

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

  cin >> s>>t;
  cin >> a >> b;
  cin >> u;
  if (s==u) {
    cout << a-1 << ' ' << b << "\n";
  } else {
    cout << a << ' ' << b-1 << "\n";
  }

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 100005
#define NIL -1

struct node{
  int p;
  int l;
  int r;
};
struct node T[MAX];
int n,D[MAX];

void print(int u){
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if(T[u].p==NIL)printf("root, [");
  else if(T[u].l==NIL)printf("leaf, [");
  else printf("internal node, [");

  for(i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
    if(i!=0){
      printf(", ");
    }
    printf("%d",c);
  }
  printf("]\n");
}

int rec(int u,int p){
  D[u]=p;
  if(T[u].r!=NIL)rec(T[u].r,p);
  if(T[u].l!=NIL)rec(T[u].l,p+1);
}

int main(){
  int i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=NIL;
    T[i].r=NIL;
    T[i].l=NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0){
	T[v].l=c;
      }
      else{
	T[l].r=c;
      }
      l=c;
      T[c].p=v;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].p==NIL)r=i;
  }

  rec(r,0);
  for(i=0;i<n;i++){
    print(i);
  }
  return 0;
}



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

#define ll   long long int
#define PI 3.14159265358979
#define zig ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;


int main()
{
    zig
    string s;
    cin>>s;
    map<char, int> mp;
    set<char> st;
    bool flag=false;
    for(char a:s)
    {
        mp[a]++;
        st.insert(a);
    }
    for(auto i:st)
    {
        if(mp[i]%2)
        {
            flag=true;
            break;
        }
    }
    (flag)?cout<<"No":cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
#include <fstream>
#include <sstream>
#include <string>
#include <time.h>
#include <math.h>

using namespace std;

int main() {
  int N;
  cin >> N;
  string s;
  cin >> s;
  vector<bool> hituzi(N+1);
  bool check = false;
  hituzi[0] = true;
  hituzi[1] = true;
  for(int i=1; i<N; i++) {
    if(hituzi[i]) {
      if(s[i] == 'o') {
        hituzi[i+1] = hituzi[i-1];
      }else{
        hituzi[i+1] = !hituzi[i-1];
      }
    }else{
      if(s[i] == 'o') {
        hituzi[i+1] = !hituzi[i-1];
      }else{
        hituzi[i+1] = hituzi[i-1];
      }
    }
  }
  if(hituzi[0] == hituzi[N]) {
    if(s[0] == 'o' && hituzi[1] == hituzi[N-1])check = true;
    if(s[0] == 'x' && hituzi[1] != hituzi[N-1])check = true;
  }
  if(!check) {
    hituzi[0] = true;
    hituzi[1] = false;
    for(int i=1; i<N; i++) {
      if(hituzi[i]) {
        if(s[i] == 'o') {
          hituzi[i+1] = hituzi[i-1];
        }else{
          hituzi[i+1] = !hituzi[i-1];
        }
      }else{
        if(s[i] == 'o') {
          hituzi[i+1] = !hituzi[i-1];
        }else{
          hituzi[i+1] = hituzi[i-1];
        }
      }
    }
    if(hituzi[0] == hituzi[N]) {
      if(s[0] == 'o' && hituzi[1] == hituzi[N-1])check = true;
      if(s[0] == 'x' && hituzi[1] != hituzi[N-1])check = true;
    }
  }
  if(!check) {
    hituzi[0] = false;
    hituzi[1] = true;
    for(int i=1; i<N; i++) {
      if(hituzi[i]) {
        if(s[i] == 'o') {
          hituzi[i+1] = hituzi[i-1];
        }else{
          hituzi[i+1] = !hituzi[i-1];
        }
      }else{
        if(s[i] == 'o') {
          hituzi[i+1] = !hituzi[i-1];
        }else{
          hituzi[i+1] = hituzi[i-1];
        }
      }
    }
    if(hituzi[0] == hituzi[N]) {
      if(s[0] == 'o' && hituzi[1] != hituzi[N-1])check = true;
      if(s[0] == 'x' && hituzi[1] == hituzi[N-1])check = true;
    }
  }
  if(!check) {
    hituzi[0] = false;
    hituzi[1] = false;
    for(int i=1; i<N; i++) {
      if(hituzi[i]) {
        if(s[i] == 'o') {
          hituzi[i+1] = hituzi[i-1];
        }else{
          hituzi[i+1] = !hituzi[i-1];
        }
      }else{
        if(s[i] == 'o') {
          hituzi[i+1] = !hituzi[i-1];
        }else{
          hituzi[i+1] = hituzi[i-1];
        }
      }
    }
    if(hituzi[0] == hituzi[N]) {
      if(s[0] == 'o' && hituzi[1] != hituzi[N-1])check = true;
      if(s[0] == 'x' && hituzi[1] == hituzi[N-1])check = true;
    }
  }
  if(check){
    for(int i=0; i<N; i++) {
      if(hituzi[i]) cout << "S";
      else cout << "W";
    }
    cout << endl;
  }else{
    cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>

struct StrComp {
  bool operator()(const std::string& lhs, const std::string rhs) {
    if(lhs.length() < rhs.length()) {
      return true;
    }

    if(lhs.length() > rhs.length()) {
      return false;
    }

    for(size_t i=0; i<lhs.length(); ++i) {
      if(lhs[i] < rhs[i]) {
        return true;
      }

      if(lhs[i] > rhs[i]) {
        return false;
      }
    }

    return false;
  }
};

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

  int n,l;
  std::cin >> n >> l;
  std::vector<std::string> sv;
  std::string s;

  for(int i=0; i<n; ++i) {
    std::cin >> s;
    sv.push_back(s);
  }

  std::sort(sv.begin(), sv.end(), StrComp());

  for(auto v : sv) {
    std::cout << v;
  }
  std::cout << std::endl;

  return 0;
}


Measured memory_bytes: 256