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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  ll n;
  cin >> n;
  vector<ll> dv;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      dv.push_back(i);
      if (i * i != n && i != 1) { // nを含めたければi!=1を外す
        dv.push_back(n / i);
      }
    }
  }
  sort(dv.begin(), dv.end());
  dump(dv);
  ll ans = LINF;
  rep(i, dv.size()) {
    ll a = dv[i];
    ll b = n / dv[i];
    ans = min(ans, (a - 1) + (b - 1));
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll MAXN = 100005; 

ll n,a[MAXN];
ll xid,nid,ps,ng;
vector<pii> ans;
/********** Good Luck :) **********/
int main()
{
    IOS();
    cin >> n;
    REP (i,n) {
        cin >> a[i];
    }
    xid = max_element(a,a+n) - a;
    nid = min_element(a,a+n) - a;
    if (xid == nid) {
        nid = xid == 0 ? n-1 : 0;
    }

    ps = a[xid];
    ng = a[nid];
    
    REP (i,n) {
        if (i != xid && i != nid) {
            if (a[i] > 0) {
                ans.eb(ng,a[i]);
                ng = ng - a[i];
            } else {
                ans.eb(ps,a[i]);
                ps = ps - a[i];
            }
        }
    }
    ans.eb(ps,ng);

    cout << ps - ng << endl;
    for (auto p : ans) {
        cout << p.X << " " << p.Y << endl;
    }
    return 0;
}


Measured memory_bytes: 4336
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
  int n;
  bool ans = true;
  cin >> n;
  vector<int> h(n);

  for(int i=0; i<n; i++) {
    cin >> h[i];
  }

  for(int i=n-1; i>0; i--) {
    if(h[i-1] > h[i]) {
      if(h[i-1]-1 <= h[i]) h[i-1]--;
      else ans = false;
    }
  }

  cout << (ans? "Yes" : "No") << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "No" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    string S; cin>>S;
    ll K; cin>>K;
    rep(i,S.size()){
        if(S[i]=='a') continue;
        if(('z'-S[i]+1)>K) continue;
        K-=('z'-S[i]+1);
        S[i]='a';
    }
    S[S.size()-1]='a'+((S[S.size()-1]-'a')+K)%26;
    cout<< S <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int x; cin >> x;
	while(true){
		bool ok = true;
		for(int i = 2; i*i <= x; i++){
			if(x % i == 0){
				ok = false;
				break;
			}
		}
		if(ok){
			cout << x << endl;
			break;
		}
		x++;
	}
} 

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back


using namespace std;

