akhauriyash/Code-Regression huggingface dataset:
n = input()
s = []
h = []
c = []
d = []
for i in range(n):
	spare = raw_input().split()
	if spare[0]=='S':
		s.append(int(spare[1]))
	elif spare[0]=='H':
		h.append(int(spare[1]))
	elif spare[0]=='C':
		c.append(int(spare[1]))
	else :
		d.append(int(spare[1]))
for j in range(1,14):
	judge = True
	for k in range(len(s)):
		if j==s[k] :
			judge = False
			break
	if judge :
		print 'S %d' %j
for j in range(1,14):
	judge = True
	for k in range(len(h)):
		if j==h[k] :
			judge = False
			break
	if judge :
		print 'H %d' %j
for j in range(1,14):
	judge = True
	for k in range(len(c)):
		if j==c[k] :
			judge = False
			break
	if judge :
		print 'C %d' %j
for j in range(1,14):
	judge = True
	for k in range(len(d)):
		if j==d[k] :
			judge = False
			break
	if judge :
		print 'D %d' %j

Measured memory_bytes: 6372
import java.util.Scanner;

public class Main {
	public static void main(String[] args){



		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		double[] x = new double[n];
		double[] y = new double[n];
		for(int i =0;i<n;i++) {
			x[i] = sc.nextDouble();
			y[i] = sc.nextDouble();
		}
		
		double sum=0;
		for(int i =0;i<n;i++) {
			for(int j=i+1;j<n;j++) {
				sum+=Math.sqrt(Math.pow(x[i]-x[j],2)+Math.pow(y[i]-y[j],2));
			}
		}
		int divide = 1;
		for(int i =1;i<n+1;i++) {
			divide = divide*i;
		}
		divide  = divide/2;
		System.out.println(sum*2/n);
	}

	

}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


Measured memory_bytes: 24276
import math

def solve(x):
    y = 0
    for i in range(n):
        if a[i] >= x / f[i]:
            y += math.ceil(a[i] - x / f[i])
    if y <= k:
        return True
    else:
        return False

def binary_search(c1, c2):
    m = (c1 + c2 + 1) // 2
    if abs(c1 - c2) <= 1:
        return m
    else:
        if solve(m):
            c1 = m
        else:
            c2 = m
        return binary_search(c1, c2)

n, k = map(int, input().split())
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort(reverse = True)
M = 0
for i in range(n):
    M = max(M, a[i] * f[i])
ans = binary_search(M, -1)
print(ans)

Measured memory_bytes: 119628
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

long long inputValueLongLong(){
    long long a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

void inputVectorlonglong(vector<long long> * p, long long a){
    rep(i, a){
        long long input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}


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

    std::string S;
    cin >> S;
  int res=0;
    if(S=="SUN"){
        res = 7;
    }else if(S=="MON"){
        res = 6;
    }else if(S=="TUE"){
        res = 5;
    }else if(S=="WED"){
        res = 4;
    }else if(S=="THU"){
        res = 3;
    }else if(S=="FRI"){
        res = 2;
    }else if(S=="SAT"){
        res = 1;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] a = new int[N];
		for (int i = 0; i < N; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		int check=0;
		for (int i = 0; i < N; i++) {
			if ((i + 1) % 2 == 1 && a[i] % 2 == 1) {
				check++;
			}
		}
		System.out.println(check);
	}

}


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

def main():
    N, K = map(int, input().split())
    L = 2*K
    state = [[[0, 0] for _ in range(L+1)] for _ in range(K+1)]

    for _ in range(N):
        x, y, c = map(str, input().split())
        a, b = int(x)%L, int(y)%L
        k = 0 if c == 'W' else 1
        if a >= K:
            if b >= K:
                a -= K
                b -= K
            else:
                a -= K
                b += K
        state[a+1][b+1][k] += 1


    for i in range(K):
        for j in range(L):
            for k in [0, 1]:
                state[i+1][j+1][k] += state[i+1][j][k] + state[i][j+1][k] - state[i][j][k]

    ans = 0
    for x in range(K):
        for y in range(K):
            for k in [0, 1]:
                count = 0
                count += state[x][y][k]
                count += state[x][L][k] - state[x][y+K][k]
                count += state[K][y+K][k] - state[x][y+K][k] - state[K][y][k] + state[x][y][k]

                l = k ^ 1
                count += state[K][y][l] - state[x][y][l]
                count += state[x][y+K][l] - state[x][y][l]
                count += state[K][L][l] - state[K][y+K][l] - state[x][L][l] + state[x][y+K][l]

                ans = max(ans, count)
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 200028
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	static int n = 26, d;
	static int[] c, last;
	static int[][] s;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		d = Integer.parseInt(br.readLine());
		String[] sa = br.readLine().split(" ");
		c = new int[n];
		for (int i = 0; i < n; i++) {
			c[i] = Integer.parseInt(sa[i]);
		}
		s = new int[d][n];
		for (int i = 0; i < d; i++) {
			sa = br.readLine().split(" ");
			for (int j = 0; j < n; j++) {
				s[i][j] = Integer.parseInt(sa[j]);
			}
		}
		int[] t = inputB(br);

		int m = Integer.parseInt(br.readLine());
		for (int i = 0; i < m; i++) {
			sa = br.readLine().split(" ");
			int k = Integer.parseInt(sa[0]) - 1;
			int q = Integer.parseInt(sa[1]) - 1;
			t[k] = q;
			System.out.println(calc(t, d - 1));
		}
		br.close();
	}

	static int[] inputB(BufferedReader br) throws Exception {
		int[] t = new int[d];
		for (int i = 0; i < d; i++) {
			t[i] = Integer.parseInt(br.readLine()) - 1;
		}
		return t;
	}

	static int calc(int[] t, int end) {
		int[] last = new int[n];
		int ret = 0;
		for (int i = 0; i <= end; i++) {
			ret += s[i][t[i]];
			last[t[i]] = i + 1;
			for (int j = 0; j < n; j++) {
				ret -= c[j] * (i + 1 - last[j]);
			}
		}
		return ret;
	}
}


