akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
// #define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pi pair<int,int>
#define pii pair< int, pi >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)
using namespace std;
using namespace std::chrono;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}
void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
vector<vector<int>> vis;
int h,w,ch,cw,dh,dw;
int X[]={1,0,0,-1};
int Y[]={0,1,-1,0};
bool safe(int x,int y){
  return x>=0 && x<h && y>=0 && y<w;
}
void solve(){
  cin>>h>>w;
  cin>>ch>>cw;
  cin>>dh>>dw;
  ch--,cw--,dh--,dw--;
  char a[h][w];
  rep(i,0,h) {string s;cin>>s;rep(j,0,w) a[i][j]=s[j];}
  vis=vector<vector<int>> (h,vector<int>(w,0));
  priority_queue<pii,vector<pii>,greater<pii>> pq;
  vector<vector<int>> dp(h,vector<int>(w,INT_MAX));
  pq.push({0,{ch,cw}});
  while(!pq.empty()){
    pii x=pq.top();
    pq.pop();
    if(x.s.f==dh && x.s.s==dw){
      cout<<x.f<<endl;
      return;
    }
    rep(i,0,4){
      int x1=X[i]+x.s.f,y1=Y[i]+x.s.s;
      if(safe(x1,y1) && dp[x1][y1]> x.f && a[x1][y1]=='.'){
        dp[x1][y1]=x.f;
        pq.push({x.f,{x1,y1}});
      }
    }
      rep(i,-2,3){
        rep(j,-2,3){
          if(safe(x.s.f+i,x.s.s+j) && !(i==0 && j==0) && dp[x.s.f+i][x.s.s+j]>x.f+1 && a[x.s.f+i][x.s.s+j]=='.'){
            dp[x.s.f+i][x.s.s+j]=x.f+1;
            pq.push({x.f+1,{x.s.f+i,x.s.s+j}});
          }
        }
      }
  }
  cout<<-1<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}

Measured memory_bytes: 12340
#include <bits/stdc++.h>
#include <cctype>
#include <cmath>
#include <string>
using namespace std;
int main(){
    int H,W;
    cin >> H >> W;
    vector<string> a(H);
    for(int i = 0;i < H;i ++){
        cin >> a.at(i);
    }
    vector<bool> isH(H,true);
    vector<bool> isW(W,true);
    for(int i = 0;i < H;i ++){
        for(int j = 0;j < W;j ++){
            if(a.at(i).at(j) == '#'){
                isH.at(i) = false;
                isW.at(j) = false;
            }
        }
    } 
    for(int i = 0;i < H;i ++){
        if(isH.at(i)) continue;
        for(int j = 0;j < W;j ++){
            if(isW.at(j)) continue;
            cout << a.at(i).at(j); 
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

int main(){
  bool hurui[55556];hurui[0] = false;hurui[1] = false;repd(i,2,55555)hurui[i] = true;
  for(int i = 2;i*i < 55555;i++){
    repd(j,2,55555/i)hurui[i * j] = false;
  }
  int n;cin>>n;
  vector<int> ans;
  rep(i,55555){
    if(ans.size() >= n)break;
    if(hurui[i] && i%5==1)ans.push_back(i);
  }
  cout << ans[0];
  repd(i,1,n){
    cout << " " << ans[i];
  }
  cout << endl;
}




Measured memory_bytes: 256
import sys

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

x,y = map(int,input().split())

MOD = 10**9 + 7

MAX = max(x,y)
MIN = min(x,y)

if (2*MAX - MIN) % 3 != 0 or MAX / MIN > 2:
	print(0)
	sys.exit()

c1 = (2*MAX - MIN) // 3
c2 = MAX - 2*c1

c1 %= MOD
c2 %= MOD

ans = cmb(c1 + c2 , c1)
print(ans%MOD)


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

using namespace std;
int main()
{
    int a,b,x;
    cin>>a>>b;

    if(a>b)
    {
        x=(a+a)-1;
    }
    else if(a<b)
    {
        x=(b+b)-1;
    }
    else
    {
        x=a+b;
    }
    cout<<x<<endl;
    return 0;
}


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

using namespace std;

#define ll long long
#define fix cout << fixed; cout << setprecision(0)





void solve() {

	
	int n;
	cin >> n;
	string s = to_string(n);
	if(s.find('7') == string::npos) {
		cout << "No";
	}
	else {
		cout << "Yes";
	}




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	fix;
	solve();

	return 0;
}

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

int main(){
	int N,K,C; string S;
	cin>>N>>K>>C>>S;

	vector<int> L,R;
	int c;

	c = 0;
	rep(i, N){
		if(c-- > 0) continue;
		c = 0;
		if(S[i] == 'o'){ L.push_back(i); c = C; }
	}

	c = 0;
	for(int i=N-1; i>=0; --i){
		if(c-- > 0) continue;
		c = 0;
		if(S[i] == 'o'){ R.push_back(i); c = C; }
	}

	reverse(R.begin(), R.end());

	if(L.size() > K) return 0; // 働ける日に余裕があると、その日に必ず働く必要がないから

	rep(i, L.size()) if(L[i] == R[i]) cout<<L[i]+1<<endl;
}

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

public class Main {


    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner();
        int n = in.nextInt();
        int m = in.nextInt();
        int[]a = new int[n];
        int cnt = 0;
        int sum = 0;
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
            sum += a[i];
        }
        for (int i = 0; i < n; i++) {
            if(a[i] >= (double)sum / (4 * m)){
                cnt++;
            }
        }
        if(cnt >= m) in.out.println("Yes");
        else in.out.println("No");
        in.out.close();
    }
}


class FastScanner {
    BufferedReader br;
    StringTokenizer st = new StringTokenizer("");
    PrintWriter out;

    FastScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
    }

    FastScanner(String in, String out_) throws FileNotFoundException {
        br = new BufferedReader(new FileReader(in));
        out = new PrintWriter(out_);
    }

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    long nextLong() throws IOException {
        return Long.parseLong(next());
    }
}

