akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const int mod = 1e9 + 7, N = 16;

namespace {
  inline int add(int x, int y) { return (x += y) >= mod ? x - mod : x; }
  inline int sub(int x, int y) { return (x -= y) < 0 ? x + mod : x; }
  inline int mul(int x, int y) { return 1LL * x * y % mod; }
  inline int kissme(int x, int y) {
    int c = 1;
    while(y) {
      if(y & 1) {
	c = mul(c, x);
      }
      x = mul(x, x);
      y >>= 1;
    }
    return c;
  }
}

int n, Q, scnt, l[N], r[N], h[1 << N], f[10][1 << N];
bool vis[N << 1];
vector<int> all, vec[N], g[N << 1];

int get(int x) {
  if(!x) {
    return 1;
  }
  return mul(sub(kissme(10, x), 1), kissme(9, mod - 2));
}

int calc(vector<int> a) {
  sort(a.begin(), a.end());
  int ans = 1;
  for(int i = 1; i < a.size(); i++) {
    if(a[i] - a[i - 1] == 1) {
      int x = get(all[a[i]] - all[a[i - 1]]);
      ans = mul(ans, mul(add(x, 1), kissme(x, mod - 2)));
    }
  }
  return ans;
}

void dfs(int s, int x) {
  vis[x] = true;
  vec[s].push_back(x);
  for(int v : g[x]) {
    if(!vis[v]) {
      dfs(s, v);
    }
  }
}

int main(void) {
  scanf("%d%d", &n, &Q);
  for(int i = 1; i <= Q; i++) {
    scanf("%d%d", &l[i], &r[i]);
    l[i]--;
    all.push_back(l[i]);
    all.push_back(r[i]);
  }
  sort(all.begin(), all.end());
  all.erase(unique(all.begin(), all.end()), all.end());
  for(int i = 1; i <= Q; i++) {
    l[i] = lower_bound(all.begin(), all.end(), l[i]) - all.begin();
    r[i] = lower_bound(all.begin(), all.end(), r[i]) - all.begin();
    g[l[i]].push_back(r[i]);
    g[r[i]].push_back(l[i]);
  }
  for(int i = 0; i < all.size(); i++) {
    if(!vis[i]) {
      dfs(scnt++, i);
    }
  }
  for(int i = 0; i < (1 << scnt); i++) {
    vector<int> cur;
    for(int j = 0; j < scnt; j++) {
      if(i >> j & 1) {
	for(int k : vec[j]) {
	  cur.push_back(k);
	}
      }
    }
    h[i] = calc(cur);
  }
  f[0][0] = 1;
  for(int o = 0; o < 9; o++) {
    for(int i = 0; i < (1 << scnt); i++) {
      if(!f[o][i]) {
	continue;
      }
      int t = (1 << scnt) - 1 - i;
      for(int j = t; ; j = t & (j - 1)) {
	f[o + 1][i | j] = add(f[o + 1][i | j], mul(f[o][i], h[j]));
	if(!j) {
	  break;
	}
      }
    }
  }
  int ans = mul(f[9][(1 << scnt) - 1], kissme(10, all[0]));
  for(int i = 1; i < all.size(); i++) {
    ans = mul(ans, get(all[i] - all[i - 1]));
  }
  cout << mul(mul(ans, kissme(10, n - all.back())), kissme(9, mod - 2)) << endl;
  return 0;
}


Measured memory_bytes: 1536
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int cnt=1;
    int tmp=0;
    while(true){
        if(cnt==n){
            cout << -1 << endl;
            break;
        }
        if(a[tmp]==2){
            cout << cnt << endl;
            break;
        }
        cnt++;
        tmp = a[tmp]-1;
    }
    return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
import java.util.*
import kotlin.math.*

fun main() {
    var fs = Atcoder.FastReader()
    var k = fs.nextInt()
    if(k%7 ==0) k /= 7
    if(gcd(10,k) != 1){
        println("-1")
    }
    else {
        var a = 1 % k
        var len =1
        while (a != 0) {
            a = (10*a +1)%k
            len++
        }
        println(len)
    }
}
private fun gcd(i: Int, j: Int):Int {
    var max = max(i, j)
    var min = min(i, j)
    var rest:Int = max%min
    var oldRest:Int = min
    while (rest != 0) {
        max = min
        min = rest
        oldRest = rest
        rest = max%min
    }
    return oldRest
}
class Atcoder {
    internal class FastReader {
        private var br: BufferedReader = BufferedReader(InputStreamReader(System.`in`))
        private var st: StringTokenizer? = null

        operator fun next(): String {
            while (st == null || !st!!.hasMoreElements()) {
                try {
                    st = StringTokenizer(br.readLine())
                } catch (e: IOException) {
                    e.printStackTrace()
                }

            }
            return st!!.nextToken()
        }

        fun nextInt(): Int {
            return Integer.parseInt(next())
        }

        fun nextLong(): Long {
            return java.lang.Long.parseLong(next())
        }

        fun nextDouble(): Double {
            return java.lang.Double.parseDouble(next())
        }

        fun nextLine(): String {
            var str = ""
            try {
                str = br.readLine()
            } catch (e: IOException) {
                e.printStackTrace()
            }
            return str
        }

