akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <cassert>
using namespace std;
using LL = long long;

LL edrimos[2345][2345];
LL eddimos[2345][2345];
LL veimos[2345][2345];
LL n, m, q;
vector<string>board;

int main(void)
{
	cin >> n >> m >> q;
	for (int i = 0; i < n; ++i)
	{
		string s;
		cin >> s;
		board.push_back(s);
	}
	auto cell = [&](int i, int j)
	{
		assert(i >= 0 && j >= 0 && i < n && j < m);
		return board[i][j] - '0';
	};
	//imos構築
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
		{
			veimos[i + 1][j + 1] = cell(i, j);
		}
	//右に伸びる辺
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m - 1; ++j)
		{
			if (cell(i, j) && cell(i, j + 1))
			{
				edrimos[i + 1][j + 1] += 1;
			}
		}
	//下に伸びる辺
	for (int i = 0; i < n - 1; ++i)
		for (int j = 0; j < m; ++j)
		{
			if (cell(i, j) && cell(i + 1, j))
			{
				eddimos[i + 1][j + 1] += 1;
			}
		}
	//累積する
	for (int i = 0; i <= n; ++i)
		for (int j = 0; j < m; ++j)
		{
			edrimos[i][j + 1] += edrimos[i][j];
			eddimos[i][j + 1] += eddimos[i][j];
			veimos[i][j + 1] += veimos[i][j];
		}
	for (int i = 0; i < n; ++i)
		for (int j = 0; j <= m; ++j)
		{
			edrimos[i + 1][j] += edrimos[i][j];
			eddimos[i + 1][j] += eddimos[i][j];
			veimos[i + 1][j] += veimos[i][j];
		}
	for (int k = 0; k < q; ++k)
	{
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		int lefcost = 0;
		{
			int px = x1 - 1, py = y1 - 1;
			int qx = x2, qy = y2 - 1;
			lefcost = edrimos[px][py] + edrimos[qx][qy] - edrimos[px][qy] - edrimos[qx][py];
		}
		int uppcost = 0;
		{
			int px = x1 - 1, py = y1 - 1;
			int qx = x2 - 1, qy = y2;
			uppcost = eddimos[px][py] + eddimos[qx][qy] - eddimos[px][qy] - eddimos[qx][py];
		}
		int vertcost = 0;
		{
			int px = x1 - 1, py = y1 - 1;
			int qx = x2, qy = y2;
			vertcost = veimos[px][py] + veimos[qx][qy] - veimos[px][qy] - veimos[qx][py];
		}
		int ans = vertcost - lefcost - uppcost;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 120576
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            String s = in.next();
            boolean[] odd = new boolean[26];

            for (char c : s.toCharArray())
                odd[c - 'a'] = !odd[c - 'a'];

            for (boolean o : odd) {
                if (o) {
                    out.println("No");
                    return;
                }
            }
            out.println("Yes");
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
            this.bufPointer = 0;
            this.bufLength = 0;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isPrintableChar(int c) {
            return c >= 33 && c <= 126;
        }

        public String next() {
            StringBuilder sb = new StringBuilder();

            int b = readByte();
            while (!isPrintableChar(b))
                b = readByte();

            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }

            return sb.toString();
        }

    }
}



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

//#define int long long
//struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
//const int MOD = 1e9 + 7;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

int H, W;
bool can_move[30][30][4];

inline bool is_safe(int x, int y){
    return (0 <= x && x < W)&&(0 <= y && y < H);
}

int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
enum {DOWN, RIGHT, UP, LEFT};

int dist[50][50];
int bfs(){
    queue<pair<int,int>> q;
    
    q.push({0,0});
    rep(i,H)rep(j,W) dist[i][j] = 0;
    dist[0][0] = 1;
    
    while(!q.empty()){
        int x = q.front().first;
        int y = q.front().second;
        int d = dist[y][x];
        
        q.pop();
        
        for(int i = 0; i < 4; ++i){
            if(!can_move[y][x][i]){
                continue;
            }
            int x1 = x+dx[i], y1 = y+dy[i];
            
            if(!is_safe(x1,y1))    continue;
            if(dist[y1][x1] != 0)  continue;
            
            if(x1 == W-1 && y1 == H-1){
                return d + 1;
            }
            
            dist[y1][x1] = d+1;
            q.push({x1, y1});
        }
    }
    
    return 0;
}

int solve(){
    rep(i,H)rep(j,W)rep(k,4) can_move[i][j][k] = true;
    
    rep(i,2*H-1){
        if(i % 2 == 0){
            rep(j,W-1){
                bool is_wall; cin >> is_wall;
                if(is_wall){
                    can_move[i/2][j][RIGHT]  = false;
                    can_move[i/2][j+1][LEFT] = false;
                }
            }
        }else{
            rep(j,W){
                bool is_wall; cin >> is_wall;
                if(is_wall){
                    can_move[i/2][j][DOWN] = false;
                    can_move[i/2+1][j][UP] = false;
                }
            }
        }
    }
    
    return bfs();
}

signed main(){
    while(true){
        cin >> W >> H;
        if(W==0 && H==0) break;
        cout << solve() << endl;
    }
}


Measured memory_bytes: 3140
#define _USE_MATH_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

