akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
 
class Main {
 
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken());
        int m = Integer.parseInt(st.nextToken());
        int l = Integer.parseInt(st.nextToken());
        long[][] matrix1 = new long[n][m];
        long[][] matrix2 = new long[m][l];
        for (int i = 0; i < n; i++) {
            st = new StringTokenizer(br.readLine());
            for (int j = 0; j < m; j++) {
                matrix1[i][j] = Long.parseLong(st.nextToken());
            }
        }
        for (int i = 0; i < m; i++) {
            st=new StringTokenizer(br.readLine());
            for(int j=0;j<l;j++){
                matrix2[i][j]=Long.parseLong(st.nextToken());
            }
        }
        long[][] sum = dot(matrix1, matrix2, n, m,l);
        for (int i = 0; i < n; i++) {
            for(int j=0;j<l;j++){
                if(j!=l-1){ System.out.print(sum[i][j]+" "); }
                else System.out.print(sum[i][j]);
            }System.out.println();
        }
    }
 
    static long[][] dot(long[][] matrix1, long[][] matrix2, int n, int m,int l) {
        long[][] sum = new long[n][l];
        for(int i=0;i<n;i++){ Arrays.fill(sum[i], 0); }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < l; j++) {
                for(int k=0;k<m;k++){
                    sum[i][j]+=(matrix1[i][k]*matrix2[k][j]);
                }
            }
        }
        return sum;
    }
}
 

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

int main() {
    int n;
    cin >> n;
    int a,ans,mi;
    map<int,int> m;
    m[8] = 0;
    for(int i=0; i<n; i++){
        cin >> a;
        if(a >= 1 && a <= 399){
            m[0]++;
        }
        if(a >= 400 && a <= 799){
            m[1]++;
        }
        if(a >= 800 && a <= 1199){
            m[2]++;
        }
        if(a >= 1200 && a <= 1599){
            m[3]++;
        }
        if(a >= 1600 && a <= 1999){
            m[4]++;
        }
        if(a >= 2000 && a <= 2399){
            m[5]++;
        }
        if(a >= 2400 && a <= 2799){
            m[6]++;
        }
        if(a >= 2800 && a <= 3199){
            m[7]++;
        }
        if(a >= 3200){
            m[8]++;
        }
    }
    if(m.size()-1 == 0){
        mi = 1;
    }
    else{
        mi = m.size()-1;
    }
    if(m[8] == 0){
        ans = m.size()-1;
    }
    else{
        ans = m.size()-1 + m[8];
    }
    cout << mi << " " << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;
    int n=max(a,b);
    int cnt=0;
    for(int i=n;i>=1;i--){
        if(a%i==0&&b%i==0) cnt++;
        if(cnt>=c){
            cout<<i<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int w, h;
int c[50][50];
int dx[8]={-1,0,1,-1,1,-1,0,1,};
int dy[8]={-1,-1,-1,0,0,1,1,1};

void dfs(int x,int y){
  int i;
  c[y][x]=0;
  for(i=0;i<8;i++){
    int ny=y+dy[i];
    int nx=x+dx[i];
    if(ny>=0&&ny<h&&nx>=0&&nx<w){
      if(c[ny][nx]==1) dfs(nx, ny);
    }
  }
}

int main(){

  int i, j, ans;

  while(scanf("%d %d", &w, &h), w){

    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	scanf("%d", &c[i][j]);
      }
    }
    
    ans=0;
    
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(c[i][j]==0) continue;
	if(c[i][j]==1){
	  ans++;
	  dfs(j, i);
	}
      }
    }
    
    printf("%d\n", ans);
  }
    
    
  return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())

signed main(){

	string s;
	cin>>s;

	lli cnt=0;
	for(lli i=0;i<s.size()/2;i++){
		if(s.at(i)!=s.at(s.size()-1-i))cnt++;
	}

	cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < (int)vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

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

	int N;
	cin >> N;

	map<int, int> mp;
	int a;
	for (int i = 0; i < N; i++) {
		cin >> a;
		a++;
		mp[a - 1]++; mp[a]++, mp[a + 1]++;
	}

	cout << max_element(mp.begin(), mp.end(),
			[](auto r, auto l) {return r.second < l.second; }) -> second << "\n";

	return 0;
}

Measured memory_bytes: 4736
import java.util.*;
public class Main{
	public static void main(String []args){
    	Scanner sc = new Scanner(System.in) ;
      	int n = sc.nextInt() ;
      	sc.nextLine() ;
      //	String s1 = sc.next() ;
      //	String s2 = sc.next() ;
      String s[] = sc.nextLine().split(" ") ;
      String s1 = s[0] ; 
      String s2 = s[1] ;
      
       String res = "" ;
      	for(int i = 0  ; i < s1.length() ; i++) {
        	res+=s1.charAt(i);
            res+=s2.charAt(i) ; 
        }
      System.out.println(res) ;
    }
}

