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

#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }

using ld = long double;

const ld INF = 1e9;
const ld EPS = 1e-9;
const ld G = 1.0;

int main() {
    ld D;
    int N, B; cin >> D >> N >> B;    
    B += 1;
    vector<ld> P(N), H(N); rep(i, N) cin >> P[i] >> H[i];
    
    ld ans = INF * INF;
    repeat(b, 1, B + 1) {
        ld d = D / b;
        
        auto calc_vx = [&] (ld vy) {
            return d * G / 2.0 / vy;
        };
        auto calc_v = [&] (ld vy) {
            ld vx = calc_vx(vy);
            return sqrt(vx * vx + vy * vy);
        };
        auto calc_y = [&] (ld vy, ld x) {
            ld vx = calc_vx(vy);
            return -(G / 2.0 / vx / vx) * x * x + vy / vx * x;
        };
        auto can_reach = [&] (ld vy) {
            rep(i, N) {
                int idx = P[i] / d;
                ld sx = d * idx;
                if(calc_y(vy, P[i] - sx) < H[i]) return false;
            }
            return true;
        };

        {
            ld vv = sqrt(d * G / 2.0);
            if(can_reach(vv)) ans = calc_v(vv);
        }
        rep(i, N) {
            int idx = P[i] / d;
            ld sx = d * idx;
            ld x = P[i] - sx;
            ld y = H[i];
            ld l = 0,  r = INF;
            while(r - l > EPS) {
                ld vy = (l + r) / 2.0;
                (calc_y(vy, x) >= y ? r : l) = vy;
            }
            if(can_reach(r)) {
                set_min(ans, calc_v(r));
            }
        }
    }
    printf("%.16f\n", (double)ans);
    return 0;
}

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

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define sz(x)             (int)x.size()
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        (a*(b/gcd(a,b)))
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#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 all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
#define watch(x)         cout << #x << " = " << x << endl
#define trace(x)         cerr << #x << " = " << x << endl
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void angshuGod()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){
    
	int k; cin>>k;
	int x = 7%k;
	for(int i = 0;i<3*k;i++){
		if(!x){
			cout<<i+1;
			return;
		}
		x = (x*10 + 7)%k;
	}
	cout<<"-1\n";
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

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

int main() {
  int num;
  cin >> num;
  string wword[num];

  for (int k = 0; k < num; k++) {
    cin >> wword[k];
  }

  for (int k = 0; k < num; k++) {
    for (int l = k+1; l < num; l++) {
      if (wword[k] == wword[l]) {
        cout << "No" << endl;
        return 0;
      } 
    }
  }
  for (int k = 0; k < num-1; k++) {
    if (wword[k].back() != wword[k+1].front()) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;
ll MOD = 1000000007;

int main()
{
    ll N;
    cin >> N;
    ll T, A;
    cin >> T >> A;
    ll countT = T;
    ll countA = A;
    for(ll i = 1; i < N; i++) {
        cin >> T >> A;
        ll tmpT = countT/T;
        ll tmpA = countA/A;
        if (countT%T!=0) tmpT++;
        if (countA%A!=0) tmpA++;
        ll n = max(tmpT, tmpA);
        countT = n * T;
        countA = n * A;
    }
    cout << countA + countT << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<map>
#include<numeric>
//#include <bits/stdc++.h>
#include<cstring>
#include<iostream>
#include<functional>
using namespace std;
int main() {

	int A, B, C;
	cin >> A >> B >> C;
	cout << min({ A + B, B + C, C + A }) << endl;

	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
   int i,n,a,max=-1000000,min=1000000;
   long long int sum=0;
    
   scanf("%d",&n);
   for(i=1;i<=n;i++){
       scanf("%d",&a);
       if(a>max) max=a;
       if(a<min) min=a;
       sum=sum+a;
   }
    
   printf("%d %d %lld\n",min,max,sum);
    
   return 0;
}


Measured memory_bytes: 2104
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

#define rep(i, n) for(long int i = 0; i < n; i++)
#define P pair<int, int>
#define ll long long
typedef vector<int> vec;
typedef vector<vec> mat;

int main(){
    string t;
    cin >> t;
    rep(i, t.size()){
        if(t[i] == '?') t[i] = 'D'; 
    }
    cout << t << endl;
}


Measured memory_bytes: 3752
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return 1;}return 0;}

const long long INF = 1LL << 60;
int n;
long long h[100010];
long long dp[100010];
int main(){
    cin >> n;
    for(int i = 0; i < n; i++) cin >> h[i];
    for(int i = 0; i < 100010; i++) dp[i] = INF;
    dp[0] = 0;
    chmin(dp[1], dp[0] + abs(h[1]-h[0]));
    for(int i = 2; i <= n; i++){
        chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }
    //for(int i = 0; i < n; i++)
    cout << dp[n-1] << endl;
}

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

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (b < a) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int x, y; cin >> x >> y;
  int group[] = { 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1 };

  cout << (group[x-1] == group[y-1] ? "Yes\n" : "No\n");
  
  return (0);
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin>>N;
    int sum=0;
    int A[N];
    bitset<4000001> bit;
    bit[0]=1;
    rep(i,0,N){
        cin>>A[i];
        sum+=A[i];
        bit|=bit<<A[i];
    }
    sum=(sum+1)/2;
    rep(i,sum,4000001){
        if(bit[i]){
            cout <<i<<"\n";
            return 0;
        }
    }
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

typedef long long ll;

ll n,k;
ll ans=0;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	
	cin >> n >> k;
	
	for(int b=k+1;b<=n;b++){
		ll q=n/b;
		
		ans+=q*(b-k);
		
		if(n%b>=k){
			ans+=(n%b-k+1);
		}
	}
	
	if(k==0) ans-=n;
	
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a,b,i,H,W;
	for (i=0;i<=1;){
		scanf ("%d %d",&H,&W);
		if (H+W==0){
		break;
		}
		for (a=1;a<=H;a++){
			for (b=1;b<=W;b++){
				if ((a+b)%2==0){
					printf ("#");
				}
				else if ((a+b)%2==1){
					printf (".");
				}
			}
			printf ("\n");
		}
		printf ("\n");
	}
	return 0;
}

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

const int N = 100010;

char s[N];

int main(){
	scanf("%s", s);
	int now = strlen(s);
	while (now > 0){
		if (now < 5)
			return printf("NO\n"), 0;
		if (s[now - 1] == 'm' && s[now - 2] == 'a' && s[now - 3] == 'e' && s[now - 4] == 'r' && s[now - 5] == 'd'){
			now -= 5;
			continue;
		}
		if (s[now - 1] == 'e' && s[now - 2] == 's' && s[now - 3] == 'a' && s[now - 4] == 'r' && s[now - 5] == 'e'){
			now -= 5;
			continue;
		}
		if (now < 6)
			return printf("NO\n"), 0;
		if (s[now - 1] == 'r' && s[now - 2] == 'e' && s[now - 3] == 's' && s[now - 4] == 'a' && s[now - 5] == 'r' && s[now - 6] == 'e'){
			now -= 6;
			continue;
		}
		if (now < 7)
			return printf("NO\n"), 0;
		if (s[now - 1] == 'r' && s[now - 2] == 'e' && s[now - 3] == 'm' && s[now - 4] == 'a' && s[now - 5] == 'e' && s[now - 6] == 'r' && s[now - 7] == 'd'){
			now -= 7;
			continue;
		}
		return printf("NO\n"), 0;
	}
	return printf("YES\n"), 0;
}

Measured memory_bytes: 384
s = input()
t = input()
sl = len(s)
tl = len(t)
ans = 10**8
for i in range(sl-tl+1):
  tmp = s[i:i+tl]
  pen = 0
  for j,k in enumerate(tmp):
    if t[j]!=k: pen += 1
  ans = min(ans,pen)
print(ans)

Measured memory_bytes: 67504
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

int main() {
	string S;
	cin >> S;
	rep(i, 3) {
		cout << S[i];
	}
	cout << endl;
}

Measured memory_bytes: 3580
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
 
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int d[20][20];
int main(){
    int h,w;
    char c;
    bool fld[20][20];
    cin>>h>>w;
    REP(i,h)REP(j,w)
    {
        cin>>c;
        if(c=='.')
        {
            fld[i][j]=true;
        }else
        {
            fld[i][j]=false;
        }
    }
    int ans=0;
    REP(i,h)REP(j,w)
    {
        if(!fld[i][j])continue;
        // cout<<i<<" "<<j<<endl;
        REP(y,h)REP(x,w)d[y][x]=1e9;
        d[i][j]=0;
        queue<pair<int, int> >q;
        q.push(MP(i,j));
        while(q.size())
        {
            pair<int,int> p=q.front();q.pop();
            int ny=p.first,nx=p.second;
            REP(k,4)
            {
                int nny=ny+dy[k];
                int nnx=nx+dx[k];
                if(nnx>=0&&nnx<w&&nny>=0&&nny<h)
                {
                    if(fld[nny][nnx]){
                        if(d[nny][nnx]>d[ny][nx]+1)
                        {
                            q.push(MP(nny,nnx));
                            d[nny][nnx]=d[ny][nx]+1;
                        }
                    }
                }
            }
        }
        // REP(y,h){
        //     REP(x,w)cout<<d[y][x]<<" ";cout<<endl;
        // }
        // cout<<endl;
        REP(y,h)REP(x,w)if(d[y][x]!=1e9)ans=max(ans,d[y][x]);
    }
    cout<<ans<<endl;
}

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

using namespace std;
typedef long long ll;

int main(){
    string s;
    ll k;
    cin >> s >> k;
    for(ll i = 0; i < k; ++i){
        if(s.at(i) != '1'){
            cout << (s.at(i) - '0') << endl;
            return 0;
        }
    }
    cout << 1 << endl;
    return 0;
}


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

int main(){
    int N,M;
    cin>>N>>M;
    vector<int> A(N);

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

    int sum=0;

    for(int i=0;i<N;i++){
        sum += A[i];
    }

    int count=0;

    for(int i=0;i<N;i++){
        if(A[i]*(4*M) >= sum){
            count++;
        }
    }

    if(count>=M) cout << "Yes" <<endl;
    else cout << "No" <<endl;
} 


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

#define ull unsigned long long
#define endl '\n'
#define ll long long
const int N = 2e5 + 5;
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        //freopen("VLJUM.INP", "r", stdin);
        //freopen("VLJUM.OUT", "w", stdout);
        string s;
        cin >> s;
        if (s[0] == '7' || s[1] == '7' || s[2] == '7') cout << "Yes";
        else cout << "No";
}


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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}

