akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty())return out;
    constexpr bool is_vector_v = is_vector<T>::value;
    if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
    else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
    return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }



int main() {
    IOS;
    int n;
    string s;
    cin >> n >> s;
    unordered_map<int, int> mp1,mp2;
    using ps = pair<string,string>;
    vector<ps> p1,p2;
    int t = 1<<n;
    REP(i,t){
        string s1,s2;
        int k = i;
        REP(j,n){
            if(k%2==1){
                s1.push_back(s[j]);
            }else{
                s2.push_back(s[j]);
            }
            k/=2;
        }
        p1.push_back(ps(s1,s2));
    }
    REP(i,t){
        string s1,s2;
        int k = i;
        REP(j,n){
            if(k%2==1){
                s2.push_back(s[j+n]);
            }else{
                s1.push_back(s[j+n]);
            }
            k/=2;
        }
        reverse(all(s1));
        reverse(all(s2));
        p2.push_back(ps(s1,s2));
    }
    sort(all(p1));
    sort(all(p2));
    ll res = 0;
    REP(i,t){
        int itr1 = lower_bound(all(p2),p1[i])-p1.begin();
        int itr2 = upper_bound(all(p2),p1[i])-p1.begin();
        res += itr2-itr1;
    }
    put(res);
    return 0;
}


Measured memory_bytes: 64492
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    n = I()
    a = LI()
    ans = 0
    l = 0
    r = 0
    s = 0
    while l < n and r < n:
        while s&a[r] == 0:
            s += a[r]
            r += 1
            ans += r-l
            if r == n:break
        if l==r:
            s += a[r]
            r += 1
        s -= a[l]
        l += 1
    print(ans)
#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    D()


Measured memory_bytes: 71672
S  = list(input())
index_even = ['R','U','D']
index_odd = ['L','U','D']
cnt_odd = 0
cnt_even = 0
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] in index_even:
            cnt_even += 1
    else:
        if S[i] in index_odd:
            cnt_odd += 1
if (cnt_even + cnt_odd) == len(S):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
m,t,pre,ans,h,i,a,j;
main(n){
	for(;scanf("%d%d",&n,&m)*n;){
		t=1e6;
		h=0;
		pre=0;
		for(i=0;i<n;i++){
			scanf("%d",&a);
			j=m/a*a;
			if(j*2000+a<=t*2000+pre){
				h=j*2000+a==t*2000+pre;
				t=j;
				pre=a;
				ans=i;
			}
		}
		printf("%d\n",h?n:ans+1);
	}
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void)
{
	int a, b;
	
	scanf("%d %d", &a, &b);
	
	if(a > b){
		printf("a > b\n");
	}
	else if(a < b){
		printf("a < b\n");
	}
	else{
		printf("a == b\n");
	}
	
	return (0);
}

Measured memory_bytes: 580
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vp = vector<pii>;
using vs = vector<string>;
using qi = queue<int>;
using qp = queue<pii>;
using pqi = priority_queue<int>;
using pqim = priority_queue<pii, vector<pii>, greater<pii> >;
using ppp = pair<int, pair<int, int>>;
#define all(vec) vec.begin(), vec.end()
#define rall(vec) vec.rbegin(), vec.rend()
#define pb push_back
const ll mod = 998244353;
const ll inf = 1e18;

ll n;
bool prime[10000001] = { 1, 1 };

void input() {
	cin >> n;
}
void solve() {
	if (n == 1) {
		cout << 0;
		return;
	}
	vi ppp;
	for (int i = 2; i <= 10000000; ++i) {
		if (prime[i]) continue;
		ppp.push_back(i);
		for (int j = 2 * i; j <= 10000000; j += i)
			prime[j] = 1;
	}
	vl factor;
	ll ans = 0;
	for (int x : ppp) {
		ll p = x;
		if (p > n) break;
		if ((n % p) != 0) continue;
		factor.push_back(p);
		ll c = 0;
		while ((n % p) == 0) {
			c++;
			n /= p;
		}
		ll cnt = 0;
		if (c < 3) cnt = 1;
		else if (c < 6) cnt = 2;
		else if (c < 10) cnt = 3;
		else if (c < 15) cnt = 4;
		else if (c < 21) cnt = 5;
		else if (c < 28) cnt = 6;
		else if (c < 36) cnt = 7;
		else if (c < 45) cnt = 8;
		else if (c < 55) cnt = 9;
		else if (c < 66) cnt = 10;
		ans += cnt;
	}
	if (n > 1) ans++;
	if (factor.empty()) cout << 1;
	else cout << ans;

	return;
}

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

	//int tc; cin >> tc;
	//while (tc--) {
	input();
	solve();
	//}
}

Measured memory_bytes: 17196
#include <iostream>
#include <map>
#include <cmath>
#include <vector>
#include <algorithm>

#define M 1000000007

using namespace std;

int found[26];

