akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p) pom(a,p-2,p)

////////////////////////////////////////////////////////////////////////////////////////

int main(){
    ll n;cin>>n;
    ll a[3*n];rep(i,0,3*n)cin>>a[i];
    sort(a,a+3*n,greater<ll>());
    ll res = 0;
    repp(i,0,2*n,2)
        res += a[i+1];
    cout << res << endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define mod 1000000007

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n; cin>>n;
  ll ans=0;
  for(int i=0;i<n;i++){
    int x; cin>>x;
    ans+=x;
  }
  cout<<ans-n<<"\n";
  return 0;
}

Measured memory_bytes: 256
#define REP(i, t, n)  for (int i = t; i < n; i++)
#define ALL(n)        (n).begin(),(n).end()
#include <limits.h>
#include <stdio.h>
#include <cmath>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <deque>
#include <functional>
#include <algorithm>
#include <cstring>
#include <unordered_map>
#include <numeric>

#define INF (1000000000)

using namespace std;

typedef bool               BOOL;
typedef short              WORD;
typedef unsigned short     U_WORD;
typedef long               DWORD;
typedef unsigned long      U_DWORD;
typedef long long          QWORD;
typedef unsigned long long U_QWORD;

#define H_MAX (2000)
#define W_MAX (2000)

// . = 1, # = 0 とする
bool Field[H_MAX + 2][W_MAX + 2] = {};
QWORD ansTable[H_MAX + 2][W_MAX + 2] = {};
DWORD H, W;

void calcLightNum(int idxH, int idxW, int *lightNum)
{
	if (Field[idxH][idxW]) {
		(*lightNum)++;
	} else {
		(*lightNum) = 0;
	}
}

void solve_main()
{
	QWORD qwAns = 0;
	cin >> H >> W;

	REP(i, 0, H_MAX + 2) {
		REP(j, 0, W_MAX + 2) {
			ansTable[i][j] = 0;
		}
	}

	REP(i, 1, H + 1) {
		string input;
		cin >> input;
		REP(j, 1, W + 1) {
			if (input[j - 1] == '.') {
				Field[i][j] = true;
			}
		}
	}
	
	//左方向への光確認
	REP(idxH , 1, (H + 1)) {
		int lightNum = 0;
		REP(idxW, 1, (W + 1)) {
			calcLightNum(idxH, idxW, &lightNum);
			ansTable[idxH][idxW] += lightNum;
		}
	}

	//右方向への光確認
	REP(idxH, 1, (H + 1)) {
		int lightNum = 0;
		for (int idxW = W; idxW > 0; idxW--) {
			calcLightNum(idxH, idxW, &lightNum);
			ansTable[idxH][idxW] += lightNum;
		}
	}

	//下方向への光確認
	REP(idxW, 1, (W + 1)) {
		int lightNum = 0;
		REP(idxH, 1, (H + 1)) {
			calcLightNum(idxH, idxW, &lightNum);
			ansTable[idxH][idxW] += lightNum;			
		}
	}
	
	//上方向への光確認
	REP(idxW, 1, (W + 1)) {
		int lightNum = 0;
		for (int idxH = H; idxH > 0; idxH--) {
			calcLightNum(idxH, idxW, &lightNum);
			ansTable[idxH][idxW] += lightNum;
		}
	}

	REP(idxH, 1, (H + 1)) {
		REP(idxW, 1, (W + 1)){
			ansTable[idxH][idxW] -= 3; // 重複をマイナス
			qwAns = max(qwAns, ansTable[idxH][idxW]);
		}
	}

	cout << qwAns << endl;
}

int main()		
{
#ifdef FOR_IDE
	ifstream in("input.txt");
	cin.rdbuf(in.rdbuf());
#endif

	solve_main();
	return 0;
}


Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
 
typedef long long ll;
typedef pair<int, int> ii;


string target;
int pos;
 
struct Node{
    string num;
    Node *left;
    Node *right;
    Node(){
        num = "";
        left = NULL;
        right = NULL;
    }
    Node(string n, Node *l, Node *r){
        num = n;
        left = l;
        right = r;
    }
};

Node *rule_formula();

Node *rule_equation(){
	Node *ret = new Node;
	ret->num = "=";
	ret->left = rule_formula();
	assert(target[pos] == '=');
	pos++;
	ret->right = rule_formula();
    return ret;
}

