akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include <unordered_set>

#define _CRT_SECURE_NO_WARNINGS

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1; i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

// N, E, S, W
const int dx[4] = { 1, 0, -1, 0};
const int dy[4] = { 0, 1, 0, -1};

using LL = long long int;
using LD = long double;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;

//==============================================
int n, e;
vvl M;

void warshallFloyd() {
	REP(k, n) {
		REP(i, n) {
			if (M[i][k] == INF64) continue;
			REP(j, n) {
				if (M[k][j] == INF64) continue;
				M[i][j] = min(M[i][j], M[i][k] + M[k][j]);
			}
		}
	}
}

void print() {
	REP(i, n) {
		if (M[i][i] < 0) {
			cout << "NEGATIVE CYCLE" << "\n";
			return;
		}
	}

	REP(i, n) {
		REP(j, n) {
			if (j) cout << " ";
			if (M[i][j] == INF64) cout << "INF";
			else cout << M[i][j];
		}
		cout << "\n";
	}
	
}

void solve() {
	warshallFloyd();
	print();
}

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

	cin >> n >> e;

	M.resize(n, vl(n, INF64));
	REP(i, n) M[i][i] = 0;

	LL s, t, d;
	REP(i, e) {
		cin >> s >> t >> d;
		M[s][t] = d;
	}

	solve();
	return 0;
}

Measured memory_bytes: 3284
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	int cnt=1;
	for(int i=0;i<=30;i++){
		if(cnt>=b){
			cout<<i;
			return 0;
		}
		cnt+=a-1;
	}
	return 0;
} 

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, long long X, std::vector<long long> m){
    sort(ALL(m));
    int ans = m.size();
    REP(i, N) X -= m[i];
    if(X != 0 ) ans += X / m[0];
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    std::vector<long long> m(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&m[i]);
    }
    solve(N, X, std::move(m));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define Vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<string,string> Pss;
const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int dp[300001]={};

void add(int k){
	if(dp[k]==0){
		dp[k]=1;
	}else{
		dp[k]=0;
		add(k+1);
	}
}
int main() {
	int n,a,b;
	Vi v;
	cin>>n;
	rep(i,n){
		cin>>a>>b;
		add(a+b);
	}
	rep(i,300001){
		if(dp[i]==1)cout<<i<<" 0"<<endl;
	}
	return 0;
}



Measured memory_bytes: 3860
#include <iostream>
#include <queue>

using namespace std;
typedef pair<double, int> P;

void solve()
{
	priority_queue<P, vector<P>, greater<P> > PQue[3];
	for(int a = 0; a < 3; ++a)
	{
		for(int i = 0; i < 8; ++i)
		{
			P p;
			cin >> p.second >> p.first;
			PQue[a].push(p);
		}
	}
	for(int a = 0; a < 3; ++a)
	{
		for(int i = 0; i < 2; ++i)
		{
			printf("%d %.2f\n", PQue[a].top().second, PQue[a].top().first);
			PQue[a].pop();
		}
	}
	for(int a = 1; a < 3; ++a)
	{
		for(int i = 0; i < 2; ++i)
		{
			PQue[0].push(PQue[a].top());
			PQue[a].pop();
		}
	}
	for(int i = 0; i < 2; ++i)
	{
		printf("%d %.2f\n", PQue[0].top().second, PQue[0].top().first);
		PQue[0].pop();
	}

}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
int main()
{
    IOS
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
 	ll n,m;
 	cin>>n>>m;
 	cout<<(n*(n-1)/2) + (m*(m-1))/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,m,ans=0;
  cin >> n >> m;
  long long a[n],b[n];
  pair<long long, long long> p[n];
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
    p[i] = make_pair(a[i], b[i]);
  }
  sort(p,p+n);
  for(int i=0;i<n;i++){
    ans+=p[i].first*min(p[i].second, m);
    m-=p[i].second;
    if(m<=0) break;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
//typedef std::pair<std::string,double> P;


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

typedef long long ll;
typedef vector<int> VI;
const constexpr ll MOD = 1e9+7;
vector<pair<int, int> > vp;
 
struct Less {
    bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
        return x.first > y.first;
    }
};

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