Measured memory_bytes: 21844
#include<stdio.h>
int main()
{
    int r , xi , D , i;
    int x=0;
    scanf("%d %d %d",&r , &D, &xi);
    for (i=0 ; i<10 ; i++)
    {
        x = r*xi - D;
        printf("%d\n",x);
        xi=x;
    }
    return 0;
}


Measured memory_bytes: 128
$ary = []
$queries = []

def calc
  res = 0

  $queries.each do |q|
    res += q[3] if $ary[q[1] - 1] - $ary[q[0] - 1] == q[2]
  end

  return res
end

def dfs
  return calc() if $ary.length >= $len
  
  min = 1
  min = $ary[-1] if $ary.length > 0

  res = 0
  (min..$max).each do |i|
    $ary.push(i)
    res = [dfs(), res].max
    $ary.pop
  end

  return res
end

$len, $max, num_queries = gets.split.map(&:to_i)

num_queries.times do |i|
  $queries.push(gets.split.map(&:to_i))
end

puts dfs()

Measured memory_bytes: 14384
#include<iostream>
#include<iostream>
#include<string>
#include<sstream>
#include<vector>
#include<algorithm>
#include<math.h>
#include"boost/algorithm/string.hpp"

using namespace std;


typedef struct{
	long param;//座標
	long delta;//次の値との差分
}mass;

int main(){


	/*Q1*/
	//typedef
	

	int a, b = 0;
	
	cin >> a >> b;

	cout << (b % a == 0 ? a + b : b - a) << endl;

	return 0;

	/*Q2*/

	/*Q3*/

		/*Q4*/

		//return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector <double> v(N);

    for (int i = 0; i < N; i++){
        cin >> v.at(i);
    }
    sort(v.begin(),v.end());

    for (int i = 0; i < N - 1; i++){
        v.at(i+1) = (v.at(i) + v.at(i+1)) / 2;
    }
    
    cout << v.at(N-1) << endl;
}


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