int n, m, s[2001], t[2001];
long long memo[2001][2001];

long long helper(int pa, int pb){

    if(pa == n || pb == m)
        return 0;

    if(memo[pa][pb] != -1)
        return memo[pa][pb];

    long long tot = ((helper(pa + 1, pb) + helper(pa, pb + 1)) % MOD - helper(pa + 1, pb + 1) + MOD) % MOD;

    if(s[pa] == t[pb])
        tot += 1 + helper(pa + 1, pb + 1);

    return memo[pa][pb] = tot % MOD;

}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    cin >> n >> m;

    for(int i = 0; i < n; ++i)
        cin >> s[i];
    for(int i = 0; i < m; ++i)
        cin >> t[i];

    for(int i = 0; i < n; ++i)
        for(int j = 0; j < m; ++j)
            memo[i][j] = -1;

    cout << (helper(0, 0) + 1) % MOD;

    return 0;
}


Measured memory_bytes: 31744
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <bitset>
#include <map>
#include <vector>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

const int MAX = 404;
const int MAXM = 100100;

int must[MAX][MAX];
bool good[MAX];
int x[MAXM], y[MAXM];

map<pair<int, int>, int> D;

bitset<MAX> cant[MAX];

int main(void) {
  int N, M;
  scanf("%d %d", &N, &M);
  
  vector<pair<int, int>> v(M);
  REP(i, M) {
    scanf("%d %d", &x[i], &y[i]);
    --x[i], --y[i];

    if (!D.count({x[i], y[i]})) {
      D[{x[i], y[i]}] = i;
      D[{y[i], x[i]}] = i;
    }
  }


  REP(i, N) {
    REP(j, N) must[i][j] = -1;
    must[i][i] = M;
    good[i] = true;
    for (int j = M-1; j >= 0; --j) {
      if (must[i][x[j]] != -1 && must[i][y[j]] != -1) {
        good[i] = false;
        break;
      }
      if (must[i][x[j]] != -1) {
        must[i][y[j]] = j;
      } else if (must[i][y[j]] != -1) {
        must[i][x[j]] = j;
      }
    }
  }

  bitset<MAX> b;
  REP(x, N) REP(y, N) {
    if (x == y) continue;

    if (!D.count({x, y})) continue;

    int d = D[{x, y}];

    vector<int> a;
    b.reset();

    REP(i, N) if (good[i]) {
      if (must[i][x] > d) a.push_back(i);
      if (must[i][y] > d) b.set(i);
    }

    for (int i: a) {
      cant[i] |= b;
    }
  }

  int ret = 0;
  REP(j, N) REP(i, j) {
    if (good[i] && good[j]) {
      if (!cant[i][j] && !cant[j][i]) ret++;
    }
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

int main(){
  string s,p;cin >> s >> p;
  s = s+s;
  if(s.find(p)!=-1){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 3204
#include <stdio.h>
int main(){
 
  int a,b,i,d;
 
  while(1){
  scanf("%d %d",&a,&b);
if(a==0 && b==0)break;
 
  for(i=0;i<a;i++){

    for(d=0;d<b;d++)
{
    printf("#");
  } 
  printf("\n");
 
  
  }
  printf("\n");
  }
  
 
  return 0;
  }

Measured memory_bytes: 572
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
int gcd(int a,int b){
  if(b==0) return a;
  return gcd(b,a%b);
}
// 最小公倍数
int lcm(int a,int b){
  return a*b/gcd(a,b);
}

int main()
{
  int x; cin >> x;
  int lc = lcm(360, x);
  cout << lc / x << "\n";
  return 0;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <cstdio>
typedef long long LL;
const int N=100005;
LL a[N],cnt[N],ans[N];
void add(int i,LL x,LL y){
	if (x<=a[1]){
		ans[x]+=y;
		return;
	}
	cnt[i]+=x/a[i]*y;x%=a[i];
	add(std::lower_bound(a+1,a+i,x)-a-1,x,y);
}
int main(){
	int n,m,q;
	scanf("%d%d\n",&n,&q);
	a[m=1]=n;
	for (int i=1;i<=q;i++){
		long long x;
		scanf("%lld",&x);
		for (;m && x<=a[m];m--);
		a[++m]=x;
	}
	cnt[m]=1;
	for (int i=m;i>=1;i--) add(i-1,a[i],cnt[i]);
	for (int i=a[1];i;i--) ans[i]+=ans[i+1];
	for (int i=1;i<=n;i++) printf("%lld\n",ans[i]);
}

Measured memory_bytes: 3968
N = int(input())
N2 = 2**N
S = list(map(int, input().split()))
S.sort(reverse=True)

slimes = [S[0]]
S[0] = float('inf')
num = 1
for i in range(N):
  slimes.sort()
  n = num
  idx = 0
  while n and idx<=N2-1:
    if S[idx] < slimes[n-1]:
      slimes.append(S[idx])
      S[idx] = float('inf')
      idx += 1
      n -= 1
    else:
      idx += 1
  
  if n:
    print('No')
    quit()
  
  num *= 2

print('Yes')

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

int main()
{
	int n,l,r;
    cin >> n >> l >> r;
    
    if(l-r>=n)
    {
		cout << "OK" << endl;
    }
    else
    {
		int prev = l - l%n;
        int next = (l%n==0?l:prev + n);
        
        if(next <= r)
        {
			cout << "OK" <<endl;
        }
        else
        {
			cout << "NG" << endl;
        }
    }
	return 0;
}

Measured memory_bytes: 3620
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll A,B,C,X;
	while(cin>>A>>B>>C>>X) {
		ll ans=0;
		REP(a, A+1) REP(b, B+1) REP(c, C+1) if(500*a+100*b+50*c==X) ans++;
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
int n,m,i,j;
string s,t;
int main()
{
	cin>>n;
	cout<<48-n;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vivi;
typedef vector<ll> vll;
typedef vector<vll> vllvll;
typedef pair<int, int> Pi;
typedef queue<Pi> QPi;
typedef pair<ll, ll> Pll;
typedef queue<Pll> QPll;
using Graph = vector<vector<int>>;
const int mod = 1000000007;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 文字判定　isupper islower
// 順列　do {} while(next_permutation(ALL(X)));
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;

int main() {
  ll n,temp;
  ll ans=0;
  cin >> n;
  REP(i,n) {
    temp=i+1;
    if(temp%3==0) continue;
    if(temp%5==0) continue;
    ans+=temp;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int gcd(int x,int y){
    while(y){
        if(x<y)swap(x,y);
        int tmp=x;
        x=y;
        y=tmp%y;
    }
    return x;
}
int main(void){
    // Your code here!
    int n,k;
    cin>>n>>k;
    int a;
    cin>>a;
    int g=abs(a-k);
    for(int i=0;i<n-1;i++){
        cin>>a;
        g=gcd(g,abs(a-k));
    }
    cout<<g<<endl;
}


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

using namespace std;

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

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


int main(void){


    int n;
    cin >> n;

    if(n >= 30){
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }

    return 0;
}

Measured memory_bytes: 3604
use std::io::stdin;
use std::time::SystemTime;

fn main() {
    let ny: Vec<u64> = read().split(" ").map(|n| n.parse().unwrap()).collect();
    let mut count = 0;
    let mut _i = -1;
    let mut _j = -1;
    let mut _k = -1;
    
    for i in 0..ny[0]+1 {
        let fo = ny[0] - i;
        for j in 0..fo+1 {
            let k = fo - j;
            if i * 10000 + j * 5000 + k * 1000 == ny[1] {
                _i = i as i64;
                _j = j as i64;
                _k = k as i64;
                break;
            }
        }
    }
    println!("{} {} {}", _i, _j, _k);
}

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

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define INFTY 1<<20
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const int MOD=1000000007;

//最大公約数
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}

int a[100010];


int main(){
    int n;cin>>n;
    string s;cin>>s;
    int ce[n],cw[n];
    if(s[0]=='W'){
            cw[0] = 1;
            ce[0] = 0;
    }else{
        cw[0] = 0;
        ce[0] = 1;
    }
    for (int i = 1; i < n; i++)
    {
        if(s[i]=='W'){
            cw[i]=cw[i-1]+1;
            ce[i] = ce[i-1];
        }
        else{
            ce[i]=ce[i-1]+1;
            cw[i] = cw[i-1];
        }
    }
    int mn=ce[n-1]-ce[0];
    for (int i = 1; i < n; i++)
    {
        int num = cw[i-1]+ce[n-1]-ce[i];
        mn = min(mn,num);
    }
    cout<<mn<<endl;
return 0;
}

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

int main(){
  int a,b,N = 0;
  cin >> a >> b >> N;

  int s[N], f[N];
  for(int i=0; i<N; i++){
    cin >> s[i] >> f[i];
  }

  int Flag=0;
  for(int i=a; i<b; i++){
    for(int j=0; j<N; j++){
      if(s[j]<=i && i<f[j]){
        Flag=1;
        break;
      }
    }
  }

  if(Flag==1){
    cout << "1" << endl;
  }else{
    cout << "0" << endl;
  }
  return 0;
}



Measured memory_bytes: 3124
n=int(input())
a=[]
for i in range(n):
    a.append(int(input())-1)

ans=0
count=0
light=0
for i in range(n):
    count+=1
    light=a[light]
    if light==1:
        ans=count
        break
    
if ans==0:
    print(-1)
else:
    print(ans)
    

Measured memory_bytes: 7084
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define all(v) (v).begin(),(v).end()
#define endl "\n"
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a;i>b;i--)
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>
#define SET(A,VAL) memset(A, VAL, sizeof(A))
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
const int MAX = 1e6 + 8;
const int MOD = 1e9 + 7;
const int sz = 1e5 + 5;
void f_io(){
    IOS;
    // #ifndef ONLINE_JUDGE
    // FRE
    // #endif
}


int32_t main(){
    f_io();
    int tc = 1;
    //cin>>tc;
    while(tc--){
        int n; cin >> n;
        if(n % 1000) cout << 1000 - (n % 1000);
        else cout << "0" << endl;
    }
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

std::vector<int> getPrimes(ll K) {
    std::vector<int> div;
    for(ll i=2; i*i<=K; ++i) {
        if (K%i == 0) {
            div.push_back(i);
            while(K%i==0) { K /= i; }
        }
    }
    if(K!=1) div.push_back(K);
    return div;
}

int Euler(int n) {
    auto div = getPrimes(n); int m = div.size(); int res = 0;
    rep(bit, 1<<m) {
        int mul = 1;
        rep(i, m) if (bit&1<<i) mul *= div[i];
        res += n/mul * (__builtin_popcount(bit)%2==1? -1:1);
    }
    return res;
}

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

    int n; std::cin >> n;
    std::cout << Euler(n) << std::endl;
    
    return 0;
}


Measured memory_bytes: 3216
#include<cstdio>
#include<cstring>
char a[11];
int add[10],len;
long long ans=0;
void getsum1()
{
    long long temp=0;
    for (int i = 0; i < len; i++)
    {
        if(add[i])
        {
            ans+=temp;
            temp=0;
        }
        temp=temp*10+a[i]-'0';
    }
    ans+=temp;
}
void getsum2()
{
    long long temp = a[0]-'0';
    for (int i = 1; i < len; i++)
    {
        if (!add[i])
        {
            ans += temp;
            temp = 0;
        }
        temp = temp * 10 + a[i] - '0';
    }
    ans += temp;
}
void dfs(int pos,int num)
{
    if(!num)
    {
        getsum1();
        //getsum2();
        return;
    }
    for (int i = pos; i < len-num+1; i++)
    {
        add[i]=1;
        dfs(i+1,num-1);
        add[i]=0;
    }
}
int main()
{
    scanf("%s",a);
    len=strlen(a);
    for (int i = 0; i < len; i++)
    {
        dfs(1,i);
    }
    printf("%lld",ans);
}

Measured memory_bytes: 128
n=int(input())

memo = []

for i in range(1,1000000*3+1):
    if i == 1:
        memo.append(n)

    if memo[-1]%2 == 0:
        a = memo[-1]//2
    else:
        a = (memo[-1]*3)+1

    if a in memo:
        print(i+1)
        exit()
    else:
        memo.append(a)


Measured memory_bytes: 38384
n = int(input())
a = list(map(int, input().split()))
MAX = 10 ** 6 + 5
cnt = [0] * MAX
ok = [True] * MAX
for x in a:
    cnt[x] += 1
ans = 0
for i in range(1, MAX):
    if cnt[i] > 0:
        for j in range(i * 2, MAX, i):
            if cnt[j] > 0:
                ok[j] = False       
        if ok[i] and cnt[i] == 1:
            ans += 1
print(ans)

Measured memory_bytes: 34796
#include <stdio.h>

using namespace std;

int main(){
	int n,taro_point = 0,hanako_point = 0,j;
	char taro_card[101],hanako_card[101];
	scanf("%d",&n);
	for(int i = 0; i < n; i++){
		scanf("%s %s",taro_card,hanako_card);
		for(j = 0; taro_card[j] != '\0' && hanako_card[j] != '\0' && taro_card[j] == hanako_card[j];j++);
		if(taro_card[j] == '\0'){
			if(hanako_card[j] == '\0'){
				taro_point += 1;
				hanako_point += 1;
			}else{
				hanako_point += 3;
			}
		}else if(hanako_card[j] == '\0'){
			taro_point += 3;
		}else if(hanako_card[j] > taro_card[j]){
			hanako_point += 3;
		}else{
			taro_point += 3;
		}
	}
	printf("%d %d\n",taro_point,hanako_point);
}



Measured memory_bytes: 2756
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = 3.141592653589;
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}

signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    intl a,b;
    cin >> a >> b;
    bool f = false;
    repi(i,a,b + 1){
        if(!(i % n))f = true;
    }
    fp(f,"OK","NG");
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>

int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b){
        printf("a < b\n");
    }else if(a>b){
        printf("a > b\n");
    }else{
        printf("a == b\n");
    }
    return 0;
}

Measured memory_bytes: 580
h,w=[int(s)for s in input().split(" ")]
flag=[input()for i in range(h)]
mincnt=1145141919810
for i in range(1,h-1):
    for j in range(1,h-i):
        cnt=0
        wr=flag[:i]
        br=flag[i:i+j]
        rr=flag[i+j:]
        for l in wr:
            for c in l:
                if c!='W':cnt+=1
        for l in br:
            for c in l:
                if c!='B':cnt+=1
        for l in rr:
            for c in l:
                if c!='R':cnt+=1
        if cnt<mincnt:
            mincnt=cnt
print(mincnt)

Measured memory_bytes: 7784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
string ans[4]={"SW","SS","WW","WS"};
int main(){	
	int n;cin>>n;bool ok=1;
	string s,t;cin>>s;
	for(int k=0;k<4;k++){
		t=ans[k];
	for(int i=1;i<n-1;i++,ok=1){
		if(t[i]=='S'){
			if(s[i]=='o') t+=t[i-1];
			else t+=(t[i-1]=='W')?'S':'W';
		}
		else {
			if(s[i]=='o') t+=(t[i-1]=='W')?'S':'W';
			else t+=t[i-1];
		} 
	}
	//cout<<t<<endl;
	if(t[0]=='S'){
		if(s[0]=='o') ok&=(t[1]==t[n-1]);
		else ok&=(t[1]!=t[n-1]);
	}
	else {
			if(s[0]=='x') ok&=(t[1]==t[n-1]);
		else ok&=(t[1]!=t[n-1]);
	}
	if(t[n-1]=='S'){
		if(s[n-1]=='o') ok&=(t[0]==t[n-2]);
		else ok&=(t[0]!=t[n-2]);
	}
	else {
		if(s[n-1]=='x') ok&=(t[0]==t[n-2]);
		else ok&=(t[0]!=t[n-2]);
	}
	if(ok) break;
	}
	if(ok) cout<<t;
	else puts("-1");
	return 0;
}

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

const int maxn = 1e5 + 10;
typedef long long int ll;
void solved(){
	ll k;cin>>k;
	queue<string>st;
	st.push("1");
	st.push("2");st.push("3");
	st.push("4");st.push("5");
	st.push("6");st.push("7");
	st.push("8");st.push("9");
	vector<string>ve;
	int cnt = 0;
	while(!st.empty()){
		string now = st.front();st.pop();
		cnt ++;
		if(cnt > 1e5 + 10)break;
		ve.push_back(now);
		//cout<<now<<endl;
		char cur = now[now.size() - 1];
		if(cur != '0')
		st.push(now + (char)(cur - 1));
		st.push(now + cur);
		if(cur != '9')
		st.push(now + (char)(cur + 1));
	}
	cout<<ve[k - 1]<<endl;
}
int main(){
	solved();
	return 0;
} 

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

using namespace std;

using int64 = long long;

int main()
{
  int N, M;
  cin >> N >> M;
  map< int, vector< int > > g[100000];
  for(int i = 0; i < M; i++) {
    int p, q, c;
    cin >> p >> q >> c;
    --p, --q;
    g[p][c].emplace_back(q);
    g[q][c].emplace_back(p);
  }

  queue< int > que;
  int v[100000];
  memset(v, -1, sizeof(v));
  v[0] = 0;
  que.emplace(0);

  while(!que.empty()) {
    int p = que.front();
    que.pop();

    if(p == N - 1) {
      cout << v[p] << endl;
      return (0);
    }

    function< void(int, int) > add_dfs = [&](int company, int idx)
    {
      if(v[idx] == -1) {
        v[idx] = v[p] + 1;
        que.emplace(idx);
      }
      if(!g[idx].count(company)) {
        return;
      }
      auto &x = g[idx][company];
      while(x.size()) {
        int to = x.back();
        x.pop_back();
        add_dfs(company, to);
      }
    };

    for(auto &e : g[p]) {
      add_dfs(e.first, p);
    }
  }

  cout << -1 << endl;
}

Measured memory_bytes: 49280
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    int h, w;
    cin >> h >>w;
    bool flag = false;
    int cnt = 0;
    REP(i, h){       
        string s;
        cin >> s;
        REP(j, s.size()){
            if(s[j] == '#') cnt++;
        }
    }
    if(cnt == h+w-1) flag = true;
    if(flag) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}

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

Measured memory_bytes: 256
#define     ll      long long int

#include <bits/stdc++.h>
using namespace std;
int main()
{
    ll n,i,a,ans=0;
    vector<ll>v;
    priority_queue<ll>q;
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> a;
        v.push_back(a);
        q.push(a);
    }
    q.pop();
    sort(v.rbegin(),v.rend());
    ans+=v[0];
    for(i=2;i<v.size();i+=2)
    {
        a=q.top();
        q.pop();
        ans+=a;
        if(i+1<n)
            ans+=a;
    }
    cout << ans << endl;
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N, M, Q; cin >> N >> M >> Q;
  string S[N]; rep(i,N) cin >> S[i];
  int x1[Q], y1[Q], x2[Q], y2[Q]; 
  rep(i,Q) {
    cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
    x1[i]--; y1[i]--; x2[i]--; y2[i]--;
  }
  int b[N+1][M+1] = {}, adjh[N][M+1] = {}, adjw[N+1][M] = {};
  rep(i,N) rep(j,M) {
    b[i+1][j+1] = b[i][j+1] + b[i+1][j] - b[i][j] + (S[i][j]=='1');
    if (i!=N-1) {
      adjh[i+1][j+1]  = adjh[i][j+1] + adjh[i+1][j] - adjh[i][j];
      adjh[i+1][j+1] += (S[i][j]=='1'&&S[i+1][j]=='1');
    }
    if (j!=M-1) {
      adjw[i+1][j+1]  = adjw[i][j+1] + adjw[i+1][j] - adjw[i][j];
      adjw[i+1][j+1] += (S[i][j]=='1'&&S[i][j+1]=='1');
    }
  }
  // rep(i,N+1) { rep(j,M+1) cout << b[i][j] << " "; cout << endl; }
  // rep(i,N) { rep(j,M+1) cout << adjh[i][j] << " "; cout << endl; }
  // rep(i,N+1) { rep(j,M) cout << adjw[i][j] << " "; cout << endl; }

  rep(i,Q) {
    int black = b[x2[i]+1][y2[i]+1] - b[x2[i]+1][y1[i]] - b[x1[i]][y2[i]+1] + b[x1[i]][y1[i]];
    int ah = adjh[x2[i]][y2[i]+1] - adjh[x2[i]][y1[i]] - adjh[x1[i]][y2[i]+1] + adjh[x1[i]][y1[i]];
    int aw = adjw[x2[i]+1][y2[i]] - adjw[x2[i]+1][y1[i]] - adjw[x1[i]][y2[i]] + adjw[x1[i]][y1[i]];
    int result = black - ah - aw;
    // cout << black << " " << ah << " " << aw << endl;
    cout << result << endl;
  }

  return 0;
}

Measured memory_bytes: 57600
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] num = new int[6];

        for(int i = 0; i < num.length; i++) {
        	num[i] = sc.nextInt();
        }

        Dice dice = new Dice();
        String com = sc.next();
        for(int i = 0; i < com.length(); i++) {
        	dice.change(com.charAt(i));
        }

        System.out.println(num[dice.getTop()-1]);
    }
}

