akhauriyash/Code-Regression huggingface dataset:
#include"iostream"
#include"string"
#include"vector"
using namespace std;

int main()
{
	int n;
	cin >> n;
	bool ans = true;
	vector<string> w(110);
	for (int i = 0; i < n; i++)
	{
		cin >> w[i];
		for (int j = 0; j < i; j++)
		{
			if (w[j] == w[i])ans = false;
		}
		if (i > 0 && w[i-1].back() != w[i].front())ans = false;
	}
	cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b) {
		printf("a < b\n");
	}
	else if(a>b) {
		printf("a > b\n");
	}
	else {
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
import math
import queue

mod = 1e9+7

def swap(a,b):
    return (b,a)

def gcd(a,b):
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def divisors(a):
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def main():
    s = input()
    t = input()
    ans = 0
    for i in range(len(s)):
        if s[i]==t[i]:
            ans += 1
    print(ans)
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 38508
/*input
5 8
5 3
2 3
2 4
5 2
5 1
1 4
4 3
1 3
*/

//sometimes it's the people who no one imagines anything of 
//who do the things that no one can imagine.

//code author: iamxlr8

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define N 300005
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll n,m,u,v;
vector<vector<ll> >g;
vector<ll> dp;
vector<ll> vis;

void dfs(ll v)
{
    if(vis[v])
        return;
    vis[v]=1;
    for(auto to:g[v])
    {
        dfs(to);
        dp[v]=max(dp[v],dp[to]+1);
    }
}

int main() 
{
    off;
    cin>>n>>m;
    g=vector<vector<ll> >(n+1);
    dp=vector<ll>(n+1);
    vis=vector<ll>(n+1);
    fill(dp.begin(),dp.end(),0);
    fill(vis.begin(),vis.end(),0);
    for(ll i=0;i<m;i++)
    {
        cin>>u>>v;
        g[u].push_back(v);
    }
    for(ll i=1;i<=n;i++)
    {
        if(!vis[i])
            dfs(i);
    }
    cout<<*max_element(dp.begin(),dp.end());
    return 0;
}

Measured memory_bytes: 9344
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

N = int(input())
An = [int(input()) for i in range(N)]
Asort = sorted(An, reverse=True)

for A in An:
    if A != Asort[0]:
        print(Asort[0])
    else:
        print(Asort[1])


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

using namespace std;

using dijkstra_cost = long long;
template<class V, class E>
struct Graph
{
	int sz;
	vector<V> v;
	vector<vector<E>> e;
	Graph(int n) : sz(n), v(n), e(n) {}
	template<class... Args>
	inline void assign_vertex(int pos, Args... args) {
		v[pos] = V(args...);
	}
	template<class... Args>
	inline void add_edge(int pos, Args... args) {
		e[pos].emplace_back(args...);
	}
	inline int size() {
		return sz;
	}
};

template<class T>
struct Vertex
{
	T cost;
	Vertex(T v1) : cost(v1) {}
	Vertex() {}
};
using vertex = Vertex<dijkstra_cost>;

template<class T>
struct Edge
{
	int to;
	T cost;
	Edge(int t, T c) : to(t), cost(c) {}
	Edge() {}
};
using edge = Edge<dijkstra_cost>;
using graph = Graph<vertex, edge>;

template<class V, class E>
void Dijkstra(Graph<V, E>& G, int s, dijkstra_cost INF_COST)
{
	auto &v = G.v;
	auto &e = G.e;
	for (auto& vv : v) vv.cost = INF_COST;
	using Q_T = pair<dijkstra_cost, int>;
	priority_queue<Q_T, vector<Q_T>, greater<>> q;
	q.emplace(0, s);
	while (!q.empty()) {
		auto a = q.top();
		q.pop();
		if (a.first >= v[a.second].cost) continue;
		v[a.second].cost = a.first;
		for (auto& p : e[a.second]) {
			if (p.cost == INF_COST) continue;
			if (a.first + p.cost < v[p.to].cost) q.emplace(a.first + p.cost, p.to);
		}
	}
}

int main() {
	int n, m, s, t;
	cin >> n >> m >> s >> t;
	s--;t--;
	graph g1(n);
	graph g2(n);
	for (int i = 0; i < m; i++) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		g1.add_edge(a-1, b-1, c);
		g1.add_edge(b-1, a-1, c);
		g2.add_edge(a-1, b-1, d);
		g2.add_edge(b-1, a-1, d);
	}
	Dijkstra(g1, s, LLONG_MAX);
	Dijkstra(g2, t, LLONG_MAX);
	auto& v1 = g1.v;
	auto& v2 = g2.v;
	vector<long long> res(n, 0);
	for (int i = 0; i < n; i++) {
		res[i] = (long long) 1e15 - v1[i].cost - v2[i].cost;
	}
	for (int i = n-2; i >= 0; i--) {
		res[i] = max(res[i+1], res[i]);
	}

	for (int i = 0; i < n; i++) {
		cout << res[i] << endl;
	}
}

Measured memory_bytes: 19000
'use strict'
 
function main(n) {
  let N = new Set(n.split("\n")[0].split("").sort());
  const alphabets = 'abcdefghijklmnopqrstuvwxyz'.split('');
  let ans = "None";
  rooptag:
  for(let n = 0; n < N.size; n++ ){
    for(let m = 0; m < alphabets.length; m++){
      if(!N.has(alphabets[m])){
      	ans = alphabets[m];
        break rooptag;
      }
    }
  }
  
  console.log(ans);
}

 
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 15640
x,n=map(int, input().split())
ans=x
judge=True
if(n!=0):
  p=list(map(int, input().split()))
else:
  ans=x
  judge=False
  
if(n==1):
  if(x==p[0]):
    ans = x-1
    judge=False