int main(){
  string s;
  cin >> s;

  bool isA = false;
  bool did = false;
  for(int i = 0;i < s.size();i++){
    if(s[i] == 'A'){
      isA = true;
    }else if(isA && s[i] == 'C'){
      did = true;
    }else{
      isA = false;
    }
  }

  cout << (did ? "Yes": "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
using namespace std;
const string W= "WRONG";
const string C= "CORRECT";
int main() {
  while(1){
    int T,P,R;
    cin >> T >> P >> R;
    if(T==0&&P==0&&R==0)break;
    vector<vector<int> > teamW(T,vector<int>(P,0));
    vector<pair<int,pair<int,int> > > teamSum(T,pair<int,pair<int,int> >(0,pair<int,int>(0,0)));
    for(int i = 0;i < T;i++){
      teamSum[i].second.second = i+1;
    }
    for(int i = 0;i < R;i++){
      int tID,pID,time;
      string mes;
      cin >> tID >> pID >> time >> mes;
      if(mes == W){
	teamW[tID-1][pID-1]++;
      }
      //      teamSum[T-tID].second.second = T-tID;
      if(mes == C){
	teamSum[tID-1].first++;
	teamSum[tID-1].second.first = teamSum[tID-1].second.first + time + teamW[tID-1][pID-1]*1200;
      }
    }
    for(int i = 0;i < T;i++){
      teamSum[i].second.first  = teamSum[i].second.first*(-1);
      teamSum[i].second.second = teamSum[i].second.second*(-1);
      
    }
    sort(teamSum.begin(),teamSum.end());//,greater<pair<int,int> >());
    for(int i = T-1;i >= 0;i--){
      cout << (-1)*teamSum[i].second.second  << " " << teamSum[i].first << " " << (-1)*teamSum[i].second.first << endl;

    } 
    
  }
  return 0;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

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

int N;
ll K;

const ll MOD = 1e9+7;

typedef vector<vector<ll>> mat;

mat mul(mat &A, mat &B){

  mat C(N, vector<ll>(N));

  rep(i, N){
    rep(k, N){
      rep(j, N){
        C[i][j] = (C[i][j] + (A[i][k] * B[k][j]) % MOD) % MOD;
      }
    }
  }

  return C;

}

mat pow(mat A, ll n){

  mat B(A.size(), vector<ll>(A.size()));

  for(int i = 0; i < A.size(); i++){
    B[i][i] = 1;
  }

  while(n > 0){
    if(n & 1) B = mul(B, A);
    A = mul(A, A);
    n >>= 1;
  }

  return B;

}



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

  cin >> N >> K;

  vector<vector<ll>> a(N);
  rep(i, N){
    rep(j, N){
      a[i].push_back(0);
    }
  }

  rep(i, N){
    rep(j, N){
      cin >> a[j][i];
    }
  }

  mat ansmat = pow(a, K);

  ll ans = 0;
  rep(i, N){
    rep(j, N){
      ans = (ans + ansmat[i][j]) % MOD;
    }
  }

  cout << ans << endl;



  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	char s[11]; scanf("%s", s);
	int N = strlen(s);
	int idx = 0;
	char ans[20];

	REP(i,N){
		switch(s[i]){
			case '0':
				ans[idx++] = '0';
				break;
			case '1':
				ans[idx++] = '1';
				break;
			case 'B':
				if(idx != 0) ans[idx--] = '\0';
				else{continue;}
				break;
			default:
				break;
		}

	}

	REP(i,idx) printf("%c", ans[i]);

	printf("\n");

	return 0;

}


Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  auto Dfs = [&](auto &&Func, string temp, const char end) -> void {
    if (static_cast<int64_t>(temp.length()) == N) {
      cout << temp << endl;
    } else {
      for (char ch = 'a'; ch <= end; ++ch) {
        const char next_end = (ch == end) ? end + 1 : end;
        Func(Func, temp + ch, next_end);
      }
    }
  };

  Dfs(Dfs, "", 'a');
  return 0;
}


Measured memory_bytes: 3552
//itp1_topic2_c

#include <bits/stdc++.h>
using namespace std;

int main() {
    int a,b,c;
    cin>>a>>b>>c;
    if(a > b) swap(a , b);
    if(b > c) swap(b , c);
    if(a > b) swap(a , b);
    
    cout<<a<<" "<<b<<" "<<c<<endl;
    
return 0;
}


Measured memory_bytes: 3104
#include<stdio.h>
#include<stdbool.h>
//declare function                                                              
bool judgelpyear(int fstyear,int lastyear);

/*==============end of delaration====================================*/

int main(void){
    int fstimp;//first imput                                                    
    int secimp;//second imput                                                   
    do {
        scanf("%d %d", &fstimp, &secimp);
    }while(judgelpyear(fstimp, secimp) == true);
    return 0;
}

bool judgelpyear(int fstyear,int lastyear) {
    static bool judgefst;
    bool discovery = false;//if he can discover a leap year                     

    if(fstyear == 0 && lastyear == 0){
        return false;//end main                                                 
    }
    if(judgefst == true) {//make a space between outputs                        
        printf("\n");
    }

    for(int i = fstyear; i <= lastyear; i++) {
        if(i % 4 == 0 && (i % 100 != 0 || i % 400 == 0)) {
            printf("%d\n", i);
            discovery = true;//he discovered at least one leap year             
        }
    }
    if(discovery == false) {
        printf("NA\n");
    }

    judgefst = true;//he did this function at least one time                    
    return true;//repeat scanning years                                         
}

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

n, m = map(int, input().split())
*a, = map(int, input().split()) 

a = [ai >> 1 for ai in a]

import fractions
from functools import reduce

def getLCM(a, b):
    return a * b // fractions.gcd(a, b)

def f(x):
    cnt = 0
    while x%2 == 0:
        x //= 2
        cnt += 1
    return cnt

cnt = f(a[0])
for i in range(1, len(a)):
    if cnt != f(a[i]):
        print(0)
        break
else:
    lcm = reduce(lambda x, y: getLCM(x, y), a)
    ans = (m-lcm) // (lcm*2) + 1 if m >= lcm else 0
    print(ans)

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

using namespace std;

long long a,b,x,ans;

int main()
{
	scanf("%lld%lld%lld",&a,&b,&x);
	ans=b/x-a/x;
	if(a%x==0)ans++;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i < (n); ++i)  //0スタート
#define rep1(i,n) for (int i = 1; i < (n); ++i)  //1スタート
#define REP(i,a,b) for (int i = a; i < (b); ++i)  //aからbまで
#define P(x) cout<<x<<endl  //変数xを改行付きで出力
#define INF 1000000007  //最大値兼MOD
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
    ./a.exe
	*/
	vector<int>a(3);
	rep0(i,3)cin>>a[i];
	sort(a.begin(),a.end());
	int c = a[2] * 10 + a[1];
	int b = a[0];
	cout<<c+b<<endl;
	return 0;

}


Measured memory_bytes: 256
import math

A,B,H,M = map(int,input().split())