void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {std::cout << x;}
void __print(unsigned x) {std::cout << x;}
void __print(unsigned long x) {std::cout << x;}
void __print(unsigned long long x) {std::cout<< x;}
void __print(float x) {std::cout << x;}
void __print(double x) {std::cout << x;}
void __print(long double x) {std::cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
template <typename T> inline void inp(T &any) {cin >> any;} template <typename T, typename... U>inline void inp(T &a, U &...b) {cin >> a; inp(b...);}
#define rin(args...) ll args; inp(args);
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#define matdeb(mat,row,col) cout << #mat << "::" << endl; printmat(mat,row,col); printpartition;
#define debugv(v,n) cout << #v << ":" << endl; printv(v,0,n-1); printpartition;
#else
#define debug(x...)
#define matdeb(mat,row,col)
#define debugv(v,n)
#endif

const int maxm = 1000000000 + 7;

double startTime;
double getCurrentTime() {
	return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}


//----------->CODE BEGINS --------------->


int main()
{

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

  string s;
  string t;
  cin>>s>>t;


  string ans;

  int i =0;

  while(i<min(s.length(),t.length()))
  {
  	 ans += s[i];
  	 ans += t[i];

  	 i++;
  }

  if(s.length()>t.length())
  {
  	ans += s[s.length()-1];
  }

  if(s.length()<t.length())
  {
  	ans += t[t.length()-1];
  }

  cout<<ans<<endl;


}


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

int main(){
    string s;
    cin >> s;
    int N = count(s.begin(), s.end(), 'N');
    int E = count(s.begin(), s.end(), 'E');
    int W = count(s.begin(), s.end(), 'W');
    int S = count(s.begin(), s.end(), 'S');
    if (((N>0&&S>0)||(N==0&&S==0)) && ((E>0&&W>0)||(E==0&&W==0))) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef unsigned long long ull;
inline ll toInt(string s) { ll v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }


#define For(i,a,b)	for(int (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define rall(a)		(a).rbegin(), (a).rend()
#define sz(a)		(sizeof(a))
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

bool cheak(int x, int y, int xMax, int yMax){ return x >= 0 && y >= 0 && xMax > x && yMax > y; }
const int dx[3] = { -1, -1, 0 }, dy[3] = { -1, 0, -1};
const int mod = 1000000007;
const int INF = 1e9;

ll n, m;

int main()
{
	while (cin >> n >> m && n){
		const int M = 10001;
		P dp[M];
		rep(i, n){
			cin >> dp[i].second >> dp[i].first;
		}
		sort(dp, dp + n,greater<P>());
		ll ans = 0;

		rep(i, n){
			if (m){
				if (m >= dp[i].second){
					m -= dp[i].second;
				}
				else{
					ans += (dp[i].second - m)*dp[i].first;
					m = 0;
				}
			}
			else{
				ans += dp[i].second * dp[i].first;
			}
		}
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1312
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
using namespace std;

typedef complex<double> P;
typedef pair<P,P> L;
const double EPS = 1e-8;

double dot(P a, P b){ return real(conj(a)*b);}

double cross(P a, P b){ return imag(conj(a)*b);}

int ccw(P a, P b, P c){
  b -= a;
  c -= a;
  if(cross(b,c) > EPS) return 1;
  if(cross(b,c) < -EPS) return -1;
  if(dot(b,c) < -EPS) return 2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}

P crossPoint(L l, L m){
  double A = cross(l.second - l.first, m.second - m.first);
  double B = cross(l.second - l.first, l.second - m.first);
  if(fabs(A) < EPS && fabs(B) < EPS) return m.first;
  else if(fabs(A) >= EPS) return m.first + B / A * (m.second - m.first);
}

vector<P> convex_cut(vector<P> G, L l){
  vector<P> ans;
  for(int i=0;i<G.size();i++){
    P A = G[i];
    P B = G[(i+1)%G.size()];
    if(ccw(l.first, l.second, A) != -1) ans.push_back(A);
    if(ccw(l.first, l.second, A) * ccw(l.first, l.second, B) < 0){
      L ll(A,B);
      ans.push_back(crossPoint(ll,l));
    }
  }
  return ans;
}

double area(vector<P> v){
  double sum = 0.0;
  int n = v.size();
  for(int i=0;i<n;i++)
    sum += (real(v[i]) - real(v[(i+1)%n])) * (imag(v[i]) + imag(v[(i+1)%n]));
  sum = fabs(sum);
  return sum / 2.0;
}

int main(){
  int x[3], y[3];
  int T = 1;
  while(cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] && (x[0]|y[0]|x[1]|y[1]|x[2]|y[2])){
    vector<P> v;
    v.push_back(P(0.0,0.0));
    v.push_back(P(10000.0,0.0));
    v.push_back(P(10000.0,10000.0));
    v.push_back(P(0.0,10000.0));
    P p[3];
    for(int i=0;i<3;i++) p[i] = P((double)x[i], (double)y[i]);
    for(int i=0;i<2;i++){
      L l;
      P a = P(-imag(p[i+1]-p[0]), real(p[i+1]-p[0]));
      P b = p[0] + (p[i+1]-p[0])/2.0;
      l = L(b, a+b);
      //l = L(a+b, b);
      v = convex_cut(v,l);
    }
    printf("%d %.5f\n", T++, area(v) / 100000000.0);
  }
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  ll h,w;
  cin >> h >> w;
  ll ans=10000000;
  rep(i,h-1){
    ll a,b,c;
    a=w*(i+1);
    if(w*(h-i-1)%2==0){
      ans=min(ans,abs(a-w*(h-i-1)/2));
    }
    else{
      b=w*(h-i-1)/2-min(w/2,(h-i-1)/2);
      c=w*(h-1-i)-b;
      ans=min(ans,max(a,max(b,c))-min(a,min(b,c)));
    }
  }
  swap(h,w);
  rep(i,h-1){
    ll a,b,c;
    a=w*(i+1);
    if(w*(h-i-1)%2==0){
      ans=min(ans,abs(a-w*(h-i-1)/2));
    }
    else{
      b=w*(h-i-1)/2-min(w/2,(h-i-1)/2);
      c=w*(h-1-i)-b;
      ans=min(ans,max(a,max(b,c))-min(a,min(b,c)));
    }
  }
  cout << ans << endl;
}  


Measured memory_bytes: 256
n,m=map(int,input().split())
sitei=[]
for i in range(m):
    a,b=map(int,input().split())
    sitei.append([a-1,b])

ans=[-1]*n

kano=True
for i in range(m):
    if(ans[sitei[i][0]]==-1):
        ans[sitei[i][0]]=sitei[i][1]
    elif(ans[sitei[i][0]]!=sitei[i][1]):
        kano=False

if(n!=1):
    if(ans[0]==0):
        kano=False
    if(ans[0]==-1):
        ans[0]=1


if(not kano):
    print(-1)
else:
    kotae=0
    for i in range(n):
        if(ans[i]==-1):
            pass
            #kotae+="0"
        else:
            kotae+=ans[i]*(10**(n-i-1))
    print(kotae)

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

using namespace std;
const int max_value = 1'000'000'000 + 1;
int comparision_times = 0;

void merge(vector<int>& sequence, int top_index, int middle_index, int tail_index) {
  vector<int> first_half, second_half;
  first_half.resize((middle_index - top_index) + 1);
  second_half.resize((tail_index - middle_index) + 1);

  // Copy to tmp
  for(int i = 0; i < (middle_index - top_index); i++) {
    first_half[i] = sequence[top_index + i];
  }
  for(int i = 0; i < (tail_index - middle_index); i++) {
    second_half[i] = sequence[middle_index + i];
  }
  // Set sentinel
  first_half[first_half.size() - 1] = max_value;
  second_half[second_half.size() - 1] = max_value;

  int first_half_poped_index = 0;
  int second_half_poped_index = 0;
  for(int i = 0; i < tail_index - top_index; i++) {
    if(first_half[first_half_poped_index] < second_half[second_half_poped_index]) {
      sequence[top_index + i] = first_half[first_half_poped_index++];
    } else {
      sequence[top_index + i] = second_half[second_half_poped_index++];
    }
    comparision_times++;
  }
}

void merge_sort(vector<int>& sequence,  int top_index, int tail_index) {
  if(tail_index - top_index <= 1)  {
    return;
  }

  int middle_index = (top_index + tail_index) / 2;

  merge_sort(sequence, top_index, middle_index);
  merge_sort(sequence, middle_index, tail_index);

  merge(sequence, top_index, middle_index, tail_index);
}

int main() {
  int sequence_num;
  vector<int> sequence;

  // Init
  comparision_times = 0;
  cin >> sequence_num;

  sequence.resize(sequence_num);
  for(int i = 0; i < sequence_num; i++) {
    cin >> sequence[i];
  }

  // Do merge sort
  merge_sort(sequence, 0, sequence.size());

  // Output
  for(int i = 0; i < sequence_num; i++) {
    cout << sequence[i];
    if(i != sequence_num - 1) {
      cout << ' ';
    }
  }
  cout << endl;
  cout << comparision_times << endl;
}



Measured memory_bytes: 6760
n,m=list(map(int,input().split()))
x=list(map(int,input().split()))
import sys
if n>m:
  print(0)
  sys.exit()

x.sort()
ans_list=[]
for i in range(1,m):
  ans_list.append(x[i]-x[i-1])
ans_list.sort(reverse=True)

print(max(x)-min(x)-sum(ans_list[:n-1]))




Measured memory_bytes: 20468
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	lli N;
	cin >> N;

	cout << pow(N, 3) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

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

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

int main() {
	ll n,k,a[100000]={0};
    cin>>n>>k;
    REP(i,n){
        cin>>a[i];
    }

    ll zero,one,b=pow(2,45),x=0;
    REP(j,47){
        zero=0,one=0;
        REP(i,n){
            if((a[i]&b)==b){
                one++;
                //cout<<a[i]<<endl;
            }
            else{
                zero++;
            }
        }
        if(zero>one){
            if(x+b<=k)
            x+=b;
        }
        b/=2;
    }
    
    ll ans=0;
    REP(i,n){
        ans+=x^a[i];
    }

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


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const long MOD = 1000000007;
        static void Solve()
        {
            string s = Console.ReadLine();
            var sb = new StringBuilder();
            for(int i=0;i<s.Length;++i)
            {
                char op = s[i];
                if (op == '0' || op == '1')
                {
                    sb.Append(op);
                }
                else// op=='B'
                {
                    if (sb.Length >= 1)
                    {
                        sb.Remove(sb.Length - 1, 1);
                    }
                }
            }
            string ans = sb.ToString();
            Console.WriteLine(ans);
        }
        
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

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

int main() {
	int N;
	cin >> N;
	int a[4];

	a[0] = (N % 10); N /= 10;
	a[1] = (N % 10); N /= 10;
	a[2] = (N % 10); N /= 10;
	if (a[0] == 7) {
		cout << "Yes" << endl;
	}
	else if (a[1] == 7) {
		cout << "Yes" << endl;
	}
	else if (a[2] == 7) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define mod 1000000007
#define int unsigned long long
using namespace std;
vector<vector<int>> adj;
vector<vector<int>> f;//0 for white 1 for black
void dfs(int u,int e){
	f[u][0]=1;
	f[u][1]=1;
	bool fr=true;
	for(auto v:adj[u])
	if(v!=e){
		dfs(v,u);
		if(!fr)
		{
			f[u][0]*=f[v][1]+f[v][0];
			f[u][0]%=mod;
		}
		else 
		{
			f[u][0] = f[v][1]+f[v][0];
			f[u][0]%=mod;
		}
		if(!fr)
		{
			f[u][1]*=f[v][0];
			f[u][1]%=mod;
		}
		else f[u][1] = f[v][0];
		fr = false;
	}
}
signed main() {
	int n;
	cin>>n;
	adj.resize(n);
	for(int _=0;_<n-1;_++){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	f.resize(n,vector<int>(2));
	dfs(0,-1);
	cout<<(f[0][0]+f[0][1])%mod;
}

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

int n, m;

char wcz[1007][1007];

char wyj1[1007][1007];
char wyj2[1007][1007];

int main()
{
    scanf("%d%d", &n, &m);
    for (int i=1; i<=n; i++)
        scanf("%s", wcz[i]+1);
    for (int i=1; i<=n; i++)
    {
        for (int j=1; j<=m; j++)
        {
            wyj1[i][j]=wyj2[i][j]=wcz[i][j];
        }
    }
    for (int i=1; i<=n; i++)
    {
        if (i&1)
        {
            for (int j=2; j<m; j++)
            {
                wyj1[i][j]='#';
            }
        }
        else
        {
            for (int j=2; j<m; j++)
            {
                wyj2[i][j]='#';
            }
        }
        wyj1[i][1]='#';
        wyj2[i][m]='#';
    }
    for (int i=1; i<=n; i++)
    {
        for (int j=1; j<=m; j++)
        {
            printf("%c", wyj1[i][j]);
        }
        printf("\n");
    }
    printf("\n");
    for (int i=1; i<=n; i++)
    {
        for (int j=1; j<=m; j++)
        {
            printf("%c", wyj2[i][j]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#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++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int N; cin >> N;
    N %= 10;
    if (N == 2 || N == 4 || N == 5|| N == 7 || N == 9) {
        cout << "hon" << endl;
    }
    else if (N == 0 || N == 1 || N == 6 || N == 8) {
        cout << "pon" << endl;
    }
    else cout << "bon" << endl;
}


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

#define all(x) x.begin(), x.end()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
const int maxn = 1e5+1;

vi a(maxn, 1);
int dp[maxn];

int mult(int a, int b) { return 1LL * a * b % mod; }
int n, m;

int f(int n){
    if(n>::n)
        return 0;
    if(!a[n])
        return 0;
    if(n == ::n)
        return 1;
    if(dp[n] != -1)
        return dp[n];
    return dp[n] = (f(n+1) + f(n+2)) % mod;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    memset(dp, -1, sizeof(dp));
    
    cin >> n >> m;
    for(int i=0; i<m; i++){
        int tmp;
        cin >> tmp;
        a[tmp]=0;
    }
    cout << f(0);
}

Measured memory_bytes: 4096
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (ll i = ll(a); i <= ll(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end

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

    ll n, k;
    in >> n >> k;
    vector<ll> h(n+1);
    h[0] = INF;
    REP(i, n){
        in >> h[i+1];
    }
    ll dp[n] = {};
    REP_AB(i, 2, n){
        dp[i] = INF;
        REP_AB(j, 1, k){
            if(i - j < 0){
                break;
            }
            dp[i] = min(dp[i], dp[i-j] + abs(h[i-j] - h[i]));
        }
    }
    out << dp[n] << endl;
}


Measured memory_bytes: 1792
n = int(input())
dict1 = {}
li = ['M', 'A', 'R', 'C', 'H']
ans = 0

for _ in range(n):
    s = input()
    if s[0] not in dict1:
        dict1[s[0]] = 1
    else:
        dict1[s[0]] += 1

for i in range(5):
    for j in range(i+1, 5):
        for k in range(j+1, 5):
            if li[i] in dict1 and li[j] in dict1 and li[k] in dict1:
                ans += dict1[li[i]] * dict1[li[j]] * dict1[li[k]]

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 15;
int mat[N][N], inside[1 << N], cross[1 << N][N], f[1 << N][N];
int main()
{
	int n, m;
	cin >> n >> m;
	while (m--)
	{
		int u, v, w;
		cin >> u >> v >> w;
		mat[u - 1][v - 1] = mat[v - 1][u - 1] = w;
	}
	for (int i = 0; i < 1 << n; i++)
		for (int j = 0; j < n; j++)
			if (i & (1 << j))
				for (int k = 0; k < j; k++)
					if (i & (1 << k))
						inside[i] += mat[j][k];
	for (int i = 0; i < 1 << n; i++)
		for (int j = 0; j < n; j++)
			if (!(i & (1 << j)))
				for (int k = 0; k < n; k++)
					if (i & (1 << k))
						cross[i][j] += mat[j][k];
	fill_n(&f[0][0], sizeof(f) / sizeof(int), -1);
	f[1][0] = 0;
	for (int i = 0; i < 1 << n; i++)
		for (int j = 0; j < n; j++)
			if (~f[i][j])
			{
				for (int k = 0; k < n; k++)
					if (!(i & (1 << k)) && mat[j][k])
						f[i | (1 << k)][k] = max(f[i | (1 << k)][k], f[i][j] + mat[j][k]);
				int c = (1 << n) - i - 1;
				for (int s = c; s; s = (s - 1) & c)
					f[i | s][j] = max(f[i | s][j], f[i][j] + inside[s] + cross[s][j]);
			}
	cout << inside[(1 << n) - 1] - f[(1 << n) - 1][n - 1] << endl;
	return 0;
}

Measured memory_bytes: 4224
// 23.07.2017
//
// WA 1-3-4
// Tagir
// Tagirov+Ravil+R


/*
C - Colorful Leaderboard

Time limit : 2sec / Memory limit : 256MB
Score : 300 points
Problem Statement
In AtCoder, a person who has participated in a contest receives a color,
which corresponds to the person's rating as follows:
    Rating 1-399 : gray
    Rating 400-799 : brown
    Rating 800-1199 : green
    Rating 1200-1599 : cyan
    Rating 1600-1999 : blue
    Rating 2000-2399 : yellow
    Rating 2400-2799 : orange
    Rating 2800-3199 : red
Other than the above, a person whose rating is 3200 or higher can freely pick his/her color,
which can be one of the eight colors above or not.
Currently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of ai.
Find the minimum and maximum possible numbers of different colors of the users.
Constraints
    1 <= N <= 100
    1 <= ai <= 4800
    ai is an integer.
Input
Input is given from Standard Input in the following format:
N
a1 a2 … aN
Output
Print the minimum possible number of different colors of the users,
and the maximum possible number of different colors, with a space in between.
Sample Input 1
4
2100 2500 2700 2700
Sample Output 1
2 2
The user with rating 2100 is "yellow", and the others are "orange". There are two different colors.
Sample Input 2
5
1100 1900 2800 3200 3200
Sample Output 2
3 5
The user with rating 1100 is "green", the user with rating 1900 is blue and the user with rating 2800 is "red".
If the fourth user picks "red", and the fifth user picks "blue", there are three different colors.
This is one possible scenario for the minimum number of colors.
If the fourth user picks "purple", and the fifth user picks "black", there are five different colors.
This is one possible scenario for the maximum number of colors.
Sample Input 3
20
800 810 820 830 840 850 860 870 880 890 900 910 920 930 940 950 960 970 980 990
Sample Output 3
1 1
All the users are "green", and thus there is one color.

*/


# include <iostream>
# include <iomanip>
# include <cstdio>
# include <cstdlib>
# include <cmath>
# include <cstring>
# include <vector>
# include <stack>
# include <queue>
# include <algorithm>


//# define __TRR__

using namespace std;

const int N = 111;

int n, m, k, mi, ma;
int a [N];
int col [9];


int main ()
{
# ifdef __TRR__
   freopen ("C.TXT", "r", stdin);
   freopen ("C.OUT", "w", stdout);
# endif

   cin >> n;

   for ( int i=0; i < n; i++ )
   {
      cin >> k;
      if ( k > 3200 )
         col [8] ++;
      else
         col [k/400] ++;
   }

   for ( int i=0; i < 8; i++ )
      if ( col [i] > 0 )
         mi++;

//   ma = mi;
   ma = mi + col [8];
   if ( mi == 0 )
      mi = 1;
/*
   if ( mi + col [8] < 8 )
      ma = mi + col [8];
   else
      ma = 8;
*/
   cout << mi << " " << ma;

//system ("pause");
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define lli long long int
using namespace std;
#define S second
#define F first
#define pb push_back 
#define M1 1000000007
#define M2 998244353
#define plli pair<lli,lli>
#define setit set<lli>::iterator seti
#define mapit map<lli,lli> ::iterator mapi
#define MP make_pair
#define MT make_tuple
// map      iterator->first  iterator.first
// map      mp[key]=value
// set      *s.begin()
// vector   v[j]=value
// pair     p.first p.second
// vector of pairs v[j].first v[j].second
// tuple    get<index>(tuple_name)
// vector of tuples get<index>(v[j])  sort(v.begin(),v.end())
//priority queue .top() .pop() .push()
// __gcd(x,y)
#define fr(j,a,b) for(j=a;j<b;j++)

int power(int x, unsigned int y, int p)  
{    int res = 1;    
     x = x % p;
     if (x == 0) return 0;
     while (y > 0)  
     {  if (y & 1)  
        res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
     }  
    return res;  
}





















int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lli w,sx,sy,t,i,j,n,x,l,k,r,y,u,d;
    string s;
    cin>>k>>n;
    lli a[n];
    lli b[n];
    l=k;
    for(i=0;i<n;i++){cin>>a[i];}
    for(i=0;i<n-1;i++){
        b[i]=a[i+1]-a[i];
        b[i]=k-b[i];
        l=min(l,b[i]);
    }
    b[n-1]=-a[0]+a[n-1];
    l=min(l,b[n-1]);
    cout<<l;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int n; cin >> n;
    vector<ll> a;
    ll sum = 0;
    for(int i=0; i<n; i++){
        ll tmp; cin >> tmp;
        a.push_back(tmp);
        sum +=tmp;
    }
    ll x = 0;
    ll ans = 1000000000000000000LL;
    for(int i=0; i<n; i++){
        x +=a[i];
        if(i+1 < n){
            ans = min(ans, abs(sum - 2*x));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5356
H, W = map(int, input().split())

a = []

for _ in range(H):
    a.append(input())

# horizon
h_remove_index = []
for h_i in range(H):
    if not "#" in a[h_i]:
        h_remove_index.append(h_i)




#vertex
v_remove_index = []
for v_i in range(W):
    is_ok = True
    for h_i in range(len(a)):
        if a[h_i][v_i] == "#":
            is_ok = False
            break
    # remove
    if is_ok:
        v_remove_index.append(v_i)
    

for h_i in range(H):
    if h_i in h_remove_index:
        continue
    for v_i in range(W):
        if v_i in v_remove_index:
            continue

        print(a[h_i][v_i], end='')
    print("\n",end='')



Measured memory_bytes: 4468
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
#define chmin(x,y) x = min(x,y)

int main(){
    int n; cin>>n;
    int dp[100005];
    rep(i,100005) dp[i]=1e9;
    dp[0]=0;
    for(int i=1;i<=n;i++){
        for(int a=1;a<=i;a*=6) chmin(dp[i], dp[i-a]+1);
        for(int b=1;b<=i;b*=9) chmin(dp[i], dp[i-b]+1);
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 3988
#include<iostream>
#include<cmath>
#include<string>
#include<list>
#include<vector>
#include<algorithm>
#include<numeric>
#include<queue>
#include<utility>
#include <map>

using namespace std;

int main(int argc, char const *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.tie(0);
    /*
    cin>>x;
    cout<<x<<endl;
    */
    int a,b,c,i,j,k,x,y,z,cnt=0,ans=0;
    string s;
    string v[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    cin>>s;
    for(i=0;i<7;i++){
        if(s==v[i]){
        cout<<7-i<<endl;
        }
    }

}

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

int main()
{
    int n, k;
    while (cin>>n>>k) {
        vector<int> a(n);
        for(int& e: a) cin>>e;

        int gcd=a[0];
        for(int e: a) gcd=__gcd(gcd, e);

        bool ok=false;
        for(int e: a) {
            if (e>=k && (e-k)%gcd==0) ok=true;
        }

        if (!ok) cout<<"IM";
        cout<<"POSSIBLE"<<endl;
    }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
typedef mp::cpp_int ll;
using namespace std;
// typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e18)


ll A, B, C, D;
map<ll, ll> visited;

ll dfs(ll v) {
    // cout << v << endl;
    if (visited.find(v) != visited.end()) return visited[v];
    ll x, y, ans = v * D;

    // x*2+y
    y = v % 2;
    x = (v - y) / 2;

    if (x < v) {
        if (A > x * D) {
            if ((x + y) * D < ans)
                ans = min(ans, (x + y) * D + dfs(x));
        } else {
            if (A + y * D < ans)
                ans = min(ans, A + y * D + dfs(x));
        }
    }

    // x*2-y
    y = 2 - (v % 2);
    x = (v + y) / 2;
    if (x < v) {
        if (A > (x - 2 * y) * D) {
            if ((x - y) * D < ans)
                ans = min(ans, (x - y) * D + dfs(x));
        } else {
            if (A + y * D < ans)
                ans = min(ans, A + y * D + dfs(x));
        }
    }

    // x*3+y
    y = v % 3;
    x = (v - y) / 3;
    if (x < v) {
        if (B > 2 * x * D) {
            if ((2 * x + y) * D < ans)
                ans = min(ans, (2 * x + y) * D + dfs(x));
        } else {
            if (B + y * D < ans)
                ans = min(ans, B + y * D + dfs(x));
        }
    }

    // x*3-y
    y = 3 - (v % 3);
    x = (v + y) / 3;
    if (x < v) {
        if (B > (2 * x - 2 * y) * D) {
            if ((2 * x - y) * D < ans)
                ans = min(ans, (2 * x - y) * D + dfs(x));
        } else {
            if (B + y * D < ans)
                ans = min(ans, B + y * D + dfs(x));
        }
    }

    // x*5+y
    y = v % 5;
    x = (v - y) / 5;
    if (x < v) {
        if (C > 4 * x * D) {
            if ((4 * x + y) * D < ans)
                ans = min(ans, (4 * x + y) * D + dfs(x));
        } else {
            if (C + y * D < ans)
                ans = min(ans, C + y * D + dfs(x));
        }
    }

    // x*5-y
    y = 5 - (v % 5);
    x = (v + y) / 5;
    if (x < v) {
        if (C > (4 * x - 2 * y) * D) {
            if ((4 * x - y) * D < ans)
                ans = min(ans, (4 * x - y) * D + dfs(x));
        } else {
            if (C + y * D < ans)
                ans = min(ans, C + y * D + dfs(x));
        }
    }

    visited[v] = ans;
    return ans;
}

int main() {
    ll T;
    cin >> T;
    for (ll i = 0; i < T; i++) {
        ll N;
        cin >> N >> A >> B >> C >> D;
        visited = {{0, 0}};
        cout << dfs(N) << endl;
    }
}


Measured memory_bytes: 5856
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int H,W,K;
    cin >> H >> W >> K;
    vector<string> s(H);
    for (int i = 0; i < H; i++) {
        cin >> s[i];
    }
    vector<vector<int>> ans(H, vector<int>(W));

    int prev_h = 0, now_h = 0;
    int id = 1;
    while(now_h < H){
        //Hの探索
        int n = 0;
        while(n == 0){//空白行->いちご有り
            REP(i, W){
                if(s[now_h][i] == '#') n++;
            }
            now_h++;
        }

        int t_n = 0;
        while(t_n == 0){//空白行
            if(now_h >= H) break;
            REP(i, W){
                if(s[now_h][i] == '#') t_n++;
            }
            if(t_n == 0) now_h++;
        }
        
        //Wの探索
        int prev_w = 0;
        int now_w = 0;
        while(now_w < W){
            n = 0;
            while (n == 0)
            {
                Rep(i, prev_h, now_h){
                    if(s[i][now_w] == '#') n++;
                }
                now_w++;
            }
            t_n = 0;
            while(t_n == 0){//空白行
                if(now_w >= W) break;
                Rep(i, prev_h, now_h){
                    if(s[i][now_w] == '#') t_n++;
                }
                if(t_n == 0) now_w++;
            }

            //ansに答えを入れる
            Rep(i, prev_h, now_h) Rep(j, prev_w, now_w){
                ans[i][j] = id;
            }
            id++;
            prev_w = now_w;
        }
        prev_h = now_h;
    }

    REP(i, H){
        REP(j, W){
            cout << ans[i][j] << ' ';
        }
        cout << endl;
    }
}

Measured memory_bytes: 1280
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n; n++;
  cout << (1000 - (n % 1000) + 1) % 1000 << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int MOD = 1000000007;
const int dx[] = {1, 0};
const int dy[] = {0, 1};

int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<char>> a(h, vector<char>(w));
	for(int i = 0; i < h; i++){
		string s;
		cin >> s;
		for(int j = 0; j < w; j++){
			a[i][j] = s[j];
		}
	}
	vector<vector<int>> dp(h, vector<int>(w));
	dp[0][0] = 1;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(i == 0 && j == 0) continue;
			for(int k = 0; k < 2; k++){
				int yp = i - dy[k];
				int xp = j - dx[k];
				if(0 <= yp && yp < h && 0 <= xp && xp < w && a[i][j] != '#') dp[i][j] += dp[yp][xp];
				if(dp[i][j] > MOD) dp[i][j] %= MOD;
			}
			if(dp[i][j] > MOD) dp[i][j] %= MOD;
		}
	}
	cout << dp[h - 1][w - 1] << endl;
}


Measured memory_bytes: 8516
r,c=gets.split(' ')
r=r.to_i
c=c.to_i
a=Array.new(r){Array.new(c)}

for i in 0..r-1 do
    total=0
    a[i]=gets.split(' ').map(&:to_i)
    for j in 0..c-1 do
        total+=a[i][j]
    end
    a[i].push(total)
end

b=Array.new()
for j in 0..c do
    total=0
    for i in 0..r-1 do
        total+=a[i][j]
    end
    b.push(total)
end
a.push(b)

a.each{|e|
  e.each_with_index{|x,i|
    if i<e.length-1 then
    printf("%d ",x)
    else
    printf("%d\n",x)
    end
  }
}

Measured memory_bytes: 8876
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int a,b,c,d,ab,bc,ac;
int main()
{
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if (a>c) ac=a-c;
		else ac=c-a;
	if (a>b) ab=a-b;
		else ab=b-a;
	if (b>c) bc=b-c;
		else bc=c-b;
	if ((ac<=d) || ((ab<=d) && (bc<=d)))
		printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{ int m=1000000007;
    int n,k;
    cin>>n>>k;
    int arr[n+1]={0};
    for(int i=1;i<=n;i++)
        cin>>arr[i];
    long long int dp[n+1][k+1]={0};
    for(int i=0;i<=n;i++)
    { for(int j=0;j<=k;j++)
        dp[i][j]=0;
    }
    for(int i=0;i<=n;i++)
        dp[i][0]=1;
        long long int pre[n+1][k+1]={0};

        for(int i=0;i<=k;i++)
            pre[0][i]=1;

        for(int i=1;i<=n;i++)
            pre[i][0]=1;

    for(int i=1;i<=n;i++)
    { for(int j=1;j<=k;j++)
        { int lim=arr[i];
            dp[i][j]=pre[i-1][j];
           if(lim<=j)
           { dp[i][j]=dp[i][j]-pre[i-1][j-lim]+dp[i-1][j-lim];

           }
              dp[i][j]%=m;
           pre[i][j]=pre[i][j-1]+dp[i][j];


        }
    }

   // for(int i=0;i<=n;i++)


    cout<<dp[n][k]<<endl;
}


Measured memory_bytes: 158080
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 17
#define MAXM (1<<17)
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,m,k,a[MAXN];
int dp[MAXN][MAXM];
int fact[MAXM],invf[MAXM];
void add(int &a,int b) {a+=b; if(a>=MOD) a-=MOD;}
void dec(int &a,int b) {a-=b; if(a<0) a+=MOD;}
int pow_mod(int a,int i)
{
    int s=1;
    while(i)
    {
        if(i&1) s=1LL*s*a%MOD;
        a=1LL*a*a%MOD;
        i>>=1;
    }
    return s;
}
int comb(int n,int k)
{
    if(n<k) return 0;
    return 1LL*fact[n]*invf[k]%MOD*invf[n-k]%MOD;
}
int main()
{
    fact[0]=invf[0]=1;
    for(int i=1;i<MAXM;i++) fact[i]=1LL*fact[i-1]*i%MOD;
    invf[MAXM-1]=pow_mod(fact[MAXM-1],MOD-2);
    for(int i=MAXM-2;i>=1;i--) invf[i]=1LL*invf[i+1]*(i+1)%MOD;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++) scanf("%d",&a[i]);
    dp[m][0]=1;
    for(int i=m;i>0;i--)
    {
        for(int mask=0;mask<(1<<n);mask++)
        {
            if(!dp[i][mask]) continue;
            add(dp[i-1][mask],dp[i][mask]);
            int cnt=0;
            for(int j=0;j<n;j++) if(mask&(1<<j)) cnt+=(1<<j);
            for(int j=0;j<n;j++)
            {
                if(mask&(1<<j)) continue;
                int newmask=mask|(1<<j);
                add(dp[i-1][newmask],1LL*dp[i][mask]*comb((1<<n)-a[i-1]-cnt,(1<<j)-1)%MOD*fact[(1<<j)]%MOD);
            }
        }
    }
    for(int mask=0;mask<(1<<n);mask++)
    {
        int cnt=0;
        for(int j=0;j<n;j++) if(mask&(1<<j)) cnt+=(1<<j);
        dp[0][mask]=1LL*dp[0][mask]*fact[(1<<n)-1-cnt]%MOD;
    }
    int ans=0;
    for(int mask=0;mask<(1<<n);mask++)
    {
        if(__builtin_popcount(mask)&1) dec(ans,dp[0][mask]); else add(ans,dp[0][mask]);
    }
    ans=1LL*ans*pow_mod(2,n)%MOD;
    printf("%d\n",ans);
    return 0;
}



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

int main() {

    int N, T;

    cin >> N >> T;

    vector<int> cs;
    vector<int> ts;

    for (int i = 0; i < N; i++) {
        int c, tempo;
        cin >> c >> tempo;
        if (tempo <= T) {
            cs.push_back(c);
            ts.push_back(tempo);
        }
    }

    if (ts.size() == 0) {
        cout << "TLE" << endl;
    }
    else {
        cout << *min_element(cs.begin(), cs.end()) << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int time_in_seconds;
	int hour, min, sec;
	
	scanf("%d", &time_in_seconds);
	
	hour = time_in_seconds / 3600;
	
	time_in_seconds -= hour * 3600;
	
	min = time_in_seconds / 60;
	
	time_in_seconds -= min * 60;
	
	sec = time_in_seconds;
	
	printf("%d:%d:%d\n", hour, min, sec);
	
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define debug_array(a,n) for (ll bccc=(0); bccc<(n); bccc++) cout<<a[bccc]<<" "<<"\n"
#define debug_vector(a) for(ll bccc=(0); bccc<(a.size());bccc++) cout<<a[bccc]<<" "<<"\n"
#define F           first
#define S           second
#define debug_set(s) for(auto p:s) cout<<p<<" "
#define debug_map(m) for(auto p:m) cout<<p.F<<" "<<p.S<<"\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;

/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
//#pragma GCC optimize("Ofast")  // works very well
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long double lld;
lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll kjk;
    for(kjk=0;kjk<b;kjk++)
        c*=a;
    return c;
}
ll hell=1000000007;
//ll hell=998244353   ;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
// to generate random number , use rng() ... eg cout<<rng();
ll n,k;
ll dp[100005];
ll f(ll i)
{
    if(i>k)
        return 0;
    if(dp[i]!=-1)
        return dp[i];
    // now calc gcd exact(i)
    ll ans=0;
    ll j;
    ans=power(k/i,n,hell);
    for(j=2*i;j<=k;j+=i)
    {
        ans=(ans-f(j)+hell)%hell;
    }
    dp[i]=ans;
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    ll i;
    cin>>n>>k;
    ll ans=0;
    memset(dp,-1,sizeof(dp));
    for(i=1;i<=k;i++)
    {
        ans=(ans+((i*f(i))%hell))%hell;
    }
    /*for(i=1;i<=k;i++)
        cout<<i<<" "<<f(i)<<"\n";
    */
    cout<<ans;
    return 0;
}



Measured memory_bytes: 4424