Measured memory_bytes: 22612
#include <stdio.h>

int main(void) {
	int Height, Width, n;
	
	while(1) {
	    scanf("%d%d", &Height, &Width);
	    
	    //どちらも0の場合、処理を終了する
	    if((Height == 0) && (Width == 0)) {
	        break;
	    }
	    
	    n = 0;
	    for(int i = 0; i < Height; i++) {
	        n = ++n % 2;
	        for(int j = 0; j < Width; j++) {
	            if(j % 2 == n) {
	                printf(".");
	            }
	            else {
	                printf("#");
	            }
	        }
	        printf("\n");
	    }
	    printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2040
#include <iostream>
#include <vector>
#include <map>
#include <numeric>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<long long> a(n), b(n + 1);
    for(auto&& i : a){
        cin >> i;
    }
    partial_sum(begin(a), end(a), begin(b) + 1);
    long long ans = 0;
    map<long long, int> cnt;
    for(int i = 1; i <= n; i++){
        if(b[i] == 0) ans++;
        ans += cnt[b[i]];
        cnt[b[i]]++;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 15872
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1e18;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
int main()
{
	fast();
	ll a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	ll k;
	cin>>k;
	cout<<a[k-1];
}

Measured memory_bytes: 256
import heapq as hq

INF = 100000000

def dijkstra(n):
    global INF, W
    D = [INF] * n
    D[0] = 0
    Q = []
    hq.heappush(Q, (0, 0))

    while len(Q) != 0:
        minw, i = hq.heappop(Q)
        if D[i] < minw:
            continue
        for j in W[i].keys():
            w = W[i][j]
            if D[j] > D[i] + w:
                D[j] = D[i] + w
                hq.heappush(Q, (D[j], j))

    for i in range(n):
        print i, D[i]

n = int(input())
W = [{} for _ in range(n)]
for _ in range(n):
    l = map(int, raw_input().split())
    for i in range(l[1]):
        W[l[0]][l[2 * i + 2]] = l[2 * i + 3]

dijkstra(n)

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

#define all(a) a.begin(), a.end()
#define ff first
#define ss second
#define pb push_back

using ll = long long;
using pii = pair<int, int>;

template<typename T> using V = vector<T>;

const int N = 1e5 + 10, C = 26;
int pres[N][C];

int main() {
	ios::sync_with_stdio(false);cin.tie(nullptr);
	string s, t; cin >> s >> t;
	int curt = 0;
	ll ans = 0;
	int tlen = int(t.length()), slen = int(s.length());
	for (int i = slen - 2; i >= -1; --i) {
		int c = s[i + 1] - 'a';
		for (int j = 0; j < C; ++j) {
			pres[i + 1][j] = pres[i + 2][j];
		}
		pres[i + 1][c] = (i + 2);
	}
	while (true) {
		bool found = false;
		int curs = 0;
		while (curs <= slen and curt < tlen) {
			int c = t[curt] - 'a';
			if (pres[curs][c] > curs) {
				found = true;
				++curt;
				ans += ll(pres[curs][c] - curs);
				curs = pres[curs][c];
			} else {
				ans += ll(slen - curs);
				break;
			}
		}
		if (curt == tlen) {
			cout << ans << '\n';
			exit(0);
		}
		if (!found) {
			cout << -1 << '\n';
			exit(0);
		}
	}
}

Measured memory_bytes: 10704
def main():
  s=input()
  flg=0
  if s.count(s[0])!=2:
    flg=1
  s=s.replace(s[0],'')
  if len(s)>0 and s.count(s[0])!=2:
    flg=1
  if flg==1:
    print('No')
  else:
    print('Yes')  
main()

Measured memory_bytes: 3060
/* ABC145-C
   Takatan */

#include<stdio.h>
#include<math.h>
#include<stdlib.h>
double distance(int x1, int y1, int x2, int y2);
int main(void){
    int number, *x, *y, i, j;
    double sum = 0;
    
    scanf( "%d" , &number);
    x = malloc(sizeof(int) * number);
    y = malloc(sizeof(int) * number);
    for(i=0; i < number; i++){
        scanf( "%d %d" , &x[i], &y[i]);
    }

    for(i=0; i < number; i++){
        for(j=i+1; j < number; j++){
            sum += distance(x[i], y[i], x[j], y[j]); /* 全場合のうち2(n-1)通りがこの経路を使う */
        }
    }
    sum = sum * 2 / number;

    printf( "%f\n" , sum);
    return 0;
}

double distance(int x1, int y1, int x2, int y2){
    double dis2 = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
    return sqrt(dis2);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
  
#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed(x) fixed<<setprecision(x)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline A abs(A &a) { return (a < 0 ? -a : a); }
bool inLine(int x,int y,int mx,int my){return (x>=0&&y>=0&&x<mx&&y<my);}
const lol inf=(1LL<<62);
const lol MOD=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol score[4000][4000];
lol dp[4000][4000][4];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int R,C,K;
  cin >>R>>C>>K;
  vector<int> r(K),c(K),v(K);
  for(int i=0;i<K;i++){
    cin >>r[i]>>c[i]>>v[i];
    score[r[i]][c[i]]=v[i];
  }
  for(int i=1;i<=R;i++){
    for(int j=1;j<=C;j++){
      dp[i][j][0]=max(dp[i-1][j][3],dp[i][j-1][0]);
      dp[i][j][1]=max(dp[i-1][j][3]+score[i][j],max(dp[i][j-1][1],dp[i][j-1][0]+score[i][j]));
      dp[i][j][2]=max(max(dp[i-1][j][3],dp[i][j-1][1])+score[i][j],dp[i][j-1][2]);
      dp[i][j][3]=max(max(dp[i-1][j][3],dp[i][j-1][2])+score[i][j],dp[i][j-1][3]);
    }
  }
  cout <<dp[R][C][3]<<'\n';
  return(0);
}

Measured memory_bytes: 379168
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define ff              first
#define ss              second
#define int             long long int
#define pb              push_back
#define mp              make_pair
#define pi              pair<int,int>
#define vi              vector<int>
#define mi              map<int,int>
#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 MOD             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1N
#define loop(i,a,b)     for(int i=a;i<b;i++)

void FIO(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}

int32_t main(){
    FIO();
    string s; cin >> s;
    if(s[2]==s[3] && s[4]==s[5]) cout << "Yes";
    else cout << "No";


}





































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































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

#define rep(i,n) for(int i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;

const int INF = 1001001001;

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

    string s, t;
    cin >> s >> t;
    t += s;
    cout << t << endl;
    cout << endl;
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int a, b, c; cin >> a >> b >> c;
    int coins = 0;
    int ans = 0;
    while(true) {
        if(coins >= c) break;
        coins += a;
        ans++;
        if(ans%7 == 0) coins += b;
    }
    cout << ans << '\n';
    return 0;
}


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

using namespace std;

int main(void){
	string str;
	long long int ans=0;
	long long int n=1;
	int a;
	while((cin >> str)!=0){
		n=1;
		reverse(str.begin(),str.end());
		for(a=0;a<str.size();a++){
			if(str[a]>='0' && str[a]<='9'){
				ans+=n*(str[a]-'0');
				n*=10;
			}else n=1;
		}
	}
	cout << ans << endl;
	cin >> n;
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define show(x) cout<<#x" = "<<x<<endl;
#define INF 0x3f3f3f3f
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> iipair;
typedef pair<unsigned,unsigned> uupair;
typedef vector<int> vec;
typedef vector<unsigned> uvec;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    unsigned n,m;
    cin>>n>>m;
    if(n==m) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
/*****************************************************

*****************************************************/

#include<bits/stdc++.h>
#define MAX 9223372036854775807
#define endl "\n"
#define ll long long
#define int long long
#define pb push_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define ip pair<int, int>

#define loop(i,n) for(int i=0;i<n;i++)
#define fast ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
using namespace std;

const ll MOD = 1e9+7;
const ll SZ = 107;
const ll N = 2e5+7;
const ll inf = 1e17;

int pwr(int x, int y)
{
    ll r = 1LL;
    while(y)
    {
        if(y&1)
            r = (r * x) % MOD;
        y >>= 1;
        x = (x * x) % MOD;
    }
    return r % MOD;
}

int inv(int x)
{
    return pow(x, MOD-2);
}

void solve()
{
    string s; cin>>s;
    if((s[0]==s[1]) or s[1]==s[2] or s[2]==s[3])
        cout<<"Bad";
    else
        cout<<"Good";
}

signed main()
{
    fast;
    int t=1;
    // cin >>t;
    while(t--){
        solve();
    }
    return 0;
}

/*****************************


****************************/

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		String s = sc.next();
		String t = sc.next();
		sc.close();
		int cnt=0;
		for (i = 0; i < s.length(); i++) {
			if(s.charAt(i) == t.charAt(i)) {
				cnt++;
			}
		}
		out.println(cnt);
	}
}


Measured memory_bytes: 21716
#include <stdio.h>
#include <algorithm>
using namespace std;

int main(void)
{
	char num[9];
	int array[8];
	int n;
	int i;
	int j;
	int array2[8];
	int num_max;
	int num_min;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		num_max = 0;
		num_min = 0;
		scanf("%s", num);
		for (j = 0; j < 8; j++){
			array[j] = num[j] - '0';
		}
		sort(array, array + 8);
		for (j = 0; j < 8; j++){
			array2[j] = array[j];
		}
		reverse(array, array + 8);
		for (j = 0; j < 8; j++){
			num_max = num_max * 10 + array[j];
			num_min = num_min * 10 + array2[j];
		}
		num_max -= num_min;
		
		printf("%d\n", num_max);
	}
	
	return 0;
}