class Dice {
	private int top = 1;
    private int front = 2;
    private int right = 3;
    private int left = 4;
    private int back = 5;
    private int bottom = 6;

    void change(char dir) {
    	switch(dir) {
    	case 'N' : moveN(); break;
    	case 'S' : moveS(); break;
    	case 'E' : moveE(); break;
    	case 'W' : moveW(); break;
    	}
    }

    void moveN() {
    	int temp = top;
    	top = front;
    	front = bottom;
    	bottom = back;
    	back = temp;
    }
    void moveS() {
    	int temp = top;
    	top = back;
    	back = bottom;
    	bottom = front;
    	front = temp;
    }
    void moveE(){
        int temp = top;
        top = left;
        left = bottom;
        bottom = right;
        right = temp;
    }
    void moveW(){
        int temp = top;
        top = right;
        right = bottom;
        bottom = left;
        left = temp;
    }

    int getTop() {
    	return top;
    }
}


Measured memory_bytes: 26364
#define ENABLE_DEBUG 1
// hidden common codes{{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(lint ngtkana_is_a_genius=0; ngtkana_is_a_genius<(lint)k; ngtkana_is_a_genius++)
using lint=long long;
using ld=long double;
template<class T> using numr=std::numeric_limits<T>;
struct input_t {
    template<class T> operator T() {
        T t;
        std::cin>>t;
        return t;
    }
} input;
#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::string s=input;
    while(true){
        s.pop_back();
        s.pop_back();

        lint n=s.length()/2;
        for(lint i=0;i<=n;i++){
            if(i==n){
                std::cout<<s.length()<<'\n';
                return 0;
            }
            if (s.at(i)!=s.at(i+n)){
                break;
            }
        }
    }
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#pragma endregion

