akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] ten = new int[n][3];
		int[][] root = new int[m][2];
		for (int i = 0; i < ten.length; i++) {
			ten[i][0] = sc.nextInt();
		}
		for (int i = 0; i < m; i++) {
			root[i][0] = sc.nextInt();
			root[i][1] = sc.nextInt();
		}
		for (int[] i : root) {
			int[] j = ten[i[0] - 1];
			int[] k = ten[i[1] - 1];
			if (j[0] == k[0]) {
				j[1] = 0;
				k[1] = 0;
			} else if (j[0] < k[0]) {
				if (k[2] == 0) {
					k[1] = 1;
				}
				j[1] = 0;
			} else {
				if (j[2] == 0) {
					j[1] = 1;
				}
				k[1] = 0;
			}
			j[2] = 1;
			k[2] = 1;
		}

		int count = 0;
		for (int[] i : ten) {
			count += i[1];
		}
		count += (n - Arrays.stream(ten).filter(s -> s[2] == 1).count());
		System.out.println(count);
	}

	static class FastScanner {
		private BufferedReader reader;
		private StringTokenizer tokenizer;

		public FastScanner(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
			tokenizer = null;
		}

		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public String nextLine() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					return reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}

			return tokenizer.nextToken("\n");
		}

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

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

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
	}
}

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

int main(void){
  char S[100000];
  int ans = 0;
  scanf("%s",S);

  for(int i = 0;i < strlen(S);i++){
    if(S[i] == 'p'){
      ans++;
    }
  }

  printf("%d\n",(int)strlen(S)/2-ans);

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    
using namespace std;
typedef long long ll;
    
int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int left = A + B;
    int right = C + D;
    if (left > right) {
        cout << "Left";
    } else if (left == right) {
        cout << "Balanced";
    } else {
        cout << "Right";
    }

    return 0;
}


Measured memory_bytes: 256
use std::io::prelude::*;
use std::io::*;
use std::str::FromStr;

fn main() {
    let stdin = stdin();
    let mut stdinLock = stdin.lock();
    let mut string1 = String::new();
    stdinLock.read_to_string(&mut string1).unwrap();
    let mut iterator1 = string1.split_whitespace();
    let n: u32 = u32::from_str(iterator1.next().unwrap()).unwrap();
    let m: u32 = u32::from_str(iterator1.next().unwrap()).unwrap();
    println!("{}", (100 * n + 1800 * m) * 2u32.pow(m));
}


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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
			var AArray = retreiveLongArray();

			var minusCount = 0;
			var haveZero = false;

			for (int i = 0; i < N; i++) {
				if (AArray[i]==0) {
					haveZero = true;
				}
				if (AArray[i] <0) {
					minusCount++;
				}
			}

			//0がある場合
			if (haveZero) {
				var ans = AArray.Select(x =>Math.Abs(x)).Sum();
				Console.WriteLine(ans);
				return;
			}

			if (minusCount%2==0) {//マイナスの数偶数の場合、すべて正にできる
				var ans = AArray.Select(x => Math.Abs(x)).Sum();
				Console.WriteLine(ans);
				return;
			}

			var absArray = AArray.Select(x => Math.Abs(x));
			var min = absArray.Min();

			var ans2 = absArray.Sum() - min*2;
			Console.WriteLine(ans2);
		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}

Measured memory_bytes: 31452
def resolve():
    INF = 1 << 60
    H, W = map(int, input().split())
    G = [input() for _ in range(H)]

    # 長方形区域を選んで、その中の通路と壁を反転する操作ができる
    # dp[ y ][ x ] := マス (y, x) に到達するまでに魔法を唱える回数の最小値

    dp = [[INF] * W for _ in range(H)]
    if G[0][0] == "#":
        dp[0][0] = 1
    else:
        dp[0][0] = 0

    # 1, (nx, ny) が通路のとき, 操作なし
    # 2, (nx, ny) か壁で、(x, y) が通路のとき, 操作する
    # 3, (nx, ny) が壁で、(x, y) も壁のとき, 2の操作が継続中

    drc = [(0, 1), (1, 0)]
    for y in range(H):
        for x in range(W):
            for dy, dx in drc:
                ny = y + dy
                nx = x + dx
                if ny >= H or nx >= W:
                    continue
                cost = 0
                if G[ny][nx] == "#" and G[y][x] == ".":
                    cost = 1
                dp[ny][nx] = min(dp[ny][nx], dp[y][x] + cost)

    print(dp[H - 1][W - 1])


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 9112
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 998244353;
const long long int INF = 1e18;

long long int N,X,Y,res[2005]={};