if(judge):
  check=True
  s_list=[]
  l_list=[]
  for i in range(n):
    for j in range(n):
      if(x-i==p[j]):
        check=False
    if(check):
      s_list.append(x-i)
    check=True

    for i in range(n):
      for j in range(n):
        if(x+i==p[j]):
          check=False
      if(check):
        l_list.append(x+i)
      check=True
    if(l_list == []):
      ans = max(s_list)
    if(s_list == []):
      ans = min(l_list)
    else:
      if(abs(x-min(l_list)) > abs(x-max(s_list))):
        ans = max(s_list)
      elif(abs(x-min(l_list))==abs(x-max(s_list))):
        ans=max(s_list)
      else:
        ans=min(l_list)  

print(ans)

Measured memory_bytes: 9056
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int vec[N][3];
  for(int i=0; i<N; i++){
    for(int j=0; j<3; j++){
      cin >> vec[i][j];
    }
  }
  
  int dp[N][3];
  for(int i=0; i<3; i++){
    dp[0][i] = vec[0][i];
  }
  for(int i=1; i<N; i++){
    dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + vec[i][0];
    dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + vec[i][1];
    dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + vec[i][2];
  }
  cout << max({dp[N-1][0], dp[N-1][1], dp[N-1][2]}) << endl;
}

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

string Sp, T;

int main() {
	cin >> Sp >> T;

	bool flag;
	for (int i = Sp.length() - 1; i >= 0; i--) {
		if (i < T.length() - 1) break;

		flag = true;
		for (int j = 0; j < T.length(); j++) {
			if (!(Sp[i - (T.length() - 1) + j] == T[j] || Sp[i - (T.length() - 1) + j] == '?')) {
				flag = false;
				break;
			}
		}
		if (flag) {
			for (int j = 0; j < T.length(); j++) {
				Sp[i - (T.length() - 1) + j] = T[j];
			}
			break;
		}
	}

	if (flag) {
		for (int i = 0; i < Sp.length(); i++) {
			if (Sp[i] == '?') Sp[i] = 'a';
		}
		cout << Sp << endl;
	}
	else {
		cout << "UNRESTORABLE" << endl;
	}
}

Measured memory_bytes: 764
import java.util.Scanner;
public class Main {
	static String[] c = {"a", "b", "c"};
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n =Integer.parseInt(sc.next());
		int[] a = new int[100003];
		for (int i = 0; i < n; i++) {
			int b = Integer.parseInt(sc.next());
			a[Math.max(0, b - 1)]++;
			a[b + 2]--;
		}
		int max = 0;
		for (int i = 1; i <= 100000; i++) {
			a[i] += a[i - 1];
			if (a[i] > max)
				max = a[i];
		}
		System.out.println(max);
	}

}

Measured memory_bytes: 46912
#include <algorithm>
#include <climits>
#include <iostream>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;

#define loop(i, times) for(int i = 0; i < times; i++)
#define seloop(i, start_index, end_index) for(int i = start_index; i < end_index; i++)
#define eqseloop(i, start_index, end_index) for(int i = start_index; i <= end_index; i++)

long Sum(vector<pair<int, int>>& collection, int min_index, int max_index)
{
	long sum = 0;
	for (int i = min_index; i < max_index; i++)
		sum += get<0>(collection[i]);
	return sum;
}

int main()
{
	int n; cin >> n;
	vector<int> odd_collection(n / 2, 0), even_collection(n / 2, 0);

	loop(i, n / 2)
	{	// 偶数番目と奇数番目の入力を保存
		cin >> odd_collection[i];
		cin >> even_collection[i];
	}

	vector<pair<int, int>> count_odd_collection;
	count_odd_collection.resize(100001);
	for (const auto& e : odd_collection)
	{	// 偶数数列の同じ要素をカウントする
		get<0>(count_odd_collection[e])++;
		get<1>(count_odd_collection[e]) = e;
	}
	sort(count_odd_collection.begin(), count_odd_collection.end(), greater<pair<int, int>>());

	vector<pair<int, int>> count_even_collection;
	count_even_collection.resize(100001);
	for (const auto& e : even_collection)
	{	// 奇数数列の同じ要素をカウントする
		get<0>(count_even_collection[e])++;
		get<1>(count_even_collection[e]) = e;
	}
	sort(count_even_collection.begin(), count_even_collection.end(), greater<pair<int, int>>());

	long min = 0;
	if (get<1>(count_odd_collection[0]) == get<1>(count_even_collection[0]))
	{	// 例外処理その１「偶数数列と奇数数列で出現頻度が最も高い数字が同じ時」
		if (get<0>(count_odd_collection[1]) < get<0>(count_even_collection[1]))
		{
			min += Sum(count_odd_collection, 1, count_odd_collection.size());
			min += get<0>(count_even_collection[0]);
			min += Sum(count_even_collection, 2, count_even_collection.size());
		}
		else
		{
			min += get<0>(count_odd_collection[0]);
			min += Sum(count_odd_collection, 2, count_odd_collection.size());
			min += Sum(count_even_collection, 1, count_even_collection.size());

		}
	}
	else
	{	// 通常処理　出現頻度が最も高い数字に置き換えれば答えになる
		min += Sum(count_odd_collection, 1, count_odd_collection.size());
		min += Sum(count_even_collection, 1, count_even_collection.size());
	}

	// 例外処理その２「偶数数列と奇数数列が全て同じ数字のとき」
	// 数列を個別に見れば置き換え回数はゼロだが、実際は片方の数列を全て置き換える必要がある
	if (min == 0 && odd_collection[0] == even_collection[0])
		min = n / 2;

	cout << min;

	return 0;
}


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

using namespace std;

