akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
 
 
using namespace __gnu_pbds;
using namespace std;
 
 
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;
 
      a=a*a%mod;
      b/=2;
 
      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }
 
 
  int main()
  {
ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    // ifstream fin(".in");
    // ofstream fout(".in");
 
int n;
cin>>n;
bool is=false;
while(n)
{
  if(n%10==7)is=true;
  n/=10;
}
if(is)cout<<"Yes";
else cout<<"No";
 
 
    return 0;
  }

Measured memory_bytes: 3692
#include<cstdio>
using namespace std;
int main(void){
	int n,c;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		c=0;
		while(n!=1){
			if(n%2==0)n/=2;
			else      n=3*n+1;
			c++;
		}
		printf("%d\n",c);
	}
	return 0;
}

Measured memory_bytes: 2676
#pragma GCC optimize("trapv")
//#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
using vpi = vector<pi>;
const int maxn = 2e5 + 55;
const int mod = 1e9 + 7;
ll n, m, col[60], dp[2][1<<20];
vector<vpi> g;
bool dfs(int v, int p, int t, int c) {
	if(v==t) return true;
	for(auto i : g[v]) {
		if(i.first==p) continue;
		if(dfs(i.first, v, t, c)) {
			col[i.second]|=c;
			return true;
		}
	}
	return false;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	g.resize(n+1);
	for(int f, t, i = 1; i <n ; i++) {
		cin >> f >> t;
		g[f].pb({t, i-1});
		g[t].pb({f, i-1});
	}
	cin >> m;
	for(int f, t, i = 0; i < m; i++) {
		cin >> f >> t;
		dfs(f, f, t, 1<<i);
	}
	memset(dp, 0, sizeof dp);
	dp[0][0] = 1;
	for(int it = 0; it < n-1; it++) {
		int i = it&1;
		memset(dp[i^1], 0, sizeof dp[i^1]);
		for(int c = 1<<m; c--;) {
			dp[i^1][c|col[it]] += dp[i][c];
			dp[i^1][c] += dp[i][c];
		}
	}
	cout << dp[(n-1)&1][(1<<m)-1];

}


Measured memory_bytes: 16768
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <tuple>
#include <limits>

using namespace std;

