akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    vector<int> length;
    // 全ての i について
    int now = 0;
    int l = 0, r = 0 ;
    vector<int> len;
    for(int l=0;l<N;l++){
        //if(l>r)r = l ;
        while( (now + A[r]) == (now^A[r]) && r < N){
            now += A[r];
            r++;
        }
        //cout << now << endl;
        now -= A[l];
        len.push_back(r-l);
    }
    ll ans = 0;
    for(auto x:len)ans += x;
    cout << ans << endl;
}

Measured memory_bytes: 2936
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C: Grid Repainting 2
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_H = 50;
const int MAX_W = 50;
const int dxs[] = { 1, 0, -1, 0 }, dys[] = { 0, -1, 0, 1 };

/* typedef */

/* global variables */

char flds[MAX_H][MAX_W + 4];

/* subroutines */

/* main */

int main() {
  int h, w;
  scanf("%d%d", &h, &w);

  for (int y = 0; y < h; y++) scanf("%s", flds[y]);

  bool ok = true;
  for (int y = 0; ok && y < h; y++)
    for (int x = 0; ok && x < w; x++)
      if (flds[y][x] == '#') {
	bool nbr = false;
	for (int di = 0; ! nbr && di < 4; di++) {
	  int vx = x + dxs[di], vy = y + dys[di];
	  nbr =
	    (vx >= 0 && vx < w && vy >= 0 && vy < h && flds[vy][vx] == '#');
	}
	ok = nbr;
      }

  if (ok) puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 256
program main
Implicit None
	integer(8)::n,k,i,j,a
	real(8)::p=0,q
	
	read*,n,k
	
	do i = 1,n
		a = i
		j = 0
		do
		if(a >= k) exit
		a = a*2
		j = j+1
		enddo
		
		q = (5d-1)**real(j)
		p = p+q
	enddo
	p = p/n
	
	print *,p
end program main

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    string s;
    cin>>s;
    if(s[0]!='A')
        cout<<"WA"<<endl;
    else
    {
        map<int,int>mp;
        for(int i=0; i<s.length(); i++)
            mp[s[i]]++;
        int f=0;
        for(int i='A'; i<='Z'; i++)
        {
            if(i=='A' || i=='C')
                continue;
            if(mp[i])
                f=1;
        }
        if(f)
            cout<<"WA"<<endl;
        else
        {
            mp.clear();
            for(int i=2; i<s.length()-1; i++)
                mp[s[i]]++;
            if(mp['C']==1)
                cout<<"AC"<<endl;
            else
                cout<<"WA"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3632
def main():
    height, width = map(int, input().split())
    grid = [list(input()) for _ in range(height)]
    count = 0
    for g in grid:
        count += g.count("#")
    print("Possible" if count == height + width - 1 else "Impossible")


if __name__ == '__main__':
    main()



Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int A,B;
  cin >> A >> B;
  int ans = 0;
  for(int i = 1; i < 20000; i++){
    double i8 = (double)i * 0.08;
    double i10 = (double)i * 0.1;
    if((int)i8 != A) continue;
    else if((int)i10 != B) continue;
    else {ans = i; break;}
  }
  if(ans != 0) cout << ans;
  else cout << "-1";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=100005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int N,M;cin>>N>>M;
	cout<<(N*(N-1)/2)+(M*(M-1)/2);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define P std::pair<int,int>
#define double long double
typedef long long ll;
using namespace std;
int n,a[100010];
vector<int> vec;
signed main() {
	cin>>n;
	rep(i,n){
		cin>>a[i];
	}
	sort(a,a+n);
	int ans=0;
	if(n<=8){
		do{
			int cnt=0;
			rep(i,n){
				if(i>=1)cnt+=abs(a[i]-a[i-1]);
			}
			ans=max(ans,cnt);
		}while(next_permutation(a,a+n));
		cout<<ans<<endl;
		return 0;
	}
	ans+=a[n-1]-a[0];
	ans+=a[n-2]-a[0];
	for(int i=1;i<n/2;i++){
		ans+=abs(a[n-i-2]-a[i]);
		ans+=abs(a[n-i]-a[i]);
	}
	if(n%2){
		if(a[n/2+1]-a[n/2]>a[n/2]-a[n/2-1]){
			ans-=a[n/2]-a[n/2-1];
			ans+=a[n/2+1]-a[n/2];
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
    string s, t;
    cin >> s >> t;
    int n = s.size();
    for(int i = 0; i < n; i++){
        if(s[i] != t[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 3624
n,k=map(int,input().split())
a=list(map(int,input().split()))
tmax=max(a)
tmin=0
import math
ans=tmax
if k==0:
  print(tmax)
else:
  while True:
    t=(tmax+tmin)//2
    if abs(tmax-tmin)<=1:
      break
    s=0
    for i in range(n):
      s=s+math.ceil(a[i]/t)-1
    if k>=s:
      ans=min(math.ceil(t),ans)
      tmax=t
    else:
      tmin=t
  print(ans)

Measured memory_bytes: 30820
#include<iostream>
#include<stdio.h>
#include<string>
#include <algorithm>
#include<cstring>
using namespace std;

int main()
{
  string w;
  string t;
  int count=0;
  cin>>w;
  transform(w.begin(), w.end(), w.begin(), ::toupper);
  while(1){
    cin>>t;
    if(t=="END_OF_TEXT") break;
    transform(t.begin(), t.end(), t.begin(), ::toupper);
    if(w==t) count++;
  }
  cout<<count<<endl;
  return 0;
}                 



Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n, a[N], id[N];
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        id[i] = i;
    }
    sort(id + 1, id + n + 1, [](int x, int y) { return a[x] < a[y]; });
    for (int i = 1; i <= n; i++) a[id[i]] = i;
    int pos = 1, ans = 0;
    for (int i = 1; i <= n; i++) {
        if ((a[i] & 1) && !(i & 1)) ans++;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1024
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;

int solve(int n){
    int ret=0;
    int m[]={500,100,50,10,5,1};
    rep(i,6){
        ret+=n/m[i];
        n-=m[i]*(n/m[i]);
    }
    return ret;
}


int main(){
    vi a,b;
    rep(j,10){
        int k;
        cin>>k;
        a.pb(k);
    }
    rep(j,10){
        int k;
        cin>>k;
        b.pb(k);
    }
    sort(all(a));
    sort(all(b));
    
    cout<<(a[9]+a[8]+a[7])<<" "<<(b[9]+b[8]+b[7])<<endl;
    
    return 0;
}

Measured memory_bytes: 1220
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

/* gcd */
template<typename T>
T gcd(T a,T b)
{
	if(a==0 || b==0)return 0;
	if(b<a)swap(a,b);
	T r;
	while(1)
	{
		r=a%b;
		if(r==0)break;
		a=b;
		b=r;
	}
	return b;
}

/* lcm */
template<typename T>
T lcm(T a,T b)
{
	if(a==0 || b==0)return 0;
	return a*(b/gcd(a,b));
}

int main()
{
	lint A,B,C,D;
	lint ans=0;

	cin >> A >> B;
	cin >> C >> D;

	ans+=(B/C-(A-1)/C);
	ans+=(B/D-(A-1)/D);
	ans-=(B/lcm(C,D)-(A-1)/lcm(C,D));

	cout << (B-A+1)-ans << endl;
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> h(N+1,0);
  for(int i=1;i<N+1;i++){
    cin >> h[i];
  }
  int cnt=0;
  for(int i=0;i<N;i++){
    cnt +=max(h[i+1]-h[i],0);
  }
  cout << cnt << endl;
}


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

// alias templates
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// alias declaration
using ll = long long;
using str = string;

using vll = V<ll>;
using vvll = V<vll>;
using vs = V<str>;

// loops
#define FOR(i, a, b)  for (ll i = (a); i <= (ll)(b); i++) // [a,b]
#define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) // [b,a]
#define REP(i, a) FOR((i), 0, (ll)(a)-1) // [0,a-1]

// for debug
#define dbg(a) cerr << "  " << (#a) << ": " << (a) << "\n";

// procon common constants
const ll MOD_BIG = 1e9 + 7;

int main(void){
    ll N;
    ll a;
    ll c;
    cin >> N;

    //悩んだ末にこれである
    if(N<=9){
        c = N;
    }else if(N>=10 && N<=99){
        c = 9;
    }else if(N>=100 && N<=999){
        c = N-99+9;
    }else if(N>=1000 && N<=9999){
        c = 999-99+9;
    }else if(N>=10000 && N<=99999){
        c = N-9999+999-99+9;
    }else if(N==100000){
        c = 90909;
    }
    
    cout << c << endl;
}

Measured memory_bytes: 256
package main

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

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	stdin.Split(bufio.ScanWords)
	var A, B int
	A = nextInt()
	B = nextInt()
	fmt.Println(A * B)
}

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

func nextStr() string {
	stdin.Scan()
	i := stdin.Text()
	return i
}


Measured memory_bytes: 1756
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,h;
    cin>>n;
    std::deque<int> deq;
    for (int i=0;i<n;i++) {
        cin>>h;
        deq.emplace_back(h);
    }
    int count=0,flag=0;
    while (1) {
        int zero_count=0;
        for (int j=0;j<n;j++) {
            if (deq[j]>0) {
                if (j!=n-1&&deq[j+1]!=0) {
                    deq[j]--;
                } else if (j!=n-1&&deq[j+1]==0) {
                    deq[j]--;
                    break;
                } else if (j==n-1) {
                    deq[j]--;
                }
            } else if (deq[j]==0) {
                zero_count++;
                if (zero_count==n) {
                    cout<<count<<endl;
                    flag=1;
                    break;
                }
            }
        }
        count++;
        if (flag==1) {
            break;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long  N,A=0,B=0;
    int ans=0;


    cin>>A>>B;

    if(A+B>=A-B&&A+B>=A*B){
        cout<<A+B<<endl;
    }else if(A-B>=A+B&&A-B>=A*B){
        cout<<A-B<<endl;
    }else{
        cout<<A*B<<endl;
    }


}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()
auto &errStream = cerr;
#ifdef LOCAL
#define cerr (cerr << "-- line " << __LINE__ << " -- ")
#else
class CerrDummy {
} cerrDummy;
template <class T> CerrDummy &operator<<(CerrDummy &cd, const T &) {
  return cd;
}
using charTDummy = char;
using traitsDummy = char_traits<charTDummy>;
CerrDummy &operator<<(CerrDummy &cd,
    basic_ostream<charTDummy, traitsDummy> &(
      basic_ostream<charTDummy, traitsDummy> &)) {
  return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr << "reached" << endl
#define DMP(x) cerr << #x << ":" << x << endl
#define ZERO(x) memset(x, 0, sizeof(x))
#define ONE(x) memset(x, -1, sizeof(x))

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

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, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

#define CAPITAL
void Yes(bool ex = true) {
#ifdef CAPITAL
  cout << "YES" << endl;
#else
  cout << "Yes" << endl;
#endif
  if (ex)
    exit(0);
}
void No(bool ex = true) {
#ifdef CAPITAL
  cout << "NO" << endl;
#else
  cout << "No" << endl;
#endif
  if (ex)
    exit(0);
}

const ll infLL = LLONG_MAX / 3;

#ifdef int
const int inf = infLL;
#else
const int inf = INT_MAX / 2 - 100;
#endif

signed main() {
  int N = read(), A = read(), B = read();

  if ( N == 1 ) {
    cout << "Hello World" << endl;
  } else {
    print(A + B);
  }

  return 0;
}


Measured memory_bytes: 256
// AOJ 2005: Water Pipe Construction
// 2017.9.24 bal4u@uu
// 2017.11.21

#include <stdio.h>
#include <string.h>
#define INF 0x7ffffff

int dist[102][102];
char buf[50], *p;

int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int n, m, s, g1, g2, b1, b2, i, j, k, x, ans;

	while (fgets(p=buf, 50, stdin) && *p != '0') {
		n = getint(), p++, m = getint(), p++;
		s = getint(), p++, g1 = getint(), p++, g2 = getint();
		memset(dist, 0x11, sizeof(dist));
		for (i = 0; i <= n; i++) dist[i][i] = 0;

		while (m--) {
			fgets(p=buf, 50, stdin);
			b1 = getint(), p++, b2 = getint(), p++;
			dist[b1][b2] = getint();
		}
        for (k = 1; k <= n; k++) for (i = 1; i <= n; i++) for (j = 1; j <= n; j++) {
			x = dist[i][k] + dist[k][j];
	        if (dist[i][j] > x) dist[i][j] = x;
        }
		for (ans = INF, i = 1; i <= n; i++) {
			if ((x = dist[s][i] + dist[i][g1] + dist[i][g2]) < ans) ans = x;
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

int main() {
	string x;
	cin >> x;
	int pre_t = 0;
	int post_s = 0;
	for (int i = 0; i < x.length(); i++) {
		char a;
		a = x.at(i);
		if (post_s == 0) {
			if (a == 'S') post_s++;
			else pre_t++;
		}
		else if (post_s >= 1) {
			if (a == 'S')post_s++;
			else post_s--;
		}
	}
	cout << pre_t + post_s << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
vll yakusuu;
void div(ll N)
{
    for (ll i = 1; i * i <= N; i++)
    {
        if (N % i == 0)
        {
            yakusuu.push_back(i);
            if (i * i != N)
                yakusuu.push_back(N / i);
        }
    }
}
int main()
{
    ll N, ans = 0;
    cin >> N;
    div(N);
    for (auto i : yakusuu)
    {
        ll m = N / i - 1;
        if (N / (m + 1) < m)
            ans += m;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
ll h, w;

ll ans(ll hh, ll ww) {
  ll a = ww;
  for (ll i = 1; i < hh; i++) {
    ll p1, p2, p3;
    p3 = ww * i;
    p1 = (ww / 2) * (hh - i);
    p2 = (hh - i) * ww - p1;
    a = min(a, max(p1, max(p2, p3)) - min(p1, min(p2, p3)));
  }
  return a;
}

int main() {
  cin >> h >> w;
  if (h == 2 && w == 2) {
    cout << 1 << endl;
    return 0;
  }
  if (h % 3 == 0 || w % 3 == 0) {
    cout << 0 << endl;
    return 0;
  }
  cout << min(ans(h, w), ans(w, h)) << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static final int MOD = 1_000_000_007;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        Integer[] i = {2,3,4,5,6,7,8,9,10,11,12,13,1};
        List<Integer> list = Arrays.asList(i);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if(list.indexOf(a) > list.indexOf(b)) System.out.println("Alice"); else if(list.indexOf(a) == list.indexOf(b)) System.out.println("Draw"); else System.out.println("Bob");
    }
}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
int main(){
  int inf=1000000007;
  int n,k;cin>>n>>k;
  vector<int>h(n);
  for(int i=0;i<n;i++){
    cin>>h.at(i);
  }
  vector<int>dp(n,inf);
  dp.at(0)=0;
  for(int i=0;i<n;i++){
    for(int j=1;j<=k;j++){
      if(i+j>n-1)break;
      dp.at(i+j)=min(dp.at(i+j),dp.at(i)+abs(h.at(i)-h.at(i+j)));
    }
  }
  cout <<dp.at(n-1)<<endl;
}

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

int main(){
    int n;
    int i;
    int card[4][13]={{}};
    cin>>n;
    char a;
    int b;
    //input the exist cards
    for(int i=0; i<n; i++){
        cin >> a >> b;
        switch(a){
            case 'S':
            card[0][b-1]=1;
            break;
            case 'H':
            card[1][b-1]=1;
            break;
            case 'C':
            card[2][b-1]=1;
            break;
            case 'D':
            card[3][b-1]=1;
            break;
        }
    }
    //output the missing cards
    for(i=0;i<52;i++) {
    switch(i/13){
    case 0:
      if(card[0][i%13]==0) cout << "S " << i+1 << endl;
      break;
    case 1:
      if(card[1][i%13]==0) cout << "H " << i%13+1 << endl;
      break;
    case 2:
      if(card[2][i%13]==0) cout << "C " << i%13+1 << endl;
      break;
    case 3:
      if(card[3][i%13]==0) cout << "D " << i%13+1 << endl;
      break;
    }
  }
  
  return 0;
}


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

long long mod = 1000000007;
  /*long long f(long long x) {
    if (x == 0){
      return 1;
    }
    return x * f(x - 1) % mod;
  }*/

int main() {
  long long N,K;
  cin >> N >> K;
  long long sum = 0;
  for (long long i = K; i <= N + 1; i++){
    sum += i * (N - i + 1) + 1;
    sum = sum % mod;
  }
  
  cout << sum ;
  
}

Measured memory_bytes: 3676
N, C = gets.split.map(&:to_i)
D = Array.new(C) { Array.new(C) }
C.times do |i|
  D[i] = gets.split.map(&:to_i)
end
GRID = Array.new(N) { Array.new(N) }
N.times do |i|
  GRID[i] = gets.split.map(&:to_i)
end

cost = Array.new(3) { Array.new(C) {0} }
(1..C).each do |c|
  (1..N).each do |x|
    (1..N).each do |y|
      cost[(x-1+y-1)%3][c-1] += D[GRID[x-1][y-1]-1][c-1]
    end
  end
end

ans = 1 << 30
(1..C).each do |c1|
  (1..C).each do |c2|
    next if c1 == c2
    (1..C).each do |c3|
      next if c2 == c3 || c1 == c3
      ans = [ans, cost[0][c1-1] + cost[1][c2-1] + cost[2][c3-1]].min
    end
  end
end

puts ans


Measured memory_bytes: 6396
#include<iostream>
#include <math.h>
#include <iomanip>
#include <vector>

typedef long long ll;

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

using namespace std;

int main()
{
    // vector<int> a, b;
    int as, bs;
    int n, m;
    cin >> n >> m;
    vector<vector<int>> a(n+1);
    vector<int> room(n+1, -1);

    rep(i, m) {
        cin >> as >> bs;
        a.at(as).push_back(bs);
        a.at(bs).push_back(as);
    }
    vector<int> next;
    room.at(1) = 0;
    next.push_back(1);
    while (0 < next.size()) {
        vector<int> nextt;
        for(int ni: next) {
            for (int r: a.at(ni)) {
                if (room.at(r) != -1)
                {
                    continue;
                }
                room.at(r) = ni;
                nextt.push_back(r);
            }
        }
        next = nextt;
    }
    cout << "Yes" << endl;
    room.erase(room.begin()+0);
    room.erase(room.begin()+0);
    for ( int m: room) {
        cout << m << endl;
    }
}


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

/*                          
---------------------------------------------------------------
Aditya Kumar mishra
---------------------------------------------------------------
*/

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define len(s) s.length()
#define forp(i, a, b) for (int i = a; i <= b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define ren(i, n) for (int i = n - 1; i >= 0; i--)
#define forn(i, a, b) for (int i = a; i >= b; i--)
#define on cout << endl
#define o2(a, b) cout << a << " " << b
#define os cout << " "
#define all(v) v.begin(), v.end()
#define mem(n, m) memset(n, m, sizeof(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define sii set<int>
#define us unordered_set<int>
#define um unordered_map<int, int>
#define sll set<long long>
#define vii vector<int>
#define vll vector<long long>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ret return 0
#define present(s, x) (s.find(x) != s.end())
#define cpresent(s, x) (find(all(s), x) != s.end())
#define ford(container, it) for (__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define fors(container, it, a, b) for (__typeof(container.begin()) it = a; it != b; it++)

#define boost ios_base::sync_with_stdio(0)
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100001
#define SIZ 1000001
#define SIZE 200001

typedef long long ll;
typedef long double ldo;
typedef double db;
using namespace std;
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)

void c_p_c()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
int main()
{
    //c_p_c();
    int n, x, t;
    cin >> n >> x >> t;

    int t1 = (n + x - 1) / x;
    cout << t1 * t << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{

int n;
cin>>n;
int s[131072];
for(int i=0;i<n;i++)
    cin>>s[i];
sort(s,s+n);
cout<<s[n-1]<<" "; 
if(s[0]==0 and n==2) {cout<<s[0]; 
                      system("pause");
                      return 0;}  
for(int i=0;i<n;i++)
    if(s[i]<=s[n-1]/2 and s[i+1]>s[n-1]/2) {if((s[i+1]-s[n-1]/2)>(s[n-1]/2-s[i])) cout<<s[i];
                                                                             else cout<<s[i+1];}
                                                                             
system("pause");
return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const ll l_inf=0x3f3f3f3f3f3f3f3f;
const int maxn=1010;
inline int read(){
    int x=0,c=getchar(),f=0;
    for(;c>'9'||c<'0';f=c=='-',c=getchar());
    for(;c>='0'&&c<='9';c=getchar())
    x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
inline bool scan_lf(double &num)
{
        char in;double Dec=0.1;
        bool IsN=false,IsD=false;
        in=getchar();
        if(in==EOF) return false;
        while(in!='-'&&in!='.'&&(in<'0'||in>'9'))
                in=getchar();
        if(in=='-'){IsN=true;num=0;}
        else if(in=='.'){IsD=true;num=0;}
        else num=in-'0';
        if(!IsD){
                while(in=getchar(),in>='0'&&in<='9'){
                        num*=10;num+=in-'0';}
        }
        if(in!='.'){
                if(IsN) num=-num;
                return true;
        }else{
                while(in=getchar(),in>='0'&&in<='9'){
                        num+=Dec*(in-'0');Dec*=0.1;
                }
        }
        if(IsN) num=-num;
        return true;
}

int main()
{
	int n , a;
	while (~scanf("%d%d", &n, &a)){
		if (n%500 <= a)  puts("Yes");
		else  puts("No");
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
  
  int a, b, c, d;
  
  cin >> a >> b >> c >> d;
  
  if(a+b > c+d){
    cout << "Left" << endl;
  }else if(a+b == c+d){
    cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin>>n;
	long long ans=1;
	for(int i=0;i<n;i++){
		ans*=i+1;
		if(ans>=1000000007){
			ans=ans%1000000007;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
S = list(input())

n = len(S)

ans = [0] * n

# print(ans)

# まず R について解き、反転して L について解く
for i in range(2):
  ## solve R##
  cnt = 0 
  for k in range(n):
    if S[k] == "R":
      cnt += 1
    else:
      ans[k] += cnt // 2
      ans[k-1] += (cnt + 1) // 2
      cnt = 0
  
  
  ans = list(reversed(ans))
  S = list(reversed(S))
  # print(S)
 
  for j in range(n):
    if S[j] == "R":
      S[j] = "L"
    else:
      S[j] = "R"
      
  # print(S)
  
# print(ans)
print(" ".join([str(item) for item in ans]))

Measured memory_bytes: 11116
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define wzh(x) cerr<<#x<<'='<<x<<endl;
int n,m;
int main() {
  ios::sync_with_stdio(false);
  cin>>n>>m;
  if(n%3==0 || m%3==0)cout<<0<<'\n';
  else{
    LL ans=LLONG_MAX;
    for(int i=1;i<n;i++){
      LL now=1ll*i*m;
      LL l=1ll*(n-i)*(m/2);
      LL r=1ll*(n-i)*((m+1)/2);
      ans=min(ans,max({l,r,now})-min({l,r,now}));
    }
    for(int i=1;i<m;i++){
      LL now=1ll*i*n;
      LL l=1ll*(m-i)*(n/2);
      LL r=1ll*(m-i)*((n+1)/2);
      ans=min(ans,max({l,r,now})-min({l,r,now}));
    }
    if(n>=3){
      ans=min(ans,1ll*m);
    }
    if(m>=3){
      ans=min(ans,1ll*n);
    }
    cout<<ans<<'\n';
  }
  return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int n,r,b;
int main()
{
	cin>>n;
	string k;
	cin>>k;
	for(int i=0;i<n;i++)
	{
		if(k[i]=='R')
		{
			r++;
		}
		else
		{
			b++;
		}
	}
	if(r>b)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
}

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

/*#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#define mp make_pair
#define pb push_back
#define pll pair<LL,LL>
#define pii pair<int,int>
#define y second
#define x first
#define LL long long 
#define sqr(x) ((x)*(x))
#define pi acosl(-1)
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
using namespace std;
LL gor[200005][20];
LL valr[200005][20];
LL gol[200005][20];
LL vall[2000005][20];
void solve(){
    int n,k;
    scanf("%d %d",&n,&k);
    int x[200005];
    for(int i = 1;i<=n;i++){
        scanf("%d",&x[i]);
    }
    for(int i = 0;i<20;i++){
        gor[n+1][i]=n+1;
        gol[0][i]=0;
    }
    int now=0;
    for(int i = 1;i<=n;i++){
        while(now!=n+1&&x[now]-x[i]<k){
            now++;
        }
        gor[i][0]=now;
        valr[i][0]=i;
    }
    now=n;
    for(int i =n;i>=1;i--){
        while(now!=0&&x[i]-x[now]<k){
            now--;
        }
        gol[i][0]=now;
        vall[i][0]=i;
    }
    for(int i = 1;i<20;i++){
        for(int j = 1;j<=n;j++){
            gol[j][i]=gol[gol[j][i-1]][i-1];
            vall[j][i]=vall[j][i-1]+vall[gol[j][i-1]][i-1];
            gor[j][i]=gor[gor[j][i-1]][i-1];
            valr[j][i]=valr[j][i-1]+valr[gor[j][i-1]][i-1];
         //   printf("%d %d %lld %lld %lld %lld\n",i,j,gol[j][i],vall[j][i],gor[j][i],valr[j][i]);
        }
    }
    int q;
    scanf("%d",&q);
    while(q--){
        int l,r;
        scanf("%d %d",&l,&r);
        LL ans=0;
        int now=r;
        for(int i = 19;i>=0;i--){
            if(gol[now][i]>=l){
                ans+=vall[now][i]+(1<<i);
                now=gol[now][i];
                 //printf("%lld %d %d\n",now,ans,i);
            }
        }
        ans+=now+1;
      //  printf("%lld\n",ans);
        now=l;
        for(int i = 19;i>=0;i--){
            if(gor[now][i]<=r){
                ans-=valr[now][i];
               // printf("%d %d\n",i,valr[now][i]);
                now=gor[now][i];
            }
        }
        ans-=now;
        printf("%lld\n",ans);
    }
}
int main(){
    int t=1;
    //scanf("%d",&t);
    while(t--){
        solve();
    }
}
/*
1 6 6
2 7 4
3 5 2
4 3 1
5 2 5
6 4 0
7 1 3
*/
/*
100
5
5 4
4 2
4 2 3
5 4 2 3 1
*/


Measured memory_bytes: 129576
#include<stdio.h>
int main(void)
{
	int h,m,s;
	int h1,m1,s1;
	int go,zi,zi2,i;
	for(i=0;i<3;i++){
	scanf("%d %d %d",&h,&m,&s);
	scanf("%d %d %d",&h1,&m1,&s1);
	zi=h*3600+m*60+s;
	zi2=h1*3600+m1*60+s1;
	go=zi2-zi;
	s=go%3600;
	go=go/3600;
	m=s%60;
	h=s/60;
	printf("%d %d %d\n",go,h,m);
	}
	return 0;
}

Measured memory_bytes: 1028
<?php

while (true) {
    $alphabets = strtolower(trim(fgets(STDIN))); //文字列。
    if ($alphabets == '-') break; //文字列が'-'ならば処理をやめる。

    $shuffle_time = intval(trim(fgets(STDIN))); //シャッフル回数を取得。

    //hiを取得できる回数分、処理を行なう
    for ($i = 0; $i < $shuffle_time; $i++) {
        $shuffle_num = intval(trim(fgets(STDIN))); //hを取得。

        //文字列においてh番目から以降の文字列のみすべてを取得。
        //例）abcdeの2ならばbcdeを取得。
        $str = substr($alphabets, $shuffle_num);

        //例）bcdeに、abcdeの先頭から2番目までの文字=aを足し入れる。
        $str .= substr($alphabets, 0, $shuffle_num);

        $alphabets = $str;
//        最終的に文字列に格納しないといけない。なぜなら処理を繰り返す際、再び最初から$alphabetsを参照するから。
    }
    echo $alphabets . "\n";
}


Measured memory_bytes: 9220
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <deque>

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

using namespace std;

int main()
{
	char c = 'C';
	string s;
	cin >> s;

	rep(i, s.size()) {
		if (s[i] == c)
			c = 'F';
		if (c == 'F' && s[i] == c)
			c = 'O';
	}

	if (c == 'O')
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
from collections import namedtuple
I = namedtuple("I", "k v w")

n, w = map(int, input().split())
s = []

for i in range(n):
    vi, wi = map(int, input().split())
    s.append(I(vi / wi, vi, wi))
s.sort()

ans = 0
while w > 0 and s != []:
    item = s.pop()
    if w < item.w:
        a, b = item.v * w, item.w
        if a % b == 0:
            ans += a // b
        else:
            ans += a / b
    else:
        ans += item.v
    w -= item.w

print(ans)



Measured memory_bytes: 23484
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
typedef unordered_map<ll,ll> umap;
#define pb emplace_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;

int main() {
    // your code goes here
    ll n, dp[3005][3005]={0}, sa[3005][3005]={0}, sb[3005][3005]={0};
    string s;
    cin >> n >> s;
    dp[0][1] = 1;
    sa[0][1] = 1;
    sb[0][1] = 1;
    rep(i,1,n-1){
    	rep(j,1,i+1){
    		if(s[i-1] == '<') dp[i][j] = sa[i-1][j-1];
    		else dp[i][j] = sb[i-1][j];
    	}
    	rep(j,1,i+1) sa[i][j] = (sa[i][j-1] + dp[i][j]) % mod;
    	repr(j,i+1,1) sb[i][j] = (sb[i][j+1] + dp[i][j]) % mod;
    }
    cout << sa[n-1][n] << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const ll LongINF=1e13+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない
#define rep(i,n) for(int i=0;i<(n);i++)

int main(){
    int H,W;
    cin>>H>>W;
    vector<string> way(H);
    rep(i,H)cin>>way[i];

    vector<vector<int> >dist(H,vector<int>(W,-1));
    queue<pair<int,int> > que;
    int gy=H-1,gx=W-1;
    dist[0][0]=0;
    que.push(make_pair(0,0));
    while(!que.empty()){
        int x=que.front().second;
        int y=que.front().first;
        que.pop();

        for(int i=0;i<4;i++){
            int nx=x+dx[i];
            int ny=y+dy[i];

            if(nx<0||nx>=W||ny<0||ny>=H)continue;

            if(way[ny][nx]=='#')continue;

            if(dist[ny][nx]!=-1)continue;

            que.push(make_pair(ny,nx));
            dist[ny][nx]=dist[y][x]+1;
            if(ny==gy&&nx==gx)clear(que);
        }
    }
    int Co=0;
    int g=dist[gy][gx];
    if(g==-1){
        cout<<-1<<endl;
        return 0;
    }
    else{
        rep(i,H){
            rep(j,W){
                if(i==0&&j==0)continue;
                if(i==gy&&j==gx)continue;
                if(way[i][j]=='.')Co++;
            }
        }
    }
    cout<<Co-g+1<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
#define fst first
#define snd second
using ll = long long;
using I = pair<int, int>;

int main() {
  ll N, Y;
  while (cin >> N >> Y) {
    ll ax = -1, ay = -1, az = -1;
    for (ll x = 0; x <= N; x++) {
      for (ll y = 0; x + y <= N; y++) {
        ll z = N - x - y;
        if (10000 * x + 5000 * y + 1000 * z == Y) {
          ax = x;
          ay = y;
          az = z;
        }
      }
    }
    cout << ax << " " << ay << " " << az << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.next());
        if (N == 22) {
            System.out.println("Christmas Eve Eve Eve");
        } else if (N == 23) {
            System.out.println("Christmas Eve Eve");
        } else if (N == 24) {
            System.out.println("Christmas Eve");
        } else {
            System.out.println("Christmas");
        }

    }

}



Measured memory_bytes: 21840
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,X;
  cin >> A >> B >>X;
  if(A > X){
  	cout << "NO" << endl;
  }else{
  	if(A + B < X){
    	cout << "NO" << endl;
    }else{
    	cout << "YES" << endl;
    }
  }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int ans;
		double xa,ya,ra,xb,yb,rb;
		for(int i=0;i<n;i++){
			while(true){
				xa=sc.nextDouble();
				ya=sc.nextDouble();
				ra=sc.nextDouble();
				xb=sc.nextDouble();
				yb=sc.nextDouble();
				rb=sc.nextDouble();
				double X=Math.abs(xa-xb);
				double Y=Math.abs(ya-yb);
				double h=Math.sqrt(X*X+Y*Y);
				if(h>ra+rb){
					ans=0;
					break;
				}
				if(ra>rb){
					if(ra>h+rb){
						ans=2;
						break;
					}
				}else{
					if(rb>h+ra){
						ans=-2;
						break;
					}
				}
				ans=1;
				break;
			}
			System.out.println(ans);
		}
		sc.close();
	}
}

Measured memory_bytes: 20480
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 100005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

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

  ll n, m, a, b;
  cin >> n >> m >> a >> b;

  for (ll i = 1; i <= b; i++) {
    for (ll j = 1; j <= a; j++)
      cout << 0;
    for (ll j = a + 1; j <= m; j++)
      cout << 1;
    cout << en;
  }
  for (ll i = b + 1; i <= n; i++) {
    for (ll j = 1; j <= a; j++)
      cout << 1;
    for (ll j = a + 1; j <= m; j++)
      cout << 0;
    cout << en;
  }

  return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    vi a(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    vi b(n);
    for(int i=0;i<n;i++) 
        cin>>b[i];
    int ans=0;
    for(int i=28;i>=0;i--)
    {
        for(int j=0;j<n;j++) b[j]%=1<<(i+1);
        sort(b.begin(),b.end());
        ll cc=0;
        for(int j=0;j<n;j++)
        {
            a[j]%=1<<(i+1);
            cc+=lower_bound(b.begin(),b.end(),2*(1<<i)-a[j])-lower_bound(b.begin(),b.end(),(1<<i)-a[j]);
            cc+=lower_bound(b.begin(),b.end(),4*(1<<i)-a[j])-lower_bound(b.begin(),b.end(),3*(1<<i)-a[j]);
            //dbg(i,j,cc);
        }
        if(cc&1) ans|=1<<i;
    }
    print(ans);
}

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

int main() {
  int n;
  while (cin >> n, n) {
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    int ans = 1000010;
    REP(i,n-1) ans = min(ans,a[i+1]-a[i]);
    cout << ans << endl;
  }
}


Measured memory_bytes: 3132
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
    int n;
    while (cin >> n && n != 0) {
        if (n == 0) return 0;
        int a[n];
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
        }
        sort(a, a + n);
        int ans = 0;
        for (int i = 1; i < n - 1; ++i) {
            ans += a[i];
        }
        cout << ans / (n - 2) << endl;
    }
}



Measured memory_bytes: 3116
S = gets.chomp.chars
Q = gets.to_i
QList = []
Q.times{ QList << gets.chomp }

reverse = false
QList.each do  |query|
  ch = query.split
  if ch[0].to_i == 1
    reverse = !reverse
  elsif (ch[1].to_i == 1 and reverse) or (ch[1].to_i == 2 and !reverse)
    S << ch[2]
  else
    S.unshift(ch[2])
  end
end

if reverse
  S.reverse!
end

puts S.join


Measured memory_bytes: 39164
#include<iostream>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int h,a,n,s=0;
  cin>>h>>n;
  while(n--)
  {
    cin>>a;
    s+=a;
    
  }
  
   if(s>=h)
     cout<<"Yes";
  else
    cout<<"No";
  return 0;
}


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

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        ArrayList<Person> al = new ArrayList<>();
        for (int i=1; i<=N;i++){
            al.add(new Person(i, sc.next(), sc.nextInt()));
        }
        al.sort(Comparator.comparing(Person::getNum).reversed());
        al.sort(Comparator.comparing(Person::getName));
        for (int i=0; i<N; i++){
            System.out.println(al.get(i).getId());
        }
    }
}
class Person{
    int id;
    String name;
    int num;
    public Person(int id, String name, int num){
        this.id = id;
        this.name = name;
        this.num = num;
    }

    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public int getNum() {
        return num;
    }
}


Measured memory_bytes: 26964
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main() {
  int height, width, max_whites;
  scanf("%d%d%d", &height, &width, &max_whites);

  char ch[10][2000];

  for(int i = 0; i < height; i++) {
    scanf("%s", ch[i]);
  }

  int sum[10][2000];

  for(int i = 0; i < height; i++) {
    sum[i][0] = ch[i][0] - '0';

    for(int j = 0; j < width - 1; j++) {
      sum[i][j+1] = sum[i][j] + (int)(ch[i][j+1] - '0');
    }
  }

  int res = 10000000;
  for(int bit = 0; (bit & (1 << height)) == 0; bit++) {
    int tmp = 0;

    for(int b = 0; b < height; b++) {
      if ((bit & (1 << b)) > 0) tmp+=1;
    }

    bool ng = false;
    int sp = -1;
    for(int i = 0; i < width; i++) {
retry:
      int sum2 = 0;

      for(int j = 0; j < height; j++) {
        if (sp == -1) {
          sum2 += sum[j][i];
        } else {
          sum2 += sum[j][i] - sum[j][sp];
        }

        if ((bit & (1 << j)) > 0 || j == height - 1) {
          if (sum2 > max_whites) {
            if (i - sp == 1) {
              goto ng;
            } else {
              sp = i - 1;
              tmp += 1;
              goto retry;
            }
          }

          sum2 = 0;
        }
      }
    }

    res = min(tmp, res);
ng:
    tmp = 0;
  }

  printf("%d\n", res);

  return 0;
}

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

public class Program
{

    public void Proc()
    {

		int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();

		int ans = inpt[0] - 1;
		if(inpt[1]>=inpt[0]) {
			ans++;
		}
		Console.WriteLine(ans);


	}


	public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"


2 1



";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 13396
from collections import deque
n = int(input())
graph = [[] for _ in range(n)]
global Q, S, T
global visited, dis
Q = deque([0])
S = [0] #訪れた順
T = []
visited = [0 for _ in range(n)]
dis = [-1 for _ in range(n)] #初めからの距離
visited[0] = 1
dis[0] = 0
def input_graph(n):
  for _ in range(n):
    node_id, num, *v = list(map(int, input().split()))
    for i in range(num):
      graph[node_id-1].append(v[i]-1)

def bfs(node_id):
  global Q, S
  while Q:
    node_id = Q.popleft()

    for ad_node in graph[node_id]:
      if visited[ad_node] == 1:
        continue
      visited[ad_node] = 1
      dis[ad_node] = dis[node_id] + 1
      S.append(ad_node)
      Q.append(ad_node)

if __name__ == "__main__":
  input_graph(n)
  bfs(0)
  for i, d in enumerate(dis):
    print(i+1, d)




Measured memory_bytes: 6040
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    vector <vector <ll>> graph(n, vector<ll>());
    ll m; cin >> m;
    REP(i, m){
        ll a; ll b;
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    queue <ll> q;
    q.push(0);
    vector <ll> parents(n, -1);
    parents[0] = 0;
    while(!q.empty()){
        ll now = q.front();
        q.pop();
        for(auto next: graph[now]){
            if (parents[next] != -1){
                continue;
            }
            q.push(next);
            parents[next] = now;
        }
    }
    cout << "Yes" << endl;
    for(ll i=1; i<n; i++){
        cout << parents[i] + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 12976