int main(){
	int n, i=0;
	string s;
	cin >> n;
	cin >> s;
	s.shrink_to_fit();
	while(i<s.length()){
		s[i] = s[i] + (char)n;
		if(s[i]>90){
			s[i] -= 26;
		}
		i++;
	}
	cout << s << endl;
	return 0;
}

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

int gcd2 (int a, int b) {
    if (a < b) {
        swap(a, b);
    }
    while (a % b > 0) {
        int r = a % b;
        a = b;
        b = r;
    }
    return b;
}

int gcd3 (int a, int b, int c) {
    return gcd2(a, gcd2(b, c));
}

int main(){
    long K;
    long ans = 0;
    cin >> K;
    for (int a = 1; a <=K; ++a){
        for (int b = 1; b <= K; ++b){
            for (int c = 1; c <= K; ++c){
                ans += gcd3(a, b, c);
            }
        }
    }
    cout << ans << endl;
}




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

#define pb push_back
#define fi first
#define se second
#define eb emplace_back

using namespace std;
typedef pair<int, int> ii;
typedef long long ll;

const int M = 1000000007;


ll pa(ll a, ll b) {
    return (a + b) * (b - a + 1)/2;
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, k; cin >> n >> k;

    ll tot = 0;

    for(int i = k; i <= n + 1; ++i) {
        // 0 + 1 + 2 (k vezes)
        ll l = pa(0, i-1);
        ll r = pa(n - i + 1, n);
        assert(r >= l);
        tot += r - l + 1;
    }

    cout << tot%M << endl;
}

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

using namespace std;

int a[2019], b[2019];

int main()
{
    long long ans = 0LL;
    char g = getchar();
    while (g > '0' && g <= '9')
    {
        int x = g - '0';
        ++b[x];
        for (int i = 0; i < 2019; ++i)
            b[(i * 10 + x) % 2019] += a[i];

        ans += 1LL * b[0];
        for (int i = 0; i < 2019; ++i)
            a[i] = b[i], b[i] = 0;
        g = getchar();
    }
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 3752
n = int(input())
s = "abcdefghij"

class Node:
    __slots__ = ["string", "index"]
    def __init__(self, string, index):
        self.string = string
        self.index = index

    def get_children(self):
        parent = self.string
        out = [None]*(self.index+1)
        for i, c in enumerate(s[:self.index]):
            out[i] = Node(parent+c, self.index)
        out[i+1] = Node(parent+s[self.index], self.index+1)
        return out

root = Node("a", 1)
children = [root]
for _ in range(n-1):
    parents, children = children, []
    for parent in parents:
        children.extend(parent.get_children())
for child in children:
    print(child.string)

Measured memory_bytes: 21848
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define inf 100000000000000000
#define mod 1000000007
#define MAX 1000005
#define MAX2 1005
#define pb push_back
#define mp make_pair
#define vit vector<int>::iterator
typedef pair<lint,lint> pii;
map<lint,lint>M;

lint fact[MAX+1],ifact[MAX+1];
void nCr2_pre(void){ /// O(N) ; all ncr; N<=10^6; m must be prime and m>N;
    fact[0]=fact[1]=ifact[0]=ifact[1]=1;
    for(lint i=2;i<=MAX;i++){
        fact[i]=(fact[i-1]*i)%mod;
        ifact[i]=(mod-((mod/i)*ifact[mod%i])%mod)%mod;
    }
    for(lint i=2;i<=MAX;i++){
        ifact[i]=(ifact[i-1]*ifact[i])%mod;
    }
}
lint nCr2(lint n,lint r){
    if(n<r) return 0;
    else return ((fact[n]*ifact[r])%mod *ifact[n-r])%mod;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    lint n,m,ans,sn;
    nCr2_pre();
    cin>>n>>m;
    ans=(nCr2(m,n)*fact[n])%mod;
    for(lint i=1;i<=n;i++){
        if(i%2) sn=-1;
        else sn=1;
        lint cr=((nCr2(n,i)*nCr2(m-i,n-i))%mod*fact[n-i])%mod;
        ans=((ans+sn*cr)%mod+mod)%mod;
    }
    cout<<((ans*fact[n])%mod*nCr2(m,n))%mod;
    return 0;
}



Measured memory_bytes: 19268
#include<stdio.h>
int main()
{
  int n,r[100],c[100][100];
  int i,j,k,l,m;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&r[i],&j);
  }
  r[n]=j;
  for(i=1;i<=n;i++){
    c[i][i]=0;
  }
    
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j =i+l-1;
      c[i][j]=1000000;
      for(k=i;k<=j-1;k++){
	m=c[i][k]+c[k+1][j]+(r[i-1]*r[k]*r[j]);
      
	if(c[i][j]>m){
	  c[i][j]=m;
	}
      }
    }
  }
  printf("%d\n",c[1][n]);
  
  return 0;
}

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

using namespace std;

#define int long long
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cint int t;cin>>t;while(t--)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define vint vector<int>
#define all(v) (v).begin(), (v).end()
#define pii pair<int,int>
#define pb push_back
const int N=1e5+5;