int a[200'000];
int s[200'000];
vector<int> result;

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

    for (int i=0;i<n;i++){
        s[i] = 0;
    }

    for (int i =n;i>0;i--){
        if (s[i-1] % 2 != a[i-1]) {
            result.push_back(i);
            for (int j=1; j <= (int)floor(sqrt(i));j++ ){
                if (i % j==0){
                    s[j-1]++;
                    if (i!=j*j){
                        s[i/j-1]++;
                    }
                }
            }
        }
    }

    cout << result.size() << endl;
    for (int i =0;i<result.size(); i++){
        cout << result[i] << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3064
/*input
2 2 2 2 2
8 6
9 1
2 1
*/

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


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector<long long> p(a),q(b),r(c);
    for(int i=0;i<a;i++) cin >> p[i];
    for(int i=0;i<b;i++) cin >> q[i];
    for(int i=0;i<c;i++) cin >> r[i];

    sort(p.begin(), p.end());
    sort(q.begin(), q.end());
    sort(r.begin(), r.end());
    
    priority_queue<long long,vector<long long>,greater<long long>>pq1;

    long long sum = 0;
    for(int i=a-1;i>=a-x;i--){
        pq1.push(p[i]);
        sum += p[i];
    }
    for(int i=b-1;i>=b-y;i--){
        pq1.push(q[i]);
        sum += q[i];
    }

    for(int i=c-1;i>=0;i--){
        if(pq1.top()<=r[i]){
            sum -= pq1.top();
            sum += r[i];
            pq1.push(r[i]);
            pq1.pop();
        }
        else
            break;
    }
    cout <<sum;
    return 0;
}


Measured memory_bytes: 4852
import java.util.ArrayList;
import java.util.Scanner;

public class Main 
{

	public static void main(String[] args) 
	{
		Scanner scan = new Scanner(System.in);
		
		while(true)
		{
			int ruleNum = scan.nextInt();
			int packNum = scan.nextInt();
			ArrayList<Rule> rules = new ArrayList<Rule>();
//			ArrayList<Rule> permits = new ArrayList<Rule>();
//			ArrayList<Rule> denies = new ArrayList<Rule>();
			ArrayList<String> okpacks = new ArrayList<String>();
			
			if(ruleNum == 0 && packNum == 0)
			{
//				System.out.println("..... (terminated because of the limitation)");
				break;
			}
			
			for(int i = 0; i < ruleNum; i++)
			{
				String type = scan.next();
				if(type.equals("permit"))
				{
					rules.add(new Rule(scan.next(), scan.next(), i, 1));
				}
				
				if(type.equals("deny"))
				{
					rules.add(new Rule(scan.next(), scan.next(), i, 0));
				}
			}
			
			for(int i = 0; i < packNum; i++)
			{
				String ip1 = scan.next();
				String ip2 = scan.next();
				String content = scan.next();
				
				int status = 0;
				
				for(int r = 0; r < rules.size(); r++)
				{
					Rule rul = rules.get(r);
					
					if(rul.ip1matches(ip1) && rul.ip2matches(ip2))
					{
						//affected
						status = rul.type;
					}
				}
				
				if(status == 1)
				{
					okpacks.add(ip1 + " " + ip2 + " " + content);
				}
			}
			
			//print all okpacks
			System.out.println(okpacks.size());
			for(String pack : okpacks)
			{
				System.out.println(pack);
			}
		}
	}
	
	static class Rule
	{
		String ip1 = "";
		String ip2 = "";
		int index;
		int type;
		
		public Rule(String ip1, String ip2, int index)
		{
			this.ip1 = ip1;
			this.ip2 = ip2;
			this.index = index;
		}
		
		public Rule(String ip1, String ip2, int index, int type)
		{
			this.ip1 = ip1;
			this.ip2 = ip2;
			this.index = index;
			this.type = type;
		}
		
		boolean ip1matches(String enter)
		{
			for(int i = 0; i < ip1.length(); i++)
			{
				String curlet1 = ip1.substring(i, i+1);
				String curlet2 = enter.substring(i, i+1);
				
				if(!curlet1.equals(curlet2) && !curlet1.equals("?"))
				{
					return false;
				}
			}
			
			return true;
		}
		
		boolean ip2matches(String enter)
		{
			for(int i = 0; i < ip2.length(); i++)
			{
				String curlet1 = ip2.substring(i, i+1);
				String curlet2 = enter.substring(i, i+1);
				
				if(!curlet1.equals(curlet2) && !curlet1.equals("?"))
				{
					return false;
				}
			}
			
			return true;
		}
	}
}



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

using namespace std;

int main()
{
    int n;
    string str;

    cin>>str;
    n=str.length();

    long long dp[n+1][13];

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

    for(int i=0;i<n;i++){
        for(int j=0;j<10;j++){
            int nxt=str[i]-'0';
            if(str[i]=='?') nxt=j;
            for(int k=0;k<13;k++){
                int rem = (10*k+nxt)%13;
                dp[i+1][rem]+=dp[i][k];
                dp[i+1][rem]%=1000000000+7;
            }
            if(str[i]!='?') break;
        }
    }
    cout << dp[n][5] <<endl;

    return 0;
}


Measured memory_bytes: 10624
#include<bits/stdc++.h>
#define endl "\n" 
#define pi acos(-1)
#define ll long long 
using namespace std;
ll power(ll a,ll b){
	ll k=1;
	for(int i=0;i<b;i++)
		k*=a;
	return k;
}
void solve();
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif
	int q=1;//cin>>q;
	while(q--){
		solve();
	}
}
void solve(){
	ll n,sum(0),z;cin>>n;ll arr[100001]={0};
	for(int i=1;i<=n;i++){
		cin>>z;
		sum+=z;arr[z]++;
	}
	int q;cin>>q;ll x,y;
	for(int i=0;i<q;i++){
		cin>>x>>y;
		sum+=arr[x]*(y-x);
		arr[y]+=arr[x];
		arr[x]=0;
		cout<<sum<<endl;
	}
}

Measured memory_bytes: 4440
def get_combination_num(n: int, x: int) -> int:
    total_num: int = 0
    for a in [elem for elem in range(1, n + 1)]:
        if x < a:
            break
        for b in [elem for elem in range(1, a)]:
            if x < a + b:
                break
            for c in [elem for elem in range(1, b)]:
                if x < a + b + c:
                    break
                elif x == a + b + c:
                    total_num += 1

    return total_num


if __name__ == "__main__":
    while(True):
        n, x = map(lambda x: int(x), input().split())

        if (n == x == 0):
            break

        print(f"{get_combination_num(n, x)}")



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

int a, c;

main(){
    while (cin >> a){
        if (a == 0)return 0;
        a = 1000 - a, c = 0;
        int b[6] = {500, 100, 50, 10, 5, 1};
        for (int i = 0; i < 6 && a > 0; i++){
            while (a >= b[i])a -= b[i], c++;
        }
        cout << c << endl;
    }
}


Measured memory_bytes: 3000
import bisect

q = int(input())
M = {}
sortedList = []

for value in range(q):
    query, *inp = input().split()
    key = inp[0]

    # insert
    if query == "0":
        x = int(inp[1])

        if key not in M:
            bisect.insort_left(sortedList, key)
            M[key] = []

        M[key].append(x)

    # get
    elif query == "1":
        if key in M:
            if M[key]:
                for value in M[key]:
                    print(value)

    # delete
    elif query == "2":
        if key in M:
            M[key] = []

    # dump
    else:
        L = inp[0]
        R = inp[1]

        index_left = bisect.bisect_left(sortedList, L)
        index_right = bisect.bisect_right(sortedList, R)

        for value in range(index_left, index_right):
            keyAns = sortedList[value]
            if M[keyAns]:
                for valueAns in M[keyAns]:
                    print(keyAns, valueAns)



Measured memory_bytes: 39208
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<algorithm>
#include<queue>
#include<bitset>
#include<map>
#include<set>

#define maxn 200005
#define MOD 1000000007

using namespace std;

inline int getint()
{
	int num=0,flag=1;char c;
	while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;
	while(c>='0'&&c<='9')num=num*10+c-48,c=getchar();
	return num*flag;
}

int n,H;
int f[maxn];
int In[maxn],Ot[maxn];
int vis[maxn];

inline int find(int x)
{return f[x]==x?x:f[x]=find(f[x]);}
int main()
{
	n=getint(),H=getint();
	for(int i=1;i<=2*H;i++)f[i]=i;
	for(int i=1;i<=n;i++)
	{
		int A=getint(),B=getint(),C=getint(),D=getint();
		int x=C?C+H:A,y=D?D:B+H;
		Ot[x]++,In[y]++;
		x=find(x),y=find(y);
		if(x!=y)f[y]=x;
	}
	for(int i=1;i<=H;i++)if(In[i]>Ot[i]){printf("NO\n");return 0;}
	for(int i=H+1;i<=2*H;i++)if(In[i]<Ot[i]){printf("NO\n");return 0;}
	for(int i=1;i<=2*H;i++)if((!In[i]&&!Ot[i])||In[i]!=Ot[i])vis[find(i)]=1;
	for(int i=1;i<=2*H;i++)if(find(i)==i&&!vis[i]){printf("NO\n");return 0;}
	printf("YES\n");
}

Measured memory_bytes: 1560
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
int main()
{
	string a, b, c;
	cin >> a >> b >> c;
	cout << a[0] << b[0] << c[0];
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <stack>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <sstream>
#include <iomanip>
using namespace std;


#define int int64_t
#define vi vector<int>
#define vb vector<bool>
#define vbb vector< vector<bool> >
#define all(x) (x).begin(), (x).end()
#define vii vector< vector<int> >
#define rip(dp, n, m) vector< vector<int> > dp(n, vector<int>(m,0))
#define ff first
#define ss second
#define pii pair<int64_t, int64_t>
#define miv map<int, vector<int> >
#define mp make_pair
#define pb push_back
#define prr(x) cout << (#x) <<'	' << (x) << endl
#define pr(x) cout  << (x) << endl
#define f(i,n) for(i=0;i<n;i++)
#define pqb priority_queue<int>
#define pqs priority_queue<int,vi,greater<int> >
#define setbits(x)  __builtin_popcountll(x)
#define zrobits(x)  __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x) int x; cin>>x; while(x--)
#define FIO  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int dr8[] = {1,1,0,-1,-1,-1, 0, 1};
int dc8[] = {0,1,1, 1, 0,-1,-1,-1};
int dr4[] = {1,0,0,-1};
int dc4[] = {0,1,-1,0};

int32_t main()
{
    FIO;
    int i, n, j, m, k, l, t;
    // w(X)
    {
        string s, s1;
        cin >> s >> s1;
        l=0;
        for(i=0;i<=s.length()-s1.length();i++)
        {
            k=0;
            for(j=i;j<s1.length()+i;j++)
            {
                if(s[j]==s1[j-i]) k++;
            }
            // cout << i << " " << k << endl;
            l = max(l,k);
        }

        cout << s1.length()-l << endl;
    }
}

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

int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll>l(m);
    vector<ll>r(m);
    vector<ll>a(n+1);
    rep(i,m) cin>>l[i]>>r[i];
    sort(l.begin(),l.end());
    sort(r.begin(),r.end());
    if(r[0]<l[m-1]) cout<<"0"<<endl;
    else cout<<r[0]-l[m-1]+1<<endl;
    return 0;
}

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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i=0;i<N;i++) cin >> a[i];
    int all = 0;
    for (int i=0;i<N;i++){
        all ^= a[i];
    }
    for (int i=0;i<N;i++){
        int p = all^a[i];
        cout << p;
        if (i==N-1) cout << "\n";
        else cout << " ";
    }
}

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