Measured memory_bytes: 54864
#include <bits/stdc++.h>
// #define test TEST 
using namespace std;
typedef long long ll;
const int maxn=1e5+5;

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	int n;
	while(cin>>n){
		map<int,int>mii;
		for(int i=0,temp;i<n;i++){
			cin>>temp;
			mii[temp-1]++,mii[temp]++,mii[temp+1]++;
		}
		int ans=0;
		for(auto iter:mii){
			ans=max(ans,iter.second);
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 4736
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
using namespace std;

int main(){
  int N;
  cin >> N;
  long long x[N],y[N],h[N];

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

  long long pans,d;
  long long Ans;
  int xa, ya;
  bool flag = false;
  bool middleflag = true;

  for(int i = 0; i <= 100; i++){
    if(flag) break;
    for(int j = 0; j <= 100; j++){
      pans = -1;
      middleflag = true;
      for(int k = 0; k < N; k++){
        if(h[k] > 0){
          d = h[k] + abs(i-x[k]) + abs(j-y[k]);
          if(pans == -1){
            pans = d;
          }else{
            if(d != pans){
              middleflag = false;
              break;
            }
          }
        }
      }
      if(middleflag){
        bool smallflag = true;
        for(int k = 0; k < N; k++){
          if(h[k] == 0){
            d =  abs(i-x[k]) + abs(j-y[k]);
            if(d < pans){
              smallflag = false;
              break;
            }
          }
        }

        if(smallflag){
          Ans = pans;
          xa = i;
          ya = j;
          flag = true;
          break;
        }
      }
    }
  }

  printf("%d %d %lld\n",xa,ya,Ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <functional>
#include <cstring>
#include <cmath>
#include <random>
using namespace std;

int main() {
    int n;
    cin >> n;
    cout << n * 800 - n / 15 * 200 << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = "abcdefghijklmn"
Q = [(1,1,"a")]
A = []
while Q:
    q = Q.pop(-1)
    if q[0]==N:
        A.append(q[2])
        continue
    for i in range(q[1]+1):
        Q.append((q[0]+1,max(q[1],i+1),q[2]+S[i]))
for a in sorted(A):print(a)

Measured memory_bytes: 13512
#include <iostream>

using namespace std;

int A[110];

int main() {
    int N;
    cin >> N;
    bool isApproved = true;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        if (A[i] % 2 == 0) {
            if(!(A[i] % 3 == 0 || A[i] % 5 == 0)) {
                isApproved = false;
            }
        }
    }
    if (isApproved) {
        cout << "APPROVED" << endl;
    } else {
        cout << "DENIED" << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
long long a[100005];
int b[100005];

long long abs(long long u){ return u>0?u:-u; }

long long getDiff(int n){
    long long res = 0;
    for(int i = 1; i <= n-1; i++){
        res += abs(a[b[i]]-a[b[i+1]]);
    }
    return res;
}

long long max(long long a,long long b){ return a>b?a:b; }

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= n; i++) scanf("%lld",&a[i]);
    std::sort(a+1,a+1+n);
    if(n%2==0){
        int gap = n/2+1;
        for(int i = 1; i <= n; i += 2){
            b[i] = gap;
            gap++;
        }
        gap = n/2;
        for(int i = n; i >= 1; i -= 2){
            b[i] = gap;
            gap--;
        }
        printf("%lld\n",getDiff(n));
    }
    else{
        int gap = n/2+2;
        for(int i = 2; i <= n; i+=2){
            b[i] = gap;
            gap++;
        }
        gap = n/2+1;
        b[1] = gap--;
        b[n] = gap--;
        for(int i = 3; i <= n-2; i+=2){
            b[i] = gap--;
        }
        long long ans = getDiff(n);
        gap = 1;
        for(int i = 2; i <= n; i+=2){
            b[i] = gap++;
        }
        b[1] = gap++;
        b[n] = gap++;
        for(int i = 3; i <= n-2; i+=2) b[i] = gap++;
        ans = max(ans,getDiff(n));
        printf("%lld\n",ans);
    }
    
    return 0;
}


Measured memory_bytes: 2904
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <limits>
#include <vector>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int64_t> vs(n);
    for (auto& v : vs)
    {
        cin >> v;
    }
    sort(vs.begin(), vs.end());
    int64_t min_value = numeric_limits<int64_t>::max();
    for (int i = k - 1; i < n; i++)
    {
        min_value = min(min_value, vs[i] - vs[i - k + 1]);
    }
    cout << min_value << endl;
}

Measured memory_bytes: 1024
#設定
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

class Graph(object):
	def __init__(self):
		self.graph = defaultdict(list)

	def __len__(self):
		return len(self.graph)

	def add_edge(self, a, b):
		self.graph[a].append(b)

	def get_nodes(self):
		return self.graph.keys()

def DFS(G, A, use, Wlist, visit, jud, node):
	for i in G.graph[node]:
		if visit[i] != "Yes":
			visit[i] = "Yes"
			DFS(G, A, use, Wlist, visit, jud, i)
			Wlist[node].append(use[i])

	#抜けの処理
	if Wlist[node] == []:
		use[node] = A[node]
	else:
		Z = sum(Wlist[node])
		if max(max(Wlist[node]), (Z + 1) // 2) <= A[node] and A[node] <= Z:
			use[node] = 2 * A[node] - Z
		else:
			use[node] = 2 * A[node] - Z
			jud[node] = "NO"

#処理内容
def main():
	N = int(input())
	A = getlist()
	G = Graph()
	for i in range(N - 1):
		a, b = getlist()
		a -= 1; b -= 1
		G.add_edge(a, b)
		G.add_edge(b, a)

	#面倒なケース
	if N == 2:
		if A[0] == A[1]:
			print("YES")
			return
		else:
			print("NO")
			return

	s = None
	for i in range(N):
		if len(G.graph[i]) >= 2:
			s = i
			break
	#DFS
	judge = "YES"
	use = [None] * N
	jud = ["YES"] * N
	Wlist = [[] for i in range(N)]
	visit = ["No"] * N
	visit[s] = "Yes"
	DFS(G, A, use, Wlist, visit, jud, s)
	# print(use)

	for i in range(N):
		if jud[i] == "NO":
			judge = "NO"

	if use[s] != 0:
		judge = "NO"
	#答え
	print(judge)

if __name__ == '__main__':
	main()

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

using namespace std;
using ll = long long;
#define int ll
using PII = pair<int, int>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;
template <typename T> using VVV = vector<VV<T>>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll INF = (1LL<<60);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n;
  cin >> n;
  if(n%2) cout << n*2 << endl;
  else cout << n << endl;

  return 0;
}


Measured memory_bytes: 256
from itertools import combinations
import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(20000000)

n, m, q = map(int, input().split())
abcd = []
for i in range(q):
    a, b, c, d = map(int, input().split())
    abcd.append([a-1, b-1, c, d])

def dfs(A, depth, max_a):
    if depth == n:
        score = 0
        for a, b, c, d in abcd:
            if A[b] - A[a] == c:
                score += d
        return score
    ans = 0
    for i in range(max_a, m+1):
        ans = max(ans, dfs(A + [i], depth+1, i))
    return ans

ans = dfs([1], 1, 1)
print(ans)



Measured memory_bytes: 71448
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

vector<vector<int>> G(1e5+5);

void bfs(int r,vector<int> &d) {
  queue<int> Q;
  Q.push(r);
  d[r]=0;
  int u;
  while(!Q.empty()) {
    u=Q.front(); Q.pop();
    for(auto next:G[u]) {
      if(d[next]==-1) {
        Q.push(next);
        d[next]=d[u]+1;
      }
    }
  }
}

int main() {
  int f=0,s=0;
  int a,b;
  int n; cin>>n;
  vector<int> df(1e5+5,-1),ds(1e5+5,-1);
  for(int i=0;i<n-1;i++) {
    cin>>a>>b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  bfs(1,df);
  bfs(n,ds);

  for(int i=1;i<=n;i++) {
    if(df[i]<=ds[i]) f++;
    else s++;
  }
  if(f>s) cout<<"Fennec"<<endl;
  else cout<<"Snuke"<<endl;
}


Measured memory_bytes: 9596
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class KCity {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            out.println((in.nextInt() - 1) * (in.nextInt() - 1));
        }

    }

    static class FastReader {
        BufferedReader reader;
        StringTokenizer st;

        public FastReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            st = null;
        }

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

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

    }
}



Measured memory_bytes: 21456
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        long A = scan.nextLong();
        long B = scan.nextLong();
        long h[] = new long[N];

        for (int i = 0; i < N; i++) {
            h[i] = scan.nextLong();
        }

        long l = 0;
        long r = 1000000000 + 1;

        while (l < r - 1) {
            long m = (l + r) / 2;
            long temp[] = new long[N];
            for(int i = 0;i < N;i++)
                temp[i] = h[i];
            for (int i = 0; i < N; i++) {
                temp[i] -= B * m;
            }
            long x = 0;
            for (int i = 0; i < N; i++) {
                if (temp[i] > 0) {
                    if (temp[i] % (A - B) == 0) {
                        x += temp[i] / (A - B);
                    } else {
                        x += temp[i] / (A - B) + 1;
                    }
                }
            }
                if(m < x){
                    l = m;
                }else{
                    r = m;
                }
            }
        System.out.println(r);
    }
}


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