int32_t main() {
    faster;

    int n,x,y;
    cin>>n>>x>>y;

    int a[n+1]={};
    int ans=0;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            int tmp=min(j-i,abs(x-i)+1+abs(y-j));
            if(j-i<=n-1){
                a[tmp]++;
            }
        }
    }

    for(int i=1;i<=n-1;i++){
        cout<<a[i]<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define eps 1e-3
#define pi acos(-1.0)
#define inf 0x3f
#define INF 0x3f3f3f3f
#define pb push_back
#define debug1 cout<<"&&";
#define debug2 cout<<"**";
#define ms(a, x) memset(a, x, sizeof(a))
#define for0(i, n) for(int i = 0; i < n; ++i)
#define for1(i, n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, int> pli;
typedef pair<long long, long long> pll;
const int mod = 1e9 + 7;
const int N = 1e5+10;
const int M = 1e6+10;
/*=================================================================================*/

ll n, m, q, ans;
int a[N], b[N], c[N], d[N], A[N];

void last() {
   ll maxn = 0;
   for1(i, q) {
      if(A[b[i]] - A[a[i]] == c[i]) maxn += d[i];
   }
   ans = max(ans, maxn);
}

void dfs(int a, int b) {
   if(a==n+1) {
      last(); return;
   }
   for(int i = b; i<=m; ++i) {
      A[a] = i;
      dfs(a+1, i);
   }
}

int main() {
   cin>>n>>m>>q;
   for1(i, q) scanf("%d%d%d%d", &a[i], &b[i], &c[i], &d[i]);
   dfs(1,1);
   cout<<ans;
}

Measured memory_bytes: 3620
import math

a, b, h, m = map(int, input().split())

x_1 = a * math.cos(-h * math.pi / 6 - m * math.pi / 360)
y_1 = a * math.sin(-h * math.pi / 6 - m * math.pi / 360)

x_2 = b * math.cos(-m * math.pi / 30)
y_2 = b * math.sin(-m * math.pi / 30)

print(((x_2 - x_1) ** 2 + (y_2 - y_1) ** 2) ** 0.5)

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

int main(){
    int n;
    cin >> n;
    vector<double> v(n, 0);
    rep(i, n){
        cin >> v.at(i);
    }
    sort(v.begin(), v.end());
    rep(i, n-1){
        v.at(i+1) = 1.0 * (v.at(i) + v.at(i+1))/2;
    }
    cout << v.at(n-1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(){
  string O, E;
  cin >> O >> E;
  int l = O.size() + E.size();
  int ocntr = 0;
  int ecntr = 0;
  string ans;
  for(int i = 1; i <= l; i++){
    if(i % 2 == 0){
      ans.push_back(E[ecntr]);
      ecntr++;
    }else{
      ans.push_back(O[ocntr]);
      ocntr++;
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

int N,K;
string S;
int main(){
    cin>>N>>K>>S;
    S[K-1]-='A'-'a';
    cout<<S;
    return 0;
}

Measured memory_bytes: 256
const inp = require('fs').readFileSync('/dev/stdin', 'utf8').split(/\n/);
let num = Number(inp[0]);
let input = inp[1].split(' ').map(Number);
let minj = 0;
let count = 0;
let tmp;
function selectionSort(A, N) {
    for (let i=0; i<=N-1; i++) {
        minj = i 
       for (let j=i; j<=N-1; j++) {
           if (A[j] < A[minj]) {
                minj = j;
           }
       }
            if (A[i] != A[minj]) {
              tmp = A[i];
             A[i] = A[minj];
             A[minj] = tmp;
             count++
            }
       }
    }


selectionSort(input, num);
console.log(input.join(' '));
console.log(count);
 


Measured memory_bytes: 15320
use std::io::BufRead;

fn main() {
    let mut mat = read_spread_sheet();
    let mut sum_vec = Vec::new();
    for i in 0..mat[0].len() {
        let mut sum = 0;
        for vec in &mut mat {
            sum += vec[i];
        }
        sum_vec.push(sum);
    }
    mat.push(sum_vec);
    for vec in &mut mat {
        let sum = vec.iter().sum();
        vec.push(sum);
    }
    for vec in mat {
        let mut s = String::new();
        for i in vec {
            s.push_str(&format!("{} ",i));
        }
        s.pop();
        println!("{}", s);
    }
}

fn read_spread_sheet() -> Vec<Vec<isize>> {
    let mut mat = Vec::new(); 
    let handle = std::io::stdin();
    let mut buf = String::new();
    handle.lock().read_line(&mut buf).unwrap();
    let number_of_rows: Vec<usize> = buf.split_whitespace()
        .map(|a| a.parse().unwrap()).collect();
    for line in handle.lock().lines().filter_map(|a| a.ok()).take(number_of_rows[0]) {
        let mut v: Vec<isize> = line.split_whitespace()
            .map(|a| a.parse().unwrap()).collect();
        mat.push(v);
    }
    mat
}


Measured memory_bytes: 5064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll mod = 1e9 + 7;
 
int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}
 
ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

bool is_prime(long long N){
    if (N == 1) return false;
    for (long long i = 2;i * i <= N;i++){
        if (N % i == 0) return false;
    }
    return true;
}
 
ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}
 
double DegreeToRadian(double degree){
    return degree * M_PI / 180.0;
}
 
 
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
 
 
///////////////////////////////////////////////////////////////////////////////////

int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> a(n+1);
    for (int i = 0;i < m;i++){
        int x,y;
        cin >> x >> y;
        a[x].push_back(y);
        a[y].push_back(x);
    }

    for (auto nx : a[1]){
        for (auto v : a[nx]){
            if (v == n){
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }

    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 15100
import sys
(k,n)=map(int,input().split())
a=input().split()
n-=1
j=int(a[n])-int(a[0])
l=0
for i in range(n):
  l=int(a[(n+i+1)%(n+1)])+k-int(a[i+1])
  if(j>l):
    j=l
print(j)

Measured memory_bytes: 18500
# coding: utf-8
# Your code here!
L, R = map(int, input().split())
ans = 2019
for i in range(L, R):
    for j in range(i + 1, R + 1):
        if i * j % 2019 < ans:
            ans = i * j % 2019
        if ans == 0:
            break
    if ans == 0:
        break
print(ans)
     

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

int main() 
{
    int a, b, x, y;
    cin >> a >> b >> x >> y;
    double ans1 = double(a)*double(b) / 2; // rectangle can always be halved
    int ans2 = (x+x == a && y+y == b); // checks if (x,y) is the center
    cout << setprecision(6) << ans1;
    cout <<  " " << ans2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(12)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define test int t; cin >> t; while(t--)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

void solve() {
	int n, k, cnt = 0;
	cin >> n >> k;
	string s;
	cin >> s;
	for (int i = 0, j; i < sz(s); i = j) {
		for (j = i + 1; j < sz(s) && s[j] == s[i]; j++);
		cnt++;
	}
	cnt = max(1ll, cnt - 2 * k);
	cout << n - cnt;
}

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

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

#define TEST 0

	if (TEST) {
		test;
		solve();
	} else {
		solve();
	}

	return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

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() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	ll n, k;
	cin >> n >> k;

	n %= k;
	ll ans = min(n, abs(n - k));

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

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    char s[10];
    int c = 1;
    int i = 0;
    
    scanf("%s",s);
    while (s[i]){
        if (!((i%2 == 0 && s[i] == 'h') || (i%2 == 1 && s[i] == 'i'))){
            c = 0;
            break;
        }
        i++;
    }
    if (c == 1 && i%2 == 0){
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
n = int(input())
A = list(map(int, input().split()))
flag=1
count=0
while flag:
    flag=0
    j=1
    while j < n:
        if A[j]<A[j-1]:
            A[j], A[j-1]=A[j-1], A[j]
            count+=1
            flag=1
        j+=1

print(" ".join(list(map(str, A))))
print(count)


Measured memory_bytes: 5600
#include<iostream>
#include<assert.h>

using namespace std;

void hoge(int N){

   int M;
   cin>> M;
   int X[M], Y[M];
   for(int i=0; i<M; i++) cin>> X[i]>> Y[i];
   for(int n=0; n<N; n++){
      int m;
      cin>> m;
      int x[m], y[m];
      for(int i=0; i<m; i++) cin>> x[i]>> y[i];
      if(m!=M) continue;
      bool okok=false;
      for(int k=0; k<4; k++){
         for(int i=0; i<M; i++){
            swap(X[i], Y[i]);
            X[i]=-X[i];
         }
         bool ok=true;
         for(int i=0; i+1<m; i++){
            ok&=(x[i+1]-x[i]==X[i+1]-X[i]);
            ok&=(y[i+1]-y[i]==Y[i+1]-Y[i]);
         }
         bool rev=true;
         for(int i=0, j=m-1; i+1<m, j>0; i++, j--){
            rev&=(x[i+1]-x[i]==X[j-1]-X[j]);
            rev&=(y[i+1]-y[i]==Y[j-1]-Y[j]);
         }
         okok|=(ok||rev);
      }
      if(okok){
         cout<< n+1<< endl;
      }
   }
}

int main(){

   while(1){
      int N;
      cin>> N;
      if(!N) break;
      hoge(N);
      cout<< "+++++"<< endl;
   }

   return 0;
}

Measured memory_bytes: 3016
#include <iostream>
#include <algorithm>
#include <string>
#include <unordered_map>
#include <deque>
#include <array>
#include <cmath>

using namespace std;

int main()
{
  long long n, k;

  cin >> n >> k;

  long long res = n % k;

  if (res != 0)
  {
    res = min(res, abs(k - res));
  }

  cout << res << endl;

  return 0;
}

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

#define M 1000000
#define INF 10000000

#define min(a,b) (a<b?a:b)

int main() {
	int n, p;
	vector<int> fn, fno;
	static int dp[M+1], odp[M+1];
	for(int i=1;; ++i) {
		p = i*(i+1)*(i+2)/6;
		if(p>M) break;
		fn.push_back(p);
		if(p%2) fno.push_back(p);
	}
	for(int i=0; i<=M; ++i) dp[i] = odp[i] = INF;
	dp[0] = 0; dp[1] = 1; odp[0] = 0; odp[1] = 1;
	for(int i=2; i<=M; ++i) {
		for(int j=0; j<(signed)fn.size(); ++j) {
			if(i-fn[j]>=0) dp[i] = min(dp[i], dp[i-fn[j]]+1);
			else break;
		}
		for(int j=0; j<(signed)fno.size(); ++j) {
			if(i-fno[j]>=0) odp[i] = min(odp[i], odp[i-fno[j]]+1);
			else break;
		}
	}
	
	while(1) {
		cin >> n;
		if(!n) break;
		cout << dp[n] << " " << odp[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 9032
#include <iostream>
#include <cmath>
#include <string>
using namespace std;

long long str2int(string S) {
    long long ret = 0;
    int digit = S.length();
    for (int i = 0; i < digit; i++) {
        ret += (S[i] - '0') * pow(10, digit - 1 - i);
    }
    return ret;
}

int main() {
    // 入力を文字列として受け取る
    string S; cin >> S;

    // "(文字列の長さ)-1" をl(Lengthの略)とする．
    int l = S.length() - 1;

    // 長さ(l+1)の文字列の間に+を挿入する時，
    // 挿入の仕方は2のl乗通りある．
    // その通り数をNとする．
    int N = 1 << l;

    // 答え
    long long ans = 0;

    // 二進数を使って全探索を行う
    // 整数を二進数表示した時に"1"の場所に+を挿入すると考える
    // +を挿入する位置をflags変数として探索する．
    for (int flags = 0; flags < N; flags++) {
        // 一時変数(temporary)
        string tmp = "";
        for (int j = 0; j < l; j++) {
            tmp += S[j];
            if ((flags >> j & 1) == 1) {
                ans += str2int(tmp);
                tmp = "";
            }
        }
        tmp += S[l];
        ans += str2int(tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    #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
        

fast();
//ll t;cin>>t;while(t--)
{
  ll x,y;
  cin>>x>>y;
  if(y<x*2||y>x*4||y&1)
    No
    else
    {
       Yes
    }  
}
return 0;
}

Measured memory_bytes: 3592
def resolve():
    import sys
    input = sys.stdin.readline
    # row = [int(x) for x in input().rstrip().split(" ")]
    # n = int(input().rstrip())
    # s = input().rstrip()

    a = int(input().rstrip())
    b = int(input().rstrip())

    if a > b:
        print("GREATER")
    elif a < b:
        print("LESS")
    else:
        print("EQUAL")

if __name__ == "__main__":
    resolve()


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

int check[300] = {};
int main() {
	while (1) {
		for (int i = 0; i < 300; i++) check[i] = 2;
		int a, b, c;
		cin >> a >> b >> c;
		if (a == 0 && b == 0 && c == 0) return 0;
		int x;
		cin >> x;
		vector<vector<int>> list;
		for (int i = 0; i < x; i++) {
			int t1, t2, t3, t4;
			cin >> t1 >> t2 >> t3 >> t4;
			if (t4) {
				check[t1 - 1] = 1;
				check[t2 - 1] = 1;
				check[t3 - 1] = 1;
			}
			else {
				vector<int> tmp(3);
				tmp[0] = t1 - 1;
				tmp[1] = t2 - 1;
				tmp[2] = t3 - 1;
				list.push_back(tmp);
			}
		}

		for (int i = 0; i < list.size(); i++) {
			int cnt = 0;
			vector<int> tmp;
			for (int j = 0; j < 3; j++) {
				if (check[list[i][j]] == 1) cnt++;
				else {
					if (check[list[i][j]] == 2) tmp.push_back(list[i][j]);
				}
			}
			if (cnt == 2) {
				for (int j = 0; j < tmp.size(); j++) {
					check[tmp[j]] = 0;
				}
			}
		}

		for (int i = 0; i < a + b + c; i++) cout << check[i] << endl;
	}
}

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

int ans(int x,int y) {
  int p=x+y;
  int q=x-y;
  int r=x*y;
  int s=0;
  if(p>=q && p>=r) s=p;
  if(q>=p && q>=r) s=q;
  if(r>=p && r>=q) s=r;
  return s;
}
int main() {
  int a,b;
  cin >> a >> b;
  cout << ans(a,b) << endl;
  return 0;
}
  
    


Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

int main() 
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
    else if(a <= c && c <= b)
        cout << a << " " << c << " " << b << endl;
    else if(b <= a && a <= c)
        cout << b << " " << a << " " << c << endl;
    else if(b <= c && c <= a)
        cout << b << " " << c << " " << a << endl;
    else if(c <= a && a <= b)
        cout << c << " " << a << " " << b << endl;
    else if(c <= b && b <= a)
        cout << c << " " << b << " " << a << endl;
}


Measured memory_bytes: 3088
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int odd[100001];
int even[100001];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int v;
		cin >> v;
		if (i % 2 == 0) {
			even[v]++;
		}
		else {
			odd[v]++;
		}
	}
	int o1 = 0, o2 = 0;
	int e1 = 0, e2 = 0;
	for (int i = 1; i <= 100000; i++) {
		if (even[i] >= even[e1]) {
			e2 = e1;
			e1 = i;
		}
		else if (even[i] >= even[e2]) {
			e2 = i;
		}
		if (odd[i] >= odd[o1]) {
			o2 = o1;
			o1 = i;
		}
		else if (odd[i] >= odd[o2]) {
			o2 = i;
		}
	}
	if (o1 == e1) {
		cout << min((n / 2 - odd[o1]) + (n / 2 - even[e2]), (n / 2 - odd[o2]) + (n / 2 - even[e1])) << endl;
	}
	else {
		cout << (n / 2 - odd[o1]) + (n / 2 - even[e1]) << endl;
	}
}

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

int main() {
	int n, m;
	vector<int64_t> a, b;
	vector<int64_t> c, d;

	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		int64_t a_i, b_i;
		cin >> a_i >> b_i;
		a.push_back(a_i);
		b.push_back(b_i);
	}
	for (int i = 0; i < m; i++) {
		int64_t c_i, d_i;
		cin >> c_i >> d_i;
		c.push_back(c_i);
		d.push_back(d_i);
	}

	for (int i = 0; i < n; i++) {
		int64_t min_i = 0;
		int64_t min_d = abs(a[i] - c[0]) + abs(b[i] - d[0]);

		for (int j = 1; j < m; j++) {
			int64_t tmp_d = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if (tmp_d < min_d) {
				min_d = tmp_d;
				min_i = j;
			}
		}
		cout << min_i + 1 << endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

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

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 100000;

#define MAX 110

/*

##
#
0 2

 #
##
1 3

###
2 12

#
#
#
3 03

*/

signed main() {
	int dp[MAX + 1][MAX + 1][4] = {};
	dp[2][0][3] = 1;
	dp[1][1][0] = 1;
	dp[1][1][1] = 1;
	dp[0][2][2] = 1;
	rep(i, 0, MAX)rep(j, 0, MAX) {
		rep(k, 0, 4)dp[i][j][k] %= MOD;
		dp[i][j + 1][2] += dp[i][j][0];
		dp[i + 1][j][3] += dp[i][j][1];
		dp[i][j + 1][2] += dp[i][j][2];
		dp[i + 1][j][1] += dp[i][j][2];
		dp[i][j + 1][0] += dp[i][j][3];
		dp[i + 1][j][3] += dp[i][j][3];
	}
	//rep(i, 0, 3)rep(j, 0, 4) {
	//	int ans = 0;
	//	cerr << i + 1 << " " << j + 1;
	//	rep(k, 0, 4)cerr << " " << dp[i][j][k];
	//	cerr << endl;
	//}
	for (int w, h; cin >> w >> h&&w;) {
		int ans = 0;
		rep(k, 0, 4)ans += dp[h - 1][w - 1][k];
		ans %= MOD;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3296
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int64_t n;
  cin>>n;
  
  
  //divisor n
  std::vector<int64_t> div;
  for (int64_t i = 1; i*i < n; ++i)
  {
    if(n%i==0){
      div.push_back(n/i);
    }
  }

  int64_t ans=0;
  for(auto&& e: div) {
    e-=1;
    if(n%e==(n-n%e)/e){
      ans+=e;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 256
N = int( input() )

L = []
for i in range( N ):
  a, b = map( int, input().split() )
  L.append([ a, b ])
L.sort( key=lambda x: -x[ 1 ] )

Max = L[0][1]
for i, j in L:
  Max -= i + max( Max - j, 0 )
if Max >= 0:
  print('Yes')
else:
  print('No')

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

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

    if(2 * k >= b - a + 1){
        for(int i=0; i<b-a+1; i++){
            cout << a + i << endl;
        }
    }else{
        for(int i=0; i<k; i++){
            cout << a + i << endl;
        }
        for(int i=0; i<k; i++){
            cout << (b - k + 1) + i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



string s, t;

int dp[3001][3001];


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

	cin >> s >> t;
	memset(dp, -1, sizeof(dp));

	rep(i, s.size() + 1)dp[i][0] = 0;
	rep(i, t.size() + 1)dp[0][i] = 0;

	rep(i, s.size() + 1)rep(j, t.size() + 1) {
		if (i < s.size()) {
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
		}
		if (j<t.size()) {
			dp[i][j + 1] = max(dp[i][j + 1], dp[i][j]);
		}
		if (i < s.size() && j < t.size() && s[i] == t[j]) {
			int v = dp[i][j] + 1;
			dp[i + 1][j + 1] = max(dp[i + 1][j + 1], v);
		}
	}

	string ans;
	int x = s.size(), y = t.size();
	int v = dp[x][y];
	while (0 < x && 0 < y) {
		if (dp[x-1][y] == dp[x][y]) {
			x--;
		}
		else if (dp[x][y-1] == dp[x][y]) {
			y--;
		}
		else {
			x--;
			y--;
			ans += s[x];
		}
	}
	reverse(all(ans));
	cout << ans << endl;



	
	return 0;
}


Measured memory_bytes: 35456
#include <cstdio>
#include <iostream>
#include <queue>
using namespace std;

long long a[300030];

int main(){
  int n;
  cin >> n;
  priority_queue<long long> lpq;
  priority_queue<long long> rpq;
  priority_queue<long long> tr;
  long long lmin;
  long long l = 0;
  long long r = 0;
  for (int i = 0; i < 2 * n; i++) {
    scanf("%lld", &a[i]);
    lpq.push(a[i]);
  }
  for (int i = 0; i < n; i++) {
    long long k;
    scanf("%lld", &k);
    r += k;
    rpq.push(k);
  }
  for (int i = 0; i < n; i++) {
    l += lpq.top();
    lmin = lpq.top();
    lpq.pop();
  }
  long long ans = l - r;
  for (int i = 2 * n - 1; i >= n; i--) {
    long long t = a[i];
    if (lmin <= t) {
      while(true) {
        if (tr.empty()) break;
        int u = lpq.top();
        if (tr.top() != u) break;
        else {
          lpq.pop(); tr.pop();
        }
      }
      l -= (t - lpq.top());
      lmin = lpq.top();
      lpq.pop();
    } else tr.push(t);
    if (t <= rpq.top()) {
      r -= (rpq.top() - t);
      rpq.pop();
      rpq.push(t);
    }
    ans = max(ans, l - r);
    //printf("\t%lld\t%lld\n", ans, l - r);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6000
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

typedef  long long ll;
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;}

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep2(i, begin_i, end_i) for (int i = (int)begin_i; i < (int)end_i; i++)

long long INF = 1LL<<60;
long long dp[100010];
int h[100010];
int f[110][15];
int p[110][15];
int n;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=10;j++)
            cin>>f[i][j];
    }
    for(int i=1;i<=n;i++){
        for(int j=0;j<=10;j++){
            cin>>p[i][j];
        }
    }
    int ans = (-1)<<30;
    for(int bits=1;bits<(1<<10);bits++){
        int tmpv = 0;
        for(int i=1;i<=n;i++){
            int sametime=0;
            for(int j=1;j<=10;j++){
               if(!(bits>>(j-1)&f[i][j]))continue;
                sametime++;
            }
            tmpv += p[i][sametime];
        }
        ans = max(ans,tmpv);
    }
    cout<<ans<<endl;
    return 0;
}




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

int main()
{
	string s; cin >> s;
	vector<bool> n(4, 0);

	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'N') n[0] = 1;
		if (s[i] == 'S') n[1] = 1;
		if (s[i] == 'E') n[2] = 1;
		if (s[i] == 'W') n[3] = 1;
	}

	cout << ((n[0]^n[1]) or (n[2]^n[3]) ? "No" : "Yes") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

string s;

void input(){
    cin >> s;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    for(int i=0;i<6;i++){
        if(s.substr(0, i+1) + s.substr(s.size()-6+i) == "keyence"){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;
typedef long long ll;
const int MAX_N = 1e5 + 1;
ll N, M;
int par[MAX_N];
int UFTrank[MAX_N];
int ele[MAX_N];

void init(int n) {
   for (int i = 0; i < n; i++) {
      par[i] = i;
      UFTrank[i] = 0;
      ele[i] = 1;
   }
}

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

void unite(int x, int y) {
   x = find(x);
   y = find(y);
   if (x == y) return;
   ele[x] += ele[y];
   ele[y] = ele[x];
   if (UFTrank[x] < UFTrank[y]) {
      par[x] = y;
   } else {
      par[y] = x;
      if (UFTrank[x] == UFTrank[y]) UFTrank[x]++;
   }
}

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

int main() {
   cin >> N >> M;
   int A, B;
   int a[M], b[M];
   for (int m = 0; m < M; m++) {
      cin >> A >> B;
      a[m] = A;
      b[m] = B;
   }

   init(N);
   vector<ll> ans;
   ans.resize(M + 1);
   ans[M] = N * (N - 1) / 2;
   for (int m = M - 1; m >= 0; m--) {
      if (same(a[m], b[m])) ans[m] = ans[m + 1];
      else {
         int x0 = find(a[m]);
         int y0 = find(b[m]);
         ans[m] = ans[m + 1] - ele[x0] * ele[y0];
         unite(a[m], b[m]);
      }
   }
   for (int m = 1; m <= M; m++) {
      cout << ans[m] << endl;
   }
   return 0;
}


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

int main() {
    string s; cin >> s;
    int ans = s.size();
    for (char c = 'a'; c <= 'z'; c++) {
        string t = s;
        int same = 0;
        for (int i = 0; i < t.size(); i++) {
            if (t[i] == c) same++;
        }
        int cnt = 0;
        while (same != t.size()) {
            same = 0;
            cnt++;
            string str;
            for (int i = 0; i < t.size() - 1; i++) {
                if (t[i] == c || t[i+1] == c) {
                    str += c;
                    same++;
                } else {
                    str += t[i];
                }
            }
            t = str;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int a;
    int b;
    
    while (std::cin >> a >> b){
        int sum;
        int digits;
        
        sum = a + b;
        digits = 1;
        while (sum / 10){
            sum /= 10;
            digits++;
        }
        std::cout << digits << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 1160
function myout(text){console.log(text);}//standard output
function Main(input) {
	input = parseInt(input.trim());
	//input = input.trim().split(" ");
	//input = input.trim().split("\n");
	//input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  var count = 0;
  for(var i = 1; i <= input; i++){
    if(i % 2 == 1){
      var div = 0;
       for(var j = 1; j <= i; j++){
         if(i % j == 0){
            div++;
         }
       }
      if(div == 8){
         count++;
         }
    }
  }
  myout(count);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#define MAX 200
#define WHITE 0
#define BLACK 1

int main() {
	int H, W;
	int c[10][10];
	int A[MAX][MAX];
	cin >> H >> W;
	for (int i = 0; i <= 9; i++) {
		for (int j = 0; j <= 9; j++) {
			cin >> c[i][j];
		}
	}
	// Optimize minimum cost c[i][j]
	int cto1[10];
	int col[] = {WHITE, WHITE, WHITE, WHITE, WHITE,
				 WHITE, WHITE, WHITE, WHITE, WHITE};
	priority_queue<pair<int, int>> PQ;	// cost, current location
	PQ.push(make_pair(-0, 1));
	while (!PQ.empty()) {
		auto u = PQ.top();
		PQ.pop();
		if (col[u.second] == WHITE) {
			col[u.second] = BLACK;
			cto1[u.second] = -u.first;
			for (int i = 0; i <= 9; i++) {
				PQ.push(make_pair(u.first - c[i][u.second], i));
			}
		}
	}
	int ans = 0;
	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++) {
			int a;
			cin >> a;
			ans += (a == -1 ? 0 : cto1[a]);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
while ((str = gets()) != "0\n")
  hand = str.chomp().split()
  point = 0
  one = 0
  hand.each() do |c|
    card = c.to_i()
    if (card == 1)
      one += 1
    elsif (card > 10)
      card = 10
    end
    point += card
  end
  while (one > 0)
    if (point + 10 <= 21)
      point += 10
      one -= 1
    else 
      break
    end
  end
  if (point > 21)
    point = 0
  end
  puts(point)
end

Measured memory_bytes: 6100
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Graph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	public void printAdjMatrix() {
		Integer[][] adjMatrix = new Integer[totalVertex][totalVertex];
		Iterator<LinkedList<Integer>> it1 = adjList.iterator();
		
		
		for(int i =0; i < adjMatrix.length; i++) {
			for(int j = 0; j < adjMatrix[i].length; j++) {
				adjMatrix[i][j] = 0;
			}
			
		}
		int row = 0;
		while(it1.hasNext()){
			LinkedList<Integer> tmp = it1.next();
			
			Iterator<Integer> it2 = tmp.iterator();
			
			while(it2.hasNext())
			{
				adjMatrix[row][it2.next()] = 1;
				
			}

			row++;
		}
	    
		for(int i =0; i < adjMatrix.length; i++) {
			for(int j = 0; j < adjMatrix[i].length; j++) {
				if(j  == adjMatrix[i].length -1) {
					System.out.print(adjMatrix[i][j]);
				} else {
					System.out.print(adjMatrix[i][j] + " ");
				}
				
			}
			System.out.println();
		}
		
	}
}

//change class name GraphRepresentation to Main() for submission to AIZU
public class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.printAdjMatrix();
	}
}



Measured memory_bytes: 32772
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <cmath>
using namespace std;
#define fio ios::sync_with_stdio(0),cin.tie(0);
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



int N,K;
int dp[110] = { 1 };
int c[2] = { 4,7 };
int main() {
	scanf("%d", &N);
	for(int k=0;k<2;k++)
	for (int i = 0;i <= N;i++) {
		if (dp[i]) dp[i + c[k]] = 1;
	}
	printf("%s", dp[N] ? "Yes" : "No");
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 0x3f3f3f3f;
const ll maxn= 1e5+10;
int main(){
	string s1,s2;
	cin>>s1>>s2;
	int flag=0;
	for(int i=0;i<s1.length();i++){
		if(s1[i]!=s2[i]){
			flag=1;
		}
	}
	if(flag) cout<<"No\n";
	else cout<<"Yes\n";

	return 0;
}


Measured memory_bytes: 3628