Hangle = (H + (M/60))/12*360
Mangle = M/60*360
angle = abs(Hangle - Mangle)

C = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(angle)))

print(C)

Measured memory_bytes: 62404
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;

const int INF = 1 << 30;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};

class Point
{
public:
  int x, y;
  Point(int _x, int _y)
    :x(_x), y(_y) {}
};

class Cell
{
public:
  bool w[4];
  Cell()
  {
    w[0] = w[1] = w[2] = w[3] = true;
  }
};

class State
{
public:
  Point p;
  int cost;
  State(Point _p, int _cost)
    :p(_p), cost(_cost) {}
  bool operator < (const State& st) const
  {
    return this->cost > st.cost;
  }
};

int main()
{
  int w, h;
  while (~scanf("%d %d", &w, &h)) {
    if (w == 0 && h == 0)
      break;

    vector<vector<Cell> > map(h, vector<Cell>(w));
    for (int i = 0; i < 2*h-1; ++i) {
      int in;
      if (i&1) {
	for (int j = 0; j < w; ++j) {
	  scanf("%d", &in);
	  map[i/2][j].w[3] = map[i/2+1][j].w[1] = in;
	}
      } else {
	for (int j = 0; j < w-1; ++j) {
	  scanf("%d", &in);
	  map[i/2][j].w[0] = map[i/2][j+1].w[2] = in;
	}
      }
    }

    int ans = 0;
    priority_queue<State> que;
    que.push(State(Point(0, 0), 1));
    vector<vector<int> > dp(h, vector<int>(w, INF));
    while (!que.empty()) {
      const State st = que.top();
      que.pop();

      if (st.p.x == w-1 && st.p.y == h-1) {
	ans = st.cost;
	break;
      }

      if (dp[st.p.y][st.p.x] < st.cost)
	continue;

      dp[st.p.y][st.p.x] = st.cost;
      for (int i = 0; i < 4; ++i) {
	if (!map[st.p.y][st.p.x].w[i]) {
	  if (dp[st.p.y+dy[i]][st.p.x+dx[i]] > st.cost+1) {
	    dp[st.p.y+dy[i]][st.p.x+dx[i]] = st.cost+1;
	    que.push(State(Point(st.p.x+dx[i], st.p.y+dy[i]), st.cost+1));
	  }
	}
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}

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

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int C = scan.nextInt();
        long mod = (long)1e9+7;
        long[] A = new long[N];
        long[] B = new long[N];

        //K[i][j] = 0^j + 1^j + 2^j + ... + i^j
        long[][] K = new long[401][401];
        for(int i=0;i<401;++i){
            K[i][0]=1;
            for(int j=1;j<401;++j){
                K[i][j]=(K[i][j-1]*(long)i)%mod;
            }
        }
        for(int i=1;i<401;++i){
            for(int j=0;j<401;++j){
                K[i][j] = (K[i-1][j] + K[i][j])%mod;
            }
        }

        for(int i=0;i<N;++i)A[i]=scan.nextLong();
        for(int i=0;i<N;++i)B[i]=scan.nextLong();
        long[][] dp = new long[N+1][C+1];
        dp[0][0]=1;

        for(int i=0;i<N;++i){
            for(int c=0;c<=C;++c){
                for(int k=0;k<=c;++k)dp[i+1][c] = (dp[i+1][c] + (((K[(int)B[i]][k]-K[(int)A[i]-1][k]+mod)%mod)*dp[i][c-k])%mod)%mod;
            }
        }
        System.out.println(dp[N][C]);
    }
}

Measured memory_bytes: 25824
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
struct str
{
	char ss[10];
	bool operator<(const str &s)const
	{
		return strcmp(ss,s.ss)<0;
	}
}a[505050];
char s[5050];
int main()
{
	int k,l,cnt=0;
	scanf("%s",s);
	l=strlen(s);
	scanf("%d",&k);
	for(int i=0;i<l;i++)
		for(int j=0;j<k&&i+j<l;j++)
		{
			cnt++;
			for(int kk=i;kk<=i+j;kk++)
				a[cnt].ss[kk-i]=s[kk];
			a[cnt].ss[j+1]='\0';
		}
	sort(a+1,a+1+cnt);
	for(int i=1;i<=cnt;i++)
		if(i==1||strcmp(a[i].ss,a[i-1].ss)!=0)
		{
			k--;
			if(k==0)
			{
				printf("%s",a[i].ss);
				return 0;
			}
		}
}


Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>

bool Pali(char* str, int start, int end){   //str:文字列のポインタ  start:初期位置  end:終了位置
    int length = end - start + 1;
    int half = length / 2;
    for(int i = 0; i < half; i++){
        if(str[i] != str[end - i])return false;
    }

    return true;
}

int main(){
    char s[99];
    std::cin >> s;

    int length = 0;
    while(s[length])length++;

    if(Pali(s, 0, length - 1) && Pali(s, 0, (length-3)/2) && Pali(s, (length+1)/2, length -1))
        printf("Yes");
    else printf("No");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
 
using namespace std;
 
#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
 
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
 
const int N = 1e6 + 10, A = 5e3 + 10;
int main() {
    fast_cin();
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++) {
            cin>>arr[i];
    }
      int sum[n];
    sum[0]=0;
    sum[1]=sum[0]+abs(arr[1]-arr[0]);
    for(int i=2;i<n;i++){
        sum[i]=min(sum[i-1]+abs(arr[i]-arr[i-1]),sum[i-2]+abs(arr[i]-arr[i-2]));
    }
    cout<<sum[n-1];
}


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

int main() {
  string s,t;
  cin >> s >> t;
  char min_s=s[0];
  char max_t=t[0];
  for(int i=0; i<s.size(); i++){
      if(s[i]<min_s){
        min_s=s[i];
      }
  }
  for(int j=0; j<t.size(); j++){
      if(t[j]>max_t){
        max_t=t[j];
      }
  }
  if(min_s<max_t){
    cout << "Yes" << endl;
  }
  else{
    bool c=true;
    for(int i=0; i<s.size(); i++){
      if(s[i]!=t[i]){
        c=false;
      }
    }
    if(c && s.size()<t.size()){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  
  
}

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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

set<ll> factor(ll x){
    set<ll> s;
    s.insert(1);
    for(ll i = 2; i * i <= x; i++){
        if(x % i == 0){
            s.insert(i);
            while(x % i == 0){
                x /= i;
            }
        }
    }

    if(x != 1) s.insert(x);
    return s;
}

int main(){
    fcin;
    ll a, b;
    cin >> a >> b;

    set<ll> s1 = factor(a);
    set<ll> s2 = factor(b);

    int ans = 0;
    for(auto p : s1) if(s2.count(p)) ans++;
    cout << ans << endl;
    return 0;
}



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

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n), b(m);
    long long asum = 0, bsum = 0;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < m; i++) {
        cin >> b[i];
        bsum += b[i];
    }

    int ans = 0, bi = m;
    for (int ai = 0; ai <= n; ai++) {
        if (ai > 0) asum += a[ai-1];
        if (asum > k) break;
        for (; bi >= 0; bi--) {
            if (asum+bsum <= k || bi == 0) {
                ans = max (ans, ai+bi);
                break;
            }
            else bsum -= b[bi-1];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4796
import heapq
N,Q = map(int, input().split())

S,T,X = [],[],[]

Ev = []
for _ in range(N):
  s,t,x = map(int, input().split())
  Ev.append((s-x,True,x))
  Ev.append((t-x,False,x))
"""
2 5 6
5 -1
4 2
3 3
2 4
1 5
0 -1
"""
Ev.sort()
#print(Ev)
# C++のSetはminもO(logN)で取れるが、Pythonは無理。
# setとheapqを併用すると計算量が実現できる。
h = []
closed = set()
eidx = 0
for i in range(Q):
  # dはsortedでinputされる。
  d = int(input())
  #Query.append(d)
  while eidx < 2*N and Ev[eidx][0] <= d:
    #pop
    t,e,x = Ev[eidx]
    eidx += 1
    if e:
      heapq.heappush(h, x)
      closed.add(x)
    else:
      closed.remove(x)
      
  # heqpqの最小値がsetに含まれている間、捨て続ければ、setの要素とheapqの要素が一致する
  while h and h[0] not in closed:
    heapq.heappop(h)
    
  # assert( len(h) == len(set) )
  if h:
    print(h[0])
  else:
    print(-1)


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

struct node{int p, l, r;};
const int NIL = -1, N = 100005;
node T[N]; 
int D[N];
string type[N];

void print(int id){
    cout << "node " << id << ": "
         << "parent = " << T[id].p
         << ", depth = " << D[id]
         << ", " << type[id] << ", [";
    if (T[id].l != NIL)
    {
        cout << T[id].l;
        int x = T[T[id].l].r;
        while(x != NIL){
            cout << ", " << x;
            x = T[x].r;
        }
    }
    cout << "]" << endl;
    
}

void make_depth(int root, int d){
    D[root] = d;
    if(T[root].r != NIL) make_depth(T[root].r, d);
    if(T[root].l != NIL) make_depth(T[root].l, d+1);
}

void make_type(int n){
    for (int i = 0; i < n; i++)
    {
        if (T[i].p == NIL)
            type[i] = "root";
        else if (T[i].l == NIL)
            type[i] = "leaf";
        else
            type[i] = "internal node";
    }
    
}
int root(){
    int nd = 0;
    while(T[nd].p != NIL){
        nd = T[nd].p;
    }
    return nd;
}

void initialize(node T[], int n){
    for (int i = 0; i < n; i++)
        T[i].p = T[i].l = T[i].r = NIL;
    
}
void make_tree(int id, int k, int A[]){
    if (k == 0) return;
    T[A[0]].p = id;
    T[id].l = A[0];
    for (int i = 1; i < k; i++)
    {
        T[A[i]].p = id;
        T[A[i-1]].r = A[i];
    }
}


int main(){
    int A[N]; 
    int n; cin >> n;
    initialize(T, n);
    for (int i = 0; i < n; i++)
    {
        int id, k;
        cin >> id >> k;
        for (int i = 0; i < k; i++)
            cin >> A[i];
        make_tree(id, k, A);
    }
    make_depth(root(), 0);
    make_type(n);
    for (int i = 0; i < n; i++)
    {
        print(i);
    }
    
}


Measured memory_bytes: 13712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int n;
	cin>>n;
	vector<pair<int,int> > v(n);
	pair<int,int> A(1e9+1,1e9+1);
	pair<int,int> B(-1,-1);
	int ans=0;
	int s,e;
	for(int i=0;i<n;++i){
		auto &x=v[i];
		scanf("%d%d",&x.first,&x.second);
		ans=max(ans,x.second-x.first+1);
		if(x.second<A.second || x.second==A.second && x.first<A.first){
			A=x;
			s=i;
		}
		if(x.first>B.first || x.first==B.first && x.second>B.second){
			B=x;
			e=i;
		}
	}
	if(s==e){
		B={-1,-1};
		for(int i=0;i<n;++i){
			if(i==s)
				continue;
			auto &x=v[i];
			if(x.first>B.first || x.first==B.first && x.second>B.second){
				B=x;
				e=i;
			}
		}
	}
	{
		multiset<int> l,r;
		for(auto x:v){
			l.insert(x.first);
			r.insert(x.second);
		}
		for(auto x:v){
			l.erase(l.find(x.first));
			r.erase(r.find(x.second));
			int cur=max(0,*r.begin()-*--l.end()+1);
			ans=max(ans,x.second-x.first+1+cur);
			l.insert(x.first);
			r.insert(x.second);
		}
	}
	vector<pair<int,int> > w;
	for(int i=0;i<n;++i){
		if(i==s || i==e)
			continue;
		if(v[i].second<B.first){
			A.first=max(A.first,v[i].first);
			A.second=min(A.second,v[i].second);
		}else if(v[i].first>A.second){
			B.first=max(B.first,v[i].first);
			B.second=min(B.second,v[i].second);
		}else
			w.push_back(v[i]);
	}
	if(A.first>A.second || B.first>B.second){
		cout<<ans<<endl;
		return 0;
	}
	sort(w.begin(),w.end());
	vector<int> mn(w.size()+1);
	mn.back()=2e9;
	for(int i=(int)w.size()-1;i>=0;--i)
		mn[i]=min(mn[i+1],w[i].second);
	if(!w.empty())
		ans=max(ans,A.second-A.first+1+max(0,min(B.second,mn[0])-B.first+1));
	for(int i=0;i<w.size();++i){
		A.first=max(A.first,w[i].first);
		if(A.first>A.second)
			break;
		ans=max(ans,A.second-A.first+1+max(0,min(B.second,mn[i+1])-B.first+1));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10368
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <string.h>
#include <bitset>
#include <map>
#include <climits>
#include <set>

using namespace std;

int main()
{
    int H, W;
    cin >> H >> W;
    vector<vector<char>> v;
    for (int y = 0; y < H; ++y)
    {
        string s;
        cin >> s;
        vector<char> row;
        for (int x = 0; x < W; ++x)
        {
            char c = *(s.c_str() + x);
            row.push_back(c);
        }
        v.push_back(row);
    }
    auto black = [&v, &W, &H](int x, int y) {
        if (0 <= x && x < W && 0 <= y && y < H)
        {
            return v[y][x] == '#';
        }
        return false;
    };

    // 周囲から孤立している # があれば達成不可能
    for (int y = 0; y < H; ++y)
    {
        for (int x = 0; x < W; ++x)
        {
            if (v[y][x] == '.')
            {
                continue;
            }
            if (black(x - 1, y) || black(x, y - 1) || black(x + 1, y) || black(x, y + 1))
            {
            }
            else
            {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a1 = sc.nextInt();
		int a2 = sc.nextInt();
		int a3 = sc.nextInt();

		int sum = a1 + a2 + a3;

		if(sum >= 22) {
			System.out.println("bust");
		} else {
			System.out.println("win");
		}
	}

}

Measured memory_bytes: 23764
import sys
input = sys.stdin.readline
from collections import deque

N, D, A = map(int, input().split())
X = []
for _ in range(N):
    x, h = map(int, input().split())
    X.append((x << 30) + h)
X = sorted(X)[::-1]
Q = deque([])

ans = 0
k = 0
while X:
    if len(Q) == 0 or X[-1] >> 30 <= Q[0][0]:
        xh = X.pop()
        x, h = xh >> 30, xh % (1<<30)
        h = max(h - k * A, 0)
        a = (h + A - 1) // A
        ans += a
        k += a
        deque.append(Q, (x + 2 * D, a))
    else:
        x, a = deque.popleft(Q)
        k -= a

print(ans)

Measured memory_bytes: 28712
public class Hello {
    public static void Main(){
        // 1行に複数の入力値がある場合の例
        string [] inputs = System.Console.ReadLine().Split(' ');
        int a = int.Parse(inputs[0]);
        int b = int.Parse(inputs[1]);
        int c = (a * b);
        int d = (a + b) * 2;
        System.Console.WriteLine(c + " " + d);
    }
}



Measured memory_bytes: 9172
#include <iostream>
#include <algorithm>
#include <string>
#include <list>
#include<vector>
#include <sstream>
#include <stdio.h>
#include <valarray>
#include <iomanip>
using namespace std;

int main(void)
{

	long int A=0;
	long int B= 0;

	cin >> A >> B;


	if (A<=B) 
	{
		cout << "unsafe" << endl;
		return 0;
	}

	cout << "safe" << endl;

	return 0;
}

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

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

	int N, C = 0;
	cin >> N;

	FOR(i, 1, N+1)
	{
		if(i%2==1)
		{
			C++;
		}
	}

	cout << (double)C/(double)N << endl;

	return 0;
}

Measured memory_bytes: 256
sum[3<<17],cnt[3<<17];
N,i,acc,t,k,x;
char f[10];
char buf[2200000];
sz;
main()
{
	read(0,buf,2200000);
	for(;;)
	{
		k=buf[sz++];
		if(k<'0')break;
		N=N*10+k-'0';
	}
	for(i=0;i<N;i++)
	{
		x=0;
		for(;;)
		{
			k=buf[sz++];
			if(k<'0')break;
			x=x*10+k-'0';
		}
		++sum[cnt[x]++];
	}
	i=sz=0;
	for(t=N;t;t--)
	{
		while(acc>=i*t)acc+=sum[i++];
		cnt[t]=i-1;
	}
	for(i=1;i<=N;i++)
	{
		if(!cnt[i])
		{
			buf[sz++]='0';
		}
		else
		{
			if(cnt[i-1]!=cnt[i])
			{
				k=0;
				t=cnt[i];
				while(t)
				{
					f[k++]=t%10;
					t/=10;
				}
				acc=k;
			}
			else k=acc;
			while(k--)buf[sz++]=f[k]+'0';
		}
		buf[sz++]='\n';
		if(sz>100000)
		{
			write(1,buf,sz);
			sz=0;
		}
	}
	write(1,buf,sz);
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
#include<array>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;
#define rep(i,n) for(int i=0; i<(n); i++)

LL X[200000]={};
vector<string> ans;

void Plus(int i, int j, int k){
 string tmp = "+";
 tmp += " " + to_string(i);
 tmp += " " + to_string(j);
 tmp += " " + to_string(k);
 ans.push_back(tmp);
}
void Less(int i, int j, int k){
 string tmp = "<";
 tmp += " " + to_string(i);
 tmp += " " + to_string(j);
 tmp += " " + to_string(k);
 ans.push_back(tmp);
}
void And(int i, int j, int k){
 Plus(i,j,k);
 Less(99999,k,100000);
 Less(100000,k,k);
}
void Reverse(int i, int I){
 Plus(i,i,100000);
 Less(99999,I,i);
 Less(100000,i,i);
}
void Double(int i){
 Plus(i,i,i);
}
void Zero(int i){
 Less(0,0,i);
}

int main() {

 for(int x=29; x>=0; x--){
  Double(5);
  Less(99999,0,3);
  Plus(3,5,3);
  rep(i,x) Double(3);
  Less(0,3,3);
  Reverse(3,0);
  Plus(3,5,5);

  Zero(13); Zero(15);

  for(int y=29; y>=0; y--){
   Double(15);
   Less(99999,1,13);
   Plus(13,15,13);
   rep(i,y) Double(13);
   Less(1,13,13);
   Reverse(13,1);
   And(3,13,13);
   Plus(13,15,15);
  }

  Double(2);
  Plus(2,15,2);
 }

 cout << ans.size() << endl;
 rep(i,ans.size()) cout << ans[i] << endl;
 
 return 0;
}


Measured memory_bytes: 4180
N = int(input())
lst = []
for i in range(0, N):
	lst.append([i, int(input())])
lst.sort(lambda v: v[1], reverse = True)
index = lst[0][0]
for i in range(0, N):
	if i == index:
		print(lst[1][1])
	else:
		print(lst[0][1])

Measured memory_bytes: 92760
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

    int h, w;
    cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w));
    rep(i, h) rep(j, w) cin >> a[i][j];
    typedef pair<P, P> PP;
    vector<PP> ans;
    rep(i, h) rep(j, w)
    {
        if (a[i][j] % 2 == 0 || (i == h - 1) && (j == w - 1))
            continue;
        if (j == w - 1)
        {
            ans.push_back(PP(P(i + 1, j + 1), P(i + 2, j + 1)));
            a[i][j]--;
            a[i + 1][j]++;
        }
        else
        {
            ans.push_back(PP(P(i + 1, j + 1), P(i + 1, j + 2)));
            a[i][j]--;
            a[i][j + 1]++;
        }
    }
    cout << ans.size() << endl;
    rep(i, ans.size())
    {
        P a = ans[i].first, b = ans[i].second;
        cout << a.first << " " << a.second << " " << b.first << " " << b.second << endl;
    }
}

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

int dfs(vector<vector<int>> &graph, int v, set<int> s){

    s.insert(v);
    if(s.size() == graph.size()){   //全ての頂点（n個）を訪問したら完了
        return 1;
    }

    int res = 0;
    for(int e : graph[v]){
        if(s.count(e)){
            continue;   //訪問済みなら(集合の中にあるなら)次のノード訪問する
        }
        res += dfs(graph, e, s);
    }
    return res;
}

int main() {

    int n, m;
    cin >> n >> m;
    vector<vector<int>> graph(n);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].emplace_back(b);
        graph[b].emplace_back(a);
    }

    int ans = dfs(graph, 0, {}); //始点0、集合｛｝

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std ;
const int N = 5010; const long long inf = 0x3f3f3f3f3f3f3f3f ; 
struct rec{
	int h,p ;
	friend inline bool operator < (const rec a,const rec b){
		return a.h+a.p < b.h+b.p ; 
	} 
}t[N];
int n,ans ; long long dp[N] ; 
int main(){
//	freopen("in.txt","r",stdin) ; 
	cin >> n ;
	for(int i = 1 ; i <= n ; i++) scanf("%d%d",&t[i].h,&t[i].p) ;
	sort(t+1,t+n+1) ;
	for(int i = 1 ; i <= n ; i++) dp[i] = inf; dp[0] = 0 ;
	for(int i = 1 ; i <= n ; i++)
	    for(int j = i ; j ; j--) 
	        if(t[i].h >= dp[j-1])
	           dp[j] = min(dp[j],dp[j-1]+t[i].p) ;
	for(int i = 1 ; i <= n ; i++) if(dp[i] < inf) ans = i ;
	cout << ans << endl ; 
	return 0 ; 
}

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

int A, B, C, D;

int main(){
  cin >> A >> B >> C >> D;

  while(A > 0 && C > 0){
    C -= B;
    if(C <= 0){ cout << "Yes" << endl; break; }
    A -= D;
    if(A <= 0){ cout << "No" << endl; break; }
  }

  return 0;

}

Measured memory_bytes: 3636
n = int(input())
a = list(map(int, input().split()))
d = [0]*(10**5+1)
ans = 0
for i in a:
    d[i] += 1
    ans += i

q = int(input())
for _ in range(q):
    b, c = map(int, input().split())
    if d[b]==0:
        print(ans)
    else:
        ans += (d[b]*c)-(d[b]*b)
        d[c] += d[b]
        d[b] = 0
        print(ans)

Measured memory_bytes: 20824
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<map>
using namespace std;

const int N = 3;
const int N2 = 9;
const int mx[4] = {0,-1,0,1};
const int my[4] = {-1,0,1,0};
const char itoc[10] = {'0','1','2','3','4','5','6','7','8','9'};

int bfs(vector<int> p, string key) {
    queue< pair<vector<int>,int> > q;
    map<string,bool> m;
    pair<vector<int>,int> a,b;
    q.push(make_pair(p,0));
    m[key] = true;

    while(!q.empty()) {
        a = q.front(); q.pop();
        bool flg=true;
        int blank;
        for(int i=0; i<N2; i++) {
            if(a.first[i]!=i+1) flg = false;
            if(a.first[i]==N2) blank=i;
        }
        if(flg==true) return a.second;
        int bx = blank%N, by = blank/N;
        for(int i=0; i<4; i++) {
            int x=bx+mx[i],y=by+my[i];
            if(x<0 || x>=N || y<0 || y>=N) continue;
            b = make_pair(a.first,a.second);
            swap(b.first[y*N+x],b.first[blank]);
            key="";
            for(int j=0; j<N2; j++) key += itoc[b.first[j]];
            if(!m[key]) {
                m[key] = true;
                b.second+=1;;
                q.push(b);
            }
        }


    }
    return 0;
}

int main() {
    vector<int> init; int k;
    string key="";
    for(int i=0; i<N2; i++) {
        cin >> k; init.push_back(k);
        if(init[i]==0) init[i]=N2;
        key+=itoc[init[i]];
    }
    cout << bfs(init, key) << endl;
    return 0;
}



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

#define For(i, j, k) for(int i = j; i <= k; i++)

using namespace std;

typedef long long LL;

const int N = 3e7 + 10;
const int Mod = 1e9 + 7;

int Pow(int x, int e){
	int ret = 1;
	while(e){
		if(e & 1) ret = 1ll * ret * x % Mod;
		x = 1ll * x * x % Mod;
		e >>= 1;
	}
	return ret;
}

int S;
int sum[N];

int main(){

	scanf("%d", &S);

	For(i, 1, N - 5) sum[i] = sum[i / 10] + 1;
	For(i, 1, N - 5) sum[i] += sum[i - 1];

	int ans = 0, l = 0;
	For(r, 1, N - 5){
		while(l < 9999998 && sum[r] - sum[l] > S) ++l;
		ans += sum[r] - sum[l] == S;
	}
	ans += S / 8;
	
	for(int i = 1; i * i <= S; ++i)
		if(S % i == 0){
			if(i > 7) ans = (ans + Mod + 9ll * Pow(10, i - 1) - S / i) % Mod;
			if(i * i != S && S / i > 7) ans = (ans + Mod + 9ll * Pow(10, S / i - 1) - i) % Mod;
		}
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 117504
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <complex>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int N = 101010;
int main(){
	int n,t1=0,t2,x1=0,x2,y1=0,y2,ans;
	cin>>n;
	bool t=true;
	for(int i=1;i<=n;i++){
		if(!t)break;
		cin>>t2>>x2>>y2;
		ans=abs(x2-x1)+abs(y2-y1);
		if((t2-t1)<ans) t=false;
		if((t2-t1-ans)%2==1)t=false;
		t1=t2;
		x1=x2;
		y1=y2;
	}	
	if(t)cout<<"Yes";
	else cout<<"No";
	return 0;
}  

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
char jz[102][102];
int r,q,h,w;
bool ok=true;
bool d(int now){
	for(int i=1;i<=q;i++){
		if(jz[i][now]!='.')	return false;
	}
	return true;
}
bool c(int now){
	for(int i=1;i<=r;i++){
		if(jz[now][i]!='.')	return false;
	}
	return true;
}
void dd(int now){
	for(int i=now;i<=r;i++){
		for(int j=1;j<=q;j++){
			jz[j][i]=jz[j][i+1];
		}
	}
	return;
}
void dc(int now){
	for(int i=now;i<=q;i++){
		for(int j=1;j<=r;j++){
			jz[i][j]=jz[i+1][j];
		}
	}
	return;
}
int main(){
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			scanf(" %c",&jz[i][j]);
		}
	}
	r=w;q=h;
	while(ok){
		ok=false;
		for(int i=1;i<=r;i++){
			if(d(i)){
				ok=true;
				dd(i);
				--r;
			}
		}
		for(int i=1;i<=q;i++){
			if(c(i)){
				ok=true;
				dc(i);
				--q;
			}
		}
	} 
	for(int i=1;i<=q;i++){
		for(int j=1;j<=r;j++){
			printf("%c",jz[i][j]);
		}
		printf("\n");
	}
	return 0;
}

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


int main() {
  long long N;
  cin >> N;
  long long a[3*N];
for (long long i=0; i < 3*N; i++) cin >> a[i];


sort(a, a+3*N);
long long sum=0;
for(long long i=N; i<3*N; i+=2){
    sum += a[i];
  }
  
  cout << sum << endl;
}



Measured memory_bytes: 2560
let rec fix f x = f (fix f) x;;
Scanf.(Array.(
  let e = make 4 [] in
  init 3 (fun i ->
    scanf " %d %d" @@ fun u v -> (
      let u,v = u-1,v-1 in
      e.(u) <- (v,i) :: e.(u);
      e.(v) <- (u,i) :: e.(v)
    )
  ) |> ignore;
  init 3 (fun i ->
    fix (fun f count v a ->
      if count=3 then (
        if fold_left (&&) true a then
          (print_string "YES"; exit 0)
      ) else (
        List.iter (fun (w,i) ->
          if not a.(i) then (
            a.(i) <- true;
            f (count+1) w a;
            a.(i) <- false;
          )
        ) e.(v)
      )
    ) 0 i @@ make 3 false
  ) |> ignore;
  print_string "NO"
))

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
bool compare(const pair<int,int> &a,const pair<int,int> &b){
    return a.first<b.first;
}
 
int main()
{
    int i,j,k,n; cin>>n;
    vector<pair<int,int>> vec;
    for(i=0;i<n;i++)
    {
        int a,b;cin>>a>>b;
        vec.push_back(make_pair(b,a));
    }
    sort(vec.begin(),vec.end());
    int s=0; bool f=true;
    sort(vec.begin(),vec.end());
 
    for(i=0;i<n;i++)
    {
        s+=vec[i].second; if(vec[i].first<s) {f=false; break;}
    }
    cout<<(f ? "Yes":"No");
 
 
 
    return 0;
 
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

bool need(vector<int> &a, int &cn, int &k){
  if(k<=a[cn]) return true;
  vector<bool> dp(2*k+1,false);
  dp[a[cn]] = true;
  rep(i,a.size()){
    if(i==cn) continue;
    vector<bool> ndp(2*k+1);
    rep(j,2*k+1) ndp[j] = dp[j];
    for(int j=a[i]; j<2*k+1;j++){
      if(j-a[i]>=0){
	dp[j] = (ndp[j-a[i]] || dp[j]);
      }
    } 
  }
  for(int i=k;i<k+a[cn];i++){
    if(dp[i]) return true;   
  }
  return false;
}




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

  int n,k;
  cin >> n >> k;

  vector<int> a(n);

  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());

  
  int ub=n-1;//need
  int lb=0;//no need

  if(!need(a,ub,k)){
    cout << n << endl;
    return 0;
  }

  if(need(a,lb,k)){
    cout << 0 << endl;
    return 0;
  }
  
  while(ub-lb>1){
    int mid = (ub+lb)/2;
    if(need(a,mid,k)) ub = mid;
    else lb = mid;
  }

  cout << ub << endl;
    
  

  
  return 0;
    

}