namespace ABC121A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c, d, e;
            var wod = Console.ReadLine().Split(' ');
            a = int.Parse(wod[0]);
            b = int.Parse(wod[1]);
            var word = Console.ReadLine().Split(' ');
            c = int.Parse(word[0]);
            d = int.Parse(word[1]);
            e = (a - c) * (b - d);
            Console.WriteLine(e);
            Console.ReadKey();
                    }
    }
}


Measured memory_bytes: 13140
n,m=map(int,input().split())
x=list(map(int,input().split()))

#n=2
#m=5
#x=[10 ,12,1,2,14]

#n=3
#m=7
#x=[-10,-3,0,9,-100,2,17]

x.sort()
dx=[]
if n>=m:
    print(0)
else:
#    print(x)
    for i in range(len(x)-1):
        dx.append(x[i+1]-x[i])
    dx.sort()
    dxsum=sum(dx[0:m-n])
    print(dxsum)


Measured memory_bytes: 13968
#include<bits/stdc++.h>
#define ls k<<1,l,mid
#define rs k<<1|1,mid+1,r
#define mp(x,y) make_pair(x,y)
#define r(x) read(x)
#define rrr(x,y,z) read(x);read(y);read(z)
#define FOR(i,l,r) for(int i=l;i<=r;i++)
using namespace std;
typedef long long LL;
typedef pair<int,int> pt;
const int N=2e5+5;
const int M=2e3+5;
const int INF=0x7fffffff;
const int mod=1e9+7;
const double eps=1e-8;
const double pi=acos(-1);
LL n,m;
double f[N];
double sum[N];
template<class T>
inline void read(T &x)
{
    char c; x=1;
    while((c=getchar())<'0'||c>'9') if(c=='-') x=-1;
    T res=c-'0';
    while((c=getchar())>='0'&&c<='9') res=res*10+c-'0';
    x*=res;
}
int main()
{
    r(n); r(m);
    FOR(i,1,n)
	{
        r(f[i]);
        sum[i]=sum[i-1]+(f[i]+1)/2;
    }
    double ans=0;
    FOR(i,1,n-m+1){
        ans=max(ans,sum[i+m-1]-sum[i-1]);
    }
    printf("%.8f\n",ans);
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define REP(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl


int main(){
    int n,a;
    cin>>n>>a;
    vector<vl> dp(n+1,vl(50*n+1)); // i枚選んで合計jになる選び方がdp[i][j]個
    dp[0][0]=1;
    REP(i,n){
        int K;
        cin>>K;
        for(int j=n;j>0;j--){
            REP(k,50*n){
                dp[j][k+K]+=dp[j-1][k];
            }
        }
    }
    ll ans=0;
    REP(i,1,n+1){
        ans+=dp[i][a*i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}



int main(void){
  int n;
  cin >> n;
  vector<pair<ll, ll>> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i].second >> a[i].first;
  }
  sort(a.begin(), a.end());
  int ok = 1;

  ll t = 0;
  for (int i = 0; i < n; i++){
    if (t + a[i].second > a[i].first)
      ok = 0;

    t += a[i].second;
  }
  
  cout << (ok ? "Yes" : "No") << endl;

  return 0;
}


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

using namespace std;
# define M_PI 3.14159265358979323846
# define epsi 1e-9
# define F first
# define S second
# define REP(i,a,b) for(int i=a;i<=b;i++)
# define my_sizeof(type) ((char *)(&type+1)-(char*)(&type))
using ll = long long int;
const int MOD = 1e9 + 7;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    ll h[n];
    for(int i=0;i<n;i++)
    {
        ll temp;
        cin>>temp;
        h[i]=temp;
    }
    long dp[n];
    dp[0]=0;
    for(int i=1;i<n;i++)
    {
        ll mini=10e9;
        for(int j=1;j<=k;j++)
        {
            if(i-j>=0)
            {
                mini=min(mini,dp[i-j]+abs(h[i]-h[i-j]));
            }
        }
        dp[i]=mini;
    }

    cout<<dp[n-1];
}

Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	iv, _ := strconv.Atoi(scanString())
	return iv
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 100000), 100000000)
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	n := scanInt()
	ans := 0
	ba, bx, xa := 0, 0, 0
	for i := 0; i < n; i++ {
		s := scanString()
		if s[0] == 'B' && s[len(s)-1] == 'A' {
			ba++
		} else if s[0] == 'B' {
			bx++
		} else if s[len(s)-1] == 'A' {
			xa++
		}
		for i := range s[:len(s)-1] {
			if s[i:i+2] == "AB" {
				ans++
			}
		}
	}
	if bx > 0 && ba > 0 {
		bx--
		ans++
	}
	if xa > 0 && ba > 0 {
		xa--
		ans++
	}
	if ba > 0 {
		ans += ba - 1
	}
	ans += min(bx, xa)
	fmt.Println(ans)
}