Node *rule_formula(){
	Node* ret = new Node;
	if(DEBUG) cout << pos << endl;
	switch (target[pos]){
		case '-':
			if(DEBUG) cout << "- " << pos << endl;
			ret->num = "-";
			pos++;
			ret->left = rule_formula();
			break;
		case '(':
			if(DEBUG) cout << "( " << pos << endl;
			pos++;
			ret->left = rule_formula();
			if(target[pos] == '-'){
				ret->num = ">";
				pos += 2;
			}
			else{
				ret-> num = target[pos];
				pos++;
			}
			ret->right = rule_formula();
			pos++;//')'
			break;
		default:
			if(DEBUG) cout << "num " << pos << endl;
			ret->num = target[pos];
			pos++;
			break;
	}
	
	return ret;
}

Node *makeTree(string str){
 
    target = str;
    pos = 0;
    Node *ret;
 
    ret = rule_equation();
 
    return ret;
}

vector<bool> b(11);

bool eval(Node *a){
	switch(a->num[0]){
		case '=' :
			return (eval(a->left) == eval(a->right));
			break;
		case '>':
			bool x, y;
			x = eval(a->left);
			y = eval(a->right);
			if(x == true && y == false) return false;
			else return true;
			break;
		case '-':
			return (!eval(a->left));
			break;
			
		case '+':
			return (eval(a->left) | eval(a->right));
			break;
			
		case '*':
			return (eval(a->left) & eval(a->right));
			break;
		
		case 'T':
			return true;
			break;
		case 'F':
			return false;
			break;
		
		default:
			return (b[(int)(a->num[0] - 'a')]);
			break;
	}
}

int main() {
	
	string s;
	while(getline(cin, s)){
		if(s == "#") break;
		pos = 0;
		Node *a;
		a = makeTree(s);
		bool f = true;
		rep(i, 1 << 11){
			int tmp = i;
			rep(j, 11){
				b[j] = (tmp % 2 == 1);
				tmp = tmp >> 1;
			}
			f = f & eval(a);
		}
		
		cout << (f? "YES" : "NO") << endl;
	}
	
	return 0;
}

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

