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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define data asd09123jdf02i3h

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9+10;
const lf eps = 1e-8;
const int mod = 1e9+7;

pii a[maxn];
int n;

int main() {
    read(n);int mn=inf,mx=-inf,l,r,p,q;
    for(int i=1;i<=n;i++) {
        read(a[i].fr),read(a[i].sc);
        if(a[i].fr>mx) mx=a[i].fr,l=i;
        if(a[i].sc<mn) mn=a[i].sc,r=i;
    }
    int ans=0;p=a[l].sc,q=a[r].fr;
    for(int i=1;i<=n;i++) if(i!=l&&i!=r) ans=max(ans,a[i].sc-a[i].fr+1);
    ans+=max(0,a[r].sc-a[l].fr+1);// printf("%d %d\n",l,r);
    sort(a+1,a+n+1);int res=inf;
    for(int i=n;~i;i--) {
        if((a[i].fr==mx&&a[i].sc==p)||(a[i].sc==mn&&a[i].fr==q)) continue;
        ans=max(ans,max(0,mn-max(q,a[i].fr)+1)+max(0,min(res,p)-mx+1));// write(ans);
        res=min(res,a[i].sc);
    }write(ans);
    return 0;
}


Measured memory_bytes: 1024
Button={
"1":"',.!?",
"2":"abcABC",
"3":"defDEF",
"4":"ghiGHI",
"5":"jklJKL",
"6":"mnoMNO",
"7":"pqrsPQRS",
"8":"tuvTUV",
"9":"wxyz",
"0":" "}

while True:
    try:
        sent=raw_input()
    except EOFError:
        break
    init=sent[0]
    cnt=1
    ans=[]
    for c in sent[1:]:
        if c==init:
            cnt+=1
        elif init=="0" and c!="0":
            init=c
            ans.append(" "*(cnt-1))
            cnt=1
        else:
            ans.append(Button[init][cnt-1])
            init=c
            cnt=1
    else:
        ans.append(Button[init][cnt-1])
    print "".join(ans)

Measured memory_bytes: 4256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;

    int cnt = 0;
    if(s.size()>=2)
    {
        for(int i=1; i<s.size();i++)
        {
            if(s[i]!=s[i-1])cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3716
n,m,x,y=map(int,input().split())
xx=list(map(int,input().split()))
yy=list(map(int,input().split()))
s=0
X=max(xx)
Y=min(yy)

for i in range(x+1,y):
  if X<i<=Y:
    print("No War")
    s=1
    break
if s==0:
  print("War")

Measured memory_bytes: 3064
#とりあえず全検索
iN,iK = [int(_) for _ in input().split()]
aX = [int(_) for _ in input().split()]
aP = [_ for _ in aX if  _ >= 0]
aM = [-1*_ for _ in aX if  _ < 0][::-1]
iP = len(aP)
iM = len(aM)
if iP == 0:
    print(aM[iK-1])
    exit()
elif iM == 0:
    print(aP[iK-1])
    exit()
iD = 2*aP[-1]+2*aM[-1]
for i in range(min(iP-1,iK-1),-1,-1):
    if iK - 2 -i < 0:
        iD = min(iD,aP[i])
    elif iM > iK -2 - i :
        iD = min(iD,aP[i] + 2*aM[iK-i-2])
for i in range(min(iM-1,iK-1),-1,-1):
    if iK - 2 - i < 0:
        iD = min(iD,aM[i])
    elif iP > iK -2 - i :
        iD =  min(iD,aM[i] + 2*aP[iK-i-2])
print(iD)


Measured memory_bytes: 14396
loop do 
  h, w = gets.split.map!(&:to_i)
  break if h == 0 && w == 0
  h.times do |i|
    if (i == 0 || i == h - 1) then 
      puts "#" * w
    else
      if (w <= 2) then
        puts "#" * w 
      else
        margin_count = w - 2
        puts "#" + "." * margin_count + "#"
      end
    end
  end
  puts ""
end

Measured memory_bytes: 8784
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t,u;
  cin >> s >> t >> u;
  if(s.at(s.size()-1)==t.at(0) && t.at(t.size()-1)==u.at(0)){
    cout << "YES";
  }else{
     cout << "NO";
  }
}

Measured memory_bytes: 256
def qsort(array):
    if len(array) < 2:
        return array
    else:
        pivot = array[0]
        less = [i for i in array[1:] if i <= pivot]
        greater = [i for i in array[1:] if i > pivot]
        return qsort(less) + [pivot] + qsort(greater)

si = input()
ti = input()

s_sort = qsort(si)
t_sort = qsort(ti)

s = ''
t = ''

for i in s_sort:
    s += i
for i in t_sort[::-1]:
    t += i
if s < t:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <math.h>

using namespace std;

int main(void){
    int x;
    cin >> x;
    
    if(x == 7 || x == 5 || x == 3){
        cout << "YES" << endl;
    } else {
        cout << "NO" << 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 reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];
#define int long long

signed main(){
    int T,X;
    cin >> T >> X;
    printf("%f\n",(double)T/X);
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]

A, B = 1, N
for lr in LR:
    L, R = lr
    if R < A or B < L:
        print(0)
        exit()

    if A <= L <= R <= B:
        A, B = L, R
    elif L <= A <= R <= B:
        B = R
    elif A <= L <= B <= R:
        A = L
print(B - A + 1)


Measured memory_bytes: 56284
#include <bits/stdc++.h>
     
#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair
     
using namespace std;
     
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  const int N = 1e6 + 10;
  vi p(N, 1);
  for (int u = 2; u < N; u++) {
    if (p[u] != 1) continue;
    for (int v = u; v < N; v += u) {
      p[v] = u;
    }
  }
  vi cnt(N, 0);
  int g = 0;
  for (int i = 1; i <= n; i++) {
    int ai;
    cin >> ai;
    if (i == 1) g = ai;
    else g = __gcd(g, ai);
    while (ai != 1) {
      int pi = p[ai];
      cnt[pi]++;
      while (ai % pi == 0) ai /= pi;
    }
  }
  bool ok = true;
  for (int i = 2; i < N; i++) {
    ok &= (cnt[i] < 2);
  }
  if (ok) cout << "pairwise coprime\n";
  else if (g == 1) cout << "setwise coprime\n";
  else cout << "not coprime\n";
  return (0);
}


Measured memory_bytes: 11116
temthr = input()
tem1, tem2, tem3 = temthr[:1], temthr[1:2], temthr[2:3]
c = 0
if tem1 == "R":
  if tem2 == "R":
    if tem3 == "R":
      print(3)
    elif tem3 == "S":
      print(2)
  elif tem2 == "S":
    print(1)
if tem1 == "S":
  if tem2 == "R":
    if tem3 == "R":
      print(2)
    elif tem3 == "S":
      print(1)
  elif tem2 == "S":
    if tem3 == "R":
      print(1)
    else:
      print(0)

Measured memory_bytes: 8988
#include <bits/stdc++.h>
using namespace std;
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
#define exit(a, b) return cout << a, b;
 
#define PB push_back
#define MP make_pair
 
#define sd(n) scanf("%lld", &n)
#define pdn(n) printf("%lld\n", n);
#define pds(n) printf("%lld ", n);
#define endl '\n'
 
#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define all(v) v.begin(), v.end() 
 
using vi = vector<int>;
using vb = vector<bool>;
using pii = pair<int, int>;
using mii = map<int, int>;
 
#define print(stuff) cout << stuff << endl
#define len(stuff) stuff.size()
 
#define int long long
 
const int upper = 3e5 + 20;
const int M = (int) 1e9 + 7;
const int inf = (int) 1e17;
const double eps =  1e-8;
 
signed main () {
	start_routine();
	speed();
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);	
	// freopen("output.txt", "w", stdout);
	// freopen("errlog.txt", "w", stderr);
	#endif
 
	int n, k; 
	cin >> n >> k;
 
	int mn = inf;
 
	int arr[n];
	for (int i = 0; i < n; i += 1) {
		cin >> arr[i];
	}
 
	sort(arr, arr + n);
 
	for (int i = 0; i < n; i += 1) {
		if (i + k - 1 >= n) break;
		mn = min(mn, arr[i + k - 1] - arr[i]);
	}
 
	cout << mn;	
 	end_routine();	
}

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