int main() {
    string S;
    cin >> S;
    set<char>st;
    for (int i = 0; i < S.size(); i++) {
        if (find(st.begin(), st.end(), S[i])!= st.end()) {
            cout << "no" << endl;
            return 0;
        }
        st.insert(S[i]);
    }

    cout << "yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int h, w, i, j;
  while(1){
    scanf("%d %d",&h,&w);
    if(h==0 && w==0) break;

    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(i==0 || i==h-1 || j==0 || j==w-1) printf("#");
	else printf(".");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2088
N, M = map(int, input().split())
a_list = list(map(int, input().split()))

items = {
    1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6
}
dp = ["-"] * (N + 10000)

dp[0] = ""


def max_str(s, t):
    if s == "-":
        return t
    elif len(s) < len(t):
        return t
    elif len(s) == len(t):
        if s < t:
            return t
        else:
            return s
    else:
        return s


for i in range(N + 1):
    if dp[i] == "-":
        continue
    for a in a_list:
        dp[i + items[a]] = max_str(dp[i + items[a]], dp[i] + str(a))

print(dp[N])


Measured memory_bytes: 30196
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		int num;
		int counter = 0;
		for (int i = n; i > 0; --i) {
			num = i;
			while (num % 5 == 0 && num != 0) {
				counter++;
				num /= 5;
			}
		}
		cout << counter << endl;
	}
}

Measured memory_bytes: 2988
//ProblemE.cpp

#include <iostream>

static std::istream & ip = std::cin;
static std::ostream & op = std::cout;

#if OJ_MYPC
#include <ojio.h>
#endif

#ifndef OPENOJIO
#define OPENOJIO
#endif

#if 1 || DEFINE
/***************************************************************/
typedef unsigned long long u64;
typedef long long s64;

typedef unsigned uint;

#define ABS(x) ((x) > 0 ? (x) : -(x))

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

#define MIN3(x, y, z) MIN(x, MIN(y, z))
#define MAX3(x, y, z) MAX(x, MAX(y, z))

#define FillZero(arr) memset(arr, 0, sizeof(arr));

/***************************************************************/
#endif //1 || DEFINE

#include <string>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <stack>
#include <utility>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>

//001
//op << setfill('0') << setw(3) << setiosflags(ios::right) << 1;

//op << fixed << setprecision(20);

using namespace std;

//ProblemE.cpp

#define MAXN 100010
#define MAXM 100010
#define MAXQ 100010

int main(int argc, char* argv[])
{
	OPENOJIO;

	int n, m, q;
	static int a[MAXQ];

	ip >> n >> m >> q;
	for (int i = 1; i <= q; ++i) ip >> a[i];

	static bool used[MAXM];
	for (int i = 1; i <= m; ++i) used[i] = false;

	int last[MAXM];
	int ilast = 1;

	for (int i = q; i >= 1; --i) {
		if (used[a[i]])
			continue;

		last[ilast++] = a[i];
		used[a[i]] = true;
	}

	for (int i = 1; i <= m; ++i) {
		if (used[i])
			continue;

		last[ilast++] = i;
	}

	int mii[MAXM];
	for (int i = 1; i <= m; ++i)
		mii[last[i]] = i;

	static int cl[MAXM];
	for (int i = 1; i <= m; ++i)
		cl[i] = 0;
	cl[0] = n;

	for (int i = q; i >= 1; --i) {
		int index = mii[a[i]];

		if (cl[index - 1] > 0) {
			--cl[index - 1];
			++cl[index];
		}
	}

	bool rst = true;
	for (int i = 0; i < m; ++i) {
		if (cl[i] == 0) continue;
		for (int j = i + 1; j < m; ++j) {
			if (last[j] > last[j + 1]) {
				rst = false;
				break;
			}
		}
		break;
	}

	op << (rst ? "Yes" : "No") << endl;
	return 0;
}
/***************************************************************/


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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vector<long long>>;
df data(n, vector<long long>(m));
const int MOD = 1e9 + 7;
int INF = numeric_limits<int>::max();
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join; // string s = join(arr, "");
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
#include <boost/range/algorithm.hpp> // boost::sort(arr)
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/

/* if in function
template <class T>
bool contain(vector<T> &vec, T find_it) {
  auto it = find(vec.begin(), vec.end(), find_it);
  return it != vec.end();
}

bool contain(string &str, char c) {
  return str.find(c) != string::npos;
}
*/