Measured memory_bytes: 1844
def main():
    """
    1 <= N <= 500
    3 <= C <= 30
    (i!=j): 1 <= D(i,j) <= 1000
    (i==j): 0  = D(i,j)
    1 <= c(i,j) <= C
    """
    N, C = map(int, input().split())
    D = [
        list(map(int, input().split()))
        for _ in range(C)
    ]
    c = [
        list(map(int, input().split()))
        for _ in range(N)
    ]
    ans = f(N, C, c, D)
    print(ans)


def TLE(N, C, c, D):
    for i in range(N):
        for j in range(N):
            for x in range(N):
                for y in range(N):
                    same_type = (i + j) % 3 == (x + y) % 3
                    c1 = c[i][j]
                    same_color = c1 == c[x][y]
                    if same_type != same_color:
                        D[c1-1]

    return


def f(N, C, c, D):
    """
    """
    t = [[0] * C for _ in range(3)]
    ans = float("inf")
    for i in range(N):
        for j in range(N):
            # 余りのパターンごとに色情報の集計
            rem = (i + j) % 3
            color = c[i][j]
            t[rem][color - 1] += 1

    for i in range(C):
        for j in range(C):
            if i == j:
                continue
            for k in range(C):
                if i == k or j == k:
                    continue

                tmp = 0
                for bef in range(C):
                    for aft, rem in zip((i, j, k), range(3)):
                        tmp += D[bef][aft] * t[rem][bef]

                ans = min(ans, tmp)

    return ans