        fun readIntArray(n: Int): IntArray {
            val a = IntArray(n)
            for (i in 0 until n) a[i] = nextInt()
            return a
        }

        fun readLongArray(n: Int): LongArray {
            val a = LongArray(n)
            for (i in 0 until n) a[i] = nextLong()
            return a
        }

        fun readDoubleArray(n: Int): DoubleArray {
            val a = DoubleArray(n)
            for (i in 0 until n) a[i] = nextDouble()
            return a
        }
    }
}


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

int A[100005];

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

    int N;
    cin >> N;

    for(int i=1; i<=N; i++)
        cin >> A[i];
    
    sort(A+1, A+1+N);
    N /= 2;

    cout << A[N+1] - A[N] << "\n";
    return 0;
}


Measured memory_bytes: 640
N, x = map(int, input().split())
array = list(map(int, input().split()))
a = sorted(array, reverse=False)
#print(a)
answer = 0
for i in range(N):
    x -= a[i]
    if x < 0:
        break
    answer += 1
    if i == N-1 and x != 0:
        answer -= 1
        break
    if x < a[i]:
        break
print(answer)

Measured memory_bytes: 3060
num ,endu = map(int,input().split())

arr = [[0]*(endu+1) for i in range(num+1)]

value = [0]
weight = [0]
for i in range(num):
    val, wei = map(int,input().split())
    value.append(val)
    weight.append(wei)

for i in range(1,num+1):
    
    for j in range(1,endu+1):
        if j >= weight[i]:
            arr[i][j] = max(arr[i-1][j-weight[i]]+value[i],arr[i-1][j])
        else:
            arr[i][j] = arr[i-1][j]

print(arr[num][endu])


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

bitset<4000001> b;

int n, s;

int main() {
	scanf("%d", &n);
	b[0] = 1;
	for (int i = 1; i <= n; i++) {
		int x;
		scanf("%d", &x);
		b |= b << x;
		s += x;
	}
	for (int i = (s + 1) / 2; i <= s; i++) {
		if (b[i]) {
			printf("%d", i);
			break;
		}
	}
	return 0;
}


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

#define MOD 1000000007
#define MODSET(d) if ((d) >= MOD) d %= MOD;

using namespace std;

vector<int> graph[2005];
bool visited[2005];
int subtreeSize[2005];
int n, k;

int dfsTree(int u, int distance, bool isRoot)
{
	visited[u] = true;
	subtreeSize[u] = 1;
	
	if (distance == (k+1)/2)
	{
		return 1;
	}
	
	int total = 0;
	int maxK = 0;
	
	for (auto v: graph[u])
	{
		if (!visited[v])
		{
			int curr = dfsTree(v, distance + 1, false);
			total += curr;
			maxK = max(maxK, curr);
			subtreeSize[u] += subtreeSize[v];
		}
	}
	
	if (isRoot)
	{
		return n - (subtreeSize[u] - (k % 2 ? (total - maxK) : 0));
	}
	else
	{
		return total;
	}
}

int main()
{
    #ifdef VSP4
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

	int i, j, u, v, ans;
	
	cin >> n >> k;
	
	for (i = 0; i < n-1; i++)
	{
		cin >> u >> v;
		graph[u].push_back(v);
		graph[v].push_back(u);
	}
	
	ans = n;
	
	for (i = 1; i <= n; i++)
	{
		memset(visited, false, sizeof(visited));
		memset(subtreeSize, 0, sizeof(subtreeSize));
		ans = min(ans, dfsTree(i, 0, true));
	}
	
	cout << ans;
		
    return 0;
}


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

struct v
{
    int i,j;
};

v a[5000];
int n;
long long dp[5000][5002];

bool comp(v x, v y)
{
    if((x.i+x.j)==(y.i+y.j))
        return(x.j<y.j);
    return((x.i+x.j)<(y.i+y.j));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int i,j,k,r=1;
    cin>>n;
    for(i=0;i<n;i++)
        cin>>a[i].i>>a[i].j;
    sort(a,a+n,comp);
    dp[0][1]=a[0].j;
    dp[0][2]=1e13;
    for(i=1;i<n;i++)
    {
        k=i+2;
        for(j=1;j<k;j++)
        {
            dp[i][j]=1e13;
            if(dp[i-1][j-1]<=a[i].i)
            {
                dp[i][j]=dp[i-1][j-1]+a[i].j;
                r=max(r,j);
            }
            dp[i][j]=min(dp[i][j],dp[i-1][j]);
        }
        dp[i][j]=1e13;
    }
    cout<<r;
    return 0;
}

Measured memory_bytes: 193920
import sys

n = input()

n=n[::-1]

num = int(n[0])
if num==2 or num==4 or num ==5 or num==7 or num==9:
    print("hon")
elif num ==0 or num ==1 or num ==6 or num ==8:
    print('pon')