int main() {
  string s;
  cin >> s;
  cout << s.front() + to_string(s.size() - 2) + s.back() << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
using namespace std;

int main ()
{
	int a, b;
	cin >> a >> b;
	cout << "a " << (a < b ? "<" : (a == b ? "==" : ">")) << " b" << endl;
	
	return 0;
}


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

using llu = unsigned int;

llu power( llu b, llu i ){
    llu r = 1;
    while( i ){
        if( i&1 ) r *= b;
        i >>= 1;
        b *= b;
    }
    return r;
}

int main() {

    int N;
    Scd(N);

    char s[312][312];

    Rep(i,N) Scs(s[i]);

    llu hash = 0;
    llu roll = 1000000007;
    llu roll2 = 998244353;
    llu rollN = power(roll,N);
    llu roll2N = power(roll2,N);
    llu  vh[300][300];
    llu  hh[300][300];
    llu vhh[300][300];
    llu hhh[300][300];

    Rep(i,N){
        hash = 0;
        Rep(j,N) hash = hash*roll + s[i][j];
        Rep(j,N){
            hh[i][j] = hash;
            hash = hash*roll - s[i][j]*rollN + s[i][j];
        }
    }
    Rep(j,N){
        hash = 0;
        Rep(i,N) hash = hash*roll2 + hh[i][j];
        Rep(i,N){
            hhh[i][j] = hash;
            hash = hash*roll2 - hh[i][j]*roll2N + hh[i][j];
        }
    }
    Rep(j,N){
        hash = 0;
        Rep(i,N) hash = hash*roll + s[i][j];
        Rep(i,N){
            vh[i][j] = hash;
            hash = hash*roll - s[i][j]*rollN + s[i][j];
        }
    }
    Rep(i,N){
        hash = 0;
        Rep(j,N) hash = hash*roll2 + vh[i][j];
        Rep(j,N){
            vhh[i][j] = hash;
            hash = hash*roll2 - vh[i][j]*roll2N + vh[i][j];
        }
    }

    int ans = 0;
    Rep(i,N) Rep(j,N){
        if( vhh[i][j] == hhh[i][j] ) ans++;
    }
    printf ("%d\n", ans );

    return 0;
}





Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
 
int main(void) {
    char a[200],b[200],result[200],temp[200];
    int ketaagari;
    int i,j;
    int max;
    char in;
    int overflow;
    int count,kazu;
    scanf("%d",&kazu);
    for(count=0;count<kazu;count++) {
        for(i=0;i<200;i++) {
            a[i]=0;b[i]=0;
        }
        i=0;
        overflow=0;
    	
    	scanf(" %s ",temp);
    	i=strlen(temp);
    	if(i>80)overflow=1;
        else for(j=0;j<i;j++)a[j]=temp[i-j-1]-'0';
    	
    	scanf(" %s ",temp);
    	i=strlen(temp);
    	if(i>80)overflow=1;
    	else for(j=0;j<i;j++)b[j]=temp[i-j-1]-'0';
 
        for(i=0,ketaagari=0,max=0;i<80;i++) {
            result[i]=(a[i]+b[i]+ketaagari)%10;
            ketaagari=(a[i]+b[i]+ketaagari)/10;
            if(result[i]!=0)max=i;
        }
        if(ketaagari)overflow=1;

    	if(overflow==0) {
            for(i=max;i>=0;i--)printf("%d",result[i]);
            printf("\n");
        } else printf("overflow\n");
    }
    return 0;
}

Measured memory_bytes: 0
INF = 10**18


def calc(point_list, t):
    x_min, y_min, x_max, y_max = INF, INF, -INF, -INF
    for point in point_list:
        x, y, d = point
        dx = t if d == 'R' else (-t if d == 'L' else 0)
        dy = t if d == 'U' else (-t if d == 'D' else 0)
        x_min = min(x_min, x + dx)
        x_max = max(x_max, x + dx)
        y_min = min(y_min, y + dy)
        y_max = max(y_max, y + dy)
    return (x_max - x_min) * (y_max - y_min)


def main():
    N = int(input())
    point_list = list()
    x_min, y_min, x_max, y_max = INF, INF, -INF, -INF
    for _ in range(N):
        X, Y, D = input().split()
        X = int(X)
        x_min = min(x_min, X)
        x_max = max(x_max, X)
        Y = int(Y)
        y_min = min(y_min, Y)
        y_max = max(y_max, Y)
        point_list.append((X, Y, D))
    if N == 1:
        print(0)
        return
    t_left, t_right = 0, 2 * max(x_max - x_min, y_max - y_min)
    v_left, v_right = calc(point_list, t_left), calc(point_list, t_right)
    while True:
        dt = t_right - t_left
        if dt < 10 ** (-8):
            break
        t_in_left, t_in_right = t_left + dt / 3, t_right - dt / 3
        v_in_left, v_in_right = calc(point_list, t_in_left), calc(point_list, t_in_right)
        if v_in_left < v_in_right:
            t_right = t_in_right
            v_right = v_in_right
        else:
            t_left = t_in_left
            v_left = v_in_left
    print(v_left)


if __name__ == '__main__':
    main()

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

def main():
    H,W = map(int, input().split())
    if (H==1) or (W==1):
        print(1)
        quit()
        
    i = H*W
    if i%2==0:
        print(i//2)
    else:
        print(i//2+1)

if __name__ == '__main__':
    main()

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

int a[20];
int main(){
	int x, y;
	a[1] = a[3] = a[5] = a[7] = a[8] = a[10] = a[12] = 1;
	a[4] = a[6] = a[9] = a[11] = 2;
	a[2] = 3;
	scanf("%d%d", &x, &y);
	if(a[x] == a[y])printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, d, x;
  cin >> n >> d >> x;
  for (int i = 1; i <= n; i++) {
    int t;
    cin >> t;
    for (int j = 1; j <= d; j += t)
      x++;
  }
  cout << x << endl;
}

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

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

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  if(n == 0) cout << 1 << endl;
  else cout << 0 << endl;
  
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <math.h>
#include <numeric>
#include <iomanip>
using namespace std;
int main(){
  int A,B,H,M;
  cin >> A >> B >> H >> M;
  float Am=30*H+0.5*M;
  float Bm=6.*M;
  float space=abs(Am-Bm);
  double ans=sqrt(A*A+B*B-2*A*B*cos(double(space*M_PI/180)));
  cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 4164
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e10;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};


int main(){
    ll A,B,C,D; cin>>A>>B>>C>>D;
    A--; A/=D;
    C--; C/=B;
    if(A>=C) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

typedef long long LL;

template <class TAT>
void read(TAT &a)
{
	static char ch;
	while ((ch = getchar()) < '0' || ch > '9');
	a = ch - '0';
	while ((ch = getchar()) >= '0' && ch <= '9') a = a * 10 + ch - '0';
}

const int maxn = 2e5+115;
const int mod = 1e9+7;

int n;
struct Data
{
	int x, v;
	int index;
}per[maxn];
int L[maxn], R[maxn];
int two[maxn];

bool cmp_Data_x(const Data &a, const Data &b)
{
	return a.x < b.x;
}
bool cmp_Data_v(const Data &a, const Data &b)
{
	return a.v < b.v;
}
bool cmp_pair_second(const pair<int, int> &a, const pair<int, int> &b)
{
	return a.second < b.second || (a.second == b.second && a.first < b.first);
}

void Init()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		read(per[i].x);
		read(per[i].v);
	}
	sort(per + 1, per + 1 + n, cmp_Data_v);
	for (int i = 1; i <= n; ++i) {
		per[i].index = i;
	}
	two[0] = 1;
	for (int i = 1; i <= n; ++i) two[i] = (two[i - 1] * 2) % mod;
}

void Get_interval()
{
	static bool del[maxn];
	int p;
	sort(per + 1, per + 1 + n, cmp_Data_x);
	memset(del, 0, sizeof(del)); p = n;
	for (int i = n; i >= 1; --i) {
		R[per[i].index] = p;
		del[per[i].index] = 1;
		while (del[p]) --p;
	}
	memset(del, 0, sizeof(del)); p = 1;
	for (int i = 1; i <= n; ++i) {
		L[per[i].index] = p;
		del[per[i].index] = 1;
		while (del[p]) ++p;
	}
}

void Solve()
{
	int S, T;
	static int f[maxn], sum[maxn];
	static pair<int, int> interval[maxn];
	for (int i = 1; i <= n; ++i) {
		interval[i] = make_pair(L[i], R[i]);
	}
	sort(interval + 1, interval + 1 + n, cmp_pair_second);
	f[0] = 1; sum[0] = 1;
	S = 1; T = 1;
	for (int i = 1; i <= n; ++i) {
		if (interval[S].second == i) {
			T = S;
			while (T < n && interval[T + 1].second == interval[S].second) ++T;
			for (int j = S; j <= T; ++j) {
				f[i] = (f[i] + (LL)(sum[i - 1] - sum[interval[j].first - 2] + mod) % mod * two[T - j]) % mod;
			}
			S = T + 1;
		}
		else {
			f[i] = 0;
		}
		sum[i] = (sum[i - 1] + f[i]) % mod;
	}
	printf("%d\n", f[n]);
}

int main()
{
	Init();
	Get_interval();
	Solve();
	return 0;
}
	


Measured memory_bytes: 8320
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;

void solve() {
  int x, y;
  cin >> x >> y;
  int ret = x;
  if(x%y==0) ret = -1;
  cout << ret << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
}


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

int main() {
  int n;
  cin >> n;
  int a = n % 10;
  if (a == 3) cout << "bon" << endl;
  else if (a == 0 || a == 1 || a == 6 || a == 8) cout << "pon" << endl;
  else cout << "hon" << endl;
}

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

int main() {
  int N;
  cin >> N;
  bool col[8]={true,true,true,true,true,true,true,true};
  int mas=0;
  int g=0;
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    if(0<a && a<400 && col[0]){
      mas++;
      col[0]=false;
    }
    else if(399<a && a<800 && col[1]){
      mas++;
      col[1]=false;
    }
    else if(799<a && a<1200 && col[2]){
      mas++;
      col[2]=false;
    }
    else if(1199<a && a<1600 && col[3]){
      mas++;
      col[3]=false;
    }
    else if(1599<a && a<2000 && col[4]){
      mas++;
      col[4]=false;
    }
    else if(1999<a && a<2400 && col[5]){
      mas++;
      col[5]=false;
    }
    else if(2399<a && a<2800 && col[6]){
      mas++;
      col[6]=false;
    }
    else if(2799<a && a<3200 && col[7]){
      mas++;
      col[7]=false;
    }
    else if(a>3199){
      g++;
    }
  }
  if(mas==0){
    cout << 1 << ' ' << g;
  }
  else
    cout << mas << ' ' << mas+g;
}



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

int main() {
  char c;
  cin >> c;

  if (c == 'a'
     || c == 'e'
     || c == 'i'
     || c == 'o'
     || c == 'u') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}

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

int main(){
    int N,L;
    cin >> N >> L;
    int taste[N];
    int i;
    int all_apple = 0;
    for (i = 0; i < N;i++){
        taste[i] = L + i;
        all_apple += taste[i];
    }
    int j;
    int min_diff=420000;
    int tmp,pi;
    for(i = 0;i < N;i++){
        pi = 0;
        for(j = 0;j < N;j++){
            if(i != j){
                pi += taste[j];
            }
        }
        if (abs(all_apple - pi) < min_diff){
            min_diff = abs(all_apple - pi);
            tmp = pi;
        }
    }
    cout << tmp << endl;
}

Measured memory_bytes: 256
# Problem B - Break Number

# input
N = int(input())

# initialization
max_count = -1
max_ans = 1

# count
for i in range(1, N+1):
    tmp_count = 0
    tmp = i
    while tmp%2==0:
        tmp_count += 1
        tmp = tmp // 2
    if tmp_count>max_count:
        max_count = tmp_count
        max_ans = i

# output
print(max_ans)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  string S;
  cin >> S;
  
  bool r = true;
  vector<long> res;
  res.reserve(S.size());
  long cnt_r = 0;
  long cnt_l = 0;
  for (size_t i = 0, size = S.size(); i < size; ++ i) {
    char c = S[i];
    if (c == 'R' || i == size - 1) {
      if (r && c == 'R') ++cnt_r;
      if (c == 'L') {
        ++cnt_l;
        if (r) {
          for (long j = 1; j < cnt_r; ++j) {
            res.push_back(0);
          }
        }
        r = false;
      }
      if (!r) {
        long r_base = cnt_r / 2;
        long l_base = cnt_l / 2;
        res.push_back(r_base + l_base + cnt_r % 2);
        res.push_back(r_base + l_base + cnt_l % 2);
        for (long j = 1; j < cnt_l; ++j) {
          res.push_back(0);
        }
        cnt_r = 1;
        cnt_l = 0;
        r = true;
      }
    } else {
      if (r) {
        r = false;
        for (long j = 1; j < cnt_r; ++j) {
          res.push_back(0);
        }
        cnt_l = 1;
      } else {
        ++cnt_l;
      }
    }
  }
  cout << res[0];
  for (size_t i = 1, size = res.size(); i < size; ++i) {
    cout << " " << res[i];
  }
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 1408
h,w = map(int, input().split())
s = [list(input()) for i in range(h)]
dx = [-1,0,1]
dy = [-1,0,1]
for i in range(h):
	for j in range(w):
		count = 0
		if s[i][j] == '#':
			continue
		if s[i][j] == '.':
			for l in dx:
				for m in dy:
					if i+l< 0 or i+l > h-1 or j+m < 0 or j+m > w-1:
						continue
					if s[i+l][j+m] == '#':
						count += 1
		s[i][j] = str(count)
for i in s:
	k = ''.join(i)
	print(k)

Measured memory_bytes: 3188
#include<cstdio>
const int MAXN=200;
int a[MAXN][MAXN];
int main()
{
	int n,i,j,k;
	int max=-10,s=0;
	scanf("%d",&n);
	for(i=1;i<=2;i++)
		for(j=1;j<=n;j++)
			scanf("%d",&a[i][j]);
	for(k=1;k<=n;k++)
	{
		s=0;
		for(j=1;j<=k;j++)
			s+=a[1][j];
			
		for(j=k;j<=n;j++)
			s+=a[2][j];
		if(s>max)
			max=s;
	}
	printf("%d\n",max);
	return 0;
}


Measured memory_bytes: 128
def partition(A, p, r):
    r = r-1
    x = A[r]
    i = p-1
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return  A, i+1

def main():
    n = int(input())
    A = list(map(int, input().split()))
    A, i = partition(A, 0, len(A))
    for j, a in enumerate(A):
        if j == i:
            print(f"[{a}] ", end="")
        elif j == (len(A)-1):
            print(f"{a}")
        else:
            print(f"{a} ", end="")
        




if __name__ == "__main__":
    main()


Measured memory_bytes: 16400
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<string,ll> mp;
#define inf 1e9


string stdaikus(vector<vector<mp> > &g,int s,int t){
	int n = g.size();
	vector<vector<string> > cost(n,vector<string>(2*n*6+10,"{") );
	vector<vector<bool> > used(n,vector<bool>(2*n*6+10,false) );
	priority_queue<mp,vector<mp>,greater<mp> > q;
	q.push(mp("",s) );
	cost[s][0] = "";
	while(!q.empty() ){
		mp now = q.top();
		string str = now.first;
		ll nn = now.second;
		q.pop();
		//if(str.size() > n*6 ) "NO";
		if(nn == t){
		    if(str.size() <= (n*6) )return str;
		    else return "NO";
		}
		if(used[nn][str.size() ] )continue;
		used[nn][str.size()] = true;
		cost[nn][str.size()] = min(str,cost[nn][str.size()] );
		for(int i=0;i<g[nn].size();i++){
			ll next = g[nn][i].second;
			string nstr =str +  g[nn][i].first;
			if(nstr.size() >= 2*n*6+10 )continue;
			if(used[next][nstr.size()] )continue;
			//if(cost[next][nstr.size()] <= nstr  ) continue;
			//cost[next][nstr.size()] = nstr;
			q.push(mp(nstr,next) );
		}
	}
	return "NO";
}


int main(){
	while(1){
		int n,a,s,gg;
		cin>>n>>a>>s>>gg;
		if(n==0)break;
	//	cout<<"OK"<<n<<' '<<a<<' '<<s<<' '<<gg<<endl;
		vector<vector<mp> > g(n);
		for(int i=0;i<a;i++){
			int x,y;
			string st;
			cin>>x>>y>>st;
			g[x].push_back(mp(st,y) );
		}
		cout<< stdaikus(g,s,gg) <<endl;

	}
	return 0;
}



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

 int main() {
   int N;
   cin >> N;
   //cout << N << endl;
   vector<int> A(N),B(N);
   for(int i = 0;i < N; i++){
     cin >> A.at(i) >> B.at(i);
   }
   
   int ans = 0;
   for(int i = 0; i < N;i++){
    ans += B.at(i) - A.at(i) + 1; 
   }
   cout << ans << endl;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sort stable_sort
#define all(x) (x).begin(),(x).end()
#define rep(i,x) for (int (i)=(1);(i)<=(x);(i)++)
#define rep2(i,x) for (int (i)=(x);(i)>=(1);(i)--)
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
using namespace std;
int n,m,q,i,j,nxtx[100005],prex[100005],nxty[100005],prey[100005],x,y,xx,yy,lst1,lst2;
ll dis[55];
string s,t;
char ss[100005];
vector<pair<int,int> > all;
vector<pair<int,int> > bi[55];
void add(int x,int y)
{
	all.push_back(make_pair(x,y));
	if (prex[x]) all.push_back(make_pair(prex[x],y));
	if (nxtx[x]) all.push_back(make_pair(nxtx[x],y));
	if (prey[y]) all.push_back(make_pair(x,prey[y]));
	if (nxty[y]) all.push_back(make_pair(x,nxty[y]));
	if (prex[x]&&prey[y]) all.push_back(make_pair(prex[x],prey[y]));
	if (prex[x]&&nxty[y]) all.push_back(make_pair(prex[x],nxty[y]));
	if (nxtx[x]&&prey[y]) all.push_back(make_pair(nxtx[x],prey[y]));
	if (nxtx[x]&&nxty[y]) all.push_back(make_pair(nxtx[x],nxty[y]));
}
ll dijkstra(int x,int y)
{
	memset(dis,18,sizeof(dis));
	dis[x]=0;
	priority_queue<pair<ll,ll> > pq;
	pq.push(make_pair(0,x));
	while (!pq.empty())
	{
		x=pq.top().second;pq.pop();
		foreach(it,bi[x])
		{
			if (dis[it->fi]>dis[x]+it->se)
			{
				dis[it->fi]=dis[x]+it->se;
				pq.push(make_pair(-dis[it->fi],it->fi));
			}
		}
	}
	if (dis[y]==dis[54]) return -1;
	return dis[y];
}
void solve(int x,int y,int xx,int yy)
{
	sort(all.begin(),all.end());
	all.resize(unique(all.begin(),all.end())-all.begin());
//	foreach(it,all) cerr<<it->fi<<' '<<it->se<<endl;
	int i,j,ss,tt;
	for (i=0;i<all.size();i++) if (all[i].first==x&&all[i].second==y) ss=i;
	for (i=0;i<all.size();i++) if (all[i].first==xx&&all[i].second==yy) tt=i;
	for (i=0;i<all.size();i++) bi[i].clear();
	for (i=0;i<all.size();i++) for (j=0;j<all.size();j++) if (i!=j)
	{
		if (all[i].first==all[j].first&&((s[all[i].first]=='E')==(all[i].second<all[j].second)))
		{
			bi[i].push_back(make_pair(j,abs(all[i].second-all[j].second)));
		}
		if (all[i].second==all[j].second&&((t[all[i].second]=='S')==(all[i].first<all[j].first)))
		{
			bi[i].push_back(make_pair(j,abs(all[i].first-all[j].first)));
		}
	}
	printf("%lld\n",dijkstra(ss,tt));
}
int main()
{
	scanf("%d%d%d",&n,&m,&q);
	scanf(" %s",ss);s=ss;s=" "+s;
	scanf(" %s",ss);t=ss;t=" "+t;
	lst1=lst2=0;
	rep(i,n){if (s[i]=='W'){prex[i]=lst2;lst1=i;}else{prex[i]=lst1;lst2=i;}}
	lst1=lst2=0;
	rep2(i,n){if (s[i]=='W'){nxtx[i]=lst2;lst1=i;}else{nxtx[i]=lst1;lst2=i;}}
	lst1=lst2=0;
	rep(i,m){if (t[i]=='N'){prey[i]=lst2;lst1=i;}else{prey[i]=lst1;lst2=i;}}
	lst1=lst2=0;
	rep2(i,m){if (t[i]=='N'){nxty[i]=lst2;lst1=i;}else{nxty[i]=lst1;lst2=i;}}
	while (q--)
	{
		scanf("%d%d%d%d",&x,&y,&xx,&yy);
		all.clear();
		add(x,y);add(x,yy);add(xx,y);add(xx,yy);
		solve(x,y,xx,yy);
	}
	return 0;
}

Measured memory_bytes: 3456
#include <cassert>
#include <numeric>
#include <vector>
#include <iostream>
using namespace std;
int main() {
    string s; cin >> s;
    vector<int> idx[26];
    const int n = s.size();
    for (int i = 0; i < n; i++) idx[s[i]-'a'].push_back(i);
    int ocount = 0;
    for (vector<int> &v : idx) if (v.size() % 2) ocount++;
    if (ocount > 1) { cout << "-1\n"; return 0; }
    int target[n];
    fill(target, target+n, -1);
    for (int i = 0; i < 26; i++)
        for (int l = 0, r = idx[i].size()-1; l <= r; l++, r--)
            target[idx[i][l]] = idx[i][r];
    int p[n];
    for (int i = 0, l = 0; i < n; i++) {
        if (target[i] == -1) continue;
        if (target[i] == i) { p[i] = n/2; continue; }
        p[i] = l;
        p[target[i]] = n-l-1;
        assert (l < n - l - 1);
        l++;
    }
    // for (int i = 0; i < n; i++) cerr << target[i] << " "; cerr << endl;
    // for (int i = 0; i < n; i++) cerr << p[i] << " "; cerr << endl;
    long long ans = 0;
    int bit[n+1];
    fill(bit, bit+n+1, 0);
    for (int i = 0; i < n; i++) {
        for (int x = p[i]+1; x <= n; x += x&-x) ans += bit[x];
        for (int x = p[i]+1; x > 0; x -= x&-x) bit[x]++;
    }
    cout << ans << endl;
}


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

main(){
  int n, T[10], x;
  while(1){
    cin >> n;
    if ( n == 0 ) break;
    assert(1 <= n && n <= 10000);
    for ( int i = 0; i < 10; i++ ) T[i] = 0;
    for ( int i = 0; i < n; i++ ){ 
      cin >> x; T[x]++;
    }
    for ( int i = 0; i < 10; i++ ){
      if (T[i] == 0 ) cout << "-" << endl;
      else {
	for ( int j = 0; j < T[i]; j++ ) cout << "*";
	cout << endl;
      }
    }
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;

int n, mx, mx2, mi, a[N];
int main()
{
	int i, t;
	cin >> n;
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		mx = max(mx, a[i]);
	}
	for (i = 0; i < n; i++) {
		if (a[i] > mx - a[i]) t = mx - a[i];
		else t = a[i];
		if (t > mx2) mx2 = t, mi = a[i];
	}
	cout << mx << ' ' << mi;
    return 0;
}

Measured memory_bytes: 640
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = (1e-9);
typedef long long ll;
typedef unsigned long long ull;
#define flush fflush(stdout), cout.flush()
#define all(v) ((v).begin()),((v).end())
#define rall(v) ((v).rbegin()),((v).rend())
#define clr(v,line) memset(v,line,sizeof(v))
#define rep(i,n) for(int(i)=0;(i)<(int)(n);(i)++)
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define RT(x) return cout<<x, 0;
//#define lcm(a,b) (a*(b/__gcd(a,b)))
#define P 1000000007
#define endl '\n'
const int dx[] = {1,-1,0,0,1,-1,1,-1};
const int dy[] = {0,0,1,-1,1,-1,-1,1};
const int dxhorse[] = {-2,-2,-1,-1,1,1,2,2};
const int dyhorse[] = {1,-1,2,-2,2,-2,1,-1};
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 <<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* coma = strchr(names + 1, ',');cerr.write(names, coma - names) << " : " << arg1<<" | ";__f(coma+1, args...);
}
#else
#define trace(...)
#endif
 
void file() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void fast()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
}
std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int h, w;

char grid[1003][1003];

bool valid(int r, int c){return r >= 0 && r < h && c >= 0 && c < w && grid[r][c]!='#';}

int dp[1003][1003];

int solve(int r, int c)
{
    if(!valid(r, c))return 0;

    if(r == h - 1 && c == w - 1)return 1;

    int & ret = dp[r][c];
    if(~ret)return ret;
    return ret = (solve(r + 1 , c) % P + solve(r , c + 1) % P) % P;

}

int main(int argc, char const *argv[])
{
    // file();
    fast();
   
    cin>>h>>w;
    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
        {
            cin>>grid[i][j];
        }
    }
    clr(dp, -1);
    cout<<solve(0, 0);
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s; cin >> s;
  int f[3] = {0, 0, 0};
  for(char x : s){
    if(x == 'a') f[0] = 1;
    else if(x == 'b') f[1] = 1;
    else if(x == 'c') f[2] = 1;
  }
  if(f[0]&&f[1]&&f[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int Alice = 0, Bob = 0, N;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0; i < N; i++) cin >> vec[i];
  sort(vec.begin(), vec.end());
  for(int i = 0; i < N; i++) {
    if(i % 2 == 0) Alice += vec[i];
    else Bob += vec[i];
  }
  cout << abs(Alice - Bob) << endl;
}

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

class UF{
  vi p,r;

public:
  UF(int n):p(n,-1),r(n,0){ }

  int find(int x){ return (p[x]<0)?x:(p[x] = find(p[x])); }

  void unite(int x,int y){
    x = find(x); y = find(y);
    if(x==y)return;

    if(r[x] < r[y])p[x] = y;
    else p[y] = x;
    if(r[x] == r[y])r[x]++;
  }

  bool same(int x,int y){return find(x)==find(y);}
};

int memo[1001][1001][2];

int rec(int odd, int even, int edges){
  if(memo[odd][even][edges]>=0)return memo[odd][even][edges];
  if(odd + even == 2)return edges;

  int res = 1;
  if(edges)res *= rec(odd, even, 1-edges);
  if(odd && even)res *= rec(odd, even-1, 1-edges);
  if(odd >= 2)res *= rec(odd-2, even+1, edges);
  if(even >= 2)res *= rec(odd, even-1, 1-edges);

  return memo[odd][even][edges] = 1-res;
}

int main(){
  int n;
  scanf("%d",&n);
  UF uf(n);

  char s[1010];
  int num = 0;
  rep(i,n){
    scanf("%s",s);
    rep(j,i)if(s[j] == 'Y')uf.unite(i,j), num--;
  }

  vi card(n,0);
  rep(i,n)card[uf.find(i)]++;
  
  int odd = 0, even = 0;
  rep(i,n){
    if(card[i]){
      if(card[i] & 1)odd++;
      else even++;
      num += card[i]*(card[i]-1)/2;
    }
  }

  memset(memo,-1,sizeof(memo));
  if(rec(odd, even, num&1))puts("Taro");
  else puts("Hanako");
}

Measured memory_bytes: 9136
A,B,K = map(int, input().split())
for i in range(1,K+1):
    if i%2 == 1:
        if(A%2==1):
            A = (A-1)/2
        else:
            A = A/2
        B = B+A
    else:
        if(B%2 == 1):
            B = (B-1)/2
        else:
            B = B/2
        A = A+B
print(int(A), int(B))

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

  typedef long long int ll;
  typedef pair<int,int> pi;
  typedef pair<ll,ll> pll;
  typedef vector<int> vi;
  typedef vector<ll> vll;
  typedef vector<pi> vpi;
  typedef vector<pll> vpll;

  #define  ff           first
  #define  ss           second
  #define  pb           push_back
  #define  IOS          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define  D(x)         cout << #x << " - " << x << endl;
  #define  D2(x)        cout << "[" << #x << ": "; for(auto it:x) cout << it << " "; cout << "]" << endl;
  #define  all(x)       (x).begin(), (x).end()
  #define  D2p(x)       cout << #x << " ~ [ "; for(auto n: x) cout << n.first << "-" << n.second << " / "; cout << "]" << endl;
  #define  ps(x,y)      fixed<<setprecision(y)<<x
  #define  rep(i,a,b)   for(ll i=a ; i<b ; ++i)

  const ll MOD = 1e9 + 7;
  const ll INF = 1e18;
  const ll maxn = 1e6 + 4;


  void solve(){
	ll a,b;
	cin >> a >> b;
	ll k = __gcd(a,b);
	int ans=0;
	for(ll i=2;i*i<=k;i++){
		int cnt=0;
		while(k%i==0){
			k/=i;
			cnt++;
		}
		if(cnt)ans++;
	}
	if(k>1)ans++;
	cout << ans+1;
  }

  int main(){
    IOS
    solve();
    cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }

// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


Measured memory_bytes: 3756
#include<iostream>
#include<algorithm>
using namespace std;
long n,a[1<<17],t;
main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<n-1;i++)
	{
		if(a[i+1]>a[i]*2)t=i+1;
		a[i+1]+=a[i];
	}
	cout<<n-t<<endl;
}

Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7 # 998244353
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    S = input()
    k = int(input())
    n = len(S)
    candidate = set()
    for l in range(1, k + 1):
        for i in range(n - l + 1):
            candidate.add(S[i : i + l])
    print(sorted(candidate)[k - 1])