int main()
{
    cin>>N>>X>>Y;
    for(long long int i =1; i <= N; i++){
        for(long long int j = i+1; j <= N; j++){
            res[min(j-i,abs(i-X)+abs(j-Y)+1)]++;
        }
    }
    
    for(long long int i = 1; i < N; i++){
        cout<<res[i]<<endl;
    }
}


Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
A.append(0)
ary = []
for i, a in enumerate(A):
    if i == 0:
        ary.append(abs(0-a))
    else:
        ary.append(ary[-1]+abs(A[i-1]-a))
for i in range(N):
    ans = 0
    if i != 0:
        ans = ary[i-1]
        ans += abs(A[i-1]-A[i+1])
    else:
        ans += abs(A[1])
    ans += ary[-1]-ary[i+1]
    print(ans)


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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


int main()
{
    int N;
    cin >> N;

    vector<vector<int> >x(N,vector<int>(2));

    rep(i,N) cin >> x[i][0] >> x[i][1];

    vector<int> ary(N,1);
    rep(i,N) ary[i] += i;

    double total = 0;

    do
    {
        rep(i,N-1)
        {
            int key = ary[i]-1;
            int next_key = ary[i+1]-1;

            total += sqrt(pow(x[key][0]-x[next_key][0],2) + pow(x[key][1]-x[next_key][1],2));
        }
    }
    while(next_permutation(all(ary)));

    double num = 1.0;
    rep(i,N) num *= (i+1);
    
    put_double(total/num);
}


