akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
    is >> p.first >>p.second ;
    return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
    rep(i, v.size()) {
        is >> v[i];
    }
    return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
    ll k,a,b;
    ll ans=1LL;
	ll ter;
	cin >>k>>a>>b;
    
		ter = min(a - 1, k);
		ans += ter;
		k -= ter;
        if(b-a>2){
		ans += (b - a) * (k / 2LL);
		k %= 2LL;
        }
		ans += k;
	
    cout<<ans<<endl;
}
/*
48518828981938099
48518828981938099
? 3 5
2... 3
3... 4 / 0 (1)
4... 5 / 4
*/

/*
4 2 6
1... 2
2...0(1)
3... 6
4...7

*/

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEsL 2e9
#define PIE 3.1415a926535

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;}
template <class T>
inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

int main(){
    ll n, k;
    cin >> n >> k;
    cout << min(n % k, k - n % k) << endl;
}

Measured memory_bytes: 256
#入力
n,m,r=map(int,input().split())
abc=[list(map(int,input().split())) for _ in [0]*m]
#グラフ
g=[[] for _ in [0]*n]
[g[a-1].append([b-1,c]) for a,b,c in abc]

#逆辺
g2=[[] for _ in [0]*n]
[g2[b-1].append([a-1,c]) for a,b,c in abc]

#前処理用のDFS
def remove_edge(graph,start):
    q=[start]
    memo=[True for _ in range(n)]
    memo[start]=False
    while q:
        qq=q.pop()
        for i,j in graph[qq]:
            if memo[i]:
                q.append(i)
                memo[i]=False
    return {i for i,j in enumerate(memo) if j==True}

#前処理
rmv=remove_edge(g,0)|remove_edge(g2,n-1)
for i in rmv:
    g[i]=[]
for i in range(n):
    for j in g[i]:
        if j[0] in rmv:
            g[i].remove(j)

#ベルマンフォード
dist=[-10**15 for _ in [0]*n]
dist[0]=0

for k in range(n):
    for p in range(n):
        for i,j in g[p]:
            dist[i]=max(dist[i],dist[p]+j-r)
    if k==n-2:
        d1=[t for t in dist]
    if k==n-1:
        d2=[t for t in dist]
        
#1からでもnの間に負の閉路があるときは-1
if d1==d2:
    print(max(d1[-1],0))
else:
    print(-1)

Measured memory_bytes: 57048
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int ans;
char a;
int main()
{
	ans=700;
	for (int i=1;i<=3;i++)
	{
		cin>>a;
		if (a=='o') ans+=100;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    ct=0
    for i in range(1,n+1):
        if len(str(i))%2==1:
            ct+=1
    print(ct)
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define fill( x, y ) memset( x, y, sizeof x )
#define copy( x, y ) memcpy( x, y, sizeof x )
using namespace std;

typedef long long LL;
typedef pair < int, int > pa;

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

const int MAXN = 100005;

int n, a[MAXN], b[MAXN];
map < pa, bool > cnt;
pa c[MAXN];

inline void GG() { puts( "-1" ); exit( 0 ); }

int main()
{
#ifdef wxh010910
	freopen( "data.in", "r", stdin );
#endif
	n = read();
	for( int i = 1 ; i <= n ; i++ )
	{
		a[ i ] = read(), b[ i ] = read(), c[ i ] = mp( a[ i ] + b[ i ], b[ i ] );
		if( !a[ i ] && i != 1 ) GG();
		if( !b[ i ] && i != 2 ) GG();
		cnt[ mp( a[ i ], b[ i ] ) ] = 1;
	}
	if( a[ 1 ] || b[ 2 ] ) GG();
	sort( c + 1, c + n + 1 );
	int ret = n - 1 << 1;
	for( int l = 1, r = 1 ; l <= n ; l = r )
	{
		while( r <= n && c[ r ].xx == c[ l ].xx )
		{
			int x = c[ r ].xx - c[ r ].yy, y = c[ r ].yy;
			if( x )
			{
				bool flag = false;
				for( int d = -1 ; d <= 1 ; d++ ) if( cnt.find( mp( x - 1, y + d ) ) != cnt.end() ) flag = true;
				if( !flag ) GG();
			}
			if( y )
			{
				bool flag = false;
				for( int d = -1 ; d <= 1 ; d++ ) if( cnt.find( mp( x + d, y - 1 ) ) != cnt.end() ) flag = true;
				if( !flag ) GG();
			}
			r++;
		}
		for( int i = l, j = l, last = 0, left = 0 ; i < r ; i = j )
		{
			while( j < r && c[ j ].yy == c[ i ].yy ) j++;
			int now = j - i, del = 0;
			if( c[ i ].yy == last + 1 ) del = min( now, left ), ret -= del;
			if( cnt.find( mp( c[ i ].xx - c[ i ].yy - 1, c[ i ].yy - 1 ) ) != cnt.end() ) ret -= now - del, now = del;
			last = c[ i ].yy; left = now;
		}
	}
	return printf( "%d\n", ret ), 0;
}


Measured memory_bytes: 8064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException{
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);

		String str = br.readLine();

		calc(str);
	}

	public static void calc(String str){
		int num = Integer.parseInt(str);
		int s,m,h;

		h = num/3600;
		m = (num-3600*h)/60;
		s = num - 3600*h -60*m;

		System.out.println(h+":"+m+":"+s);
		}
}

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