else:
    print("bon")


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main(void) {
  ios_base::sync_with_stdio(false);

  int x;
  cin >> x;

  cout << 10 - (x / 200) << '\n';
  return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int main()
{ string s;int i,sum=0,t;
    cin>>s;
    t=s.length();
    for(i=0;i<t;i++)
    { sum=sum+(s[i]-'0');
        
    
}

if(sum%9==0)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
return 0;

}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;

void solve() {

}

int main() {
  ll K,N;
  cin >> K >> N;
  vector<ll> A(N);
  ll maxi = 0;
  rep(i,N) {
    cin >> A[i];
  }
  rep(i,N) {
    if( i + 1 < N ) {
      maxi = max(maxi,llabs(A[i]-A[(i+1)%N]));
    } else {
      maxi = max(maxi,A[0]+(K-A[i]));
    }
  }
  cout << K - maxi << endl;
  
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
            using namespace std;
             
            int main() {
              int N, p, y , w, g, i, sum;
              
              cin >> N;
              cout << endl;
              bool flag = false;
              string x;
              
              for(i = 0; i < N; i++){
                cin >> x;
                if (x == "Y") flag = true;
              }
              if (flag){cout << "Four";}
              else {cout << "Three";}
            }

Measured memory_bytes: 256
#include <bits/stdc++.h>
/*    #include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;       */
using namespace std;

#define ll long long
#define ull unsigned long long
#define f(a, b) for (ll i = a; i < b; i++)
#define mod 1000000007
#define pb push_back
#define vll vector<ll>
#define pll vector<pair<ll, ll>>
#define ld long double
#define fr(a, b) for (ll j = a; j >= b; j--)
#define fi(a, b) for (ll j = a; j < b; j++)
#define fii(a, b) for (ll k = a; k < b; k++)
//      typedef tree<ll ,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

template <class T>
ostream &operator<<(ostream &os, vector<T> V)
{
    os << "[ ";
    for (auto v : V)
        os << v << " ";
    os << "]";
    return os;
}
template <class T>
ostream &operator<<(ostream &os, set<T> S)
{
    os << "{ ";
    for (auto s : S)
        os << s << " ";
    return os << "}";
}
template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P)
{
    return os << "(" << P.first << "," << P.second << ")";
}
template <class L, class R>
ostream &operator<<(ostream &os, map<L, R> M)
{
    os << "{ ";
    for (auto m : M)
        os << "(" << m.first << ":" << m.second << ") ";
    return os << "}";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s;
    cin >> s;
    if (s.length() & 1)
    {
        cout << "No";
        return 0;
    }
    f(0, s.length())
    {
        if (!(s[i] == 'h' && s[i + 1] == 'i'))
        {
            cout << "No";
            return 0;
        }
        i++;
    }
    cout << "Yes";

    return 0;
}

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

#include <stdio.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, k, n) for (int i = (k); i < (n); i++)
#define rrep(i, k, n) for (int i = (k); i >= (n); i++)
#define pb push_back
#define vec vector
#define ref(a) &(a)

typedef long long ll;

using namespace std;

int n;
vec<ll> a;

ll gcd(ll m, ll n) {
  if (n == 0) return m;
  else return gcd(n, m % n);
}

ll solve() {
  ll res = 0;
  vec<ll> l(n), r(n);
  rep(i, n) {
    if (!i) l[i] = a[i];
    else l[i] = gcd(l[i - 1], a[i]);
  }
  rep(i, n) {
    if (!i) r[n - 1] = a[n - 1];
    else r[n - i - 1] = gcd(r[n - (i - 1) - 1], a[n - i - 1]);
  }
  rep(i, n) {
    ll g = 0;
    if (!i) g = r[i + 1];
    else if (i == n - 1) g = l[i - 1];
    else g = gcd(l[i - 1], r[i + 1]);
    res = max(res, g);
  }

  return res;
}

int main() {
  cin >> n;
  rep(i, n) {
    ll x; cin >> x;
    a.pb(x);
  }
  cout << solve() << endl;
  return 0;
}

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

int main(){
    int x,n;
    cin >> x >> n;
    set<int> s;
    for(int i=0;i<n;i++){
        int t;cin>>t;
        s.insert(t);
    }
    int k=0;
    while(1){
        if(s.find(x-k)==s.end()){cout << x-k <<"\n";break;}
        if(s.find(x+k)==s.end()){cout << x+k <<"\n";break;}
        k++;
    }
    return 0;
}


Measured memory_bytes: 3636
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <set>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
//const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

}
ll min(ll a, ll b) {
	if (a < b)
		return a;
	else
		return b;

}

ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}