using namespace std;
const int maxn=2e5+5;
int a[maxn],b[maxn];
int main() {
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",a+i);
    int l=1,r=n;
    for(int i=n;i;i--)
    {
        if((n-i)&1) b[r--]=a[i];
        else b[l++]=a[i];
    }
    for(int i=1;i<=n;i++)
        printf("%d%c",b[i],i==n?'\n':' ');
    return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;


int main() {
  string s;
  cin >> s;
  char temp=s[0];
  ll ans=0;
  for(ll i=1;i<s.size();i++) {
    if(s[i]!=temp) {
      temp=s[i];
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    ll x;
    cin >> x;
    ll ans = (x/11) * 2;
    if (x%11) ans += (x%11 <= 6) ? 1 : 2;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

int main(){
  int i,T,j;
  cin >> T;
  long long A,B,C,D,G,K;
  for (i=0;i<T;++i) {
    cin >> A >> B >> C >> D;
    if (A<B || D < B) {
      cout << "No" << endl;
      continue;
    }
    G=gcd(D, B);
    if (C-A>=0) {
      K=((C-A)/G)+1;
    } else {
      K=((C-A+1)/G);
    }
    if (A+(K*G)< B) {
      cout << "No" << endl;
      continue;
    } else {
      cout << "Yes" << endl;
      continue;
    }
  }
  return 0;
}


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

using namespace std;
int main(){
  int n,x;
  int cnt=0;
  int flag=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x;

if(x==2) flag=0;
else if(x%2==0) flag=1;

else{
    for(int j=2;j<=sqrt(x);j++){
      if(x%j==0){
        flag=1;
        break;
      }
    }
  }
      if(flag==0) cnt++;
      flag=0;
    }
  cout<<cnt<<endl;
  return 0;
}



Measured memory_bytes: 3056
// Problem : A - ringring
// Contest : AtCoder - AtCoder Beginner Contest 066
// URL : https://atcoder.jp/contests/abc066/tasks/abc066_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
int a,b,c;cin>>a>>b>>c;
cout<<a+b+c-max2(a,max2(b,c));
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


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

int main() {
  int r, g, b;
  int R, G, S;
  cin >> r >> g >> b;
  R=r*100;
  G=g*10;
  S=R+G+b;
  
  if(S%4==0) cout << "YES" << endl;
  else cout << "NO" << endl;  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const int inf=0x3f3f3f3f;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	long long a;
	cin>>a;
	long long ans=a+a*a+a*a*a;
	cout<<ans<<endl; 
	return 0;
}




Measured memory_bytes: 3648
N = int(input())
S = list(input())

ans = ""

for i in range(len(S)):
    s = ord(S[i])

    if 65 <= s & s <= 90:
        s = s + N
        if s > 90:
            s = s - 26
    
    elif 97 <= s & s <= 122:
        s = s + 13
        if s > 122:
            s = s - 26
    
    ans += chr(s)

print(ans)


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n,d;
vector<int> v;

signed main() {
    cin >> n;
    rep(i,n) cin >> d,v.pb(d);
    sort(all(v));
    cout << v[n/2] - v[n/2-1] << endl;
}



Measured memory_bytes: 1400
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
int main(){
    //CIN(N);
    //SCIN(str);
    CIN(A);
    CIN(B);
    //CIN(C);
    COUT((A-1)*(B-1));
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;
template <typename T> using vvec = vector<vector<T>>;

constexpr int64_t mpow(int64_t a, int64_t b, int64_t mod = 1000000007) {
    if (b <= 0) { return 1; } if (b == 1) { return a % mod; } if (b == 2) { return (a * a) % mod; }
    return (max(a * (b & 1), (int64_t)1) * mpow(mpow(a, b / 2, mod), 2, mod)) % mod;
}
constexpr int64_t mdiv(int64_t a, int64_t b, int64_t mod = 1000000007) {
    return (a * mpow(b, mod - 2, mod)) % mod;
}

int main() {
    int n, k; cin >> n >> k;
    int p;
    for (int i = 0; i < n; ++i) {
        int a; cin >> a;
        if (a == 1) p = i;
    }

    int ans = INT_MAX;
    for (int i = 0; i < k; ++i) {
        int cnt = 1;
        int s1 = max(1, p - i + 1) - 1;
        int s2 = max(1, n - (p + k - i - 1)) - 1;

        ans = min(ans, 1 + (s1 + k - 2) / (k - 1) + (s2 + k - 2) / (k - 1));
    }

    cout << ans << endl;
}



Measured memory_bytes: 3632
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var count = 0;
        for (int i = a; i <= b; i++)
            if (checkK(i)) count++;
        Console.WriteLine(count);
    }
    public static bool checkK(int n)
    {
        var s = n.ToString();
        return s[0] == s[4] && s[1] == s[3];
    }
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};



int main()
{
  int n, m; cin >> n >> m;
  vector<llP> drink(n);
  rep(i, n) cin >> drink[i].first >> drink[i].second;
  sort(ALL(drink));

  ll now = 0;
  ll ans = 0;
  rep(i, n) {
    if(now + drink[i].second <= m) {
      ans += drink[i].first * drink[i].second;
      now += drink[i].second;
    }
    else {
      ans += drink[i].first * (m-now);
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4840
N, M = map(int, input().split())
A = list(map(int, input().split()))
D = {0:1}
for i in A:
  i %= M
S = 0
for i in range(N):
  S += A[i]
  S %= M
  if S % M in D:
    D[S%M] += 1
  else:
    D[S%M] = 1
perm = 0
for i in D:
  perm += (D[i] * (D[i] - 1)) // 2
print(perm)

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

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

// code starts
#define INF 1020304050

int main()
{
  int n,m,x;cin>>n>>m>>x;
  vector<int> c(n);
  vector<vector<int>> a(n,vector<int>(m));
  int i,j,k;
  rep(i,n)
  {
    cin>>c[i];
    rep(j,m)cin>>a[i][j];
  }
  int ans=INF;
  rep(i,1<<n)
  {
    bool ok=true;
    int kcost=0;
    vector<int> skill(m,0);
    rep(j,n)
    {
      if((1<<j)&i)
      {
        kcost+=c[j];
        rep(k,m)
        {
          skill[k]+=a[j][k];
        }
      }
    }
    rep(j,m)
    {
      if(skill[j]<x)ok=false;
    }
    if(ok)ans=min(ans,kcost);
  }
  if(ans==INF)cout<<-1<<endl;
  else cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int n, k;
    cin >> n >> k;
    int ans = 1050;
    for(int a = 0; a <= n; a++){
        int tmp = 1;
        for(int i = 0; i < a; i++)
            tmp *= 2;
        int b = n - a;
        while(b--)
            tmp += k;
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <climits>
#include <string>
#include <set>
#include <cmath>
#include <map>
#include <unordered_map>
#include <numeric>
#include <random>
#include <memory>
#include <chrono>
#include <functional>
#include <unordered_set>
#include <cstring>
#include <cassert>
#include <bitset>
#ifdef LOCAL
#include "debug.h"
#else
#define debug(x...)
#endif

//#define int ll
//#pragma GCC optimize("Ofast")

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define sz(x) int((x).size())

#ifdef ONLINE_JUDGE
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#else
mt19937 rng(228);
#endif

const int N = 2e6 + 7;
const int inf = INT_MAX / 2;
const ll INF = LLONG_MAX / 3;
//const int MOD = 998244353;
const int MOD = 1e9 + 7;
const ld eps = 1e-6;
const pii dir[] = { { 0, 1 }, { 0, -1 }, { 1, 0 }, { -1, 0 } };


signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cout << fixed << setprecision(9);
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    int n, m, k;
    cin >> n >> m >> k;

    char a[n][m];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }

    int ans = 0;
    for (int m1 = 0; m1 < (1 << n); m1++) {
        for (int m2 = 0; m2 < (1 << m); m2++) {
            char b[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    b[i][j] = a[i][j];
                }
            }

            for (int i = 0; i < n; i++) {
                if ((m1 >> i) & 1) {
                    for (int j = 0; j < m; j++) {
                        b[i][j] = '!';
                    }
                }
            }

            for (int j = 0; j < m; j++) {
                if ((m2 >> j) & 1) {
                    for (int i = 0; i < n; i++) {
                        b[i][j] = '!';
                    }
                }
            }

            int cur = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    cur += (b[i][j] == '#');
                }
            }
            ans += (cur == k);
        }
    }    

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost {ios_base::sync_with_stdio(false);}
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
#define scanf(...) scanf(__VA_ARGS__)?:0
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <PII, PII> PP;
typedef pair <PII, int> PPI;
typedef pair <int, PII> PIP;
typedef pair <ll, int> PLI;
typedef unsigned int ui;
typedef vector <int> vi;
const int mod = 1e9+7;
const int inf = 1e9+10;
const ll MOD = 1e9+696969;
const ll INF = 1e18;
const int W = 1e9;
#define maxn 500100
int tab[maxn], n, DL, a;
ll dp[maxn];
int main()
{
	ll res = 0;
	boost;
	cin >> n;
	FOR(i, 1, n) 
	{
		cin >> a;
		if (a >= 3) {
			a -= 3;
			res += (a / 2);
			a %= 2;
			a += 3;
		}
		FOR(j, 1, a) tab[++DL] = i;
	}
	dp[0] = dp[1] = 0;
	sort(tab+1, tab+DL+1);
	
	FOR(i, 2, DL)
	{
		if (tab[i] - tab[i-1] <= 1) dp[i] = dp[i-2] + 1;
		dp[i] = max(dp[i], dp[i-1]);
	}
	cout << dp[DL] + res;
}


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

using namespace std;

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

typedef long long ll;

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

const long long INF = 1LL << 60;

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() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int w,a,b; cin>>w>>a>>b;
  
  int res = 0;
  if (b>=a+w) {
    res = b-a-w;
  }else {
    res = a-b-w;
  }
  
  res = max(0,res);
  cout<<res;
}

Measured memory_bytes: 3648
use std::io::prelude::*;

fn main() {
    let mut input_str = String::new();
    std::io::stdin().read_to_string(&mut input_str).unwrap();

    let input_parts = input_str.split_whitespace().collect::<Vec<_>>();
    let mut input_parts_it = input_parts.iter().cloned();

    let code = input_parts_it.next().unwrap();
    let code = code.as_bytes();

    for i in 0..3 {
        if code[i] == code[i + 1] {
            println!("Bad");
            return;
        }
    }

    println!("Good");
}


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

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

bool isPrime(int n){
    for(int i=2; i*i<=n; i++){
        if(n%i == 0) return false;
    }

    return true;
}

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

    int cnt = 0;
    for(int i=2; i<=55555; i++){
        if(isPrime(i) && i%5 == 1){
            cout << i;
            cnt++;

            if(cnt != N){
                cout << " ";
            }
            else{
                cout << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int x,y,i;

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	int h, m, s;
	scanf("%d", &x);
	h = x / 3600;
	x = x - h * 3600;
	m = x / 60;
	x = x - m * 60;
	s = x;


	printf("%d:%d:%d\n", h, m, s);











	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	return 0;
}


Measured memory_bytes: 2100
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int N, q;
    string S;
    cin >> N >> q >> S;
    vector<int> count(N, 0);
    int now_cnt = 0;
    for(int i = 1; i < N; i++){
        if(S[i-1] == 'A' && S[i] == 'C'){
            now_cnt++;
        }
        count[i] = now_cnt;
    }
    vector<int> ans(q);
    rep(i, q){
        int l, r;
        cin >> l >> r;
        int val = count[r-1] - count[l-1];
        ans[i] = val;
    }
    rep(i, q) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 4280
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)

using namespace std;
typedef pair<int, int> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

int L, R;

//|{ x ∈ [1, right]; x ≡ m (mod r) }|
llong modcnt(llong right, llong r, llong m) {
    if(right == 0) return 0;
    m = modulo(m, r), r = abs(r);
    return right / r + (m <= right % r && m != 0);
}

//|{ x ∈ [left, right]; x ≡ m (mod r) }|
llong modcnt(llong left, llong right, llong r, llong m) {
    llong res = 0;
    if(left > 0)
        res -= modcnt(left - 1, r, m);  // [1, left - 1]
    else if(left < 0)
        res += modcnt(-left, r, r - m);    // [left, -1]
    
    if(right > 0)
        res += modcnt(right, r, m); // [1, right]
    else if(right < 0)
        res -= modcnt(-right - 1, r, r - m);    // [right + 1, -1]
    
    if(left <= 0 && right >= 0)
        res += m % r == 0;  // {0}
    return res;
}

llong cnt[2019];
int solve() {
    for(int i = 0; i < 2019; ++i) {
        cnt[i] = modcnt(L, R, 2019, i);
    }

    int res = INF;
    for(int i = 0; i < 2019; ++i)
        for(int j = 0; j < 2019; ++j) {
            if(i == j) {
                if(cnt[i] <= 1) continue;
                res = min(res, (i * j) % 2019);
            } else {
                if(cnt[i] == 0 || cnt[j] == 0) continue;
                res = min(res, (i * j) % 2019);
            }

        }
    
    return res;
}

int main(int argc, char **argv) {
    cin >> L >> R;

    cout << solve() << endl;
}

Measured memory_bytes: 256
// finish date: 2018/03/14

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


int main() {
    int N;
    cin >> N;
    vi p(N);
    rep(i, N) cin >> p[i];
    vi a(N), b(N);
    rep(i, N) {
        a[i] = 30000 * (i + 1);
        b[i] = 30000 * (N - i);
    }
    rep(i, N) {
        b[p[i] - 1] += i;
    }
    rep(i, N) cout << a[i] << " ";
    cout << endl;
    rep(i, N) cout << b[i] << " ";
    cout << endl;

    return 0;
}

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

int main() {

	ll n; cin >> n;
	const ll p = 26;
	string  ans = "";
	ll tmp = n;
	while (true) {
		tmp--;
		ll mod = tmp % p;
		string mod_s{ (char)('a' + mod) };
		ans += mod_s;
		if (tmp / p == 0) break;
		tmp /= p;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define mod 1000000007

const long double PI = acos(-1);
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main(){
    ll n;
    cin >> n;
    ll a[n+1];
    for(ll i = 0; i < n; i++) cin >> a[i];

    sort(a, a+n);

    map<ll, ll> mp;
    for(ll i = 0; i < n; i++) mp[a[i]]++;

    ll ans = 0;
    for(ll i = 0; i < n; i++){
        if(a[i] == a[i+1]) continue;
        if(mp[a[i]] % 2 == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

const int MAX = 1e5 + 5;

#define dbg(a) cout << "-> " << __LINE__ << ": " << #a << " = " << a << endl

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	string s;
	cin >> n >> s;
	for (char &c : s) {
		--c;
	}
	int sub = n - 1, odd = s[0] - '0';
	while (sub > 0) {
		odd += (s[sub] - '0');
		odd %= 2;
		sub = (sub - 1) & (n - 1);
	}
	if (odd != 0) {
		cout << 1 << '\n';
		return 0;
	}
	for (char &c : s) {
		if (c == '1') {
			cout << '0' << endl;
			return 0;
		}
		c = (c == '2') ? '1' : '0';
	}
	sub = n - 1, odd = s[0] - '0';
	while (sub > 0) {
		odd += (s[sub] - '0');
		odd %= 2;
		sub = (sub - 1) & (n - 1);
	}
	if (odd != 0) {
		cout << 2 << '\n';
	}
	else {
		cout << 0 << '\n';
	}
	return 0;
}


Measured memory_bytes: 1948
#include <bits/stdc++.h>
using namespace std;
int INF = 1000000;
int main(){
  while (1){
    int N, M, L, K, A, H;
    cin >> N >> M >> L >> K >> A >> H;
    if (N == 0 && M == 0 && L == 0 && K == 0 && A == 0 && H == 0){
      break;
    }
    vector<int> C(L);
    for (int i = 0; i < L; i++){
      cin >> C[i];
    }
    vector<vector<pair<int, int>>> E(N);
    for (int i = 0; i < K; i++){
      int X, Y, T;
      cin >> X >> Y >> T;
      E[X].push_back(make_pair(T, Y));
      E[Y].push_back(make_pair(T, X));
    }
    vector<vector<pair<int, int>>> E2(N * (M + 1));
    for (int i = 0; i < L; i++){
      for (int j = 0; j < M; j++){
        E2[C[i] * (M + 1) + j].push_back(make_pair(1, C[i] * (M + 1) + j + 1));
      }
    }
    for (int i = 0; i < N; i++){
      for (auto P : E[i]){
        int t = P.first;
        int j = P.second;
        for (int k = 0; k <= M - t; k++){
          E2[i * (M + 1) + k + t].push_back(make_pair(t, j * (M + 1) + k));
          E2[j * (M + 1) + k + t].push_back(make_pair(t, i * (M + 1) + k));
        }
      }
    }
    int V = N * (M + 1);
    int s = A * (M + 1);
    vector<int> d(V, INF);
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
    pq.push(make_pair(0, A * (M + 1) + M));
    while (!pq.empty()){
      int c = pq.top().first;
      int v = pq.top().second;
      pq.pop();
      if (d[v] == INF){
        d[v] = c;
        for (auto P : E2[v]){
          int w = P.second;
          if (d[w] == INF){
            pq.push(make_pair(d[v] + P.first, w));
          }
        }
      }
    }
    int ans = INF;
    for (int i = 0; i <= M; i++){
      ans = min(ans, d[H * (M + 1) + i]);
    }
    if (ans == INF){
      cout << "Help!" << endl;
    } else {
      cout << ans << endl;
    }
  }
}


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

using namespace std;
using ll = long long;

ll N;
vector<int> v;

int main(){
    cin >> N;
    while (N > 0) {
        v.insert(v.begin(), N % 10);
        N /= 10;
    }

    int d = v.size();

    int tmp = 0;
    int sume = 0;
    int maxsum = 0;
    int i = 0;
    for (int vi : v) {
        tmp += vi - 1;
        sume += vi;
        int sum = tmp + (d - i - 1) * 9;
        if (maxsum < sum) maxsum = sum;
        i++;
    }
    cout << max(maxsum, sume) << endl;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
typedef long long ll;


int main() {
    int n[4];
    string s; cin >> s;
    rep(i, 4){
        n[i] = (int)s[i] - 48;
    }
    string ans;
    for(int bits = 0; bits < (1 << 3); bits++){
        int sum = n[0];
        ans = to_string(n[0]);
        rep(i, 3){
            if(bits & (4 >> i)){ // +
                sum += n[i+1];
                ans += "+";
            }else{ // -
                sum -= n[i+1];
                ans += "-";
            }
            ans += to_string(n[i+1]);
        }
        if(sum == 7) break;
    }
    cout << ans << "=7" << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int c;
	int t[]={'a','i','u','e','o'};
	int i;
	c=getchar();
	for(i=0;i<5;i++){
		if(c==t[i]){
			puts("vowel");
			return 0;
		}
	}
	puts("consonant");
	return 0;
}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Set<String> S = new HashSet<>();
		for(int i = 0; i < N; i++)
			S.add(sc.next());
		System.out.println(S.size());
	}

}


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

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

int main(void)
{
    int A,B,C,D;
    cin >> A >> B >> C >> D;

    int ans = 0;
    int low = max(A,C);
    int high = min(B,D);

    if (high > low)
        ans = high - low;

    cout << ans << endl;

    return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  vector<int> a(3);
  int sum = 0;
  for (int i = 0; i < 3; i++) cin >> a[i], sum += a[i];
  sort(a.rbegin(), a.rend());
  cout << sum - a[0] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
using namespace std;

pair <long long, int> x_v[100000];
pair <long long, int> y_v[100000];
pair <long long, pair<int, int> > diff_v_pair[200000];
struct UnionFind{
    vector <int> par;
    vector <int> height;
    vector <int> card;

    UnionFind(int N){
        par.assign(N, 0);
        height.assign(N, 0);
        card.assign(N, 1);
        for(int i = 0; i < N; i++){
            par[i] = i;
        }
    }
    int set_size(int x){
        return card[root(x)];
    }
    int root(int x){
        if(x == par[x]){
            return x;
        }
        par[x] = root(par[x]);
        return par[x];
    }

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

    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y){
            return;
        }
        if(height[x] >= height[y]){
            par[y] = x;
            if(height[x] == height[y]){
                height[x] ++;
            }
            card[x] += card[y];
        } else {
            par[x] = y;
            card[y] += card[x];
        }
    }
};

int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        long long x;
        long long y;
        cin >> x >> y;
        x_v[i] = make_pair(x, i);
        y_v[i] = make_pair(y, i);
    }

    sort(x_v, x_v + N);
    sort(y_v, y_v + N);

    for(int i = 0; i < N - 1; i++){
        diff_v_pair[i] = make_pair(x_v[i + 1].first - x_v[i].first, 
            make_pair(x_v[i + 1].second, x_v[i].second));
    }
    for(int i = 0; i < N - 1; i++){
        diff_v_pair[i + N - 1] = make_pair(y_v[i + 1].first - y_v[i].first,
            make_pair(y_v[i + 1].second, y_v[i].second));
    }
    sort(diff_v_pair, diff_v_pair + 2 * (N - 1));
    set <int> vs;
    long long ans = 0;
    UnionFind uf(N);
    for(int i = 0; i < 2 * (N - 1); i++){
        int x = diff_v_pair[i].second.first;
        int y = diff_v_pair[i].second.second;
        long long diff = diff_v_pair[i].first;
        if(!uf.same(x, y)){
            ans += diff;
            uf.unite(x, y);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7680
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define sb __builtin_popcount
#define MOD (ll)998244353
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;

ll dp[101][101];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, m;
    cin >> n >> m;
    string s[n];
    for (ll i = 0; i < n; i++)
    {
        cin >> s[i];
    }
    if (s[0][0] == '.')
    {
        dp[0][0] = 0;
    }
    else
    {
        dp[0][0] = 1;
    }
    for (ll i = 1; i < m; i++)
    {
        if (s[0][i] == '.' || (s[0][i - 1] == '#' && s[0][i] == '#'))
        {
            dp[0][i] = dp[0][i - 1];
        }
        else
        {
            dp[0][i] = 1 + dp[0][i - 1];
        }
    }
    for (ll i = 1; i < n; i++)
    {
        if (s[i][0] == '.' || (s[i - 1][0] == '#' && s[i - 1][0] == '#'))
        {
            dp[i][0] = dp[i - 1][0];
        }
        else
        {
            dp[i][0] = dp[i - 1][0] + 1;
        }
    }
    for (ll i = 1; i < n; i++)
    {
        for (ll j = 1; j < m; j++)
        {
            ll up = dp[i - 1][j];
            if (!(s[i][j] == '.' || (s[i - 1][j] == '#' && s[i][j] == '#')))
            {
                up++;
            }
            ll left = dp[i][j - 1];
            if (!(s[i][j] == '.' || (s[i][j - 1] == '#' && s[i][j] == '#')))
            {
                left++;
            }
            dp[i][j] = min(up, left);
            //cout << dp[i][j] << " ";
        }
        //cout << endl;
    }
    cout << dp[n - 1][m - 1] << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
   int n ;
   cin >> n ;
   int x[n];
   int minn = 100 ;
   int maxx = 1 ;

   for(int i=0;i<n;i++){
     cin >> x[i];
     if(x[i]<=minn) minn = x[i] ;
     if(x[i]>=maxx) maxx = x[i] ;
   }
  
  int ans = 1000000;
  for(int i=minn;i<=maxx;i++){
    int tmp = 0 ;
    for(int j=0;j<n;j++){
      tmp+= (x[j]-i)*(x[j]-i) ;
    }
    if(tmp<=ans) ans = tmp;
  }
    cout << ans << endl;   
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int a[200010];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int t;
		scanf("%d",&t);
		a[t]++;
	}
	for(int i=1;i<=n;i++)printf("%d\n",a[i]);
}

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

void solve(long long A, long long B) {
    cout << A * B << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main() {
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 3656
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  long n, m;
  rd(n, m);
  auto s = readln.chomp.to!(char[]);
  auto t = readln.chomp.to!(char[]);

  import std.numeric : gcd;

  auto l = n * m / gcd(n, m);
  char[long] ch;
  foreach (i; 0 .. n) {
    auto j = i * (l / n);
    ch[j] = s[i];
  }
  foreach (i; 0 .. m) {
    auto j = i * (l / m);
    if (j in ch) {
      if (ch[j] != t[i]) {
        writeln(-1);
        return;
      }
    }
  }
  writeln(l);
}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


Measured memory_bytes: 6780
//Author : Vipul Sharma

// LIBRARIES
#include <bits/stdc++.h>

// MACROS
#define ll long long int
#define rep(i, a, b) for (i = a; i < b; i++)
#define rev(i,b,a) for(i=b-1;i>=a;i--)
#define s1rep(i,a,b) for( i=1;i<=b;i++)
#define itrep(at) for (auto it = at.begin(); it != at.end(); it++)
#define ld long double
#define pb push_back
#define w(t) while (t--)
#define booster                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define mod 1000000007
#define endl "\n"
#define deb1(x) cout << #x << " : " << x << endl;
#define deb2(x, y) cout << #x << " : " << x << "\t" << #y << " : " << y << endl;
#define deb3(x, y, z) cout << #x << " : " << x << "\t" << #y << " : " << y << "\t" << #z << " : " << z << endl;
#define deb4(x, y, z, w) cout << #x << " : " << x << "\t" << #y << " : " << y << "\t" << #z << " : " << z << "\t" << #w << " : " << w << endl;
#define deb5(a, b, c, d, e) cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define deb6(a, b, c, d, e, f) cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

using namespace std;
long long cost = 1e18;
// FUNCTIONS
ll power(ll a, ll n)
{
    ll res = 1;
    while (n)
    {
        if (n & 1)
        {
            res *= a;
            n--;
        }
        else
        {
            a *= a;
            n >>= 1;
        }
    }
    return res;
}

string solve(string s,string t,int n,int m)
{
	int dp[n+1][m+1];
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=m;j++)
		{
			if(i==0||j==0) dp[i][j]=0;
			else if(s[i-1]==t[j-1])
			{
				dp[i][j]=1+dp[i-1][j-1];
			}
			else
			{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	int i=n,j=m;
	string res;
	while(i>0&&j>0)
	{
		if(s[i-1]==t[j-1])
		{
			res.pb(s[i-1]);
			i--;
			j--;
		}
		else
		{
			if(dp[i-1][j]>dp[i][j-1])
			{
				i--;
			}
			else j--;
		}
	}
	reverse(res.begin(),res.end());
	return res;
	
}




int main()
{
	booster;
	string s,t;
	cin>>s>>t;
	int n=s.length();
	int m=t.length();
	cout<<solve(s,t,n,m)<<endl;
	return 0;
}

Measured memory_bytes: 35584
#include <iostream>

using namespace std;

typedef long long LL;

int main() {
	LL a, b;
	cin >> a >> b;
	LL ans;
	if (a * b > 0) {
		if (a == 1 || b == 1)
			ans = a + b;
		else
			ans = a * b;
	}
	else
		ans = a + b > a - b ? a + b : a - b;
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
time = [int(input()) for _ in range(5)]
count = 0
if all([i >= n for i in time]):
    print(5)
else:
    smallest = min(time)
    smallest_index = time.index(smallest)
    count += n // smallest
    if n % smallest != 0:
        count += 1
    print(count + 4) 

Measured memory_bytes: 61888
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

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

#処理内容
def main():
	N = int(input())
	a = getlist()
	val = 1
	for i in range(N):
		if a[i] == val:
			val += 1
	if val == 1:
		print(-1)
	else:
		print(N - val + 1)
	


if __name__ == '__main__':
	main()

Measured memory_bytes: 71024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int ans=0;
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=1;i<n-1;i++){
    if((a[i-1]-a[i])*(a[i]-a[i+1])>0){ans++;}
  }
  cout<<ans;
}

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

int N;
bool ok = false;

int main(){
  cin >> N;

  string s = to_string(N);
  for(int i = 0; i < s.size(); i++){
    if(s[i] == '7') ok = true;
  }

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

  return 0;
}


Measured memory_bytes: 3692
#include<bits/stdc++.h>
#define pb push_back
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
#define skip continue
#define NAME "code"

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef long double ld;

void faster(){
  	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
	cout.tie(NULL);
}

const int MAXN = 5e1 + 1;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

ll n, P, cnt[2], c[MAXN][MAXN], ans;

int main(){
	faster();

	cin >> n >> P;

	for(int i = 0, a; i < n; ++i){
		cin >> a;
		cnt[a % 2]++;
	}

	c[0][0] = 1;
	for(int i = 1; i <= n; ++i){
		c[i][0] = c[i - 1][0];
		for(int j = 1; j <= i; ++j){
			c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
		}
	}

	for(int i = 0; i <= cnt[0]; ++i){
		for(int j = P; j <= cnt[1]; j += 2){
			ans += c[cnt[0]][i] * c[cnt[1]][j];
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
// C.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;


int main()
{
    int x,ans;
    cin >> x;
   // int i = x;
    while (true) {
        int i = 2;
        int flag = 0;
        while (i * i <= x) {

            if (x % i == 0) {
                flag = 1;
                break;
            }
            i++;
        }
        if (flag == 0) {
            ans = x;
            break;
        }

        x++;

    }
    cout << ans << endl;
}



Measured memory_bytes: 256