Measured memory_bytes: 384
sx,sy,tx,ty = map(int,input().split())
ans = []
ans_out2 = ["D"]
ans_re2 = ["U"]

def solve(sx,sy,tx,ty):
    for i in range(tx-sx):
        ans.append("R")
    for i in range(ty-sy):
        ans.append("U")
    for i in range(tx-sx):
        ans.append("L")
    for i in range(ty-sy):
        ans.append("D")

    for i in range(tx-sx+1):
        ans_out2.append("R")
    for i in range(ty-sy+1):
        ans_out2.append("U")
    ans_out2.append("L")

    for i in range(tx-sx+1):
        ans_re2.append("L")
    for i in range(ty-sy+1):
        ans_re2.append("D")
    ans_re2.append("R")

    list = ans+ans_out2+ans_re2

    return list
  
ans_list = solve(sx,sy,tx,ty)
    
for i in range(len(ans_list)):
    print(ans_list[i],end="")

Measured memory_bytes: 9360
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  string str = "";

  while (N != 0) {
    int r = N % 2;
    if (r < 0) {
      r += 2;
    }

    N = (N - r) / -2;
    str += (char)('0' + r);
  }

  reverse(str.begin(), str.end());
  if (str == "") {
    str = "0";
  }
  cout << str << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