int main() {

	int N;
	cin >> N;
	vector<ll> A(N);

	rep(i, N)
		cin >> A[i];
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {

			ans += A[i] * A[j];
		}

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

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <limits.h>
#include <memory.h>


using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef vector<double> vec;
typedef vector<vec> mat;

int f[105];
int p[105][15];
int store[105];

int cnt(int f){
	int ret=0;
	FORI(0,10){
		ret+=f&1;
		f = f>>1;
	}
	return ret;
}

int main() {
	int n;
	cin>>n;
	FORI(0,n){
		FORJ(0,10){
			int t;
			cin >> t;
			f[i]=(f[i]<<1)|t;//
		}
	}
	FORI(0,n){
		FORJ(0,11){//
			cin>>p[i][j];
		}
	}
	int ans=-2000000000;//
	for(int i=1;i<(1<<10);i++){
		int sum=0;
		memset(store,0,sizeof(store));
		FORJ(0,n){	
			int t = cnt(f[j] & i);
			sum += p[j][t];
		}
		ans=max(sum,ans);
	}
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int digitsSum(int x){
    int ans=0;
    while(1){
        ans+=x%10;
        x/=10;
        if(x<1){
            break;
        }
    }
    return ans;
}

int main(){

    int N,min=INT32_MAX,temp;
    cin >> N;

    for(int A=1;A<=(N/2);A++){
        int B=N-A;

        temp=digitsSum(A)+digitsSum(B);
        if(temp<min){
            min=temp;
        }
    }

    cout << min<<endl;

    return 0;
}


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

int main(void) {
    int max_cnt = 0;
    int N;
    string S;
    cin>>N>>S;
    for (int i = 0; i <= N - 2; i++) {
        set<char> sets;
        for (int j = 0; j <= i; j++) sets.insert(S[j]);
        int cnt;
        set<char> sets_after;
        for (int j = i + 1; j <= N - 1; j++) {
            if (sets.find(S[j]) != sets.end()) sets_after.insert(S[j]);
        }
        cnt = sets_after.size();
        if (max_cnt < cnt) max_cnt = cnt;
    }
    cout << max_cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template

//main
signed main(){
  int N,K;cin>>N>>K;
  string s;cin>>s;
  for(int i=0;i<N;i++){
    if(i==K-1)cout<<char(s[i]-('A'-'a'));
    else cout<<s[i];
  }
  cout<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
using namespace std;
int main(){
  int n;
  cin>>n;
  set<int> s;
  for (;n;--n)
  {
    int val;
    cin>>val;
    if (s.find(val)!=s.end())
      s.erase(val);
    else
      s.insert(val);
  }
  cout<<s.size()<<endl;
  
  return 0;
}




Measured memory_bytes: 4864
function main(input){
  var input = input.trim();
  var input = input.split("\n");
  var kazu = parseInt(input[0].split(" ")[0]);
  var answer;
  if(input[1]){var fList = input[1].split(" ");}
  else{fList=[];}
  for(var i=0; i<fList.length; i++){fList[i]=parseInt(fList[i]);}
  var nList = [];
  for(var i=0; i<102; i++){
    if(fList.includes(i)==false){
      nList[nList.length]=[i,Math.abs(kazu-i)];
    }
  }
  // console.log(nList);
  nList.sort(function (a, b) {
    return (a[1] - b[1]);
  });
  console.log(nList[0][0]);
  // console.log(nList);
}//main(input);
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29420
#pragma once
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max3(x, y, z) max(x, max(y,z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endlhttps:  // stopwatch.onl.jp/#
#endif
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  cout << max3(a+b,a-b,a*b);
  return 0;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
  cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> vec;
vec.at(i)
vector<vector<int>> vec(10, vector<int>(10));
sort(all(vec));
sort(all(vec), greater<int>());
    //配列の内容表示
dout << "====vecの内容====\n";
for (int i = 0; i < N; i++) dout << vec[i] << endl;
dout << "====ここまで====\n";
*/

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
  
	int N; 	cin >> N;
	vector<int> h(N);
	for (int i = 0; i < N; i++) cin >> h[i];
	vector<long long> dp(N, 10000000001);
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for (int i = 2; i < N; ++i) {
		dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
		dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	cout << dp[N - 1] << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    int a, w, t, r;
    a = w = t = r = 0;
    for (int i = 0; i < N; i++) {
        string S;
        cin >> S;
        if (S == "AC") a++;
        if (S == "WA") w++;
        if (S == "TLE") t++;
        if (S == "RE") r++;
    }
    printf("AC x %d\n", a);
    printf("WA x %d\n", w);
    printf("TLE x %d\n", t);
    printf("RE x %d\n", r);
}

Measured memory_bytes: 3728
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def ris(): return list(input())
def pli(): return "".join(list(map(str, ans)))
 
 
N = ri()
a = rli()
ma = max(a)
mi = min(a)
if(ma - mi > 1):
    print("No")
elif(ma - mi == 1):
    l_ma = a.count(ma)
    l_mi = a.count(mi)
    if(ma <= l_mi):
        print("No")
    elif(l_mi + l_ma/2 >= ma):
        print("Yes")
    else:
        print("No")
else:
    if(a[0] == N-1):
        print("Yes")
    elif(N/a[0] >= 2):
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 14300
col_list = ['R', 'Y', 'G', 'B']

H, W, d = map(int, input().split())

for i in range(H):
    tmp = ""
    for j in range(W):
        c = ((i+j)//d)%2 + (((i-j+W)//d)%2)*2
        tmp += col_list[c]
    print(tmp)

Measured memory_bytes: 3316
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        boolean ans = true;
        
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if ((i % 2 == 0 && c == 'L') || (i % 2 == 1 && c == 'R')) {
                ans = false;
                break;
            }
        }
        System.out.println(ans ? "Yes":"No");
    }
}

Measured memory_bytes: 21972
import bisect
import math
N = int(input())
S = input()
ans = 1

ball = [0, 0, 0]
d = {"R":0, "G":1, "B":2}

for i in range(3*N):
    b = d[S[i]]
    if ball[b-1] == 0 or ball[b-2] == 0:
        if max(ball) == ball[b]:
            ball[b] += 1
            continue
        else:
            ans *= max(ball) - ball[b]
            ball[b] += 1
    else:
        ans *= (min(ball[b-1], ball[b-2]))
        ball[b-1] -= 1
        ball[b-2] -= 1

    ans %= 998244353

for i in range(N):
    ans *= i+1
    ans %= 998244353
print(ans % 998244353)


Measured memory_bytes: 3956
/**
 * 
 */
import java.util.*;
/**
 * @author akira
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int a, b;
		a = scan.nextInt();
		b = scan.nextInt();
		System.out.format("%.5f",(a * b / 3.305785));

	}

}

Measured memory_bytes: 17320
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
int main(){
  int a,b;
  cin >> a >> b;
  if(b % a == 0)cout << a + b << endl;
  else cout << b - a << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  string answer;
  for(int i=0;i<tx-sx;i++) answer+='R';
  for(int i=0;i<ty-sy;i++) answer+='U';
  for(int i=0;i<tx-sx;i++) answer+='L';
  for(int i=0;i<ty-sy+1;i++) answer+='D';
  for(int i=0;i<tx-sx+1;i++) answer+='R';
  for(int i=0;i<ty-sy+1;i++) answer+='U';
  answer+='L';
  answer+='U';
  for(int i=0;i<tx-sx+1;i++) answer+='L';
  for(int i=0;i<ty-sy+1;i++) answer+='D';
  answer+='R';
  cout<<answer<<endl;
  
  return 0;
}

Measured memory_bytes: 3168
def aaa(strArg):
  str = ''
  for c in strArg:
    str += ' ' + c
  return str

n = [int(input())]

house = ['0' * 30, '0' * 30, '0' * 30, '0' * 30]
hr = '#' * 20

for nn in range(n[0]):
  bfrv = [int(x) for x in input().split()]

  b = bfrv[0] - 1
  f = bfrv[1] - 1
  r = bfrv[2] - 1
  v = bfrv[3]

  pos = (f * 10) + r
  humal = int(house[b][pos]) + v

  house[b] = house[b][:pos] + str(humal) + house[b][pos + 1:]

for ii in range(4):
  print(aaa(house[ii][:10]))
  print(aaa(house[ii][10:20]))
  print(aaa(house[ii][20:]))
  if ii != 3:
    print(hr)

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

int num[5][4][11];

int main()
{
    int iNum = 0;
    int iB = 0;
    int iF = 0;
    int iR = 0;
    int iV = 0;
    
    cin >> iNum;
    
    for (int i = 0; i < iNum; i++)
    {
        cin >> iB >> iF >> iR >> iV;
        num[iB][iF][iR] += iV;
    }
    
    for (int i = 1; i < 5; i++)
    {
        for (int j = 1; j < 4; j++)
        {
            for (int k = 1; k < 11; k++)
            {
                cout << " " << num[i][j][k];
            }
            
            cout << endl;
        }
        
        if (i != 4)
        {
            cout << "####################" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ini(a,i) memset(a,i,sizeof(a))
#define pb push_back
#define ll int64_t
#define inf LLONG_MAX

void solve()
{
	ll n,h,w,k,i,cnt,ans;
	cin>>h>>w>>k;


	string str[h+1];
	for(i=0;i<h;i++)	{cin>>str[i];}
	
	ans=0;
	for(i=0;i<(1<<h);i++)	
	{
		for(ll j=0;j<(1<<w);j++)	
		{
			cnt=0;
			for(ll l=0;l<h;l++)	
			{
				for(ll r=0;r<w;r++)	
				{
					if(i&(1<<l) and j&(1<<r))
					{
						cnt+=(str[l][r]=='#');
					}
				}
				
			}
			ans+=(cnt==k);
		}
	}

	cout<<ans<<endl;

}


signed main()
{
	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//ll tt;	cin>>tt;	while(tt--)
	{
		solve();
 	}
	cerr<<" Execution : "<<(1.0*clock())/CLOCKS_PER_SEC<<"s \n";
		
		
return 0;
}

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

int main() {
    int H, W;
    char tmp;
    char C[210][110];

    cin >> H >> W;
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            cin >> tmp;
            C[2*i-1][j] = tmp;
            C[2*i][j] = tmp;
        }
    }

    for (int i = 1; i <= 2*H; i++) {
        for (int j = 1; j <= W; j++) {
            cout << C[i][j] << flush;
        }
        cout << endl;
    }
}

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

int main(){
    int N, K; cin >> N >> K;
    int h[100100];
    for(int i=0; i<N; i++){
        cin >> h[i+1];
    }
    const int INF = 1001001001;
    int ans[100100];
    ans[1]=0;
    for(int i=2; i<=N; i++){
        int a = INF;
        for(int j=1; j<=K; j++){
            if(i-j >= 1){
                int b = ans[i-j] + abs(h[i]-h[i-j]);
                a = min(a,b);
            }
        }
        ans[i] = a;
    }
    cout << ans[N] << endl;
}

Measured memory_bytes: 1024
#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
#include <bits/stdc++.h>
using namespace std;
/* {{{ */
/*-------------------------------*/
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)

#define all(i) (i).begin(),(i).end()
#define rall(i) (i).begin(),(i).end(),greater<int>()
#define print(x) cout << (x) << endl
#define PB push_back
#define pb push_back
#define mp make_pair
#define FI first
#define SE second

inline int in(){int x;std::cin>>x;return x;}
struct FAST {FAST(){cin.tie(0);ios::sync_with_stdio(false);}} Fast;
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<long long> llv;
typedef vector<pint> vpint;
/*-------------------------------*/
/* }}} */ 

signed main(void)
{
  int a, b;

  while (cin >> a >> b){
    cout << a + b << endl;
  }

  return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	ll n, a, b;
	cin >> n >> a >> b;
	ll t=(a+b-1)/2;
	if((b-a)%2==0) cout << (b-a)/2 << endl;
	else cout << min(t, n-t) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// const ll INF = 1LL <<60;
// const int INF = 10000;

//最大公約数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 1e6+1;
const int MOD = 1e9+7;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}

long long modpow(long long res,long long a, long long n, long long mod) {
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//sieve(MAX);でベクトルIsPrimeに「MAXまでの数値の素数の真偽」を格納する。
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}
// ここから開始

bool dp[30009][4][1009];


int main(){
    int n;
    cin>>n;
    int a[n];
    int cnt[n];
    for(int i = 0; i < n; i++){
        cin>>a[i];
        cnt[i]=0;
    }
    cnt[0] = 3;
    ll ans = 1;
    ll mod = 1000000000+7;
    for(int i = 0; i < n; i++){
        ans*=cnt[a[i]];
        cnt[a[i]]--;
        cnt[a[i]+1]++;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3072
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	D_fix_3
# CreatedDate:  2020-08-30 13:22:07 +0900
# LastModified: 2020-08-30 13:41:03 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    S = input()
    Q = int(input())
    appendix_1 = ''
    appendix_2 = ''
    reverse = 0
    for _ in range(Q):
        q = list(input().split())
        if q[0] == '1':
            reverse += 1
        else:
            if q[1] == '1' and reverse % 2 == 0:
                appendix_1 += q[2]
            elif q[1] == '1' and reverse % 2 == 1:
                appendix_2 += q[2]
            if q[1] == '2' and reverse % 2 == 0:
                appendix_2 += q[2]
            elif q[1] == '2' and reverse % 2 == 1:
                appendix_1 += q[2]

    if reverse % 2 == 0:
        print(appendix_1[::-1] + S + appendix_2)
    else:
        print(appendix_2[::-1] + S[::-1] + appendix_1)



if __name__ == "__main__":
    main()


Measured memory_bytes: 10104
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;


class Program
{
    internal static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());
        var inp = ReadLine().Split(' ');

        if (inp.Contains("Y")) {
            WriteLine("Four");
        } else {
            WriteLine("Three");
        }
    }
}


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



int main(){

	int n;
	cin>>n;

	bool present = false;

	while(n!=0){
		if(n%10==7){
			present = true;
			break;
		}
		n=n/10;
	}

	if(present){
		cout<<"Yes";
	}
	else cout<<"No";
	
}

Measured memory_bytes: 3692
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    for(;;){
        int H,W; cin >> H >> W;
        if(H == 0) break;
        char c[H][W];
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if (i == 0 && j == 0){
                    c[i][j] = '#';
                } else if (j == 0) {
                    if (c[i-1][j] == '#') c[i][j] = '.';
                    else c[i][j] = '#';
                } else {
                    if (c[i][j-1] == '.') c[i][j] = '#';
                    else c[i][j] = '.';
                }
            }
        }
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                cout << c[i][j];
            }
            cout << endl;
        }
        cout << endl;
    }
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll h,w,n;
    cin >> h >> w >> n;
    map<pair<ll,ll>,ll> mp;
    ll dx[8] = {-1,-1,-1,0,0,1,1,1};
    ll dy[8] = {-1,0,1,-1,1,-1,0,1};
    for(i = 0;i < n;++i){
        ll a,b;
        cin >> a >> b;
        mp[make_pair(a,b)] = 1;
        rep(j,8){
            ll na = a + dx[j];
            ll nb = b + dy[j];
            if(na <= 0 || na > h || nb <= 0 || nb > w) continue;
            if(!mp.count(make_pair(na,nb))) mp[make_pair(na,nb)] = 0;
        }
    }
    vector<ll> ans(10,0);
    for(auto z:mp){
        ll x = z.first.first;
        ll y = z.first.second;
        if(x  == 1 || x == h || y == 1 || y == w) continue;
        ll cnt = z.second;
        for(i = 0;i < 8;++i){
            ll nx = x + dx[i];
            ll ny = y + dy[i];
            if(mp.count(make_pair(nx, ny))) cnt += mp[make_pair(nx, ny)];
        }
        if(cnt) ++ans.at(cnt);
    }
    ll tmp = 0;
    for(i = 1;i < 10;++i) tmp += ans.at(i);
    ans.at(0) = (h-2)*(w-2) - tmp;
    for(auto x:ans) cout << x << endl;

    return 0;
}