void solve(){
    int N;
    cin >> N;
    vector<ll> A(N);
    for (int i=0; i<N; i++) {
        cin >> A.at(i);
    }
    ll sum = 0;
    int right = 0;
    ll ans = 0;
    for (int left=0; left<N; left++) {
        while (right < N && sum + A.at(right) == (sum ^ A.at(right))) {
            sum += A.at(right);
            right++;
        }
        ans += right - left;
        if (left == right) {
            right++;
        } else {
            sum -= A.at(left);
        }
    }
    cout << ans << "\n";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


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

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

  int64_t count=1;
  for (int i = 0; i < N; i++) {
    count=count*(i+1);
    count=count%(1000000007);
  }

  cout << count << endl;
}

Measured memory_bytes: 384
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
 

int main()
{	
	
	char c;
	cin >> c;

	cout << (char)(c + 1) << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
it, ix, iy = 0, 0, 0
ans = 'Yes'
for _ in range(N):
    t, x, y = map(int, input().split())
    dt = abs(it - t)
    dx = abs(ix - x)
    dy = abs(iy - y)
    d = dt - (dx + dy)
    if d < 0 or d % 2 != 0:
        ans = 'No'
        break
    it, ix, iy = t, x, y
print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#define debug printf("\n-------------\n")
using namespace std;
typedef long long ll;
const int INF1=(~0u>>2);
const ll INF2=(~0ull>>2),P1=10007,P2=998244353,P3=1000000007;
int n,m;
int main()
{
	scanf("%d %d",&n,&m);
	printf(n==m?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
X, N = map(int, input().split())
if(N > 0):
    p = list(map(int, input().split()))
    ans = 103

    for i in range(-1,102):
        if(i not in p):
            e = abs(i - X)
            if e < ans:
                ans = e
                ans1 = i
    print(ans1)
else:
    print(X)

Measured memory_bytes: 9128
# 3:06
s = input()
out = True
for c in s[1:]:
    if c != '9':
        out = False
        break

if out:
    print(int(s[0]) + (len(s) - 1) * 9)
else:
    print(int(s[0]) - 1 + (len(s) - 1) * 9)


Measured memory_bytes: 2940