int main() {
  int n;
  cin>>n;
  string s[n];
  for(int i=0; i<n; i++) cin>>s[i];

  for(int i=0; i<n; i++) {
    sort(s[i].begin(), s[i].end());
  }

  sort(s, s+n);

  vector<int64_t> ana;

  string now = s[0];
  int posi = 1;
  int count = 1;
  while(posi<n) {
    if(s[posi]==now) {
      posi++;
      count++;
    }

    else {
      ana.push_back(count);
      now = s[posi];
      posi++;
      count = 1;
    }
  }
  ana.push_back(count);

  int64_t ans = 0;
  for(int i=0; i<ana.size(); i++) {
    ans += ana[i]*(ana[i]-1)/2;
  }

  cout<<ans<<endl;

  // for(int i=0; i<n; i++) cout<<s[i]<<endl;

  return 0;
}

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

using namespace std;

void solve() {
    int D, T, S;
    cin >> D >> T >> S;
    if (S * T >= D)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

Measured memory_bytes: 3620
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル



n,k= map(int,input().split())


for i in range( 2, n + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans = 0
for i in range(min(n+1,k+1)):
    ans += cmb(n,i,mod)*cmb(n-1,i,mod)
    ans %= mod
print(ans)

Measured memory_bytes: 27052
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repR(i, n) for(ll i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(ll i = n; i >= 0; ++i)
#define FOR(i, m, n) for(ll i = m; i < n; ++i)
#define FORR(i, m, n) for(ll i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define itn ll
#define ednl endl
using namespace std;
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	
	int N;
	cin>>N;
	vector<int> A(N);
	FDS(i,N){
		cin>>A[i];
	}
	int sum=0;
	FDS(i,N){
		if(A[i]==0){
			sum++;
			break;
		}
	}
	if(sum==1){
		ll ans=0;
		FDS(i,N){
			ans+=abs(A[i]);
		}
		cout<<ans<<endl;
		return 0;
	}
	
	ll hiku=0;
	FDS(i,N){
		if(A[i]<0){
			hiku++;
		}
	}
	ll ans=0;
	if(hiku%2==0){
		FDS(i,N){
			ans+=abs(A[i]);
		}
		cout<<ans<<endl;
		return 0;
	}
	
	FDS(i,N){
		A[i]=abs(A[i]);
	}
	VSORT(A);
	FDS(i,N){
	    ans+=A[i];
	}
	ans-=A[0];
	ans-=A[0];
	cout<<ans<<endl;
}

Measured memory_bytes: 640
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define cy cout << "Yes" << endl
#define cn cout << "No" << endl
typedef long long ll;

void Main()
{
	int r;
  	cin >> r;
  	cout << 3*r*r << endl;

  return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
D = {i: 0 for i in range(1, N + 1)}
for i in range(M):
  a, b = map(int, input().split())
  D[a] += 1
  D[b] += 1
p = 0
for i in D:
  if D[i] % 2 == 1:
    p = 1
if p == 0:
  print("YES")
else:
  print("NO")


Measured memory_bytes: 15084
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  ll A[N];
  vector<int> plus, minus;
  int mini = inf, maxi = -inf;
  int miniind = -1, maxiind = -1;
  for(int i=0;i<N;++i) {
    cin>>A[i];
    if(A[i]<0) minus.push_back(i);
    else plus.push_back(i);
    if(mini>A[i]) {
      mini = A[i];
      miniind = i;
    }
    if(maxi<=A[i]) {
      maxi = A[i];
      maxiind = i;
    }
  }
  vector<pair<int, int> > ans;
  for(int i=0;i<minus.size();++i) {
    if(maxiind==minus[i] || miniind==minus[i]) continue;
    ans.push_back(mp(maxi, A[minus[i]]));
    maxi = maxi-A[minus[i]];
  }
  for(int i=0;i<plus.size();++i) {
    if(maxiind==plus[i] || miniind==plus[i]) continue;
    ans.push_back(mp(mini, A[plus[i]]));
    mini = mini - A[plus[i]];
  }
  if(plus.size()>0 && minus.size()>0) {
    cout<<maxi-mini<<endl;
    for(int i=0;i<ans.size();++i) cout<<ans[i].fi<<" "<<ans[i].se<<endl;
    cout<<maxi<<" "<<mini<<endl;
  }
  else if(plus.size()==0) {
    cout<<maxi-mini<<endl;
    for(int i=0;i<ans.size();++i) cout<<ans[i].fi<<" "<<ans[i].se<<endl;
    cout<<maxi<<" "<<mini<<endl;
  }
  else {
    cout<<maxi-mini<<endl;
    for(int i=0;i<ans.size();++i) cout<<ans[i].fi<<" "<<ans[i].se<<endl;
    cout<<maxi<<" "<<mini<<endl;
  }
}



Measured memory_bytes: 5964
n = int(input())
r = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(n)]
r.sort()
b.sort()
s = []
k = 0
ans = 0
for i in range(n):
    while True:
        if k >= n:
            break
        if b[i][0] > r[k][0]:
            s.append(r[k][1])
            k += 1
        else:
            s.sort()
            break
    for j in range(len(s) - 1, -1, -1):
        if s[j] < b[i][1]:
            ans += 1
            s.remove(s[j])
            break
print(ans)

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    D = list(map(int, input().split()))

    de = []
    count = [0] * 12
    for d in D:
        if d == 0 or d == 12:
            de.append(d)
        else:
            count[d] += 1
    
    ind = []
    for i in range(12):
        if count[i] == 1:
            ind.append(i)
        elif count[i] == 2:
            de.append(i)
            de.append(24-i)
        elif count[i] >= 3:
            print(0)
            return
    
    for i in range(len(ind)):
        if i&1:
            de.append(ind[i])
        else:
            de.append(24-ind[i])

    de = sorted(de)

    # print(count)
    # print(de)
    # print(ind)

    ans = de[0] - 0
    for i in range(1, N):
        ans = min(ans, de[i] - de[i-1])
    ans = min(ans, 24-de[-1])
    print(ans)
    



if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <sstream>
#include <numeric>
#include <string>
#include <vector>
#include <cstdio>
#include <bitset>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define np(v) next_permutation(v.begin(), v.end())
#define pll pair < long long, long long>
#define all(a) a.begin(), a.end()
#define ull unsigned long long
#define pii pair < int, int >
#define sz(a) (int)a.size()
#define sqr(x) ((x) * (x))
#define y1 stupid_cmath
#define vi vector <int>
#define pb push_back
#define mp make_pair
#define ll long long
#define f first
#define s second

const int inf = (int)3e6;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);

