akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int numVerticalLines, vLineSelected, goalLine, dan;
		int[][] horizontalLine = null;
		while((numVerticalLines = sc.nextInt()) != 0){
			vLineSelected = sc.nextInt();
			goalLine = sc.nextInt();
			dan = sc.nextInt();
			horizontalLine = new int[dan][numVerticalLines];
			//get Line data
			for(int i = 0; i < horizontalLine.length; i++){
				String input = sc.next();
				for(int j = 0; j < horizontalLine[0].length - 1; j++){
					horizontalLine[i][j] = Integer.parseInt(String.valueOf(input.charAt(j)));
				}
			}
			//show result
			System.out.println(solve(vLineSelected, goalLine, horizontalLine));
		}
		sc.close();
	}
	
	public static String solve(int vLineSelected, int goalLine, int[][] horizontalLine){
		if(getPosition(vLineSelected - 1, horizontalLine)[0] == getLineToGoal(goalLine - 1, horizontalLine)[0])
			return "0";
		int[] o = getNewLinePosition(getPosition(vLineSelected - 1, horizontalLine), getLineToGoal(goalLine - 1, horizontalLine), horizontalLine);
		return (o == null)? "1" : ((o[0] + 1) + " " + (o[1] + 1));
	}
	
	private static final int LINE = 1;
	private static final int NO_LINE = 0;
	
	public static int[] getNewLinePosition(int[] pos, int[] goal, int[][] horizontalLine){
		//経路情報を上から参照していく
		for(int dan = 0; dan < pos.length; dan++){
			//隣り合っていて、線を引くことが出来る場合段数を返す
			if(Math.abs(pos[dan] - goal[dan]) == 1){
				int min = Math.min(pos[dan], goal[dan]);
				//既にラインがあれば次の段へ
				if(horizontalLine[dan][min] == LINE)	continue;
				//引くラインの左に線があれば次の段へ
				if(0 < min && horizontalLine[dan][min - 1] == LINE)	continue;
				//引くラインの右に線があれば次の段へ
				if(min < horizontalLine[0].length - 1 && horizontalLine[dan][min + 1] == LINE) continue;
				
				return new int[]{dan, Math.min(pos[dan], goal[dan])};
			}
		}
		return null;
	}
	
	public static int[] getPosition(int n, int[][] horizontalLine){
		int[] pos = new int[horizontalLine.length];
		//横線情報を上から参照していく
		int currentPos = n;
		int tmp;
		for(int d = 0; d < horizontalLine.length; d++){
			tmp = currentPos;
			//左となりの縦線チェック
			if(tmp != 0 && horizontalLine[d][tmp - 1] == LINE){
				currentPos--;
			}
			//右となりの縦線チェック
			else if(tmp != horizontalLine[0].length && horizontalLine[d][tmp] == LINE){
				currentPos++;
			}
			pos[d] = currentPos;
		}
		return pos;
	}

	public static int[] getLineToGoal(int goal, int[][] horizontalLine){
		int[] goalOn = new int[horizontalLine.length];
		//横線情報を下から参照していく
		int currentGoal = goal;
		int tmp;
		for(int d = horizontalLine.length - 1; d >= 0; d--){
			tmp = currentGoal;
			//左となりの縦線チェック
			if(tmp != 0 && horizontalLine[d][tmp - 1] == LINE){
				currentGoal--;
			}
			//右となりの縦線チェック
			else if(tmp != horizontalLine[0].length && horizontalLine[d][tmp] == LINE){
				currentGoal++;
			}
			goalOn[d] = tmp;
		}
		return goalOn;
	}
}

Measured memory_bytes: 18864
#include <iostream>
using namespace std;
typedef long long int ll;

ll gcd(ll x,ll y){
    if(y<x){
        ll t=x;
        x=y;
        y=t;
    }
    ll r = x%y;
    while(r!=0){
        x=y;
        y=r;
        r=x%y;
    }
    return y;
}