if __name__ == '__main__':
    main()


Measured memory_bytes: 5620
s = list(input())
s = [int(l) for l in s]
k = int(input())

if s[0] > 1:
  print(s[0])
elif sum(s[0:k]) == k and len(s[0:k]) == k:
  print(1)
else:
  i = 0
  while s[i] == 1:
    i += 1
    if s[i] != 1:
      print(s[i])
      break

Measured memory_bytes: 8940
#include <algorithm>
#include <iostream>
#include <vector>
#include <functional>
#include <string>
#include <cmath>  //sqrt 
#include <iomanip> //setprecision
using namespace std;

int main(){
    cout << fixed << setprecision(6);
    long long a,b,k ; cin >> a >> b >> k;
    long long n=a,m=b;
    if(a>k) n = a-k;
    else if(b > k-a) {
        n= 0;
        m = b-(k-a);
    }else{
        n=0;m=0;
    }
    cout << n << " " <<m << endl;
    return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define rn(i,n) for(int i=1;i<=n;i++)

int main(){
 vector<int> a(3);
 r(i,3)cin>>a.at(i);
 sort(a.begin(),a.end());
 int cnt=0;
 if(a.at(0)%2==0 and a.at(1)%2==1){
      if(a.at(2)%2==0){
        a.at(0)++;a.at(2)++;
        cnt++;
      }else{
        a.at(1)++;a.at(2)++;
        cnt++;
      }
    }
 else if(a.at(0)%2==1 and a.at(1)%2==0){
   if(a.at(2)%2==0){
     a.at(1)++;a.at(2)++;
     cnt++;
   }else{
     a.at(0)++;a.at(2)++;
     cnt++;
   }
  }
  //r(i,3)cout<<a.at(i)<<" ";
  //cout<<endl;
  cout<<((a.at(2)-a.at(0))+a.at(2)-a.at(1))/2+cnt<<endl;






  return 0;
}


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

int main(){
	int N, num_punched;
	vector<vector<int>> num_card(3,vector<int> (3));
	vector<vector<bool>> judge_punched(3,vector<bool> (3));
	
	// INPUT part
	for(int i=0;i<3;i++){
		cin >> num_card.at(i).at(0)
			>> num_card.at(i).at(1)
			>> num_card.at(i).at(2);
	}
	/*
	for(int i=0;i<3;i++){
		cout << num_card.at(i).at(0)
			<< num_card.at(i).at(1)
			<< num_card.at(i).at(2) << endl;
	}
	*/
	cin >> N;
	vector<int> num_input(N);
	for(int i=0;i<N;i++){
		cin >> num_input.at(i);
	}
	// END of INPUT
	
	// Initialization of bingo card punch
	for(int i=0;i<3;i++){
		judge_punched.at(i).at(0) = false;
		judge_punched.at(i).at(1) = false;
		judge_punched.at(i).at(2) = false;
	}
	/*
	for(int i=0;i<3;i++){
		cout << judge_punched.at(i).at(0)
			<< judge_punched.at(i).at(1)
			<< judge_punched.at(i).at(2) << endl;
	}
	*/
	
	// Punching holes through the bingo card
	for(int i=0;i<N;i++){
		num_punched = num_input.at(i);
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				if(num_card.at(j).at(k)==num_punched){
					judge_punched.at(j).at(k) = true;
				}
			}
		}
	}
	/*
	for(int i=0;i<3;i++){
		cout << judge_punched.at(i).at(0)
			<< judge_punched.at(i).at(1)
			<< judge_punched.at(i).at(2) << endl;
	}
	*/
	
	// judge whether BINGO exists.
	if((judge_punched.at(0).at(0)*judge_punched.at(0).at(1)*judge_punched.at(0).at(2))
		+(judge_punched.at(1).at(0)*judge_punched.at(1).at(1)*judge_punched.at(1).at(2))
		+(judge_punched.at(2).at(0)*judge_punched.at(2).at(1)*judge_punched.at(2).at(2))){
			cout << "Yes" << endl;
			return 0;
		}
	if((judge_punched.at(0).at(0)*judge_punched.at(1).at(0)*judge_punched.at(2).at(0))
		+(judge_punched.at(0).at(1)*judge_punched.at(1).at(1)*judge_punched.at(2).at(1))
		+(judge_punched.at(0).at(2)*judge_punched.at(1).at(2)*judge_punched.at(2).at(2))){
			cout << "Yes" << endl;
			return 0;
		}
	
	if((judge_punched.at(0).at(0)*judge_punched.at(1).at(1)*judge_punched.at(2).at(2))
		+(judge_punched.at(2).at(0)*judge_punched.at(1).at(1)*judge_punched.at(0).at(2))){
			cout << "Yes" << endl;
			return 0;
		}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>