Measured memory_bytes: 256
/*https://atcoder.jp/contests/abc114/tasks/abc114_b*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	string s;
	int min_dif = 1e5 + 1;
	cin >> s;
	for (int i = 0; i < s.length() - 2; i++)
	{
		char a, b, c;
		a = s[i], b = s[i + 1], c = s[i + 2];
		string n;
		n += s[i];
		n += s[i + 1];
		n += s[i + 2];

		// cout << a << " " << b << " " << c << endl;
		// int x = stoi(n) + atoi(b) + atoi(c);
		// cout << n << endl;

		int x = stoi(n);
		// cout << x <<< " ->" abs(x - 753)
		min_dif = min(min_dif, abs(x - 753));
	}
	cout << min_dif;
}

Measured memory_bytes: 3628
# ABC138 D 
import sys
sys.setrecursionlimit(3*10**5)

res=0
INF=10**9
from collections import deque

f=lambda:map(int,input().split())
N,Q=f()
G=[[] for _ in [0]*(N+1)]
for i in range(N-1):
    a,b=f()
    G[a].append(b)
    G[b].append(a)

def bfs(a):
    q=deque()
    q.append(a)
    d=[INF]*(N+1)
    d[a]=0
    res=0
    while q:
        r=q.popleft()
        for nr in G[r]:
            if d[nr]==INF:
                q.append(nr)
                d[nr]=d[r]+1
                res+=1
    return d

d=bfs(1)

late=[0]*(N+1)
for _ in [0]*Q:
    p,x=f()
    late[p]+=x
    


S=[0]*(N+1)
q=deque()
q.append((1,0))
while q:
    node,par=q.popleft()
    S[node]+=late[node]
    for p in G[node]:
        if p==par:
            continue
        late[p]+=late[node]
        q.append((p,node))
        
print(*S[1:],sep='\n')

Measured memory_bytes: 140096
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null) {

			Stack<String> stack = new Stack<String>();
			double a, b;

			for (String s : line.split(" ")) {
				if (isNumeric(s)) {
					stack.push(s);
				} else {
					b = Double.parseDouble(stack.pop());
					a = Double.parseDouble(stack.pop());
					switch (s.toCharArray()[0]) {
					case '+':
						stack.push(String.valueOf(a + b));
						break;
					case '-':
						stack.push(String.valueOf(a - b));
						break;
					case '*':
						stack.push(String.valueOf(a * b));
						break;
					case '/':
						stack.push(String.valueOf(a / b));
						break;
					}
				}
			}
			System.out.println(stack.pop());
		}
	}

	static boolean isNumeric(String s) {
		boolean result = false;
		try {
			Double.parseDouble(s);
			result = true;
		} catch (NumberFormatException e) {
		}
		return result;
	}
}

Measured memory_bytes: 15188
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

S = read().decode().rstrip()

f_half = S[:len(S) // 2]
s_half = S[(len(S) + 2) // 2:]

if f_half == s_half:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int64_t N; cin>>N;

    int64_t ans=INT64_MAX;
    for(int64_t a=1;a*a<=N;a++){
        if(N%a==0){
            int64_t b=N/a;
            ans=min(ans,a+b-2);
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
char judge(int math, int eng, int jap);
 
int main()
{
    int n, pm, pe, pj;
    while (true) {
        std::cin >> n;
        if (n == 0) {
            break;
        }
 
        for (int i = 0; i < n; i++) {
            std::cin >> pm >> pe >> pj;
            std::cout << judge(pm, pe, pj) << std::endl;
        }
    }
     
    return 0;
}
 
char judge(int math, int eng, int jap)
{
    float two_ave = (math + eng) / 2;
    float all_ave = (math + eng + jap) / 3;
 
    if (math == 100 || eng == 100 || jap == 100) {
        return 'A';
    } else if (two_ave >= 90) {
        return 'A';
    } else if (all_ave >= 80) {
        return 'A';
    } else if (all_ave >= 70) {
        return 'B';
    } else if (all_ave >= 50 && (math >= 80 || eng >= 80)) {
        return 'B';
    } else {
        return 'C';
    }
 
}

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

int main(void) {
	int K, S;
	cin >> K >> S;

	unsigned int ans = 0;
	for (int X = 0; X <= K; X++) {
		for (int Y = 0; Y <= K; Y++) {
			int Z = S - X - Y;
			if ((0<=Z) && (Z<=K)) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int a, b, c;
  cin >> a >> b >> c;
  int m = max(a, max(b, c));
  int d[] = {m-a, m-b, m-c};
  int s = 0;
  REP(i, 3) s += d[i]%2;
  int ans = 0;
  if(s%2){
    REP(i, 3) d[i]++;
    s = (s == 1) ? 2 : 0;
  }
  REP(i, 3) ans += d[i]/2;
  if(s == 2) ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
 
int count=0;
int stack[100];
 
void push(int x){
  stack[++count]=x;
}

int pop(){
  count--;
  return stack[count+1];
}
 
int main(){
  int x;
  char s[100];
  int a,b;
  
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      a=pop();
      b=pop();
      push(a+b);
    } else if ( s[0] == '-' ){
      a=pop();
      b=pop();
      push(b-a);
    } else if ( s[0] == '*' ){
      a=pop();
      b=pop();
      push(a*b);
    } else {
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n",stack[count]);
  return 0;
}
 

 

Measured memory_bytes: 1852
import java.util.*;

public class Main {
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		ArrayList<Integer>[] graph = new ArrayList[n + 1];
		for (int i = 1; i <= n; i++) {
			graph[i] = new ArrayList<Integer>();
		}
		for (int i = 0; i < m; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			graph[a].add(b);
			graph[b].add(a);
		}
		HashSet<Integer> set = new HashSet<>();
		ArrayList<Integer> list = new ArrayList<>();
		int idx = 1;
		boolean flag = false;
		list.add(idx);
		set.add(idx);
		while (!flag) {
			flag = true;
			for (int x : graph[idx]) {
				if (!set.contains(x)) {
					flag = false;
					idx = x;
					list.add(idx);
					set.add(idx);
					break;
				}
			}
		}
		flag = false;
		idx = 1;
		while (!flag) {
			flag = true;
			for (int x : graph[idx]) {
				if (!set.contains(x)) {
					flag = false;
					idx = x;
					list.add(0, idx);
					set.add(idx);
					break;
				}
			}
		}
		StringBuilder sb = new StringBuilder();
		sb.append(list.size()).append("\n");
		for (int i = 0; i < list.size(); i++) {
			if (i != 0) {
				sb.append(" ");
			}
			sb.append(list.get(i));
		}
		System.out.println(sb);
	}
}


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

int main () {
  long N;
  cin >> N;
  string goods[N];

  for (int i = 0; i < N; i++) {
    cin >> goods[i];
  }

  map<string, long> count;
 long result = 0;

  for (int i = 0; i < N; i++) {
   if (count[goods[i]] == 1) {
      result = result;
     } else {
      count[goods[i]] = 1;
      result += 1;
    } 
  }


  cout << result << endl;
  
    return 0;

  }

Measured memory_bytes: 23496
#include "bits/stdc++.h"
using namespace std;
vector <int> g[100010], t[100010];
int a[100010], b[100010];
int par[100010];
long long cost[100010];
long long sub[100010];

int main(int argc, char const *argv[])
{
	int n, m;
	cin >> n >> m;
	vector <int> ord;
	for(int i = 1; i <= n; i++) {
		cin >> a[i] >> b[i];
		par[i] = i;
		ord.push_back(i);
	}
	for(int i = 1; i <= m; i++) {
		int x, y; cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	sort(ord.begin(), ord.end(), [&] (int i, int j) { return a[i] - b[i] < a[j] - b[j]; });
	
	vector <int> done (n + 1, false);
	function <int(int)>  root = [&] (int x) {
		if(par[x] == x) return x;
		else return par[x] = root(par[x]);
	};
	for(int i : ord) {
		for(auto j : g[i]) {
			if(done[j] && root(j) != i) {
				t[i].push_back(root(j));
				par[root(j)] = i;
			}
		}
		done[i] = true;
	}
	function <void(int)> dfs = [&] (int x) {
		sub[x] = b[x];
		for(auto i : t[x]) {
			dfs(i);
			sub[x] += sub[i];
		}
		long long var = max(0, a[x] - b[x]);
		cost[x] = sub[x] + var;
		for(auto i : t[x]) {			
			cost[x] = min(cost[x], sub[x] - sub[i] + max(var, cost[i]));
		}
	};
	dfs(root(1));
	cout << cost[root(1)] << endl;
	return 0;
}

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

#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { cout << p.first << ' ' << p.second; return os; }

void solve() {
  int N, Z, W; cin >> N >> Z >> W;
  vi32 a(N); cin >> a;

  function<int(int)> dp0, dp1;
  vi32 memo0(N, -1), memo1(N, -1);

  dp0 = [&](int l) {
    if (memo0[l] != -1) return memo0[l];
    int x = l == 0 ? W : a[l - 1];
    int ret = abs(x - a[N - 1]);
    repi(i, l, N - 1) {
      amax(ret, dp1(i + 1));
    }
    return memo0[l] = ret;
  };

  dp1 = [&](int l) {
    if (memo1[l] != -1) return memo1[l];
    int x = l == 0 ? Z : a[l - 1];
    int ret = abs(x - a[N - 1]);
    repi(i, l, N - 1) {
      amin(ret, dp0(i + 1));
    }
    return memo1[l] = ret;
  };

  cout << dp0(0) << '\n';
}


Measured memory_bytes: 512
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N, M, X, Y = sc.nextInt()
    val x = Array.fill(N)(sc.nextInt())
    val y = Array.fill(M)(sc.nextInt())
    println((X + 1 to Y) exists { Z =>
      x.max < Z && Z <= y.min
    } match {
      case true => "No War"
      case false => "War"
    })
  }

}



Measured memory_bytes: 25800
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
const int N = 1e5;  // limit for array size
ll n;  // array size

int main(){
	int n;cin>>n;
	ll a[n];
    for(int i=0;i<n;i++){
    	cin>>a[i];
	}
	ll ans=0;
	
	for(int i=0;i<n;i++){
    	while(a[i]%2==0){
    		ans++;
    		a[i]/=2;
		}
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>


using namespace std;

int main(){

  int n,m;
  int res=0;
  cin >> n >> m;
  int counts[31]={0};
  
  for(int i=0;i<n;i++){
  
    int k;
    cin >> k;
  
    int a[k];
  for(int j=0;j<k;j++){
   cin >> a[j];
   counts[a[j]]++;
  }
    
  }
  
  for(int i=0;i<31;i++){
  if(counts[i]==n){
     res++;
  }
  }
 
   cout << res << endl;
  
    
  
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int k = sc.nextInt();
		
		boolean result = false;
		int operationNum = 0;
		while(!(a < b && b < c) && operationNum < k) {
			if(a < b && b < c) {
				result = true;
				break;
			}
			if(a >= b) {
				b *= 2;
				operationNum++;
				continue;
			}
			if(b >= c) {
				c *= 2;
				operationNum++;
			}
		}
		if(a < b && b < c) {
			result = true;
		}
		System.out.println(result ? "Yes" : "No");
	}
}


Measured memory_bytes: 35688
def main():
    N = int(raw_input())
    A = map(int, raw_input().split())
    sort(A)

def sort(A):
    N = len(A)
    display(A)
    for j in range(1, N):
        key = A[j]
        i = j - 1
        while i >= 0 and A[i] > key:
            A[i+1] = A[i]
            i -= 1
        A[i+1] = key
        display(A)

def display(A):
    print(" ".join(map(str, A)))

main()

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

int n;
int dp[50];

int fibo(int i){
  if(dp[i] != 0) return dp[i];
  else if(i == 0 || i == 1) return dp[i] = 1;
  else{
    return dp[i] = fibo(i-1) + fibo(i-2);
  }
}

int main(){
  cin >> n;
  cout << fibo(n) << endl;
  return 0;
}



Measured memory_bytes: 3116
import copy
def a():return input()#s
def ai():return int(input())#a,n or k
def ma():return map(int, input().split())#a,b,c,d or n,k
def ms():return map(str, input().split())#,a,b,c,d
def lma():return list(map(int, input().split()))#x or y
def lms():return list(map(str, input().split()))#x or y
k= []
l = []
for i in range(3):
    k.append(lma())
l = copy.deepcopy(k)
p = copy.deepcopy(k)

for i in range(1,3):
    for j in range(0,3):
        l[i][j] -= k[i-1][j]
        p[j][i] -= k[j][i-1]
if l[1][0]==l[1][1] and l[1][1]==l[1][2] and l[2][0]==l[2][1] and l[2][1]==l[2][2] and p[0][1] == p[1][1] and p[2][1] == p[1][1] and p[2][2] == p[1][2] and p[0][2]==p[1][2]:
    print("Yes")
else:print("No")




Measured memory_bytes: 3444
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int N;
	cin >> N;
	int A = 0;
	int ans;
	while (1) {
		if (A >= N) {
			ans = A - N;
			break;
		}
		A += 1000;
	}


	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        sc.next();
        int k = Integer.parseInt(sc.next());
        String s = sc.next();
        
        char[] c = s.toCharArray();
        if(c[k-1] == 'A'){
            c[k-1] = 'a';
        }else if(c[k-1] == 'B'){
            c[k-1] = 'b';
        }else{
            c[k-1] = 'c';
        }
        
        System.out.println(c);
    }
}

Measured memory_bytes: 22996
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

string T[] ={ "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };

string S;
signed main(){
    cin >> S;
    rep(i, 7){
        if(S == T[i]) cout << 7-i << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        long n = sc.nextLong();
        long m = sc.nextLong();
        long ret = 0;
        if (n==m/2) {
            ret = n;
        } else if (n>m/2) {
            ret = m/2;
        } else {
            ret = n+(m-n*2)/4;
        }
        System.out.println(ret);
    }
}


Measured memory_bytes: 21972
n=input()
keta=[0,0]
for i in range(len(n)):
	keta.append(int(n[i]))
ans=0
for i in range(len(keta)-1):
	if keta[-i-2]>=5:
		if keta[-i-1]>=5:
			ans+=10-keta[-i-1]
			keta[-i-2]+=1
		else:
			ans+=keta[-i-1]
	else:
		if keta[-i-1]>=6:
			ans+=10-keta[-i-1]
			keta[-i-2]+=1
		else:
			ans+=keta[-i-1]
print(ans)

Measured memory_bytes: 13636
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
const ll  M = 1e9 + 7;
ll n, k, x = 0, y = 0;

ll dp[3002][3002][2];

ll f(ll l, ll r, vector<ll> &v, ll turn)
{

	if(l > r)
	{
		
		return 0;
		
	}
	if(dp[l][r][turn] != -1)
		return dp[l][r][turn];
	// turn is to tell whos turn it is now (which player) : 0 -> X
	// option1 I take from l, option2 i take from right end

	if(turn == 0)
	{
		ll opt1 = f(l + 1, r, v, !turn) +v[l];
		ll opt2 = f(l, r-1, v, !turn) +v[r];
		return dp[l][r][turn] = max(opt1, opt2);
	}
	else
	{
		ll opt1 = f(l + 1, r, v, !turn) -v[l];
		ll opt2 = f(l, r-1, v, !turn) -v[r];
		return dp[l][r][turn] = min(opt1, opt2);
	}

	
}

int main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll i, j, wt, m;
	
	cin >> n;
	vector<ll> v(n + 1);
	for(i = 0; i < n; i++)
		cin >> v[i];
	memset(dp, -1, sizeof(dp));
	cout << f(0, n-1, v, 0);
}


Measured memory_bytes: 144632
#include <array>
#include <cstdint>
#include <iostream>
#include <queue>

using namespace std;

void wfs(array<array<int32_t, 200>, 200> &hex, int32_t x, int32_t y) {
  queue<pair<int32_t, int32_t>> q;

  hex[x][y] = 0;
  q.push({x, y});

  while (!q.empty()) {
    pair<int32_t, int32_t> p = q.front();
    int32_t x = p.first;
    int32_t y = p.second;
    q.pop();

    vector<pair<int32_t, int32_t>> vecs{{0, 1}, {1, 1},   {-1, 0},
                                        {1, 0}, {-1, -1}, {0, -1}};
    for (uint32_t i = 0; i < vecs.size(); i++) {
      int32_t posx = x + vecs[i].first;
      int32_t posy = y + vecs[i].second;
      if (0 <= posx && posx < 200 && 0 <= posy && posy < 200 &&
          hex[posx][posy] == INT32_MAX) {
        hex[posx][posy] = hex[x][y] + 1;
        q.push({posx, posy});
      }
    }
  }
}

int32_t main() {
  while (true) {
    int32_t t, n;
    cin >> t >> n;
    if (t == 0 && n == 0) break;

    array<array<int32_t, 200>, 200> hex;
    for (uint32_t i = 0; i < hex.size(); i++) {
      for (uint32_t j = 0; j < hex[0].size(); j++) {
        hex[i][j] = INT32_MAX;
      }
    }

    for (uint32_t i = 0; i < n; i++) {
      int32_t x, y;
      cin >> x >> y;
      hex[x + 100][y + 100] = -1;
    }
    int32_t x, y;
    cin >> x >> y;
    wfs(hex, x + 100, y + 100);

    uint32_t count = 0;
    for (uint32_t i = 0; i < hex.size(); i++) {
      for (uint32_t j = 0; j < hex[0].size(); j++) {
        if (0 <= hex[i][j] && hex[i][j] <= t) {
          count++;
        }
      }
    }

    cout << count << endl;
  }

  return 0;
}

Measured memory_bytes: 3252
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    a,b,x = LMIIS()
    import math
    if x / a <= a * b / 2:   
        print(math.degrees(math.atan(b * b * a/ x /2 )))
    else:
        y = (a*b - x / a) *2 / a
        print(math.degrees(math.atan(y/a)))

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include<iostream>

using namespace std;

int main()
{
	int n; cin>>n;
	int pre[3];
	cin>>pre[0]>>pre[1]>>pre[2];
	n--;
	int cur[3];
	while(n--)
	{
		cin>>cur[0]>>cur[1]>>cur[2];
		cur[0] = cur[0]+max(pre[1],pre[2]);
		cur[1] = cur[1]+max(pre[0],pre[2]);
		cur[2] = cur[2]+max(pre[0],pre[1]);

		pre[0] = cur[0];
		pre[1] = cur[1];
		pre[2] = cur[2];
	}

	cout<<max(pre[0],max(pre[1],pre[2]));
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rng(i, l, r) for (size_t i = (l); i < (r); ++i)
#define rep(i, n) rng(i, 0, n)
#define gnr(i, l, r) for (size_t i = (r)-1; i >= (l); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(obj) (obj).begin(), (obj).end()    //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend() //...,3,2,1

using namespace std;

const int INF = 1e18;

#define RED 0
#define GREEN 1
#define WHITE 2

void solve()
{

    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("./sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);

    int X, Y, a, b, c;
    cin >> X >> Y >> a >> b >> c;

    priority_queue<pair<int, int>> pq;
    rep(i, a)
    {
        int p;
        cin >> p;
        pq.push(make_pair(p, RED));
    }
    rep(i, b)
    {
        int q;
        cin >> q;
        pq.push(make_pair(q, GREEN));
    }
    rep(i, c)
    {
        int r;
        cin >> r;
        pq.push(make_pair(r, WHITE));
    }

    int ans = 0;
    int cntR = 0;
    int cntG = 0;
    int cntW = 0;
    while (cntR <= X && cntG <= Y)
    {
        if (cntR + cntG + cntW == X + Y)
            break;

        auto now = pq.top();
        pq.pop();
        if (now.second == RED)
        {
            if (X <= cntR)
                continue;
            cntR++;
        }
        else if (now.second == GREEN)
        {
            if (Y <= cntG)
                continue;
            cntG++;
        }
        else
        {
            cntW++;
        }
        ans += now.first;
    }

    cout << ans << endl;
}

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


Measured memory_bytes: 10348
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  int m;
  cin>>n>>m;
  vector<vector<int>> v(n,vector<int>(m,0));
  for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
         char temp;
         cin>>temp;
         if(temp=='.'){
             v[i][j]=0;
         }
         else{
             v[i][j]=-1;
         }
      }
  }
  v[0][0] = 1;
  for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
          if(v[i][j]==-1){
              continue;
          }
          if((i-1>=0)&&v[i-1][j]!=-1){
              v[i][j]=(v[i][j]+v[i-1][j]%MOD)%MOD;
          }
          if((j-1>=0)&&v[i][j-1]!=-1){
               v[i][j]=(v[i][j]+v[i][j-1]%MOD)%MOD;
          }
      }
  }
  cout<<v[n-1][m-1]%MOD;
  
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
const int maxn=305;
const int mod=1e9+7;
vc<pi> q[maxn];
ll dp[maxn][maxn][maxn];
int n,m;
ll dfs(int r,int g,int b)
{
    //dbg(r,g,b);
    if(r==n||g==n||b==n) return 1;
    ll &ret=dp[r][g][b];
    if(ret!=-1) return ret;
    ret=0;
    int p=max({r,g,b})+1;
    bool okr=1,okg=1,okb=1;
    for(auto u:q[p])
    {
        int l=u.first,t=u.second;
        okr&=(((g>=l)+(b>=l)+1)==t);
        okb&=(((r>=l)+(g>=l)+1)==t);
        okg&=(((r>=l)+(b>=l)+1)==t);
    }
    if(okr) ret=(ret+dfs(p,g,b))%mod;
    if(okg) ret=(ret+dfs(r,p,b))%mod;
    if(okb) ret=(ret+dfs(r,g,p))%mod;
    //dbg(r,g,b,ret);
    return ret;
}
int main()
{
    memset(dp,-1,sizeof(dp));
    cin>>n>>m;
    for(int i=0,l,r,x;i<m;i++)
    {
        cin>>l>>r>>x;
        q[r].push_back(make_pair(l,x));
    }
    cout<<dfs(0,0,0)<<'\n';
}

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

int main() {
    int N, Q; cin >> N >> Q;
    string str; cin >> str;

    // 累積和
    vector<int> s(N+1, 0);
    for (int i = 0; i < N; ++i) {
        if (i+1 < N && str[i] == 'A' && str[i+1] == 'C') s[i+1] = s[i] + 1;
        else s[i+1] = s[i];
    }

    // クエリ
    for (int q = 0; q < Q; ++q) {
        int l, r; cin >> l >> r;
        --l, --r; // 0-indexed にする
        cout << s[r] - s[l] << endl;
    }
}   
//けんちょんさんのコピー

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

int main() {
    string s;
    cin >> s;
    string t;
    cin >> t;
    int count = 0;
    for(int i = 0; i < 3; i++){
        if(s.at(i) == t.at(i)){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxm=2e5+5;
vector<int>g[maxm];
int L[maxm],R[maxm],idx;
int rk[maxm];
int a[maxm];
int n,q;
void dfs(int x,int fa){
    L[x]=++idx;
    rk[idx]=x;
    for(int v:g[x]){
        if(v==fa)continue;
        dfs(v,x);
    }
    R[x]=idx;
}
signed main(){
    cin>>n>>q;
    for(int i=1;i<n;i++){
        int a,b;cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(1,1);
    while(q--){
        int x,val;cin>>x>>val;
        a[L[x]]+=val;
        a[R[x]+1]-=val;
    }
    for(int i=1;i<=n;i++){
        a[i]+=a[i-1];
    }
    for(int i=1;i<=n;i++){
        cout<<a[L[i]]<<' ';
    }
    return 0;
}


Measured memory_bytes: 30204
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

const int MAX = 1010101;

long long fac[MAX], finv[MAX], inv[MAX];

void binom_init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long binom(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long perm(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * finv[n - k] % MOD;
}

ll X, Y;

int main() {
  cin >> X >> Y;

  if (Y > X) {
    swap(X, Y);
  }

  if (X == 0 && Y == 0) {
    cout << 1;
    return 0;
  }

  if ((X + Y) % 3 != 0) {
    cout << 0;
    return 0;
  }

  binom_init();

  ll sum = X + Y;
  ll rank = sum / 3;
  ll diff = X - Y;

  if (abs(diff) > rank) {
    cout << 0;
    return 0;
  }

  if (rank % 2 == 0) {
    ll mid = rank / 2;
    cout << binom(rank, mid - abs(diff) / 2);
  } else {
    ll mid = rank / 2;
    cout << binom(rank, mid - diff / 2);
  }
}


Measured memory_bytes: 27320
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001

int main(void) {
	int a,b; cin >> a >> b;
	int ans;
	if(a<=5) ans = 0;
	else if(6<=a&&a<=12) ans = b/2;
	else ans = b;
	cout << ans << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <set>
#define ii pair<int,int>
#define X first
#define Y second
using namespace std;
const int maxn = 100;
int n,m;
int a['z'+1],b['z'+1],dem[5];
set<ii> S;
int main()
{
	ios_base::sync_with_stdio(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >> n >> m;
	memset(a,0,sizeof(a));
	for (int i=1; i<=n; i++)
		for (int j=1; j<=m; j++)
		{
			char x;
			cin >> x;
			a[x]++;
		}
	
	S.clear();
	for (int i=1; i<=n; i++)
	for (int j=1; j<=m; j++)
	S.insert(ii(i,j));
	
	memset(dem,0,sizeof(dem));
	
	for (int i=1; i<=n; i++)
	for (int j=1; j<=m; j++)
	if (S.count(ii(i,j)))
	{
		S.erase(ii(i,j));
		int p=1;
		if (S.count(ii(n-i+1,j)))
		{
			S.erase(ii(n-i+1,j));
			p++;
		}
		if (S.count(ii(i,m-j+1)))
		{
			S.erase(ii(i,m-j+1));
			p++;
		}
		if (S.count(ii(n-i+1,m-j+1)))
		{
			S.erase(ii(n-i+1,m-j+1));
			p++;
		}
		//cout << i << ' ' << j << ' ' << p << '\n';
		dem[p]++;
	}
	
	/*for (int i=1; i<=4; i++)
	cout << dem[i] << '\n';*/
	
	for (int i=4; i>=1; i--)
	{
		memset(b,0,sizeof(b));
		
		int cnt=0;
		
		for (char j='a'; j<='z'; j++)
		{
			b[j]=a[j]/i;
			cnt+=b[j];
		}
		
		if (cnt<dem[i]) 
		{
			cout << "No";
			return 0;
		}
		else
		{
			cnt=0;
			char j='a';
			while (cnt<dem[i])
			{
				a[j]-=min(b[j],dem[i]-cnt)*i;
				cnt+=b[j];
				j++;
			}
		}
		/*for (char j='a'; j<='z'; j++)
		cout << a[j] << ' ';
		cout << '\n';*/
	}
	
	cout << "Yes";
	return 0;
}

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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    string s;
    cin >> s;
    sort(ALL(s));
    if (s == "abc") {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
}


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