char str[30][30];
int dx[]={1,-1,0,0};
int dy[]={0,0,-1,1};
char dir[6]="DULR";
char com[110];
int main(){
	int T;scanf("%d",&T);
	while(T--){
		int a,b;scanf("%d%d",&a,&b);for(int i=0;i<a;i++)scanf("%s",str[i]);
		int d=0;
		int row,col;
		for(int i=0;i<a;i++)for(int j=0;j<b;j++){
			if(str[i][j]=='^'){
				d=1;row=i;col=j;
			}
			if(str[i][j]=='v'){
				d=0;row=i;col=j;
			}
			if(str[i][j]=='<'){
				d=2;row=i;col=j;
			}
			if(str[i][j]=='>'){
				d=3;row=i;col=j;
			}
		}
		str[row][col]='.';
		int c;scanf("%d",&c);
		scanf("%s",com);
		for(int i=0;i<c;i++){
			for(int j=0;j<4;j++){
				if(com[i]==dir[j]){
					d=j;
					if(0<=row+dx[d]&&row+dx[d]<a&&0<=col+dy[d]&&col+dy[d]<b&&str[row+dx[d]][col+dy[d]]=='.'){
						row+=dx[d];
						col+=dy[d];
					}
				}
			}
			if(com[i]=='S'){
				int nr=row;int nc=col;
				while(1){
					nr+=dx[d];
					nc+=dy[d];
					if(nr<0||nr>=a||nc<0||nc>=b||str[nr][nc]=='#')break;
					if(str[nr][nc]=='*'){
						str[nr][nc]='.';
						break;
					}
				}
			}
		}
		if(d==0)str[row][col]='v';
		if(d==1)str[row][col]='^';
		if(d==2)str[row][col]='<';
		if(d==3)str[row][col]='>';
		for(int i=0;i<a;i++)printf("%s\n",str[i]);
		if(T)printf("\n");
	}
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){

  int k;
  cin>>k;
  cout<<(k/2)*((k+1)/2)<<endl;

  return 0;
}

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