int main() {
  int K,X;
  cin >> K >> X;
  
  int m = max(X-(K-1), -1000000);
  int M = min(X+(K-1), 1000000);
  
  bool isFirst = true;
  for(int i = m; i <= M; i++){
  	cout << i;
    if(isFirst) { cout << " "; }
  }
  cout << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		final int n = sc.nextInt();

		List<String> list = new ArrayList<String>();
		boolean result = false;
		for (int i = 0; i < n; i++) {
			final String str = sc.next();
			final String prevStr = i == 0 ? null : list.get(i - 1).substring(list.get(i - 1).length() - 1);

			if (list.contains(str)) {
				result = true;
				break;
			}
			if (i > 0 && !str.substring(0, 1).equals(prevStr)) {
				result = true;
				break;
			}
			list.add(str);
		}

		System.out.println(result ? "No" : "Yes");

	}

}


Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
using namespace std;

int main()
{
  int N;
  cin>>N;
  set <int> A;
  for(int i=0;i<N;i++){
    int tmp;
    cin>>tmp;
    A.insert(tmp);
  }
  cout<<A.size()-(A.size()+1)%2<<endl;
}


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

int main() {
	int n, a, mn = 1001, mx = -1;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (mn > min(mn, a)) mn = min(mn, a);
		if (mx < max(mx, a)) mx = max(mx, a);
	}
	cout << mx - mn << endl;
	return 0;
}

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

#pragma GCC optimuze("Ofast")
#pragma GCC optimuze("03")
#pragma GCC optimuze("unroll-loops")

#define F first
#define S second
#define pb push_back
#define llong long long
#define ld long double
#define int llong
#define endl '\n'

using namespace std;

const int N = 2e5 + 5;
const int M = 2e3 + 5;
const int MOD = 1e9 + 7;
const int rx[] = {1, 0, -1, 0};
const int ry[] = {0, 1, 0, -1};

int dp[N];

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef ARINOCHKA
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
#endif // ARINOCHKA

    int n, s;
    cin >> n >> s;
    vector <pair <int, int> > a;
    for(int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        a.pb({x, y});
    }

    for(int i = 1; i < N; i++) {
        dp[i] = 2e9;
    }

    dp[0] = 0;
    for(auto to : a) {
        int w = to.F, cost = to.S;
        for(int i = N - 1; i >= 0; i--) {
                if (i + cost >= N) continue;
            if (dp[i + cost] > dp[i] + w){
                dp[i + cost] = dp[i] + w;
            }
        }
    }

    int ans = 0;

    for(int i = 0; i < N; i++){
        if (dp[i] <= s){
            ans = i;
        }
    }

    cout << ans;



    return 0;


}


Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
#include<stdio.h>
#include <ctype.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<deque> //<< fixed << setprecision()
#include<queue> //priority_queue
#include<vector>
typedef long long ll;
using namespace std;
const double pi = (2 * acos(0));


struct point
{
	long double x, y;
};
double area(int x1, int y1, int x2, int y2, int x3, int y3)
{
	double a = (x2*y3) - (x3*y2) - (x1*y3) + (x3*y1) + (x1*y2) - (x2*y1);
	a /= 2;
	return fabs(a);
}

long double anyarea(point p[], int n)
{
	long double sum1 = p[n - 1].x * p[0].y, sum2 = p[n - 1].y * p[0].x;
	for (int i = 0; i < n - 1; i++)
	{
		sum1 += p[i].x * p[i + 1].y;
		sum2 += p[i].y * p[i + 1].x;
	}
	return  fabs((sum1 - sum2) * 0.5);
}

ll fastpow(ll base, ll p, ll m)
{
	if (p == 0)
		return 1;
	ll ans = fastpow(base, p / 2, m);
	ans = ((ans%m)*(ans%m)) % m;
	if (p % 2)
		ans = ((base%m)*ans) % m;
	return ans;
}
ll GCD(ll M, ll m)
{
	if (M%m == 0)
		return m;
	M %= m;
	ll x1 = M, x2 = m;
	m = min(x1, x2);
	M = max(x1, x2);
	return GCD(M, m);


}
ll lcm(ll M, ll m)
{
	return (M*m) / GCD(max(M, m), min(M, m));

}

	long double p[3002];
	long double arr[3002][3002];
int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> p[i];

	arr[1][0] = 1 - p[1];
	arr[1][1] =p[1];
	for (int i = 2; i <= n; i++)
	{
		for (int j = 0; j <= i; j++)
		{
			arr[i][j] = arr[i - 1][j] * (1 - p[i]);
			if (j)
				arr[i][j] += arr[i - 1][j-1] * ( p[i]);

		}
	}
	long double ans = 0;
	for (int i = (n + 1) / 2; i <= n; i++)
	{
		ans += arr[n][i];
	}
	cout << fixed << setprecision(12) << ans;






}


