akhauriyash/Code-Regression huggingface dataset:
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=924844033;


typedef long double D;
typedef complex<long double> P;

template<typename D=long double,typename P=complex<long double>>
struct Geometry{
    const D EPS=1e-9;
    
    P project(P vec,P x){return vec*(x/vec).real();}
    
    P project(P p1,P p2,P x){return p1+project(p2-p1,x-p1);}
    
    P reflect(P vec,P x){return vec*conj(x/vec);}
    
    P reflect(P p1,P p2,P x){return p1+reflect(p2-p1,x-p1);}
    
    D dot(P p1,P p2){return p1.real()*p2.real()+p1.imag()*p2.imag();}
    
    D cross(P p1,P p2){return p1.real()*p2.imag()-p1.imag()*p2.real();}
    
    D area(const vector<P> &poly){
        D ans=0;
        for(int i=2;i<poly.size();i++){ans+=cross(poly[i-1]-poly[0],poly[i]-poly[0]);}
        return ans/2;
    }
    
    vector<P> convexhull(vector<P> pts){
        vector<P> ret;
        sort(pts.begin(),pts.end(),[](P a,P b){return (a.real()<b.real() || (a.real()==b.real() && a.imag()<b.imag()));});
        for(auto &I:pts){
            if(!ret.empty() && I==ret.back()){continue;}
            while(ret.size()>=2 && cross(ret.back()-ret[ret.size()-2],I-ret.back())<-EPS){ret.pop_back();}
            ret.push_back(I);
        }
        reverse(pts.begin(),pts.end());
        for(auto &I:pts){
            if(!ret.empty() && I==ret.back()){continue;}
            while(ret.size()>=2 && cross(ret.back()-ret[ret.size()-2],I-ret.back())<-EPS){ret.pop_back();}
            ret.push_back(I);
        }
        if(ret[0]==ret.back()){ret.pop_back();}
        return ret;
    }
};



int main(){
    Geometry<D,P> G;
    ll n;
    cin>>n;
    vector<P> A(n);
    for(auto &I:A){
        D x,y;
        cin>>x>>y;
        I={x,y};
    }
    A=G.convexhull(A);
    deque<P> B(A.size());
    cout<<B.size()<<endl;
    for(int i=0;i<A.size();i++){B[i]=A[i];}
    while(B[0].imag()>B[1].imag()){B.push_back(B[0]); B.pop_front();}
    for(int i=0;i<B.size();i++){
        cout<<B[i].real()<<" "<<B[i].imag()<<endl;
    }
    
    
    return 0;
}



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

int main(){
  int a,b;
  char op;

  while(1){
    cin >> a >> op >> b;

    if(op=='?'){
      break;
    }
    switch(op){
      case '+':
        cout << a+b << endl;
        break;
      case '-':
        cout << a-b << endl;
        break;
      case '*':
        cout << a*b << endl;
        break;
      case '/':
        cout << a/b << endl;
        break;
      default:
        break;
    }
  }
  
  return(0);
}

Measured memory_bytes: 1160
INF = 10**12

H, N = map(int, input().split())
magics = [tuple(map(int, input().split())) for _ in range(N)]
dp = [[INF]*(H+1) for _ in range(N+1)]
dp[0][0] = 0
for i, (a, b) in enumerate(magics):
    for j in range(H+1):
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])
        dp[i+1][min(H, j+a)] = min(dp[i+1][min(H, j+a)], dp[i+1][j] + b)
print(dp[N][H])

Measured memory_bytes: 121692
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define FOR(i, first, last) for (int i = (first); i < (last); ++i)
#define REP(i, n) FOR(i, 0, n)
#define CLR(a) memset((a), 0, sizeof(a))
#define DUMP(x) std::cerr << #x << " = " << (x) << std::endl;

