akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
using namespace std;

int main(){
    int n, n4 = 0, n2 = 0, a;
    string ans = "No";
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if(a%4==0)n4++;
        else if(a%2==0)n2++;
    }
    if(n2==0 && n%2 == 1){
        if(n4 * 2 >= n-1)ans = "Yes";
    }
    else{
        if(n4 * 2 + n2 >= n) ans = "Yes";
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/*                    */
#include <bits/stdc++.h>
//#include <numeric>
using namespace std;
using lint = int64_t;
char itoc(int i) { return i + '0'; };
int ctoi(char c) { return c - '0'; };
/*                    */

int main() {
  int k;
  cin >> k;
  lint ans = 0;
  for (int a = 1; a <= k; a++) {
    for (int b = 1; b <= k; b++) {
      for (int c = 1; c <= k; c++) {
        ans += gcd(gcd(a, b), gcd(b, c));
      }
    }
  }
  cout << ans << endl;
}

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

#define rep(i, n)     repi (i, 0, n)
#define repi(i, m, n) for (int i = m; i < int(n); ++i)

using ll = long long;
using ull = unsigned long long;

template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> a(n);
  rep (i, n) cin >> a[i];

  int ctz = __builtin_ctz(a[0]);
  repi (i, 1, n) {
    if (ctz != __builtin_ctz(a[i])) {
      cout << "0\n";
      return 0;
    }
  }

  ll l = 1;
  rep (i, n) {
    l = lcm(l, a[i] / 2);
    if (l > m) {
      cout << "0\n";
      return 0;
    }
  }

  ll ans = m / (l * 2);
  if (m % (l * 2) >= l) ++ans;
  cout << ans << "\n";
}


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