int main() {
  int n;string s;cin>>n>>s;
  int ans=0;
  rep(i,1000){
    string t;int x=i;
    rep(j,3){
      t+=(x%10+'0');
      x/=10;
    }
    int a=0;
    rep(j,n){
      if(t[a]==s[j])a++;
      if(a==3){
        ans++;
        break;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3684
#include<stdio.h>

int main(void)
{
	int n,x,i,j,k,sum,count=0;

	while(1){
		scanf("%d %d",&n,&x);
		if(n==0 && x==0) break;
		for(i=n;i>=1;i--){
			for(j=i-1;j>=1;j--){
				for(k=j-1;k>=1;k--){
					sum=i+j+k;
					if(sum==x) count++;
				}
			}
		}
		printf("%d\n",count);
		count=0;
	}

	return 0;	
}	

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;

signed main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  for (auto &x : A) {
    cin >> x;
  }
  map<ll, ll> mp;
  for (auto x : A) {
    for (ll a = 1; a*a <= x; a++) {
      if (x % a) continue;
      if (a != 1)
        mp[a] += x;
      if (x/a != a)
        mp[x/a] += x;
    }
  }
  ll res = 0;
  for (auto x : mp) {
    res = max(res, x.second);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 4484
def C_BFS(R, C, sy, sx, gy, gx, c):
    """
    R:行数
    C:列数
    sy,sx:スタートの座標(sy行sx列)
    gy,gx:ゴールの座標(gy行gx列)
    c:迷路の形状(.:通路,#:壁)
    """
    INF = float('inf')
    sy -= 1
    sx -= 1
    gy -= 1
    gx -= 1

    def bfs(maze, row, column, sy, sx, gy, gx):
        # 原点は(0,0)とする(問題の制約によっては原点をずらす必要がある)
        queue = []
        queue.insert(0, (sy, sx))
        dist = [[INF for _ in range(column)] for _ in range(row)]
        dist[sy][sx] = 0  # yが行数、xが列数を意味するときはこの順に書く
        dist_max = 0 
        while len(queue):
            y, x = queue.pop()
#             if x == gx and y == gy:
#                 # ゴール座標と一致するなら
#                 break
            for i in range(4):
                nx, ny = x + [1, 0, -1, 0][i], y + \
                    [0, 1, 0, -1][i]  # (x,y)の右、上、左、下
                if 0 <= nx and nx < column and 0 <= ny and ny < row \
                        and maze[ny][nx] != '#' and dist[ny][nx] == INF:
                    #(nx,ny)が迷路内であり、壁でなく、まだ距離が確定していないとき
                    queue.insert(0, (ny, nx))  # 次に探索する座標
                    dist[ny][nx] = dist[y][x] + 1
                    if dist_max < dist[ny][nx]:
                        dist_max = dist[ny][nx]
        return dist_max
 
    maze = [['' for _ in range(C)] for _ in range(R)]
    for i, tmp in enumerate(c):
        for j in range(C):
            maze[i][j] = tmp[j]
 
    ans = bfs(maze, R, C, sy, sx, gy, gx)
    return ans

R , C = [int(i) for i in input().split()]
c = [input() for _ in range(R)]

ans = 0
for sy in range(1, R+1):
    for sx in range(1, C+1):
        if c[sy-1][sx-1] != '#':
            count_tmp = C_BFS(R, C, sy, sx, 1, 1, c)
            if ans < count_tmp:
                ans = count_tmp
print(ans)

Measured memory_bytes: 51308
cnt = [0] * 4
for i in range(3):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    cnt[a] += 1
    cnt[b] += 1

one = 0
two = 0
for i in range(4):
    if cnt[i] == 1:
        one += 1
    elif cnt[i] == 2:
        two += 1
if one == two and one == 2:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 8960
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args){
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int res = 0;
		int N = sc.nextInt();
		for(int i =1;i<=N;i+=2){
			int sum = 0;
			for(int j =1;j <= i / 3;j++){
				if(i % j==0)sum++;
			}
			if(sum == 7)res++;
		}
		out.println(res);
		out.flush();
	}
}



class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

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

int main() {
  ll n;
  cin >> n;
  vector<ll> h(n);
  vector<bool> can(n-1,false);
  rep(i,n){
    cin >> h[i];
    if(i>=1 && h[i-1]>=h[i])
      can[i-1]=true;
  }
  
  ll MAX=0;
  ll ma = 0;
  rep(i,n-1){
    if(can[i]){
      ma++; MAX=max(ma,MAX);
    }else{
      ma=0;
    }
      
  }
  
  cout << MAX << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};


int main(){
	int n,m;
	cin>>n;
	set<string> st;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		st.insert(s);
	}
	cin>>m;
	bool b=1;
	for(int i=0;i<m;i++){
		string s;
		cin>>s;
		if(st.find(s)!=st.end()){
			if(b) cout<<"Opened by ";
			else cout<<"Closed by ";
			b^=1;
		}
		else cout<<"Unknown ";
		cout<<s<<endl;
	}
}


Measured memory_bytes: 3224
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ std::cin >> head; _cin(std::forward<Tail>(tail)...); }
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; For(i, n){ Cin(T, x); map[x] ++; }
#define Cout(x) cout << (x) << "\n"
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Couty(cond) Cout((cond) ? "Yes" : "No")
#define CoutY(cond) Cout((cond) ? "YES" : "NO")

using namespace std;
using ll = long long;

int main(void){
    Cin(int, a, b, c, d);
    Cout(max(0, min(b, d) - max(a, c)));
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#define EPS 1e-10
using namespace std;

struct P {
  P(){}
  double x,y;
  P(double x,double y):x(x),y(y){}
};

double det(P ab,P cd){
  return ab.x * cd.y - ab.y*cd.x; 
}
int main(){
  P a,b,c,d;
  int n;
  cin >> n;
  while(n--) {
    cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y >> d.x >> d.y;
    P ab,cd;
    ab = P(b.x - a.x,b.y - a.y);
    cd = P(d.x - c.x,d.y - c.y);
    if(abs(det(ab,cd)) < EPS)cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 1224
s = input().split();
a = int(s[0]);
b = int(s[1]);
c = int(s[2]);
k = int(s[3]);
max = 0;
x = a;
if( (a - k) >= 0 ):
    max = k;
elif((a + b - k) >= 0):
    max = a;
else:
    k = k - (a + b);
    max = -k;
    max = max + a;

print(max);

Measured memory_bytes: 9200
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(int n);            // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
int main() {

  int r;
  cin >> r;

  cout << 2.0 * r * 3.14159 << endl; 

  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 1)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int ans[]={0,0,0,0};
    for (int i=0; i<n; i++){
        string s;
        cin>>s;
        if (s=="AC"){
            ans[0]++;
        }
        else if(s=="WA"){
            ans[1]++;
        }
        else if (s=="TLE"){
            ans[2]++;
        }
        else{
            ans[3]++;
        }
    } 
    cout<<"AC x "<<ans[0]<<"\n";
    cout<<"WA x "<<ans[1]<<"\n";
    cout<<"TLE x "<<ans[2]<<"\n";
    cout<<"RE x "<<ans[3]<<"\n";

    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define IOS {ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
#define endl "\n"
#define int long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fb(i, a, b) for(int i=a; i>=b; i--)
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define LB lower_bound
#define UB upper_bound
#define fp(x, y) fixed<<setprecision(y)<<x
#define PI 3.141592653589793238462643383279502884
using namespace std;

const int M = (int)2e5+5;
const int mod = (int)1e9+7;

void solve()
{
    int n;
    cin>>n;
    int cnt[10005] = {};
    f(i, 1, 101)
    {
        f(j, 1, 101)
        {
            f(k, 1, 101)
            {
                int x = (i+j)*(i+j) + (i+k)*(i+k) + (j+k)*(j+k);
                if(x < 20005 && x%2 == 0) cnt[x/2]++;
            }
        }
    }
    f(i, 1, n+1) cout<<cnt[i]<<endl;
}

int32_t main()
{
    IOS
    int t = 1;
    // cin>>t;
    f(tno, 1, t+1)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3684
N,X,M = map(int,input().split())
array = [0,X]
array2 = [X]
a = X
sum = X
valid = True
while(True):
    a = pow(a,2,M)
    if a in array2:
        y = array2.index(a)
        break
    sum += a
    array.append(sum)
    array2.append(a)
l = len(array2)
h = l - y
if N <= y:
    print(array[N])
else:
    ans = array[y] + (array[-1]-array[y])*((N-y)//h) + array[y+(N-y)%h] - array[y]
    print(ans)


Measured memory_bytes: 70836
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<ll> B = A;  // copy!
  sort(begin(A), end(A));

  ll count = 0;
  for (ll i = 0; i < N; i++) {
    if (A[i] != B[i]) {
      count++;
    }
  }
  string ans = count > 2 ? "NO" : "YES";

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int getdigit(long long N) {
  int digit = 0;
  while(N>0) {
    digit++;
    N /= 10;
  }
  return digit;
}
  
int main() {
  long long N; cin >> N;
  int mindigit;
  for (int i = sqrt(N)+1; i > 0; i--) {
    if(N % i == 0) {
      mindigit = max(getdigit(i), getdigit(N / i));
      cout << mindigit;
      return 0;
    }
  }
}

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

int main(void){
    int d;
    cin >> d;
    cout << "Christmas";
    rep(i,25-d){
        cout << " Eve";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int n;
    cin >> n;
    ll a[n]; for (auto &ai:a) cin >> ai;
    sort(a, a+n, greater<ll>());
    ll ans = -a[0];
    for (int i=0; i<n; i++) {
        ans += a[i / 2];
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 5196
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

// input scanner
var sc = bufio.NewScanner(os.Stdin)

const (
	initialBufSize = 10e4
	maxBufSize     = 10e6
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// util
func max(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n > ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func min(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n < ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

type Magic struct {
	Att int
	Mp  int
}

type Magics []Magic

func (m Magics) Len() int {
	return len(m)
}

func (m Magics) Less(i, j int) bool {
	return m[i].Att < m[j].Att
}

func (m Magics) Swap(i, j int) {
	m[i], m[j] = m[j], m[i]
}

// main
func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	h := nextInt()
	n := nextInt()
	ms := make([]Magic, n, n)
	for i := 0; i < n; i++ {
		ms[i].Att = nextInt()
		ms[i].Mp = nextInt()
	}
	sort.Sort(Magics(ms))
	INF := 1001001001
	dp := make([]int, h+1, h+1)
	for i := 0; i < h+1; i++ {
		if i == h {
			dp[i] = 0
		} else {
			dp[i] = INF
		}
	}
	for i := h; i > 0; i-- {
		for j := 0; j < n; j++ {
			_, ii := max([]int{0, i - ms[j].Att})
			_, dp[ii] = min([]int{dp[ii], dp[i] + ms[j].Mp})
		}
	}
	fmt.Println(dp[0])
}


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

using namespace std;
using ll = long long;

int main() {
	ll h, a, ans = 0;
	cin >> h >> a;
	ans = (h + a - 1) / a;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll r,c;
  cin>>r>>c;
  if(r==1 || c==1)
  {
    cout<<"1";
    return 0;
  } 
  if(r&1 && c&1)
  cout<<(1+(r*c))/2;
  else
  cout<<(r*c)/2;
}
  


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

#define x first
#define y second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const int mod=1000000000+7;

int addm(int& a,int b) {return (a+=b)<mod?a:a-=mod;}

template<class T,class U> bool smin(T& a,U b) {return a>b?(a=b,1):0;}
template<class T,class U> bool smax(T& a,U b) {return a<b?(a=b,1):0;}

int N,K,opc;
string s;

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

	cin >> N >> K >> s;
	int i=0;
	bool f=0;
	int shif=0;
	for (i=0;i<N && opc<K;i++) {
		if ((s[i]=='A')==(i%2==0)) {
			f=1;
			opc++;
			if (opc==K) break;
		}
		else f=0;
		opc++;
		shif++;
		f=0;

		//cerr << '1' << endl;
	}

	K-=opc;
	stringstream ans;

	cerr << "opc: " << opc << endl;

	if (K) {
		if (N%2 && K%2) f=1;
		else f=0;
	}
	//if (K==0) {
	for (;i<N;i++) {if ((shif%2==0)==(s[i]=='A')) ans << 'A';
		else ans << 'B';
		cerr << "2" << endl;
	}
	for (int j=N-shif;j<N;j++) {if ((N-j)%2==1) ans << 'A';
		else ans << 'B';
		cerr << "3" << endl;
	}
	string ss;
	ans << endl;
	ans >> ss;

	//cerr << ss << endl;
	//cerr << "ss " << ss.size() << " " << N << endl;
	//ss=ss.substr(ss.size()-N);
	//cerr << ss << endl;
	if (f==(ss[0]=='A')) ss[0]='B';
	else ss[0]='A';

	cout << ss << endl;
	return 0;
	//}


}

Measured memory_bytes: 1304
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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



int main()
{
  ll K,X; cin>>K>>X;
  if(500*K>=X) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 3584
#include <iostream>
using namespace std;
int main() 
{
	int D, N; 
	cin >> D >> N;
	int S = 1; 
	for (int i = 0; i < D; i++) S *= 100;
	if (N <= 99) cout << S * N << endl;
	else cout << S * 101 << endl;
	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define forn(low,high,i) for(i = low;i < high;i++)
#define forrev(high,low,i) for(i = high; i >= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';        
#define debug(x) cerr << __LINE__ << ' ' << #x << " = " << x << '\n';
#define dln cerr << '\n';
#define dsp cerr << ' ';
#define pln cout << '\n';
#define psp cout << ' ';

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;


clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

const ll mod = 1e9 + 7;

const ll N = 2000 + 5;

ll f[N];

inline ll add(ll a,ll b){
  return (a % mod + b % mod) % mod;
}

inline ll sub(ll a,ll b){
  return (a % mod - b % mod + mod) % mod;
}

inline ll mul(ll a,ll b){
  return(a % mod * b % mod) % mod;
}

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

inline ll modinv_Fermat(ll a){
  return modexpo(a,mod - 2);
}

inline ll divide(ll a,ll b){
  return(a%mod * modexpo(b,mod - 2)%mod)%mod;
}

int main(){
  fastio;
  ll n,k;
  ll i,j,ans = 0; 
  cin >> n >> k;
  f[0] = 1;
  forn(1,N,i){
    f[i] = mul(i, f[i - 1]);
  }

  forn(1,k + 1,i){
    ll blue = f[k - 1];
    blue = divide(blue, f[i - 1]);
    blue = divide(blue, f[k - i]);
    ll red;
    if(n - k + 1 >= i){
      red = f[n - k + 1];
      red = divide(red, f[i]);
      red = divide(red, f[n - k + 1 - i]);
    }else{
      red = 0;
    }
    ans = mul(red, blue);
    cout << ans << '\n';
  }

  ktj();

}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))
import itertools

N, *A = mi()
L = [ii() for _ in range(N)]

#A = sorted(A)
sum_a = sum(A)

def dfs(i, a, b, c, use):
    if (0 not in [a, b, c]) and use > 2:
        global ans
        #abc = sorted([a, b, c])
        #ans = min(ans, (use-3)*10 + sum([abs(abc[i]-A[i]) for i in range(3)]))
        ans = min(ans, (use-3)*10 + abs(a-A[0]) + abs(b-A[1]) + abs(c-A[2]))

    if i > N-1:
        return

    dfs(i+1, a+L[i], b, c, use+1)
    dfs(i+1, a, b+L[i], c, use+1)
    dfs(i+1, a, b, c+L[i], use+1)
    dfs(i+1, a, b, c, use)

ans = float('inf')
dfs(0, 0, 0, 0, 0)

print(ans)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
#define fst first
#define snd second
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

void solve(long long n, vector<long long> a){
	ll sum=0;
	for (auto &w:a) {
		sum+=w-1;
	}
	printf("%lld\n",sum);
}

int main(){	
	ios_base::sync_with_stdio(false); cin.tie(0);
	long long N;
	scanf("%lld",&N);
	vector<long long> a(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&a[i]);
	}
	solve(N, a);
	return 0;
}



Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RankNTypes #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List
-- import qualified Data.Vector.Unboxed as VU
-- import qualified Data.Vector.Unboxed.Mutable as VUM
-- import Control.Monad
-- import Control.Monad.ST
-- import Debug.Trace
-- trace _ = id

solve :: Int -> Int -> Int -> [Int] -> [[Int]]
solve bH bW bN as = answer
  where
    xs = concat $ map (\(i,a) -> replicate a i) $ zip [1..bN] as
    answer = unfoldr f (True, xs)
      where f (_, []) = Nothing
            f (b, xs) | b == True  = Just (xs1, (False, xs2))
                      | b == False = Just (reverse xs1, (True, xs2))
              where (xs1, xs2) = splitAt bW xs

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> [[Int]]
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_bH,bs_bW]:remLines1 = remLines0
      bH = readBInt bs_bH
      bW = readBInt bs_bW
      [bs_bN]:remLines2 = remLines1
      bN = readBInt bs_bN
      line3:remLines3 = remLines2
      as = map readBInt line3
  in solve bH bW bN as

outAnswer :: [[Int]] -> IO ()
outAnswer css = putStr $ unlines $ map (unwords . map show) css

main :: IO ()
main = outAnswer . tmain =<< B.getContents


-------------------------------------------------------------------------------

inp1 = "2 2\n3\n2 1 1\n"
inp2 = "3 5\n5\n1 2 3 4 5\n"
inp3 = "1 1\n1\n1\n"
tv1 = tmain $ B.pack inp1
tv2 = tmain $ B.pack inp2
tv3 = tmain $ B.pack inp3



Measured memory_bytes: 1020
import math
a, b = map(int,input().split())

a = [math.ceil(a * 12.5),(a + 1) * 12.5]
b = [math.ceil(b * 10),math.floor((b + 1) * 10)]
# print(a)
# print(b)
if max(a[0], b[0]) < min(a[1], b[1]):
    print(max(a[0], b[0]))
else:
    print(-1)

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

public class Main {
	
	private static class Pair {
		private int x;
		private int y;
	}
	
	public static void main(String[] args) {
		int sum = 0;
		Stack<Integer> s1 = new Stack<Integer>();
		Stack<Pair> s2 = new Stack<Pair>();
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String map;
		try {
			map = br.readLine();
			br.close();
		} catch (Throwable t) {
			return;
		}
		
		for (int i = 0; i < map.length(); i ++) {
			switch (map.charAt(i)) {
				case '\\':
					s1.add(i);
					
					Pair pair = new Pair();
					pair.x = i;
					pair.y = 0;
					s2.add(pair);
					
					break;
				case '/':
					if (s1.isEmpty()) break;
					int j = s1.pop();
					sum += i - j;
					
					Pair pair1 = s2.pop();
					int l = 0;
					int sum1 = 0;
					
					while (pair1.x > j) {
						l ++;
						sum1 += pair1.y;
						if (s2.isEmpty()) break;
						pair1 = s2.pop();
					} 
					sum1 += i- j;
					
					if (pair1.x <= j) s2.add(pair1);
					
					Pair pair2 = new Pair();
					pair2.x = j;
					pair2.y = sum1;
					s2.add(pair2);
					
					break;
			}
		}
		
		int[] l = new int[s2.size()];
		int k = 0;
		while (!s2.isEmpty()) {
			int lk = s2.pop().y;
			if (lk == 0) continue;
			l[k++] = lk;
		}
		
		System.out.println(sum);
		
		System.out.print(k);
		for (int i = k - 1; i >= 0; i --) {
			System.out.print(" ");
			System.out.print(l[i]);
		}
		System.out.println();	
	}
} 



Measured memory_bytes: 26748
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    string S;
    cin >> S;
    S = ">" + S + "<";
    int N = S.size() + 1;
    vector<int> vec(N, -INF);
    vec[0] = 0;
    rep(i,0,N-1){
        if(S[i] == '>' && S[i+1] == '<'){
            vec[i+1] = 0;
            //left
            int num = 0;
            for(int j = i;j >= 0;j--){
                if(S[j] == '<')break;
                vec[j] = max(vec[j], ++num);
            }
            //right
            num = 0;
            for(int j = i+2;j < N;j++){
                if(S[j-1] == '>')break;
                vec[j] = max(vec[j], ++num);
            }
        }
    }
    ll sum = 0;
    rep(i,1,N-1){
        //cout << vec[i] << " ";
        sum += vec[i];
    }//cout << endl;
    cout << sum << endl;
}

Measured memory_bytes: 2840
#include<stdio.h>
#include <algorithm>
#include<string>
#include <iostream>
using namespace  std;
int main()
{

    char a;
    scanf("%c",&a);
    if(a>='A' &&a<='Z')
    {
        puts("A");
    } else if(a>='a'&&a<='z')
    {
        puts("a");
    }
    return 0 ;

}

Measured memory_bytes: 3648
#include<stdio.h>

int main(){
    
    int N;
    int i,j,k,v;
    
    scanf("%d",&N);
    
    int a[N];
    
    for(i=0;i<N;i++){
        scanf("%d",&a[i]);
    }
    
    for(i=0;i<N;i++){
        
        v=a[i];
        j=i-1;
        while(j>=0 && a[j]>v){
            a[j+1]=a[j];
            j--;
        }
       a[j+1]=v;
       
       for(k=0;k<N-1;k++){
           printf("%d ",a[k]);
       }
       printf("%d\n",a[N-1]);
       
    }
    return 0;
}

Measured memory_bytes: 600
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <stack>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_set>
#define INF 2147483647
#define MAXN  200005
#define mod 1000000007
#define PII pair<int, int>
#define lowbit(x) (x&-x)
#define PI acos(-1.0)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int vis[5] = { 0 }, d[5];
ull sum = 0;
void dfs(int t,int id,ull a)
{
	if (t == 4)
	{
		sum += a;
		return;
	}
	for (int i = 0; i < 5; i++)
		if (i>id&&vis[i] == 0 && d[i] != 0)
		{
			vis[i] = 1;
			dfs(t + 1,i, a*d[i]);
			vis[i] = 0;
		}
}
int main()
{
	//ios::sync_with_stdio(false);
	cin.tie(0);
#ifdef local_debug1
	ifstream inputs("input.txt");
	cin.rdbuf(inputs.rdbuf());
	freopen("input.txt", "r", stdin);
	//ofstream outputs("output.txt");
	//cout.rdbuf(outputs.rdbuf());
#endif

	int n;
	cin >> n;
	unordered_set<string> s[5];
	string om;
	char ch;
	for (int i = 0; i < n; i++)
	{
		cin >> om;
		ch = om[0];
		if (ch == 'M')
			s[0].insert(om);
		else if (ch == 'A')
			s[1].insert(om);
		else if (ch == 'R')
			s[2].insert(om);
		else if (ch == 'C')
			s[3].insert(om);
		else if (ch == 'H')
			s[4].insert(om);
	}
	
	for (int i = 0; i < 5; i++) d[i] = s[i].size();

	dfs(1,-1,1);
	cout << sum << endl;
	return 0;
}

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

using namespace std;using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

int main() {
  int N, K;
  cin >> N >> K;
  vector< int > A(N), B(N);
  for(int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }
  function< int64(int, bool, int) > calc = [&](int idx, int lim, int bit) {
    int64 ret = 0;
    if(!lim || idx == -1) {
      for(int i = 0; i < N; i++) {
        int uku = A[i] >> (idx + 1);
        if((uku & ~bit)) continue;
        ret += B[i];
      }
      return ret;
    }
    for(int k = lim ? ((K >> idx) & 1) : 1; k >= 0; k--) {
      chmax(ret, calc(idx - 1, lim & (((K >> idx) & 1) == k), (bit << 1) | k));
    }
    return ret;
  };
  cout << calc(29, true, 0) << endl;

}




Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(void){
    int n;
    string a;
    cin>>n;
    cin>>a;
    if(a.size()%2==1){
        cout<<"No"<<endl;
            }
    else{
        rep(i,a.size()/2){
        if(a[i]!=a[i+a.size()/2]){
            cout<<"No"<<endl;
            break;
        }
        if(i==(a.size()/2)-1){
                cout<<"Yes"<<endl;
        }
    }
}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S(vector).size()
using namespace std;
typedef long long ll;

int main(void){
  int n;
  cin >> n;
  int h[n + 1];
  rep(i, n) cin >> h[i];

  h[n] = MOD;
  int ans = 0;
  int cnt = 0;

  for(int i = 0; i < n; i++){
    if(h[i] >= h[i + 1]){
      cnt++;
      continue;
    }
    else {
      ans = max(ans, cnt);
      cnt = 0;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n,r; cin >> n >> r;
  if(n<10){
    cout << 100*(10-n)+r << endl;
  }
  else{
    cout << r << endl;
  }
  
}

Measured memory_bytes: 256
#include <stdio.h>
int a[10][10000],b[10],n,m;
int ans(int o){
    if(o==n){
        int i,j,re=0;
        for(i=0;i<m;i++){
            int k=0;
            for(j=0;j<n;j++){
                k+=(a[j][i]+b[j])%2;
            }
            re+=n-k<k?n-k:k;
        }
        return re;
    }else{
        int x,y;
        b[o]=0;
        x=ans(o+1);
        
        b[o]=1;
        y=ans(o+1);
        
        return x<y?x:y;
    }
}
int main(void){
   int i,j;
   while(1){
   scanf("%d%d",&n,&m);
    if(n==0&&m==0){
        break;
    }
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    printf("%d\n",n*m-ans(0));
   }
}

Measured memory_bytes: 2964
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    vector<int> menu(5);
    rep(i, 5) cin >> menu.at(i);

    int min_pos;
    int min_rem = 10;
    rep(i, 5) {
        int rem = menu.at(i) % 10;
        if(rem == 0) {
            continue;
        } else if(rem < min_rem) {
            min_rem = rem;
            min_pos = i;
        }
    }
    dump(min_pos);

    int sum = 0;
    rep(i, 5) {
        if(i == min_pos) {
            sum += menu.at(i);
        } else {
            sum += menu.at(i) + (10 - menu.at(i) % 10);
            if(menu.at(i) % 10 == 0) {
                sum -= 10;
            }
        }
        dump(sum);
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
// ABC74-D
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define e_b emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
void map_p(map<int,int>& d){cout<<"map: ";for(auto a : d){cout<<"{"<<a.first<<":"<<a.second<<"}";}cout<<endl;} //mapの中身を見る
void set_p(set<int>& d){cout<<"set: ";for(int a : d){cout<<a<<" ";}cout<<endl;} //setの中身を見る


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int n;
    cin>>n;
    vector<vector<ll>> dp(n,vector<ll>(n,0));
    vector<vector<bool>> exist(n,vector<bool>(n,true));
    rep(i,n){
        rep(j,n){
            cin>>dp[i][j];
        }
    }
    bool flag=true;
    rep(k,n){
        rep(i,n){
            rep(j,n){
                if(k!=i && k!=j){
                    ll kari=dp[i][k]+dp[k][j];
                    if(kari<dp[i][j]){ //最短距離が更新されてしまった。
                        flag=false;
                        break;
                    }
                    if(kari==dp[i][j]){ //う回路がある
                        exist[i][j]=false,exist[j][i]=false;
                    }
                }
            }
        }
    }
    if(flag){
        ll ans=0;
        for(int i=0;i<=n-2;i++){
            for(int j=i+1;j<=n-1;j++){
                if(exist[i][j]) ans+=dp[i][j];
            }
        }
        cout<<ans<<endl;
    }else cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 3988
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
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 (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    int N,K;cin >> N >> K;
    LL ans = 0;
    ans += K;
    rep(i,N-1)ans *= (K-1);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
  int a,b,c;

  cin >> a >> b >> c;

  if (a > b){
      int d;
      d = b;
      b = a;
      a = d;
  }
  if (b > c){
      int e;
      e = c;
      c = b;
      b = e;
  }
  if (a > b){
      int f;
      f = b;
      b = a;
      a = f;
  }
  cout << a << " " << b << " " << c << endl;
  return 0;		 
}
		   


Measured memory_bytes: 3056
#include<stdio.h>
int main(void)
{
	int S, h, m, s;

	scanf("%d", &S);
	h = S / 3600;
	S = S % 3600;
	m = S / 60;
	s = S%60;

	printf("%d:%d:%d\n", h, m, s);

	return 0;
}

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

const long long mo=1000000000+7;

using mat=std::vector< std::vector<long long > >;

mat mul(mat a,mat b){
  mat ret(50,std::vector<long long>(50));
  for(int i=0;i<50;++i){
    for(int j=0;j<50;++j){
      for(int k=0;k<50;++k){
	ret[i][j]+=a[i][k]*b[k][j]%mo;
	ret[i][j]%=mo;
      }
    }
  }
  return ret;
}

int main(){
  int N;
  long long K;
  std::cin>>N;
  std::cin>>K;
  mat a(50,std::vector<long long>(50));
  for(int i=0;i<N;++i){
    for(int j=0;j<N;++j){
      std::cin>>a[i][j];
    }
  }
  
  mat ret(50,std::vector<long long>(50));
  for(int i=0;i<50;++i)ret[i][i]=1;
  for(;K>0;K/=2,a=mul(a,a)){
    if(K%2==1){
      ret=mul(ret,a);
    }
  }
  long long ans=0;
  for(int i=0;i<50;++i){
    for(int j=0;j<50;++j){
      ans+=ret[i][j];
      ans%=mo;
    }
  }
  std::cout<<ans<<std::endl;
  return 0;
}


Measured memory_bytes: 384