resolve()

Measured memory_bytes: 39024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int[] list = new int[3];
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        for (int i=0; i<3; i++) {
        	list[i] = sc.nextInt();
        }
    }
    
    //解答処理
    private String solve() {
        String answer = "NO";
        int count5 = 0;
        int count7 = 0;
        
        for (int i=0; i<3; i++) {
        	if (list[i] == 5) {
        		count5++;
        	} else if (list[i] == 7) {
        		count7++;
        	}
        }
        if (count5 == 2 && count7 == 1) {
        	answer = "YES";
        }
        
        return answer;
    }
    
    //出力
    public void show(String answer) {
        System.out.println(answer);
    }

}


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

namespace ConsoleApp11
{
    class Class19
    {
        static void Main()
        {
            string S = Console.ReadLine();
            string N = "753";
            List<int> Data = new List<int>();
            for(int i = 0; i < S.Length - 2; i++)
            {
                Data.Add(int.Parse(S.Substring(i,3)));

            }
            int R = Data.Min(x => Math.Abs(753 - x));
            Console.WriteLine(R);
        }
    }
}


Measured memory_bytes: 13396
#include <stdio.h>

int main()
{
	int A;
	int B;
	int C;
	int D;
	int R1;
        int R2;
	
	scanf("%d %d %d %d",&A,&B,&C,&D);
	
	R1=A*B;
	R2=C*D;
	
	if(R1>=R2)
	printf("%d\n",R1);
	else
	printf("%d\n",R2);
	
	return 0;
}
	

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int mod=1000000007;
const double PI = 3.14159265359;
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define INF 1000000000000
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define FOR(i,n) for(int i=0;i<(n);i++)
#define FORA(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define count_1(n)  __builtin_popcountll(n)
#define parity(n)   __builtin_parityll(n)   //Even parity 0 as output
void show    (int a[], int arraysize) { for (int i = 0; i < arraysize; ++i)  {cout << a[i] << " ";}	cout<<endl;}
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b);}
void sieve(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}
int main()
{FAST
int a,b,c,v=0;
cin>>a>>b>>c;
int k;
cin>>k;
while(b<=a)
{
	b*=2;
	v++;
}
while(c<=b)
{
	c*=2;
	v++;
}
if(v<=k)
{
	cout<<"Yes\n";
}
else
{
	cout<<"No\n";
}
return  0;
}