int n;
string s;
int pr1[300300];
int pr2[300300];

int main(){
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n >> s;
    for(int i = 1; i <= n; ++i){
        pr1[i] = pr1[i - 1];
        pr2[i] = pr2[i - 1];
        if(s[i - 1] == 'E'){
            pr1[i]++;
        }else{
            pr2[i]++;
        }
    }
    int ans = inf;
    for(int i = 1; i <= n; ++i){
        ans = min(ans, pr2[i - 1] + pr1[n] - pr1[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 2964
#include <iostream>

using namespace std;

int main() {
	int N, B, res = 0, L;
	cin >> N;
	for (int i = 0; i <= 6; i++) {
		B = 1;
		L = 0;
		while ( L < i) {
			B = B * 2;
			L++;
		}
		if (N >= B) {
			res = B;
		}
		else {
			break;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
const int MAX_N=1e3,MAX_M=1e3;
int N,M;
const ll MOD=1e9+7;
map<int,int> mpa,mpb;
int main(){
	cin>>N>>M;
	bool aflg=true;
	REP(i,N){
		int a;
		cin>>a;
		if (mpa.find(a)!=mpa.end()){
			aflg=false;
		}else{
			mpa[a]=i;
		}
	}
	REP(i,M){
		int b;
		cin>>b;
		if (mpb.find(b)!=mpb.end()){
			aflg=false;
		}else{
			mpb[b]=i;
		}
	}
	ll ans;
	if (aflg){
		ans=1;
	}else{
		ans=0;
	}
	int rc=0,cc=0,dc=0;
	for(int v=N*M;v>0;v--){
		int i,j;
		if (mpa.find(v)==mpa.end()){
			i=-1;
		}else{
			i=mpa[v];
		}
		if (mpb.find(v)==mpb.end()){
			j=-1;
		}else{
			j=mpb[v];
		}
		if (i!=-1 && j!=-1){
			dc+=rc+cc;
			rc++;
			cc++;
		}else if (i!=-1){
			ans*=cc;
			ans%=MOD;
			rc++;
			dc+=cc-1;
		}else if (j!=-1){
			ans*=rc;
			ans%=MOD;
			cc++;
			dc+=rc-1;
		}else{
			ans*=dc;
			ans%=MOD;
			dc--;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pie (3.141592653589)
using namespace std;

const int N = 2e5 + 10;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout << fixed;
	cout.precision(10);
	
	string s;
	cin >> s;
	if(s.back() == 's')
	{
		s += "es";
	}
	else
	{
		s += 's';
	}
	cout << s;
	
	return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


void solve(){
    string S, T;
    cin >> S >> T;
    int n = S.size();
    if(S == T.substr(0,n)){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}


Measured memory_bytes: 3640
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#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 reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

struct unionfind {
    vector<int> d;
    unionfind(int n=0) : d(n,-1) {}
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y);}
    int size(int x) { return -d[find(x)];}
};

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

    int n, m, k;
    cin >> n >> m >> k;
    unionfind uf(n);
    auto to = make_vec<int>(n, 0);
    auto block = make_vec<int>(n, 0);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].pb(b);
        to[b].pb(a);
        uf.unite(a, b);
    }
    rep(i, k) {
        int c, d;
        cin >> c >> d;
        c--; d--;
        block[c].pb(d);
        block[d].pb(c);
    }
    rep(i, n) {
        int ans = 0;
        ans += uf.size(i);
        ans--;
        ans -= sz(to[i]);
        for (auto&& j : block[i]) if (uf.same(i, j)) ans--;
        cout << ans << endl;
    }
    
}


Measured memory_bytes: 14556
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.matches("2019/0[1-4]/[0-3][0-9]")) {
            System.out.println("Heisei");
        } else {
            System.out.println("TBD");
        }
        sc.close();
    }
}

Measured memory_bytes: 19796
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

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


using namespace std;

bool f[10005];

int main() {
	
	for (int i = 3; i < 10005; i += 2) {
		f[i] = 1;
		for (int j = 3; j*j <= i; j+=2) {
			if (i%j == 0) {
				f[i] = 0; break;
			}
		}
	}
	f[2] = 1;
	int x;
	while (cin >> x) {

		int p = 0;
		for (int i = 1; i <= x; i++) {
			if (f[i] && f[x - i + 1])p++;
		}
		cout << p << endl;
	}
	
	return 0;

}

Measured memory_bytes: 3072
#include<stdio.h>

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

  int dif = 0;
  dif = b-a;

  int i = 0;
  if( dif < 2*k){
    for(i = a; i <= b ; i++ )printf("%d\n", i );
    }else{
    for(i = a; i < a+k; i++)printf("%d\n", i);
    for(i = b-k+1 ; i <= b; i++)printf("%d\n", i);
  }

  return 0;
}


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

using namespace std;

#define INF ((1<<30)-1)  //int32_t
#define MOD 1000000007
#define MOD2 

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

#define mkp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll GCD(ll m,ll n){
    ll big,small;
    ll p=-1;
    big=max(m,n);
    small=min(m,n);

    while(1){
        p=big%small;
        if(p==0)break;
        big=small;
        small=p;
    }
    
    return small;
}

int main(){

    bool flag=true;

    ll ans=1,sum=0;
    
    ll a,b;
    cin >>a>>b;


    __int128_t ab = a*b;
    ll lcm = GCD(a,b);

    for(int i = 2; i <= sqrt(lcm) + 1; i++){
        
        if(lcm%i == 0){
            //ll temp = lcm;
            while (lcm%i == 0)lcm /= i;
            ++ans;

            //while (lcm%(temp/i) == 0)lcm /= temp/i;
            //++ans;
        }

        if(lcm <= 1)break;
    }

    if(lcm > 1)++ans;

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
s = int(input())
def f(n):
    if n %2 == 0:
        return int(n / 2)
    else:
        return int(3*n+1)
ans = 0
a = []
a.append(s)
i = 1
while True:
    # print(a)
    ai = f(a[i-1])
    if ai in a:
        ans = i
        break
    a.append(ai)
    i+=1

print(ans +1 )

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <vector>
#include <stack>
#include <set>
#define fi first
#define se second
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const ll mod  = 1e9 + 7;
const ll N = 1e6 + 5;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a,b,c,k;
 	cin>>a>>b>>c>>k;
 	while(k--){
 		if(a>=b) b*=2;
 		else if(b>=c) c*=2;
 		else if(c>b && b>a) break;
 	}
 	if(c>b && b>a) cout<<"Yes\n";
 	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define MAX 9223372036854775807
#define MIN -9223372036854775807
#define PI 3.141592653589
#define setbits(n) __builtin_popcountll(n)
const ll mod=1e9+7;

const int N=1e5+1;
ll n,m;
vector<ll> a[N],b[N],c[N],d[N];
map<ll,ll> pos;
ll dp[N][2][2], par[N];


ll dfs(ll v, ll color, ll already_black, ll p=-1){
    if(dp[v][color][already_black]!=-1)
        return dp[v][color][already_black];
    par[v]=p;
    ll ans=1;
    vector<ll> k;
    for(ll u: a[v]){
        if(u==p) continue;
        ll add=0;
        if(color==1)
            add=(dfs(u,0,1,v)+dfs(u,1,1,v))%m;
        else{
            if(already_black==0) add=dfs(u,1,1,v);
            add=(add+dfs(u,0,already_black,v))%m;
        }
        if(color==1){
            pos[u]=k.size();
            k.pb(add);
            //cout<<add<<" ";
        }
        ans=(ans*add)%m;
    }
    int nk=k.size();
    if(color==1 && k.size()!=0){
        d[v].assign(nk,1);
        b[v].assign(nk,1);
        c[v].assign(nk,1);
        b[v][0]=k[0];
        for(int i=1;i<nk;i++)
            b[v][i]=(b[v][i-1]*k[i])%m;
        //cout<<"\n";
        //for(ll i=0;i<nk;i++) cout<<b[v][i]<<" ";
        //cout<<"\n";
        c[v][nk-1]=k[nk-1];
        for(int i=nk-2;i>=0;i--)
            c[v][i]=(c[v][i+1]*k[i])%m;
        //for(ll i=0;i<nk;i++) cout<<c[v][i]<<" ";
        //cout<<"\n";
        d[v].assign(nk,1);
        if(nk>1) d[v][0]=c[v][1], d[v][nk-1]=b[v][nk-2];
        for(int i=1;i<nk-1;i++)
            d[v][i]=(b[v][i-1]*c[v][i+1])%m;
        //cout<<"  -  ";
        //for(ll i=0;i<nk;i++) cout<<d[v][i]<<" ";
        //cout<<'\n';
    }
    return dp[v][color][already_black]=ans;
}

void dfs1(ll v, ll prevmul, ll p=-1){
    ll mul;
    if(p==-1) mul=0;
    else mul=(d[p][pos[v]]*(prevmul+1))%m;
    dp[v][1][1]=(dp[v][1][1]*(mul+1))%m;
    for(ll u: a[v]){
        if(u==p) continue;
        dfs1(u,mul,v);
    }
}


int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll T=clock();
    
    cin>>n>>m;
    for(int i=0;i<n-1;i++){
        ll u,v;
        cin>>u>>v; u--,v--;
        a[u].pb(v);
        a[v].pb(u);
    }
    memset(dp,-1,sizeof(dp));
    dfs(0,1,1), dfs(0,0,0);
    ll prevmul=0;
    dfs1(0,0);
    cout<<dp[0][1][1]<<"\n";
    for(ll i=1;i<n;i++)
        cout<<dp[i][1][1]<<"\n";

    cerr<<"\n\nTIME: "<<(double)(clock()-T)/CLOCKS_PER_SEC<<" sec\n";
    T = clock();
    return 0;
}

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

// Macros
#define F  first
#define S  second
#define PB push_back

// Rename Datatypes
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;

// Common Functions
ll fastpow(ll a, ll ex){ ll res = 1; while(ex){ if(ex & 1) res *= a; a *= a; ex >>= 1; } return res; }
ll fastpow(ll a, ll ex, ll m){ a %= m; ll res = 1; while(ex){ if(ex & 1) res = (a*res) % m; a = (a*a) % m; ex >>= 1; } return res; }
ll modinverse(ll a, ll m){ ll m0 = m, y = 0, x = 1; while (a > 1){ ll q = a / m; a %= m; swap(a,m); x -= q*y; swap(x,y); } if(x < 0) x += m0; return x; }

// HELPERS
//  Tedious Grid Movements
vector<pii> moves_grid = { {0,1} , {0,-1} , {1,0} , {-1,0} };
inline bool move_okay(int x, int y, int n, int m) { return 0 <= x and x < n and 0 <= y and y < m; }
//  Remember:
//   * vec.assign() GOOD; vec.resize() BAD
//   * comparator uses <


// CODE STARTS HERE

void solve(){
	int X;
	cin >> X;

	cout << (30 <= X ? "Yes\n" : "No\n");
}

signed main (void){
	// Fast_IO
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// Set Fixed Notation (default sucks), High Precision for Floating-Point Output
	cout << fixed << setprecision(20);

	// Multiple TCs
	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
}


Measured memory_bytes: 3612
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()
	x := readString()
	y := readString()
	a := []byte(x)[0]
	b := []byte(y)[0]
	if a < b {
		println("<")
	} else if a > b {
		println(">")
	} else {
		println("=")
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve() {
    ll n; cin >> n;
    ll mint = 1e16;
    rep(i, 0, 5){
        ll t; cin >> t;
        mint = min(mint, t);
    }
    ll ans;
    // nがmintで割り切れるかどうかで場合分け
    if(n%mint == 0) ans = n/mint + 4;
    else ans = n/mint + 5;
    cout << ans << endl;
}

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

    solve();
    return 0;
}

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

int n,m;
char a[10][10];
int x[2]={0,1},y[2]={1,0};

queue<pair<int,int> > q;

main()
{
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++)
	{
		scanf("%s",a[i]);
	}
	if(a[0][0]=='#'&&a[n-1][m-1]=='#')
	{
		a[0][0]='.';
		q.push(make_pair(0,0));
		int d=0;
		while(!q.empty())
		{
			int p1=q.front().first,p2=q.front().second;
			q.pop();
			d=0;
			for(int i=0;i<2;i++)
			{
				if(p1+x[i]<n&&p2+y[i]<m&&a[p1+x[i]][p2+y[i]]=='#')
				{
					d++;
					a[p1+x[i]][p2+y[i]]='.';
					q.push(make_pair(p1+x[i],p2+y[i]));
				}
			}
			if(d==2)
			{
				printf("Impossible");
				return 0;
			}
		}
		if(a[n-1][m-1]!='.')
		{
			printf("Impossible");
			return 0;
		}
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				//printf("%c",a[i][j]);
				if(a[i][j]=='#')
				{
					printf("Impossible");
					return 0;
				}
			}
			//printf("\n");
		}
		printf("Possible");
	}
	else
	{
		printf("Impossible");
	}
}


