akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll a,b;
  cin >> a >> b;
  if(a<=9&&b<=9) pr(a*b);
  else pr(-1);
}

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


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
int nmax=200000; // 2*(10^5)
vvec g(nmax);



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int m,k;
    cin>>m>>k;
    if(k>=(1LL<<m)){
        cout<<-1<<endl;
        return 0;
    }
    if(m==0){
        if(k==0) cout<<"0 0";
        else cout<<-1<<endl;
        return 0;
    }
    if(m==1){
        if(k==0) cout<<"0 0 1 1";
        else cout<<-1<<endl;
        return 0;
    }
    if(m>=2){
        vec b;
        rep(i,(1LL<<m)){
            if(i==k){
                continue;
            }
            b.pb(i);
            cout<<i<<endl;
        }
        cout<<k<<endl;
        reverse(all(b));
        rep(i,(1<<m)-1){
            cout<<b[i]<<endl;
        }
        cout<<k<<endl;
    }
    
}

Measured memory_bytes: 7668
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int d1[4] = { 1,0,-1,0 };
int d2[4] = { 0,1,0,-1 };

int main() {
	int n;
	cin >> n;
	rep(i, n) {
		int y, m, d, ans = 0;
		cin >> y >> m >> d;

		//year
		ans += ((y - 1) / 3) * 590;
		ans += ((y - 1) % 3) * 195;

		//month
		if (y % 3 != 0) {
			ans += ((m - 1) / 2) * 39;
			ans += ((m - 1) % 2) * 20;
		}
		else {
			ans += (m - 1) * 20;
		}

		//day
		ans += d;

		cout << 196471 - ans << endl;
	}
}


Measured memory_bytes: 3040
package main

import "fmt"

func main() {
	var (
		n, a, b, num int
	)
	fmt.Scan(&n ,&a, &b)

	num += a * (n / (a+b))
	if n % (a+b) >= a {
		num += a
	} else {
		num += n % (a+b)
	}

	fmt.Println(num)
}