Measured memory_bytes: 1040
#include<iostream>
#include<algorithm>
using namespace std;
int N;
long A[2<<17],B[2<<17];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>A[i]>>B[i];
	}
	sort(A,A+N);
	sort(B,B+N);
	long ans;
	if(N%2==1)
	{
		ans=B[N/2]-A[N/2]+1;
	}
	else
	{
		ans=(B[N/2]+B[N/2-1])-(A[N/2]+A[N/2-1])+1;
	}
	cout<<ans<<endl;
}
/*	long Lm=0,Rm=2e9+1;
	while(Rm-Lm>1)
	{
		long M=Lm+Rm>>1;
		int cnt=0;
		for(int i=0;i<N;i++)
		{
			if(A[i]<=M)cnt++;
		}
		if(cnt*2>=N)Rm=M;
		else Lm=M;
	}
	long LM=0,RM=2e9+1;
	while(RM-LM>1)
	{
		long M=LM+RM>>1;
		int cnt=0;
		for(int i=0;i<N;i++)
		{
			if(B[i]>=M)cnt++;
		}
		if(cnt*2>=N)LM=M;
		else RM=M;
	}
	cout<<LM<<" "<<Rm<<endl;
	cout<<LM-Rm+1<<endl;
}*/


Measured memory_bytes: 6756
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b,h,m;
	cin>>a>>b>>h>>m;
	double ans=hypot(abs(a*cos(2*PI*((h+m/60.0)/12.0))-b*cos(2*PI*m/60)),abs(a*sin(2*PI*((h+m/60.0)/12.0))-b*sin(2*PI*m/60)));
	fcout(10)<<ans<<endl;
}