int main(){
 int n,k;
  string s;
  cin >> n >> s >> k;
  r(i,n){
    if(s.at(i)==s.at(k-1))cout << s.at(i);
    else cout << "*";
  }
  cout <<endl;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<vector<ll>> mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;

int N;
int a[110];
multiset<int> ms;

signed main()
{
    cin >> N;
    REP(i,N) {
        cin >> a[i];
        ms.insert(a[i]);
    }

    int K = *max_element(a, a + N);
    if (K % 2 == 0) {
        for (int i=K/2+1; i<=K; i++) if (ms.count(i) < 2) {
            cout << "Impossible" << endl;
            return 0;
        }
        for (int i=K/2+1; i<=K; i++) ms.erase(i);
        if (ms.count(K/2) == 1 && ms.size() == 1) {
            cout << "Possible" << endl;
            return 0;
        } else {
            cout << "Impossible" << endl;
            return 0;
        }
    } else {
        for (int i=(K+1)/2; i<=K; i++) if (ms.count(i) < 2) {
            cout << "Impossible" << endl;
            return 0;
        }
        for (int i=(K+1)/2+1; i<=K; i++) ms.erase(i);
        if (ms.count((K+1)/2) == 2 && ms.size() == 2) {
            cout << "Possible" << endl;
            return 0;
        } else {
            cout << "Impossible" << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
import math
r=0
while r==0:
        L=l=""
        i=map(float,raw_input().split())
        if i[0]==i[1]==0:
                break
        a=b=i[1]
        c=math.floor(i[0]/2)
        while 0<a:
                L=L+"#"
                a=a-1
                if 0<a:
                        L=L+"."
                        a=a-1
        while 0<b:
                l=l+"."
                b=b-1
                if 0<b:
                        l=l+"#"
                        b=b-1
        while 0<c:
                print L
                print l
                c=c-1
        if i[0]%2==1:
                print L
        print

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

using namespace std;

int main() {
	int N,T;

	cin >> N >> T;

	vector<int> c, t, k;
	int temp;
	for (int i = 0; i < N; i++) {
		cin >> temp;
		c.push_back(temp);
		cin >> temp;
		t.push_back(temp);
	}

	for (int i = 0; i < N; i++) {
		if (t[i] <= T) {
			k.push_back(c[i]);
		}
		else {

		}
	}

	if (k.size() == 0) {
		cout << "TLE" << endl;
		exit(0);
	}


	int min = k[0];

	for (int i = 1; i < k.size(); i++) {
		if (k[i] < min) {
			min = k[i];
		}
	}

	cout << min << endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

char str[505][505];

int main() {
  int n,m;
  scanf("%d%d",&n,&m);
  for(int i=1;i<=n;i++) scanf("%s",str[i]+1);
  for(int i=1;i<=n;i++)  {
  	for(int j=1;j<=m;j++) putchar((str[i][j]=='#'||(j<m&&(j==1||(i&1))))?'#':'.');
  	putchar('\n');
  }
  putchar('\n');
  for(int i=1;i<=n;i++)  {
  	for(int j=1;j<=m;j++) putchar((str[i][j]=='#'||(j>1&&(j==m||!(i&1))))?'#':'.');
  	putchar('\n');
  }
  return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main() {
	int m, n;

	while(cin >> m >> n, m || n) {
		cin.ignore();
		int nex_p[1024];
		bool f[1024];
		int plre = m;
		for(int i = 0; i < 1024; i++) {
			nex_p[i] = (i + 1) % m;
			f[i] = true;
		}

		int cur, pre;
		cur = 0;
		pre = m-1;
		for(int i = 0; i < n; i++) {
			string in;
			stringstream sstr;
			string a;
			bool flg = true;

			getline(cin,in);
			sstr << i+1;
			sstr >> a;

			if(in == "Fizz" && (i+1) % 3 == 0 && (i+1) % 5 != 0) {
				;
			}
			else if(in == "Buzz" && (i+1) % 3 != 0 && (i+1) % 5 == 0) {
				;
			}
			else if(in == "FizzBuzz" && (i+1) % 15 == 0) {
				;
			}
			else if(in == a && (i+1) % 3 && (i+1) % 5) {
				;
			}
			else {
				flg = false;
			}

			if(flg) {
				pre = cur;
			}
			else if(plre>1){
				plre--;
				nex_p[pre] = nex_p[cur];
				f[cur] = false;
			}
			cur = nex_p[cur];
		}

		/*
		for(int i = 0; i < m; i++)
			cout << nex_p[i] << " ";
		cout << endl;
		// */

		bool space = false;
		for(int i = 0; i < m; i++) {
			if(f[i]) {
				if(space)
					cout << " ";
				cout << (i+1);
				space = true;
			}
		} cout << endl;
	}
}

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

int main(){

  int x[5];
  int k;
  int i,j;
  
  for(i=0; i<5; i++){
    cin >> x[i];
  }
  cin >> k;

  for(i=0; i<4; i++){
    for(j=i+1; j<5; j++){
      if( x[j]-x[i]>k ){
	cout << ":(" << endl;
		   return 0;
		   }
      }
    }
    
    cout << "Yay!" << endl;
    return 0;
  }

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


using namespace std ; 

int n ; 

int main(){
        ios_base::sync_with_stdio(0) ; 
        cin.tie(0) ;
       // reopen("in.in" , "r" , stdin) ; 
        int m ; 
        cin>>n>>m ; 
        cout<< n *  m ; 
        return 0 ; 
}

Measured memory_bytes: 3640
a, b = map(int, input().split())
S = input()

ans = 'Yes'
if S[a] == '-':
    S = S.replace('-', '', 1)
    for i in S:
        if not i in '1234567890':
            ans = 'No'
else:
    ans = 'No'
    
print(ans)

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

int main() {
  int N,M;
  cin >> N >> M;
  
  int Answer;
  
  vector<int> road(2*M);
  
  for (int i=0; i<2*M; i++){
    cin >> road.at(i);
  }
  
  for (int i=0; i<N; i++){
    Answer = 0;
    for (int j=0; j<2*M; j++){
      if(road.at(j) == i+1) Answer ++;
    }
    cout << Answer << endl;
  }
}


Measured memory_bytes: 3576
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
const int maxn = 15;
int a[maxn];
int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	for(int i = 0;i < n; ++i)
	{
		scanf("%d",&a[i]);
	}
	sort(a,a + n);
	int ans = 0;
	for(int i = 0;i < n - 1; ++i)
	{
		ans += a[i];
	}
	ans += a[n - 1] / 2;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
/*
    CP Submission
*/

#include<bits/stdc++.h>

using namespace std;

/* Shortcuts */
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define val(x) cout << #x << ": " << (x) << endl;
#define log(x) cout << (x) << endl;
#define sz(x) (int)(x.size())
#define REP(i, a, b) for(int i = a; i < b; i++)

/* typedefs */
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <char> vc;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <string,string> mss;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int a, b, c;
    cin>>a>>b>>c;

    int n_c = min(c, a+b+1);

    cout << (n_c + b) << endl;

    return 0;
}


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

int n, m;
string seat;

void sit(char a) {
    switch (a) {
        case 'A': {
            for (int i=1; i<=n; ++i) {
                if (seat[i] == '#') {
                    seat[i] = 'A'; return ;
                }
            }
            break;
        }
        case 'B': {
            for (int i=n; i>=1; --i) {
                if (seat[i] == '#' && seat[i-1] != 'A' && seat[i+1] != 'A') {
                    seat[i] = 'B'; return ;
                }
            }
            for (int i=1; i<=n; ++i) {
                if (seat[i] == '#') {
                    seat[i] = 'B'; return ;
                }
            }
            break;
        }
        case 'C': {
            bool empty = true;
            for (int i=1; i<=n; ++i) {
                if (seat[i] != '#') {
                    empty = false; break;
                }
            }
            if (empty) {
                seat[(n+2)/2] = 'C'; return ;
            }
            for (int i=1; i<=n; ++i) {
                if (seat[i] != '#') {
                    if (seat[i+1] == '#') {
                        seat[i+1] = 'C'; return ;
                    } else if (seat[i-1] == '#') {
                        seat[i-1] = 'C'; return ;
                    }
                }
            }
            break;
        }
        case 'D': {
            int k, mx = -1;
            for (int i=1; i<=n; ++i) {
                int l = 0;
                while (0 < i-l && seat[i-l] == '#') ++l;
                int r = 0;
                while (i+r < n+1 && seat[i+r] == '#') ++r;

                if (i+r == n+1) r = INT_MAX;
                if (i-l == 0) l = INT_MAX;
                int dist = min(l, r);

                if (mx < dist) {
                    k = i;
                    mx = dist;
                }
            }
            seat[k] = 'D';
            break;
        }
    }
}

int main() {
    while (cin >> n >> m, (n || m)) {
        seat = "_";
        for (int i=0; i<n; ++i) {
            seat += "#";
        }
        seat += "_";
        char a;
        for (int i=0; i<m; ++i) {
            cin >> a;
            sit(a);
        }
        cout << seat.substr(1,n) << endl;
    }
    return 0;
}

Measured memory_bytes: 1208
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Data.List

main :: IO ()
main = do
    n <- readLn :: IO Int
    a <- map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
    let a' = sortOn fst $ zip a [1..]
    mapM_ (print . snd) a'


Measured memory_bytes: 33404
local function query(x)
  io.write(x - 1 .. "\n")
  io.flush()
  local ret = io.read("*l")
  if ret == "Vacant" then os.exit() end
  return ret
end

local n = io.read("*n", "*l")
local first = query(1)
-- check-only
query(n)
local min, max = 1, n
while true do
  local mid = (min + max) // 2
  local ret = query(mid)
  local valid = false
  if mid % 2 == 0 and ret ~= first then
    valid = true
  end
  if mid % 2 == 1 and ret == first then
    valid = true
  end
  if valid then
    min = mid
  else
    max = mid
  end
end


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

int main() {
  
  int N;
  cin >> N;
  
  int countm=0;
  for(int j=1; j<=N; j++){
    int count=0;
    for(int i=0; i<=N; i++){
      int odd=i*2+1;
      if( j%odd==0 ){ count+=1; }
    }
    if(count==8){ countm+=1; }
  }
  cout << countm << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using P = pair<int,int>;
using ll = long long;

int main() {
    ll a,b;
    int x;
    cin >> x;
    for(ll i=0;i<400;i++){
        for(ll j=-400;j<i;j++){
            if(pow(i,5)-pow(j,5)==x) {
                cout << i << " " << j <<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 4100
#include <iostream>
using namespace std;
int main()
{
    int a,b,i;cin>>a>>b;
    string x,y;
    x="";
    y="";
    for(i=0;i<b;i++){
        x+=char(a%10+48);
    }
    for(i=0;i<a;i++){
        y+=char(b%10+48);
    }
    if(a>b){
        cout<<y;
        return 0;

    }
    cout<<x;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
# define M_PI 3.14159265358979323846
using ll = long long int;
const int MOD = 1e9 + 7;
int main()
{
    int n,k;
    cin>>n>>k;
    map<int,int> mp;
    for(int i=0;i<k;i++)
    {
        int d;
        cin>>d;
        for(int j=0;j<d;j++)
        {
            int temp;
            cin>>temp;
            if(mp[temp]==0)
            {
                mp[temp]=1;
            }
        }
    }
    cout<<n-mp.size()<<endl;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1000000000000000;
#define MAX_N 10000

struct edge{
	int start;
	int to;
	int cost;
};

bool operator>(const struct edge &left,const struct edge &right){
	return left.cost > right.cost;
}

priority_queue<edge,vector<edge>,greater<edge>> edgeList;

typedef vector<vector<struct edge>> AdjList;
AdjList graph;

int par[MAX_N];

void initUnionFind(){
	rep(i,MAX_N) par[i] = i;
}

int root(int i){
	if( par[i] == i) return i;
	par[i] = root(par[i]);
	return par[i];
}

bool isSameRoot(int i,int j){
	i = root(i);
	j = root(j);
	return i == j;
}

void unite(int i,int j){
	i = root(i);
	j = root(j);
	if( i == j) return;
	par[i] = j;
}

void kruskal(){
	initUnionFind();
	while(!edgeList.empty()){
		edge e = edgeList.top();
		edgeList.pop();
		int u,v;
		u = e.start;
		v = e.to;
		if( isSameRoot(u,v) == false){
			unite(u,v);
			edge e1;
			e1.cost = e.cost;
			e1.start = u;
			e1.to = v;
			graph[u].push_back(e1);

			/*edge e2;
			e2.cost = e.cost;
			e2.start = v;
			e2.to = u;
			graph[v].push_back(e2);*/
		}
	} 
}



int main()
{
	int V,E;
	cin>>V>>E;
	graph = vector<vector<edge>>(V);
	rep(i,E){
		int s,t,w;
		cin>>s>>t>>w;
		edge e;
		e.start = s;
		e.to = t;
		e.cost = w;
		edgeList.push(e);
	}
	kruskal();
	ll ans = 0;
	rep(i,V){
		for(auto iter = graph[i].begin(); iter != graph[i].end(); iter++){
			ans += iter->cost;
			//cout<<i<<"->"<<iter->to<<":"<<iter->cost<<endl;
		}
	}
	cout<<ans<<endl;
	return 0;
}




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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = 1e9 + 7;
const int INF = 1e9;



int main() {
	cin.sync_with_stdio(false);
	int N;
	cin >> N;
	map<int,int>mp;
	rep(i, N) {
		int D;
		cin >> D;
		mp[D]++;
	}
	int M;
	cin >> M;
	rep(i, M) {
		int T;
		cin >> T;
		if (mp[T])mp[T]--;
		else {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 9600
def fact(n):
  a = 1
  for i in range(2, n+1):
    a *= i
  return a

def comb(n, r):
  return fact(n) // fact(r) // fact(n-r)

n, p = map(int, input().split())
a = list(map(int, input().split()))

zero = 0
one = 0
for i in a:
  if i % 2 == 0:
    zero += 1
  else:
    one += 1

if p == 0:
  ans = 2 ** zero
  c = 0
  for i in range(0, one+1, 2):
    c += comb(one, i)
  ans *= c
  print(ans)
else:
  ans = 2 ** zero
  c = 0
  for i in range(1, one+1, 2):
    c += comb(one, i)
  ans *= c
  print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
using ll = long long;
using P = pair<int, int>;

constexpr ll mod = 1e9 + 7;
const double PI = acos(-1.0);

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

  int n, m; cin >> n >> m;

  if (n>=m) {
    cout << 0 << endl;
    return 0;
  }

  vector<int> x(m);
  rep(i, m) {
    cin >> x[i];
  }
  sort(x.begin(), x.end());

  vector<int> d(m-1);
  for(int i=0; i<m-1; i++) {
    d[i] = x[i+1] - x[i];
  }

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

  int ans = 0;
  for(int i=0; i<m-n; i++) {
    ans += d[i];
  }

  cout << ans << endl;
}

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

int main(int argc, char const* argv[])
{
  int a, b, k;
  cin >> a >> b >>k;
  int idx = 0;
  int num = max(a,b) + 1;
  while(idx < k){
    num--;
    if( a%num==0 && b%num == 0){
      idx++;
    }
  }
  cout << num << endl;
  return 0;
}

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

int main()
{
 int n,m;
 cin >> n >> m;
 char mat[n+10][m+10];
 for(int i=0; i<n; i++)
 {
     for(int j=0; j<m; j++)
     {
         cin >> mat[i][j];
     }
 }
 bool ok = 0;

 for(int i=0; i<n; i++)
 {
     for(int j=0; j<m; j++)
     {
         if(mat[i][j]=='#')
         {
             if(i>0 && mat[i-1][j]=='#')continue;
             if(i<n-1 && mat[i+1][j]=='#')continue;
             if(j>0 && mat[i][j-1]=='#')continue;
             if(j<m-1 && mat[i][j+1]=='#')continue;
             ok=1;break;
         }
     }
 }

 if(!ok)cout << "Yes" << endl;
 else cout << "No" << endl;


}


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

int main () {

    char b;
    cin >> b;

    if (b == 'A') cout << "T" << endl;
    else if (b == 'T') cout << "A" << endl;
    else if (b == 'C') cout << "G" << endl;
    else if (b == 'G') cout << "C" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	void main()	{
		try(Scanner sc = new Scanner(System.in)){
			for(;;) {
				int x = sc.nextInt();
				int y = sc.nextInt();
				if(x == 0&&y == 0)break;
				if(x < y) {
					System.out.println(x+" "+y);
				} else {
					System.out.println(y+" "+x);
				}
				
			}
		}
    	
	}
	

    public static void main(String[] args) {

        new Main().main();

    }

}


Measured memory_bytes: 35432
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace _20170409_AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            for (;;)
            {
                char[] x = Console.ReadLine().ToCharArray();
                if (x.Length == 1 && x[0] == '0')
                {
                    break;
                }

                int sum = 0;
                foreach (var v in x)
                {
                    sum += v - '0';
                }

                Console.WriteLine(sum);
            }

            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9032
#include<stdio.h>
int main(){
  int a[100][100],i,j,k,b[100],n,m,c[100][100],d=0;
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      scanf("%d",&a[i][j]);
    }
  }
  for(i=0;i<m;i++){
    scanf("%d",&b[i]);
  }
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      c[i][j]=a[i][j]*b[j];
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      d=d+c[i][j];
    }
    printf("%d\n",d);
    d=0;
  }
  return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	int N;
	cin >> N;
	cout << (N - 1) / 2 << "\n";
}

Measured memory_bytes: 3544
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

int D;
int c[32];
int s[512][32];
int ans[512];

void inp(){
    cin>>D;
    for(int i=1;i<=26;i++){
        cin>>c[i];
    }
    for(int i=1;i<=D;i++){
        for(int j=1;j<=26;j++){
            cin>>s[i][j];
        }
    }
}

void ans_inp(){
    for(int i=1;i<=D;i++){
        cin>>ans[i];
    }
}

void ans_ran(){
    for(int i=1;i<=D;i++){
        ans[i]=rand()%26+1;
    }
}

int man_calc(bool disp){
    int l[32]={0};
    int man=0;
    for(int i=1;i<=D;i++){
        int n=ans[i];
        l[n]=i;
        man+=s[i][n];
        for(int j=1;j<=26;j++){
            man-=c[j]*(i-l[j]);
        }
        if(disp) cout<<man<<endl;
    }
    return man;
}

void ans_disp(){
    for(int i=1;i<=D;i++){
        cout<<ans[i]<<endl;
    }
}

int change_ans(int i,int n,bool f){
    int ret=0;
    if(f){
        int fr=ans[i];
        ret+=s[i][n];
        ret-=s[i][fr];

        //cout<<ret<<endl;
        int fl=0;
        for(int j=1;j<=i-1;j++){
            if(ans[j]==fr) fl=0;
            else fl++;
        }
        for(int j=i;j<=D;j++){
            if(ans[j]==fr&&j!=i) break;
            ret-=c[fr]*(fl+1);
        }
        //cout<<ret<<endl;
        int tl=0;
        for(int j=1;j<=i-1;j++){
            if(ans[j]==n) tl=0;
            else tl++;
        }
        for(int j=i;j<=D;j++){
            if(ans[j]==n) break;
            ret+=c[n]*(tl+1);
        }
        //cout<<ret<<endl;
    }
    ans[i]=n;
    //cout<<ret<<endl;
    return ret;
}

void solve_C(){
    int M;
    cin>>M;
    int man=man_calc(false);
    //cout<<man<<endl;
    for(int i=0;i<M;i++){
        int from,to;
        cin>>from>>to;
        int cng=change_ans(from,to,true);
        man+=cng;
        cout<<man<<endl;
    }
}

void random_solve(){
    int seed=1234;
    int cnt=1000000;
    srand(seed);
    ans_ran();
    for(int i=0;i<=cnt;i++){
        int bef=man_calc(false);
        int ci=rand()%D+1;
        int tn=rand()%26+1;
        int fn=ans[ci];
        int cng=change_ans(ci,tn,true);
        if(cng<0){
            change_ans(ci,fn,false);
        }
    }
    ans_disp();
    //cout<<man_calc(false)<<endl;
}

signed main(){
    inp();
    ans_inp();
    solve_C();
    //random_solve();
    return 0;
}



Measured memory_bytes: 3264
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
using std::min; using std::max;
using std::sort; using std::swap;
typedef long long ll;

template<typename T>void read(T &x) {
	x = 0; int f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') { if(ch == '-') f = -f; ch = getchar(); }
	while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); x *= f;
}

const int _ = 2e5 + 10, __ = 4e3 + 10, P = 1e9 + 7, I2 = 500000004;
int n, a[_], b[_], fac[__ << 1], ifac[__ << 1], ret, tmp, f[__][__];
inline void pls(int &a, int b) { a += b; if(a >= P) a -= P; }
inline int add(int a, int b) { a += b; if(a >= P) a -= P; return a; }

int qpow(int a, int b) {
	int r = 1;
	for(; b; b >>= 1, a = 1ll * a * a % P)
		if(b & 1) r = 1ll * r * a % P;
	return r;
}
int C(int n, int m) {
	return 1ll * fac[n] * ifac[m] % P * ifac[n - m] % P;
}

int main() {
	read(n);
	for(int i = 1; i <= n; ++i) read(a[i]), read(b[i]);
	fac[0] = 1;
	for(int i = 1; i <= 8000; ++i) fac[i] = 1ll * fac[i - 1] * i % P;
	ifac[8000] = qpow(fac[8000], P - 2);
	for(int i = 8000; i >= 1; --i) ifac[i - 1] = 1ll * ifac[i] * i % P;
	for(int i = 1; i <= n; ++i)
		pls(tmp, C((a[i] + b[i]) * 2, a[i] * 2));
	for(int i = 1; i <= n; ++i) f[2000 - a[i]][2000 - b[i]] += 1;
	for(int i = 0; i <= 4000; ++i)
		for(int j = 0; j <= 4000; ++j) {
			if(i) pls(f[i][j], f[i - 1][j]);
			if(j) pls(f[i][j], f[i][j - 1]);
		}
	for(int i = 1; i <= n; ++i) pls(ret, f[2000 + a[i]][2000 + b[i]]);
	printf("%d\n", (int)(1ll * I2 * add(ret, P - tmp) % P));
	return 0;
}


Measured memory_bytes: 64640
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <sstream>
#include <complex>
#include <ctime>
#include <cassert>
#include <functional>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;

#define REP(i,s,t) for(int i=(s);i<(t);i++)
#define FILL(x,v) memset(x,v,sizeof(x))

const int INF = (int)1E9;
#define MAXN 100005

ll N, A, B, C, D;
int main() {
  //freopen("input", "r", stdin);
  cin >> N >> A >> B >> C >> D;
  if (A > B) swap(A, B);
  N--;
  ll G = B - A;
  REP(i,0,N+1) {
    int j = -(N-i);
    ll low = i*C + j*D, high = i*D + j*C;
    if (low > high) swap(low, high);
    //cerr << low << " " << high << endl;
    if (low <= G && high >= G) return puts("YES"), 0;
  }
  puts("NO");
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

vector<P> costs[100010];
ll dist[100010];

void dfs(int parent, int node){
    for(P &e : costs[node]){
        if (e.first == parent) continue;
        dist[e.first] = dist[node] + e.second;
        dfs(node, e.first);
    }
}

int main()
{
    int N;
    cin >> N;
    int M = N-1, a, b, c;
    for(int i=0;i<M;++i){
        cin >> a >> b >> c;
        --a;
        --b;
        costs[a].push_back(P(b, c));
        costs[b].push_back(P(a, c));
    }

    int Q, K;
    cin >> Q >> K;
    --K;
    dist[K] = 0;
    dfs(-1, K);
    int x, y;
    for(int i=0;i<Q;++i){
        cin >> x >> y;
        --x;
        --y;
        cout << dist[x] + dist[y] << endl;
    }
}


Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a==5&&b==5&&c==7||a==7&&b==5&&c==5||a==5&&b==7&&c==5)  
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
} 

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var (
		N, M int
		s, t string
	)
	var st = map[string]int{}

	fmt.Scan(&N)
	for i := 0; i < N; i++ {
		fmt.Scan(&s)
		st[s]++
	}

	fmt.Scan(&M)
	for i := 0; i < M; i++ {
		fmt.Scan(&t)
		st[t]--
	}

	max := 0
	for _, v := range st {
		if max < v {
			max = v
		}
	}

	fmt.Println(max)
}


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

int main () {
  int K;
  string S;
  cin >> K >> S;
  if (S.size() <= K) cout << S << endl;
  else {
    for (int i = 0; i < K - S.size(); i++) S.pop_back();
    cout << S << "..." << endl;
  }
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
using namespace std;
typedef pair<int, int> PII;
typedef vector<PII> VP;
typedef VP::iterator VPI;

int N, M;
VP iimoriyama, tsurugajo, table;
VPI pi, pt;

int main()
{
	cin >> N;
	for (int i = 0; i < N; i++){
		int h, m;
		cin >> h >> m;
		iimoriyama.push_back(make_pair(h, m));
	}
	cin >> M;
	for (int i = 0; i < M; i++){
		int k, g;
		cin >> k >> g;
		tsurugajo.push_back(make_pair(k, g));
	}

	pi = iimoriyama.begin();
	pt = tsurugajo.begin();
	while (pi != iimoriyama.end() || pt != tsurugajo.end()){
		if (pi == iimoriyama.end()){
			table.push_back(*pt);
			pt++;
		}
		else if (pt == tsurugajo.end()){
			table.push_back(*pi);
			pi++;
		}
		else if (*pi > *pt){
			table.push_back(*pt);
			pt++;
		}
		else if (*pi < *pt){
			table.push_back(*pi);
			pi++;
		}
		else{
			table.push_back(*pi);
			pi++; pt++;
		}
	}
	for (pt = table.begin(); pt != table.end() - 1; pt++){
		cout << pt->first << ((pt->second < 10) ? ":0" : ":") << pt->second << " ";
	}
	cout << pt->first << ((pt->second < 10) ? ":0" : ":") << pt->second << endl;
	return 0;
}

Measured memory_bytes: 1208
/*
    author:  Maksim1744
    created: 18.01.2020 15:07:31
*/

#include <bits/stdc++.h>

using namespace std;

#define ll   long long
#define ld   long double

#define mp   make_pair
#define pb   push_back
#define eb   emplace_back

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

template<typename T>             vector<T>& operator--            (vector<T>& v){for (auto& i : v) --i;            return  v;}
template<typename T>             vector<T>& operator++            (vector<T>& v){for (auto& i : v) ++i;            return  v;}
template<typename T>             istream& operator>>(istream& is,  vector<T>& v){for (auto& i : v) is >> i;        return is;}
template<typename T>             ostream& operator<<(ostream& os,  vector<T>& v){for (auto& i : v) os << i << ' '; return os;}
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p){is >> p.first >> p.second;        return is;}
template<typename T, typename U> ostream& operator<<(ostream& os, pair<T, U>& p){os << p.first << ' ' << p.second; return os;}
template<typename T, typename U> pair<T,U> operator-(pair<T,U> a, pair<T,U> b){return mp(a.first-b.first, a.second-b.second);}
template<typename T, typename U> pair<T,U> operator+(pair<T,U> a, pair<T,U> b){return mp(a.first+b.first, a.second+b.second);}
template<typename T, typename U> void umin(T& a, U b){if (a > b) a = b;}
template<typename T, typename U> void umax(T& a, U b){if (a < b) a = b;}

#ifdef HOME
#define TAG_LENGTH       25
#define LR_LEFT          left
#define LR_RIGHT         right
#define LR_VALUE         value
#define LR_SECOND_VALUE  mn
#include "C:/C++ libs/print.cpp"
#else
#define showl            42;
#define shows            42;
#define show(...)        42;
#define showm(...)       42;
#define showt(...)       42;
#define printTree(...)   42;
#define printGraph(...)  42;
#define printLRTree(...) 42;
#define printMatrix(...) 42;
#define printWGraph(...) 42;
#define debug     if (false)
#endif

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

    int n;
    cin >> n;
    vector<pair<int, int>> v(n);
    cin >> v;
    for (int i = 0; i < n; ++i) {
        v[i] = {v[i].first - v[i].second, v[i].first + v[i].second};
    }
    sort(v.begin(), v.end(), [&](pair<int, int> a, pair<int, int> b){
        return a.second < b.second;
    });
    show(v);
    int r = -2e9;
    int c = 0;
    for (auto xy : v) {
        auto x = xy.first, y = xy.second;
        if (x >= r) {
            r = y;
            ++c;
        }
    }
    cout << c << endl;

    return 0;
}


Measured memory_bytes: 1024
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]

s = s()

mod = 2019
num_int = 0
mod_dict = defaultdict(int)
mod_dict[num_int % mod] += 1
s = s[::-1]
t = 1
for i in range(len(s)):
    num_int += t * int(s[i])
    num_int %= mod
    t *= 10
    t %= mod
    mod_dict[num_int] += 1

for i in mod_dict:
    ans += ((mod_dict[i] - 1) * mod_dict[i]) // 2

print(ans)

Measured memory_bytes: 11200
n = int(input())
a = list(map(int, input().split()))

b = [0] * n
for i in range(n)[::-1]:
    multiple = b[i::i + 1]
    if sum(multiple) % 2 != a[i]:  # 偶奇が一致していない場合
        b[i] = 1  # ボールを入れる
    
print(sum(b))
true_b = []  # ボールが入っている箱の番号 true_b
for i in range(n):
    if b[i] == 0: continue
    true_b.append(str(i + 1))

if len(true_b) != 0:
    print(' '.join(true_b))


Measured memory_bytes: 19388
#include<stdio.h>
int main(void)
{
    int a[3],i,max,min;

    for(i=0;i<3;i++){
        scanf("%d",&a[i]);
    }
    max=a[0];
    min=a[0];
    for(i=0;i<3;i++){
        if(max<a[i]){
            max = a[i];
        }
     else if(min>a[i])
            min=a[i];
    }
    printf("%d\n",max-min);
    return 0;
}

Measured memory_bytes: 128
import fractions
a,b = map(int,input().split())
c = fractions.gcd(a,b)

ans = [1]
while c % 2 == 0:
  ans.append(2)
  c //= 2
i = 3
while c >= i ** 2:
  if c % i == 0:
    ans.append(i)
    c //= i
  else:
    i += 2
if c != 1:
  ans.append(c)
print(len(set(ans)))

Measured memory_bytes: 64108
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    string s;
    cin >> s;
    s = "2018" + s.substr(4, 6);
    cout << s << endl;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
import java.math.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] youbi = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
		String s = sc.next();
		int ans = 0;
		for(int i = 0; i < youbi.length; i++) {
			if (youbi[i].equals(s)) {
				ans = 7 - i;
			}
		}
		out.println(ans);
		
	}
}

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

int const MAX = 200005;
int dp[24][MAX];

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		long long t;
		cin >> t;
		for (int j = 0; j <= 20; j++) {
			dp[j][i] = t & 1;
			t /= 2;
		}
	}
	for (int j = 0; j <= 20; j++) {
		dp[j][0] = 0;
		for (int i = 1; i <= n; i++) {
			dp[j][i] += dp[j][i - 1];
		}
	}
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		int next = n + 1;
		for (int j = 0; j <= 20; j++) {
			int t = upper_bound(dp[j] + i, dp[j] + n + 1, dp[j][i] + 1) - (dp[j] + i) - 1;
			next = min(next, t);
		}
		ans += next;
	}
	cout << ans << endl;
}

