akhauriyash/Code-Regression huggingface dataset:
/*
Hey there stalker....

█▀▀▄░░░░░░░░░░░▄▀▀█
░█░░░▀▄░▄▄▄▄▄░▄▀░░░█
░░▀▄░░░▀░░░░░▀░░░▄▀
░░░░▌░▄▄░░░▄▄░▐▀▀
░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█
░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█
▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█
█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀
░▀▄░░▀░░▀▀▀░░▀░░░▄█▀
░░░█░░░░░░░░░░░▄▀▄░▀▄
░░░█░░░░░░░░░▄▀█░░█░░█
░░░█░░░░░░░░░░░█▄█░░▄▀
░░░█░░░░░░░░░░░████▀
░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀

Like what you see?
*/
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pii         pair<ll ,ll>
#define vi          vector<ll>
#define present(container, element) (container.find(element) != container.end()) /* For set n maps */
#define cpresent(container, element) (find(all(container),element) != container.end()) /* For vectors */
#define all(a)      (a).begin(),(a).end()
#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define inset(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.I(tmp);commands}
#define F           first
#define S           second
#define I           insert
#define sz(x)       (ll)x.size()
#define rep(i,a,b)    for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define trav(a, x) 	for(auto& a : x)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lcase(a) (char)tolower(a)
#define ll long long int
#define lld long double
#define endl "\n"
#define PI 3.14159265358979323844
#define MOD 1000000007
#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)
#define mod 1e9 + 7
/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

int main()
{
   IOS

    int TESTS=1;
    //cin >> TESTS;
    while (TESTS--)
    {
        ll n,k;
        cin >> n >> k;
        vi v(n);
        rep(i,0,n)
        {
            cin>> v[i];
        }
        sort(v.begin(),v.end());
        ll ans=0;
        for(int i=0;i<n &&k!=0 ;i++)
        {
            ans+=v[i];
            k--;
        }
        cout<< ans << endl;



    }
    return 0;
}


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

int main()
{  
    int n;
    cin>>n;
    set<int>s;
    REP(i,n)
    {
        int x,y;
        cin>>x>>y;
        if(x==0){s.insert(y);cout<<s.size()<<endl;}
        if(x==1)cout<<s.count(y)<<endl;
        if(x==2)
        {
            if(s.find(y)!=s.end())s.erase(y);
        }
    }
}



Measured memory_bytes: 12372
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> vpll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define yes(a) printf(a ? "yes\n" : "no\n")
#define Yes(a) printf(a ? "Yes\n" : "No\n")
#define YES(a) printf(a ? "YES\n" : "NO\n") 
const long double PI = acos(-1);
const long long INF = (1 << 30);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll r;
  cin >> r;
  cout << 3 * r * r << endl;
	return 0;
}

Measured memory_bytes: 256
import sys

def solve(m):
    ans=[]
    for i in range(10)[::-1]:
        w=1<<i
        if m==0: break
        if m >= w:
            m-=w
            ans.append(w)

    ans.reverse()
    return " ".join(map(str,ans))

for m in sys.stdin.readlines():
    print solve(int(m.rstrip()))

Measured memory_bytes: 4220
Public Class Main
    Public Shared Sub Main(ByVal args() As String)
        Dim H, A as Integer
        Dim arr(2) as String
        arr = Split(Console.ReadLine())
        H = arr(0) : A = arr(1)
        Console.WriteLine(IIf(H mod A <> 0, Math.Floor(H / A) + 1, H / A))
    End Sub
End Class


Measured memory_bytes: 11488
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, cnt = 0;
    cin >> n;

    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
        if((a.at(i) % 2 == 0) && ((a.at(i) % 3 == 0) || (a.at(i) % 5 == 0))) cnt++;
        else if(a.at(i) % 2 != 0) cnt++;
    }

    if(cnt == n) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
// Problem : N - Slimes
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_n?lang=en
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
#define Ma7moud_7amdy                                                                                                  \
    ios_base::sync_with_stdio(false);                                                                                  \
    cin.tie(NULL);                                                                                                     \
    cout.tie(NULL)
#define Open_Sesame Open()
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define clr(arr, x) memset(arr, x, sizeof arr)
#define endl "\n"
#define watch(x) cout << #x << " = " << x << endl;
#define RT(x) return cout << (x), 0;
#define Accepted 0
typedef long long ll;
typedef vector<int> vi;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
void Open()
{
#ifndef ONLINE_JUDGE
    freopen("Input.txt", "r", stdin);
    freopen("Output.txt", "w", stdout);
#endif
}
const int mod = ll(1e9 + 7), N = 2000 + 5;
//“Nobody but you have to believe in your dreams to make them a reality.” ― Germany Kent
int n;
ll a[401], mem[403][403];
ll solve(int l = 1, int r = n)
{
    if (l == r)
        return 0;

    ll &ret = mem[l][r];
    if (~ret)
        return ret;
    ret = 1e15;
    for (int i = l; i < r; i++)
    {
        ret = min(ret, solve(l, i) + solve(i + 1, r) + a[r] - a[l - 1]);
    }
    return ret;
}
int main()
{
    Ma7moud_7amdy;
    // Open_Sesame;
    clr(mem, -1);
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i], a[i] += a[i - 1];
    cout << solve() << endl;
}