int main(){
    ll a,b,c,d;
    cin >> a>>b>>c>>d;
    ll g=gcd(c,d);
    ll l=c*d/g;

    ll ctac=0,ctad=0,ctbc=0,ctbd=0,ctal=0,ctbl=0;
    ctac=(a-1)/c;
    ctad=(a-1)/d;
    ctbc=b/c;
    ctbd=b/d;
    ctal=(a-1)/l;
    ctbl=b/l;
    ll ansb=b-ctbc-ctbd+ctbl;
    ll ansa=a-1-ctac-ctad+ctal;
    ll ans=ansb-ansa;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<cassert>

using namespace std;
typedef long long ll;

const int MAXN = 2222;
const int MOD = 924844033;
ll dp[MAXN][MAXN][2]; // dp[vertexNum][edgeNum][prevUsed] = way
ll P[MAXN];

ll solve(int N, int K) {
    P[0] = 1;
    for (int i = 1; i <= N; i++)
        P[i] = i*P[i-1] % MOD;
    dp[0][0][0] = 1;
    for (int i = 0; i < 2*K; i++) {
        if (i >= N) break;
        // 新しい i になったら情報更新
        if (i) {
            int d = (N-i)/(2*K);
            for (int j = 0; j <= N; j++) {
                (dp[i][j][0] += dp[(i-1)+d*2*K][j][0] + dp[(i-1)+d*2*K][j][1]) %= MOD;
            }
        }
        if (i+K < N) {
            for (int j = N-1; j >= 0; j--) {
                (dp[i][j+1][1] += dp[i][j][0]) %= MOD;
            }
        }
        if (i-K >= 0) {
            for (int j = N-1; j >= 0; j--) {
                (dp[i][j+1][0] += dp[i][j][0]) %= MOD;
            }
        }
        for (int j = i+2*K; j < N; j+=2*K) {
            for (int edge = 0; edge <= N; edge++) {
                // 何も選ばない
                (dp[j][edge][0] += dp[j-2*K][edge][0] + dp[j-2*K][edge][1]) %= MOD;
                // 戻る辺を選ぶ
                (dp[j][edge+1][0] += dp[j-2*K][edge][0]) %= MOD;
                // 進む辺を選ぶ
                if (j+K < N) {
                    (dp[j][edge+1][1] += dp[j-2*K][edge][0]+dp[j-2*K][edge][1]) %= MOD;
                }
            }
        }
    }
    int now = min(2*K-1, N-1);
    while (now < N)
        now += 2*K;
    now -= 2*K;
    ll ans = 0;
    for (int edge = 0; edge <= N; edge++) {
        ll tmp = dp[now][edge][0] + dp[now][edge][1];
        tmp %= MOD;
        ans = ans + (edge%2 == 0 ? 1 : -1) * tmp * P[N-edge];
        ans = (ans+MOD)%MOD;
    }
    return ans;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    cout << solve(n, k) << endl;
    return 0;
}

Measured memory_bytes: 69760
#include<stdio.h>
int main() {
    int n, i, j, x, a[111];
    scanf("%d%d", &n, &x);
    for (i = 0; i < n; i++)
        scanf("%d", &a[i]);
    int keep;
    for (i = 0; i < n; i++) {
        for (j = 0; j < n - 1; j++) {
            if (a[j] > a[j + 1]) {
                keep = a[j];
                a[j] = a[j + 1];
                a[j + 1] = keep;
            }
        }
    }
    int ans = 0;
    for (i = 0; i < n; i++) {
        if (x >= a[i]) {
            ans++;
            x -= a[i];
        }
    }
    if (ans == n && x > 0)
        ans--;
    printf("%d\n", ans);
    return 0;
}

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

using namespace std;

void hawawa()
{
  int n;
  cin >> n;
  cout << "ABC" << setfill('0') << setw(3) << n << "\n";
}

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

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    LL w,h,x,y;
    cin >> w >> h >> x >> y;
    if (w == x * 2 && h == 2 * y) {
        printf("%.9lf 1\n", 1.0 * w * h / 2);
    } else {
        printf("%.9lf 0\n", 1.0 * w * h / 2);
    }
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<int> graph[MAXN];
vector<pii> H[MAXN];
vector<pii> W[MAXN];
queue<int> que;

int A[MAXN];
int X[MAXN];
int Y[MAXN];
char S[MAXN];
vector<int> xx;
vector<int> yy;

bool visited[MAXN];

void dfs(int here)
{
    visited[here] = true;
    xx.push_back(X[here]);
    yy.push_back(Y[here]);

    int there;

    for(int i=0;i<graph[here].size();i++)
    {
        there = graph[here][i];
        if(visited[there])continue;
        dfs(there);
    }
    return;
}

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;

    for(int i=0;i<n;i++)
    {
        cin>>X[i]>>Y[i];
        H[X[i]].push_back(pii(Y[i],i));
        W[Y[i]].push_back(pii(X[i],i));
    }

    for(int i=1;i<=100000;i++){
        sort(H[i].begin(),H[i].end());
        sort(W[i].begin(),W[i].end());
    }

    pii u,v;

    for(int i=1;i<=100000;i++){
        for(int j=1;j<(int)H[i].size();j++){
            u = H[i][j]; v = H[i][j-1];
            graph[u.s].push_back(v.s);
            graph[v.s].push_back(u.s);
        }
        for(int j=1;j<(int)W[i].size();j++){
            u = W[i][j]; v = W[i][j-1];
            graph[u.s].push_back(v.s);
            graph[v.s].push_back(u.s);
        }
    }

    ll res = 0;
    ll tmp;

    for(int i=0;i<n;i++){
        if(visited[i])continue;

        xx.clear();
        yy.clear();

        dfs(i);

        sort(xx.begin(),xx.end());
        sort(yy.begin(),yy.end());
        xx.erase(unique(xx.begin(),xx.end()),xx.end());
        yy.erase(unique(yy.begin(),yy.end()),yy.end());
        tmp = (xx.size())*1LL*(yy.size());
        res+=tmp;
    }

    res-=n;

    cout<<res<<"\n";

    return 0;
}


Measured memory_bytes: 26228
n = int(input())
s = input()
w_count = s.count('W')
e_count = s.count('E')
w_count_cum = 0
e_count_cum = 0
ans = n

for i, s_i in enumerate(s):
  if s_i == 'W':
    w_count_cum += 1
    l_w = max(0, w_count_cum-1)
  elif s_i == 'E':
    e_count_cum += 1
    l_w = max(0, w_count_cum)
 
  r_e = max(0, e_count-e_count_cum)
  
  ans = min(ans, l_w+r_e)
    
print(ans)

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