using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;

#define out(a) cout << a << endl
#define out1(a) cout << a
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define rep(i, N) for (ll i = 0; i < (ll)N; i++)
#define rep1(i, N) for (ll i = 1; i <= (ll)N; i++)
#define repi(i, j, N) for (ll j = (ll)i + 1; j < (ll)N; j++)
#define all(v) v.begin(), v.end()

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

constexpr int inf = 1e9;
constexpr ll linf = 1e18;
constexpr ll mod = 1e9 + 7;

void solve();

int main()
{
    solve();
}

void solve()
{
    int n;
    in(n);
    double a[n];
    double ans = 0;
    rep(i, n)
    {
        in(a[i]);
        ans += 1.0 / a[i];
    }
    ans = 1 / ans;
    cout << fixed << setprecision(5) << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define inf 1e9
#define INF 1000000000000000000

vector<pair<long long, long long>> prime_factorize(long long N) {
    vector<pair<long long, long long>> res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0)
            continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1)
        res.push_back({N, 1});
    return res;
}

int main() {
    int N;
    cin >> N;
    vector<ll> count(N + 1, 0);
    for (int i = 2; i < N + 1; i++) {
        vector<pair<ll, ll>> pri = prime_factorize(i);
        rep(k, pri.size()) { count[pri[k].first] += pri[k].second; }
    }

    ll over2 = 0, over4 = 0, over14 = 0, over24 = 0, over74 = 0;

    rep(i, N + 1) {
        if (count[i] >= 2)
            over2++;
        if (count[i] >= 4)
            over4++;
        if (count[i] >= 14)
            over14++;
        if (count[i] >= 24)
            over24++;
        if (count[i] >= 74)
            over74++;
    }

    ll ans = (over4 * (over4 - 1) * (over2 - 2)) / 2 + (over2 - 1) * over24 +
             (over4 - 1) * over14 + over74;
    cout << ans << endl;
}