//グラフの隣接リスト
VI g[200010];
//頂点の入次数を管理
int h[100010];
int p[11], c[11];
int main(void) {
    int N, K; cin >> N >> K;
    int ans = (N-K)/(K-1)+1;
    if((N-K)%(K-1)!=0) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
#島数と要望数を入力
n_island, n_demand = map(int, input().split())

#要望を取得
demand_list = [list(map(int, input().split())) for i in range(n_demand)]

#右側の島についてソート
demand_list = sorted(demand_list, key=(lambda x:x[1]))

#直前に壊した橋番号を保持
b_0 = 0 #島i-1と島i間の橋
count = 0
for i in range(n_demand):
    #直前の橋を越えた場合
    if demand_list[i][0] >= b_0:
        #次の橋を壊す
        count += 1
        b_0 = demand_list[i][1]

#出力
print(count)

Measured memory_bytes: 29860
#include<stdio.h>
#include<string.h>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       >
int a[1000100];
int main()
{
	int n,i,j;
	scanf("%d",&n);

		a[1]=n;
		int flag=0;
		for( i=2;;i++)
		{
		if(n%2==1)			{n=n*3+1;a[i]=n;}
		else	if(n%2==0)	{n/=2;	a[i]=n;}
		for( j=1;j<i;j++)
			if(a[j]==a[i]){
	        flag=1;
			break;}
		if(flag)
			break;
		}
		printf("%d\n",i);
 return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	int h, a;
	cin >> h >> a;

	println((h + a - 1) / a);
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;

void prework(){

}

void read(){
	ll n, m;
	cin>>n>>m;
	ll ans = min(n, m / 2);
	n -= ans, m -= ans * 2;
	ans += (m / 4);
	cout<<ans<<endl;
}

void solve(int casi){

}

void printans(){

}


int main(){
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}




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

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

const long long INF =1LL << 60;

int N;
long long W, weight[110], value[110];

long long dp[110][100100] = {0};

int main() {
  cin >> N >> W;
  for (int i = 0; i < N; i++) cin >> weight[i] >> value[i];
  
  for (int i = 0; i < N; i++) {
    for (int sum_w = 0; sum_w <= W; sum_w++) {
      if (sum_w - weight[i] >= 0) {
        chmax(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
      }
      chmax(dp[i + 1][sum_w], dp[i][sum_w]);      
    }
  }
  cout << dp[N][W] << endl;
}
    


Measured memory_bytes: 79360
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<cctype>
#include<iomanip>
#include<functional>
#include<numeric>
#include<map>
#include<set>
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	string s;
	while (cin >> s) {
		vector<vector<int>>v(10, vector<int>(10));
		for (int i = 0; i < 10; i++) {
			v[0][i] = s[i] - '0';
		}
		int n = 9;
		//for (int k = 0; k < n+1; k++) {
		//	cout << v[0][k] << " ";
		//}
		//cout << endl;
		for (int i = 1; i < 10; i++) {
			int j = 0;
			while (j < n) {
				v[i][j] = (v[i - 1][j] + v[i - 1][j + 1]) % 10;
				j++;
			}
			//for (int k = 0; k < n; k++) {
			//	cout << v[i][k] << " ";
			//}
			//cout << endl;
			n--;
		}
		cout << v[9][0] << endl;
	}
	return 0;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define ll long long
#define sz 100002
using namespace std;
int f[10];
int main()
{
int n,m,x;

   cin>>n>>m;
   string s[101];
   for(int i=0;i<n;i++)cin>>s[i];
   sort(s,s+n);
   for(int i=0;i<n;i++)cout<<s[i];
   cout<<endl;

    return 0;



}


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

int main()
{
  int n, m;
  cin >> n >> m;

  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  int s = accumulate(v.begin(), v.end(), 0);
  int cnt = 0;
  for (int x : v) {
    if (s <= 4 * m * x) {
      cnt++;
    }
  }
  if (m <= cnt) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}


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

int main(void){
	long long int ans=0;
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int a;
		scanf("%d",&a);
		ans+=a;
	}
	printf("%d\n",ans/n);
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define dbg(x) cout << #x << ": " << (x) << '\n'
#define ff first
#define ss second
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

int main() {

   ios::sync_with_stdio(false);   cin.tie(NULL);   cout.tie(NULL);

   char x;
   cin >> x;
   if ('a' <= x && x <= 'z') {
      cout << 'a' << endl;
   } else {
      cout << 'A' << endl;
   }


   return 0;
}


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

#define pb push_back
#define fi first
#define SZ(x) (int((x).size()))
#define se second
#define ll long long
#define pq priority_queue
#define MP make_pair
#define pii pair<int,int>
#define mod 998244353
#define inf 0x3f3f3f3f
#define debug(x) cerr<<#x<<"="<<x<<'\n'
#define rep(i, a, b) for (int i=a; i<(b); i++)

int n,m,s;
struct E{
	int v,c,t;
	E(){}
	E(int v,int c,int t):v(v),c(c),t(t) {}
};
vector <E> edge[55];
ll dis[55][55*55],ans[55];
pii city[55];
int dmax=0;
pq <pair<ll,pii>,vector<pair<ll,pii> >,greater<pair<ll,pii> > > q;

int main(){
    scanf("%d%d%d",&n,&m,&s);
    rep(i,0,m) {
    	int u,v,c,t;
    	scanf("%d%d%d%d",&u,&v,&c,&t);
    	u--,v--;
    	edge[u].pb(E(v,c,t));
    	edge[v].pb(E(u,c,t));
    	dmax+=c;
	}
	s=min(s,dmax);
	rep(i,0,n) scanf("%d%d",&city[i].fi,&city[i].se),ans[i]=1e18;
	rep(i,0,n)
		rep(j,0,dmax+1) dis[i][j]=1e18;
	dis[0][s]=0;
	q.push(MP(0,MP(0,s)));
	while (!q.empty()) {
		int x=q.top().se.fi,y=q.top().se.se;
		ll d=q.top().fi;
		q.pop();
		if (dis[x][y]!=d) continue;
//		printf("dis[%d][%d]=%lld\n",x,y,d);
		//gold->silver
		int tmp=min(dmax,y+city[x].fi);
//		debug(tmp);
		if (d+(ll)city[x].se<dis[x][tmp]) {
			dis[x][tmp]=d+(ll)city[x].se;
			q.push(MP(dis[x][tmp],MP(x,tmp)));
		}
		rep(i,0,SZ(edge[x])) {
			int v=edge[x][i].v;
			tmp=y-edge[x][i].c;
			if (tmp<0) continue;
			if (dis[v][tmp]>d+(ll)edge[x][i].t) {
				dis[v][tmp]=d+(ll)edge[x][i].t;
				q.push(MP(dis[v][tmp],MP(v,tmp)));
			}
		}
	}
	rep(i,1,n) {
		rep(j,0,dmax) ans[i]=min(ans[i],dis[i][j]);
		printf("%lld\n",ans[i]);
	}
	return 0;
}


Measured memory_bytes: 6396
def main():
    n, *h = map(int, open(0).read().split())
    #print(n)
    #print(h)
    ans = h[0]
    #print(ans)
    for i in range(n-1):
        ans += max(h[i+1]-h[i],0)
        #print(ans)
    print(ans)
    return


main()

Measured memory_bytes: 2940
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値


const vector<pair<int,int>> np={{-1,0},{1,0},{0,-1},{0,1}};

int main(){
    int H,W;
    cin>>H>>W;
    vector<vector<char>> S(410,vector<char>(410,'x'));    
    REP(i,H){
        string s;
        cin>>s;
        REP(j,s.size()){
            S[i+1][j+1]=s[j];
        }
    }
    ll ans=0;
    // BFS のためのデータ構造
    vector<vector<int>> dist(410,vector<int>(410,-1)); // 全頂点を「未訪問」に初期化
    REP2(i,1,H+1){
        REP2(j,1,W+1){
            if(dist[i][j]!=-1) continue;
            
            queue<pair<int,int>> que;
            
            // 初期条件 (頂点 0 を初期ノードとする)
            dist[i][j] = 0;
            que.push(make_pair(i,j)); // 0 を橙色頂点にする
            ll cnt1=0;
            ll cnt2=0;
            // BFS 開始 (キューが空になるまで探索を行う)
            while (!que.empty()) {
                pair<int,int> t = que.front(); // キューから先頭頂点を取り出す
                que.pop();
                int x=t.first;
                int y=t.second;
                
                if(S[x][y]=='#') cnt1++;
                if(S[x][y]=='.') cnt2++;
                char bv=S[x][y];
                S[x][y]='x';
                
                // v から辿れる頂点をすべて調べる
                for (auto n : np) {
                    int nx=x+n.first;
                    int ny=y+n.second;
                    if (S[nx][ny]=='x') continue;
                    if (S[nx][ny]==bv) continue;
                    if (dist[nx][ny]!=-1) continue;
                    // 新たな白色頂点 nv について距離情報を更新してキューに追加する
                    dist[nx][ny] = dist[x][y] + 1;
                    que.push(make_pair(nx,ny));
                }
            }
            ans+=cnt1*cnt2;
        }
    }
    cout<<ans<<endl;
    

}

Measured memory_bytes: 4384
#include <stdio.h>

int main()
{
    int n,r=0;
    scanf("%d", &n);
    char color[n];
    scanf("%s", color);
    for(int i = 0; i < n; i++){
        if(color[i] == 'R'){
            r++;
        }
    }
    if(r > n-r){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <queue>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

const int MAX_V = 300;

int N, M, Q;
ll L;
ll dist[MAX_V][MAX_V];

void warshall_floyd(int v) {
  for (int k = 0; k < v; k++) {
    for (int i = 0; i < v; i++) {
      for (int j = 0; j < v; j++) {
        ll cost = dist[i][k] + dist[k][j];

        if (dist[i][j] > cost) {
          dist[i][j] = cost;
        }
      }
    }
  }
}

ll INF = 1152921504606846976;

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

  int A, B, C;

  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      if (i == j) {
        dist[i][j] = 0;
      } else {
        dist[i][j] = INF;
      }
    }
  }

  for (int i = 0; i < M; ++i) {
    cin >> A >> B >> C;

    if (C > L) continue;

    dist[A - 1][B - 1] = C;
    dist[B - 1][A - 1] = C;
  }

  warshall_floyd(N);

  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      if (i == j) {
        dist[i][j] = 0;
      } else if (dist[i][j] <= L) {
        dist[i][j] = 1;
      } else {
        dist[i][j] = INF;
      }
    }
  }

  warshall_floyd(N);

  cin >> Q;

  int s, t;

  for (int i = 0; i < Q; ++i) {
    cin >> s >> t;
    
    ll d = dist[s - 1][t - 1];

    if (d != INF) {
      cout << d - 1 << endl;
    } else {
      cout << -1 << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#define COLD 0
#define HOT 1
#define SUITABLE 2
using namespace std;
typedef pair<int,int>P;
typedef pair<P,P>Snake;
const int INF=1<<30;
int n,m,limit;
int min_cost[2][205][10005];
int temperature[10005];
vector<P>node[10005];
priority_queue<Snake,vector<Snake>,greater<Snake> >pq;
int main(){
  cin>>n>>m>>limit;
  for(int i=0;i<2;i++){
    for(int j=0;j<=limit;j++){
      for(int k=0;k<=n;k++){
	min_cost[i][j][k]=INF;
	if(k==1){
	  min_cost[i][j][k]=0;
	}
      }
    }
  }
  
  for(int i=1;i<=n;i++){
    int data;
    cin>>data;
    if(data==0){
      temperature[i]=COLD;
    }else if(data==1){
      temperature[i]=SUITABLE;
    }else if(data==2){
      temperature[i]=HOT;
    }
  }
  for(int i=0;i<m;i++){
    int a,b,c;
    cin>>a>>b>>c;
    node[a].push_back(P(b,c));
    node[b].push_back(P(a,c));
  }

  pq.push(Snake(P(0,1),P(COLD,limit)));
  while(!pq.empty()){
    Snake now=pq.top();pq.pop();
    int cost=now.first.first;
    int pos=now.first.second;
    int thermo=now.second.first;
    int times=now.second.second;
    for(int i=0;i<node[pos].size();i++){
      int next=node[pos][i].first;
      int ncost=node[pos][i].second;
      int n_thermo=temperature[next];
      int n_times=max(times-ncost,0);
      if(n_thermo==SUITABLE){
	if(cost+ncost<min_cost[thermo][n_times][next]){
	  min_cost[thermo][n_times][next]=cost+ncost;
	  pq.push(Snake(P(cost+ncost,next),P(thermo,n_times)));
	}
      }else if(thermo==n_thermo){
	if(cost+ncost<min_cost[thermo][limit][next]){
	  min_cost[thermo][limit][next]=cost+ncost;
	  pq.push(Snake(P(cost+ncost,next),P(n_thermo,limit)));
	}
      }else if(n_times==0){
	if(cost+ncost<min_cost[thermo][limit][next]){
	  min_cost[thermo][limit][next]=cost+ncost;
	  pq.push(Snake(P(cost+ncost,next),P(n_thermo,limit)));
	}
      }
    }
  }
  
  int minimum=INF;
  for(int i=0;i<2;i++){
    for(int j=0;j<=limit;j++){
      minimum=min(min_cost[i][j][n],minimum);
    }
  }
  cout<<minimum<<endl;
  return(0);
}



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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int k = Integer.parseInt(in.readLine());
        String input = in.readLine();

        if (k < input.length()) {
            System.out.print(input.substring(0, k) + "...");
        } else {
            System.out.print(input);
        }
    }
}

Measured memory_bytes: 36156
#!/usr/bin/env python

sa = input()
sb = input()
sc = input()

ch = sa[0]
sa = sa[1:]

while True:
    if ch == 'a':
        if len(sa) == 0:
            print('A')
            exit()
        ch = sa[0]
        sa = sa[1:]
    elif ch == 'b':
        if len(sb) == 0:
            print('B')
            exit()
        ch = sb[0]
        sb = sb[1:]
    elif ch == 'c':
        if len(sc) == 0:
            print('C')
            exit()
        ch = sc[0]
        sc = sc[1:]


Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;

ll a[200100];

int main(void){
    ll n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    reverse(a,a+n);
    ll x=0,z=0;
    ll ans=0;
    for(int i=n-1;i>0;i--){
        if(i==n-1){
            ans+=a[x];
            x++;
        }
        else if(z==0){
            ans+=a[x];
            z=1;
        }
        else{
            z=0;
            ans+=a[x];
            x++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
int N, M;
void func()
{
    cin >> N;
    ll A[N + 1] = {};
    ll B[N], max(0);
    rep(i, 0, N)
    {
        cin >> B[i];
        ++A[B[i]];
    }
    rep(i, 1, N + 1)
    {
        if (A[i] >= 2)
            max += (A[i] * (A[i] - 1) / 2);
    }
    rep(k, 0, N)
    {
        ll ans = max, tmp = B[k];
        if (A[tmp] >= 2)
        {
            ans -= (A[tmp] - 1);
        }
        cout << ans << endl;
    }
}
int main()
{
    func();
}

Measured memory_bytes: 5760
#pragma comment(linker, "/STACK:102400000,102400000")
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <iomanip>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define SZ(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define pi acos(-1)
#define mod 1000000007
#define inf 1000000007
#define ll long long
#define ull unsigned long long
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
#define N 100010
#define _DEBUG
template <class U,class T> void Max(U &x, T y){if(x<y)x=y;}
template <class U,class T> void Min(U &x, T y){if(x>y)x=y;}
template <class T> void add(int &a,T b){a=(a+b)%mod;}
inline int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}

int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%mod;
        a=1LL*a*a%mod;b>>=1;
    }
    return ans;
}
int pow(int a,int b,int c){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%c;
        a=1LL*a*a%c;b>>=1;
    }
    return ans;
}

int main(){
    //srand(time(NULL)+clock());
    int T,ca=0,k,i,j,m=0,K,n;
    //double start=clock();
    scanf("%d%d",&n,&K);
    if(K<=(n+1)/2)puts("YES");
    else puts("NO");
    //cerr<<(1.*clock()-start)/CLOCKS_PER_SEC<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
const int MAX = 2000000;
const int MOD = 998244353;
Int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
Int COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main()
{
    COMinit();
    int N, M; cin >> N >> M;
    Int a = 0, b = 0, c = 0;
    for (int o = M % 2; o <= M; o += 2) {
        int t = (3 * M - o) / 2;
        a += COM(t + N - 1, N - 1) * COM(N, o);
        a %= MOD;
    }
    for (int o = M % 2; o <= M; o += 2) {
        int t = (3 * M - o) / 2;
        b += N * COM((t - M) + N - 1, N - 1) % MOD * COM(N - 1, o - 1);
        b %= MOD;
    }
    for (int o = M % 2; o <= M; o += 2) {
        int t = (3 * M - o) / 2;
        c += N * COM((t - M - 1) + N - 1, N - 1) % MOD * COM(N - 1, o);
        c %= MOD;
    }
    cout << (a + MOD - b + MOD - c) % MOD << '\n';
    return 0;
}

Measured memory_bytes: 47104
#include<stdio.h>
#define N 100

int main(){
  int i,j,k,num[N],n,key;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&num[i]);
  }
 for(j=0;j<n;j++){
    if(j==n-1) printf("%d",num[j]);
     else printf("%d ",num[j] );
    }
 printf("\n");
  for(i=1;i<=n-1;i++){
    key=num[i];
    k=i-1;
    while(k>=0 && num[k]>key){
      num[k+1]=num[k];
      k--;
      num[k+1]=key;
    }
     for(j=0;j<n;j++){
       if(j==n-1) printf("%d",num[j]);
     else printf("%d ",num[j] );
    }
     printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int SIZE=100001;
//int arr[SIZE]={};
//ここまでテンプレ
int main(){
	int seat[SIZE]={};
	int N;
	cin>>N;
	int ans=0;
	for(int i=0;i<N;i++){
		int l,r;
		cin>>l>>r;
		ans+=r-l+1;
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(x,y) cout<<x<<"-"<<y<<endl;
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long int lli;
lli minn(lli a,lli b)
{
	if(b < a)
	{
		return b;
	}
	else
	{
		 return a;
	}
	
}
lli poww(lli x,lli y)
{
	if(y==0 || x==1)return 1;
	lli ans=1;
		if(y%2==0)
		{
			lli t=poww(x,(y/2));
			return t*t;
		}
		else
		{
			return x*poww(x,y-1);
			
		}	
}
int main()
{
	FastIO
	int t=1;
	// cin>>t;
	while(t--)
	{
		int n,m,x;
		cin>>n>>m>>x;
		int arr[12][12];
		int costs[12];
		for(int i=0;i<n;i++)
		{	cin>>costs[i];
			for(int j=0;j<m;j++)cin>>arr[i][j];
		}
		lli minc=INT64_MAX;
		for(lli i=1;i<=(poww(2,n)-1);i++)
		{
			bitset<12> b(i);
			lli tc=0;
			int ms[12];
			memset(ms,0,sizeof(ms));
			// for(int j=0;j<n;j++)cout<<b[j];
			// cout<<endl;
			for(int j=0;j<n;j++)
			{
				if(b[j])
				{
					tc=tc+costs[j];
					for(int k=0;k<m;k++)
					{
						ms[k]=ms[k]+arr[j][k];
					}
				}
			}
			int f=1;
			for(int k=0;k<m;k++)
			{
				if(ms[k]<x)
				{
					f=0;
					break;
				}
			}
			if(f)
			{
				// debug(minc,tc)
				minc=minn(minc,tc);
				// debug(minc,tc);
			}
		}
		if(minc==INT64_MAX)cout<<-1<<endl;
		else
		cout<<minc<<endl;
	}
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x, cnt=0;
    cin >> x;
    string s;
    cin>>s;
    for(int i=0; i<s.length()-2;i++)
    {
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
            cnt++;
    }

    cout<<cnt<<"\n";

}


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

int main() {
    int l,r,d ;
    cin >> l >> r >>d  ;
    int ans = 0 ;
    for (int i = l; i <= r; i++){
        if(i%d==0) ans++ ;
    }
    cout << ans << endl ;

}

Measured memory_bytes: 3616
# include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define in freopen( "input.txt" , "r" , stdin );
#define out freopen( "output.txt" , "w" , stdout );

using namespace std ;

int N2 = 2 * ( 1e5 + 7 ) ;

ll N1 = 1e7 + 7 ;

int main( ){

    // in

    // out

    int n ;

    cin >> n ;

    int a[n] ;

    vector<ll>b(N1),c(N1);

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

        cin >> a[i] ;

        b[a[i]] ++ ;

    }

    for( int i = 0 ; i < N1 ; i ++ ){

        if( b[i] == 0 ){

            c[i] = 0 ;

        }else if( b[i] > 0 ){

            c[i] = ( b[i] * ( b[i] - 1 ) ) / 2  ;

        }

    }

    ll sum = 0 ;

    for( int i = 0 ; i < N1 ; i ++ ){

        sum += c[i] ;

    }

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

        cout << sum - ( b[a[i]] - 1 )  << endl ;

    }

}


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

#define endl "\n"
using namespace std;
typedef long long int lli;
const lli M = 1e9 + 7, N = 2e6 + 5;
lli fact[N];

lli binpow(lli a, lli b) {
    if (b == 0) return 1;
    lli res = binpow(a, b / 2);
    res = (res * res) % M;

    if (b % 2) return (res * a) % M;
    return res;
}

lli inv(lli a) {
    return binpow(a, M - 2);
}

lli add(lli a, lli b) {
    lli res = a + b;
    if (res >= M)
        return res - M;
    return res;
}

lli mul(lli a, lli b) {
    lli res = a * b;
    if (res >= M)
        return res % M;
    return res;
}

lli sub(lli a, lli b) {
    return (a % M - b % M + M) % M;
}

void pre() {
    fact[0] = 1;
    for (int i = 1; i < N; i++)
        fact[i] = mul(fact[i - 1], i);
}

lli ncr(lli n, lli r) {
    return mul(fact[n], inv(mul(fact[n - r], fact[r])));
}

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

    lli k;
    string s;
    cin >> k >> s;
    lli i, n = s.length(), ans = binpow(26, n + k);

    for (i = 0; i < n; i++) ans = sub(ans, mul(ncr(n + k, i), binpow(25, n + k - i)));
    cout << ans;
    return 0;
}


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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    string s;
    cin >> s;
    int N = s.size();
    int K;
    cin >> K;
    set<string> x;
    REP(i, N) {
        FOR(j, 1, min(K + 1, N - i + 1)) {
            string y = s.substr(i, j);
            if(x.find(y) == x.end()) {
                x.insert(y);
            }
        }
    }
    int M = x.size();
    vector<string> v;
    v.reserve(M);
    for(auto i : x) {
        v.push_back(i);
    }
    sort(ALL(v));
    cout << v[K - 1] << endl;
    return 0;
}


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