int main() {
  int N;
  cin >> N;
  double total{};
  for (int i{}; i < N; ++i) {
    double x;
    string u;
    cin >> x >> u;
    if (u == "JPY") {
      total += x;
    } else {
      total += x * 380000;
    }
  }

  cout << total << endl;
  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <string>
using namespace std;
int main() {
	string s, t;
	int a, b;
	string u;
	cin >> s >> t >> a >> b >> u;
	if (u == s) {
		--a;
	} else {
		--b;
	}
	cout << a << " " << b << endl;
	return 0;
}


Measured memory_bytes: 256
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
from heapq import heappush, heappop
import sys
def main(N, KLR):
    LL = [(-(l - r), k - 1) for k, l, r in KLR if l >= r and k < N]
    RR = [(-(r - l), N - k - 1) for k, l, r in KLR if l < r and k < N]
    ans = sum(l for k, l, r in KLR if k >= N)
    ans += sum(min(l, r) for k, l, r in KLR if k != N)
    for L in (LL, RR):
        M = len(L)
        L.sort(key=lambda x: x[1], reverse=True)
        q = []
        j = 0
        for i in range(N - 1, -1, -1):
            while j < M and L[j][1] >= i:
                heappush(q, L[j][0])
                j += 1
            if q:
                ans += -heappop(q)
    return ans

if __name__ == '__main__':
    input = sys.stdin.readline
    T = int(input())
    for i in range(T):
        N = int(input())
        KLR = [tuple(map(int, input().split())) for _ in range(N)]
        ans = main(N, KLR)
        print(ans)


Measured memory_bytes: 122736
/*  -*- coding: utf-8 -*-
 *
 * 2960.cc: 
 */

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

/* constant */

const int M = 4;
const int MAX_N = 100;
const int MAX_T = 100;
const int INF = 1 << 30;

/* typedef */

/* global variables */

int ps[M], ts[M];
int dp[M + 1][MAX_N + MAX_T];

/* subroutines */

inline void setmin(int &a, int b) { if (a > b) a = b; }

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < M; i++) scanf("%d", ps + i);
  for (int i = 0; i < M; i++) scanf("%d", ts + i);

  fill(dp[0], dp[0] + MAX_N + MAX_T, INF);
  dp[0][0] = 0;

  for (int i = 0; i < M; i++) {
    copy(dp[i], dp[i] + MAX_N + MAX_T, dp[i + 1]);
    for (int j = 0; j < n; j++)
      if (dp[i][j] < INF)
	for (int k = 0, tk = 0, pk = 0; j + tk < n;) {
	  k++, tk += ts[i], pk += ps[i];
	  setmin(dp[i + 1][j + tk], dp[i][j] + pk);
	}
  }

  int mind = INF;
  for (int j = n; j < MAX_N + MAX_T; j++) setmin(mind, dp[M][j]);
  printf("%d\n", mind);
  return 0;
}



Measured memory_bytes: 3232
N,K=map(int,input().split())
A=list(map(int,input().split()))

DP=[None]*(K+1)
for i in range(A[0]):
    DP[i]=1#Jiro wins.

for i in range(A[0],K+1):
    for a in A:
        if i-a>=0 and DP[i-a]==1:
            DP[i]=0
            break

    else:
        DP[i]=1

#print(DP)
            
if DP[K]==0:
    print("First")
else:
    print("Second")


Measured memory_bytes: 42092
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>


using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> h(n); for (int i = 0; i < n; i++) cin >> h[i];
	for (int i = 1; i < n; i++) {
		if (h[i - 1] <= h[i] - 1) h[i]--;
		if (h[i - 1] > h[i]) {
			cout << "No" << "\n";
			return 0;
		}
	}
	cout << "Yes" << "\n";
	return 0;
}

Measured memory_bytes: 3712
#include <cstdio>
#include <iostream>
#include <stack>
#include <string>
using namespace std;
//yazhan
int main()
{
	stack<char> q;
	string s;
	cin >> s;
	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'S')
		{
			q.push(s[i]);
		}
		else
		{
			if (!q.empty() && q.top() != 'T')
			{
				q.pop();
			}
			else
			{
				q.push(s[i]);
			}
		}
	}
	printf("%d", q.size());


	return 0;
}


Measured memory_bytes: 644
import sys
x,n=map(int,input().split())

p=sorted([int(x) for x in input().split()])
a=[]
ans=10**9
for i in range(-1,102):
    if i in p:
        pass
    else:
        a.append([i,abs(x-i)])
        ans=min(ans,abs(x-i))
for i in range(len(a)):
    if a[i][1]==ans:
        print(a[i][0])
        sys.exit()


Measured memory_bytes: 9204
import sys

n = input()

tmp1 = 3

while tmp1 <= n:
    if tmp1 % 3 == 0:
        string =  ' ' + str(tmp1)
        sys.stdout.write(string )
    else:
        tmp2 = tmp1
        while tmp2 > 0:
            if tmp2 % 10 == 3:
                string = ' ' + str(tmp1)
                sys.stdout.write(string)
                break
            tmp2 /= 10
    tmp1 += 1
    
print ""

Measured memory_bytes: 6380
poor :: Int -> Int -> Int -> Bool
poor a b c
 | a == b && a /= c  = True
 | a == c && a /= b  = True
 | b == c && a /= b  = True
 | otherwise         = False

main = do
    [a, b, c] <- (map read).words <$> getLine
    if poor a b c then putStrLn "Yes" else putStrLn "No"

Measured memory_bytes: 508
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
  int N;
  cin >> N;
  vector<int> num(0);
  vector<int> P(0), Q(0);
  int a, b;
  for(int i = 0; i < N; i++){
    int x;
    cin >> x;
    P.push_back(x);
  }
  for(int i = 0; i < N; i++){
    int x;
    cin >> x;
    Q.push_back(x);
  }

  for(int i = 1; i <= N; i++){
    num.push_back(i);
  }
  sort(ALL(num));
  vector<vector<int>> allarray(0, vector<int>(0));
  int counter = 1;
  do {
    if(P == num) a = counter;
    if(Q == num) b = counter;
    allarray.push_back(num);
    counter++;
  } while (next_permutation(ALL(num)));
  cout << abs(a-b) << endl;
}