Measured memory_bytes: 4896
#!/usr/bin/env python3

def main():
    n, k = map(int, input().split())
    r, s, p = map(int, input().split())
    t = input()
    c = ""
    ans = 0

    for i in range(n):
        if t[i] == "r":
            if i >= k and c[i-k] == 'p':
                c += 'x'
            else:
                c += "p"
                ans += p
        elif t[i] == "s":
            if i >= k and c[i-k] == 'r':
                c += 'x'
            else:
                c += "r"
                ans += r
        else:
            if i >= k and c[i-k] == 's':
                c += 'x'
            else:
                c += "s"
                ans += s
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9344
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	string s;int k;cin>>k;cin>>s;
	if(s.size()<=k) cout<<s<<endl;
	else cout<<s.substr(0,k)<<"..."<<endl;
}


Measured memory_bytes: 3624
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	static char[][] map = new char[8][8];
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int n = stdIn.nextInt();
			if(n == 0) break;
			char[][] list = new char[n][];
			for(int i = 0; i < n; i++) {
				list[i] = stdIn.next().toCharArray();
			}
			for(int i = 0; i < n; i++) {
				for(int j = 1; j < list[i].length; j++) {
					if(list[i][j] != '.' && list[i][j-1] == '.') {
						for(int k = 0; k < j-1; k++) {
							list[i][k] = ' ';
						}
						list[i][j-1] = '+';
						for(int k = i-1; k >= 0; k--) {
							if(j-1 < list[k].length && list[k][j-1] == ' ') {
								list[k][j-1] = '|';
								continue;
							}
							else {
								break;
							}
						}
						break;
					}
				}
			}
			
			for(int i = 0; i < n; i++) {
				System.out.println(list[i]);
			}

		}
	}
	static char[] retS(char a, int b) {
		char[] tmp = new char[b];
		for(int i = 0; i < b; i++) {
			tmp[i] = ' ';
		}
		return tmp;
	}
}

Measured memory_bytes: 71772
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int dp[100005][14];
string S;
int N;

