akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MAX max<ll>
#define MIN min<ll>
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
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; }
ll devc(ll x, ll y) { return (x + y - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll H, W;
    cin >> H >> W;
    vec2 ans(H, vec(W, 0));
    vector<string> grid(H);
    rep(i, H){
        string s;
        cin >> s;
        grid[i] = s;
    }

    vec d = {-1, 0, 1};
    rep(i, H) rep(j, W){
        if(grid[i][j] == '#'){
            rep(k, 3) rep(h, 3){
                if(d[k] == 0 and d[h] == 0) continue;
                if((i + d[k] < 0) or (i + d[k] >= H)) continue;
                if((j + d[h] < 0) or (j + d[h] >= W))continue;
                
                ++ans[i + d[k]][j + d[h]];
            }
            ans[i][j] = INF;
        }
    }

    rep(i, H){
        rep(j, W){
            if (ans[i][j] >= INF) cout << "#";
            else cout << ans[i][j];
        }
        print("");
    }

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;

int a [5 + 5];

int main(void)
{
	for(int i=1; i<=5; ++i) scanf("%d",&a[i]);
	
	for(int i=1; i<=5; ++i)
		if(!a[i]) printf("%d\n",i);
	return 0;
}

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

int q, t, a, b;
long long su = 0;
priority_queue<int> lo;
priority_queue<int, vector<int>, greater<int>> hi;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> q;
    while (q--)
    {
        cin >> t;
        if (t == 1)
        {
            cin >> a >> b;
            su += b;
            if (hi.empty() || a <= hi.top())
            {
                su -= a;
                lo.push(a);
            }
            else
            {
                su += a;
                hi.push(a);
            }
            if (lo.size() > hi.size() + 1)
            {
                su += 2 * (lo.top());
                hi.push(lo.top());
                lo.pop();
            }
            if (lo.size() < hi.size())
            {
                su -= 2 * (hi.top());
                lo.push(hi.top());
                hi.pop();
            }
        }
        else
        {
            int x = lo.top();
            cout << x << " " << su + (lo.size() != hi.size() ? x : 0) << '\n';
        }
    }
}


Measured memory_bytes: 3452
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const int MAX_N=1e5+2;
const LL INF=1e12;
PLL dp[MAX_N];
int main(){
    int N;cin>>N;
    priority_queue<double>q;
    REP(i,N){
        int tmp;cin>>tmp;
        q.push(-tmp);
    }
    double res=0;
    while(q.size()>1){
        double x=q.top();q.pop();
        double y=q.top();q.pop();
        q.push((x+y)/2.0);
    }
    cout<<fixed<<setprecision(10)<<-q.top()<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long C = sc.nextLong();
        long[] x = new long[N];
        long[] v = new long[N];
        for(int n=0;n<N;n++){
        	x[n] = sc.nextLong();
        	v[n] = sc.nextLong();
        }
        
        long[] forwardSum = new long[N];
        forwardSum[0]=v[0];
        for(int n=1;n<N;n++) forwardSum[n]= forwardSum[n-1]+v[n];
        long[] forwardMax = new long[N];
        long[] forwardBackMax = new long[N];
        for(int n=0;n<N;n++){
	forwardMax[n] = Math.max(forwardSum[n]-x[n],(n==0)?0:forwardMax[n-1]);
	forwardBackMax[n] = Math.max(forwardSum[n]-2*x[n],(n==0)?0:forwardBackMax[n-1]);
        }
        long[] backwardSum = new long[N];
        backwardSum[N-1]=v[N-1];
        for(int n=N-2;n>=0;n--) backwardSum[n]= backwardSum[n+1]+v[n];
        long[] backwardMax = new long[N];
        long[] backwardBackMax = new long[N];
        for(int n=N-1;n>=0;n--){
        	backwardMax[n] = Math.max(backwardSum[n]-(C-x[n]) , (n==N-1)?0:backwardMax[n+1]);
        	backwardBackMax[n] = Math.max(backwardSum[n]-2*(C-x[n]) , (n==N-1)?0:backwardBackMax[n+1]);
        }
        
        long ans = Math.max(forwardMax[N-1], backwardMax[0]);
        for(int f=0;f<N-1;f++){
        	int b=f+1;
        	ans = Math.max(ans, forwardMax[f]+backwardBackMax[b]);
        	ans = Math.max(ans, forwardBackMax[f]+backwardMax[b]);
        }
        
        System.out.println(ans);

        
    }
}

Measured memory_bytes: 91544
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    static final int MAX = 100100;
    InputStream in = System.in;
    PrintStream out = System.out;
    // static int dp[][] = new int[MAX][MAX];

    public void _main(String[] args) {
        Scanner sc = new Scanner(in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        out.println(Math.min(n*a,b));

    }

    public static void main(String[] args) {
        new Main()._main(args);
    }
}


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

class Program
{
    static void Main(string[] args)
    {
        int[] input = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var K = int.Parse(ReadLine());

        int maxIdx = input.Select((val, idx) => new { Value = val, Index = idx }).Aggregate((max, work) => (max.Value > work.Value) ? max : work).Index;
        for (int i = 0; i < K; i++)
        {
            input[maxIdx] = input[maxIdx] * 2;
        }

        WriteLine(input.Sum());
    }

}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	ll sum = a+b;
	ll num = n/sum;
	ll r = n%sum;
	cout << num*a+min(a,r) << endl;
	return 0;
}



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

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
#include <queue>
#include <stack>