Measured memory_bytes: 139136
#include<bits/stdc++.h>
using namespace std;
int n,k,c;
char s[200005];
int l[200005],r[200005];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>k>>c;
	for(int i=1; i<=n; i++)
		cin>>s[i];
	int cnt=1,nxt=1;
	for(int i=1; i<=n; i++) {
		if(s[i]=='o'&&i>=nxt) {
			l[cnt++]=i;
			nxt=i+c+1;
		}
	}
	cnt=k,nxt=n;
	for(int i=n; i>=1; i--) {
		if(s[i]=='o'&&i<=nxt) {
			r[cnt--]=i;
			nxt=i-c-1;
		}
		if(!cnt) break;
	}
	for(int i=1; i<=k; i++)
		if(l[i]==r[i])
			cout<<l[i]<<endl;
	return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,h,d=0;
  int a[100009],b[100009];
  cin>>n>>h;
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i];
    d=max(d,a[i]);
  }
  sort(b,b+n);
  reverse(b,b+n);
  int cnt=0;
  for(int i=0;i<n;i++){
    if(d>b[i]){
      cout<<cnt+(h+d-1)/d<<endl;
      return(0);
    }
    h-=b[i];
    cnt++;
    if(h<=0){
      cout<<cnt<<endl;
      return(0);
    }
  }
  cout<<cnt+(h+d-1)/d<<endl;
  return(0);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