signed main(){
	cin>>S;
	N=S.size();
	reverse(S.begin(),S.end());
	if(S[0]=='?'){
		REP(i,10){
			dp[0][i]=1;
		}
	}
	else{
		dp[0][S[0]-'0']=1;
	}
	DEB(dp[0][8])END
	int e=1;
	for(int i=1;i<N;i++){
		e*=10;
		e%=13;
		int c=0;
		if(S[i]=='?'){
			c=-1;
		}
		else{
			c=S[i]-'0';
		}
		REP(j,10){
			if(c!=j&&c!=-1)continue;
			int s=(j*e)%13;
			REP(k,13){
				dp[i][(s+k)%13]+=dp[i-1][k];
				dp[i][(s+k)%13]%=MOD;
			}
		}
	}
	int ans=dp[N-1][5];
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 11392
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int M=1e9+7;
int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M

signed main(){
	fast;
	//string s;
	vector<int> v;
	map<int,int> mp;
	int n,m,c=0,t=1;
	//cin>>t;
	while(t--){
		cin>>n>>m>>c;
		cout<<c<<" "<<n<<" "<<m;

	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
const int sz = 2e5+10;

 
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int t;
    t=1;
    // cin>>t;
    for(int cs=1;cs<=t;cs++)
    {
 
        int n;
        cin>>n;
        
        cout<<n+(n*n)+(n*n*n)<<endl;
 
 
 
    }
    return 0;
} 

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <random>




int main() {
	int n, k; std::cin >> n >> k;
	std::vector<int> permutation(n); for (auto& p : permutation) std::cin >> p;
	std::deque<int> min_deque, max_deque;
	for (auto i = 0; i < k; ++i) {
		while (!min_deque.empty() && permutation[min_deque.back()] > permutation[i]) min_deque.pop_back();
		min_deque.push_back(i);
		while (!max_deque.empty() && permutation[max_deque.back()] < permutation[i]) max_deque.pop_back();
		max_deque.push_back(i);
	}
	int result = 1;
	bool has_sorted = (min_deque.size() == k) ? 1 : 0;
	for (auto left = 0; left < n - k; ++left) { 
		auto right = left + k;
		bool changed = false;
		if (min_deque.front() != left) {
			changed = true;
		}
		else {
			min_deque.pop_front();
		}
		if (max_deque.front() == left) max_deque.pop_front();
		while (!min_deque.empty() && permutation[min_deque.back()] > permutation[right]) min_deque.pop_back();
		min_deque.push_back(right);
		while (!max_deque.empty() && permutation[max_deque.back()] < permutation[right]) max_deque.pop_back();
		max_deque.push_back(right);
		if (max_deque.size() != 1) changed = true;
		if (changed) {
			if (!has_sorted || min_deque.size() != k) ++result;
		}
		if (min_deque.size() == k) has_sorted = true;
	}
	std::cout << result << std::endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int n,k,a[222222],b[222222],cf[222222];
int main()
{
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<=k;i++)
	{
		for (int j=1;j<=n;j++) b[j]=a[j];
		memset(cf,0,sizeof(cf));
		for (int j=1;j<=n;j++)
		{
			cf[max(1,j-a[j])]++;
			cf[min(n+1,j+a[j]+1)]--;
		}
		for (int j=1;j<=n;j++) cf[j]+=cf[j-1];
		bool flg=0;
		for (int j=1;j<=n;j++) 
		{
			a[j]=cf[j];
			if (a[j]!=b[j]) flg=1;
		}
		if (!flg) break;
	}
	for (int i=1;i<=n;i++) printf("%d ",a[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 6260
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7

ans = 0
for i in range(60):
    c = sum([1 for ai in a if (ai >> i) & 1])
    ans += (1 << i) * c * (n-c)
    ans %= mod
print(ans)

Measured memory_bytes: 137144
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;

int main(){
	
	double v;
	double t,y;
	double N;
	while(cin>>v){
		t=v/9.8;
		y=4.9*pow(t,2.0);
		N = (y+5)/5;
		if(N>(int)N)
			N=N+1;
		cout<<(int)N<<endl;
	
	}
		
	
}

Measured memory_bytes: 1224
#include <iostream>
#include <cstdio>
#include <cstring>
#define s(i) s[i-1]
#define t(i) t[i-1]
using namespace std;
string s,t;
int F[3005][3005],i,j,n,N;
char A[30005];
void backtrack(int i, int j) {
    if (i == 0 || j == 0) return ;
    if (s(i) == t(j)) {
        A[++N]=s(i);
        backtrack(i-1,j-1);
    } else {
        if (F[i][j-1] > F[i-1][j]) backtrack(i,j-1);
        else backtrack(i-1,j);
    }
}
int main()
{
    //freopen("LCS.inp","r",stdin);
    cin >> s;
    cin >> t;
    int n=s.size();
    int m=t.size();
    for (i = 1; i <= n; i++) {
        for (j = 1; j <= m; j++) {
            if (s(i) == t(j)) {
                F[i][j]=F[i-1][j-1]+1;
            } else {
                F[i][j]=max(F[i-1][j], F[i][j-1]);
            }
        }
    }
    backtrack(n,m);
    for (i = N; i > 0; i--) {
        cout << A[i];
    }
    return 0;
}


Measured memory_bytes: 35456
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

int alpha[26];

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

	int H, W; cin >> H >> W;
	for (int i = 0; i < H*W; i++) {
		char tmp; cin >> tmp;
		alpha[tmp - 'a']++;
	}

	bool flag = true;

	if (H % 2 == 0 && W % 2 == 0) { // 両方偶数
		for (int i = 0; i < 26; i++) {
			if (alpha[i] % 4 != 0) flag = false;
		}
	}
	else if (H % 2 == 0) { // Hが偶数、Wが奇数
		// 4の倍数がH*(W-1)/4個必要
		int cnt = H * (W - 1) / 4;
		for (int i= 0; i < 26; i++) {
			while (cnt > 0 && alpha[i] >= 4) {
				cnt--;
				alpha[i] -= 4;
			}
		}
		if (cnt > 0) flag = false;
		// 残りがすべて偶数なら良い
		for (int i = 0; i < 26; i++) if (alpha[i] % 2 != 0) flag = false;
	}
	else if (W % 2 == 0) {
		// 4の倍数がW*(H-1)/4個必要
		int cnt = W * (H - 1) / 4;
		for (int i= 0; i < 26; i++) {
			while (cnt > 0 && alpha[i] >= 4) {
				cnt--;
				alpha[i] -= 4;
			}
		}
		if (cnt > 0) flag = false;
		// 残りがすべて偶数なら良い
		for (int i = 0; i < 26; i++) if (alpha[i] % 2 != 0) flag = false;
	}
	else { //両方奇数
		//一つだけ4の倍数+1になってて、
		// (H-1)*(W-1)/4個の４の倍数
		int cnt1 = (H - 1)*(W - 1) / 4; // 4の塊の個数
		int cnt2 = (H + W - 2) / 2; // 2の塊の個数

		for (int i = 0; i < 26; i++) {
			while (cnt1 > 0 && alpha[i] >= 4) {
				cnt1--;
				alpha[i] -= 4;
			}
		}

		for (int i = 0; i < 26; i++) {
			while (cnt2 > 0 && alpha[i] >= 2) {
				cnt2--;
				alpha[i] -= 2;
			}
		}
		if (cnt1 != 0) flag = false;
		if (cnt2 != 0) flag = false;
	}
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

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

	map<string, int> m;
	for(int n=0; n<N; n++){
		string S;
		cin >> S;
		if(m[S]){
			m[S]++;
		} else {
			m[S] = 1;
		}
	}

	int maxcount = 0;
	for(auto c : m){
		if(c.second > maxcount){
			maxcount = c.second;
		}
	}
	for(auto c : m){
		if(c.second == maxcount){
			cout << c.first << endl;
		}
	}
}


Measured memory_bytes: 25216
from itertools import permutations
from math import hypot, factorial

n=int(input())
a=[list(map(int,input().split()))for _ in range(n)]
d = lambda x1,y1,x2,y2: ((x1-x2)**2 + (y1-y2)**2)**0.5

x = 0
for i in permutations(a):
	for j in range(n-1):
		x += d(i[j][0],i[j][1], i[j+1][0],i[j+1][1])

#for i in range(n): f*=i+1
print(x / factorial(n))




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

vector< vector<int> > to;
vector<int> ans;

void dfs(int c,int p=-1){
  for(int u:to.at(c)){
    if(u==p){
      continue;
    }
    ans.at(u)+=ans.at(c);
    dfs(u,c);
  }
}
int main(){
  int n,q;
  cin >> n >> q;
  //v.resize(N);
  to.resize(200005);
  for(int i=0;i<n-1;i++){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    to.at(a).push_back(b);
    to.at(b).push_back(a);
  }
  ans.resize(n);
  for(int i=0;i<q;i++){
    int p,x;
    cin >> p >> x;
    p--;
    ans.at(p)+=x;
  }
  dfs(0);
  for(int i=0;i<n;i++){
    cout << ans.at(i) << endl;
  }
  return 0;
}


Measured memory_bytes: 26624
#include <iostream>
//#include <vector>
#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1
//#define INFTY 1000000000000000000

int main(){
    string s;
    cin >> s;
    LL sum=0;
    LL tmp;
    for(LL i=0; i<s.size(); i++){
        tmp=s[i]-'0';
        sum=(sum+tmp)%9;
    }

    if(sum%9==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3696
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

int a[100010];

int main() {
    int h=read(),n=read();
    for (re int i=1;i<=n;++i) a[i]=read();
    sort(a+1,a+n+1); reverse(a+1,a+n+1);
    int s=0;
    for (re int i=1;i<=n;++i) {
        s+=a[i];
        if (s>=h) { puts("Yes"); return 0; }
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 1000000

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll a,b;
    cin>>a>>b;
    ll ans=0;
    for(int i=a;i<=b;i++){
	ll c[5];
	ll x=i;
	for(int j=0;j<5;j++){
	    c[j]=x%10;
	    x/=10;
	}
	if(c[0]==c[4]&&c[1]==c[3])ans++;
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 256
/**
** 
** Last Updated: 2019/06/09 21:06:51 JST
** (c) was
**/
#include <bits/stdc++.h>
using namespace std;

int main() {
  //input
  int p,q,r; cin >> p >> q >> r;
  int ans=1000;
  int tmp1,tmp2,tmp3;
  //compute
  tmp1=p+q;
  tmp2=p+r;
  tmp3=q+r;
  ans=min(tmp1,tmp2);
  ans=min(ans,tmp3);
  //output
  cout << ans << endl;
  return 0;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int h,w;
bool g[50][50];
bool used[50][50];
int dxy[4][2] = {{0,1},{1,0}, {0,-1}, {-1,0}};


int main(){
    cin >> h >> w;
    int black = 0;
    REP(j,h){
        string s;  cin >> s;
        REP(i,w){
            if(s[i]=='.'){
                g[i][j] = 1;
            }else{
                g[i][j] = 0;
                black++;
            }
        }
    }
    queue<PP> bfs;
    bfs.push(make_pair(1,make_pair(0,0)));
    int count = 0;
    while(bfs.size()>0){
        PP now = bfs.front(); bfs.pop();
        int x=now.second.first, y=now.second.second;
        int d= now.first;
        if(x== w-1 && y== h-1){
            count = d;
            break;
        }
        REP(i,4){
            int tox = x+dxy[i][0];
            int toy = y+dxy[i][1];
            if(tox >= 0 && tox < w && toy >= 0 && toy < h && g[tox][toy] && !used[tox][toy]){
                used[tox][toy] = true;
                bfs.push(make_pair(d+1, make_pair(tox,toy)));
            }
        }
    }
    int ans = h*w - black - count;
    if(count==0){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }



}

Measured memory_bytes: 256
n,m = map(int,input().split())
ans_list = ["x"]*n
for i in range(m):
    a,b = map(int,input().split())
    b = str(b)
    #print(ans_list)
    if ans_list[a-1] != b and ans_list[a-1] != "x":
        print(-1)
        exit()
    else:
        ans_list[a-1] = b
if ans_list[0] == "0" and n != 1:
    print(-1)
    exit()
#print(ans_list)
if ans_list[0] == "x" and n != 1:
    ans_list[0] = "1"

for i in range(n):
    if ans_list[i] == "x":
        ans_list[i] = "0"
ans = ""
flag = "off"
for i in ans_list:
    if i != "0":
        flag = "on"
    if flag == "on":
        ans += i
if ans == "":
    ans = 0
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <cassert>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

ll dp[60][2][2][2];   // dp[i][j][k]: i文字目まで見て、j:x>aが確定か k:y<bが確定か l:x,yの桁数一致が確定か

void solve()
{
    ll a, b;
    scanf("%lld%lld", &a, &b);
    int n = 0;
    {
        ll curr = b;
        while (curr) {
            curr /= 2;
            n++;
        }
    }

    dp[0][0][0][0] = 1;
    int i, j, k, l, x0, y0;
    for (i = 0; i < n; i++) {
        int ii = n - 1 - i;
        int tmp1 = ((b & ((ll)1 << ii)) ? 1 : 0);
        int tmp0 = ((a & ((ll)1 << ii)) ? 1 : 0);
        //printf("(%d%d)", tmp0, tmp1);
        for (j = 0; j < 2; j++) {
            for (k = 0; k < 2; k++) {
                for (l = 0; l < 2; l++) {
                    if (dp[i][j][k] == 0) continue;

                    for (y0 = 0; y0 < 2; y0++) {
                        if (k == 0 && y0 > tmp1) continue;

                        for (x0 = 0; x0 <= y0; x0++) {
                            if (j == 0 && x0 < tmp0) continue;
                            if (l == 0 && y0 != x0) continue;

                            int j2 = (((j || x0 > tmp0)) ? 1 : 0);
                            int k2 = ((k || y0 < tmp1) ? 1 : 0);
                            int l2 = ((l || y0 == 1) ? 1 : 0);
                            dp[i + 1][j2][k2][l2] = (dp[i + 1][j2][k2][l2] + dp[i][j][k][l]) % MOD;
                        }
                    }
                }
            }
        }
    }

    ll ans = 0;
    for (j = 0; j < 2; j++) {
        for (k = 0; k < 2; k++) {
            ans = (ans + dp[n][j][k][1]) % MOD;
        }
    }
    printf("%lld\n", ans);
    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}

Measured memory_bytes: 128
import math

a, b, x = map(float, input().split())
if a * a * b <= x * 2:
    h = 2 * (b - x / a / a)
    ret = math.degrees(math.atan2(h, a))
else:
    h = 2 * x / a / b
    ret = 90 - math.degrees(math.atan2(h, b))
print(ret)


Measured memory_bytes: 38384
import math
a,b,x = map(int, input().split())
  
if x > a**2 * b / 2:
  tan = 2*(a**2 * b - x)/a**3
else:
  tan = (a * b**2) / (2 * x)
  
rad = math.atan(tan)
deg = math.degrees(rad)
print(deg)

Measured memory_bytes: 3060
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>

const long long MOD = 1000000007;
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

int main(){
    llong N,M;
    cin >> N >> M;
    vector<pair<llong, llong> > Table(M);
    pair<llong, llong> element;
    llong a,b;
    llong prev;
    llong ans=0;
    for(int i=0; i<M; i++){
        cin >> a >> b;
        element.first = b;
        element.second = a;
        Table[i] = element;
    }
    sort(Table.begin(), Table.end());
    prev = Table[0].first;
    ans++;
    for(int i=1; i<M; i++){
        if(prev<=Table[i].second){
            prev = Table[i].first;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4472
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n = 0,nn,s = 0;
	cin >> n;
	nn = n;
	while(nn){
		s += nn % 10;
		nn /= 10;
	}
	if(n % s == 0) Yes();
	else No();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define ll     long long int 
    #define pb     push_back
    #define umap   unordered_map
    #define mod    1000000007
    #define all(x) (x).begin(), (x).end()
    //__builtin_popcount(x)
    //__builtin_parity(x)   =(number of set bits)%2
    //__builtin_clz(x)      to count the number of leading  zeroes 
    //__builtin_ctz(x)      to count the number of trailing zeroes 
    //__gcd(a,b)
    using namespace std;
    int main()
    {
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     int n;cin>>n;
     int x=n%10;
     if(x==1 || x==3 || x==7 || x==9)
     {
      int y=1;
      ll rem=7%n;
      for(int k=1;k<=1e6;k++)
      {
         if(rem==0)
           {cout<<k;y=0;break;}
         else
           {
            rem=((((rem*10)%n)+(7%n))%n);
           }
      }
      if(y)
        cout<<-1;
     }
     else
     {
      cout<<-1;
     }
    }

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

int main() {
  int n;
  cin>>n;
  ll ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (i%3 == 0) continue;
    if (i%5 == 0) continue;
    ans += i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
n,m = map(int,input().split(" "))
array = list(map(int,input().split(" ")))

array_sum,sums = [0,0],{0:1}
for i in range(1,n+1):
    array_sum[0] = array_sum[1]
    array_sum[1] = (array_sum[0] + array[i-1])%m
    sums[array_sum[1]] = sums.get(array_sum[1],0) + 1

ans = 0
for i in sums.values():
    ans+=int((i-1)*i/2)
print(ans)

Measured memory_bytes: 14696
n,m,x = map(int,input().split())
t = [0]*(m+1)
l = []
for i in range(n):
    l.append(list(map(int,input().split())))
    for j in range(m+1):
        t[j] += l[i][j]
p = 0
for i in range(1,m+1):
    if(t[i] < x):
        p = 1
        break
if(p == 1):
    print(-1)
else:
    c = t[0]
    for i in range(1,2**n):
        s = t.copy()
        z = str(bin(i)[2:])
        z = '0'*(n-len(z)) + z
        for j in range(n):
            if(z[j] == '0'):
                for k in range(m+1):
                    s[k] -= l[j][k]
        p = 0
        for j in range(1,m+1):
            if(s[j] < x):
                p = 1
                break
        if(p == 0):
            if(s[0] < c):
                c = s[0]
    print(c)

Measured memory_bytes: 68988
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import qualified Data.Vector.Unboxed as VU

getInts::IO[Int]
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

main = do
  [k,n] <- map read . words <$> getLine
  an <- VU.fromList <$> getInts
  print $ k - max ((k+(VU.head an))-VU.last an) (VU.maximum $ VU.zipWith (-) (VU.tail an) an)

Measured memory_bytes: 9468
#include <algorithm>
#include <iostream>

using namespace std;

int main(){
	int N, S;
	while(cin >> N && N>0){
		int largest = 0;
		int smallest = 1001;
		int sum = 0;
		for (int i = 0;i<N;i++){
			cin >> S;
			largest = max(largest,S);
			smallest = min(smallest,S);
			sum += S;
		}
		sum = sum - largest;
		sum = sum - smallest;
		cout << sum /(N-2) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
n,m,x,y = gets.split.map(&:to_i)
xs = gets.split.map(&:to_i)
ys = gets.split.map(&:to_i)
ans = false
(x+1..y).each do |z|
  if (xs.all? {|x| x < z }) && (ys.all? {|y| y >= z })
    ans = true
    break
  end
end
puts ans ? "No War" : "War"

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

#define int long long
int mod = 1000000007;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    vector<int> v[m];
    int p[m];
    int total = 0;
    for(int i=0; i<m; i++)
    {
        int k;
        cin>>k;
        while(k--)
        {
            int a;
            cin>>a;
            v[i].push_back(a-1);
        }
    }
    for(int i=0; i<m; i++)cin>>p[i];
    int alpha = pow(2, n);
    for(int i=0; i<alpha; i++)
    {
        bool check = true;
        int arr[n];
        int x = i;
        memset(arr, -1, sizeof(arr));
        for(int j=0; j<n; j++)
        {
            arr[j] = x%2;
            x/=2;
        }
        for(int j=0; j<m; j++)
        {
            int cnt = 0;
            for(int k=0; k<v[j].size(); k++)
            {
                if(arr[v[j][k]]==1)
                    cnt++;
            }
            if(cnt%2!=p[j])
            {
                check = false;
                break;
            }
        }
        if(check)
        {
            total++;
        }
    }
    cout<<total;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define nl "\n";
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define db double
#define mod 1e9 + 7
#define lb lower_bound
#define ub upper_bound
#define vlli vector<lli>
#define mslli multiset<lli>
#define inf INT_MAX
#define sp " "
#define pb push_back
#define pie 3.14159265358979323846
#define test lli t; cin>>t; while(t--)
int main()
{
    /*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);*/
	fastio;
    lli x,c,d;
    cin>>x>>c>>d;
     if(x<=0)
    {
        /*while(x<0&&c>0)
        {
            x=x+d;
            c--;
        }*/
        lli x1=abs(x);
        lli t=x1/d;
        if(t>=c)
        {
            x=x+(c*d);
            c=0;}
        else
        {
            x=x+(t*d);
            c=c-t;
        }
        lli k=abs(x);
        lli k1=abs(x+d);
        if(c%2==0)
            cout<<k;
        else
            cout<<k1;
    }
    else
    {
        /*while(x>0&&c>0)
        {
            x=x-d;
            c--;
        }*/
        lli t=x/d;
        if(t>=c)
        {
            x=x-(c*d);
            c=0;}
        else
        {
            x=x-(t*d);
            c=c-t;
        }
        lli k=abs(x);
        lli k1=abs(x-d);
        if(c%2==0)
            cout<<k;
        else
            cout<<k1;
    }

}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int a,b;
    char c;
    cin>>a>>b;
    for (int i=0;i<a+2;i++) {
        for (int j=0;j<b+2;j++) {
            if (i==0||j==0||i==a+1||j==b+1) {
                cout<<"#";
            } else {
                cin>>c;
                cout<<c;
            }
        }
        cout<<endl;
    }
}


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

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

    string keys;
    cin >> keys;

    string result = "";

    for(int i = 0; i < keys.size(); i++){
        if (keys[i] == 'b' || keys[i] == 'B'){
            if (!result.empty()){
                result.erase(result.size()-1, 1);
            }   
        }
        else {
            result.push_back(keys[i]);
        }
    }

    cout << result;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
struct segK{
    int n;
    vector<long long> dat;
    long long MAX;
    segK(int n_){
        n = 1;
        MAX = 0;
        while(n < n_) n *= 2;
        dat.resize(2 * n - 1);
        for(int i = 0; i < 2 * n - 1; i++) dat[i] = MAX;
    }
    void update(int k, int a){
        k += n - 1;
        dat[k] = a;
        while(k > 0){
            k = (k - 1) / 2;
            dat[k] = max(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }
    long long query(int a, int b, int k = 0, int l = 0, int r = -1){
        if(r < 0) r = n;
        if(r <= a || b <= l) return MAX;
        if(a <= l && r <= b) return dat[k];
        else{
            long long vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            long long vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return max(vl, vr);
        }
    }
};
int main(){
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    segK seg(300100);
    for(int i = 0; i < N; i++){
        if(i == 0) seg.update(A[i], 1);
        else{
            int l = max(0, A[i] - K);
            int r = min(300050, A[i] + K);
            int res = seg.query(l, r + 1);
            seg.update(A[i], res + 1);
        }
    }
    cout << seg.query(0, 300100) << endl;
}

Measured memory_bytes: 12776
#![allow(non_snake_case)]
#![allow(unused_variables)]

fn main() {
    let n: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let a: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    let ans = if n % 2 == 0 {
        let L = (0..(n / 2)).map(|i| a[2 * (n / 2 - i - 1) + 1].to_string()).collect::<Vec<_>>().join(" ");
        let R = (0..(n / 2)).map(|i| a[2 * i].to_string()).collect::<Vec<_>>().join(" ");
        format!("{} {}", L, R)
    } else {
        let L = (0..(n / 2 + 1)).map(|i| a[2 * (n / 2 - i)].to_string()).collect::<Vec<_>>().join(" ");
        let R = (0..(n / 2)).map(|i| a[2 * i + 1].to_string()).collect::<Vec<_>>().join(" ");
        format!("{} {}", L, R)
    };

    println!("{}", ans);
}


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

#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define ALL( a )        (a).begin(), (a).end()             

int main( void ) {
	stack<int> S1;
	stack<pair<int, int>> S2;
	char ch;
	int sum = 0;
	for( int i = 0; cin >> ch; i++ ) {
		if( ch == '\\' ) S1.push( i );
		else if( ch == '/' && S1.size() > 0 ){
			int j = S1.top(); S1.pop();
			sum += i - j;
			int a = i - j;
			while( S2.size() > 0 && S2.top().first > j ) {
				a += S2.top().second; S2.pop();
			}
			S2.push( make_pair( j, a ) );
		}
	}

	vector<int> ans;
	while( S2.size() > 0 ) { ans.push_back( S2.top().second ); S2.pop(); }
	reverse( ALL( ans ) );
	cout << sum << endl;
	cout << ans.size();
	REP( i, ans.size() ) {
		cout << " ";
		cout << ans[i];
	}
	cout << endl;

}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<char,int>;
const int inf = numeric_limits< int >::max()/3;


ll convert(string s){
  ll ret = 0;
  reverse(s.begin(),s.end());
  for(int i = 0;i < (int)s.size();++i){
    if('0' <= s[i] && s[i] <= '9')
      ret += (ll)(s[i] - '0') * (1 << (i*4));
    else
      ret += (ll)((s[i] - 'a') + 10) * (1 << (i*4));
  }
  return ret;
}

void solve(){
  vector< ll > v;
  ll check_sum;
  vector< int > res;
  string s;
  for(int i = 0; i < 8;++i){
    cin >> s;
    //cout << s << " " << convert(s) << endl;
    v.push_back(convert(s));
  }
  cin >> s;
  check_sum = convert(s);
  int carry = 0;
  for(int i = 0;i < 32;++i){
    int check = (check_sum >> i) & 1;
    int cnt = 0;
    for(int j = 0;j < 8;++j){
      if((v[j] >> i) & 1)++cnt;
    }
    if((cnt+carry) % 2 == check){
      res.push_back(0);
      carry = (carry+cnt)/2;
    }else{
      res.push_back(1);
      carry = (carry+8-cnt)/2;
    }
  }
  ll calc = 0;
  for(int i = 0;i < 32;++i){
    calc += (ll)res[i] * (1LL << i);
  }
  if(calc == 0){
    puts("0");
    return;
  }
  vector< char > out;
  while(calc > 0){
    if(calc % 16 <= 9)
      out.push_back((char)('0' + (calc % 16)));
    else
      out.push_back((char)('a' + ((calc % 16) - 10)));
    calc /= 16;
  }
  for(int i = (int)out.size()-1;i >= 0;--i)
    cout << out[i];
  cout << endl;
}


int main(void){
  int n;
  cin >> n;
  for(int i = 0;i < n;++i){
    solve();
  }
  return 0;
}

Measured memory_bytes: 3028
#include <iostream>
using namespace std;
#include<bits/stdc++.h> 
#define ll long long int
#define read(a) long long int a; cin>>a;
#define readstr(s) string s; cin>>s;
#define readarr(a,l) long long int a[l]={0}; for(ll i=0;i<l;i++) cin>>a[i];
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define ff first
#define ss second
#define readmtrx(i,j,a,b) ll arr[a][b]={0};for(ll i=0;i<a;i++)for(ll j=0;j<b;j++) cin>>arr[i][j];
#define v(pi) vector<ll>pi
#define vp(pi) vector<pair<ll,ll>>pi
#define fast ios_base::sync_with_stdio(false);cin.tie(0);
#define pb(p) push_back(p)
#define mp make_pair
#include <cmath>
int main() {
	fast;ll l=0;
	readstr(a)
	readstr(b)
	loop(i,0,a.length()){
		if(a[i]==b[i])l++;
	}
	cout<<l<<endl;
	return 0;
}

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

int main(){
    int n;
    cin>>n;
    int arr[n],ans=0;
    for(int i=0;i<n;i++)cin>>arr[i];
    for(int i=0;i<n;i+=2){
        if(arr[i]%2)ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3588
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    n = II()
    aa = MII()
    aa_acc = list(acc([0]+aa))
    min_num = 0
    min_d = abs(2*aa_acc[1]-aa_acc[n])
    for i in range(2,n):
        l = aa_acc[i]
        r = aa_acc[n] - aa_acc[i]
        min_d = min(min_d, abs(l-r))
    print(min_d)

if __name__ == '__main__':
    main()

Measured memory_bytes: 26124
import sys

def main():
    N, M, X, Y = map(int, input().split())
    x = list(map(int, input().split()))
    y = list(map(int, input().split()))
    ans = "War"

    z = Y
    while z > X:
        if max(x) < z <= min(y):
            ans = "No War"
        z -= 1

    print(ans)

main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define EPS 1e-9
#define PI acos(-1)
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int maxn = 1e5+100;
int a[maxn];

ll quick_pow(ll a,ll b)
{
    ll res = 1;
    while(b)
    {
        if(b&1) res = res*a%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return res;
}

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i = 0; i < n; i++)
    {
        int num;
        cin>>num;
        a[num]++;
    }
    int ok = 1;
    if(n%2)//奇数
    {
        if(a[0] != 1) ok = 0;
        for(int i = 1; i < n ; i++)
        {
            if(i%2==1&&a[i]>0) ok = 0;
            if(i%2==0&&a[i]!=2) ok = 0;
        }
    }
    else
    {
        for(int i = 0; i < n ; i++)
        {
            if(i%2==0&&a[i]>0) ok = 0;
            if(i%2==1&&a[i]!=2) ok = 0;
        }
    }
    if(!ok)
    {
        cout<<"0"<<"\n";
    }
    else
    {
//        ll sum = 1;
//        for(int i =0; i < (n/2); i++)
//        {
//            sum = ((sum % mod) * 2)% mod;
//        }
//        cout<<sum<<"\n";
        cout<<quick_pow(2,n/2)<<"\n";
    }
}



Measured memory_bytes: 640
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        a: i64,
        b: i64,
        c: i64, 
        d: i64,
    }
    let mut ans = false;
    for m in 0..n-1 {
        if (n as i64 - 1 - m as i64)*c - (m as i64)*d <= b-a && b-a <= -c*(m as i64) + (n as i64 -1-m as i64)*d {
            ans = true;
        }
    }
    if ans {
        println!("YES");
    }else{
        println!("NO");
    }
}

Measured memory_bytes: 4352