using namespace std;

#define ll long long

const ll mod = 1e9 + 7;

ll n, a[30], ans = 1, t;

char c;

string ins;

int main(){
    cin >> n >> ins;

    for (int i = 0; i < n; i++){
        t = ins[i] - 'a' + 1;
        a[t]++;
    }

    for (int i = 1; i <= 26; i++){
        ans = (1 + a[i]) * ans;
        ans %= mod;
    }

    cout << ans - 1;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(), (x).end())
#define Reverse(x) reverse((x).begin(), (x).end())
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15) //15桁まで表示
#define str string
typedef std::pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<ui,ui> puu;
typedef pair<int, int> P;
typedef vector<int> vi;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int floor(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template<class T>inline bool chmax(T& a,T b){if(a < b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a > b){a=b;return true;}return false;};

int main() {
	int n,m,p,x,y=0;
	cin >> n;
	vi t(n);
	rep(i,n) {cin >> t[i]; y+=t[i];}
	cin >> m;
	rep(i,m){
		cin >> p>>x;
		cout << y-t[p-1]+x << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int t[n + 1], x[n + 1], y[n + 1];
    t[0] = x[0] = y[0] = 0;
    bool can = true;
    for (int i = 1; i <= n; i++)
        cin >> t[i] >> x[i] >> y[i];
    for (int i = 0; i < n; i++){
        int dt = t[i + 1] - t[i];
        int dx = abs(x[i + 1] - x[i]);
        int dy = abs(y[i + 1] - y[i]);
        int p = x[i + 1] + y[i + 1];
        if (t[i + 1] % 2 == 0 && p % 2 != 0){
            can = false;
            goto end;
        }
        if (t[i + 1] % 2 != 0 && p % 2 == 0){
            can = false;
            goto end;
        }
        int dist = dx + dy;
        if (dist > dt){
            can = false;
            goto end;
        }
        if (dist % 2 == 0 && dt % 2 != 0){
            can = false;
            goto end;
        }
        if (dist % 2 != 0 && dt % 2 == 0){
            can = false;
            goto end;
        }
    }
    end: ;
    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

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

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


void calc_primefactorization(long long in, vector<vector<long long> >& out){
	
	long long N = in, Ntmp;
	long long p,e,p_init = 2;
	vector<long long> out_tmp(2);
	
	if( in == 1 ){
		out_tmp[0] = 1;
		out_tmp[1] = 1;
	}
	else{
		while( 1 ){

			Ntmp = N;
				
			p = N;
			e = 1;

			for(long long i = p_init;i * i <= N;i++){
						
				if( Ntmp % i == 0 ){
					e = 0;
					while( 1 ){
						if( Ntmp % i != 0 ){
							break;
						}
						else{
							Ntmp = Ntmp / i;
							e++;
						}
					}
					p = i;
					break;
				}
				
			}
			
			out_tmp[0] = p;
			out_tmp[1] = e;
			out.push_back(out_tmp);
			
			for(int i = 0;i < e;i++){
				N = N / p;
			}
			
			if( N == 1 ){
				break;
			}
			
		}
	}
	
}

int bitmask(int n){
	
	int a = 1;
	
	return ( a << (n - 1) );
	
}


int main(){
	
	int N, K, Kt;
	
	cin >> N >> K;
	
	vector<int> A(N);
	
	for(int i = 0;i < N;i++){
		cin >> A[i];
	}
	
	for(int i = K;i < N;i++){
		if( A[i - K] < A[i] ){
			cout << "Yes";
		}
		else{
			cout << "No";
		}
		
		if( i != (N - 1) ){
			cout << endl;
		}
	}
	
	
	return 0;
	
}


Measured memory_bytes: 4044
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int h,w;
  cin>>h>>w;
  vector<string> a(h);
  REP(i,h){
    cin>>a[i];
  }
  int x=0,y=0;
  int dx[]={1,0,-1,0};
  int dy[]={0,1,0,-1};
  bool down=false,right=false;
  bool flag=true;
  int nx,ny;
  vector<vector<bool> > path(h,vector<bool>(w,false));
  path[0][0]=true;
  while(x != h-1 || y != w-1){
    down = false;right=false;
    REP(i,4){
      nx = x+dx[i];
      ny = y+dy[i];
      if(0<=nx && nx<h && 0<=ny && ny<w){
        if(a[nx][ny]=='.'){
          continue;
        }else{
          if(i>=2){
            if(path[nx][ny]){
              continue;
            }else{
              flag = false;
              break;
            }
          }else{
            if(i==0){
              down = true;
            }else{
              right = true;
            }
          }
        }
      }
    }
    if(!flag){
      break;
    }
    if((down && right) || (!down && !right)){
      flag = false;
      break;
    }else if(down){
      path[x+1][y]=true;
      x = x+1;
    }else{
      path[x][y+1]=true;
      y = y+1;
    }
  }
  if(flag){
    if(a[h-1][w-2]=='#' && a[h-2][w-1]=='#'){
      cout<<"Impossible"<<endl;
    }else{
      cout<<"Possible"<<endl;
    }
  }else{
    cout<<"Impossible"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define Pr(a) (#a)<<"="<<(a)<<" "
#define pr1(a) cerr<<Pr(a)<<endl
#define pr2(a,b) cerr<<Pr(a)<<Pr(b)<<endl
#define pr3(a,b,c) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<endl
#define pr4(a,b,c,d) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<endl
#define pr5(a,b,c,d,e) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<endl
#define pr6(a,b,c,d,e,f) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<Pr(f)<<endl
#define int long long
#define double long double
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  int a,b,c;
  cin>>a>>b>>c;
  
  auto ans = minmax({a,b,c});
  cout<<ans.first<<" "<<ans.second<<endl;

  return 0;
}



Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


auto main() -> int
{
    string s1, s2;
    cin >> s1 >> s2;
    if ( s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0] ) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;

int main()
{ 
    fast;

    ll n;
    cin>>n;
    ll a[n+1];
    ll x=1;
    ll ans=0;
    for(ll i=1;i<=n;i++)
    {
      cin>>a[i];
      if(a[i]!=x)
        ans++;
      else
        x++;

    }
    if(ans>n-1)
      cout<<-1<<endl;
    else cout<<ans<<endl;

   }

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define rep1(i, n) for (int i = 1; i < int(n); ++i)
#define repx(i, x, n) for (int i = int(x); i < int(n); ++i)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define ALL(n) begin(n), end(n)
#define IN(a, x, b) ((a) <= (x) && (x) < (b))
#define OUT(a, x, b) ((x) < (a) || (x) < (b))
typedef long long ll;
typedef long double ld;
const ll INF = 1e18;
const ll MOD = 1000000007;

using Graph = vector<vector<int>>;

struct Node
{
    int pair;
    vector<int> child;
};

int main()
{
    int N, M;
    cin >> N >> M;
    Graph G(N);
    Node T[N];
    int ans[N];
    rep(i, M)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    rep(i, N)
    {
        T[i].pair = i;
    }
    queue<int> q;
    q.push(0);
    while (!q.empty())
    {
        int i = q.front();
        q.pop();
        for (auto v : G[i])
        {
            if (T[v].pair != v)
            {
                continue;
            }
            T[v].pair = i;
            T[i].child.push_back(v);
            q.push(v);
            ans[v] = i;
        }
    }
    cout << "Yes" << endl;
    rep1(i, N)
    {
        cout << ans[i] + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 15256
a = [int(input()) for _ in range(5)]
def ceil(x):
  if x % 10 != 0:
    return 10 * ((x // 10) + 1)
  else:
    return x
sum = 0
min = 10
for i in range(5):
  sum = sum + ceil(a[i])
  if a[i] % 10 != 0 and a[i] % 10 < min:
    min = a[i] % 10
print(sum - 10 + min)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <limits>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>
 
using namespace std;
 
typedef long long int ll;
typedef std::numeric_limits<double> dbl;
const long long int LL_INF=1LL<<60;
 
vector<string> split(const string& input, char delimiter)
{
    stringstream stream(input);
    
    string field;
    vector<string> result;
    while (getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}
 
//#define DEBUG
 
ll A, B, M, N, D, K, L, Q, W, H, T, X, Y, S;
 
int main()
{
    cin >> N;
    ll cnt = 0;
    for (int i = 0; i < N; ++i) {
        int l,r;cin >> l >> r;
        cnt += r-l+1;
    }
 
    cout << cnt << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define SZ(x) ((ll)(x).size())
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}


int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(m);
    vector<int> d(m);
    REP(i,n){
        cin >> a[i] >> b[i];
    }
    REP(i,m){
        cin >> c[i] >> d[i];
    }
    vector<P> res(n,P(0,INT_MAX));
    REP(i,n){
        REP(j,m){
            int temp = abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(chmin(res[i].second,temp)){
                res[i].first = j+1;
            }
        }
    }
    REP(i,n){
        put(res[i].first);
    }
    return 0;
}


Measured memory_bytes: 256