vector<int> dy={1,0,-1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main(){
    int n,m;
    cin>>n>>m;
    priority_queue<int> que;
    rep(i,n){
        int a;
        cin>>a;
        que.push(a);
    }
    
    rep(i,m){
        int x=que.top();
        que.pop();
        x/=2;
        que.push(x);
    }
    
    ll ans=0;
    rep(i,n){
        ans+=(ll)que.top();
        que.pop();
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 892
H,W=map(int,input().split())
A=[list(input()) for _ in range(H)]

ans=[["#"]*(W+2) for _ in range(H+2)]
for i in range(1,H+1):
    for j in range(1,W+1):
        ans[i][j]=A[i-1][j-1]

for i in range(H+2):
    print("".join(ans[i]))

Measured memory_bytes: 3188
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int p = sc.nextInt();
        int q = sc.nextInt();
        int r = sc.nextInt();
        int result = 0;

        int min = Math.min(p,q);
        int max = Math.max(p,q);

        result += min;

        int secondmin = Math.min(max,r);

        result += secondmin;


        System.out.println(result);
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <stack>

using namespace std;


set<int> Union(const set<int> &A,const set<int> &B){
	set<int> ret;
	for(set<int>::iterator it = A.begin(); it!=A.end(); it++){
		ret.insert(*it);
	}
	for(set<int>::iterator it=B.begin(); it!=B.end(); it++){
		ret.insert(*it);
	}
	return ret;
}

set<int> Intersection(const set<int> &A,const set<int> &B){
	set<int> ret;
	for(set<int>::iterator it=B.begin(); it!=B.end(); it++){
		if(A.find(*it)!=A.end())
			ret.insert(*it);
	}
	return ret;
}

set<int> Difference(const set<int> &A,const set<int> &B){
	set<int> ret;
	for(set<int>::iterator it=A.begin(); it!=A.end(); it++){
		if(B.find(*it)==B.end())
			ret.insert(*it);
	}
	return ret;
}

set<int> SymmetricDifference(const set<int> &A,const set<int> &B){
	return Union(Difference(A,B),Difference(B,A));
}

set<int> Complement(const set<int> &A,const set<int> &U){
	set<int> ret;
	for(set<int>::iterator it = U.begin(); it != U.end(); it++){
		if(A.find(*it)==A.end())
			ret.insert(*it);
	}
	return ret;
}

map<char,set<int> > sets;

set<int> analysis(string str){
	stack<int> s;
	if(str.size()==1){
		return sets[str[0]];
	}
	else if(str[0]=='('&&str[str.size()-1]==')'){
		bool f=false;
		for(int i = 0; i < str.size(); i++){
			if(str[i]=='('){
				s.push(1);
			}
			else if(str[i]==')'){
				s.pop();
			}
			if(i!=str.size()-1&&s.size()==0)
				f=true;
		}
		if(!f){
			return analysis(str.substr(1,str.size()-2));
		}
	}
	// ÊÉðÍ.ãë©ç©Ä¢«Astackª0ÌóÔÅZqð©Â¯½çAÄA·é.
	for(int i = str.size()-1; i >= 0; i--){
		if(str[i]==')'){
			s.push(1);
		}
		else if(str[i]=='('){
			s.pop();
		}
		else if(s.size()==0){
			if(str[i]=='u'){
				return Union(analysis(str.substr(0,i)),analysis(str.substr(i+1)));
			}
			else if(str[i]=='i'){
				return Intersection(analysis(str.substr(0,i)),analysis(str.substr(i+1)));
			}
			else if(str[i]=='d'){
				return Difference(analysis(str.substr(0,i)),analysis(str.substr(i+1)));
			}
			else if(str[i]=='s'){
				return SymmetricDifference(analysis(str.substr(0,i)),analysis(str.substr(i+1)));
			}
		}
	}
	if(str[0]=='c'){
		return Complement(analysis(str.substr(1)),sets['U']);
	}
}

int main(){


	while(1){
		sets.clear();
		//for(char ch='A'; ch <= 'E'; ch++){
		//	sets[ch];
		//}
		//sets['U'];

		char ch;
		bool f=false;
		while(cin>>ch){
			if(ch=='R'){
				int t;
				cin>>t;
				f=true;
				break;
			}
			f=true;
			int n;
			cin>>n;
			for(int i = 0; i < n; i++){
				int t;
				cin>>t;
				sets[ch].insert(t);
				sets['U'].insert(t);
			}
		}
		if(!f)
			break;
		string str;
		cin>>str;
		set<int> s = analysis(str);
		if(s.size()==0)
			cout<<"NULL"<<endl;
		else{
			for(set<int>::iterator it = s.begin(); it!=s.end(); it++){
				cout<<*it;
				if(it==--(s.end())){
					cout<<endl;
				}
				else
					cout<<" ";
			}
		}
	}
		
	return 0;
}

Measured memory_bytes: 0
a,b = map(int,input().split())
if a*b <= 0:
  print("Zero")
elif a*b > 0:
  if a > 0:
    print("Positive")
  elif a < 0:
    if b > 0:
      if a%2 == 0:
        print("Positive")
      else:
        print("Negative")
    else:
      if (b-a)%2 == 0:
        print("Negative")
      else:
        print("Positive")


Measured memory_bytes: 2940
#include<iostream>
#include<map>

using namespace std;

int main() {
  int n, m, a;
  while(cin>>n>>m>>a && !(n==0 && m==0 && a==0)) {
    map<pair<int, int>, int> myMap;
    int maxH = 0;
    for(int i=0; i<m; i++) {
      int h, p, q;
      cin>>h>>p>>q;
      myMap.insert(make_pair(make_pair(h, p), q));
      myMap.insert(make_pair(make_pair(h, q), p));
      if(maxH < h) {
	maxH = h;
      }
    }
    int now = a;
    for(int i=maxH; 0<i; i--) {
      /*
      map<pair<int, int>, int>::iterator itr;
      itr = myMap.find(make_pair(i, now));
      if(itr != myMap.end()) {
	now = myMap[itr->first];
	cout<<"moved"<<endl;
      }
      */
      if(myMap.find(make_pair(i, now)) != myMap.end()) {
	now = myMap[make_pair(i,now)];
	//cout<<"moved"<<endl;
      }
      /*
      else {
	cout<<"not"<<endl;
      }
      */
    }
    cout<<now<<endl;
  }
}

Measured memory_bytes: 1320
#include "bits/stdc++.h"
using namespace std;
int INF = numeric_limits<int>::max() / 2;
using ll = long long;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string ans = "";
    while(n != 1 && n != 0){
        int amari = n%-2;
        int shou = n/-2;
        if(amari == -1){
            shou++;
            amari = 1;
        }
        ans = to_string(amari) + ans;
        n = shou;
    }
    ans = to_string(n) + ans;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    String s = sc.next();
    int K = Integer.parseInt(sc.next());

    ArrayList<String> subs = new ArrayList<>();
    for (int i = 0; i < s.length(); i++) {
      for (int j = 0; j < 5; j++) {
        if (i + j >= s.length()) {
          break;
        }
        subs.add(s.substring(i, i + j + 1));
      }
    }
    subs.sort(null);
    String ans = subs.get(0);
    int count = 1;
    if (count == K) {
      System.out.println(ans);
      return;
    }
    for (int i = 1; i < subs.size(); i++) {
      if (ans.equals(subs.get(i))) {
        continue;
      } else {
        ans = subs.get(i);
        count++;
      }
      if (count == K) {
        System.out.println(ans);
        break;
      }
    }
  }
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	int n, m, i, j;
	cin >> n >> m;
	vi num(n, 1);
	vector<bool> pos(n, false);
	pos[0] = true;
	for (i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		if (pos[x]) {
			if (num[x] == 1) {
				pos[x] = false;
			}
			num[x]--;
			num[y]++;
			pos[y] = true;
		}
		else {
			num[x]--;
			num[y]++;
		}
	}
	int ans = 0;
	for (i = 0; i < n; i++) {
		if (pos[i]) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.*;
public class Main{

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int l = Integer.parseInt(sc.next());
        
        //n行m列の行列A
        long[][] list_a = new long[n][m];
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                list_a[i][j] = Integer.parseInt(sc.next());
            }
        }
        
        //m行l列の行列B
        long[][] list_b = new long[m][l];
        for(int i=0; i<m; i++){
            for(int j=0; j<l; j++){
                list_b[i][j] = Integer.parseInt(sc.next());
            }
        }
        
        //n行l列の行列C
        long[][] list_c = new long[n][l];
        for(int i=0; i<n; i++){
            for(int j=0; j<l; j++){
                for(int k=0; k<m; k++){
                    list_c[i][j] += list_a[i][k] * list_b[k][j];
                }
            }
        }
        
        //出力
        for(int i=0; i<n; i++){
            StringBuilder sb = new StringBuilder();
            for(int j=0; j<l; j++){
                sb.append(list_c[i][j]);
                sb.append(" ");
            }
            sb.deleteCharAt(sb.lastIndexOf(" "));
            System.out.println(sb);
        }
    }

}



Measured memory_bytes: 46572
#include<iostream> 
#include<cstring>
#define MAX 50 
#include<algorithm>
using namespace std; 
  