const int maxn = 1e5+10;
const int mod = 998244353;

using namespace std;

ll add(ll x,ll y){
	return ((x%mod+y%mod)%mod+mod)%mod;
}

void solve(){
	int n;ll ans=0;
	cin>>n;
	vii vs(n);
	vi dir(n+10,0),dp(n+10,0);
	for(ii &x:vs) cin >> x.ff >> x.ss;
	sort(all(vs));
	dp[n]=1;
	for(int i=n-1;i>=0;--i){
		dir[i] = i;
		while(dir[i] < n-1 && vs[i].ff + vs[i].ss > vs[dir[i]+1].ff){
			dir[i]=dir[dir[i]+1];
		}
		dp[i] = add(dp[i+1],dp[dir[i]+1]);
	}
	cout<<dp[0]<<endl;
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

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

int main() {
  string s,t;
  cin >> s >> t;
  int ans;
  int cur;
  rep(i,s.size()){
    if(i + t.size() > s.size()) break;
    rep(j,t.size()){
      if(s[i + j] == t[j]){
        cur++;
      }
    }
    ans = max(ans,cur);
    cur = 0;
  }
  cout << t.size() - ans << endl;
  return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n, m; cin >> n >> m;
    vector<vector<int>> g(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vector<int> dist(n, INF);
    dist[0] = 0;
    priority_queue<int> q;
    q.push(0);
    while (q.size()) {
        int u = q.top(); q.pop();
        for (int v: g[u]) {
            if (chmin(dist[v], dist[u] + 1)) {
                q.push(v);
            }
        }
    }

    cout << (dist[n-1] == 2 ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}


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

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

// code starts
int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  int i;
  rep(i,n) cin >> a[i];
  ll ans = 0;
  rep(i,n-1)
  {
    if(a[i]%2 == 1 && a[i+1] != 0)
    {
      a[i]--;
      a[i+1]--;
      ans++;
    }
  }
  rep(i,n)
  {
    ans += a[i]/2;
    a[i] %= 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cout << #v "=" << (v) << endl;
#define ppa(v) cout << "----\n"; rep(i,v.size()) cout << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)

int center_height(int x, int y, int cx, int cy, int h) {
  return abs(x-cx) + abs(y-cy) + h;
}

// ABC112C Pyramid 方針
// cx,cyで全探索
// 全座標が1万以上、観測地点100以下より、高度が0でない観測地点が一つ以上ある
// 高度が0でない観測地点を一つ選び、頂上の高さHを算出
// 観測地点の頂上からのマンハッタン距離をLとする
// 観測地点の高度が0の時、L < Hなら矛盾
// 観測地点の高度altが0以外の時、L + alt <> Hなら矛盾

int main() {
  int n; cin >> n;
  vector<int> x(n),y(n),h(n);
  rep(i,n) cin >> x[i] >> y[i] >> h[i];

  rep(cx,101) rep(cy,101) {
    bool valid = true;
    int H, L;
    rep(i,n) {
      if (h[i] == 0) continue;
      H = center_height(x[i],y[i],cx,cy,h[i]);
      break;
    }

    rep(i,n) {
      L = center_height(x[i],y[i],cx,cy,h[i]);
      if (h[i] == 0) {
        if (L < H) {
          valid = false;
          break;
        }
      } else {
        if (L != H) {
          valid = false;
          break;
        }
      }
    }

    if (valid) {
      cout << cx << " " << cy << " " << H << endl;
      exit(0);
    }
  }
}

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

int main() {
  int N,X;
  cin >> N >> X;
  vector<int> vec(N);
  for(int i = 0;i < N;i++) {
    cin >> vec.at(i);
  }
  vector<int> S(N + 1,0);
  for(int i = 1;i < N + 1;i++) {
    S.at(i) = S.at(i - 1) +vec.at(i - 1);
  }
  int count = 0;
  for(int i = 0;i < N + 1;i++) {
    if(S.at(i) > X) {
      break;
    }
    count++;
  }
  cout << count << endl;
}

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

#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  string s;
  cin>>s;
  vector<ii> f;
  vector<ii> f2;
  int p=0;
  string s3 = s.substr(min(a,b)-1, max(c,d)-min(a,b)+1);
  f.push_back(make_pair(s3[0],1));
  for (int i=1; i<n; i++) {
    if (s3[i]==f[p].first) f[p].second++;
    else {
      f.push_back(make_pair(s3[i],1));
      p++;
    }
  }
  p=0;
  string s2 = s.substr(max(a,b)-2, min(c,d)-max(a,b)+3);
  f2.push_back(make_pair(s2[0],1));
  for (int i=1; i<(int)(s2.length()); i++) {
    if (s2[i]==f2[p].first) f2[p].second++;
    else {
      f2.push_back(make_pair(s2[i],1));
      p++;
    }
  }
  int x = ((a<b)!=(c<d));
  int mxiwa = 0;
  int mxflt = 0;
  for (auto& pr: f) {
    if (pr.first=='#') mxiwa = max(mxiwa, pr.second);
    else mxflt = max(mxflt, pr.second);
  }

  if (mxiwa>=2) {
    cout << "No" << endl;
    return;
  }

  if (!x) {
    cout << "Yes" << endl;
    return;
  }

  int mxiwa2 = 0;
  int mxflt2 = 0;
  for (auto& pr: f2) {
    if (pr.first=='#') mxiwa2 = max(mxiwa2, pr.second);
    else mxflt2 = max(mxflt2, pr.second);
  }
  if (mxflt2>=3) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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


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

int main(void){
	int W,H;
	string l = "";
	for(int i = 0; i < 300; i++)l += "#";
	cin >> H >> W;
	while(H != 0 || W != 0){
		string line = l.substr(0,W);
		for(int i = 0; i < H; i++){
			cout << line << "\n";
		}
		cout << "\n";
		cin >> H >> W;
	}
	return 0;

}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define F first
#define S second
#define INF ll(1e18)
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 100005

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	//freopen("test.out","w",stdout);
	int n; cin>>n;
	string s;
	
	queue<pair<string,int>> q;
	q.push({"",0});
	
	set<string> v;
	
	while(!q.empty())
	{
		string cur=q.front().F; int cx=q.front().S; q.pop();
		
		if(cur.size()==n){
			v.insert(cur);
			continue;
		}
		
		forn(i,0,cx){
			q.push({cur+char('a'+i),cx});
		}
		q.push({cur+char('a'+cx),cx+1});
	}
	
	for(auto it=v.begin();it!=v.end();it++) cout<<*it<<'\n';
	
	return 0;
}


Measured memory_bytes: 12416
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = /*1e9 + 7*/998244353;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

//拡張拡張Euclidの互除法による(階乗)逆元の求め方
//O(N)
void stairs(long long N, vector<long long>& st, long long mod = 1e9 + 7) {
	st.resize(N + 1, 1);
	for (long long n = 2; n <= N; n++) {
		st[n] = (st[n - 1] * n) % mod;
	}
}

ll stair(ll N, ll mod = 1e9 + 7) {
	ll ans = 1;
	for (ll n = 2; n <= N; n++)ans = (ans * n) % mod;
	return ans;
}

void modinvs(long long N, vector<long long>& inv, vector<long long>& sinv, long long mod = 1e9 + 7) {
	inv.resize(N + 1);
	sinv.resize(N + 1);
	inv[1] = 1;
	sinv[0] = 1;
	sinv[1] = 1;
	for (int n = 2; n <= N; n++) {
		inv[n] = mod - (inv[mod % n] * (mod / n)) % mod;
		sinv[n] = (sinv[n - 1] * inv[n]) % mod;
	}
}

//(n^(-1),(n!)^(-1))
pll modinvs(ll N, ll mod = 1e9 + 7) {
	vector<ll> inv(N + 1);
	inv[1] = 1;
	ll sinv = 1;
	for (int n = 2; n <= N; n++) {
		inv[n] = mod - (inv[mod % n] * (mod / n)) % mod;
		sinv = (sinv * inv[n]) % mod;
	}
	return pll(inv[N], sinv);
}

long long Comb(long long n, long long k, vector<long long>& st, vector<long long>& sinv, long long mod = 1e9 + 7) {
	long long ans = st[n];
	ans = (ans * sinv[n - k]) % mod;
	ans = (ans * sinv[k]) % mod;
	return ans;
}

//ax+by=gcd(a,b)の解
ll extgcd(ll a, ll b, ll& x, ll& y) {
	ll d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1; y = 0;
	}
	return d;
}

VLL st, inv, sinv;
ll N, A, B, K;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cin >> N >> A >> B >> K;
	stairs(N, st, 998244353);
	modinvs(N, inv, sinv, 998244353);
	ll ans = 0;
	for (ll a0 = 0; a0 <= N; a0++) {
		ll left = K - a0 * A;
		if (left % B != 0)continue;
		ll b0 = left / B;
		if (b0 < 0 || b0 > N)continue;
		ll temp = Comb(N, a0, st, sinv, MOD);
		temp = (temp * Comb(N, b0, st, sinv, MOD))%MOD;
		ans = (ans + temp) % MOD;
	}
	cout << ans << "\n";
	return 0;
}

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

int main(){

    int N,K;
    cin >> N >> K;
    std::vector<int> H(N);

    for(int i = 0; i < N ; i++){
        int H_i;
        cin >> H_i;
        H[i] = H_i;
    }

    std::sort(H.begin(),H.end());
    std::vector<int> DIS(N-1);

    for(int j = 0; j < N - 1 ; j++){
        int distant;
        distant = H[j+1] - H[j];
        DIS[j] = distant;
    }
    int dif,dif_max;
    dif_max = 1000000000;
    for(int i = 0; i < N - K + 1; i++){
        dif = 0;
        for(int l = 0 ; l < K - 1 ; l++){
            dif = dif + DIS[l+i];
        }
        if(dif <= dif_max){
            dif_max = dif;
        }
    }

    cout << dif_max << endl;
    return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using ll = long long;
using namespace std;

const long long MOD = 1000000007;
const ll LINF = 1LL << 50;

int main() {
  int H, W;
  cin >> H >> W;

  vector<vector<int>> d(10,vector<int>(10,0));
  REP(i,10){
    REP(j,10){
      cin >> d[i][j];
    }
  }

  vector<int> count(10,0);
  REP(h,H){
    REP(w,W){
      int tmp;
      cin >> tmp;
      if (tmp < 0) continue;
      count[tmp] +=1;
    }
  }

  // warshall_floyd
  for (int k = 0; k < 10; k++){
    for (int i = 0; i < 10; i++){
      for (int j = 0; j < 10; j++){
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }

  int ans = 0;
  REP(i,10){
    ans += d[i][1]*count[i];
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int Maxn = 100000;
int a[10],n;
int main()
{
    scanf("%d",&n);
    a[1] = n/1000;
    a[2] = n/100%10;
    a[3] = n/10%10;
    a[4] = n%10;
    if(a[1] + a[2] + a[3] + a[4] == 7)
        printf("%d+%d+%d+%d=7\n",a[1],a[2],a[3],a[4]);
    else
        if(a[1] + a[2] + a[3] - a[4] == 7)
            printf("%d+%d+%d-%d=7\n",a[1],a[2],a[3],a[4]);
    else
        if(a[1] + a[2] - a[3] + a[4] == 7)
            printf("%d+%d-%d+%d=7\n",a[1],a[2],a[3],a[4]);
    else
        if(a[1] - a[2] + a[3] + a[4] == 7)
            printf("%d-%d+%d+%d=7\n",a[1],a[2],a[3],a[4]);
    else
        if(a[1] + a[2] - a[3] - a[4] == 7)
            printf("%d+%d-%d-%d=7\n",a[1],a[2],a[3],a[4]);
    else
        if(a[1] - a[2] + a[3] - a[4] == 7)
            printf("%d-%d+%d-%d=7\n",a[1],a[2],a[3],a[4]);
    else
        if(a[1] - a[2] - a[3] + a[4] == 7)
            printf("%d-%d-%d+%d=7\n",a[1],a[2],a[3],a[4]);
    else
        if(a[1] - a[2] - a[3] - a[4] == 7)
            printf("%d-%d-%d-%d=7\n",a[1],a[2],a[3],a[4]);

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
///#include<bits/stdc++.h>
#include <iterator>
#include<algorithm>
#include<vector>
#include<complex>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<math.h>
#include<map>
#include<stack>
#include<sstream>
#include<queue>
#include<list>
#include<iomanip>
#include<bitset>
#include<limits.h>
#include <iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<algorithm>
#include<set>
#include<math.h>
#include<map>
#include<stack>
#include<sstream>
#include<queue>
#include<list>
#include<iomanip>
#include<bitset>
#include<limits.h>
#include<map>
#include<sstream>
using namespace std;



/// Info.
///****************************************************************************************************************************************///
/// Coder               : BAHAA El_DEEN OSAMA SAYED.
/// Problem name        : B - Cats and Dogs
/// Method              : IM
/// Date                : 2/3/2020
///****************************************************************************************************************************************///


#define rep0(i,x)         for(int i=0; i<x ;++i)
#define all(v)           ((v.begin()),((v.end())
#define mm(v,d)          memset(v,d,sizeof(v))
#define lp(i,v)          for(int i=0;i<sizeof(v);++i)
#define lpi(i,j,n)       for(int i=(j);i>=(int)n;++i)
#define lpd(i,j,n)       for(int i=(j);i>=(int)n;--i)
#define MP               make_pair
#define SZ(v)            ((int) ( (v).size() ) )
#define ull              unsigned long long
#define ll               long long
#define pi               3.1415926536
#define oo               1e9
#define OO               1e18
#define Fx(n)            fixed<<setprecision(n)
#define FasterIO           std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define RE0              return 0
#define RE1              return 1
#define mp(a,b)          make_pair(a,b)
#define X                first
#define Y                second
#define pii              pair(int a, int b)
#define rep1(i,x)        for(int i=1;i<=x;++i)
#define rep2(i,x)        for(int i=2;i<x;++i)
#define RE               return
//#define LD               long double
#define all(v) ((v).begin()),((v).end())


const  int  N   = (int) 1e5+100;
const  int  M   = (int) 1e4+4;
const  int  INF = (int) 0x3f3f3f3f;
///const double ESP = 1e-7;
///const ll MOD=1e8+9;


int A=0,B=0,X=0;
void GalhO0O0O0O0O0M()
{
cin >> A >> B >> X;
(X-A>=0 && X-A<=B) ? cout << "YES" : cout << "NO" ;
}




int main()
{
FasterIO;
GalhO0O0O0O0O0M();
RE0;}


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

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

    int N;
    cin >> N;
    int ans = 0;
    while (N--) {
        ll a;
        cin >> a;
        int res = 0;
        while (a % 2 == 0) {
            a /= 2;
            res++;
        }
        ans += res;
    }
    cout << ans << endl;

    return 0;
}

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

long long int N, x;
long long int a[100000];

int main(int argc, char const* argv[])
{
    cin >> N >> x;
    for (long long int i = 0; i < N; i++) {
        cin >> a[i];
    }

    long long int res = 0;

    for (long long int i = 0; i < N; i++) {
        if (i == 0) {
            if (a[i] > x) {
                res += a[i] - x;
                a[i] -= a[i] - x;
            }
        } else {
            if (a[i] + a[i-1] > x) {
                res += a[i] + a[i-1] - x;
                a[i] -= a[i] + a[i-1] - x;
            }
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1024
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int n; cin >> n;
	string s; cin >> s;
	int k; cin >> k;

	char t = s[k - 1];

	for (int i = 0; i < n; i++) {
		if (s[i] == t) {
			cout << t;
		}
		else {
			cout << '*';
		}
	}

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int a[100010],n;
long long ans;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
    {
        if(!a[i])continue;
        ans+=a[i]/2,a[i]%=2;
        if(a[i]&&a[i+1])a[i]-=1,a[i+1]-=1,ans++;
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <tuple>
#include <array>
#include <iomanip>

using namespace std;

pair<int, int> getStart(const vector<string> &table) {
	for(int i = 0; i < table.size(); i++){
		for(int j = 0; j < table[i].length(); j++) {
			if(table[i][j] == 'S') {
				return make_pair(i, j);
			}
		}
	}
	return make_pair(-1, -1);
}

int dist(int sy, int sx, int H, int W) {
	int ans = 10000;
	ans = min(ans, sx);
	ans = min(ans, W - 1 - sx);
	ans = min(ans, sy);
	ans = min(ans, H - 1 - sy);
	return ans;
}

array<array<bool, 801>, 801> visited;

tuple<int, int, int> bfs(const vector<string> &table, const int sy, const int sx, const int K) {
	const int W = table[0].length();
	const int H = table.size();
	int bestY = sy;
	int bestX = sx;
	int bestDist = dist(sy, sx, H, W);
	
	vector<int> dy = {0, 1, 0, -1};
	vector<int> dx = {1, 0, -1, 0};

    queue<tuple<int, int, int>> vs;
	vs.push(make_tuple(0, sy, sx));
	visited[sy][sx] = true;
	
	while(!vs.empty()) {
		int y, x, turn;
		tie(turn, y, x) = vs.front();
		vs.pop();
		int d = dist(y, x, H, W);
		if(d < bestDist) {
			bestDist = d;
			bestY = y;
			bestX = x;
		}

		for(int i = 0; i < 4; i++) {
			int ny = y + dy[i];
			int nx = x + dx[i];
			if(turn < K &&
			   0 <= ny && ny < H &&
			   0 <= nx && nx < W &&
			   table[ny][nx] != '#' &&
			   !visited[ny][nx]) {
			   	
			   	visited[ny][nx] = true;
			    vs.push(make_tuple(turn + 1, ny, nx));
			}
		}
	}
	return make_tuple(bestDist, bestY, bestX);
}

int main() {
	
	cin.tie(0);
    ios::sync_with_stdio(false);
	
	for(int i = 0; i <= 800; i++) {
		for(int j = 0; j <= 800; j++) {
			visited[i][j] = false;
		}
	}
	
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> table(h);
	getline(cin, table[0]);
	for(int i = 0; i < h; i++) {
		getline(cin, table[i]);
	}
	int sy, sx;
	tie(sy, sx) = getStart(table);
	
	int turn, bestY, bestX;
	tie(turn, bestY, bestX) = bfs(table, sy, sx, k);
	cout << ((turn + k - 1) / k + 1) << endl;
	
	return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 17;
const ll MOD = 998244353;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

ll in[100050][2];
ll sum[100050];

ll mx1[100050];
ll mx2[100050];
int main() {
	ll N, C, i, j;
	scanf("%lld %lld", &N, &C);
	for (i = 1; i <= N; i++) scanf("%lld %lld", &in[i][0], &in[i][1]);
	for (i = 1; i <= N; i++) sum[i] = sum[i - 1] + in[i][1];

	ll ans = 0;
	ans = max(ans, sum[N] - C);

	for (i = 1; i <= N; i++) mx1[i] = max(mx1[i - 1], sum[i] - 2 * in[i][0]);
	for (i = N; i >= 1; i--) mx2[i] = max(mx2[i + 1], (sum[N] - sum[i - 1]) - (C - in[i][0]));
	for (i = 0; i <= N; i++) ans = max(ans, mx1[i] + mx2[i + 1]);

	for (i = 1; i <= N; i++) mx1[i] = max(mx1[i - 1], sum[i] - in[i][0]);
	for (i = N; i >= 1; i--) mx2[i] = max(mx2[i + 1], (sum[N] - sum[i - 1]) - 2 * (C - in[i][0]));
	for (i = 0; i <= N; i++) ans = max(ans, mx1[i] + mx2[i + 1]);
	return !printf("%lld\n", ans);
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define MAXNUM 111111
#define rep(i,s,t) for(int i=s;i<t;i++)
#define pii pair<int,int>
typedef long long ll;
pii num[MAXNUM];
int dset[MAXNUM*2],allx[MAXNUM],ally[MAXNUM],xsize,ysize;
int ssizex[MAXNUM*2],ssizey[MAXNUM*2];
int fa(int a)
{
    if(dset[a]!=a)return dset[a]=fa(dset[a]);
    return a;
}
int main()
{
    int n,a,b;scanf("%d",&n);
    rep(i,1,n+1)scanf("%d%d",&a,&b),num[i]={a,b},allx[++xsize]=a,ally[++ysize]=b;
    sort(allx+1,allx+xsize+1),sort(ally+1,ally+ysize+1);
    xsize=unique(allx+1,allx+xsize+1)-allx-1,ysize=unique(ally+1,ally+ysize+1)-ally-1;
    rep(i,1,xsize+ysize+1)dset[i]=i;
    rep(i,1,n+1)
    {
        int k1=lower_bound(allx+1,allx+xsize+1,num[i].first)-allx,k2=lower_bound(ally+1,ally+ysize+1,num[i].second)-ally;
        dset[fa(k1)]=fa(k2+xsize);
    }
    rep(i,1,xsize+1)ssizex[fa(i)]++;
    rep(i,1,ysize+1)ssizey[fa(i+xsize)]++;
    ll res=0;
    rep(i,1,xsize+ysize+1)if(fa(i)==i)res+=ssizex[i]*1ll*ssizey[i];
    printf("%lld\n",res-n);
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define null NULL
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) ((int)(a).size())
#define all(a) a.begin() , a.end()
#define fi first
#define se second
#define relaxMin(a , b) (a) = min((a),(b))
#define relaxMax(a , b) (a) = max((a),(b))
#define SQR(a) ((a)*(a))
#define PI 3.14159265358979323846
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

// Modular operations
const int MOD = 1E9 + 7;

int Add(int a, int b, int m = MOD){
  a += b;
  if(a >= m) a -= m;
  return a;
}

int Sub(int a, int b, int m = MOD){
  a -= b;
  if(a < 0) a += m;
  return a;
}

int AddTo(int& to, int w, int m = MOD){
  to += w;
  if(to >= m) to -= m;
  return to;
}

int SubTo(int& to, int w, int m = MOD){
  to -= w;
  if(to < 0) to += m;
  return to;
}

int Mult(int a, int b, int m = MOD){
  return (a * 1LL * b) % m;
}

// Solution
const int MAX = 3010;
int n, m;

int dp[MAX][MAX][2];

int Eval(int how, int a, int spec){
  if(dp[how][a][spec] >= 0) return dp[how][a][spec];

  int b = n - a;
  int& val = dp[how][a][spec];
  if(how == 0 && !spec) return val = 0;
  if(how == 0 && spec) return val = 1;
  val = 0;

  // AA
  if(a == 1) AddTo(val, Eval(how - 1, a - 1, 1));
  if(a > 1) AddTo(val, Eval(how - 1, a - 1, spec));

  // AB
  if(a == 1) AddTo(val, Eval(how - 1, a, 1));
  if(a > 1) AddTo(val, Eval(how - 1, a, spec));

  // BA
  if(b > 0 && a == 0) AddTo(val, Eval(how - 1, a, 1));
  if(b > 0 && a > 0) AddTo(val, Eval(how - 1, a, spec));

  // BB
  if(b > 0 && a == 0) AddTo(val, Eval(how - 1, a + 1, 1));
  if(b > 0 && a > 0) AddTo(val, Eval(how - 1, a + 1, spec));

  return val;
}

int main(){
  memset(dp, -1, sizeof dp);

  scanf("%d%d", &n, &m);

  int ans = 0;
  for(int i = 0;i <= n;++i)
    AddTo(ans, Eval(m, i, 0));

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 71296
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n;
    int[] r;
    int min, max, tmp, i;

    n = sc.nextInt();
    r = new int[n];
    for(i = 0;i < n;i++){
      r[i] = sc.nextInt();
    }

    min = r[0];
    max = r[1];
    tmp = r[0];
    if(r[1] < r[0])tmp = r[1];
    for(i = 2;i < n;i++){
      if(r[i] - tmp > max - min){
        max = r[i];
        min = tmp;
      }
      if(r[i] < tmp){
        tmp = r[i];
      }
    }

    System.out.println(max - min);

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 97144
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	
	int n;
	cin >> n;
	string s;
	cin >> s;
	int cnt = 1;
	for (int i = 1; i < n; ++i) {
		if (s[i] != s[i - 1]) {
			++cnt;
		}
	}
	cout << cnt << '\n';
 	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
  
int main(int argc, char *argv[]) {
    int a, b;
    int cnt = 0;

    scanf("%d%d", &a, &b);
    cnt = (a - 1) + ((a <= b) ? 1 : 0);
    printf("%d\n", cnt);

    return 0;
}

Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        KnapsackAizu1 solver = new KnapsackAizu1();
        solver.solve(1, in, out);
        out.close();
    }

    static class KnapsackAizu1 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int w = in.nextInt();
            int[] vs = new int[n];
            int[] ws = new int[n];

            for (int i = 0; i < n; i++) {
                vs[i] = in.nextInt();
                ws[i] = in.nextInt();
            }

            int[] dp = new int[w + 1];
            for (int i = 1; i < w + 1; i++) {
                for (int j = 0; j < n; j++) {
                    if (i >= ws[j]) {
                        dp[i] = Math.max(dp[i], vs[j] + dp[i - ws[j]]);
                    }
                }
            }

            out.printf("%d\n", dp[w]);
        }

    }
}




Measured memory_bytes: 27300
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int temp = -1;
		if(a % 3 == 0 || b % 3 == 0) {
			temp = 0;
		}
		if((a + b) % 3 == 0) {
			temp = 0;
		}
		
		if(temp == 0) {
			System.out.println("Possible");
		}
		else {
			System.out.println("Impossible");
		}
	}

}


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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
int main()
{
	int n,m;
	cin>>n>>m;
	vector<bool>v(n+1,true);
	for(int i=0;i<m;i++)
	{
		int p;
		cin>>p;
		v[p]=false;
	}
	ll int dp[n+1]={0};
	dp[0]=1;
	for(int now=0;now<n;now++)
	{
	//cout<<dp[now]<<" now ";
	for(int next=now+1;next<now+3 && next<=n;next++)
	{
		if(v[next]==true)
		{
		dp[next]+=dp[now];
		dp[next]=dp[next]%mod;
		//cout<<dp[next]<<" next ";
	    }
	    //cout<<endl;
	}
    }
	cout<<dp[n];
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <set>
#include <string>
#include <cmath>
#include <vector>
#include <map>
using namespace std;

int main()
{

	string s;
	cin >> s;
	int ret = 0;
	for (int i = 0; i < s.length(); i++)
		if (s[i] == '2')ret++;
	cout << ret;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
    #define lb lower_bound 
    #define ub upper_bound
    #define pii pair<pair<int,int>,pair<int,int> >
	#define se second
	#define endl "\n"
	#define pi pair<int, int>
	#define vi vector<int> 
	#define vvi vector<vi>
    #define bs   binary_search
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)	
    #define all(c) (c).begin(),(c).end()
    #define sz(x)       (int)x.size() 
	#define PI 3.14159265358979323846
    
	 const int N =1e5+5;
    
     int mod= 1e9+7,INF=1e17;
     
     int dx[4]={0,0,+1,-1};
     int dy[4]={+1,-1,0,0};
     
     
     vi v[N];
     int n,k,ans;
    
    void dfs(int x,int p){
		int val=k-1;
		if(p!=-1)
		  val--;
		  
		 for(auto to:v[x]){
			 
			 if(to==p)
				 continue;
				 
			 if(val<=0){
				 ans=0;
				 return;
			 }
			 
			 ans=(ans*val)%mod;
			 val--;
			 dfs(to,x);		 
		 }
	} 
     
     
     void solve(){
		 
		 
        cin>>n>>k;
        
        rep(i,1,n){
			int x,y;
			cin>>x>>y;
			v[x].pb(y);
			v[y].pb(x);
		}
		
	ans=k;
	
	dfs(1,-1);
	
		cout<<ans<<endl;
       
	 }
	
      int32_t main() {
	    cool;
	    int t=1;
        //cin>>t;
	    while(t--)
	       solve();
	       
	       
	       return 0;	   
	   }


Measured memory_bytes: 9216
# coding: utf-8
# Your code here!

while True:
   n, m = map(int, input().split())   # 品物の個数、許容額
   if n + m == 0: break

   price = list(map(int, input().split()))
   #print(price)
   
   sum = 0
   max = 0
   c = 0
   for i in range(n):
      for j in range(i + 1, n):
         sum = price[i] + price[j]
         if sum <= m and sum > max:
            max = sum
            
   if max == 0:
      print("NONE")
   else:
      print(max)



Measured memory_bytes: 5632
from collections import deque
import heapq

n, m = map(int, input().split(' '))
works = [[] for _ in range(100001)]

for i in range(n):
    a, b = map(int, input().split(' '))
    works[a].append(b)

ans = 0
h = []
for day in range(1, m + 1):
    for gain in works[day]:
        heapq.heappush(h, -gain)


    if h:
        gain = -heapq.heappop(h)
        ans += gain


print(ans)
    


Measured memory_bytes: 72480
m = 100000000000000000000000000000000000000000000000000000000000000000000000000000000
n = int(input())
for i in range(n):
    a = int(input())
    b = int(input())
    sum = a + b
    if sum > m or sum == m:
        print("overflow")
    else:
        print(sum)


Measured memory_bytes: 5592
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fi first
#define sec second 
#define MOD 1000000007
#define pb push_back
#define test cout<<"debuged\n";
#define INF 10000000000
#define si 1000000
#define debug(x) cout<<x<<"\n";

 vector<ll> v,w;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  
    ll n,we;
    cin>>n>>we;
    ll x;
    for(ll i=1;i<=n;i++)
      {
      cin>>x;
      w.pb(x);
      cin>>x;
      v.pb(x);
      }
   // cout<<solve(we,0,n);
      ll dp[n+1][we+1];
      for(ll i=0;i<=n;i++)
      {
        for(ll j=0;j<=we;j++)
          dp[i][j]=0;
      }
      for(ll i=1;i<=n;i++)
      {
        for(ll j=1;j<=we;j++)
          {
            if(j-w[i-1]>=0)
            {
              dp[i][j]=max(dp[i-1][j],v[i-1]+dp[i-1][j-w[i-1]]);
            }
            else
              dp[i][j]=dp[i-1][j];
          }
      }
     cout<<dp[n][we];
   
}

Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < (n);i++)
#define lint long long
const lint mod=1e9+7;
const lint inf=2.19e15+1;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
struct Edge {
    long long to;
};
using Graph = vector<vector<Edge>>;



signed main(){
    string s;
    cin >> s;
    if (s[(int)s.size()-1]=='s'){
        cout << s << "es" << endl;
    }
    else{
        cout << s << "s" << endl;
    }
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
  
int main() {
    ll n;
    cin >> n;

    vl x(n), y(n), h(n);
    rep(i, n) {
        cin >> x[i] >> y[i] >> h[i];
    }

    exrep(cx, 0, 100) {
        exrep(cy, 0, 100) {
            ll H;
            rep(i, n) {
                if(h[i] > 0) {
                    H  = abs(x[i] - cx) + abs(y[i] - cy) + h[i];
                    break;
                }
            }
            bool ok = true;
            rep(i, n) {
                if(h[i] != max(0LL, H - abs(x[i] - cx) - abs(y[i] - cy))) {
                    ok = false;
                }
            }
            if(ok) {
                cout << cx << " " << cy << " " << H << endl;
                re0;
            }
        }
    }

    re0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u32 = read();
    let b: u32 = read();
    let ans = if (a * b) % 2 == 0 { "Even" } else { "Odd" };
    println!("{}", ans);
}


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

using namespace std; // ???????????¨???
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define pb push_back 
					 // make_pair ??????????????§
class disjoint_set {
	vector<int> p;
public:
	disjoint_set(int n) : p(n, -1) {}
	int root(int i) { return p[i] >= 0 ? p[i] = root(p[i]) : i; }
	bool same(int i, int j) { return root(i) == root(j); }
	int size(int i) { return -p[root(i)]; }
	void merge(int i, int j) {
		i = root(i), j = root(j);
		if (i == j) return;
		if (p[i] > p[j]) swap(i, j);
		p[i] += p[j]; p[j] = i;
	}
};

int N, Q;
int main() {
	cin >> N >> Q;
	disjoint_set U(N);

	int com, x, y;
	rep(i, Q)
	{
		cin >> com >> x >> y;
		if (com)
		{
			cout << U.same(x, y) << endl;
		}
		else
		{
			U.merge(x, y);
		}
	}
	return 0;
}

Measured memory_bytes: 3140