Measured memory_bytes: 59824
#include<iostream>
using namespace std;
using ll=long long;
int main(){

  ll N,A,B;
  cin>>N>>A>>B;
  ll group=N/(A+B);
  ll mod=N%(A+B);
  if(mod>=A)mod=A;
  cout<<group*A+mod;
  return 0;
}

Measured memory_bytes: 3604
n=int(input())
S,T=map(str,input().split())

s=[]
t=[]
for i in S:
    s.append(i)
for i in T:
    t.append(i)
l=[]
for i in range(n):
    l.append(s[i])
    l.append(t[i])
t=""
for i in range(len(l)):
    t+=l[i]
print(t)

Measured memory_bytes: 3060
import java.util.Scanner;

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

  if(N>17||(N>8&&(N-7)%4==0)||(N>15&&(N-14)%4==0)||N%4==0||N%7==0){
    System.out.println("Yes");
  }else{
    System.out.println("No");
  }

}
}


Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
using namespace std;
const int mt = 100+5;
bool dp[mt*mt];
int s[mt];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s[i];
	}
	dp[0]=1;
	for(int i=1;i<=n;i++)
		for(int j=10000;j>=s[i];j--)
			dp[j]|=dp[j-s[i]];
	for(int i=10000;i>=1;i--)
		if(i%10!=0&&dp[i])
		{
			cout<<i<<endl;return 0;
		}
	cout<<"0"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int N = 0;
  int sum = 0; //結果入れる変数sum
  cin >> N; //Nを代入
  vector<int> dish(N); //配列dish(食べた順番)
  vector<int> value(N); //配列value(満足度)
  vector<int> add(N-1); //配列add(おまけ満足度)
  for(int i = 0; i < N; i++){
    cin >> dish.at(i);
  }
  for(int i = 0; i < N; i++){
    cin >> value.at(i);
  }
  for(int i = 0; i < N - 1; i++){
    cin >> add.at(i);
  }
  for(int i = 0; i < N; i++){
    sum = sum + value.at(i);
  }
  
  for(int i = 0; i < N - 1; i++){
    if(dish.at(i + 1) - dish.at(i) == 1){
      sum = sum + add.at(dish.at(i) - 1);
    }
  } 
    cout << sum;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include<string.h>