Measured memory_bytes: 512
/**
*    created: 26.06.2020 17:39:58
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcount(bit)
#define mod 1000000007
#define pi acos(-1.0)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    auto ctoi = [&] (char c) {
        if (c >= '0' && c <= '9') return c - '0';
	    return -1;
    };

    string s;
    cin >> s;
    int k;
    cin >> k;
    int l = min(k,(long long)s.size());
    rep(i,l) {
        int a = ctoi(s[i]);
        if (a == 1) continue;
        else {
            cout << a << endl;
            return 0;
        }
    }
    cout << 1 << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N);
    vector<ll> B(M);
    for(int i=0;i<N;i++){cin >> A[i];}
    for(int i=0;i<M;i++){cin >> B[i];}
    auto res = convolution<998244353>(A, B);
    for(auto v : res) cout << v << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 27256
n,a,b = list(map(int,input().split()))

c = [i for i in range(a,b+1)]

count = 0

for i in range(1,n+1):
    d = list(str(i))
    d = list(map(int, list(d)))
    d = sum(d)
    if d in c:
        count += i
print(count)

Measured memory_bytes: 3060
/*
 * omg.cpp
 *
 *  Created on: 2019/06/03
 *      Author: J01003
 */
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
	char A,T;
	cin>>A>>T;
	if(A==T){
		cout<<'H'<<endl;
	}else{
		cout<<'D'<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

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

typedef long long ll;

int main()
{
   string s;
   cin>>s;
   int n=s.length();
   vector<int>v(2019);
   int mod=2019;
   int ans=0,sum=0,p=1;
   v[sum]++;
   for(int i=n-1;i>=0;i--)
   {
       int digit=s[i]-'0';
       sum=(sum+digit*p)%mod;
       p=(p*10)%mod;
        ans+=v[sum];
       v[sum]++;
   }
   
   cout<<ans;

    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

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

int main() {
	int n, a, b, c;
	int ans = 0;
	cin >> n >> a >> b >> c;
	vector<int> v(n);
	REP(i, n) {int in; scanf("%d", &in); v.push_back(in);}
	sort(v.begin(), v.end(), greater<int>());

	REP(i, n) {
		int tmp = 0;
		for (int j = 0; j <= i; j++) tmp += v[j];
		ans = max(ans, (c + tmp) / (a + b * (i + 1)));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1256
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end()
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}

int N, C;
int d[30][30];
int c[500][500];
int cost[500][500][30];
int ch[3][30];

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

    cin >> N >> C;
    REP(i, C) REP(j, C) {
        cin >> d[i][j];
    }
    REP(i, N) REP(j, N) {
        cin >> c[i][j];
    }

REP(i, N) {
    REP(j, N) {
        REP(k, C) {
            cost[i][j][k] = d[c[i][j]-1][k];
        }
    }
}

REP(cc, C) {
    int rr[3] = {0,0,0};
    REP(i, N) {
        REP(j, N) {
            rr[(i+j+2)%3] += cost[i][j][cc];
        }
    }
    ch[0][cc] = rr[0];
    ch[1][cc] = rr[1];
    ch[2][cc] = rr[2];
}

int ans = 1<<30;
    REP(i, C) {
        REP(j, C) {
            if(i == j) continue;
            REP(k, C) {
                if(i == k || j == k) continue;
                ans = min(ans, ch[0][i]+ch[1][j]+ch[2][k]);
            }
        }
    }
cout << ans << endl;
return 0;
}


Measured memory_bytes: 30592
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
const int INF = 1<<28;
const ll MOD = 1000000007;
vector<pi> x;
int n, ans;

void dfs(int pnt, int cnt, bool b[5][200]) {
	if(pnt + n > ans) return;
	if(cnt == 10) {
		ans = min(ans, pnt + n-1);
		return;
	}
	REP(i, x.size()) {
		if(b[x[i].first][x[i].second + pnt]) {
			dfs(pnt+1, cnt, b);
			return;
		}
	}
	REP(i, x.size())
		b[x[i].first][x[i].second + pnt] = true;
	dfs(pnt+1, cnt+1, b);
	REP(i, x.size())
		b[x[i].first][x[i].second + pnt] = false;
	dfs(pnt+1, cnt, b);
	return;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	while(cin >> n, n) {
		ans = n * 10;
		x.clear();
		REP(i, 5) REP(j, n) {
			char c; cin >> c;
			if(c == 'X')
				x.pb(mp(i, j));
		}
		bool b[5][200] = {};
		dfs(0, 0, b);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int a, b, q;
    cin >> a >> b >> q;
    vector<ll> s(a+2);
    vector<ll> t(b+2);
    ll m = 100000000000;
    s[0] = -INF + m; s[a+1] = INF - m;
    t[0] = -INF + m; t[b+1] = INF - m;
    for (ll i = 1; i < a+1; i++) {
        cin >> s[i];
    }
    for (ll i = 1; i < b+1; i++) {
        cin >> t[i];
    }

    ll x, ans;
    ll ss, sss, tt, ttt;
    for (ll i = 0; i < q; i++) {
        cin >> x;
        auto itr1 = lower_bound(ALL(s), x);
        auto itr2 = lower_bound(ALL(t), x);
        sss = *itr1;
        itr1--;
        ss = *itr1;
        ttt = *itr2;
        itr2--;
        tt = *itr2;

        ans = INF;
        ans = min(ans, max(sss, ttt) - x);
        ans = min(ans, x - min(ss, tt));
        ans = min(ans, 2 * min(sss - x, x - tt) + max(sss - x, x - tt));
        ans = min(ans, 2 * min(ttt - x, x - ss) + max(ttt - x, x - ss));
        printf("%lld\n", ans);

    }



}

Measured memory_bytes: 4740
a, b = map(int, input().split())

def prize(x):
    if x == 1:
        return 300000
    elif x == 2:
        return 200000
    elif x == 3:
        return 100000
    else:
        return 0


ans = prize(a) + prize(b)

if a==b==1:
    ans += 400000
    
print(ans)




Measured memory_bytes: 2940
/*
g++ -std=c++11 -o2 -Wall ABC110B.cpp -o .\out\ABC110B.out
.\out\ABC110B.out
*/

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

typedef long long ll;

int n, m, x, y;
int xs[200];
int ys[200];

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> x >> y;
  int xmax = -200;
  for (int i = 0; i < n; ++i) {
    cin >> xs[i];
    xmax = max(xmax, xs[i]);
  }
  int ymin = 200;
  for (int i = 0; i < m; ++i) {
    cin >> ys[i];
    ymin = min(ymin, ys[i]);
  }
  for (int k = -100; k <= 100; ++k)
    if (xmax < k && k <= ymin && x < k && k <= y) {
      cout << "No War" << "\n";
      return 0;
    }
  cout << "War" << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define puts(x) cout << x << "\n"
constexpr int mod = 1000000007;
using namespace std;
int d, c[30], l[30], s[400][30];
signed main() {
	cin >> d;
	for1(i, 26)cin >> c[i];
	for1(i, d)for1(j, 26)cin >> s[i][j];
	for1(i, d) {
		int p = 0, k = -mod;
		for1(j, 26) {
			int kj = s[i][j] + c[j] * (i - l[j]) * 1.35;
			if (kj > k) { p = j; k = kj; }
			else if (kj == k && c[j] > c[p])p = j;
		}
		puts(p); l[p] = i;
	}
}

Measured memory_bytes: 3716
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       




        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            var s = Console.ReadLine();
            bool f = false;
            for (int i = 0; i < s.Length; i++)
            {
                for (int j = i+1; j < s.Length; j++)
                {
                    if (s[i] == s[j])
                        f = true;
                }
            }
            Console.WriteLine(!f ? "yes" : "no");



            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 13140
#include <stdio.h>


int main(){
 
  int a, b, r, tmp;
 
  scanf("%d%d", &a,&b);

  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  printf("%d\n", b);
 
  return 0;
}

Measured memory_bytes: 592
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
	Scanner in = new Scanner(System.in);
	int H,W;

	while(true){
	    H = in.nextInt();
	    W = in.nextInt();
	    if(H==0 && W==0)break;
	     
	    for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
		    if(i%2==0){
			if(j%2==0)System.out.print("#");
			else System.out.print(".");
		    }else{
			if(j%2==0)System.out.print(".");
			else System.out.print("#");
		    }
		}
		System.out.println();  
	    }
	    System.out.println();  
	}
    }
}
	   



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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

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

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