using namespace std;

int main()
{
    int K;
    char S[105];
    cin >> K >> S;

    int i;
    int len_s = strlen(S);

    if (len_s < K) {
        cout << S;
        return 0;
    }

    for (i = 0; i < len_s; i++) {
        if (i >= K) {
            S[i] = '.';
            S[i + 1] = '.';
            S[i + 2] = '.';
            S[i + 3] = '\0';
            break;
        }
    }

    cout << S;

    return 0;
}

Measured memory_bytes: 3620
// Author -> Preeyadarshee Dev
//
// train hard win easy :D
// nik is love
// nik is motivation
//
// do modulo operations very carefully
// try to avoid binary search, use linear search preferrably to make calculations easier
// always make your custom binary search and watch out for overflows
// read the problems carefully
// never rely on floating point calculation
#include<bits/stdc++.h>
#define mp                    make_pair
#define pb                    push_back
#define ll                    long long
#define ss                       second
#define ff                        first
#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0)
#define eps                   0.000000000000001
#define sz(a)                int((a).size())
#define all(c)               (c).begin(),(c).end()
#define tr(c,i)              for(typeof(c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)         ((c).find(x) != (c).end())
#define cpresent(c,x)        (find(all(c),x) != (c).end())
#define pi                   pair<int,int>
#define pll                  pair < ll , ll >
#define endl                 '\n'
#define PI                   3.141592653589793238462643383279502884197169399375105820974944592307816406286
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef vector< int > vi;
typedef vector< vi > vvi;
int dx[8]={1,-1,0,0,-1,-1,1,1};
int dy[8]={0,0,-1,1,-1,1,-1,1};
vector<int> adj[100010],adj1[100010],vis(100010,0),dis(100010,0),par(100010,0);
int myrandom (int i) { return std::rand()%i;}
long long power(long long x)
{
    long long exp=1000000005;
    long long inf=1000000007;
    long long res=1;
    while(exp)
    {
        if(exp%2)
        {
            res=((res%inf)*(x%inf))%inf;
        }
        x=((x%inf)*(x%inf))%inf;
        exp=exp/2;
    }
    return res;
}
int getSubsets(int k,int n,vector<int> a)
{
    if(k==0)
        return 1;
    int inf=1000000007;
    vector<int> visited(1000010,0),psum(1000010,0);
    for(int i=2;i<=1000000;i++)
    {
        if(visited[i]==0)
        {
            for(int j=1;j*i<=1000000;j++)
            {
                visited[j*i]=1;
                psum[j*i]+=i;
            }
        }
    }
    long long sum=0;
    for(int i=0;i<(int)a.size();i++)
    {
        sum=(sum%1000000+psum[a[i]]%1000000)%1000000;
    }
    sum=sum%1000000;
    vector<long long> v(1000010,1);
    for(long long i=1;i<=1000000;i++)
    {
        v[i]=((v[i-1]%inf)*(i%inf))%inf;
    }
    long long ans=1;
    ans=ans*v[sum+k-1];
    ans=((ans%inf)*(power(v[sum])%inf))%inf;
    ans=((ans%inf)*(power(v[k-1])%inf))%inf;
    return (int)ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //ifstream fin;
    //ofstream fout;
    //fin.open("input.txt");
    //fout.open("output.txt");
    int a;
    cin>>a;
    string s;
    cin>>s;
    if(a<3200)
    {
        cout<<"red"<<endl;
    }
    else
    {
        cout<<s<<endl;
    }
}