Measured memory_bytes: 256
#ifndef ___Class_RangeTree
#define ___Class_RangeTree

// ------ Includes ------ //
#include <limits>
#include <vector>
#include <algorithm>

template<typename Type> class RangeTree {
private:
	int size_; std::vector<std::vector<Type> > dat;
	inline int query_(int a, int b, Type x, int k, int l, int r) {
		// Find range [a, b) : value < x : Now k-th node and the range is [l, r)
		if (r <= a || b <= l) return 0;
		if (a <= l && r <= b) return lower_bound(dat[k].begin(), dat[k].end(), x) - dat[k].begin();
		int lc = query_(a, b, x, (k << 1), l, (l + r) >> 1);
		int rc = query_(a, b, x, (k << 1) + 1, (l + r) >> 1, r);
		return lc + rc;
	}
public:
	RangeTree() : size_(0), dat(std::vector<Type>()) {};
	template<class T>
	RangeTree(T begin_, T end_) {
		int n = (end_ - begin_);
		for (size_ = 1; size_ < n; size_ <<= 1); dat.resize(size_ << 1, std::vector<Type>());
		for (int i = 0; i < n; i++) dat[i + size_] = std::vector<Type>({ *(begin_ + i) });
		for (int i = size_ - 1; i > 0; i--) {
			dat[i].resize(dat[i << 1].size() + dat[(i << 1) + 1].size());
			std::merge(dat[i << 1].begin(), dat[i << 1].end(), dat[(i << 1) + 1].begin(), dat[(i << 1) + 1].end(), dat[i].begin());
		}
	}
	inline int size() { return size_; }
	inline int query(int l, int r, Type x) {
		// Find range [a, b) : value < x
		return query_(l, r, x, 1, 0, size_);
	}
};

#endif

#include <cstdio>
#include <vector>
#pragma warning(disable : 4996)
using namespace std;
int N, Q, xl, yl, xr, yr;
int main() {
	scanf("%d%d", &N, &Q);
	vector<pair<int, int> > p(N);
	for (int i = 0; i < N; i++) scanf("%d%d", &p[i].first, &p[i].second);
	sort(p.begin(), p.end());
	vector<int> z1(N), z2(N);
	for (int i = 0; i < N; i++) {
		z1[i] = p[i].first;
		z2[i] = p[i].second;
	}
	RangeTree<int> seg(z2.begin(), z2.end());
	while (Q--) {
		scanf("%d%d%d%d", &xl, &yl, &xr, &yr);
		int ptr1 = lower_bound(z1.begin(), z1.end(), xl) - z1.begin();
		int ptr2 = lower_bound(z1.begin(), z1.end(), xr + 1) - z1.begin();
		int res1 = seg.query(ptr1, ptr2, yl);
		int res2 = seg.query(ptr1, ptr2, yr + 1);
		printf("%d\n", res2 - res1);
	}
	return 0;
}

Measured memory_bytes: 3600