void printString(long long n) 
{ 
    char str[50];  
    long long i = 0; 
  
    while (n > 0) { 
       
        int rem = n % 26; 
  
       
        if (rem == 0) { 
            str[i++] = 'z'; 
            n = (n / 26) - 1; 
        } 
        else 
        { 
            str[i++] = (rem - 1) + 'a'; 
            n = n / 26; 
        } 
    } 
    str[i] = '\0'; 
  
    reverse(str,str+strlen(str)); 
    cout<<str<<endl; 
  
    return; 
} 
 
int main() {
    long long a;
    cin>>a;
     printString(a);

}

Measured memory_bytes: 3628
using System;
using System.IO;
using System.Collections.Generic;

namespace Prog {
	public struct Process {
		public int start;
		public int end;
		public int time;
	}
	
	enum NewLine { CRLF, LF, CR };
	
	public class Prog {
		
		static NewLine newline;
		static byte[] text = null;
		static byte[] res = null;
		
		public static int ReadInteger(Stream s) {
			byte c = (byte)s.ReadByte();
			while (c < 0x30) c = (byte)s.ReadByte();
			int sum = 0;
			do {
				sum *= 10;
				sum += (byte)(c - 0x30);
				c = (byte)s.ReadByte();
			} while (c >= 0x30);
			return sum;
		}
		
		public static int ReadInteger(ref int idx) {
			while (text[idx] < 0x30) idx++;
			int sum = 0;
			do {
				sum *= 10;
				sum += text[idx] - 0x30;
				idx++;
			} while (text[idx] >= 0x30);
			return sum;
		}
		
		public static void Print(ref int pos, int num) {
			int n = num;
			int digit = 10000000;
			bool isPrinting = false;
			while (digit != 0) {
				int div = n / digit;
				if (div != 0 || isPrinting) {
					isPrinting = true;
					res[pos++] = (byte)(0x30 + div);
				}
				n %= digit;
				digit /= 10;
			}
			if (!isPrinting)
				res[pos++] = 0x30;
		}
		
		public static void Main() {
			Console.In.Close();
			Console.Out.Close();
			if (System.Environment.NewLine == "\r\n") newline = NewLine.CRLF;
			else if (System.Environment.NewLine == "\n") newline = NewLine.LF;
			else newline = NewLine.CR;
			
			Stream si = Console.OpenStandardInput();
			int n = ReadInteger(si);
			int q = ReadInteger(si);
			
			int maxTextLen = n * 21;
			text = new byte[maxTextLen];
			int textlen = si.Read(text, 0, maxTextLen - 1);
			text[textlen] = 0x00; // ??????
			si.Close();
			
			Process[] procs = new Process[n];
			{
				int idx = 0;
				for (int i = 0; i < n; i++) {
					while (text[idx] < 0x30) idx++;
					procs[i].start = idx;
					while (text[idx] >= 0x30) idx++;
					procs[i].end = idx;
					procs[i].time = ReadInteger(ref idx);
				}
			}
			
			var queue = new Queue<int>(n);
			for (int i = 0; i < n; i++) queue.Enqueue(i);
			
			res = new byte[maxTextLen];
			int pos = 0;
			int elapsed = 0;
			while (queue.Count != 0) {
				int idx = queue.Dequeue();
				if (procs[idx].time <= q) {
					Array.Copy(text, procs[idx].start,
					           res, pos,
					           procs[idx].end - procs[idx].start);
					pos += procs[idx].end - procs[idx].start;
					res[pos++] = 0x20;
					elapsed += procs[idx].time;
					Print(ref pos, elapsed);
					if (newline == NewLine.CRLF) {
						res[pos++] = 0x0d;
						res[pos++] = 0x0a;
					} else if (newline == NewLine.LF) {
						res[pos++] = 0x0a;
					} else {
						res[pos++] = 0x0d;
					}
				} else {
					procs[idx].time -= q;
					elapsed += q;
					queue.Enqueue(idx);
				}
			}
			
			Stream so = Console.OpenStandardOutput();
			so.Write(res, 0, pos);
			so.Close();
		}
	}
}

Measured memory_bytes: 12384
import java.util.*;
import java.lang.*;
import java.io.*;
 public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
       int n=sc.nextInt();
        double d=sc.nextDouble();
        int a[]=new int[n];
        int b[]=new int[n];	

     for(int i=0;i<n;i++){
     	a[i]=sc.nextInt();
     	b[i]=sc.nextInt();
           }

       int count=0;
           for(int i=0;i<n;i++){
           	if(func(a[i],b[i])<=d)
           		count++;
           }
           System.out.println(count);
     }
	

	public static double func(int a,int b){
		double a1=Math.pow(a,2);
		double b1=Math.pow(b,2);
		double c=Math.sqrt(a1+b1);
		return c;
	}
}







Measured memory_bytes: 63792
N = int(input())
A = list(map(int, input().split()))

A = [A[i] - i - 1 for i in range(N)]
A = sorted(A)
indx = int(len(A) / 2)

b = sum([abs(a - A[indx]) for a in A])

ans = [b]

if N > 1:
    b1 = sum([abs(a - A[indx-1]) for a in A])
    ans.append(b1)

if N > 2:
    b2 = sum([abs(a - A[indx+1]) for a in A])
    ans.append(b2)

print(min(ans))

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

int main(){
  ll a,b,x;
  cin >> a >> b >> x;
  ll ans=0;
  if(a==0) ans=b/x+1;
  else ans=b/x-(a-1)/x;
  cout << ans << endl;
}

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