namespace AtCoder.Abc
{
    class A_170_FiveVariables
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(j => long.Parse(j)).ToArray();

            int i;

            for (i = 0; i < inputLongArray.Length; i++)
            {
                if (inputLongArray[i] == 0)
                {
                    break;
                }
            }
            long result = i + 1;

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28016
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
constexpr int MAX = 55556;

class Eratosthenes {
 public:
  constexpr Eratosthenes() : is_prime() {
    is_prime[0] = false;
    is_prime[1] = false;
    for (int i = 2; i < MAX; ++i) is_prime[i] = true;
    for (int i = 2; i < MAX; ++i) {
      if (is_prime[i]) {
        for (int j = i * i; j < MAX; j += i) {
          is_prime[j] = false;
        }
      }
    }
  }
  bool is_prime[MAX];
};

class Eratosthenes2 {
 public:
  Eratosthenes e;
  constexpr Eratosthenes2() : is_prime() {
    for (int i = 0; i < MAX; ++i) {
      if (e.is_prime[i]) {
        if (i % 5 == 1) {
          is_prime[i] = true;
        } else {
          is_prime[i] = false;
        }
      } else {
        is_prime[i] = false;
      }
    }
  }
  bool is_prime[MAX];
};

class Eratosthenes3 {
 public:
  Eratosthenes2 e;
  constexpr Eratosthenes3() : is_prime() {
    int j = 0;
    for (int i = 0; i < MAX; ++i) {
      if (e.is_prime[i]) {
        is_prime[j] = i;
        ++j;
      }
    }
  }
  int is_prime[MAX];
};

main(){
  int N;
  cin >> N;
  Eratosthenes3 e;
  for (int i = 0; i < N; ++i) {
    cout << e.is_prime[i];
    if (i != N - 1) cout << " ";
  }
  cout << endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n,0);
    int ans = 0;
    rep(i, n) {
        cin >> a[i];
        if (i % 2 == 0 && a[i] % 2 == 1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628