Measured memory_bytes: 3256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


int main(){
  int n, m, x, y;
  cin >> n >> m;
  UnionFind U(n);
  vector<int> p(n);
  rep(i, n){
    cin >> p[i];
    --p[i];
  }
  rep(i, m){
    cin >> x >> y;
    --x; --y;
    U.unite(p[x], p[y]);
  }
  int ans=0;
  rep(i, n){
    if(U.same(i, p[i])){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    char trump;
    map<char, int> m = {{'2', 0}, {'3', 1}, {'4', 2},
                        {'5', 3}, {'6', 4}, {'7', 5},
                        {'8', 6}, {'9', 7}, {'T', 8},
                        {'J', 9}, {'Q', 10}, {'K', 11},
                        {'A', 12}};
    while(cin >> trump, trump != '#') {
        vector<vector<string>> v(4, vector<string>(13));
        for(int i=0; i<4; ++i) {
            for(int j=0; j<13; ++j) {
                cin >> v[i][j];
            }
        }
        int ew = 0, ns = 0;
        int win_player = 0;
        for(int i=0; i<13; ++i) {
            int rank = -1;
            bool is_trump = false;
            char trump2 = v[win_player][i][1];
            int win_player2 = 0;
            for(int j=0; j<4; ++j) {
                int cp = (win_player+j)%4;
                if(is_trump) {
                    if(m[v[cp][i][0]] > rank && v[cp][i][1] == trump) {
                        rank = m[v[cp][i][0]];
                        win_player2 = cp;
                    }
                } else {
                    if(v[cp][i][1] == trump) {
                        is_trump = true;
                        rank = m[v[cp][i][0]];
                        win_player2 = cp;
                    } else if(rank < m[v[cp][i][0]] && trump2 == v[cp][i][1]) {
                        rank = m[v[cp][i][0]];
                        win_player2 = cp;
                    }
                }
            }
            win_player = win_player2;
            if(win_player%2 == 0) {
                ns++;
            } else {
                ew++;
            }
        }

        cout << (ew > ns ? "EW" : "NS") << ' ' << max(ew, ns) - 6 << endl;
    }
}


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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            var ss = Console.ReadLine().Split();
            var W = new int[N];
            for (int i = 0; i < N; i++)
            {
                W[i] = int.Parse(ss[i]);
            }

            var sumS1 = 0;
            var sumS2 = W.Sum();
            var diff = new int[N];
            for (int T = 0; T < N; T++)
            {
                sumS1 += W[T];
                sumS2 -= W[T];

                diff[T] = Math.Abs(sumS1 - sumS2);
            }

            Console.WriteLine(diff.Min());
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using i64 = std::int64_t;
using u64 = std::uint64_t;
#define REP(i, n) for (int i = 0; i < (i64)(n); ++i)
#define WHOLE(x) std::begin(x), std::end(x)
#define LEN(a) int((a).size())

template <class T>
bool chmax(T &a, T b) {
  return a >= b ? false : (a = std::move(b)), true;
}
template <class T>
bool chmin(T &a, T b) {
  return a <= b ? false : (a = std::move(b)), true;
}

template <typename T>
using V = std::vector<T>;
template <typename T>
std::vector<T> make_vec(size_t n, T a) {
  return std::vector<T>(n, a);
}
template <typename... Ts>
auto make_vec(size_t n, Ts... ts) {
  return std::vector<decltype(make_vec(ts...))>(n, make_vec(ts...));
}
template <typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &a) {
  for (auto &x : a) is >> x;
  return is;
}
template <typename Container>
std::ostream &pprint(const Container &a, std::string_view sep = " ",
                     std::string_view ends = "\n", std::ostream *os = nullptr) {
  if (os == nullptr) os = &std::cout;
  auto b = std::begin(a), e = std::end(a);
  for (auto it = std::begin(a); it != e; ++it) {
    if (it != b) *os << sep;
    *os << *it;
  }
  return *os << ends;
}
template <typename T, typename = void>
struct is_iterable : std::false_type {};
template <typename T>
struct is_iterable<T, std::void_t<decltype(std::begin(std::declval<T>())),
                                  decltype(std::end(std::declval<T>()))>>
    : std::true_type {};

template <typename T,
          typename = std::enable_if_t<is_iterable<T>::value &&
                                      !std::is_same<T, std::string>::value>>
std::ostream &operator<<(std::ostream &os, const T &a) {
  return pprint(a, ", ", "", &(os << "{")) << "}";
}
template <typename T, typename U>
std::ostream &operator<<(std::ostream &os, const std::pair<T, U> &a) {
  return os << "(" << a.first << ", " << a.second << ")";
}

#ifdef ENABLE_DEBUG
template <typename T>
void pdebug(const T &value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void pdebug(const T &value, const Ts &... args) {
  pdebug(value);
  std::cerr << ", ";
  pdebug(args...);
}
#define DEBUG(...)                                   \
  do {                                               \
    std::cerr << " \033[33m (L" << __LINE__ << ") "; \
    std::cerr << #__VA_ARGS__ << ":\033[0m ";        \
    pdebug(__VA_ARGS__);                             \
    std::cerr << std::endl;                          \
  } while (0)
#else
#define pdebug(...)
#define DEBUG(...)
#endif
using namespace std;

const i64 INF = 1e15;

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

  int N;
  cin >> N;
  i64 smax = -INF, smin = INF, dmax = -INF, dmin = INF;
  REP(i, N) {
    i64 x, y;
    cin >> x >> y;
    chmax(smax, x + y);
    chmin(smin, x + y);
    chmax(dmax, x - y);
    chmin(dmin, x - y);
  }
  cout << max(smax - smin, dmax - dmin) << endl;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define int long long
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
typedef long long ll;
typedef long double ld;
long long dx[] = {1,0,-1,0};
long long dy[] = {0,1,0,-1};
long long dx8[] = {1,1,0,-1,-1,-1,0,1};
long long dy8[] = {0,1,1,1,0,-1,-1,-1};
long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};

signed main(){
    ll H,W,N;
    cin >> H >> W >> N;
    ll ans = H;
    vector<pair<ll,ll>> v(N);
    FOR(i,0,N)cin >> v[i].first >> v[i].second;
    sort(ALL(v));
    ll MIN[H+1];
    FOR(i,0,H+1)MIN[i] = LINF;
    MIN[0] = 0;
    FOR(i,0,N)MIN[v[i].first] = min(MIN[v[i].first],v[i].second-1);
    FOR(i,1,H+1)MIN[i] = min(MIN[i],MIN[i-1]+1);
    FOR(i,0,N){
        ll X = v[i].first-1,Y = v[i].second;
        if(MIN[X] >= Y){
            ans = min(ans,X);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
#include <stdio.h>
int main(void){
	int n,i,a,b,c;
	scanf("%d",&n);
	for(i=1,b=c=0;i<=n;i++){
		scanf("%d",&a);
		if(a==1)b++;
		if(a==0||i==n){
			if(c<b)c=b;
			b=0;
		}
	}
	printf("%d\n",c+1);
	return 0;
}



Measured memory_bytes: 2052
#include<cstdio>
#include<vector>
#include<algorithm>
const int N=2e5+3,M=1e9+7;
int n,x,y,a,b,ans,sum,t[N],invf[N],c[N],d,f[N];
std::vector<int>h[N];
bool Cmp(const int&i,const int&j){
	if(!h[i].size())return 0;
	if(!h[j].size())return 1;
	return h[i][0]<h[j][0];
}
inline int Pow(int a,int m){int s=1;for(;m;m>>=1)m&1?s=1ll*s*a%M:0,a=1ll*a*a%M;return s;}
void InC(){
	f[0]=1;
	for(int i=1;i<=n;i++)f[i]=1ll*f[i-1]*i%M;
	invf[n]=Pow(f[n],M-2);
	for(int i=n;i;i--)invf[i-1]=1ll*invf[i]*i%M;
}
inline int C(int n,int m){return 1ll*f[n]*invf[m]%M*invf[n-m]%M;}
int main(){
	scanf("%d%d%d",&n,&x,&y);
	InC();
	for(int i=1;i<=n;i++)
	  scanf("%d%d",&a,&b),h[a].push_back(b),
	  t[i]=i;
	for(int i=1;i<=n;i++){
	  std::sort(h[i].begin(),h[i].end());
	  for(int j=1;j<h[i].size();j++)
		if(h[i][0]+h[i][j]<=x)c[i]=j;
	}
	std::sort(t+1,t+1+n,Cmp);
	if(!h[t[2]].size())return 0*puts("1");
	for(int i=1,k;h[t[i]].size();i++){
	  k=i==1?2:1;
	  for(int j=0;j<h[t[i]].size();j++)
		if(h[t[k]][0]+h[t[i]][j]<=y&&j>c[t[i]])c[t[i]]=j;
	  if(h[t[i]][0]+h[t[k]][0]<=y)d=i;
	}
	ans=1;sum=0;
	for(int i=1;i<=d;i++)sum+=c[t[i]]+1;
	for(int i=1;i<=d;i++)
	  ans=1ll*ans*C(sum,c[t[i]]+1)%M,
	  sum-=c[t[i]]+1;
	printf("%d",ans);
	return 0; 
}

Measured memory_bytes: 12416
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MX 100005

const ll INF = 1e12;

int A[MX];
ll dp[MX];
int n, k;

ll recur(int pos){
    if (pos == 1) return dp[pos] = 0;
    if (pos == 2) return dp[pos] = abs(A[2] - A[1]);
    if (dp[pos] != -1) return dp[pos];

    ll mn = INF;
    for (int i = 1; i <= k; i++){
        if (pos - i >= 1){
            mn = min(mn, recur(pos - i) + abs(A[pos] - A[pos - i]));
        }
        else break;
    }
    return dp[pos] = mn;
}
int main()
{
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; i++){
        scanf("%d", &A[i]);
        dp[i] = -1;
    }

    ll ans = recur(n);
    printf("%lld\n", ans);
    return 0;
}



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

using namespace std;


#define MAXN 301
typedef long long ll;
const ll inf = 300*1e9;
ll a[MAXN][MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> a[i][j];
    }
  }
  int can = 1;
  ll ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      if (i==j) continue;
      int mn = 1;
      for (int k = 1; k <= n; ++k) {
        can &= a[i][j] <= a[i][k] + a[k][j];
        if (i==k || j==k) continue;
        mn &= a[i][j]<a[i][k] + a[k][j];
      }
      if (mn) ans += a[i][j];
    }
  }
  if (!can) {
    cout << -1 << endl;
    return 0;
  }
  cout << ans/2 << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include<string>