int main(){
  vector <int> x(5);
  
  for(int i=0; i<5; i++){
    cin >> x.at(i);
  }
  
  for(int i=0; i<5; i++){
    if(x.at(i) == 0){
      cout << (i+1) << endl;
      break;
    }
  }
}

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

int main(){
    long int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    long long int lr[n][2];

    for(int i = 0; i < q; i++){
        cin >> lr[i][0] >> lr[i][1];
    }

    long long int dp[n];
    fill_n(dp, n, 0);
    int flag_a = 0;
    int count_ac = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'A'){
            flag_a = 1;
        }
        else if(s[i] == 'C'){
            if(flag_a == 1){
               count_ac++;
            }
            flag_a = 0;
        }
        else {
            flag_a = 0;
        }
        dp[i] = count_ac;
        //cout << dp[i] << endl;
    }

    //dp[n-1] = count_ac;

    long long ans = 0;
    for(long long int i = 0; i < q; i++){
        if(lr[i][0] == 1){
            cout << dp[lr[i][1]-1] << endl;
        }
        else {
            cout << dp[lr[i][1]-1] - dp[lr[i][0]-1] << endl;
            
        }
    }
}

Measured memory_bytes: 3456
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<stdio.h>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int a, b, t;
	cin >> a >> b >> t;
	int c = 0;
	int i = 1;
	while (t + 0.5 >= a * i) {
		c++;
		i++;
	}
	cout << b * c << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;




int main() {
//    cout << fixed << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    ll n, m, v, p;
    cin >> n >> m >> v >> p;
    ll a[n], b[n];
    for (ll i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n, greater<>());


    ll ans = 0;
    ll l = 0, r = n - 1, mid;
    while (l <= r) {
        ll done[n];
        mid = (l + r) / 2;
        done[mid] = m;
        copy(a, a + n, b);
        ll rem = m * v - m;
        b[mid] += m;
        for (ll i = 0; i < n; i++) {
            if (i == mid) continue;
            if (b[i] > b[mid]) {
                ll here = min((ll) m, rem);
                b[i] += here;
                rem -= here;
                done[i] = here;
            }

            else {
                ll here = min({rem, m, b[mid] - b[i]});
                rem -= here;
                done[i] = here;
                b[i] += here;
            }
        }

        for (ll i = 0; i < n; i++) {
            if (rem && done[i] < m) {
                ll here = min(rem, (ll) m - done[i]);
                rem -= here;
                b[i] += here;
            }
        }

        ll here = b[mid];
        sort(b, b + n, greater<>());
        if (here >= b[p - 1]) {
            ans = mid;
            l = mid + 1;
        }

        else {
            r = mid - 1;
        }
    }

    cout << ans + 1;

}

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