int main()
{
    int n,c,i,j,d,x;
    int p[1000]={0};
    scanf("%d%d%d",&n,&d,&x);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&p[i]);
    }
    for(i=1,c=0;i<=n;i++)
    {
        for(j=0;j*p[i]+1<=d;j++)
        {
            c++;
        }
    }
    c+=x;
    printf("%d\n",c);
    return 0;
}


Measured memory_bytes: 128
M=10**9+7
N=gets.to_i
C=gets.split.map(&:to_i).sort

pow=Array.new(N+1){1}
N.times do |i|
  pow[i+1]=(2*pow[i])%M
end

s=1
(N-1).times do |i|
  s=(2*s+pow[i])%M
end

t=Array.new(N+1){0}
N.times do |i|
  t[i+1]=(2*t[i]+pow[i])%M
end

ans=0
N.times do |i|
  ans+=C[i]*s
  ans-=C[i]*(pow[N-1-i])*(t[i])
  ans%=M
end
ans*=pow[N]
ans%=M
p((ans+M)%M)


Measured memory_bytes: 24832
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main() {
  
  int H,W;
  cin >> H >> W;
  
  for (int i = 0 ; i < (W + 2) ; i++)
    cout << "#";
  
  cout << endl;
  
  for (int j = 0 ; j < H ; j++){
    string str;
    cin >> str;
    cout << "#" << str << "#" << endl;
  }
  
  for (int i = 0 ; i < (W + 2) ; i++)
    cout << "#";
  
  cout << endl;
  
}


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