typedef long long ll;
typedef unsigned long long ull;

#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(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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

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

int lcm(int a, int b)
{return a * b / gcd(a, b);}

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}


int main(void){
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  if (s =="ARC") cout << "ABC" << endl;
  else cout << "ARC" << endl;
  return 0;
}



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

using ll = long long int;
using vi = vector<int>;
using vll = vector<long long int>;
using vii = vector<vi>;
using pii = pair<int, int>;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int QUA = 1e9 + 7;

int main(){
  ll n, m;
  scanf("%lld%lld", &n, &m);
  ll ans;
  if(2 * n >= m){
    ans = m / 2;
  }
  else{
    ans = n + (m - 2 * n) / 4;
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define maxn 200005

ll fastpower (ll b , ll p){
    ll k= p%2 ? b : 1 ;
    return p==0 ? 1 : k*(fastpower(b*b,p/2));
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;
	map<string,int> mp;
	string s;
	for(int i=0;i<n;i++){
		cin>>s;
		mp[s]++;
	}
	cout<<"AC x "<<mp["AC"]<<"\n";
	cout<<"WA x "<<mp["WA"]<<"\n";
	cout<<"TLE x "<<mp["TLE"]<<"\n";
	cout<<"RE x "<<mp["RE"]<<"\n";
}

Measured memory_bytes: 3652
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

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

Measured memory_bytes: 256
from collections import deque
n = int(input())
a = list(map(int, input().split()))
b = deque([])
for i in range(n):
    if (i%2==0):
        b.append(a[i])
    else:
        b.appendleft(a[i])
if (n%2==1):
    b.reverse()
    print(*b)
else:
    print(*b)

Measured memory_bytes: 32408
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
constexpr int INF = 0x3f3f3f3f; constexpr ll LLINF = 0x3f3f3f3f3f3f3f3f;
#define db(x) { cerr << #x << " = " << x << endl; }
template <typename T> void _dbarr(T* a, size_t sz){ for(int i = 0; i < sz; i++) cerr << a[i] << " \n"[i == sz-1]; }
template <typename T> void _dbarr(vector<T> a, size_t sz){ for(int i = 0; i < sz; i++) cerr << a[i] << " \n"[i == sz-1]; }
#define dbarr(x, n) {cerr << #x << ": "; _dbarr((x),(n));}
#define all(x) begin(x), end(x)
#define pb push_back
#define eb emplace_back
#define mpr make_pair
#define fs first
#define sn second

int main()
{
	cin.tie(0)->sync_with_stdio(0);
    string s,t;
    cin >> s >> t;

    int ans = INF;
    for(int i = 0; i < s.size()-t.size()+1; i++)
    {
        string sub = s.substr(i,t.size());
        int cnt = 0;
        for(int j = 0; j < sub.size(); j++)
            if(sub[j] != t[j]) cnt++;
        ans = min(ans,cnt);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3616
#include<iostream>
using namespace std;
int t[100][100],u[15][15],tmp[15][15],n,m;
int ansx,ansy;
void ro(){
  for(int i=0;i<m;i++){
    for(int j=0;j<m;j++){
      tmp[m-1-j][i]=u[i][j];
    }
  }
  for(int i=0;i<m;i++){
    for(int j=0;j<m;j++){
      u[i][j]=tmp[i][j];
    }
  }
}
int check(int y,int x){
  
  for(int i=0;i<m;i++){
    for(int j=0;j<m;j++){
      if(u[i][j]==-1)continue;
      if(ansx==-1){
	ansx=x+j;
	ansy=y+i;
      }
      if(t[y+i][x+j]!=u[i][j]){
	return 0;
      }
    }
  }
  return 1;
}
void judge(){
  
  for(int i=0;i<n-m+1;i++){
    for(int j=0;j<n-m+1;j++){
      for(int k=0;k<4;k++){
	ansx=-1;
	if(check(i,j)){
	  cout<<ansx+1<<' '<<ansy+1<<endl;
	  return;
	}
	ro();
      }
    }
  }
  cout<<"NA"<<endl;
}
int main(){
  while(cin>>n>>m&&n&&m){
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)cin>>t[i][j];
    for(int i=0;i<m;i++)for(int j=0;j<m;j++)cin>>u[i][j];
    judge();			      
  }
  return 0;
}

Measured memory_bytes: 1200
#include <iostream>

using namespace std;

int main(){

    int n, d, x;
    cin >> n >> d >> x;

    int res = x;

    for (int i = 0; i < n; i++){
        int temp;
        cin >> temp;


        int tempDay = 1;
        while (tempDay <= d) {
            tempDay += temp;
            res++;
        }

    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;

int main()
{
	int a, b, ans;
	char op;

	while (1) {

		cin >> a >> op >> b;

		if (op == '+') {
			printf("%d\n", a + b);
		}
		else if (op == '-') {
			printf("%d\n", a - b);
		}
		else if (op == '*') {
			printf("%d\n", a*b);
		}
		else if (op == '/') {
			printf("%d\n", a / b);
		}
		else {
			break;
		}
	}

	return 0;
}

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

int main(){
    int N; cin >> N;
    vector<double> p(N);
    rep(i, N) cin >> p[i];
    vector<vector<double>> dp(N+1, vector<double>(N+1));
    dp[0][0] = 1;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j <= i; j++){
            dp[i+1][j+1] += dp[i][j] * p[i];
            dp[i+1][j] += dp[i][j] * (1-p[i]);
        }
    }
    int half = N/2 + 1;
    double ans = 0;
    rep(i, N+1){
        if(half > i) continue;
        ans += dp[N][i];
    }
    printf("%.10f", ans);
    cout << endl;
    return 0;
}


Measured memory_bytes: 73784
#include <stdio.h>
#include <stdlib.h>

#define INF 114514810

struct iset_t {
	int data;
	struct iset_t* next[2];
};

struct iset_t* generateSet(int data, struct iset_t* next1, struct iset_t* next2) {
	struct iset_t* generated = malloc(sizeof(struct iset_t));
	generated->data = data;
	generated->next[0] = next1;
	generated->next[1] = next2;
	return generated;
}

int N, M;
int cost[128][128];
struct iset_t* usedEdges[128][128];

char edgeUsed[1024];

void traverseSet(struct iset_t* set) {
	if (set == NULL || set->data < 0) return;
	if (set->data > 0) edgeUsed[set->data] = 1;
	set->data = -1; /* visited */
	traverseSet(set->next[0]);
	traverseSet(set->next[1]);
}

int main(void) {
	int i, j, k;
	int count;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 1; i <= N; i++) {
		for (j = 1; j <= N; j++) {
			cost[i][j] = INF;
			usedEdges[i][j] = NULL;
		}
		cost[i][i] = 0;
	}
	for (i = 1; i <= M; i++) {
		int a, b, c;
		if (scanf("%d%d%d", &a, &b, &c) != 3) return 1;
		cost[a][b] = cost[b][a] = c;
		usedEdges[a][b] = usedEdges[b][a] = generateSet(i, NULL, NULL);
	}
	for (k = 1; k <= N; k++) {
		for (i = 1; i <= N; i++) {
			for (j = 1; j <= N; j++) {
				int current = cost[i][j];
				int candidate = cost[i][k] + cost[k][j];
				if (candidate < current) {
					cost[i][j] = candidate;
					usedEdges[i][j] = generateSet(0, usedEdges[i][k], usedEdges[k][j]);
				} else if (candidate == current) {
					usedEdges[i][j] = generateSet(0, usedEdges[i][j],
						generateSet(0, usedEdges[i][k], usedEdges[k][j]));
				}
			}
		}
	}
	for (i = 1; i <= N; i++) {
		for (j = 1; j <= N; j++) {
			traverseSet(usedEdges[i][j]);
		}
	}
	count = 0;
	for (i = 1; i <= M; i++) {
		if (!edgeUsed[i]) count++;
	}
	printf("%d\n", count);
	return 0;
}


Measured memory_bytes: 3456
import java.util.*;
public class Main{

  public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int k = sc.nextInt();
      
      int[][] edges = new int[n][2];
      Set<Integer> xs = new HashSet<>();
      Set<Integer> ys = new HashSet<>();
      for(int i = 0; i < n; i++) {
        edges[i][0] = sc.nextInt();
        edges[i][1] = sc.nextInt();
        xs.add(edges[i][0]);
        ys.add(edges[i][1]);
      }

      long area = Long.MAX_VALUE;
      int cnt = 0;

      for(int xP : xs) {
          for(int yP: ys) {
              for(int xP2 : xs) {
                for(int yP2: ys) {
              
                  cnt = 0;
                  long sX = Math.min(xP, xP2), sY = Math.min(yP, yP2);
                  long eX = Math.max(xP, xP2), eY = Math.max(yP, yP2);
                  for(int m = 0; m < edges.length; m++) {
                      long x = edges[m][0], y = edges[m][1];
                      if(sX <= x && x <= eX && sY <= y && y <= eY)
                        cnt++;
                  }
                  if(cnt >= k)
                      area = Math.min(area, (long)(eX - sX) * (long)(eY - sY));
                }
              }
          }

      }

      System.out.println(area);
  }
}



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

#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;

using namespace std;





void one_case() {
    int n;
    cin >> n;
    map<int, int> mp;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        ++mp[a];
    }
    int res = 0;
    for (auto p : mp) {
        if (p.second < p.first) {
            res += p.second;
        } else {
            res += p.second - p.first;
        }

    }
    cout << res << "\n";

}


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


    int t = 1;