vector< int > z_algorithm(const string &s) {
  vector< int > prefix(s.size());
  for(int i = 1, j = 0; i < s.size(); i++) {
    if(i + prefix[i - j] < j + prefix[j]) {
      prefix[i] = prefix[i - j];
    } else {
      int k = max(0, j + prefix[j] - i);
      while(i + k < s.size() && s[k] == s[i + k]) ++k;
      prefix[i] = k;
      j = i;
    }
  }
  prefix[0] = (int) s.size();
  return prefix;
}

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

  vector< string > S(N);
  cin >> S;

  vector< bitset< 10001 > > reach(N + 1);
  reach.back().set(K);
  for(int i = N - 1; i >= 1; --i) {
    reach[i] = reach[i + 1] | (reach[i + 1] >> S[i].size());
  }

  bitset< 10001 > dp;
  dp[0] = true;

  string ans;
  for(int i = 0; i < N; ++i) {
    auto d = z_algorithm(S[i] + ans);
    string prefix;
    for(int j = 0; j <= ans.size() && j + S[i].size() <= K; ++j) {
      int t = (j == ans.size() ? 0 : d[S[i].size() + j]);
      if(dp[j] && reach[i + 1][j + S[i].size()] && (j == ans.size() || (t < S[i].size() && ans[j + t] > S[i][t]))) {
        for(int l = j + t + 1; l <= ans.size(); ++l) dp[l] = false;
        ans = prefix + S[i];
        dp[j + S[i].size()] = true;
        break;
      }
      if(j < ans.size()) prefix += ans[j];
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3968
def main() -> None:
    n = int(input())
    a = [int(s) for s in input().split()]
    od = 0
    ev = 0

    for i in range(n):
        if a[i] % 2 == 0:
            ev += 1
        else:
            od += 1

        if od == 2:
            od = 0
            ev += 1

        if ev == 2:
            ev = 1

    print("YES" if ev + od == 1 else "NO")


if __name__ == '__main__':
    main()

Measured memory_bytes: 14112
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main() {
    ll ans=LLINF;
    int n,k;
    cin>>n>>k;
    vi v(n);
    rep(i,n)cin>>v[i];
    
    for(int i=0;i<n-k+1;i++){
        ll t;
        t=v[k+i-1]-v[i];
        t+=min(abs(v[i]),abs(v[k+i-1]));
        //cout<<i<<" "<<t<<endl;
        chmin(ans,t);
    }
    fin(ans);
}


Measured memory_bytes: 640
h,w=map(int,input().split())
s=[]
for i in range(h):
    s.append(input())
from collections import deque
dp=[[-1]*w for i in range(h)]
d=[[1,0],[0,1],[-1,0],[0,-1]]
que=deque([])
que.append((0,0))
dp[0][0]=1
while len(que)>0:
    now=que.popleft()
    for i in d:
        if 0<=now[0]+i[0]<=h-1 and 0<=now[1]+i[1]<=w-1:
            x=now[0]+i[0]
            y=now[1]+i[1]
            if dp[x][y]==-1 and s[x][y]=='.':
                que.append((x,y))
                dp[x][y]=dp[now[0]][now[1]]+1
if dp[h-1][w-1]==-1:
    print(-1)
else:
    count=0
    for i in range(h):
        for j in range(w):
            if s[i][j]=='.':
                    count=count+1
    print(count-dp[h-1][w-1])


Measured memory_bytes: 40560
import math
from functools import reduce

k = int(input())

ans = 0
for i in range(1, k+1):
    for j in range(1, k+1):
        for l in range(1, k+1):
            #ans += reduce(math.gcd, [i, j, l])
            ans += math.gcd(math.gcd(i, j), l)

print(ans)

Measured memory_bytes: 68560
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <assert.h>
#include <fstream>

using namespace std;

typedef long long ll;

const int MAXN = 2005;
const ll MOD = 1000000007;

int n,k;

ll fac[MAXN * MAXN];
ll inv[MAXN * MAXN];
ll f[MAXN][MAXN];

ll power(ll a,ll b)
{
	ll res = 1;
	while (b)
	{
		if (b & 1)
			(res *= a) %= MOD;
		(a *= a) %= MOD;
		b >>= 1;
	}
	return res;
}

void init()
{
	fac[0] = 1;
	for (int i = 1;i <= n * k;i++)
		fac[i] = fac[i - 1] * i % MOD;
	inv[n * k] = power(fac[n * k],MOD - 2);
	for (int i = n * k;i >= 1;i--)
		inv[i - 1] = inv[i] * i % MOD;
}

ll C(int x,int y)
{
	return x < y ? 0 : fac[x] * inv[y] % MOD * inv[x - y] % MOD;
}

int main()
{
	cin >> n >> k;
	if (k == 1)
	{
		cout << 1 << endl;
		return 0;
	}
	init();
	f[0][0] = 1;
	for (int i = 1;i <= n;i++)
		f[0][i] = f[0][i - 1] * C((k - 1) * i - 1,k - 2) % MOD;
	for (int i = 1;i <= n;i++)
		for (int j = i;j <= n;j++)
		{
			f[i][j] = f[i - 1][j];
			if (i < j)
				(f[i][j] += f[i][j - 1] * C((k - 1) * j + i - 1,k - 2)) %= MOD;
		}
	cout << f[n][n] * fac[n] % MOD << endl;
	return 0;
}

Measured memory_bytes: 94464
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#define _USE_MATH_DEFINENS
#include <cmath>
using namespace std;

#define MOD 1000000007
#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    int a, b;
    string op;
    cin >> a >> op >> b;

    if(op == "+"){
        p(a + b);
    }else if(op == "-"){
        p(a - b);
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORC(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define pb(x) push_back(x)
#define ff first
#define ss second
#define dd double
#define mod 1000000007

template<class K,class other=null_type,class cmp=less<K>> using ordered_set=tree<K,other,
cmp, rb_tree_tag, tree_order_statistics_node_update>;

inline ll md(ll x){
    return x<mod?x:x%mod;
}

ll power(ll x, ll y){
    if(y==0){
        return 1;
    }
    ll x_=power(x,y/2);
    if(y & 1){
        return md(md(x_*x_)*md(x));
    }
    else{
        return md(x_*x_);
    }
}

ll mod_inverse(ll x){
    return power(x,mod-2);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll arr[n];
    REP(i,n){
        cin>>arr[i];
    }
    ll pre[n];
    pre[0]=arr[0];
    FOR(i,1,n){
        pre[i]=max(pre[i-1],arr[i]);
    }
    ll ans=0;
    FOR(i,1,n){
        ans+=max(0ll,pre[i-1]-arr[i]);
    }
    cout<<ans<<endl;
}


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

string a, b, c;

int main(void){
	
	cin >> a >> b >> c;
	
	if(a.back() == b.front() && b.back() == c.front()) printf("YES\n");
	else printf("NO\n");
	
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <vector>
#define int long long
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
int kai(int x) {
	int cnt = 1;
	if (x == 0)return 1;
	cnt = kai(x - 1);
	return x * cnt;
}
inline void shoki()
{
	srand((unsigned int)time(NULL));
}

/*Library End!*/

signed main() {
	int a, b;
	cin >> a >> b;
	cout << (b - a)*(b - a + 1) / 2 - b << endl;
}

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

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

  int n;
  cin >> n;

  uint64_t pow = 1;
  for (int i = 2; i <= n; ++i) {
    pow = (pow * i) % 1000000007;
  }
  cout << pow << "\n";
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <iterator>
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <regex>
#include <stdexcept>
#include <unordered_set>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <cassert>
#include <time.h>
#include <numeric>
#include <complex>

using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define fill(x, y) memset(x, y, sizeof(x))
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define itn int
#define re return
#define prev PREV
#define next NEXT

#define sz(x) ((int)x.size())

const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int maxn = 2*1000005;
const int mod = 1000000007;

#define FILENAME ""
 
char a[1001][1001];
int dp[1001][1001];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    dp[0][0] = 1 % mod;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (a[i][j] == '#') dp[i][j] = 0;
            else dp[i][j] += (((i >= 1) ? dp[i - 1][j] : 0) + ((j >= 1) ? dp[i][j - 1] : 0)) % mod;
        }
    }
    cout << dp[n - 1][m - 1] % mod;
    return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
typedef long long int LLD;

int main(){
  string s, t;
  getline(cin, s);
  getline(cin, t);
  int min_count = INT_MAX;
  int count = 0;
  for(long unsigned int i = 0; i <= (s.size()-t.size()); ++i){
    count = 0;
    for(long unsigned int j = 0; j < t.size(); ++j){
      if(s.at(i+j) != t.at(j)){
        count++;
      }
    }
    if(min_count > count){
      min_count = count;
    }
  }
  cout << min_count << endl;
  return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")
 
#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 10000000000000000 //1e16
 
// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
 
 
// using namespace __gnu_pbds;
using namespace std;
 
using ll  = long long;
using vi  = vector<int>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;
 
int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}



void solve()
{
    int t,n,m,i,k,r,l,u,v,w,j,s,sum=0,pos,flag=0,count=0;
    string S,T,U; 
    // int a,b,c;
    cin>>n>>m;
    u=max(m,n);

    rep(i,0,u)
    {
        cout<<min(n,m);
    }
}
 
 
signed main()
{
  
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define endl '\n'
using namespace std;

ll a, b, c;

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

    ll lh, rh;
    cin >> a >> b >> c;

    rh = (c - a - b) * (c - a - b);
    if(c < (a + b))
    {
        cout << "No" << endl;
        return 0;
    }
    lh =  4 * a * b;

    cout << ((lh < rh) ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a, b, c, i, N;
	int tri;
	for (;;){
		scanf("%d", &N);
		if (1 <= N&&N <= 1000)
			break;
	}
	for (i = 1; i <= N;){
		scanf("%d %d %d", &a, &b, &c);
		if (1 <= a, b, c <= 1000){
			if (a*a == (b*b + c*c))
				tri = 1;
			else if (b*b == (c*c + a*a))
				tri = 1;
			else if (c*c == (a*a + b*b))
				tri = 1;
			else
				tri = 0;
			if (tri == 1)
				printf("YES\n");
			else
				printf("NO\n");
			i++;
		}
	}
	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
    string s;
    char a[10];
    char b[10]={'K','I','H','B','R'};
    cin>>s;
    int m=s.length();
    int j=0;
    if(m>9||m<5)
        cout<<"NO"<<endl;
    else{
    for(int i=0;i<m;i++)
    {
        if(s[i]=='A'&&s[i+1]=='A')
        {cout<<"NO"<<endl;return 0;}
        else if(s[i]=='K'){
            a[j]=s[i];
            j++;
            if(s[i+1]=='I'&&s[i+2]=='H') continue;
            else {cout<<"NO"<<endl;return 0;}
        }
        else if(s[i]!='A')
        {
            a[j]=s[i];
            j++;
        }
    }
    if(j>5)
    {
        cout<<"NO"<<endl;
        return 0;
    }
    else {for(int i=0;i<5;i++)
    {
        if(b[i]!=a[i])
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }}
    cout<<"YES"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dump(x) cerr << #x << "=" << (x) << endl;
using namespace std;
const int INF = (int)2e9 + 1;
const long long LINF = (long long)9e18 + 1;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x;
  cin >> x;
  if(x==0){
    cout << "1" << endl;
  } else {
    cout << "0" << endl;
  }
  return 0;
}


Measured memory_bytes: 3636
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line: Vec<i32> = read_as_vec();
    let (n, a, b) = (line[0], line[1], line[2]);

    let max = cmp::min(a, b);
    let min = cmp::max(a+b-n, 0);

    println!("{} {}", max, min);
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
using namespace std;

int calc(int num){
    return (num/100)*60+(num%100);
}

void func(int N,int P,int Q){
    int start = calc(P),end = calc(Q);

    bool checkTable[1440],tmpCheck[1440];

    for(int i = start; i < end; i++){
        checkTable[i] = false;
    }

    int num,calc_start,calc_end;
    for(int loop = 0; loop < N; loop++){
        for(int i = start; i < end;i++){
            tmpCheck[i] = true;
        }
        scanf("%d",&num);

        for(int i = 0; i < num; i++){
            scanf("%d %d",&calc_start,&calc_end);
            if(calc(calc_end) < start || end < calc(calc_start))continue;
            for(int k = max(start,calc(calc_start)); k < min(calc(calc_end),end); k++)tmpCheck[k] = false;
        }

        for(int i = start; i < end; i++){
            if(tmpCheck[i] == true)checkTable[i] = true;
        }
    }

    int left,right,maximum = 0;

    for(left = start;left < end && checkTable[left] == false; left++);

    if(left == end){
        printf("0\n");
        return;
    }

    int count;
    for(;left < end;){
        count = 0;
        for(right = left; right < end && checkTable[right] == true;right++){
            count++;
        }
        maximum = max(maximum,count);
        for(left = right;left < end && checkTable[left] == false; left++);
    }

    printf("%d\n",maximum);
}


int main(){

    int N,P,Q;
    while(true){
        scanf("%d %d %d",&N,&P,&Q);
        if(N == 0 && P == 0 && Q == 0)break;

        func(N,P,Q);
    }

    return 0;
}

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

map<int, int> a;

int main()
{
	int n, num;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>num;
		a[num] = i;
	}
	map<int, int>::iterator it;
	for(it=a.begin();it!=a.end();it++)
		cout<<it->second<<" ";
	cout<<endl;
}

Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)3e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

void solve() {
    int n;
    cin>>n;
    string s;
    cin>>s;
    vector<int> rsuff(n, 0), bsuff(n, 0), gsuff(n, 0);
    for(int i = n - 2; i >= 0; i--) {
        rsuff[i] = rsuff[i + 1];
        bsuff[i] = bsuff[i + 1];
        gsuff[i] = gsuff[i + 1];
        if(s[i + 1] == 'R') rsuff[i]++;
        else if(s[i + 1] == 'G') gsuff[i]++;
        else bsuff[i]++;
    }
    int ans = 0;
    f(i, n - 2) {
        for(int j = i + 1; j < n; j++){
            if(s[i] == s[j]) continue;
            char col = ('R' ^ 'G' ^ 'B' ^ s[i] ^ s[j]);
            if(col == 'R') {
                ans += rsuff[j];
                if(j + j - i < n && s[j + j - i] == 'R') ans--;
            }
            else if(col == 'B') {
                ans += bsuff[j];
                if(j + j - i < n && s[j + j - i] == 'B') ans--;
            }
            else {
                ans += gsuff[j];
                if(j + j - i < n && s[j + j - i] == 'G') ans--;
            }
        }
    }
    cout<<ans;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int t = 1;
    //cin>>t;
    while(t--) {
        solve();
    }
    return 0;
}


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

int main(){
    long long n;
    cin >> n;
    long long ans = n / 11 * 2;
    if(n % 11 != 0){
        ans++;
        if(n % 11 > 6)ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))
c_list = list(map(int,input().split()))
satisfaction_point = 0

for count in range(n):
    satisfaction_point += b_list[a_list[count] - 1]
    # c_listは他の入力より１つ要素が少ない
    if count < n - 1:
        if a_list[count] + 1 == a_list[count + 1]:
            satisfaction_point += c_list[a_list[count] - 1]

print(satisfaction_point)



Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
ll BASE_NUM = 1000000007;

int main()
{
  ll H,W,K;
  cin >> H >> W >> K;
  vector<string> G(H);
  for (size_t i = 0; i < H; i++)
  {
      cin >> G[i];
  }
  ll ans = 0;
  for (size_t i = 0; i < (1<<H); i++)
  {
    for (size_t j = 0; j < (1<<W); j++)
    {
      vector<string> GG(G);
      for(int ii = 0;ii < H;ii++){
        if (i & (1<<ii)){
          for(int k = 0;k < W;k++){
            GG[ii][k] = '.';
          }
        }
      }

      for(int jj = 0;jj < W;jj++){
        if (j & (1<<jj)){
          for(int k = 0;k < H;k++){
            GG[k][jj] = '.';
          }
        }
      }
      ll total = 0;
      for(int k = 0;k < H;k++){
        for (size_t l = 0; l < W; l++)
        {
          if (GG[k][l] == '#'){
            total++;
          }
        }
      }
      if (total == K){
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3592
#include<stdio.h>
int main(){
  int x, n, i = 1;
  scanf("%d\n", &n);
  do{
    x = i;
    if(x%3 == 0) printf(" %d", i);
    else do{
      if(x%10 == 3){ printf(" %d", i); break; }
      x /= 10;
    }while(x);
  }while(++i <= n);
  printf("\n");
  return 0;
}


Measured memory_bytes: 2748
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    input!(
        n: usize,
        s: chars,
    );

    let s = s as Vec<char>;
    let mut ok = true;

    for i in 0..(n/2) {
        if s[i] != s[i+n/2] {
            ok = false;
        }
    }

    println!("{}", if ok && n%2==0 { "Yes" } else { "No" });
}

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

int main (){
    string s;
    cin >> s;
    int count=1;
    char t=s[0];
    for(int i=1;i<s.length();i++){
        if(t==s[i]) count++;
        else{
            count=1;
            t=s[i];
        }
        if(count==3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main() {
	//入力
	int h,w;
	cin >> h >> w;
	vector<vector<int>> s(h,vector<int>(w));
	rep(i,h) {
		string s1;
		cin >> s1;
		rep(j,w) {
			if (s1[j]=='#') s[i][j]=1;
		}
	}
	string ans = "Yes";
	rep(i, h) {
		rep(j, w) {
			if (s[i][j] == 1) {
				int okflg = 0;
				if (i > 0) {
					if (s[i - 1][j] == 1) {
						++okflg;
					}
				}
				if (i < h - 1) {
					if (s[i + 1][j] == 1) {
						++okflg;
					}
				}
				if (j > 0) {
					if (s[i][j-1] == 1) {
						++okflg;
					}
				}
				if (j < w - 1) {
					if (s[i][j+1] == 1) {
						++okflg;
					}
				}
				if (okflg == 0) {
					ans = "No";
					goto OWARI;
				}
			}
		}
	}
OWARI:
	//答え
	std::cout << ans << endl;
}


Measured memory_bytes: 3596
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

struct UnionFind{
    v: Vec<usize>
}

impl UnionFind{
    fn new(n: usize) -> UnionFind{
        let mut v: Vec<usize> = Vec::new();
        for i in 0..n{
         v.push(i);
        }
        UnionFind{v:v}
    }

    fn find(&mut self, i: usize) -> usize{
        if self.v[i] == i{
            i
        }else{
            let ni = self.v[i];
            self.v[i] = self.find(ni);
            self.v[i]
        }
    }

    fn union(&mut self, i: usize, j: usize){
        let root_i = self.find(i);
        let root_j = self.find(j);
        self.v[root_i] = root_j;
    }

}

struct CombMod{
    fac: Vec<u64>,
    inv: Vec<u64>,
    finv: Vec<u64>,
    mmod: u64,
}

impl CombMod{
    pub fn new(max: u64, m: u64) -> CombMod{
        let max: usize = max as usize;
        let mut fac: Vec<u64> = vec![0;max+1];
        let mut finv: Vec<u64> = vec![0;max+1];
        let mut inv: Vec<u64> = vec![0;max+1];

        fac[0] = 1;
        fac[1] = 1;
        finv[0] = 1;
        finv[1] = 1;
        inv[1] = 1;

        for i in 2..max+1{
            fac[i] = fac[i-1] * i as u64 % m;
            inv[i] = m - inv[m as usize %i] * (m/(i as u64)) % m;
            finv[i] = finv[i-1] * inv[i] % m;
        }

        CombMod{
            fac: fac,
            finv: finv,
            inv: inv,
            mmod: m,
        }
    }

    fn get(&self, n: u64, m: u64) -> u64{
        assert!(n >= m && n != 0 && m != 0);
        self.fac[n as usize] * self.finv[m as usize] % self.mmod
            * self.finv[(n-m) as usize] % self.mmod
    }
}

fn main(){
    let line = read_as_vec::<i32>();
    let (a, b) = (line[0], line[1]);

    if a < 10 && b < 10{
        println!("{}", a*b);
    }else{
        println!("-1");
    }
}


Measured memory_bytes: 4352
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    mod = int(1e9 + 7)
    n = I()
    p = 1
    for i in range(1, n+1):
        p = (p*i)%mod
    print(p)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9040