inline int to_int(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string to_string(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

typedef unsigned long long ull;
typedef unsigned long ul;
typedef long long ll;

int main() {
  ll N,K;
  cin>>N>>K;
  
  vector<pair<ll,ll>> points;
  vector<ll> xs,ys;

  REP(i,N) {
    ll x, y;
    cin>>x>>y;
    points.emplace_back(x,y);
    xs.emplace_back(x);
    ys.emplace_back(y);
  }
  sort(points.begin(),points.end());

  ull ans = 1000000000*4*1000000000;
  DUMP(ans);
  for(int i=0; i<points.size();i++) {
    for(int j=points.size()-1;j>=0;j--) {
      if(i>=j || j-i+1<K) continue;

      vector<pair<ll,ll>> cand;
      for(int k=i;k<=j;k++) cand.emplace_back(points[k]);

      sort(cand.begin(), cand.end(),
           [](const auto& l, const auto& r) { return l.second < r.second; } );
      for(int l=0; l<cand.size();l++) {
        for(int m=cand.size()-1; m>=0; m--) {
          if(l>=m || m-l+1 < K) continue;
          DUMP(l);
          DUMP(m);
          DUMP(m-l+1-K);

          ll x1 = points[i].first;
          ll x2 = points[j].first;
          ll y1 = cand[l].second;
          ll y2 = cand[m].second;
          ull dx = x2 - x1;
          ull dy = y2 - y1;
          ans = min(dx*dy, ans);
        }
      }
    }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int A, B;
	cin >> A >> B;
	A--;
	B--;
	char c[100][100];
	REP(i, 50) {
		REP(j, 100) {
			c[i][j] = '#';
		}
	}
	FOR(i, 50, 100) {
		REP(j, 100) {
			c[i][j] = '.';
		}
	}

	for(int i=0;i<49;i+=2) {
		for (int j = 0; j < 100; j+=2) {
			if (A > 0) {
				c[i][j] = '.';
				A--;
			}
		}
		
	}
	for(int i=51;i<100;i+=2) {
		for (int j = 0; j < 100; j += 2) {
			if (B > 0) {
				c[i][j] = '#';
				B--;
			}
		}
	}
	cout << 100 << " " << 100 << endl;
	REP(i, 100) {
		REP(j, 100) {
			cout << c[i][j];
		}
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define fi first
//#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;

  vector<vector<int>> cs(10, vector<int>(10));

  FOR(i, 1, N + 1) {
    auto n = i;
    int h, t;
    t = n % 10;
    while(n) {
      h = n % 10;
      n /= 10;
    }
    if (h != 0 && t != 0) {
      cs[h][t]++;
    }
  }

  i64 result = 0;
  FOR(i, 1, 10) {
    FOR(j, 1, 10) {
      result += (i64)cs[i][j] * cs[j][i];
    }
  }
  cout << result;
}
#endif


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n;
    pair<ll, P> p[5010];

    cin >> n;
    REP(i, n)
    {
        cin >> p[i].second.first >> p[i].second.second;
        p[i].first = p[i].second.first + p[i].second.second;
    }

    sort(p, p + n);

    vector<P> q;

    REP(i, n)
    q.push_back(p[i].second);

    ll dp[5010][5010];

    REP(i, n + 1)
    REP(j, n + 1)
    dp[i][j] = INF;

    REP(i, n + 1)
    dp[i][0] = 0;

    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= i; j++)
        {
            //使う
            if (dp[i - 1][j - 1] <= q[i - 1].first)
                dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + q[i - 1].second);

            //使わない
            dp[i][j] = min(dp[i][j], dp[i - 1][j]);
        }
    }

    ll res = 0;
    REP(i, n + 1)
    {
        if (dp[n][i] < INF)
            res = i;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 196480
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;

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

  double ans = 0.0;
  for(int i=1; i<=N; i++){
    double p = 1.0/N; int tmp = i;
    while(tmp < K){
      p *= 0.5; tmp *= 2;
    }
    ans += p;
  }

  cout << setprecision(10);
  cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type edge struct {
	tail   int
	weight int
}

func dfs(adj [][]edge, visited []bool, dist []int, color []int, v int) {
	for _, e := range adj[v] {
		if visited[e.tail] {
			continue
		}
		visited[e.tail] = true
		dist[e.tail] = dist[v] + e.weight
		if dist[e.tail]%2 == 1 {
			color[e.tail] = 1
		}
		dfs(adj, visited, dist, color, e.tail)
	}
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt()

	adj := make([][]edge, n)
	visited := make([]bool, n)
	dist := make([]int, n)
	color := make([]int, n)
	for i := range adj {
		line := make([]edge, 0)
		adj[i] = line
	}

	for i := 0; i < n-1; i++ {
		u, v, w := nextInt(), nextInt(), nextInt()
		adj[u-1] = append(adj[u-1], edge{v - 1, w})
		adj[v-1] = append(adj[v-1], edge{u - 1, w})
	}

	visited[0] = true
	dfs(adj, visited, dist, color, 0)

	for _, c := range color {
		fmt.Println(c)
	}
}


Measured memory_bytes: 36992
/* ABC133-C.c
   Takatan */

#include<stdio.h>
#include<stdlib.h>
int main(void){
    int number, *array, max, second, i;
    max = 0;

    scanf( "%d" , &number);
    array = malloc(sizeof(int) * number);    
    for(i=0; i < number; i++){
        scanf( "%d" , array+i);
        if(max<=array[i]){
            second = max; /* 暫定1位を2位にずらす */
            max = array[i]; /* 暫定1意を更新 */
        }else if(second<array[i]){
            second = array[i]; /* 暫定2位を更新 */
        }
    }

    for(i=0; i < number; i++){
        if(array[i]==max){
            printf( "%d\n" , second); /* A_iがmaxのときsecondを出力 */
        }else{
            printf( "%d\n" , max); /* A_iがmaxでないといmaxを出力 */
        }
    }
    return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <string.h>
#include <map>
#include <set>
#include <bitset>
#include <queue>


#define ln cout<<'\n'
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
// sort(vec.begin(), vec.end()); std::greater<>()
// reverse(vec.begin(), vec.end());
// scanf("%s",s);
// printf("%d\n",end-start+1);
// ceil (a + (b - 1)) / b

using namespace std;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
using pll = pair<long long, long long>;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;


int main() {
   int N; cin >> N;
   vector<int> x(N);
   rep (i, N) cin >> x[i];
   sort(x.begin(), x.end());
   if(x[N/2 - 1] == x[N/2]) cout << 0 << endl;
   else cout << x[N/2] - x[N/2 -1 ] << endl; 
   
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000011
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
 
int main(){
 int n;
  cin>>n;
  vector<int> G[n];
  int v=n;
  int e=n-1;
  int zisu[n];
  ll val[n];
  
  rep(i, n){
    zisu[i]=0;
  val[i]=0;}
  
  for(int i=0;i<e;i++){
    int s,t;
    cin>>s>>t;
    G[s-1].push_back(t-1);
    G[t-1].push_back(s-1);
    zisu[s-1]++;
    zisu[t-1]++;
  }
  
  ll cnum[n];
  int cn=0;
  rep(i, n){
    cin>>cnum[i];}
  sort(cnum, cnum+n, greater<ll>());
  
  int zimax=0;
  int maxv=-1;
    rep(i, n){
    if(zisu[i]>zimax){
      zimax=zisu[i];
      maxv=i;}
    }

  
  queue<int> tv;
  tv.push(maxv);
  
  int nt=maxv;
    int incnt=1;
  ll ans=0;

 
  while(cn<=n-1){
    int kis=incnt;
      incnt=0;
  for(int i=0;i<kis;i++){
    nt=tv.front();
    tv.pop();
    int gsize=G[nt].size();
    rep(i, gsize){
      if(val[G[nt].at(i)]==0){
      tv.push(G[nt].at(i));
    incnt++;}
      }
      val[nt]=cnum[cn];
    cn++;
  }
  }

   for(int j=1;j<n;j++){
     ans+=cnum[j];}
  
  cout<<ans<<endl;
  for(int i=0;i<n-1;i++){
    cout<<val[i]<<" ";}
  cout<<val[n-1]<<endl;
  
  return 0;
  
  
 
}

Measured memory_bytes: 1152
#include<cstdio>
#include<algorithm>
using namespace std;

int a[200];
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int l;
        scanf("%d",&l);
        for(int i=0;i<l;i++) scanf("%d",&a[i]);
        int m1 = 0,m2 = 0;
        for(int i=0;i<l-1;i++){
            if(a[i]-a[i+1] > 0) m1 = max(m1,a[i]-a[i+1]);
            else m2 = max(m2,a[i+1]-a[i]);
        }
        printf("%d %d\n",m2,m1);
    }
    return 0;
}

Measured memory_bytes: 1024
fun main(args: Array<String>){
    val l1 = readLine()!!.split(" ").map { it.toInt() }
    val l2 = readLine()!!
    var result = ""
    for(i in 1..l1[0]){
        if(i == l1[1]){
            result +=l2[i-1].toLowerCase()
        }else{
            result += l2[i-1]
        }
    }
    println(result)
}

Measured memory_bytes: 38000
#include <iostream>

using namespace std;

int main(){

    int x,y,s,a,b,k,sum;

    while(1){
	cin >> x >> y >> s;
	if(x == 0 && y == 0 && s == 0) break;
	sum = 0;
	for(int i=1;i<s;i++){
		k=0;
		a=i*(100+x)/100;
		b=s-a;
		for(int j=1;j<=s-a;j++){
			if(j*(100+x)/100==b) k=j;
			if(sum < i*(100+y)/100+k*(100+y)/100) sum = i*(100+y)/100+k*(100+y)/100;
		}
	}
	cout << sum << endl;
    }
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main(){
  int n;cin>>n;
  int a[n];
  int sm = 0;
  for(int i = 0; n > i; i++){
    cin>>a[i];
    sm += a[i];
  }
  int ans = 0;
  while(sm != 0){
    bool t = false;
    for(int i = 0; n > i; i++){
      if(a[i] && !t){
        t = true;
        a[i]--;
        sm--;
      }else if(a[i]){
        a[i]--;
        sm--;
      }else if(t){
        ans++;
        t = false;
      }
      //cout << a[i] << " ";
    }
   	if(t)ans++;
  }
  cout << ans << endl;
}
  
  

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const long long maxn=100000+50;
long long n,m,w[maxn],v[maxn],dp[maxn];
int main()
{
	cin>>n>>m;
	for(long long i=1;i<=n;i++)cin>>w[i]>>v[i];
	for(long long i=1;i<=n;i++)
	{
		for(long long j=m;j>=w[i];j--)
		{
			dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
		}
	}
	cout<<dp[m]<<endl;
	return 0;
}
//Phoenix-ZH

Measured memory_bytes: 4392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	vector<ll> a(3);
	cin >> a[0] >> a[1] >> a[2];
	SORT(a);
	if(a[0]!=a[1]){
		cout << a[0] << endl;
	}else{
		cout << a[2] << endl; 
	}
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

n = input()
a = map(int, raw_input().split())

max = a[0]
min = a[0]
sum = 0

for i in range(n):
    if a[i] > max:
        max = a[i]
    elif a[i] < min:
        min = a[i]
    else:
        pass
    sum += a[i]

print "%d %d %d" %(min, max, sum)

Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
int main(){
  ll N;
  cin>>N;
  vector<int> A(N+1);
  rep(i,N) cin>>A[i];
  ll ans=0,left=0,S=0;
  rep(right,N){
    while(S&A[right]){
      S^=A[left];
      left++;
    }
    S|=A[right];
    ans+=right+1-left;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
 
int main(){
  string s;
  cin>>s;
  if(s[0]==s[2]){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
 
  return 0;
}

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

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;


//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i > n;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,m)  RFOR(i,m,0)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define fst first
#define snd second
#define SORT(V) sort((V).begin(),(V).end())
#define REV(V) reverse((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//grobal variable
//------------------------------------------

//def function, class
//------------------------------------------

//main
//------------------------------------------
signed main(){
  int A, B ,T;
  cin >> A >> B >>T;

  cout << T/A*B << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    cin>>a;
    
    for(int i = 1;i<=a;i++){
    b =i;
    if(i%3 == 0)cout<<" "<<i;
    else if(b%10==3)cout<<" "<<i;
    else if(b/10%10 == 3)cout<<" "<<i;
    else if(b/100%10 == 3)cout<<" "<<i;
    else if(b/1000%10 == 3)cout<<" "<<i;
    }
    cout<<endl;
    return 0;
}



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

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

		StringBuilder sb = new StringBuilder();
		while(true){
			String[] spl = br.readLine().split(" ");
            a=Integer.parseInt(spl[0]);
            b=Integer.parseInt(spl[1]);

            if(a==0 && b==0){
            	break;
            }
            else if(a>b){
            	sb.append(b).append(" ").append(a).append("\n");
            }else{
            	sb.append(a).append(" ").append(b).append("\n");
            }


		}
		System.out.print(sb);
	}
}

Measured memory_bytes: 26240
import java.io.*
import java.util.*

fun solve(A: Int, B: Int, C: Int, D: Int){
    println((Math.max(A,C) until Math.min(B, D)).toList().size)
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val A = sc.next().toInt()
    val B = sc.next().toInt()
    val C = sc.next().toInt()
    val D = sc.next().toInt()
    solve(A, B, C, D)
}



Measured memory_bytes: 29600
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define pb push_back//also for STRING

#define MAX 55555
const int ub=55555;
bool isprime[MAX+1];//Necessary for sieve.
int c=0,p[MAX+1];

void sieve(){//prime <= n in O(n log^2 n) through the Sieve of Eratosthenes
	fill(isprime,isprime+ub+1,true);
	isprime[0]=isprime[1]=false;
	int m=sqrt(ub);
	for(int i=2;i<=m;++i) if(isprime[i]){
		p[c++]=i;
		for(int j=i*i;j<=ub;j+=i) isprime[j]=false;
	}
	for(int i=m+1;i<=ub;++i) if(isprime[i]) p[c++]=i;
	return;
}

int main(){
	int n;
	scanf("%d",&n);
	sieve();
	for(int i=0;n>0&&i<c;++i) if(p[i]%5==1){
		if(n==1) printf("%d\n",p[i]);
		else printf("%d ",p[i]);
		--n;
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (int i = l; i < r; ++i)
#define int long long
#ifdef DEBUG
#define dout cout
#else
std::stringstream dout;
#endif
using namespace std;
typedef pair<int, int> P;
struct edge {
  int to, cost;
};
// other libs
int gcd(int a, int b) {
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}
int lcm(int a, int b) {
  return a * b / gcd(a, b);
}

class dijkstra {
private:
  int V;
  int d[100002];
  priority_queue<P, vector<P>, greater<>> que;

public:
  dijkstra(int v, int s, vector<edge> G[]) {
    V = v;
    update(s, G);
  }

  void update(int s, vector<edge> G[]) {
    fill(d, d + V + 1, 100000000000ll);
    d[s] = 0;
    que.push(make_pair(0, s));
    while (!que.empty()) {
      P p = que.top();
      que.pop();
      int v = p.second;
      if (d[v] < p.first)
        continue;
      rep(i, G[v].size()) {
        edge e = G[v][i];
        if (d[e.to] > d[v] + e.cost) {
          d[e.to] = d[v] + e.cost;
          que.push(make_pair(d[e.to], e.to));
        }
      }
    }
  }

  int find(int e) {
    return d[e];
  }
};
template<typename T>
class Union_Find {
private:
  vector<T> t, s;

public:
  Union_Find(T max_length) {
    rep(i, max_length + 1) {
      t.push_back(i);
      s.push_back(1);
    }
  }

  void Union(T x, T y) {
    if (same(x, y))
      return;
    T tx = Find(x), ty = Find(y);
    if (s[tx] < s[ty]) {
      s[ty] += s[tx];
      t[tx] = ty;
    }
    else if (s[tx] > s[ty]) {
      s[tx] += s[ty];
      t[ty] = tx;
    }
    else if (tx > ty) {
      t[tx] = ty;
      s[ty] += s[tx];
    }
    else {
      t[ty] = tx;
      s[tx] += s[ty];
    }
  }
  T Find(T n) {
    if (t[n] == n)
      return n;
    else
      return t[n] = Find(t[n]);
  }

  bool same(T x, T y) {
    return Find(x) == Find(y);
  }

  T get_Size(size_t a) {
    return s[a];
  }
};
bool ifPrime(int n) {
  if (n == 1)
    return false;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0)
      return false;
  }
  return true;
}

set<int> prime_num_factor(int n){
  if(n<2)return set<int>();
  set<int> prime;
  prime.insert(2);
  for(int i=3;i<=n;i++){
    for(int it:prime){
      if(it*it>i){
        prime.insert(i);
        break;
      }
      if(i%it==0)break;
    }
  }
  return prime;
}
vector<int> makeDivisors(int n){
  vector<int> re;
  REP(i,1,sqrt(n)+1){
    if(n%i==0){
      re.push_back(i);
      if(i!=n/i)re.push_back(n/i);
    }
  }
  return re;
}
int modPow(int a,int n,int mod){
  int ret=1;
  while(n){
    if(n&1)ret=ret*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return ret;
}
signed main(signed argc, char* argv[]) {
  int n;
  cin>>n;
  int ans=0;
  REP(i,1,n/2+1){
    if(i*2!=n)ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
a, b = list(), list()
for i in range(m):
    tmp = list(map(int, input().split()))
    a.append(tmp[0])
    b.append(tmp[1])

graph = [[] for _ in range(n)]
for i in range(m):
    graph[a[i] - 1].append(b[i] - 1)
    graph[b[i] - 1].append(a[i] - 1)

pathway = [None for _ in range(n)]
queue = [0]
depth = [-1]*n
depth[0] = 0
pre = [-1]*n

while queue:
    now = queue.pop(0)
    for i in graph[now]:
        if depth[i] == -1:
            if pre[i] == -1:
                pre[i] = now
            depth[i] = depth[now] + 1
            queue.append(i)

print("Yes")
for i in range(1, n):
    print(pre[i] + 1)


Measured memory_bytes: 51088
import std.stdio;
import std.conv;
import std.string;
import std.format;

void main()
{
  //string s = chomp(readln());
  //long l = to!long(s);

  string line;
  int count = 0;
  bool loop = true;

  while (loop) {

    line = readln();
    string s = chomp(line);

    int t = to!int(s);

    if (t == 0)
      break;

    count++;
    //if (count == 10000) {
    //  writef("Case %d: %s", count, s);
    //} else {
      writefln("Case %d: %s", count, s);
    //}
  }
}

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

using namespace std;

int main(){
	long long n, x;
	scanf("%lld %lld", &n, &x);
	long long ans = n;
	n -= x;
	bool flag = true;
	while (flag){
		if (x > n){
			swap(x, n);
		}
		long long temp = 2 * (n / x);			
		if (n % x == 0){
			temp -= 1;
			flag = false;
		}
		temp *= x;
		ans += temp;
		n %= x;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int ans = 0;
    string preStr = "A";
    for(int i=0; i<=s.size(); i++){
        if(s.substr(i, 1)!=preStr){
            ans++;
            preStr = s[i];
        }else{
            preStr = s.substr(i, 2);
            i++;
            ans++;
        }
    }
    cout << ans-1 << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fo(i, u, v) for(int i = u; i <= v; ++i)
#define fob(i, u, v) for(int i = u; i >= v; --i)
#define fi first
#define se second
#define si size()
#define pb push_back

using namespace std;
typedef double db;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const ll N = 1e6+7;
const ll inf = ll(1e18);
const ll  MOD = 1e9+7;
const string name = "template";
template <class T> int getbit(T x, int y) {return x >> (y-1) & 1;}
template <class T> T sqr(T x) {return x*x;}
template <class T> void read_int(T &rs) {
    char c;
    int sign = 1;
    for(c = getchar(); c < '0' || c > '9'; c = getchar())
        if(c == '-') sign *= -1;
    rs = (c - '0');
    for(c = getchar(); c >= '0' && c <= '9'; c = getchar())
        rs = rs*10 + (c - '0');
    rs *= sign;
}

ll n, a[N], l, r;

bool update(ll &x, ll &y, ll &d) {
    ll p;
    p = ceil(double(x) / double(d));
    x = p * d;
    p = y/d;
    y = p * d;
    if(x > y) return false;
    return true;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen((name + ".inp").c_str(), "r", stdin);
    //freopen((name + ".out").c_str(), "w", stdout);
    cin>>n;
    fo(i, 1, n) cin>>a[i];
    l = r = 2;
    fob(i, n, 1) {
        if(!update(l, r, a[i])) {cout<<-1; return 0;}
        r += a[i] - 1;
    }
    cout<<l<<" "<<r<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;
typedef vector<vector<pli>> wgraph;

vector<ll> bfs(wgraph v,int x){
    priority_queue<pli,vector<pli>,greater<pli>> q;
    vector<ll> dist(v.size(),longinf);
    dist[x]=0;
    q.push({0LL,x});
    while(q.size()){
        pli p=q.top();q.pop();
        ll d=p.first,now=p.second;
        if(dist[now]<d)continue;
        for(auto to:v[now]){
            if(dist[to.second]>d+to.first){
                dist[to.second]=d+to.first;
                q.push({dist[to.second],to.second});
            }
        }
    }
    return dist;
}
int main(){
    int n,m,s;
    cin>>n>>m>>s;
    wgraph v(n);
    rep(i,m){
        ll x,y,z;
        cin>>x>>y>>z;;
        v[x].push_back({z,y});
    }
    vector<ll> ans=bfs(v,s);
    rep(i,n){
        if(ans[i]==longinf)cout<<"INF"<<endl;
        else cout<<ans[i]<<endl;
    }
   return 0;
}


Measured memory_bytes: 30784
import math

n = int(input())
#n, k = [int(i) for i in input().split()]
#table = [[int(i) for i in input().split()] for j in range(n)]
#table = [list(input()) for n in range(h)]
#list = [int(i) for i in input().split()]
#num = [int(i) for i in range(n)]
#s = input()
#list = list(s)

kotae = 0

a = int(n // 1000)
b = int((n % 1000) / 100)
c = int((n % 100) / 10)
d = int(n % 10)

if (a == b) :
    kotae = 1
if (b == c) :
    kotae = 1
if (c == d) :
    kotae = 1

if (kotae == 0) :
    print("Good")
else :
    print("Bad")


Measured memory_bytes: 3316
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function () { return this.index < this.max },
        "next": function () { if (!this.hasNext()) { throw "ArrayIndexOutOfBoundsException"; } else { return this.list[this.index++]; } }
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const bs = (arr, x) => {
    let left = -1
    let right = arr.length
    while(right - left > 1){
        let mid = Math.floor((left + right)/2)
        if(arr[mid] <= x){
            left = mid
        }else{
            right = mid
        }
    }
    return left
}
const Main = () => {
    let [N, M, K] = nextIntArray()
    let a = nextIntArray()
    let b = nextIntArray()

    let sumA = [0]
    for (let i = 0; i < a.length; i++) {
        sumA.push(sumA[i] + a[i])
    }
    let sumB = [0]
    for (let i = 0; i < b.length; i++) {
        sumB.push(sumB[i] + b[i])
    }
    let res = 0
    for(let i = 0; i<sumA.length; i++){
        let left = K - sumA[i]
        if(left >= 0){
	        let idx = bs(sumB, left)
    	    res = Math.max(res, i+idx)
        }
    }
    console.log(res)
}
Main()


Measured memory_bytes: 67284
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;

vector<vector<long long int>>matrix_product(vector<vector<long long int>>v, vector<vector<long long int>>w) {
	vector<vector<long long int>>ret(v.size(), vector<long long int>(w.front().size()));
	for (int i = 0; i < ret.size(); i++) {
		for (int j = 0; j < ret[i].size(); j++) {
			for (int k = 0; k < w.size(); k++) {
				ret[i][j] += v[i][k] * w[k][j];
				ret[i][j] %= MOD;
			}
		}
	}
	return ret;
}

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

	cin >> N >> K;
	vector<vector<long long int>>v(N, vector<long long int>(N));
	for (auto &i : v) {
		for (auto &j : i)cin >> j;
	}
	vector<vector<long long int>>ans(N, vector<long long int>(1, 1));
	for (int i = 0; i < 62; i++) {
		if ((K >> i) & 1)ans = matrix_product(v, ans);
		v = matrix_product(v, v);
	}
	long long int ret = 0;
	for (auto i : ans)for (auto j : i)ret += j;
	ret %= MOD;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 384
#!/usr/bin/env python2
"""
This file is part of https://github.com/cheran-senthil/PyRival
Copyright 2019 Cheran Senthilkumar <hello@cheran.io>

"""
from __future__ import division, print_function

import itertools
import os
import sys
from atexit import register
from io import BytesIO


class dict(dict):
    """ dict() -> new empty dictionary """

    def items(self):
        """ D.items() -> a set-like object providing a view on D's items """
        return dict.iteritems(self)

    def keys(self):
        """ D.keys() -> a set-like object providing a view on D's keys """
        return dict.iterkeys(self)

    def values(self):
        """ D.values() -> an object providing a view on D's values """
        return dict.itervalues(self)


def gcd(x, y):
    """ greatest common divisor of x and y """
    while y:
        x, y = y, x % y
    return x


range = xrange

filter = itertools.ifilter
map = itertools.imap
zip = itertools.izip

sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))

input = lambda: sys.stdin.readline().rstrip('\r\n')


def main():
    n, m = map(int, input().split())
    a = [(0, 0) for _ in range(n)]

    for i in range(n):
        a[i] = tuple(map(int, input().split()))

    a.sort()
    cost = 0
    for ai in a:
        if ai[1] < m:
            cost += ai[1] * ai[0]
            m -= ai[1]
        else:
            cost += ai[0] * m
            break

    print(cost)


if __name__ == '__main__':
    main()


Measured memory_bytes: 43472
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 
 
	public static void main(String[] args) { 
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		long mod = 998244353;
		long[] depthCnt = new long[N+1]; 
		int max = 0;
		long START = -1;
		long numZero = 0;
		for (int i = 0; i < N; i++) {
			int x = input.nextInt();
			if (i==0) START=x;
			if (x==0) numZero++;
			depthCnt[x]++;
			max=Math.max(max, x);
		}
		if (START==0&&numZero==1) { //Vertex 1 cannot be treated generically since it is the root 
			//node in this problem AND V1 is the only allowed with 0
			long ans = 1;
			for (int depth = 1; depth <= max; depth++){ //Starting from 1 since depth 0 must always 
				//be predecessor
				long numPrev = depthCnt[depth-1]; //Base of exponent
				long numCur = depthCnt[depth]; //Power of exponent
				long curans = FastExp(numPrev,numCur,mod);
				ans*=curans;
				ans%=mod;
			} 
			System.out.println(ans);
		}else System.out.println(0);
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans = 1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			base*=base;
			exp/=2;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
}


Measured memory_bytes: 59172
#include <bits/stdc++.h>
using namespace std;
#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 all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
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, k;
    cin >> n >> k;
    int ans = 0;
    rep(i, n) {
        int x;
        cin >> x;
        ans += min(x, k - x);
    }
    cout << ans * 2 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    long double a, b;
    cin >> a >> b;
    if (a > b)
    {
        cout << "GREATER" << endl;
    }
    else if (a == b)
    {
        cout << "EQUAL" << endl;
    }
    else
    {
        cout << "LESS" << endl;
    }
    return 0;
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
mod = 10 ** 9 + 7

if N < M :
    N, M = M, N
    
if N - M == 0 :
    ret = 1
    for i in range(1, N + 1) :
        ret = ret * i * i % mod
    print(ret * 2 % mod)
    
elif N - M == 1 :
    ret = 1
    for i in range(1, M + 1) :
        ret = ret * i * i % mod
    print(ret * N % mod)
else :
    print(0)

Measured memory_bytes: 38768
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String string = scan.nextLine();
        char[] a = string.toCharArray();

        while (a[0] != '0') {
            int i = 0;
            int sum = 0;
            while (i < a.length) {
                sum += a[i++] - '0';
            }
            System.out.println(sum);
            string = scan.nextLine();
            a = string.toCharArray();
        }
    }
}

Measured memory_bytes: 26520
#include<iostream>

int main(){
  int K, S;
  std::cin >> K >> S;
  int pattern = 0;
  int X, sum;
  for(int i = 0; i < K + 1; i++){
    sum = S - i;
    if(sum < 0) break;
    for(int j = 0; j < K + 1; j++){
      X = sum - j;
      if(X < 0) break;
      if(X < K + 1) pattern++;
    }
  }
  std::cout << pattern << std::endl;
}

Measured memory_bytes: 256
#ABC134 C (再考察)

N = int(input())
A = []
for i in range(N):
    a = int(input())
    A.append(a)
    
AA = sorted(A,reverse = True)
for i in range(N):
    if A[i] != AA[0]:
        print(AA[0])
    else:
        print(AA[1])

Measured memory_bytes: 19096
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)2e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

void solve() {
    int n;
    cin>>n;
    int a[n];
    f(i, n) cin>>a[i];
    vector<int> finder;
    for(int i = 1; i < n; i++) {
        int to = a[i] ^ a[i - 1];
        finder.pb(to);
    }
    int all = 0;
    for(int i = 0; i < n; i += 2) {
        all ^= finder[i];
    }
    int val = all ^ a[0];
    cout<<val<<' ';
    for(int i = 0; i < finder.size(); i++) {
        val = val ^ finder[i];
        cout<<val<<' ';
    }
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int t = 1;
    //cin>>t;
    for(int test = 1; test <= t; test++) {
        //cout<<"Case #"<<test<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 6848
#include <iostream>
#include <vector>
#include <ios>
using namespace std;
struct Node
{
	Node(int k) : depth(0) { vChildId.resize(k, -1); }
	int depth;
	vector<int> vChildId;
};

void SetNodeDepthRecursive(Node* n, vector<Node*>& vNode)
{
	int s = n->vChildId.size();
	if (0 == s) return;
	for (int i = 0; i < s; ++i){
		Node* cn = vNode[n->vChildId[i]];
		cn->depth = n->depth + 1;
		SetNodeDepthRecursive(cn, vNode);
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int nu, id, k, c;
	cin >> nu;
	vector<int> vParentId(nu, -1);
	vector<Node*> vNode(nu, (Node*)0);
	while (nu--){
		cin >> id >> k;
		vNode[id] = new Node(k);
		for (int j = 0; j < k; ++j){
			cin >> c;
			vNode[id]->vChildId[j] = c;
			vParentId[c] = id;
		}
	}
	vector<Node*> vRoot;
	for (int i = 0; i < vNode.size(); ++i){
		if (vParentId[i] == -1)
			vRoot.push_back(vNode[i]);
	}
	for (int i = 0; i < vRoot.size(); ++i)
		SetNodeDepthRecursive(vRoot[i], vNode);

	Node* n;
	int pid;
	for (int i = 0; i < vNode.size(); ++i){
		n = vNode[i];
		pid = vParentId[i];
		cout << "node " << i << ": parent = " << pid << ", depth = " << n->depth << ", ";
		if (pid == -1){
			cout << "root, [";
			if (n->vChildId.size() == 0)
				cout << "]\n";
		}
		else if (n->vChildId.size() == 0) cout << "leaf, []\n";
		else cout << "internal node, [";
		if (n->vChildId.size() != 0){
			int cs = n->vChildId.size();
			for (int j = 0; j < cs; ++j){
				cout << n->vChildId[j];
				if (j < cs - 1)
					cout << ", ";
			}
			cout << "]\n";
		}
	}

	return 0;
}

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

typedef long long int ll;
#define    mod      1000000007
#define    speed    ios_base::sync_with_stdio(false);
#define    up       cin.tie(NULL);
#define    pb       push_back
#define    mp       make_pair
#define    T        int t; cin >> t; while(t--)

ll dp[1003][1003] , h , w;
char arr[1003][1003];

ll solve(int i ,int j){
    if(arr[i][j]=='#' || i > h || j > w){
        return 0;
    }
    if(dp[i][j] != -1){
        return dp[i][j];
    }
    if(i==h && j==w){
        return 1;
    }
    
    return(dp[i][j] = (solve(i+1 , j) + solve(i , j+1))%mod);
}

int main(){
   cin >> h >> w;
   for(int i = 1; i <= h; i++){
       for(int j = 1; j <= w; j++){
           cin >> arr[i][j];
           dp[i][j] = -1;
       }
   }
   cout << solve(1 , 1)%mod << '\n';
}

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

int bubbleSort(int *a,int N){
  int flag=1;
  int num,cnt=0;
  while(flag){
    flag=0;
    for(int i=N-1;i>=1;i--){
      if(a[i]<a[i-1]){
        num = a[i-1];
        a[i-1] = a[i];
        a[i] = num;
        flag = 1;
        cnt++;
      }
    }
  }
  return cnt;
}

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

  int A[N];
  for(int i=0;i<N;i++){
    cin >> A[i] ;
  }
  int s;
  s=bubbleSort(A,N);
  for(int i=0;i<N;i++){
    if(i!=N-1){
      cout << A[i] << " ";
    }else{
      cout << A[i] << endl;
    }
  }

  cout << s << endl;
  return 0;
}



Measured memory_bytes: 3092
#include <cstdio>
#include <deque>

using namespace std;

int main() {
	deque <int> a;
	int n;
    scanf("%d", &n);
	int cmd, arg1, arg2;
	for (int i = 0; i < n; i ++) {
		scanf("%d", &cmd);
		switch (cmd) {
		case 0:
			scanf("%d%d", &arg1, &arg2);
			if (arg1 == 0)
                a.emplace_front(arg2);
            else
                a.emplace_back(arg2);
			break;
		case 1:
			scanf("%d", &arg1);
			printf("%d\n", a[arg1]);
			break;
		case 2:
			scanf("%d", &arg1);
			if (arg1 == 0)
				a.pop_front();
			else
				a.pop_back();
			break;
    	}
	}
	return 0;
}



Measured memory_bytes: 4156
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from collections import defaultdict

MX = 10**10


def getInt(cn):
  ret = 0
  for c in cn:
    ret += 2**(c-1)
  return ret


## input
N,M = map(int, input().split())
Prices = defaultdict(lambda:MX)
for _ in range(M):
  a,b = map(int, input().split())
  cn = list(map(int, input().split()))
  Prices[getInt(cn)] = min(Prices[getInt(cn)],a)

dp = [MX for _ in range(2**N)]
dp[0] = 0
for p in Prices:
  for i in range(2**N):
    dp[i|p] = min(dp[i|p],dp[i]+Prices[p])

if dp[-1]>=MX:
  print(-1)
else:
  print(dp[-1])


Measured memory_bytes: 45544
#include <stdio.h>

int main(void){

    int N = 0;
    int check = 0;
    scanf("%d", &N);

    int A[N];

    for (int i = 0; i < N; i++){

        scanf("%d", &A[i]);       

        if (A[i] % 2 == 0){

            if (A[i] % 3 != 0 && A[i] % 5 != 0){
                
                check = 1;
            }
        }
    }
    if (check == 0){

        printf("APPROVED\n");

    } else {

        printf("DENIED\n");
    }



    return 0;
}

Measured memory_bytes: 128