//    cin >> t;
    while (t--) {
        one_case();
    }

    return 0;
}


Measured memory_bytes: 4736
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools

#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)


def main():
    n=int(input())
    go=n//500
    aaa=n-go*500
    go2=aaa//5
    print(1000*go+5*go2)




if __name__ == "__main__":

    main()

Measured memory_bytes: 38416
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char name[101];
    cin>>name;
    int i;
    int k=0,l=0;
    for(i=0;i<strlen(name);i++)
    {
        if(name[i]=='A')
        {
            k++;
        }
        else
        {
            l++;
        }
    }
    if(k>0 && l>0)
    {
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;
    return 0;
}


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

int main() {
  char c;
  cin >> c;

  if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o') 
  cout << "vowel";
  
  else cout << "consonant";
  
  cout << endl;
  
  
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    int k = sc.nextInt();
    String s = new String(sc.next());
    int num = s.length();
    if (num <= k) {
      System.out.println(s);
    } else {
      String a = s.substring(0, k);
      System.out.println(a + "...");
    }
  }
}

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

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

}


Measured memory_bytes: 1408
N = int(input())
alphabet_list = [chr(i) for i in range(97, 97 + N)]

import collections

previous_list = ["a"]
for i in range(1, N):
    out_list = []
    for a in previous_list:
        # print(len(collections.Counter(a)))
        for al in alphabet_list[:len(collections.Counter(a))+1]:
            # print(a + al)
            out_list.append(a+al)
    previous_list = out_list