#include<algorithm>
#include<stdio.h>

using namespace std;

int main () {
    int n;
    scanf("%d",&n);
    if(n>=64){
        cout<<64;
    }else if(n >= 32){
        cout<<32;
    }else if(n >= 16){
        cout<<16;
    }else if(n >= 8){
        cout<<8;
    }else if(n >= 4){
        cout<<4;
    }else if(n >= 2){
        cout<<2;
    }else{
        cout<<1;
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <cstdio>
#include <iomanip>

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;(i)>=0;(i)--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())

typedef long long ll;

int main(){
    
    
    while(true){
    int n;
    cin>>n;
        
        if(n==0)break;
    
    int t=1000-n;
    int ans=0;
    
    ans+=t/500;
    t=t%500;
    
    ans+=t/100;
    t=t%100;
    
    ans+=t/50;
    t=t%50;
    
    ans+=t/10;
    t=t%10;
    
    ans+=t/5;
    t=t%5;
    
    ans+=t;
    
    cout<<ans<<endl;
    }
    
    return 0;
    
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    long double sum = 0;
    for (int i = 0; i < n; i++)
    {
        long double x;
        cin >> x;
        sum += (long double) 1.0 / x;
    }
    cout << fixed << setprecision(6) << (long double) 1.0 / sum << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)
N = int(input())
initials = [0]*5
lis = ['M', 'A', 'R', 'C', 'H']
SET = set(lis)
for _ in range(N):
    s = input()[0]
    if not s in SET:
        continue
    idx = lis.index(s)
    initials[idx] += 1

ans = 0
from itertools import permutations
for a, b, c in permutations(initials, 3):
    ans += a*b*c

print(ans//6)

Measured memory_bytes: 40556
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;
using ll = long long;

int main() {

	std::cin.tie(nullptr); std::ios::sync_with_stdio(false);

	int n, m; cin >> n >> m;

	cout << (n - 1) * (m - 1);

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,L;
    cin>>N>>L;
    vector<string> S(N);
    for(int i=0;i<N;i++){
        cin>>S[i];
    }
    sort(S.begin(),S.end());
    for(int i=0;i<N;i++){
        cout<<S[i];
    }
    puts("");
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define INF_LL 1e18
#define INF 1e9

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()

#define fst first
#define snd second

using namespace std;

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

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

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

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

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

pair<ll, pair<ll, ll> > dp[2][1010];
int main(void){
	int N, M, K;
	ll A[20020];
	cin >> N >> M >> K;
	pair<ll, pair<ll, ll> > init = {INF_LL, {INF_LL, 0}};
	REP(i, 2){
		REP(j, 1010){
			dp[i][j] = init;
		}
	}
	REP(i, N){
		cin >> A[i];
	}
	dp[1][1] = {K, {A[0], A[0]}};
	FOR(i, 1, N){
		REP(j, 1010){
			dp[(i+1)%2][j] = init;
		}
		REP(j, min(i+1, M+1)){
			if(0 < j && j < M){
				ll cost = dp[i%2][j].fst-j*(dp[i%2][j].snd.snd-dp[i%2][j].snd.fst)+(j+1)*(max(dp[i%2][j].snd.snd, A[i])-min(dp[i%2][j].snd.fst, A[i]));
				if(dp[(i+1)%2][j+1].fst > cost){
					dp[(i+1)%2][j+1] = {cost, {min(dp[i%2][j].snd.fst, A[i]), max(dp[i%2][j].snd.snd, A[i])}};
				}
			}
			ll cost = dp[i%2][j].fst + K;
			if(dp[(i+1)%2][1].fst > cost){
				dp[(i+1)%2][1] = {cost, {A[i], A[i]}};
			}
		}
	}
	ll res = INF_LL;
	REP(i, M+1){
		res = min(dp[N%2][i].fst, res);
	}
	cout << res << endl;
}

Measured memory_bytes: 3240
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define ARRAY_LEN(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
 
int main() {
  int N, K; cin >> N >> K;
  ll x[N], y[N];
  vector<vector<ll>> point(N, vector<ll>(2));
  for (int i=0; i<N; i++) { cin>>x[i]>>y[i]; point[i][0]=x[i]; point[i][1]=y[i]; }
  sort(x, x+N); sort(y, y+N);

  ll result = LLINF;
  for (int x1=0; x1<N; x1++) {
    for (int x2=0; x2<=x1; x2++) {
      for (int y1=0; y1<N; y1++) {
        for (int y2=0; y2<=y1; y2++) {
          int k_num = 0;
          for (auto &p: point) {
            if ( (p[0]<=x[x1] && p[0]>=x[x2]) && (p[1]<=y[y1] && p[1]>=y[y2]) ) k_num++;
          }
          if (k_num >= K) result = min(result, (x[x1]-x[x2]) * (y[y1]-y[y2]));
          // if (k_num >= K) cout << x[x1] << x[x2] << y[y1] << y[y2] << k_num << endl;
        }
      }
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
const ll INF=1e18+7;
const ll MOD=1e9+7;


ll formula_to_num(string s){
	ll ans = 0;
	ll w = 0;
	FOR(i,0,s.size()){
		if(s[i]=='+'){
			ans += w;
			w = 0;
		}else{
			w *= 10;
			w += s[i] - '0';
		}
	}
	return ans+w;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	ll ans = 0;
	int ss = s.size()-1;
	FOR(i,0,1<<ss){
		string k;
		k+=s[0];
		FOR(j,0,ss){
			if(i&1<<j)k+='+';
			k+=s[j+1];
		}
		ans += formula_to_num(k);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
#include<cmath>
#include<vector>
#include<stack>
#include<map>
#include<set>
#define Run(i,l,r) for(int i=l;i<=r;i++)
#define Don(i,l,r) for(int i=l;i>=r;i--)
#define ll long long
#define ld long double
#define inf 0x3f3f3f3f
#define mk make_pair
#define fir first
#define sec second
#define il inline
#define rg register
#define pb push_back
using namespace std;
const int N=110;
ll n,A,B,C,cnt1,cnt2,cnt3,vis[N];
int main(){
	cin>>n>>A>>B;
	for(int i=1,x;i<=n;++i){
		cin>>x;
	//	if(vis[x])continue;
	//	vis[x]=1;
		if(x<=A)cnt1++;
		else if(x<=B)cnt2++;
		else cnt3++;
	}
	cout<<min(cnt1,min(cnt2,cnt3))<<endl;
	return 0;
}//by tkys_Austin;


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <sstream> // std::ostringstream
#include <string>
#include <tuple>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
  uint N;
  cin >> N;

    cout << (N-2)*180 << endl;
 
  return 0;
}

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

public class Main
{
	public static void main(String args[])throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String []s = br.readLine().split(" ");
		
		int A = Integer.parseInt(s[0]);
		int B = Integer.parseInt(s[1]);

		int c=1,d=B-A;
		
		while(d>0)
		{
			d-=(A-1);
			++c;
		}
		
		if(B==1)
			c = 0;
			
		System.out.println(c);

	}
}

Measured memory_bytes: 21204
//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#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;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#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 INF 1000000000000
#define MOD 10000007
#define MA 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second


ll sieve_check[MA+1];//i番目が整数iに対応(1~100000)

//エラトステネスの篩を実装する
void es(){
    FOR(i,2,MA)sieve_check[i]=1;
    //cout << sieve_check[2] << endl;
    //sieve_check[0]=0;sieve_check[1]=0;
    //1のところが素数、ここでは0が素数でない
    for(ll i=2;i<=1000;i++){
        if(sieve_check[i]==1){
            for(ll j=2;j<=ll(MA/i);j++){
                sieve_check[j*i]=0;
            }
        }
    }
}

signed main(){
    es();
    //REP(i,10) cout << sieve_check[i] << endl;
    //REP(i,MA)sieve_check[i+1]+=sieve_check[i];
    vector<ll> pre(MA+1);FOR(i,1,MA)pre[i]=(i%2==1&&sieve_check[i]&&sieve_check[(i+1)/2]);
    REP(i,MA)pre[i+1]+=pre[i];
    ll q;cin >> q;
    vector< pair<ll,ll> > ans(q);REP(i,q) cin >> ans[i].F >> ans[i].S;
    REP(i,q)cout << pre[ans[i].S]-pre[ans[i].F-1] << endl;
    //cout << sieve_check[0] << endl;
}

Measured memory_bytes: 3712
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

bool check(int num) {
    int div = 0;
    for(int d = 1; d * d <= num; d++) {
        if(num % d == 0) {
            if(num == d * d)
                div++;
            else
                div += 2;
        }
    }
    if(div == 8)
        return true;
    return false;
}

int main() {
    int N;
    cin >> N;
    int res = 0;
    for(int i = 1; i <= N; i++) {
        if(i % 2 == 1 && check(i))
            res++;
    }
    cout << res << endl;
    return 0;
}

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

int main() {
    long k;
    int n, q;
    cin>>n >>k >>q;
    vector<int> a(q);
    vector<int> score(n,0);
    rep(i,q){
        cin>>a[i];
        score[a[i]-1]++;
    }
    rep(i,n){
        if(q-score[i]<k){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
}

Measured memory_bytes: 4028
#include <stdio.h>
#include <string.h>

int main()
{
	int i;
	int n;
	int c=0;
	char s[55]={};
	const char abc[3]="ABC"; 
	
	scanf("%d",&n);
	scanf("%s",s);
	
	for(i=0;s[i]!='\0';i++)
	{
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')	c++;
	}
	printf("%d \n",c);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <iomanip>

using namespace std;

bool check(complex<double> l, complex<double> r){
    if(l.real() == r.real()){
        return l.imag() < r.imag();
    }
    return l.real() < r.real();
}

int main(){
    int n;
    cin >> n;
    vector<complex<double>> a(n);
    for(auto&& i : a){
        int x, y;
        cin >> x >> y;
        i.real(x);
        i.imag(y);
    }
    sort(begin(a), end(a), check);
    double ans = 0;
    do{
        for(int i = 1; i < n; i++){
            ans += abs(a[i - 1] - a[i]);
        }
    }while(next_permutation(begin(a), end(a), check));
    for(int i = 1; i <= n; i++){
        ans /= i;
    }
    cout << fixed << setprecision(10) << ans << "\n";
}

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

public class hello
{
    public static void Main()
    {
        var plist = GeneratePrime(50000);
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var count = 0;
            for (int i = 0; plist[i] <= n / 2; i++)
            {
                var w = n - plist[i];
                var s = plist.BinarySearch(w);
                if (s >= 0) count++;
            }
            Console.WriteLine(count);
        }
    }
    public static List<int> GeneratePrime(int m)
    {
        var plist = new List<int>();
        int prime;
        var sqrtMax = Math.Sqrt(m);
        var searchList = Enumerable.Range(2, m - 1).ToList();
        do
        {
            prime = searchList.First();
            plist.Add(prime);
            searchList.RemoveAll(n => n % prime == 0);
        }
        while (prime < sqrtMax);
        plist.AddRange(searchList);
        return plist;
    }
}






Measured memory_bytes: 18452
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <type_traits>
#include <map>

using namespace std;


int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  vector<int> a1(n);
  vector<int> a2(n);
  vector<int> sa1(n);
  vector<int> sa2(n);

  for(int i = 0; i < n; i++){
    cin >> a1[i];
  }
  for(int i = 0; i < n; i++){
    cin >> a2[i];
  }
  sa1 = a1;
  sa2 = a2;

  for(int i = 0; i < n-1; i++){
    sa1[i+1] = sa1[i] + sa1[i+1];
  }
  for(int i = n-2; i >= 0; i--){
    sa2[i] = sa2[i] + sa2[i+1];
  }

  int ans = 0;
  for(int i = 0; i < n; i++){
    ans = max(ans, sa1[i] + sa2[i]);
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;
ll MOD = 1000000007;

int main()
{   
    int m, d;
    cin >> m >> d;
    int c = 0;

    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= d; j++) {
            int x, y;
            x = j / 10;
            y = j - (j/10)*10;
            if (!(x >= 2 && y >= 2)) continue;
            if (i == x*y) c++;
        }
    }
    cout << c << endl;
    
    return 0;
}


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

int	main()
{
	string	s;
	cin >> s;
	int		size = s.size();
	int		odd_size = (size + 1) / 2;
	string	odd_s(odd_size, '0');
	for (int i = 0; i < odd_size; ++i) {
		odd_s.at(i) = s.at(2 * i);
	}
	cout << odd_s << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<map>
using namespace std;

int main(){
    //input
    long long N;
    cin >> N;

    //calc
    long long i,j, num;
    long long sum;
    long long val;
    long long r;
    map<long long, long long> mm;
    vector<long long> S[447];

    for(i=1; i<=N; i++){
        mm.insert({i,-1});
    }

    sum = 1;
    mm[1]=1;
    for(i=2; sum+i<=N; i++){
        mm[sum+i]=i;
        sum += i;
    }

    r = mm[N];
    if(r>1){
        cout << "Yes" << endl;
        cout << r+1 << endl;
        for(i=1; i<=r; i++){
            S[0].push_back(i);
        }
        for(i=1; i<=r; i++){
            S[i].push_back(i);
        }
        val = r+1;
        for(i=1; i<=r-1; i++){
            for(j=i+1; j<=r; j++){
                S[i].push_back(val);
                S[j].push_back(val);
                val++;
            }
        }
        
        //answer
        for(i=0; i<=r; i++){
            cout << S[i].size() << " ";
            for(j=0; j<S[i].size()-1; j++){
                cout << S[i][j] << " ";
            }
            cout << S[i][j] << endl;
        }

    }else if(r == 1){
        //answer
        cout << "Yes" << endl;
        cout << 2 << endl;
        cout << 1 << " " << 1 << endl;
        cout << 1 << " " << 1 << endl;
    }
    else{
        //answer
        cout << "No" << endl;
    }
    system("pause");
    return 0;
}

Measured memory_bytes: 9720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a-1; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define rALL(x) x.rbegin(), x.rend()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    ll n;   cin >> n;
    ll cnt=0;
    vector<ll> v;
    if(n){
        while(0<abs(n)){
            v.push_back((n%2+2)%2);
            n = (n-v.back())/(-2);
        }
        repd(i, v.size()) cout << v[i];
        cout << endl;
    }else cout << 0 << endl;
    
}


Measured memory_bytes: 3600
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.LongStream;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int K = sc.nextInt();
    int X = sc.nextInt();

    long m = Math.max(-1000000, X-K+1);
    long n = Math.min(1000000, X+K-1);

    System.out.println(LongStream.rangeClosed(m, n).mapToObj(String::valueOf).collect(Collectors.joining(" ")));
  }
}

Measured memory_bytes: 29264
#include <iostream>
#include <vector>
#include <set>
using namespace std;

typedef vector<int> vi;

const int MAX_X = 20;
const int MAX_D = 10;
int N, D;
vector<vi> X;
set<int> S;

void init_data(void) {
	cin >> N >> D;
	X.resize(N, vi(D));
	for (int j = 0; j < N; ++j) {
		for (int i = 0; i < D; ++i)
			cin >> X[j][i];
	}
}

void calcu_square(void) {
	int max_sq = (2 * MAX_X) * (2 * MAX_X) * MAX_D;
	for (int i = 1; i * i <= max_sq; ++i)
		S.insert(i * i);
}

int solve(void) {
	int cnt = 0;
	for (int a = 0; a < N - 1; ++a) {
		for (int b = a + 1; b < N; ++b) {
			int d = 0;
			for (int c = 0; c < D; ++c) {
				int t = X[a][c] - X[b][c];
				d += t * t;
			}
			if (S.count(d) == 1)
				++cnt;
		}
	}
	return cnt;
}

int main(void) {
	init_data();
	calcu_square();
	int ans = solve();

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<climits>
using namespace std;

int main() {
  int N;
  int cnt;
  int num;
  int ans=INT_MAX;

  cin >> N;

  //長さNの配列を作成.
  vector<long> A(N), B(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }

  for(int i = 0; i < N; i++){
    cnt = 0;
    num = A[i];
    while(num%2 == 0){
      num=num/2;
      cnt++;
    }
    ans = min(ans, cnt);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256