Measured memory_bytes: 18816
import sys
sys.setrecursionlimit(10**8)
n=int(input())
AB=[list(map(int,input().split())) for _ in range(n-1)]

path=[[] for _ in range(n)]
for i,(a,b) in enumerate(AB):
  a,b=a-1,b-1
  path[a].append((b,i))
  path[b].append((a,i))
  
visited=[0]*n
ans=[None]*(n-1)
  
def dfs(v,c=-1):
  nc=1
  for to,i in path[v]:
    if visited[to]: continue
    visited[v]=1
    if nc==c: nc+=1
    ans[i]=nc
    dfs(to,nc)
    nc+=1
dfs(0)
print(max(ans))
print(*ans,sep='\n')

Measured memory_bytes: 97680
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x = 1;
  ll N; cin >> N;
  while(x * x <= N) x++;
  cout << (x - 1) * (x - 1) << endl;
  return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <unordered_map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;

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

	int N;
	cin >> N;

	int l = 0, r = N;
	char lc, lr;

	cout << 0 << endl;
	string s;
	cin >> s;

	if (s[0] == 'V')return 0;

	lc = lr = s[0];

	rep(i, 0, 19)
	{
		int mid = (l + r) / 2;
		cout << mid << endl;
		cin >> s;
		if (s[0] == 'V')break;
		if (lc == s[0])
		{
			if ((mid - l) % 2 == 0)
			{
				l = mid;
				lc = s[0];
			}
			else
			{
				r = mid;
				lr = s[0];
			}
		}
		else
		{
			if ((mid - l) % 2 == 1)
			{
				l = mid;
				lc = s[0];
			}
			else
			{
				r = mid;
				lr = s[0];
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll x;
  cin >> x;
  for(ll a=-200; a<=200; a++){
    for(ll b=-200; b<=200; b++){
      if(a*a*a*a*a - b*b*b*b*b == x){
        cout << a << " " << b << '\n';
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  ll N,M;
  cin>>N>>M;
  vector<ll>A(N);
  priority_queue<ll>que;
  
  rep(i,N){
    cin>>A[i];
    que.push(A[i]);
    }
    
  
  rep(i,M){
    ll max=que.top();
    max/=2;
    que.pop();
    
    que.push(max);
  }
ll ans=0;
  rep(i,N){
    ans+=que.top();
    que.pop();
  }
  
cout<<ans<<endl;
}

   

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

using namespace std;

int main() {
  int N, X, L, M{-1000000001}, ans{};
  cin >> N;
  vector<pair<int, int>> v(N);
  for (int i = 0; i != N; ++i) {
    cin >> X >> L;
    v[i] = {X + L, X - L};
  }

  sort(begin(v), end(v));

  for (const auto &p : v)
    if (M <= p.second) ++ans, M = p.first;

  cout << ans << endl;
}


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

int main() {
	long long int n,m,x,a,ans=0;
	cin>>n>>m;
	priority_queue<int>pq;
	for(int i=0;i<n;i++) {
		cin>>x;  pq.push(x);
	}
	while(!pq.empty() && m>0) {
		a=pq.top(); pq.pop();
		a/=2; pq.push(a); m--;
	}
	while(!pq.empty()) {
		ans+=pq.top(); pq.pop();
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;

bool acgt(char a){
    if (a == 'A') return 1;
    if (a == 'C') return 1;
    if (a == 'T') return 1;
    if (a == 'G') return 1;
    return 0;
}

int main(){
    string S; cin >> S;
    int n = S.size();
    int ans = 0;
    int sum=0;

    for(int i=0;i<n;i++){
        if(acgt(S[i])) sum++;
        else sum =0;
        if(sum > ans) ans = sum;
            
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
typedef long long ll;
  
// Number of bits to  
// represent int 
#define INT_BITS 62 
  
// Function to return 
// maximum XOR subse 
// in se[] 
ll maxSubarrayXOR(ll se[], int n) { 
    // Initialize index of 
    // chosen elements 
    int index = 0; 
  
    // Traverse through all 
    // bits of integer  
    // starting from the most 
    // significant bit (MSB) 
    for (int i = INT_BITS-1; i >= 0; i--) { 
        // Initialize index of 
        // maximum element and 
        // the maximum element 
        int maxInd = index; 
        ll maxEle = -1ll; 
        for (int j = index; j < n; j++) { 
            // If i'th bit of se[j] 
            // is se and se[j] is  
            // greater than max so far. 
            if ( (se[j] & (1ll << i)) != 0ll  
                     && se[j] > maxEle ) 
                maxEle = se[j], maxInd = j; 
        } 
  
        // If there was no  
        // element with i'th 
        // bit se, move to 
        // smaller i 
        if (maxEle == -1) 
        continue; 
  
        // Put maximum element 
        // with i'th bit se  
        // at index 'index' 
        swap(se[index], se[maxInd]); 
  
        // Update maxInd and  
        // increment index 
        maxInd = index; 
  
        // Do XOR of se[maxIndex] 
        // with all numbers having 
        // i'th bit as se. 
        for (int j=0; j<n; j++){ 
            // XOR se[maxInd] those 
            // numbers which have the 
            // i'th bit se 
            if (j != maxInd && 
               (se[j] & (1ll << i)) != 0ll) 
                se[j] = se[j] ^ se[maxInd]; 
        } 
  
        // Increment index of 
        // chosen elements 
        index++; 
    } 
  
    // Final result is  
    // XOR of all elements 
    ll res = 0ll; 
    for (int i = 0; i < n; i++) 
        res ^= se[i]; 
    return res; 
}
vector<int> ind;
ll convert(ll x){
	ll ret = 0ll;
	for(int i=0;i<ind.size();i++){
	 ret += ((x>>ind[i])&1ll)<<i;
	}
	return ret;
}	
ll se[100100]; 
ll t[100100];
int N;
int main() { 
    cin >> N;
    ll ans = 0ll;
    for(int i=0;i<N;i++){
        cin >> se[i];
        ans ^= se[i];
    }
		for(int i=0;i<63;i++){
			if(((ans>>i)&1ll)==0ll){
				ind.push_back(i);
			}
		}
		for(int i=0;i<N;i++){
			t[i] = convert(se[i]);
		}
    //cout << "Max subse XOR is "; 
		//cout << ans << endl;
		ll mt = maxSubarrayXOR(t,N);
		//cout << mt << endl;
		for(int i=0;i<ind.size();i++){
			if((mt>>i)&1ll)ans += (1ll<<(ind[i]+1));
		}
    cout << ans<< endl; 
    return 0; 
} 


Measured memory_bytes: 1792
use proconio::input;
use proconio::marker::Bytes;

fn main() {
    input! { s: Bytes };
    let ds: Vec<u8> = s.iter().map(|b| b - b'0').collect();
    let n = ds.len();
    let mut count = 0;
    let mut b = 1_usize;
    let mut r = 0_usize;
    let mut dp = vec![0_usize; 2019];
    dp[0] = 1;
    for i in (0..n).rev() {
        let d = ds[i] as usize;
        r = (d * b + r) % 2019;
        b = (b * 10) % 2019;
        count += dp[r];
        dp[r] += 1;
    }
    let ans = count;
    println!("{}", ans);
}


Measured memory_bytes: 2624
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int INF = 1 << 29;
		int W = sc.nextInt();
		int[] A = new int[W];
		for (int i = 0; i < W; ++i) {
			A[i] = Integer.parseInt(sc.next());
		}
		int[][] c = new int[2][W];
		for (int loop = 0; loop < 2; ++loop) {
			int exit = -1;
			int time = INF;
			for (int i = 0; i < W; ++i) {
				if (A[i] == 0) {
					exit = i;
					time = INF;
				} else if (A[i] < 0) {
					if (exit != -1) time = Math.min(time, -A[i] + i - exit);
				} else {
					if (exit != -1) c[loop][i] = Math.max(0, Math.min(A[i], time - (i - exit)));
				}
			}
			for (int i = 0; i < W / 2; ++i) {
				int tmp = A[i];
				A[i] = A[W - 1 - i];
				A[W - 1 - i] = tmp;
			}
		}
		int ans = 0;
		for (int i = 0; i < W; ++i) {
			ans += Math.max(c[0][i], c[1][W - 1 - i]);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 68280
#define _USE_MATH_DEFINES
#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(v) (v).begin(),(v).end()
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr ll LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; cin >> n;
  vector<ll> x(n), y(n);
  REP(i, n) {
    int xi, yi; cin >> xi >> yi;
    x[i] = xi + yi;
    y[i] = xi - yi;
  }
  sort(ALL(x));
  sort(ALL(y));
  cout << max(x[n - 1] - x[0], y[n - 1] - y[0]) << '\n';
  return 0;
}


Measured memory_bytes: 6356