Measured memory_bytes: 4048
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;

	char buf[L], *S , *T, c;

	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}

	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}

	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}

	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}

	char B[45], *outs=B+40, *outr=B+40;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;

		if(!a)*--outs = '0';
		else
			while(a)
				*--outs = (a % 10) + 48, a /= 10;

		if(x)
			*--outs = x;

		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
//using i128 = __int128_t;
//using u128 = __uint128_t;
using i128 = i64;
using u128 = u64;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

ll exgcd(ll a, ll b, ll &x, ll &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll px, py;
	ll d = exgcd(b, a%b, px, py);
	x = py;
	y = px-a/b*py;
	return d;
}

template<class T>
inline void freshmin(T &a, const T &b)
{
	if (a > b) a = b;
}

template<class T>
inline void freshmax(T &a, const T &b)
{
	if (a < b) a = b;
}

const int MOD = 1000000007;
const int INF = 1000000000;
const int MAXN = 100010;
const int MAXK = 20;

int n, x;
int a[MAXN];

int main()
{
	
	ll n, m, x, y;
	cin >> n >> m >> x >> y;
	
	ll area = n*m;
	if (area%2 == 0)
		printf("%lld.0 ", area/2);
	else
		printf("%lld.5 ", area/2);
	
	if (2*x == n && 2*y == m)
		puts("1");
	else
		puts("0");
	
	return 0;
}