Measured memory_bytes: 3652
#include <iostream>

using namespace std;

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

    if (a == b)
    {
        cout << a+b << endl;
    }
    else if (a > b)
    {
        cout << 2 * a - 1 << endl; 
    }
    else
    {
        cout << 2 * b - 1 << endl; 
    }

    return 0;
}

Measured memory_bytes: 256
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mod   998244353
#define PI 2*acos(0.0)
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
int dirx[] = {1, -1,0, 0}, diry[] = {0, 0, 1, -1};

ll bigmod(ll x, ll p)
{
    ll res = 1;
    while(p)
    {
        if(p&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        p >>= 1;
    }
    return res;
}

//=============================================ASIFAZAD==============================================//

int32_t main()
{
    io;
    int n, w;
    cin>>n>>w;
    vi wg(n), val(n);
    ll sum = 0;
    for(int i = 0; i< n;i++)
    {
        cin>>wg[i] >> val[i];
        sum += val[i];
    }
    ll dp[sum + 5];
    for(int i = 0; i< sum + 5; i++)
        dp[i] = INT_MAX;

    dp[0] = 0;

    for(int i =0 ; i< n;i++)
        for(int j = sum - val[i];j>= 0; j--)
            dp[j+val[i]] = min(dp[j+val[i]], wg[i] + dp[j]);

    int ans = 0;
    for(int i = 0 ; i<= sum; i++)
        if(dp[i]<= w)
            ans = i;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 4428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> v;
typedef pair<int,int>p;
typedef set<int>s;
#define ll long long
#define fr(i,a,b) for(int i=a;i<b;i++)
#define fre(i,a,b) for(int i=a;i<=b;i++)
#define FOR(i,a,b) for(int i=a;i>b;--i)
#define FORE(i,a,b) for(int i=a;i>=b;--i)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bg begin()
#define en end()
/*note

*/
int main()
{   int x,n,ans1,ans2,dif1,dif2,i,y,j;
    cin>>x>>n;
    if(n==0){cout<<x<<endl; return 0;}
    int ar[101]={0},br[n];
    for(int i=0;i<n;i++){
        cin>>y;ar[y]=1;br[i]=y;
    }
    sort(br,br+n);
    i=x;
    j=x;
    while(1){

        if(ar[i]==0){dif1=abs(x-i); ans1=i; break;}
        --i;
        if(i<(br[0]-1))break;
    }
    while(1){

        if(ar[j]==0){dif2=abs(x-j); ans2=j; break;}
        ++j;
        if(j>(br[n-1]+1))break;

    }
    if(dif1==dif2)cout<<min(ans1,ans2)<<endl;
    else if(dif1<dif2)cout<<ans1<<endl;
    else cout<<ans2<<endl;








}



Measured memory_bytes: 3640
#include<stdio.h>
int main(void)
{
	int x,n;
	scanf("%d",&x);
	n=x%7;
	if(n==1){
	printf("fri\n");
	}
	else if(n==2){
	printf("sat\n");
	}
	else if(n==3){
	printf("sun\n");
	}
	else if(n==4){
	printf("mon\n");
	}
	else if(n==5){
	printf("tue\n");
	}
	else if(n==6){
	printf("wed\n");
	}
	else {
	printf("thu\n");
	}
	return 0;
}	


Measured memory_bytes: 2136