struct Wall { int x, y, r; };

bool inside(Wall w, double x, double y) {
	return w.r * w.r >= (w.x - x) * (w.x - x) + (w.y - y) * (w.y - y);
}

int main() {
	int n, wx, wy, r, m, tx, ty, sx, sy;
	while (cin >> n, n) {
		vector<Wall> w;
		for (int i=0; i<n; ++i) {
			cin >> wx >> wy >> r;
			w.push_back((Wall){wx, wy, r});
		}
		cin >> m;
		for (int i=0; i<m; ++i) {
			cin >> tx >> ty >> sx >> sy;
			bool safe = false;
			for (int j=0; j<n && !safe; ++j) {
				int k = inside(w[j], tx, ty) + inside(w[j], sx, sy);
				if (k == 0) {
					double dx, dy, x, y, minx, maxx, miny, maxy;
					dx = (sx - tx) / 10000.0;
					dy = (sy - ty) / 10000.0;
					x = tx;
					y = ty;
					minx = min(sx, tx);
					maxx = max(sx, tx);
					miny = min(sy, ty);
					maxy = max(sy, ty);
					while ( ! safe && minx <= x && x <= maxx && miny <= y && y <= maxy) {
						if (inside(w[j], x, y)) {
							safe = true;
							break;
						}
						x += dx;
						y += dy;
					}
				} else if (k == 1) {
					safe = true;
				}
			}
			cout << (safe ? "Safe" : "Danger") << endl;
		}
	}
	return 0;
}

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