Measured memory_bytes: 256
/* ***********************************************
Author        :yang12138
Created Time  :2018年06月23日 星期六 20时03分31秒
File Name     :A.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int>pii;
#define lson (root<<1)
#define rson (root<<1|1)


int up(int a,int b){
	if(a%b==0) return a/b;
	return a/b+1;
}

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
	int n,k;
	cin>>n>>k;
	int ans=up(n-k,k-1)+1;
	cout<<ans<<endl;
    
    return 0;
}


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

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            long[] A = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            long sum =A[0];
            bool flag = true;
            if(A.Count(x=>x==0)>0){
                sum = 0;
            }else{
                for(int i = 1; i<N;i++){
                    try{
                        checked{
                            sum = sum*A[i];
                        }
                    }catch{
                        flag = false;
                        break;
                    }        
                }
                if(sum>1000000000000000000){
                    flag = false;
                }
            }
            Console.WriteLine(flag?sum:-1);
        //     int[] AB = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
        //     Console.WriteLine(AB[0]*AB[1]);
        }   
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


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

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=4005;
struct EDGE{int nxt,to;}edge[MAXN];
int n,m,mm,head[MAXN],tot,ans,fa[MAXN],dep[MAXN],id1[MAXN],id2[MAXN];
inline void add_edge(int u,int v){edge[++tot].nxt=head[u];edge[tot].to=v;head[u]=tot;}
void dfs1(int u){dep[u]=dep[fa[u]]+1;for(int i=head[u];i;i=edge[i].nxt)if(edge[i].to!=fa[u])fa[edge[i].to]=u,dfs1(edge[i].to);}
pii p[MAXN],tp[MAXN];
bool used[MAXN],fl[MAXN],res[MAXN];
void del(int a,int b,int c,int d){
	static int cnt[MAXN];memset(cnt,0,sizeof(int)*(n+5));
	while(a!=b){if(dep[a]<dep[b])swap(a,b);cnt[a]++;a=fa[a];}
	while(c!=d){if(dep[c]<dep[d])swap(c,d);cnt[c]++;c=fa[c];}
	for(int i=1;i<=n;++i)if(cnt[i]>=2)fl[i]=1;
}
void dfs2(int u){
	for(int i=head[u];i;i=edge[i].nxt)if(edge[i].to!=fa[u])dfs2(edge[i].to);
	if(fa[u]){
		vector<int>vec;
		for(int i=1;i<=mm;++i)if(!used[i]&&((tp[i].fst==u)^(tp[i].scd==u))){vec.pb(i);if((int)vec.size()==2)break;}
		ans+=min(max((int)vec.size(),2*fl[u]),2);
		if((int)vec.size()<2||fl[u]){
			for(int i=1;i<=mm;++i)if(!used[i]&&((tp[i].fst==u)^(tp[i].scd==u))){
				if(tp[i].fst==u)tp[i].fst=fa[u];
				if(tp[i].scd==u)tp[i].scd=fa[u];
			}
			return;
		}
		int a=vec[0],b=vec[1];
		del(tp[a].fst,tp[a].scd,tp[b].fst,tp[b].scd);
		used[a]=used[b]=1;
		++mm;
		if(tp[a].fst==u)tp[mm].fst=tp[a].scd,p[mm].fst=p[a].scd;
		else tp[mm].fst=tp[a].fst,p[mm].fst=p[a].fst;
		if(tp[b].fst==u)tp[mm].scd=tp[b].scd,p[mm].scd=p[b].scd;
		else tp[mm].scd=tp[b].fst,p[mm].scd=p[b].fst;
		id1[mm]=a;id2[mm]=b;
		for(int i=1;i<=mm;++i)if(!used[i]&&((tp[i].fst==u)^(tp[i].scd==u))){
			if(tp[i].fst==u)tp[i].fst=fa[u];
			if(tp[i].scd==u)tp[i].scd=fa[u];
		}
	}
}
int main() {
	n=read();m=mm=read();
	for(int i=1,u,v;i<n;++i)u=read(),v=read(),add_edge(u,v),add_edge(v,u);
	for(int i=1;i<=m;++i)p[i].fst=tp[i].fst=read(),p[i].scd=tp[i].scd=read();
	dfs1(1);dfs2(1);
	printf("%d\n",ans);
	for(int i=mm;i>=1;--i){
		if(!used[i])res[i]=0;
		if(i>m){
			if(!res[i])res[id1[i]]=(p[i].fst!=p[id1[i]].fst),res[id2[i]]=(p[i].scd!=p[id2[i]].scd);
			else res[id1[i]]=(p[i].fst==p[id1[i]].fst),res[id2[i]]=(p[i].scd==p[id2[i]].scd);
		}
	}
	for(int i=1;i<=m;++i)if(!res[i])printf("%d %d\n",p[i].fst,p[i].scd);else printf("%d %d\n",p[i].scd,p[i].fst);
	return 0;
}

Measured memory_bytes: 640
n,m=[int(x) for x in input().rstrip().split()]
a=[int(input()) for i in range(m)]
oks=[True for i in range(n+1)]

mod=10**9+7
dp=[0 for i in range(n+1)]
for i in a:
  oks[i]=False

if oks[1]==True:
  dp[1]=1
dp[0]=1
for i in range(2,n+1):
  if oks[i]==True:
    dp[i]=dp[i-2]+dp[i-1]
print(dp[n]%mod)

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

int main() {
  string s;
  cin >> s;
  bool ok=true;
  for(int i=0; i<s.size(); i++) {
    if(i%2==0&&s[i]=='L') ok=false;
    else if(i%2==1&&s[i]=='R') ok=false; 
  }
  cout << (ok? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    sc.nextLine();
    String out = "";
    String[] str = new String[a+2];
    for(int i = 0; i < a+2; i++) {
      if(i == 0 || i == a+1) {
        str[i] = "";
        for(int j = 0; j < b+2; j++) {
          str[i] += " ";
        }
      } else
        str[i] = " " + sc.nextLine() + " ";
    }
    
    for(int i = 1; i < a+1; i++) {
      for(int j = 1; j < b+1; j++) {
        if(str[i].charAt(j) == '.') {
          int count = 0;
          if(str[i-1].charAt(j-1) == '#') {
            count++;
          }
          if(str[i-1].charAt(j) == '#') {
            count++;
          }
          if(str[i-1].charAt(j+1) == '#') {
            count++;
          }
          if(str[i].charAt(j-1) == '#') {
            count++;
          }
          if(str[i].charAt(j+1) == '#') {
            count++;
          }
          if(str[i+1].charAt(j-1) == '#') {
            count++;
          }
          if(str[i+1].charAt(j) == '#') {
            count++;
          }
          if(str[i+1].charAt(j+1) == '#') {
            count++;
          }
          out += count;
        }
        else if(str[i].charAt(j) == '#') {
          out += '#';
        }
      }
      out += "\n";
    }
    System.out.println(out);
  }
}


Measured memory_bytes: 37972
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
     
      int count = 0;
      
      String s = sc.next();
      
      for(int i = 0; i < s.length() / 2;i++){
        if(s.charAt(i) != s.charAt(s.length()-1-i)){
          count++;
        }
      }
      
      System.out.println(count);
      
      
      sc.close();
    }
}

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

int N;
bool p[101];
int n[101];

int factorial(int i){
    if(i==0) return 1;
    else return i * factorial(i - 1);
}

int combination(int n, int i){
    return factorial(n) / (factorial(i) * factorial(n - i));
}

int main(){

    cin >> N;

    //search primary numbers
    for(int i = 2; i <= N; i++){
        p[i] = true;
        n[i] = 0;
    }
    for(int i = 2; i <= N; i++){
        for(int j = 2; j < i; j++){
            if(i % j == 0) p[i] = false; continue;
        }
    }


    for(int i = 2; i <= N; i++){
        for(int j = 2; j <= i; j++){
            int tmp = i;
            while(p[j] && (tmp % j == 0)){
                n[j] += 1;
                tmp /= j;
            }
        }
    }


    int m[76];
    int ind[5] = {3-1, 5-1, 15-1, 25-1, 75-1};
    for(int i = 0; i < 5; i++){
        m[ind[i]] = 0;
    }
    for(int i = 2; i<=N; i++){
        for(int j = 0; j < 5; j++){
            if(p[i] && n[i] >= ind[j]){
                m[ind[j]] += 1;
            }
        }
    }

    int ans;
    ans = m[75-1] + \
          m[25-1] * (m[3-1] - 1) + \
          m[15-1] * (m[5-1] - 1) + \
          m[5-1] * (m[5-1] - 1) / 2 * (m[3-1] - 2);

    cout << ans << endl;
}


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

int main(void){
  	int N;
  	string s;
  	cin >> N;
  	cin >> s;
  	
  	if ( N%2 != 0){
      cout << "No" << endl;
      return 0;
    }else{
      for(int i = 0; i < N/2; i++){
		if(s[i]!=s[N/2+i]){
          	cout << "No" << endl;
        	return 0;
        }
      }
    }
  	cout << "Yes" << endl;
  	
  	
	return 0;
  
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 9000000000000000000 //9e18:極めて大きい値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define LOGMAXR 18 // floor(log2(10^5)) + 1: 配列の最大のrangeのlog
//略記
//#define PB push_back //vectorヘの挿入
//#define MP make_pair //pairのコンストラクタ
//#define F first //pairの一つ目の要素
//#define S second //pairの二つ目の要素

int main(){
  ll N;
  unordered_set<string> S;
  cin >> N;
  REP(i, N){
    string buff;
    cin >> buff;
    S.insert(buff);
  }
  cout << S.size() << endl;
  return 0;
}


Measured memory_bytes: 13804
import sys
input = sys.stdin.readline
def judge(mat,x,pivot):
  b = x.bit_length()
  cnt = 0
  for i in range(b)[::-1]:
    if x&1<<i:
      if i not in pivot:
        return False
      for j in range(cnt,len(mat)):
        if mat[j]&1<<i:
          x ^= mat[j]
          cnt = j+1
          break
  if x == 0:
    return True
  else:
    return False
def add(mat,x,pivot):
  b = x.bit_length()
  cnt = 0
  for i in range(b)[::-1]:
    if x&1<<i:
      if i in pivot:
        for j in range(cnt,len(mat)):
          if mat[j]&1<<i:
            x ^= mat[j]
            cnt = j+1
            break
      else:
        pivot.add(i)
        for j in range(len(mat)):
          if mat[j] < x:
            mat.insert(j,x)
            for k in range(i)[::-1]:
              if mat[j]&1<<k and k in pivot:
                for l in range(j+1,len(mat)):
                  if mat[l]&1<<k:
                    mat[j] ^= mat[l]
            x = mat[j]
            break
        else:
          mat.append(x)
        for j in range(len(mat)):
          if mat[j] > x and mat[j]&1<<i:
            mat[j] ^= x
        break
t = int(input())
for _ in range(t):
  n = int(input())
  a = list(map(int,input().split()))
  s = input().rstrip()
  pivot = set()
  mat = []
  for i in range(n)[::-1]:

    x = a[i]
    if s[i] == "0":
      if judge(mat,x,pivot):
        continue
      else:
        add(mat,x,pivot)
    else:
      if judge(mat,x,pivot):
        continue
      else:
        print(1)
        break
  else:
    print(0)

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

int main(void) {
  int K;
  string S;
  cin >> K >> S;
  if (S.length() <= K) {
    cout << S << endl;
  } else {
    cout << S.substr(0, K) << "..." << endl;
  }
  return 0;
}

Measured memory_bytes: 3576
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 8080
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD=1e9+7;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
ll bik[114514];
ll bikinv[114514];
ll gcd(ll a, ll b) {
	return b != 0 ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
// a x + b y = gcd(a, b)
ll extgcd(ll a, ll b, ll &x, ll &y) {
	ll g = a; x = 1; y = 0;
	if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
	return g;
}
ll invMod(ll a, ll m) {
	ll x, y;
	if (extgcd(a, m, x, y) == 1) return (x + m) % m;
	else                         return 0; // unsolvable
}
void bikcal(int NN){
	ll hoge=(ll)1;
	bik[0]=(ll)1;
	bikinv[0]=(ll)1;
	for(int i=1;i<=NN;i++){
		hoge=(hoge*i)%MOD;
		bik[i]=hoge;
		bikinv[i]=invMod(bik[i],MOD);
	}
}


ll Comb(int a,int b){
	ll ret;
	ret=(((bik[a]*bikinv[b])%MOD)*bikinv[a-b])%MOD;
	return ret;
}


ll powMod(ll x, ll k, ll m) {//x^k (mod n)
if (k == 0)     return 1;
if (k % 2 == 0) return powMod(x*x % m, k/2, m);
else            return x*powMod(x, k-1, m) % m;
}
ll dp[1111][1111]={0};
int main(){
	int N,A,B,C,D;
	cin>>N>>A>>B>>C>>D;
	dp[A-1][0]=1;
	dp[0][0]=1;
	bikcal(1111);
	for(int i=A;i<=B;i++){
		for(int j=0;j<=N;j++){
			dp[i][j] = dp[i-1][j];
			for(int k=C;k<=D&&k*i<=j;k++){
				dp[i][j]=dp[i][j]+dp[i-1][j-k*i]*bik[N-j+i*k]%MOD *bikinv[N-j]%MOD *bikinv[k]%MOD*powMod(bikinv[i],k,MOD)%MOD;
				dp[i][j] %= MOD;
			}
		
		}
	}
	
	cout<<dp[B][N]<<endl;
}




















Measured memory_bytes: 10496
#include <stdio.h>
#include <string.h>
int main(void){
        char str[101];
        int alp[26] = {},num[10] = {};
        char *s = str;
        int *a = alp, *n = num;
        int i,j,f,c = 0;
        scanf("%s",str);

        while(*s){
                if(*s >= 'a' && *s <= 'z')
                        *(a + (*s-'a')) += 1;
                else if(*s >= '0' && *s <= '9')
                        *(n + (*s-'0')) += 1;
                s++;
        }
for(j=0;j<100;j++){
        f = 0;
        for(i = 0; i<26; i++){
                if(*(a+i) > 0){
                        f++;
                }else{
                        if(f > 3)
                                c += f-3;
                        f = 0;
                }
                *(a+i) -= 1;
        }
        if(f>3)
                c += f-3;

        f = 0;
        for(i = 0; i<10; i++){
                if(*(n+i) > 0){
                        f++;
                }else{
                        if(f > 3)
                                c += f-3;
                        f = 0;
                }
                *(n+i) -= 1;
        }
        if(f>3)
                c += f-3;
}
        printf("%d\n",strlen(str)-c);

        return 0;
}


Measured memory_bytes: 2148