Measured memory_bytes: 256
k, s = map(int, input().split())

counter = 0
for z in range(0, k+1):
  if 2 * k < s - z:
    continue
  for y in range(0, k+1):
    if k + y + z < s:
      continue
    elif   s - y - z < 0:
      break
    else:
      counter += 1
print(counter)

Measured memory_bytes: 41196
#include<stdio.h>
#define N 100
#define INFINITY 2000000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

void dijkstra(void);

int n,G[N][N];

int main(){
    
 int i,j,k,c,u,v;
 
 scanf("%d",&n);
 for(i=0;i<n;i++){
     for(j=0;j<n;j++){
         G[i][j]=INFINITY;
         
     }
 }
 
 for(i=0;i<n;i++){
     scanf("%d%d",&u,&k);
     for(j=0;j<k;j++){
         scanf("%d%d",&v,&c);
         G[u][v]=c;
     }
 }
 
  dijkstra();

  return 0;
  
}

void dijkstra(){
    int i,j,u,v;
  int minv;
  int d[N],color[N];

  for(i=0;i<n;i++){
    d[i]=INFINITY;
    color[i]=WHITE;
    
  }
  d[0]=0;
  color[0]=GRAY;
  while(1){
      minv=INFINITY;
      u=-1;
      for(i=0;i<n;i++){
          if(minv>d[i] && color[i] != BLACK){
              u=i;
              minv=d[i];
              
          }
          
      }
      if(u==-1) break;
  color[u]=BLACK;
  for(v=0;v<n;v++){
      if(color[v]!=BLACK && G[u][v] != INFINITY){
          if(d[v]>d[u] + G[u][v]){
              d[v] = d[u] + G[u][v];
              color[v]=GRAY;
              
          }
          
      }
      
  }
  }//while
  
  for(i=0;i<n;i++){
      if(d[i]==INFINITY) d[i]=-1;
      printf("%d %d\n",i,d[i]);
      
  }
  
  
}


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