int main() {

    string S;
    cin >> S;

    int num = 0;
    int max = 0;

    for (int i = 0; i < S.length(); i++) {

        if (S.at(i) == 'A' || S.at(i) == 'G' || S.at(i) == 'C' || S.at(i) == 'T') {
            num++;
            if (max < num) max = num;
        } else {
            num = 0;
        }
        
    
    }
    


    cout << max << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<long long> > vvll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define INF 1000000000
#define MOD 1000000007
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define p_q priority_queue

#define FOR(i, a, b) for (int i=(a); i<=(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 2005
int n, m;
int q;
int s[MN][MN], v[MN][MN], h[MN][MN];
int ps[MN][MN], pv[MN][MN], ph[MN][MN];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> m >> q;
    FOR(i, 1, n){
        FOR(j, 1, m){
            char c;
            cin >> c;
            s[i][j]=c-'0';
            if(s[i][j]&&s[i][j-1]){
                h[i][j]++;
            }
            if(s[i][j]&&s[i-1][j]){
                v[i][j]++;
            }
            ps[i][j] = ps[i][j-1]+ps[i-1][j]-ps[i-1][j-1]+s[i][j];
            ph[i][j] = ph[i][j-1]+ph[i-1][j]-ph[i-1][j-1]+h[i][j];
            pv[i][j] = pv[i][j-1]+pv[i-1][j]-pv[i-1][j-1]+v[i][j];
            //cout << ps[i][j] << " " << ph[i][j] << " " << pv[i][j] << "\n";
        }
    }

    F0R(_, q){
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        int sq = ps[x2][y2]-ps[x1-1][y2]-ps[x2][y1-1]+ps[x1-1][y1-1];
        int he = ph[x2][y2]-ph[x1-1][y2]-ph[x2][y1]+ph[x1-1][y1];
        int ve = pv[x2][y2]-pv[x1][y2]-pv[x2][y1-1]+pv[x1][y1-1];

        //cout << sq << " " << he << " " << ve << "\n";

        cout << sq-he-ve << "\n";
    }

    return 0;
}


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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int n, C;
    cin >> n >> C;
    vector<vector<PII>> V(n+2);
    set<pair<PII, int>> startTimes;
    vector<PII> recorders;
    REP(i, n) {
        int s, t, c;
        cin >> s >> t >> c;
        // V[c].pb({s, t});
        startTimes.insert({{s, t}, c});
    }
    // debug(startTimes);
    for (auto p : startTimes) {
        if (SZ(recorders) == 0) {
            recorders.pb({p.first.second, p.second});
        } else {
            bool found = false;
            for (int i = 0; i < SZ(recorders); i++) {
                if (recorders[i].second == p.second) {
                    if (recorders[i].first <= p.first.first) {
                        recorders[i].first = p.first.second;
                        recorders[i].second = p.second;
                        found = true;
                        break;
                    }
                } else {
                    if (recorders[i].first < p.first.first) {
                        recorders[i].first = p.first.second;
                        recorders[i].second = p.second;
                        found = true;
                        break;
                    }
                }
            }
            if (!found) {
                recorders.pb({p.first.second, p.second});
            }
        }
    }
    cout << SZ(recorders) << endl;
}

Measured memory_bytes: 8832
#include <iostream>
#include <math.h>

using namespace std;
 
int main(){
  int N;
  cin >> N;
  int n = N;
  int ketasu = 1;
  int sum;
  while(N >= 10){
    N /= 10;
    ketasu++;
  }
  
  if(ketasu % 2 == 0){
    for(int i = 0;2*i < ketasu;i++){
      sum += 9*pow(10,2*i);
    }
  }else{
    for(int i = 1;2*i-1 < ketasu;i++){
      sum += 9*pow(10,2*i-2);
    }
    sum += n - pow(10,ketasu-1) +1;
  }
  cout << sum;
}

Measured memory_bytes: 256
s = input()
a = -1
b = -1

if len(s) == 2:
    if s[0] == s[1]:
        a = 1
        b = 2
else:
    for i in range(len(s)-2):
        if s[i] == s[i+1]:
            a = i+1
            b = i+2
            break
        if s[i] == s[i+2]:
            a = i+1
            b = i+3
            break
print(a, b)

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

def main():
    # 証言が矛盾していないかチェックする
    def check(bit):
        for i in range(n):
            if not bit & (1 << i):
                continue

            for human, is_honest in a[i]:
                if is_honest == 1 and (bit & (1 << human)):
                    continue
                elif is_honest == 0 and not (bit & (1 << human)):
                    continue
                else:
                    return False
        return True

    n = int(input())
    ans = 0
    a = [[] for _ in range(n)]
    for i in range(n):
        m = int(input())
        for j in range(m):
            xy = list(map(int, input().split()))
            xy[0] -= 1
            a[i].append(xy)

    # 全パターン回す
    for bit in range((1 << n)):
        num = 0
        if check(bit):
            for k in range(n):
                if bit & (1 << k):
                    num += 1
            ans = max(ans, num)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 68632
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
using namespace std;

int main() {
	int N; cin >> N;
	int cnt4 = 0, cnt2=0;
	for (int i = 0; i < N; i++) {
		int a; cin >> a;
		if (a % 4 == 0)cnt4++;
		else if (a % 2 == 0)cnt2++;
	}

	if (cnt4 >= N / 2)cout << "Yes" << endl;
	else if (0 >= N - 2 * cnt4 - cnt2)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256