for out in previous_list:
    print(out)

Measured memory_bytes: 58712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e2 + 3 , M = 1e5 + 3  , inf  = 0x3f3f3f3f;
int n , w;
ll weight[N] , value[N] , mem[N][M];
ll solve(int idx , int val){
       if(val <=0)
        return 0;
       if(idx == n)   // i reached the end and value > 0
          return inf;
       ll &ret = mem[idx][val];
       if(~ret)
        return ret;
       ret = inf ;
       ret =  min(solve(idx + 1 , val) , weight[idx] + solve(idx+1 , val - value[idx]));
       return ret;
}
int main ()
{   
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    memset(mem , -1 , sizeof mem);
    cin >> n >> w;
    for(int i = 0 ; i  <n ; ++i){
        cin >> weight[i] >> value[i];
    }
    for(int i = 100000 ; i>=0 ; --i){
        if(solve(0 , i) <= w){
            cout << i ;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 80768
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		int n = Integer.parseInt(str);
		String[][] list = new String[n][];
		long[] t = new long[n];
		long[] a = new long[n];

		for(int i=0; i<n; i++){
			str = input.readLine( );
			list[i] = str.split(" ");
			t[i] = Long.parseLong(list[i][0]);
			a[i] = Long.parseLong(list[i][1]);
		}

		long tans = t[0];
		long aans = a[0];

		for(int i=1; i<n; i++){
			for(long j=1; j< (long)Math.pow(10, 18);){
				if(tans<=t[i]*j && aans<=a[i]*j){
					tans = t[i]*j;
					aans = a[i]*j;
					break;
				}else if(tans<t[i]*j && aans>a[i]*j) {
					j = (long) Math.max(j+1,(aans/a[i]));
				}else if(tans>t[i]*j && aans<a[i]*j) {
					j = (long) Math.max(j+1,(tans/t[i]));
				}else  {
					j = (long) Math.max(j+1,Math.max((tans/t[i]),(aans/a[i])));
				}
			}
		}
		System.out.println(tans+aans);
	}
}


Measured memory_bytes: 22868
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;

struct UnionFind {
    vector<int> par, siz;

    UnionFind(int N){
        for(int i=0;i<N;++i){
            par.push_back(i);
            siz.push_back(1);
        }
    }

    int root(int x){
        while(x != par[x]) x = par[x];
        return x;
    }

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

    void unite(int x, int y){
        int xx = root(x);
        int yy = root(y);
        if(siz[xx] > siz[yy]) swap(xx, yy);
        par[yy] = xx;
        siz[xx] += siz[yy];
    }
};

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

    int ans = 0;
    bool tmpans;
    int zero;
    for(int i=0;i<M;++i){
        UnionFind tree(N);
        for(int j=0;j<M;++j){
            if(j==i) continue;
            tree.unite(a[j], b[j]);
        }
        tmpans = false;
        zero = tree.root(0);
        for(int j=1;j<N;++j){
            if(zero != tree.root(j)) tmpans = true;
        }
        if(tmpans) ans++;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n, u, i, p[114];
bool check(int q) {
	int cnt = 0;
	for (int i = 0; i < n; i++)if (p[i] >= q)cnt++;
	return (cnt >= q);
}
int main() {
	cin >> n;
	for (int j = 0; j < n; j++)cin >> p[j];
	for (i = 1;; i++) 
		if (!check(i))break;
	cout << --i << endl;
}

Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <numeric>
using namespace std;

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

int main() {
    string O, E;
    cin >> O >> E;
    string ans;
    if (E.size() == O.size() - 1) {
        rep(i, O.size()) {
            ans += O[i];
            if (i == O.size() - 1)break;
            ans += E[i];
        }
        cout << ans << endl;
    }
    else {
        rep(i, O.size()) {
            ans += O[i];
            ans += E[i];
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;


vector<int> a(10000001, -1);
int ans;

void func(int i, int n){
    
    int b;
    if(n%2==0)  b=n/2;
    else if(n%2==1)  b=3*n+1;
    
    
    if(a[b]==-1){
        a[b] = i+1;
        //cout<<b<<endl;
        func(i+1, b);
    }else{
        ans = i+1;
    }
}


int main()
{
    
    int s;
    cin >> s;
    a[s] = 1;
    func(1, s);
    cout << ans << endl;
    
    
    return 0;
}



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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

struct state{ int x,y,d; };

state memo[44444];

int main()
{
    int dx[4]={0,1,0,-1}, dy[4]={-1,0,1,0};

    int h,w;
    ll L;
    while(cin >>h >>w >>L,h)
    {
        vector<string> c(h);
        rep(i,h) cin >>c[i];

        ll v[100][100][4];
        memset(v,-1,sizeof(v));

        int x=0,y=0,d=0;
        rep(i,h)rep(j,w)
        {
            if(c[i][j]!='.' && c[i][j]!='#')
            {
                x=j;
                y=i;
                if(c[i][j]=='N') d=0;
                else if(c[i][j]=='E') d=1;
                else if(c[i][j]=='S') d=2;
                else if(c[i][j]=='W') d=3;
                break;
            }
        }

        ll cycle=0;
        ll pre=0;

        ll now=1;
        v[y][x][d]=0;
        memo[0]=state{x,y,d};
        #define IN(x,y) (0<=x && x<w && 0<=y && y<h)
        bool cantmove=true;
        while(1)
        {
            cantmove=true;
            rep(i,4)
            {
                int nx=x+dx[d], ny=y+dy[d];
                if(IN(nx,ny) && c[ny][nx]!='#')
                {
                    cantmove=false;
                    x=nx;
                    y=ny;
                    break;
                }
                d=(d+1)%4;
            }

            if(cantmove) break;

            // printf("y,x,d(%d,%d,%d) : %lld\n", y,x,d,now);

            if(v[y][x][d]>0)
            {
                pre=v[y][x][d];
                cycle=now-v[y][x][d];
                break;
            }

            v[y][x][d]=now;
            memo[now]=state{x,y,d};
            if(now==L) break;
            ++now;
        }

        if(!cantmove && now<L)
        {
            L-=pre;
            ll X=L/cycle;
            ll Y=L-X*cycle;
            // printf("cycle= %lld: pre,X,Y %lld,%lld,%lld\n", cycle, pre,X,Y);

            state final=memo[pre+Y];
            x=final.x;
            y=final.y;
            d=final.d;
        }

        string NESW="NESW";
        printf("%d %d %c\n", y+1, x+1, NESW[d]);
    }
    return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> T(H,vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W ; j++){
      cin >> T.at(i).at(j);
    }
  }
  int p1=0;
  vector<int> H1(H,0);
  vector<int> W1(W,0);
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W ; j++){
      if (T.at(i).at(j)=='#'){
        p1++;
      }
    }
  if (p1==0){
    H1.at(i)=1;
  }
    p1=0;
  }

  for (int i = 0; i < W; i++) {
    for (int j = 0; j < H ; j++){
      if (T.at(j).at(i)=='#'){
        p1++;
      }
    }
  if (p1==0){
    W1.at(i)=1;
  }
    p1=0;
  }


  for (int i=0;i<H;i++){
    if (H1.at(i)==0){
      for (int j=0;j<W;j++){
        if (W1.at(j)==0){
          cout << T.at(i).at(j);
        }
        if (j==W-1){
          cout << endl;
        }
      }
    }
  }
     
}

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

using namespace std;

#define ll long long
#define ld long double

/* aとbの最大公約数を求める. */
ll gcd(ll a, ll b) {
	if (b > a) return gcd(b, a);
	if (b == 0) return a;
	return gcd(b, a % b);
}

map< int64_t, int > prime_factor(int64_t n) {
	map< int64_t, int > ret;
	for (int64_t i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

signed main() {
	ll a, b;
	cin >> a >> b;

	ll g = gcd(a, b);
	if (g == 1) {
		cout << 1 << endl;
	}
	else {
		auto p = prime_factor(g);
		cout << p.size() + 1 << endl;
	}


	return 0;
}

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

#define ll long long
#define ld long double

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rrep(i, a, b) for(ll i = a; i >= b; --i)

#define pii pair<int, int>
#define pll pair<ll, ll>

#define fi first
#define se second

#define pb push_back
#define eb emplace_back

#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>

#define all(a) a.begin(), a.end()

#define endl '\n'
using namespace std;
using namespace atcoder;

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

const ll MOD=10000007;//998244353
const ll INF=1e18;
const int inf=1e9;
const double PI=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
 
const int MAX=1e6+10;



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n,m;
  cin >> n >> m;
  dsu tree(n);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    tree.merge(a,b);
  }
  int ans = tree.groups().size()-1;
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 8856
# Binary Indexed Tree
class BIT
  def initialize(n)
    @n = n
    @bit = Array.new(n+1,0) # 1 origin
  end

  # 1~i番目の要素の合計を求める
  def sum(i)
    ans = 0
    while i > 0
      ans += @bit[i]
      i -= i & -i
    end
    return ans
  end

  # i+1~n番目の合計を求める
  def greater(i)
    sum(@n) - sum(i)
  end

  # i番目の要素にxを加える
  def add(i,x)
    while i <= @n
      @bit[i] += x
      i += i & -i
    end
  end

  # 数列Aの転倒数を求める（副作用：内部状態の変更）
  def inversion!(a)
    ans = 0
    a.each do |x|
      add(x,1)
      ans += greater(x)
    end
    return ans
  end

end

# 入力、初期化
n,k = gets.split.map &:to_i
a = gets.split.map &:to_i
bit = BIT.new(2000)
MOD = 10**9+7

# s := An内での転倒数
s = bit.inversion!(a)

# t := ひとつ前のAnとの転倒数
t = a.inject(0){|acc,x| acc += bit.greater(x) }

# f(k) := k回繰り返した時の転倒数
# f(1) = s 
# f(k+1) = f(k) + k * t + s
# => f(k) = ks + (k-1)kt/2

ans = k * s + (k-1) * k * t / 2
puts ans % MOD


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#include <math.h>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int x,y,z;
	cin >> x>> y;
    z=x+y;
    if(z<x-y)z=x-y;
    if(z<x*y)z=x*y;
      cout << z << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <queue>

using namespace std;

struct node {
	long long val;
	node *left,*rgt;
	int cut;
	bool del;
};

struct ei {
	long long val;
	node *a,*b;
};

bool operator< (const ei &a ,const ei &b) {
	return a.val<b.val;
}

priority_queue<ei> q;

node* tbl[100100];
node* null;

int main () {
	int n,l;
	scanf("%d%d",&n,&l);
	long long x;
	null = new node{};
	null->left=null;
	null->rgt=null;
	for (int i=0;i<n;i++) {
		scanf("%lld",&x);
		tbl[i]=new node{x,null,null,i+1,false};
	}
	for (int i=0;i<n;i++) {
		if (i) tbl[i]->left=tbl[i-1];
		if (i<n-1) tbl[i]->rgt=tbl[i+1];
	}
	for (int i=0;i<n-1;i++) {
		q.push(ei{tbl[i]->val+tbl[i+1]->val,tbl[i],tbl[i+1]});
	}
	vector<int> ans;
	while (!q.empty()) {
		auto cur = q.top();
		q.pop();
		if (cur.val<l) continue;
		if (cur.a->del||cur.b->del) continue;
		node* now = new node {cur.a->val+cur.b->val,cur.a->left,cur.b->rgt,cur.b->cut,false};
		cur.a->del=true;
		cur.b->del=true;
		cur.a->left->rgt=now;
		cur.b->rgt->left=now;
		ans.push_back(cur.a->cut);
		q.push(ei{cur.a->left->val+now->val,cur.a->left,now});
		q.push(ei{cur.b->rgt->val+now->val,now,cur.b->rgt});
	}
	if (ans.size()<n-1) {
		printf("Impossible\n");
		return 0;
	}
	printf("Possible\n");
	for (int i=n-2;i>=0;i--) {
		printf("%d\n",ans[i]);
	}
	return 0;
}


Measured memory_bytes: 17004
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll A, B, K;
    cin >> A >> B >> K;

    if (K <= A) {
        A -= K;
    } else if (K <= A+B) {
        K -= A;
        B -= K;
        A = 0;
    } else {
        A = B = 0;
    }

    cout << A << " " << B << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	int a,b,c;
	
	public void solve(){
		Scanner sc = new Scanner(System.in);
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		
		if(a<b){
			if(b<c){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}else{
			System.out.println("No");
		}
	}
	
    public static void main(String args[]){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17224
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;
int main()
{
    int num, temp;
    int sum=0;
    scanf("%d", &num);
    temp=num;
    while(num)
    {
        sum = sum*10 + num%10; 
        num /= 10;
    }
    if(temp == sum) 
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include<set>
using namespace std; 
int main(void){
    int N,K;
  	scanf("%d%d",&N,&K);
  	int d[K];
    set<int>st;
  vector<vector<int>> A(K, vector<int>(N));
  for(int i= 0;i<K;i++){
  	scanf("%d",&d[i]);
    for(int j= 0;j<d[i];j++){
    	cin >>A.at(i).at(j);
      st.insert(A.at(i).at(j));
    }
  }
  int ans = 0;
  for(int k=0;k<N;k++)
	if(st.count(k+1)==0){
    	ans++;
    }
  printf("%d",ans);
}

Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define pii pair<int, int>
#define forr(i,a,n) for (int i = (a); i < (n); ++i)
#define rforr(i,a,n) for (int i = (a); i > (n); --i)
#define ALL(x) x.begin(),x.end()
#define LEN(X) ((int)(X).size())
#define CASET int _T; cin >> _T; forr(caset,0,_T)


int main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    //freopen("input.txt","w",stdout);
    int n; cin >> n;

    int ans=0;

    forr(i,1,n+1) forr(j,1,n+1) forr(k,1,n+1) {
        ans+=__gcd(__gcd(i,j),k);
    }
    cout << ans << '\n'; 

    return 0;
}


Measured memory_bytes: 3596
N = int(input())
S = input()

E = [0 for _ in range(N)]
count = 0
for i in range(N - 1, -1, -1):
    if S[i] == 'E':
        count += 1
    E[i] = count

W = [0 for _ in range(N)]
T = [0 for _ in range(N)]
count = 0
for i in range(N):
    if S[i] == 'W':
        count += 1
    W[i] = count

min_value = 1000000000000
for i in range(0, N):
    t = 0
    if i > 0:
        t += W[i - 1]
    if i < N - 1:
        t += E[i + 1]
    if min_value > t:
        min_value = t
print(min_value)

Measured memory_bytes: 20172
#include <bits/stdc++.h>
using namespace std;
 
#define INF (1LL << 31 - 1)
#define MOD int(1e9+7)
#define repi(i,j,n) for(int i = (j); i < (n); ++i)
#define rep(i,n) repi(i,0,n)
#define fi first
#define se second
 
inline void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}
 
int n, l, r;
int imos[100002];
 
int main() {
    init();
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> l >> r;
        l--, r--;
        imos[l]++;
        imos[r + 1]--;
    }
 
    for (int i = 1; i <= 100000; ++i) imos[i] += imos[i - 1];
 
    int ans = 0;
 
    for (int i = 0; i < 100001; ++i) {
        if (imos[i]) ans++;
    }
 
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
 
int n,e,u,d,i,j,g[100][100];
 
int main(){
 
  for(i=0;i<100;i++)
    for(j=0;j<100;j++)g[i][j]=0;
 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&e,&u);
    for(j=0;j<u;j++){
      scanf("%d",&d);
      g[e-1][d-1]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      printf("%d",g[i][j]);
      if(j!=n-1)printf(" ");
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2104
#include "bits/stdc++.h"

#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)

using namespace std;

using I = int;
using L = long;
using F = float;
using S = string;
using SS = stringstream;
using C = char;
using LL = long long;
using VC = vector<char>;
using VI = vector<int>;
using VL = vector<long>;
using VF = vector<float>;
using VS = vector<string>;
using VVI = vector<vector<int>>;
using VVL = vector<vector<long>>;
using PLL = pair<long, long>;
using PLF = pair<long, float>;
using PLS = pair<long, string>;
using PSL = pair<string, long>;
using PSF = pair<string, float>;
using PSS = pair<string, string>;
using MLL = map<long, long>;
using MLF = map<long, float>;
using MLS = map<long, string>;
using MSL = map<string, long>;
using MSF = map<string, float>;
using MSS = map<string, string>;

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;

template <class T>
void PrintVector(const vector<T> & v) {
  for (const auto & e: v) {
    cout << e << endl;
  }
}

template <class T>
void PrintVector(const vector<T> & v, I n) {
  rep(i, 0, n - 1) {
    cout << v[i] << endl;
  }
}

I h, w;
VI dx = {-1, 0, 1, 0};
VI dy = {0, 1, 0, -1};
vector<VC> maze(100, VC(100, '.'));
VVL d(100, VL(100, kMax6));
int BFS(int sx, int sy, int gx, int gy) {
  queue<PLL> que;
  que.emplace(sx, sy);
  d[sx][sy] = 0;

  while (!que.empty()) {
    auto p = que.front();
    que.pop();
    if (p.X == gx && p.Y == gy) break;
    rep(i, 0, 3) {
      auto nx = p.X + dx[i];
      auto ny = p.Y + dy[i];
      if (nx >= 0 && nx < h && ny >= 0 && ny < w && maze[nx][ny] != '#' && d[nx][ny] == kMax6) {
        que.emplace(nx, ny);
        d[nx][ny] = d[p.X][p.Y] + 1;
      }
    }
  }
  return d[gx][gy];
}

int main(int argc, char const *argv[]) {
  I w_cnt = 0;
  cin >> h >> w;
  rep(i, 0, h - 1) {
    rep(j, 0, w - 1) {
      char c;
      cin >> c;
      maze[i][j] = c;
      if (c == '.') { ++w_cnt; }
    }
  }
  auto min_len = BFS(0, 0, h - 1, w - 1);
  if (min_len != kMax6) { cout << w_cnt - min_len - 1 << endl; }
  else { cout << -1 << endl; }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  vector<int>n(3);
  for(int i=0;i<3;i++)
    cin >> n.at(i);
  sort(n.begin(),n.end());
  vector<int>m = {5,5,7};
  if(n==m)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

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

long long gcd(long long x,long long y){return y ? gcd(y,x%y):x;}

int main(){
    long long A,B,C,D;cin>>A>>B>>C>>D;
    long long l=C*D/gcd(C,D);
    //cout<<l<<endl;
    long long n=((B/C)+(B/D)-(B/l));
    long long m=((A-1)/C+(A-1)/D-(A-1)/l);
    cout<<-n+m+B-A+1<<endl;

}

Measured memory_bytes: 256
#include<cstdio>
const int MAXN = 100;
int a[MAXN + 5];
int main() {
	int n;
	scanf("%d", &n);
	int siz = 0, ans = 0;
	for(int i=1;i<=n;i++) {
		scanf("%d", &a[i]);
		if( a[i] == a[i-1] ) {
			siz++;
		}
		else {
			ans += siz / 2;
			siz = 1;
		}
	}
	ans += siz / 2;
	printf("%d\n", ans);
}

Measured memory_bytes: 128
ND = list( map(int, input().split()) ) 
N, D = ND[0], ND[1]


count = 0
for _ in range(N): #複数行にわたって読み込みたい場合はrangeでfor文を回す。
    XY = list( map(int, input().split()) ) 
    if XY[0]*XY[0]+XY[1]*XY[1] <= D*D:
        count += 1
    
print(count)

Measured memory_bytes: 9192
n ,c = map(int,input().split())
wt =[]; val=[]
wt.append(0);val.append(0)

for _ in range(n):
  wi , vi = map(int,input().split())
  wt.append(wi)
  val.append(vi)
  
# dp [n][max_val] = 0 

max_val = sum(val)
INF = 10 **10
dp = [[INF for i in range(max_val+1)]for j in range(n+1)]

for i in range(n+1):
  dp[i][0]=0

for i in range(1,n+1):
  wi = wt[i];vi = val[i]
  for V in range(1,max_val+1):
    if vi<=V:
      dp[i][V] = min(wi+dp[i-1][V-vi] , dp[i-1][V])
    else:
      dp[i][V] = dp[i-1][V]

res = 0

for i in range(max_val+1):
  if dp[n][i] <= c:
    res = i
    
print(res)
  
  
  
  


Measured memory_bytes: 171116
#include<stdio.h>
int main()
{
    int i,n,m,k,a;
    double b;
    while(scanf("%d",&n)!=EOF)
    {
        for(i=0,m=0,k=0;i<n;i++)
        {
            scanf("%d",&a);
            if(a%4==0)
                m++;
            else if(a%2==0)
                k++;
        }
        m+=k/2;
        if(m>=n/2)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
n = int(input())
a,b = [], []
for i in range(n):
    s,t = list(map(int, input().split()))
    a.append(s)
    b.append(t)

res = 0
for i in range(n-1, -1, -1):
    if not (a[i]+res)%b[i] == 0:
        res += b[i] - (a[i]+res)%b[i]
print(res)

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

int main() {
    int x;cin>>x;
    for(int i=x;;i++){
        if(is_prime(i)){
            cout<<i<<endl;
            break;
        }
    }
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getF() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 2)
	if e != nil {
		panic(e)
	}
	return i
}

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

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = getInt()
	}

	n := [3]int{0, 0, 0}
	for i := 0; i < N; i++ {
		switch a[i] {
		case 1:
			n[0]++
		case 2:
			n[1]++
		case 3:
			n[2]++
		}
	}

	var dp [301][301][301]float64
	for i := 0; i < 301; i++ {
		for j := 0; j < 301; j++ {
			for k := 0; k < 301; k++ {
				dp[i][j][k] = -1
			}
		}
	}

	dp[0][0][0] = 0.0
	for k := 0; k <= n[2]; k++ {
		for j := 0; j <= n[1]+n[2]-k; j++ {
			for i := 0; i <= n[0]+n[1]+n[2]-k-j; i++ {
				if i == 0 && j == 0 && k == 0 {
					continue
				}
				sum := 0.0
				if i > 0 {
					sum += dp[i-1][j][k] * float64(i)
				}
				if j > 0 {
					sum += dp[i+1][j-1][k] * float64(j)
				}
				if k > 0 {
					sum += dp[i][j+1][k-1] * float64(k)
				}
				sum += float64(N)
				sum /= float64(i + j + k)
				dp[i][j][k] = sum
			}
		}
	}

	out(dp[n[0]][n[1]][n[2]])
}


Measured memory_bytes: 220544
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,k;
  cin>>a>>b>>k;
  for(int i=1;i<=k;i++){
    if(i%2){
      if(a%2)a--;
      b+=a/2,a/=2;
    }
    else{
      if(b%2)b--;
      a+=b/2,b/=2;
    }
  }
  cout<<a<<" "<<b<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,r;
    cin>>s>>r;
    int n=s.length();
    int c=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]!=r[i])
        {

            c++;
        }
    }
    cout<<c<<endl;
}


Measured memory_bytes: 3916
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    vector<int> v(h + 1, w);
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        v[x - 1] = min(v[x - 1], y - 1);
    }
    v[h] = -1;

    int nowy = 0;
    for (int i = 0; i <= h; i++) {
        if (v[i] < nowy) {
            cout << i << endl;
            break;
        }
        if (v[i] != nowy)nowy++;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
vector<int> to[200005];
vector<int> ans;

void dfs(int v, int p=-1){
    for(int u:to[v]){
        if(u==p) continue;
        ans[u]+=ans[v];
        dfs(u,v);
    }
}



int main(){
    int n,q;
    cin>>n>>q;
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans.resize(n);
    
    rep(i,q){
        int p,x;
        cin>>p>>x;
        p--;
        ans[p]+=x;
    }
    dfs(0);
    rep(i,n){
        cout<<ans[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 23552
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
const int inf = 1e+9;

const ll mod = 1000000007;



int main() {
	string s;
	cin >> s;
	if (s == "ABC") {
		cout << "ARC" << endl;
	} else {
		cout << "ABC" << endl;
	}

	return 0;
}


Measured memory_bytes: 3100