int main() {
  string s, t="keyence", u="";
  cin >> s;

  rep(i,s.size()) {

    if(s.at(i)==t.at(i)) {
      u += t.at(i);
      if(u==t) {
        cout << "YES" << endl;
      }
      continue;
    }

    for(int j = i; j<s.size(); j++) {
      if(u+s.substr(j)==t) {
        cout << "YES" << endl;
        return 0;
      }
    }
    cout << "NO" << endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define lli unsigned long long int
using namespace std;
#define S second
#define F first
#define pb push_back
#define M1 1000000007
#define M2 998244353
#define pint pair<int,int>
#define setit set<int>::iterator seti
#define mapit map<int,int> ::iterator mapi
#define MP make_pair
#define MT make_tuple
#define PI 3.14159265358979323846
// 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 mini(x,y) (y + ((x - y) & ((x - y) >>(sizeof(int) * CHAR_BIT - 1))))
#define maxi(x,y) (x - ((x - y) & ((x - y) >> (sizeof(int) * CHAR_BIT - 1))))
#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()
{
  /*
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
*/
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lli t, n, g, b, i, x, j;
    cin >> n;
    lli a[n];
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    x = 0; lli l = 0;
    for (i = 0; i < n - 1; i++) {
        if (a[i + 1] <= a[i]) {
            x++;
        }
        else {
            l = max(l, x);
            x = 0;
        }
    }
    l = max(l, x);
    cout << l;
}



Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
int mod = (int) 1e9 + 7;

int main(){
    
    int n, ans;
    cin >> n;
    vector<int> a(n,0), b(n,0);
    rep(i,n) cin >> a[i] >> b[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    if(n % 2 > 0){
        int m = (n - 1) / 2;
        ans = b[m] - a[m] + 1;
    } else {
        int m = n / 2;
        ans = b[m] + b[m - 1] - a[m] - a[m - 1]+ 1;
    }
    
    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 4368
void main() {
    int[] tmp = readln.split.to!(int[]);
    int a = tmp[0], b = tmp[1], c = tmp[2], d = tmp[3];
    int[] time = new int[101];
    ++time[a], --time[b], ++time[c], --time[d];
    foreach (i; 1 .. 101) {
        time[i] += time[i-1];
    }
    time.count(2).writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

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

using namespace std;

int main(){
	double a, b, c, d, e, f;
	double x, y;

	while(cin >> a >> b >> c >> d >> e >> f){

	x = (c*e - b*f) / (a*e - b*d);
	y = (c*d - a*f) / (b*d - a*e);

	if(x==0)x=0;
	if(y==0)y=0;

	cout << fixed << setprecision(3) << x << " " << y << endl;
}
}

Measured memory_bytes: 1280
#include <iostream>
using namespace std;
 
int main(){
    int n;
    cin >> n;
 
    long A[n+1];
    long B[n];
 
    for (int i = 0; i < n + 1;i++){
        cin >> A[i];
    }
    for (int i = 0; i < n;i++){
        cin >> B[i];
    }
    long sum = 0;
 
    for (int i = 0; i < n;i++){
        for (int j = 0; j < 2;j++){
            if(B[i] >= A[j+i]){
                B[i] -= A[j+i];
                sum += A[j+i];
                A[j+i] = 0;
            }else{
                sum += B[i];
                A[j+i] -= B[i];
                B[i] = 0;
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1792
import sys

# from collections import Counter, deque, defaultdict
# from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
# from functools import reduce
# from math import ceil, floor, log10, log2, factorial

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7

N, K = [int(x) for x in input().split()]

print(N - K if K != 1 else 0)


Measured memory_bytes: 2940
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.to!long;
  long res;
  foreach (i; 1..n+1) {
    auto x = (i.to!long) ^^ 2;
    if (x > n) break;
    res = x;
  }
  res.writeln;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll N,K;
  cin >> N >> K;
  ll x[N],y[N];
  vector<ll> xary,yary;
  ll max_x=INF,min_x=-INF,min_y=-INF,max_y=INF;
  REP(i,N){
    cin >> x[i] >> y[i];
    xary.push_back(x[i]);
    yary.push_back(y[i]);
  }
  sort(ALL(xary));
  sort(ALL(yary));
  ll ans = 1LL*(xary[N-1]-xary[0])*(yary[N-1]-yary[0]);
  REP(xi,N){
    REP(xj,N){
      REP(yi,N){
        REP(yj,N){
          ll num =0;
           ll lx=xary[xi],rx=xary[xj];
           ll by=yary[yi],uy=yary[yj];
           REP(i,N){
             if(lx<=x[i] && x[i]<=rx && by<=y[i] && y[i]<=uy){
               num++;
             }
            if(num>=K){
              ans=min(ans,1LL*(rx-lx)*(uy-by));
            }
           }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256