int main() {
    string stra;
    int x;
    cin >> stra;
    x= stra.length();
    for(int i=0;i<x;i++){
        int j=i+1;
        if(j%2!=0){
            cout << stra[i];
        }
    }
    cout << endl;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;pair<string,int> a[100];int main(){int t=0,g,i;string f,b;while(cin>>a[t].first>>a[t].second)t++;sort(a,a+t);b=a[0].first;cout<<b<<endl<<a[0].second;for(i=1;i<t;i++){bool n=0;f=a[i].first,g=a[i].second;if(i)if(f==b)n=1;if(n)cout<<" "<<g;else cout<<endl<<f<<endl<<g;b=f;}cout<<endl;return 0;}

Measured memory_bytes: 1232
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    s = str(readline().rstrip().decode('utf-8'))
    k = int(readline())
    r = s[k-1]
    ans = []
    for i in range(n):
        if s[i] != r:
            ans.append("*")
        else:
            ans.append(r)
    print("".join(ans))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
#include <bitset>
#include <set>

using ll = long long;
using namespace std;

int main(void) {
	int n, m;
	cin >> n >> m;
	
	vector<int> s(m), c(m);
	for(int i = 0; i < m; ++i) {
		cin >> s[i] >> c[i];
	}
	
	int ans = -1;
	for(int i = 999; i >= 0; i--) {
		string tmp = to_string(i);
		bool ok = true;
	
		if( tmp.size() != n ) ok = false;
		
		int j = 0;
		while( ok && j < m ) {
			if( tmp[s[j] - 1] != (char)('0' + c[j]) ) ok = false; 
			j++;
		}
		
		if( ok ) ans = i;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
  
typedef enum {
    S = 0,
    N,
    W,
    E
} cmd;
  
  
void showdice(int dice[7]) {
    int i;
  
    for (i = 1; i <= 6; ++i) {
        printf("%d ", dice[i]);
    }
    printf("\n");
    return;
}
  
void rotation(cmd command, int dice[7]) {
    int tmp;
    switch (command) {
    case S:
        tmp = dice[1];
        dice[1] = dice[5];
        dice[5] = dice[6];
        dice[6] = dice[2];
        dice[2] = tmp;
        break;
    case N:
        tmp = dice[1];
        dice[1] = dice[2];
        dice[2] = dice[6];
        dice[6] = dice[5];
        dice[5] = tmp;
        break;
    case W:
        tmp = dice[1];
        dice[1] = dice[3];
        dice[3] = dice[6];
        dice[6] = dice[4];
        dice[4] = tmp;
        break;
    case E:
        tmp = dice[1];
        dice[1] = dice[4];
        dice[4] = dice[6];
        dice[6] = dice[3];
        dice[3] = tmp;
    }
    return;
}
  
void toFront(int front, int dice[7]) {
  
     if (front == dice[1]) {
        rotation(S, dice);
    } else if(front == dice[2]) {
        ;
    } else if (front == dice[3]) {
        rotation(E, dice);
        rotation(N, dice);
    } else if (front == dice[4]) {
        rotation(W, dice);
        rotation(N, dice);
    } else if (front == dice[5]) {
        rotation(S, dice);
        rotation(S, dice);
    } else {
        rotation(N, dice);
    }
    return;
}
  
int isMatch(int dice1[7], int dice2[7]) {
    int i;
      
    toFront(dice1[2], dice2);
for (i = 0; (i < 3) && dice1[1] != dice2[1] ; ++i) {
     rotation(W, dice2);
    }
    if (dice1[1] != dice2[1]) return 0;
    for (i = 3; i <= 6; ++i) {
        if (dice1[i] != dice2[i]) return 0;
    }
    return 1;
}
  
int main(void) {
    int i, j, n;
    int dices[100][7] = {0};
  
    scanf("%d", &n);
  
    for (i = 0; i < n; ++i) {
        for (j = 1; j <= 6; ++j) {
            scanf("%d", &dices[i][j]);
        }
    }
    for (i = 0; i < n; ++i) {
        for (j = 0; j < n; ++j) {
            if (i != j) {
                if (isMatch(dices[i], dices[j])) {
                    printf("No\n");
                    return 0;
                }
            }
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 2112
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }
        static void Solve()
        {
            var N = Sarray()[0];
            Ai = Sarray();
            memo = new Dictionary<(long n, long i), long>();
            WriteLine(DFS(N - 1, N / 2));
        }
        static long[] Ai;
        static Dictionary<(long n,long i),long> memo;
        static long DFS(long n, long i) //現在index、残り選択数
        {
            if (memo.ContainsKey((n, i))) return memo[(n, i)];
            if (i <= 0) return 0;
            var s = (n + 2) / 2; //選べる数
            if (s < i) return long.MinValue / 2;
            return memo[(n, i)] = Max(DFS(n - 1, i), Ai[n] + DFS(n - 2, i - 1));
        }


        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

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

int main() {
  string a;
  cin >> a;
  if (a=="A"||a=="B"||a=="C"||a=="D"||a=="E"||a=="F"||a=="G"||a=="H"||a=="I"||a=="J"||a=="K"||a=="L"||a=="M"||a=="N"||a=="O"||a=="P"||a=="Q"||a=="R"||a=="S"||a=="T"||a=="U"||a=="V"||a=="W"||a=="X"||a=="Y"||a=="Z") {
    a="A";
  }
  else {
    a="a";
  }
  cout << a << endl;
}

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

int main()
{
  string s="CODEFESTIVAL2016",ss;
  int ans=0;
  cin>>ss;
  for(int i=0;i<16;i++)
  if(s[i]!=ss[i]) ans++;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    string N;
    cin >> N;

    for(int i = 0; i < 3; i++) {
        if(N[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007


int main(){
    int n;
    cin >>n;
    string s = to_string(n);
    int l = s.length();
    int sum=0;
    for(int i=0;i<l;i++){
        sum += s[i]-'0';//charの数字をintに変換するときは-'0'するといい
    }
    if(n%sum==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    uint64 N, K; cin >> N >> K;
    vector<int64> vA(N);
    for(uint i=0; i<N; ++i){ cin >> vA[i]; }
    
    // count num 0 1
    uint64 max = 0ull;
    int numShift = 64 - __builtin_clzll(K) - 1;
    for(uint64 digit_i=1ull<<numShift; digit_i!=0ull; digit_i>>=1){
        uint64 num0 = 0ull;
        uint64 num1 = 0ull;
        for(uint i=0; i<N; ++i){
            if(digit_i & vA[i]){ ++num1;
            }       else       { ++num0; }
        }
        max <<= 1;
        if(num1 <= num0){ max += 1ll; }
    }
    
    uint64 X  = 0ull;
    uint64 K2 = 0ull;
    for(uint64 digit_i=1ull<<numShift; digit_i!=0ull; digit_i>>=1){
        X  <<= 1; if(max & digit_i){ ++X;  }
        K2 <<= 1; if(K   & digit_i){ ++K2; }
        if(X>K2){ --X; }
    }
    
    uint64 sum=0ull;
    for(uint i=0; i<N; ++i){
        sum += X ^ vA[i];
    }
    cout << sum << endl;
    
    return 0;
}


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

int main() {
	typedef complex<double> com;
	double s = 0.0;
	int n, x0, y0, x1, y1, x2, y2;
	cin >> n >> x0 >> y0 >> x1 >> y1;
	for ( int i = 0; i < n - 2; i++ ) {
		cin >> x2 >> y2;
		s += ( conj( com( x1 - x0, y1 - y0 ) ) * com( x2 - x0, y2 - y0 ) ).imag() * 0.5;
		x1 = x2;
		y1 = y2;
	}
	printf( "%.1f\n", s );
}

Measured memory_bytes: 1200
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#ifdef  _DEBUG
#define debug(x) cout << "debug" << ": " << x << endl;
#else
    #define debug(x)
#endif

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)
#define all(v) (v).begin(),(v).end()

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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;
}

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    return gcd(b, a%b);
}

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

constexpr ll INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pair<int,int>> ans;
    if(n%2==1){
        for(int i = 1; i<n; i++){
            ans.emplace_back(make_pair(i,n));        
        }
        for(int i = 1; i<n; i++){
            for(int j = i+1; j<n; j++){
                if(i+j!=n){
                    ans.emplace_back(make_pair(i,j));
                }
            }
        }
    }
    else{
        for(int i = 1; i<n+1; i++){
            for(int j = i+1; j<n+1; j++){
                if(i+j!=n+1){
                    ans.emplace_back(make_pair(i,j));
                }
            }
        }
    }
    cout << ans.size() << endl;
    for(auto a: ans){
        cout << a.first << " " << a.second << endl;
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <stack>
#include <queue>
#include <utility>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;


int main(){
	int w,h,n;
	cin>>w>>h>>n;
	vi p(n);
	rep(i,0,n) cin>>p[i];
	int x1=0,y1=0,x2=0,y2=1,ans=0;
	int dx[3]={0,-1,0},dy[3]={1,0,-1};
	rep(i,0,n){
		if(p[i]==0){
			if(x1<w-1 && y1==0) x1++;
			else if(x1==w-1 && y1<h-1) y1++;
			else x1--;
		}else{
			if(x2<w-2 && y2==1) x2++;
			else if(x2==w-2 && y2<h-2) y2++;
			else x2--;
		}
		bool f=0;
		rep(j,0,3){
			if(x1+dx[j]==x2 && y1+dy[j]==y2){
				f=1; break;
			}
		}
		if(f) ans++;
	}
	o(ans);
}

Measured memory_bytes: 1196
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N):
    a = L[i]
    for j in range(i + 1, N):
        b = L[j]
        for k in range(j + 1, N):
            c = L[k]
            if a < b < c and a + b > c:
                ans += 1
print(ans)

Measured memory_bytes: 9136
#include "bits/stdc++.h"
#define ll long long
#define inf 1000000007
#define sort(vec) sort((vec).begin(),(vec).end());
#define rever(vec) reverse((vec).begin(),(vec).end());
#define unsort(vec) sort((vec)); rever((vec));
using namespace std;

int main() {
  int a;
  cin>>a;
  int gray=0;
  int blown=0;
  int green=0;
  int sblue=0;
  int blue=0;
  int yellow=0;
  int orange=0;
  int red=0;
  int free=0;
  int ans=0;
  for(int i=0;i<a;i++) {
    int n;
    cin>>n;
    if(n<400) {
      gray++;
    }
    else if(n<800) {
      blown++;
    }
    else if(n<1200) {
      green++;
    }
    else if(n<1600) {
      sblue++;
    }
    else if(n<2000) {
      blue++;
    }
    else if(n<2400) {
      yellow++;
    }
    else if(n<2800) {
      orange++;
    }
    else if(n<3200) {
      red++;
    }
    else {
      free++;
    }
  }
  if(gray) {
    ans++;
  }
  if(blown) {
    ans++;
  }
  if(green) {
    ans++;
  }
  if(sblue) {
    ans++;
  }
  if(blue) {
    ans++;
  }
  if(yellow) {
    ans++;
  }
  if(orange) {
    ans++;
  }
  if(red) {
    ans++;
  }
  if(ans!=0) {
    cout<<ans<<" "<<ans+free<<endl;
  }
  else {
    cout<<"1"<<" "<<free<<endl;
  }
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<tuple<int, int, int>> p; // x, y, h
    for (int i = 0; i < N; i++) {
        int x, y, h;
        cin >> x >> y >> h;
        p.push_back(make_tuple(x, y, h));
    }

    sort(p.begin(), p.end(),
         [](auto a, auto b) { return get<2>(a) > get<2>(b); });

    // 0 <= Cx,Cy <= 100, H >= 1
    for (int Cx = 0; Cx <= 100; Cx++) {
        for (int Cy = 0; Cy <= 100; Cy++) {
            int H = get<2>(p[0]) + abs(get<0>(p[0])-Cx) + abs(get<1>(p[0])-Cy);
            bool flag = true;
            for (int i=1;i<N;i++) {
                if (get<2>(p[i]) == 
                    max(H - abs(get<0>(p[i])-Cx) - abs(get<1>(p[i])-Cy), 0)) continue;
                flag = false;
                break;
            }
            if (flag) {
                cout << Cx << " " << Cy << " " << H << endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
  int h,w;
  cin>>h>>w;
  char a[h][w];
  for(int i(0);i<h;i++){
    for(int j(0);j<w;j++){
      cin>>a[i][j];
    }
  }
  for(int i(0);i<w+2;i++){
    cout<<"#";
  }
  cout<<endl;
  for(int i(0);i<h;i++){
    cout<<"#";
    for(int j(0);j<w;j++){
      cout<<a[i][j];
    }
    cout<<"#"<<endl;
  }
  for(int i(0);i<w+2;i++){
    cout<<"#";
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256