Measured memory_bytes: 6144
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		Tenbodai[] list = new Tenbodai[n];
		int sum = 0;

		for(int i = 0; i < n; i++) {
			list[i] = new Tenbodai(sc.nextLong());
		}

		for(int i = 0; i < m; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			list[a].edge.add(b);
			list[b].edge.add(a);
		}

		for(int i = 0; i < n; i++) {
			boolean b = true;
			List<Integer> to = list[i].edge;
			long height = list[i].height;
			for(Integer var : to) {
				if(height <= list[var].height) {
					b = false;
					break;
				}
			}
			if(b) sum++;
		}

		System.out.println(sum);

		sc.close();
	}
}

class Tenbodai{
	long height;
	List<Integer> edge;

	Tenbodai(long height){
		this.height = height;
		this.edge = new ArrayList<>();
	}
}

Measured memory_bytes: 64296
// ABC120_C
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
using ll = long long;

int main() {
    // input(sunippets: inpv, inpn)
    string S;
    cin >> S;
    
    // calculation
    // 最終的に 0, 1 どちらかだけになる
    ll zero = 0, one = 0;
    for (ll i = 0; i < S.size(); ++i) {
        if (S[i] == '0') ++zero;
        else ++one;
    }
    cout << min(zero, one)*2 << "\n";
    
    return 0;
}

Measured memory_bytes: 512
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int H, W;
char A[1000][1000];
ll DP[1000][1000] = {};

int Solve(){
  cin >> H >> W;
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      cin >> A[i][j];
    }
  }

  for (int i = 0; i < H; i++){
    if (A[i][0] == '#') break;
    DP[i][0] = 1;
  }
  for (int j = 0; j < W; j++){
    if (A[0][j] == '#') break;
    DP[0][j] = 1;
  }

  for (int i = 1; i < H; i++){
    for (int j = 1; j < W; j++){
      if (A[i][j] == '#') continue;
      DP[i][j] = DP[i - 1][j] + DP[i][j - 1];
      DP[i][j] %= nmax;
    }
  }
  
  cout << DP[H - 1][W - 1] << endl;

  return 0;
}


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


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

long long gcd(long long a,long long b){
  long long r,tmp;

  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

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

  long long sum=0;
  for (int i = 1; i <= n; i++)
  {
    for (int j = 1; j <= n; j++)
    {
      long long gcdij=gcd(i,j);
      for (int k = 1; k <= n; k++)
      {
        sum+=gcd(gcdij,k);
      }
    }
  }
  cout << sum << endl;
}

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "KharYusuf", 1 << 27);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastReader in = new FastReader(inputStream);
            PrintWriter out = new PrintWriter(outputStream);
            CRepsept solver = new CRepsept();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class CRepsept {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int k = s.nextInt(), MX = (int) 2e6;
            int cur = 7;
            for (int i = 1; i <= MX; i++) {
                if (cur % k == 0) {
                    w.println(i);
                    return;
                }
                cur *= 10;
                cur += 7;
                cur %= k;
            }
            w.println(-1);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 25980
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
//    cout << fixed << setprecision(20);
    
    int N, M;
    cin >> N >> M;

    int s[M], c[M];
    REP(i, M) {
        cin >> s[i] >> c[i];
        s[i]--;
    }

    REP(n, 1000) {
        string S = to_string(n);

        if (S.size() != N) continue;

        bool f = true;
        REP(j, M) {
            if (S[s[j]] != '0' + c[j]) {
                f = false;
                break;
            }
        }
        if (f) {
            cout << n << endl;
            return 0;
        }
    }

    cout << -1 << endl;
}


Measured memory_bytes: 256
<?php
function convNum($i){
    if( $i == 1 ){
        return 14 ;
    }else{
        return $i;
    }
}
fscanf(STDIN, "%d %d", $a ,$b);
$a = convNum($a);
$b = convNum($b);
if($a > $b){
    print "Alice" ;
}elseif( $a == $b ){
    print "Draw";
}else{
    print "Bob";
}



?>

Measured memory_bytes: 3828
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>

using namespace std;

int main(void) {

	int sum = 0;

	string str;
	cin >> str;

	int flg = 0;	//1なら1, 0なら0
	for (int i = 0; i < str.size(); i++) {
		if (str[i] == '1') sum++;
	}
	if (sum > str.size() - sum) flg = 1;

	sum = 0;


	int kiri = flg;
	kiri = (int)(str[0] - '0');
	for (int i = 0; i < str.size(); i++) {
		int test = (int)(str[i] - '0');
		if ( test == kiri) {
			//none;
		}
		else {
			sum++;
		}
		kiri = kiri^1;
	}

	cout << sum << endl;

	return 0;
}

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

using namespace std;

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

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

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

    bool ans = false;
    if(c>=a && c<=b)ans=true;

    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3596
#include <map>
#include <list>
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
string s;
int main()
{
    fast; 
    cin>>s;
    if (s[0]==s[2])
       cout<<"Yes"<<endl;
    else
       cout<<"No"<<endl;
    return 0;
}

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

int main() {
long long n,m;
cin >> m >> n;

  
if(m==1||n==1)
{
  cout << 1;
}
 else if((m*n)%2==0)
{
cout << m*n/2;
}
  else
  {
    cout << (m*n+1)/2;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        if (B <= A) {
            System.out.println("delicious");
        }else if (B <= A + X){
            System.out.println("safe");
        }else{
            System.out.println("dangerous");
        }
    }
}


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


class UnionFind:
    def __init__(self, size):
        self.parent = [-1] * size
        self.rank = [1] * size
        self.groups = size

    def get_root(self, node):
        parent = self.parent[node]
        if parent == -1:
            root = node
        else:
            root = self.get_root(parent)
            self.parent[node] = root  # 同じnodeへの2回目以降のget_rootを高速にするために、直接rootに繋いでおく
        return root

    def unite(self, node1, node2):
        main_root = self.get_root(node1)
        sub_root = self.get_root(node2)
        if main_root == sub_root:
            return
        if self.rank[main_root] < self.rank[sub_root]:  # rankの大きい方をmain_rootにする
            main_root, sub_root = sub_root, main_root

        self.parent[sub_root] = main_root
        self.rank[main_root] += self.rank[sub_root]
        self.groups -= 1


n, m = map(int, input().split())
uf = UnionFind(n)

for i in range(m):
    x, y, z = map(int, input().split())
    x -= 1
    y -= 1
    uf.unite(x, y)

print(uf.groups)


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

using namespace std;

int n;
long long k;
vector<long long> neg, pos;
int zer = 0;

long long checkNeg(long long x){
	x = -x;

	long long ret = 0;
	for(auto &k : neg){
		ret += (pos.end() - lower_bound(pos.begin(), pos.end(), (x + k - 1) / k));
	}

	return ret;
}

long long checkPos(long long x){
	long long ret = 0;

	for(int i = 0; i < (int) pos.size(); i++){
		ret += (upper_bound(pos.begin() + i + 1, pos.end(), x / pos[i]) - pos.begin()) - (i + 1);
	}

	for(int i = 0; i < (int) neg.size(); i++){
		ret += (upper_bound(neg.begin() + i + 1, neg.end(), x / neg[i]) - neg.begin()) - (i + 1);
	}

	return ret;
}

int main(){
	scanf("%d%lld", &n, &k);

	for(int i = 1; i <= n; i++){
		int x; scanf("%d", &x);

		if(x == 0) zer++;
		else if (x > 0) pos.emplace_back(x);
		else neg.emplace_back(-x);
	}

	long long nega = (long long) pos.size() * neg.size();

	if(k <= nega){
		sort(neg.rbegin(), neg.rend());
		sort(pos.begin(), pos.end());

		long long l, r;

		l = -1e18, r = -1;

		while(l <= r){
			long long m = (l + r) >> 1;

			if(checkNeg(m) < k) l = m + 1;
			else r = m - 1;
		}

		printf("%lld\n", l);
	} else if (k <= nega + 1LL * zer * (n - zer) + 1LL * zer * (zer - 1) / 2){
		printf("0\n");
	} else {
		k -= nega + 1LL * zer * (n - zer) + 1LL * zer * (zer - 1) / 2;

		sort(pos.begin(), pos.end());
		sort(neg.begin(), neg.end());

		long long l, r;

		l = 1, r = 1e18;

		while(l <= r){
			long long m = (l + r) >> 1;

			if(checkPos(m) < k) l = m + 1;
			else r = m - 1;
		}

		printf("%lld\n", l);
	}
	
	return 0;
}

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

int main(){
    vector<string> w = {"Sunny", "Cloudy", "Rainy"};
    string s;

    cin >> s;
    for (int i = 0; i < 3; i++)
    {
        if(w[i]==s){
            cout << w[(i + 1)%3] << endl;
        }
    }
     return 0;
}

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

int main() {
  int n;
  cin >> n ;
  vector<int> mati(n+1);
  vector<int> yusya(n);

  for (int i=0 ;i<n+1 ;i++){
    cin >> mati.at(i) ;
  }
  for (int i=0 ;i<n ;i++){
    cin >> yusya.at(i) ;
  }
  long int count=0;

  for (int i=0 ;i<n ;i++){
    if(mati.at(i)<=yusya.at(i))
    {
      yusya.at(i)-=mati.at(i);
      count+=mati.at(i);

      if(mati.at(i+1)<=yusya.at(i)){
        count+=mati.at(i+1);
        mati.at(i+1)=0;
      }
      else{
        count+=yusya.at(i);
        mati.at(i+1)-=yusya.at(i);
      }
    }
    else
    {
      count+=yusya.at(i);
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 1024