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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

    int n, d;
    cin >> n >> d;

    vii x(n, vi(d));
    rep(i, n) { rep(j, d) cin >> x[i][j]; }

    int ans = 0;
    rep(i, n) rep(j, i) {
        int sq = 0;
        rep(k, d) {
            int s = x[i][k] - x[j][k];
            sq += s * s;
        }
        int s = sqrt(sq) + 0.5;
        if (s * s == sq) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
s = gets.chomp.split('')
t = gets.chomp.split('')

ssize = s.size
tsize = t.size

ans = 1000

(ssize-tsize+1).times do |i|
  tmp = 0
  tsize.times do |u|
    if s[u+i] != t[u]
      tmp += 1
    end
  end
  ans = [ans,tmp].min
end
p ans


Measured memory_bytes: 14300
def OneStrokePath():
    from collections import deque
    import copy
    n, m = map(int, input().split())
    graph = [[] for _ in range(n)]
    ans = 0
    
    for _ in range(m):
        a, b = map(int, input().split())
        graph[a-1].append(b-1)
        graph[b-1].append(a-1)
    q = deque()
    q.append([0, []])
        
    while q:
        x0, route0 = q.pop()
        if x0 in route0:
            continue
        route1 = copy.deepcopy(route0)
        route1.append(x0)
        if len(route1) == n:
            ans += 1
        for i in graph[x0]:
            if i in route1:
                continue
            q.append([i, route1])
    print(ans)  

if __name__ == '__main__':
    OneStrokePath()
    


Measured memory_bytes: 9476
#include <iostream>
#include <queue>
#include <algorithm>

using namespace std;

int solve(int sw, int sh, int gw, int gh){
    
}

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

    char S[H][W];
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> S[i][j];
        }
    }

    int m = 0;
    for(int sw=0; sw<W; sw++){
        for(int sh=0; sh<H; sh++){
            for(int gw=0; gw<W; gw++){
                for(int gh=0; gh<H; gh++){
                    if(sw==gw && sh==gh) continue;
                    if(S[sh][sw] == '#' || S[gh][gw] == '#') continue;
                    queue<pair<int,int>> q;

                    q.push(make_pair(sh, sw));

                    int fl[H][W];
                    for(int i=0; i<W; i++){
                        for(int j=0; j<H; j++){
                            fl[j][i] = -1;
                        }
                    }

                    fl[sh][sw] = 0;
                    while(!q.empty()){
                        int y = q.front().first;
                        int x = q.front().second;

                        if(x==gw && y==gh) break;

                        if(y+1<H && S[y+1][x] == '.' && fl[y+1][x] == -1){
                            q.push(make_pair(y+1, x));
                            fl[y+1][x] = fl[y][x] + 1;
                        }

                        if(y-1>=0 && S[y-1][x] == '.' && fl[y-1][x] == -1){
                            q.push(make_pair(y-1, x));
                            fl[y-1][x] = fl[y][x] + 1;
                        }

                        if(x+1<W && S[y][x+1] == '.' && fl[y][x+1] == -1){
                            q.push(make_pair(y, x+1));
                            fl[y][x+1] = fl[y][x] + 1;
                        }

                        if(x-1>=0 && S[y][x-1] == '.' && fl[y][x-1] == -1){
                            q.push(make_pair(y, x-1));
                            fl[y][x-1] = fl[y][x] + 1;
                        }

                        q.pop();
                    }

                    m = max(m, fl[gh][gw]);

                }
            }
        }
    }

    cout << m;

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
  cin >> vec.at(i);
  }
  int maxvec=-1000000;
  for (int i = 0; i < n; i++) {
    if(vec.at(i)>=maxvec){
      maxvec=vec.at(i);
    }
  }
  int minvec=1000000;
   for (int i = 0; i < n; i++) {
    if(vec.at(i)<=minvec){
      minvec=vec.at(i);
    }
  }
  long long sumvec=0;
    for (int i = 0; i < n; i++) {
    sumvec=sumvec+vec.at(i);
    }
  cout <<minvec<<" "<<maxvec<<" "<<sumvec<<endl;
  
  return 0;
}


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

int main(){
  int M;
  cin >> M;
  vector<long long> C(M), D(M);
  long long t = 0, ans = -1;
  for(int i = 0; i < M; ++i){
    cin >> C[i] >> D[i];
    t += C[i]*D[i];
    ans += D[i];
    ans += (max(0LL,t-1)/9);
    if(t > 0) t = (t-1)%9 + 1;
  }
  cout << ans << endl;
}


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

int n,g,bit;
int dis[1<<20];
vector<int> mask[5][5];

int rec(int g, int t){
  if(t == 5){
    if( (g & 31) )return 1000000;
    return dis[g>>5];
  }

  int res = rec(g,t+1);
  for(int i=0;i<mask[0][t].size();i++){
    res = min(res,rec(g^mask[0][t][i],t+1)+1);
  }
  return res;
}
    
int main(){
  for(int i=0;i<5;i++){
    for(int j=0;j<5;j++){
      for(int k=i;k<5;k++){
	for(int l=j;l<5;l++){
	  int tmp = 0;
	  for(int y=i;y<=k;y++){
	    for(int x=j;x<=l;x++){
	      tmp |= 1<<(y*5+x);
	    }
	  }
	  mask[i][j].push_back(tmp);
	}
      }
    }
  }

  for(int i=0;i<(1<<20);i++)dis[i] = -1;
  dis[0] = 0;
  queue<int> q; q.push(0);
  while(q.size()){
    int p = q.front(); q.pop();
    for(int i=0;i<4;i++)
      for(int j=0;j<5;j++){
	for(int k=0;k<mask[i][j].size();k++){
	  if(mask[i][j][k]>=1<<20)continue;
	  int nxt = p^mask[i][j][k];
	  if(dis[nxt]<0){
	    dis[nxt] = dis[p] + 1;
	    q.push(nxt);
	  }
	}
      }
  }

  while(cin >> n,n){
    g = 0;
    for(int i=0;i<5;i++){
      for(int j=0;j<5;j++){
	if(i<n && j<n){
	  cin >> bit;
	  g |= bit<<(i*5+j);
	}
      }
    }
    if(n<5){
      for(int i=0;i<dis[g];i++)cout << "myon";
      cout << endl;
    }else{
      int tmp = rec(g,0);
      for(int i=0;i<tmp;i++)cout << "myon";
      cout << endl;
    }
  }
}

Measured memory_bytes: 7804
#include<iostream>

using namespace std;

int main()
{
    int n;

    int counter[100001]={0};


    int a;

    cin>>n;

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

    int f=0,result,pos;

    for(int i=0;i<=1000;i++)
    {
        if(f==0 && counter[i]!=0)
        {
            f=1;
            pos=i;
            result=0;
        }
        else
        {
            if(counter[i]!=0)
            {
                result+=(i-pos);
                pos=i;
            }
        }
    }

    cout<<result<<endl;

}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
const int maxn = 200200;
const int mod = 1000000007;
int main(){
  int n;
  string s;
  cin >> n >> s;
  if(count(s.begin(), s.end(), 'R') > count(s.begin(), s.end(), 'B')) cout << "Yes" << endl;
  else cout << "No"<< endl;
  return 0;
}


Measured memory_bytes: 256
N, M = map(int,input().split())
if N > M:
    N, M = M, N
if N == 1:
    if M == 1:
        ans = 1
    else:
        ans = M - 2
elif N == 2:
    ans = 0
else:
    ans = (N - 2) * (M - 2)
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    cout << n * (n+1) /2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
  int n, m;
  int d[200000], t[200000];

  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%d", &d[i]);
  }
  scanf("%d", &m);
  for(int i = 0; i < m; i++){
    scanf("%d", &t[i]);
  }

  if(n < m){
    printf("NO\n");
    return 0;
  }

  sort(d, d + n);
  sort(t, t + m);

  int i = 0, j = 0;
  while(i < n){
    if(d[i] == t[j]){
      //printf("%d %d\n", d[i], t[j]);
      j++;
    }
    i++;
    if(j == m){
      printf("YES\n");
      return 0;
    }
  }
  printf("NO\n");

  return 0;
}


Measured memory_bytes: 1792
# A, B = [int(i) for i in input().split(" ")]
# A = int(input())
# As = [int(i) for i in input().split(" ")]
# Ss = ["".join(sorted(input())) for _ in range(N)]

S = input()
a = all([s in "RUD" for i, s in enumerate(S) if i % 2 == 0])
b = all([s in "LUD" for i, s in enumerate(S) if i % 2 == 1])
if a and b:
  print("Yes")
else:
  print("No")



Measured memory_bytes: 2940
D,N  = map(int, input().split())
if D == 0:
    if N != 100:
        print(N)
    if N == 100:
        print(101)
if D == 1:
    if N != 100:
        print(N * 100)
    if N == 100:
        print(10100)
if D == 2:
    if N != 100:
        print(N * 10000)
    if N == 100:
        print(1010000)

Measured memory_bytes: 3060
n = int(input())
A = list(map(int, input().split()))

for i in range(1, n):
    for m in range(n-1):
        print(A[m], end=' ')
    print(A[n-1])
    
    v = A[i]
    j = i-1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
for m in range(n-1):
    print(A[m], end=' ')
print(A[n-1])


Measured memory_bytes: 5976
#include <iostream>
using namespace std;
int main(){
  int primecount=1,anscount=0,N,K;
  int SO;
  int prime[400];
  cin>>N;
  int ans[N];
  prime[0]=2;
for(int i=2;i<2000;i++){
    for(int j=0;j<=primecount;j++){
    if(i%prime[j]==0&&prime[j]!=0){
      SO=0;
    break;}}
    if(SO==1){
            primecount ++;
      prime[primecount]=i;
      if(i%10==1){
        ans[anscount]=i;
        anscount ++;
      }
      if(anscount==N){
        break;
      }
  }
  SO=1;
}
for(int m=0;m<N;m++){
  cout<<ans[m]<<" ";
}
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)

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

   int ans = 0;

   for(int i = 1; i < n; ++i){
      int cnt = 0;
      for(char c = 'a'; c <= 'z'; ++c){
         bool left = false, right = false;

         for(int j = 0; j < i; ++j){
            if(s[j] == c) left = true;
         }
         for(int j = i; j < n; ++j){
            if(s[j] == c) right = true;
         }

         if(left&&right) cnt++;
      }
      if(ans < cnt) ans = cnt;
   }

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <iomanip>

using namespace std;
using ll = int64_t;
using VL = vector<ll>;
using VD = vector<double>;
using VVL = vector<VL>;
using VVD = vector<VD>;

#define FOR(i, start, end) for(ll i = (start), (i ## xxxx_end)=(end); i < (i ## xxxx_end); ++i)
#define FORD(i, start, end) for(ll i = (start), (i ## xxxx_end)=(end); i > (i ## xxxx_end); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPD(i, n) FORD(i, n - 1, -1)

#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}

#define INF 1000000000000
#define MOD 1000000007

ll N, K;
VL A, dp;

void solve() {
    cin >> N >> K;
    A = VL(N);
    for(auto& a : A) cin >> a;
    dp = VL(K + 1, 0);
    FOR(i, 1, K + 1) {
        for(auto&& a : A) {
            if(a <= i && dp[i - a] == 0) {
                dp[i] = 1;
            }
        }
    }
    print(dp[K] ? "First" : "Second");
}

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef string str;
const long long INF = INT64_MAX;

#define REP(i, n) for(ll i=0;i<n;i++)
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define UNIQ(v) ASC(v);erase(unique(v.begin(), v.end()), v.end())
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);

void solve() {
    ll N;
    cin >> N;
    vll X(N), Y(N), H(N);
    ll xx, yy, hh;
    for (int i = 0; i < N; i++)
    {
        cin >> X[i] >> Y[i] >> H[i];
        if(H[i] > 0) {
            xx = X[i];
            yy = Y[i];
            hh = H[i];
        }
    }
    for (int x = 0; x < 101; x++)
    {
        for (int y = 0; y < 101; y++)
        {
            bool valid = true;
            // 中心の高さ
            ll h = hh + abs(xx - x) + abs(yy - y);
            int i = 0;
            for(i = 0; i < N; i++) {
                if(H[i] != max(0LL, h - abs(X[i] - x) - abs(Y[i] - y))) {
                    valid = false;
                    break;
                }
            }
            if(valid) {
                cout << x << " ";
                cout << y << " ";
                cout << h << endl;
                return;
            }
        }
        
    }
    
}

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

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

int selectionSort(int A[], int N) {
    int count = 0;
    for(int i = 0; i < N - 1; i++) {
        int t = A[i];
        int minj = i;
        for(int j = i; j < N; j++) {
            if(A[j] < A[minj]) minj = j;
        }
        A[i] = A[minj];
        A[minj] = t;
        if(minj != i) count++;
    }
    return count;
}
int main() {
    int A[100], N, count;
    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];

    count = selectionSort(A, N);

    for(int i = 0; i < N; i++) {
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3100
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
 
int main()
{
  string s, t; 
while(cin >> s){
cin >> t;
  // s??????
  int ans = 0;
  int cnt = 0;
  FOR(i,0,t.length()) {
  	cnt = 0;
   	for(int j = 0; j < s.length() && i + j < t.length(); j++) {
      if(s[j] == t[i+j]) cnt++;
      else {
        ans = max(ans, cnt);
        cnt = 0;
      }
    }
    ans = max(ans, cnt);
  }
    
  // t??????
  FOR(i,0,s.length()) {
    cnt = 0;
   	for(int j = 0; j < t.length() && i + j < s.length(); j++) {
      if(s[i+j] == t[j]) cnt++;
      else {
        ans = max(ans, cnt);
        cnt = 0;
      }
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;
}
  return 0;
}

Measured memory_bytes: 3232
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int N = 2e5 + 6;
int A[N];
int mat[15][N];
int dp[14][(1<<14)];
int n , m ,x;
map<string,int> mst;


void alpha(int i , string str)
{
	if(i == n)
	{
		mst[str]++;
		return;
	}
	string nstr1 = str + '1';
	string nstr2 = str + '0';
	alpha(i+1,nstr2);
	alpha(i+1,nstr1);
}

void solve()
{
	cin >> n >> m >> x;

	loop(i,0,n)
	{
		cin >> A[i];
		loop(j,0,m)
		{
			cin >> mat[i][j];
		}
	}

	alpha(0,"");

	// for(auto &it : mst)
	// {
	// 	cout << it.ff << endl;
	// }

	int ans = inf;

	for(auto &s : mst)
	{
		int ok = 0;
		loop(i,0,m)
		{
			int sum = 0;
			loop(j,0,n)
			{
				if(s.ff[j] == '1')
				{
					sum += mat[j][i];
				}
			}
			if(sum < x)
			{
				// cout << sum << endl;
				ok = 1;
				break;
			}
		}
		if(ok)continue;
		int a = 0;
		loop(j,0,n)
		{
			if(s.ff[j] == '1')
			{
				a += A[j];
			}
		}

		ans = min(ans , a);
	}

	if(ans == inf)cout << -1;
	else cout << ans;
}
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);

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

 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N; cin >> N;
    int a = N / 100;
    int b = a + 1;
    if (100 * a + 10 * a + a >= N) cout << 100 * a + 10 * a + a << endl;
    else cout << 100 * b + 10 * b + b << endl;
}

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 num: i32 = read();
    let mut ok = false;

    'outer: for i in 1..10 {
        for j in 1..10 {
            if (i * j) == num {
                ok = true;
                break 'outer;
            }
        }
    }

    println!("{}", if ok { "Yes" } else { "No" });
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>     
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long
#define int ll
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define VAR(v, i) __typeof( i) v=(i)
#define forit(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
 
using namespace std;
 
const int maxn = (int)1e2 + 100;
const int N = (int)1e5 + 100;
const int mod = (int)1e9 + 7;
 
#define inf mod
 
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;   
typedef vector<ll> Vll;               
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
 
int n, a[maxn],S;
int dp[maxn][N],pr[maxn][N];

main () {
	cin>>n>>S;
	forn(i,1,n)
		cin>>a[i];
	dp[0][0]=1;
	forn(i,0,N-1)
		pr[0][i]=1;
	forn(i, 1, n){
		forn(s,0,N-1){
			dp[i][s]=(pr[i-1][s]-((s-a[i])>=1 ? pr[i-1][(s-a[i])-1]:0)+mod)%mod;
			pr[i][s]=dp[i][s];
			if(s)
				pr[i][s]=(pr[i][s]+pr[i][s-1])%mod;
		}
		
	}
	cout<<dp[n][S];
}

Measured memory_bytes: 160128
#include<cmath>
#include<stdio.h>
//using namespace std;

int main() {
  int W;
  int H;
  int x;
  int y;
  int r;
  scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
   if( x-r >= 0 && x+r <= W && y+r <= H && y-r >= 0){
     printf("Yes\n");
   }else{
     printf("No\n");
   }
}


Measured memory_bytes: 2680
n = int(raw_input())
ais = map(int, raw_input().split(' '))

def f(ais,n):
	q = 1 # number of non leaves
	r = 0
	h = {}
	for depth,nl in enumerate(ais):
		if nl > q: return -1
		elif nl == q:
			if depth < n: return -1
			q -= nl
		elif nl < q:
			q -= nl
		#r += (q + nl)
		h[depth] = q
		if depth < n: q *= 2
	
	internal = 0
	for j in range(len(ais)-1, 0, -1):
		r += ais[j] + internal
		internal = min(h[j - 1], ais[j] + internal) 
	return r + 1


print f(ais,n)



Measured memory_bytes: 708668
#include <stdio.h>
#include <stdlib.h>

int compare(const void *a,const void *b){
	return *(int*)a-*(int*)b;
}

int main(){
	int N,A,B;
	int i;
	int first=0,second=0,third=0;
	int contest=0;
	
	scanf("%d",&N);
	scanf("%d %d",&A,&B);
	
	int Pi[N];
	
	for(i=0;i<N;i++){
		scanf("%d",&Pi[i]);
	}
	
	qsort(Pi,N,sizeof(int),compare);
	
	i=0;
	while(Pi[i]<A+1){
		first++;
		i++;
	}
	
	while(Pi[i]<B+1){
		second++;
		i++;
	}
	
	i=N-1;
	while(B<Pi[i]){
		third++;
		i--;
	}
	
	while(first!=0 && second!=0 && third!=0){
		contest++;
		
		first--;
		second--;
		third--;
	}
	
	printf("%d",contest);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int x,y,a,b,c;
int main(){
	cin>>x>>y>>a>>b>>c;
	priority_queue<int,vector<int>,greater<int> >pq_a;
	priority_queue<int,vector<int>,greater<int> >pq_b;
	priority_queue<int,vector<int>,less<int> >pq_c;
	while(a--){
		int a;
		cin>>a;
		pq_a.push(a);
	}
	while(b--){
		int a;
		cin>>a;
		pq_b.push(a);
	}
	while(c--){
		int a;
		cin>>a;
		pq_c.push(a);
	}
	while(pq_a.size()>x) pq_a.pop();
	while(pq_b.size()>y) pq_b.pop();
	while(pq_c.size()){
		int curr = pq_c.top();
		pq_c.pop();
		if(curr<=pq_a.top() && curr<=pq_b.top()) break;
		if(pq_a.top()>pq_b.top()){
			pq_b.pop();
			pq_b.push(curr);
		}
		else{
			pq_a.pop();
			pq_a.push(curr);
		}
	}
	long long ret = 0;
	while(pq_a.size()){
		ret+=pq_a.top();
		pq_a.pop();
	}
	while(pq_b.size()){
		ret+=pq_b.top();
		pq_b.pop();
	}
	cout<<ret;
}

Measured memory_bytes: 4724
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
m,d = m()

su = 0

for i in range(1,m+1):
    for j in range(1,d+1):
        d1 = j%10
        d2 = j//10
        if d1 >= 2 and d2 >= 2 and d1*d2 == i:
            su += 1
print(su)


Measured memory_bytes: 39792
#include <stdio.h>

const int MAX_H = 1005;
const int MOD = (int)1e9 + 7;

char grid[MAX_H][MAX_H];
int dp[MAX_H][MAX_H];

int main(void) {
    int h, w;

    scanf(" %d %d", &h, &w);
    for (int i = 1; i <= h; i++) {
        scanf(" %s", grid[i] + 1);
    }

    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            if (i == 1 && j == 1) {
                dp[i][j] = 1;
                continue;
            }

            dp[i][j] = grid[i][j] == '#' ? 0 : dp[i - 1][j] + dp[i][j - 1];
            dp[i][j] %= MOD;
        }
    }
    printf("%d\n", dp[h][w]);

    return 0;
}


Measured memory_bytes: 5120
import re
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


sd = S()
sd = sd.replace('?', '.')  # 正規表現を使うため、「任意の一文字」を表す「.」に変換しておく
t = S()

# s' の先頭から len(t) 文字を見て、 ? を 置き換えることで t にできる場合、
# t のために 使った s の ? 以外の ? を全て a に変えた文字列を候補の一つとする
ans = []
for i in range(len(sd) - len(t) + 1):
    if not re.match(sd[i:i + len(t)], t):
        continue
    kouho = (sd[:i] + t + sd[i + len(t):]).replace('.', 'a')
    ans.append(kouho)

if not ans:
    print('UNRESTORABLE')
    sys.exit()

print(min(ans))  # 文字列 の min は 辞書順の最小になる


Measured memory_bytes: 9756
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
LL stack[20];
inline void write(LL x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    LL top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(LL x){write(x);putchar(' ');}
inline void pr2(LL x){write(x);putchar('\n');}
const LL MAXN=1005;
const LL MAXM=2005;
const LL mod=1e9+7;
LL pow_mod(LL a,LL b)
{
	LL ret=1;
	while(b)
	{
		if(b&1)ret=1LL*ret*a%mod;
		a=1LL*a*a%mod;b>>=1;
	}
	return ret;
}
struct edge{LL x,y,c,next;}E[MAXM],a[2*MAXM];LL len,last[MAXN];
void ins(LL x,LL y,LL c){len++;a[len].x=x;a[len].y=y;a[len].c=c;a[len].next=last[x];last[x]=len;}
bool cmp(edge n1,edge n2){return n1.c<n2.c;}
LL n,m,rt[MAXN];
LL num[MAXM],fa[MAXN],cal[MAXN],dep[MAXN];
LL sum;
void init(LL x)
{
	for(LL k=last[x];k;k=a[k].next)
	{
		LL y=a[k].y;
		if(y!=fa[x])
		{
			fa[y]=x;dep[y]=dep[x]+1;
			cal[y]=a[k].c;
			init(y);
		}
	}
}
LL findrt(LL x){return rt[x]==x?rt[x]:rt[x]=findrt(rt[x]);}
LL getcal(LL x,LL y)
{
	if(x==y)return 0;
	if(dep[x]<dep[y])return max(cal[y],getcal(x,fa[y]));
	if(dep[x]>dep[y])return max(cal[x],getcal(fa[x],y));
	return max(max(cal[x],cal[y]),getcal(fa[x],fa[y]));
}
void ad(LL &x,LL y){x+=y;if(x>=mod)x-=mod;}
int main()
{
	n=read();m=read();
	sum=read();
	for(LL i=1;i<=m;i++)E[i].x=read(),E[i].y=read(),E[i].c=read();
	sort(E+1,E+1+m,cmp);
	for(LL i=1;i<=n;i++)rt[i]=i;
	memset(num,63,sizeof(num));
	LL si=0;
	for(LL i=1;i<=m;i++)
	{
		LL p=findrt(E[i].x),q=findrt(E[i].y);
		if(p!=q)rt[p]=q,ins(E[i].x,E[i].y,E[i].c),ins(E[i].y,E[i].x,E[i].c),num[i]=-1,si+=E[i].c;
	}
	if(si>sum)return puts("0"),0;
	init(1);
	for(LL i=1;i<=m;i++)if(num[i]!=-1)
	{
		LL p=getcal(E[i].x,E[i].y);
		num[i]=E[i].c-p;
	}
	LL eq=0,up=0,ans;
	for(LL i=1;i<=m;i++)
	{
		if(num[i]==sum-si)eq++;
		else if(num[i]>sum-si)up++;
	}
	ans=1LL*2*(pow_mod(2,eq)-1+mod)%mod*pow_mod(2,up)%mod;
	if(si==sum)ad(ans,1LL*(pow_mod(2,n-1)-2+mod)%mod*pow_mod(2,m-n+1)%mod);
	pr2(ans);
	return 0;
}

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

int N, T;
priority_queue<int, vector<int>, greater<int>> pq;

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

  int c, t;
  for(int i = 0; i < N; i++){
    cin >> c >> t;
    if(t <= T)
      pq.push(c);
  }

  if(pq.empty())
    cout << "TLE" << endl;
  else
    cout << pq.top() << endl;

  return 0;
    
}

Measured memory_bytes: 256
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
using namespace std;
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	string a,b;
	cin>>a>>b;
	if(a.size()==b.size()){
		for(int i=0;i<a.size();i++)
		cout<<a[i]<<b[i];
	}
	else if(a.size()>b.size()){
		for(int i=0;i<b.size();i++)
		cout<<a[i]<<b[i];
		cout<<a[a.size()-1];
	}
	else{
		for(int i=0;i<a.size();i++)
		cout<<a[i]<<b[i];
		cout<<b[b.size()-1];
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
 
#define mod(cans) cans%10**9+7
#define debug(x) cout << "Debug" << x << "\n"
#define rep(i,n) for(unsigned i=0;i<n;i++)
#define repr(i,n) for(unsigned i=n-1;i>=0;i--)
#define rep1(i,n) for(unsigned i=1;i<=n;i++)
#define cin_pl(n,x) rep(i,n){cin>>x[i];}
#define cins(s,n) rep(i,n)cin>>s.at[i];
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define prians(Answer) cout<<Answer<<"\n"
#define TF(X) X==1?cout<<"YES\n":cout<<"NO\n"
#define elcon else{continue;}
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vector<int> > matrix;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef greater<int> gi;
typedef vector<unsigned> vu;


ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
bool is_prime(const unsigned n){
    switch(n){
        case 0:
        case 1: return false;
        case 2: return true;
    }
 
 
    for(unsigned i=2;i<n;++i){
        if(n%i == 0) return false;
    }
 
    return true;
}


bool F(int a,int b,int c)
{
    rep1(i,101)
    {
        if(a*i%b==c)
        return true;
    }
    return false;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;cin>>a>>b>>c;
    TF(F(a,b,c));
    
}

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

using namespace std;

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define int long long
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define INF LLONG_MAX
#define EPS 1e-9
#define all(v) (v).begin(),(v).end()
#define sq(x) ((x)*(x))
#define foreach(it, v) for(auto it=(v).begin(); it != (v).end(); ++it)
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)


#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
 
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}
 
typedef long double dbl;
bool codejam = 0;

const int MOD = 1000*1000*1000 + 7;
const int NMAX = 1000*1000 + 11;

int arr[NMAX];
int n,m,p,q,k,a,b,c,ans;
string s,str;
char ch;
vector<int> v;
bool dp[NMAX];

void solve()
{
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    sort(arr,arr+n);
    dp[0] = 1;
    for(int i=1;i<=k;i++){
        for(int j=0;j<n;j++){
            if(arr[j] > i) break;

            if(not dp[i-arr[j]] or i == arr[j]) {
                // tr(i,j,arr[j]);
                dp[i] = 1;
            }
        }
    }
    if(dp[k]){
        cout<<"First";
    }else{
        cout<<"Second";
    }
}

int32_t main(){ fio;
    int t = 1;
    int cs = 1;
    // cin>>t;
    while(t--){
        if(codejam){
            cout<<"Case #"<<cs<<": ";
        }
        cs++;
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 384
from sys import exit

s = input()
n=len(s)
cnt=1
while cnt <= n:
    if (n-cnt)%2==0:
        if s[0:(n-cnt)//2-1] == s[(n-cnt)//2:n-cnt-1]:
            print(n-cnt)
            exit()
        else:
            cnt +=1
    else:
        cnt += 1

Measured memory_bytes: 3060
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <limits>

using namespace std;

template<class T = int,T divided_by = 10>
constexpr T PINF(){ return std::numeric_limits<T>::max()/divided_by; }
template<class T = int,T divided_by = 10>
constexpr T MINF(){ return std::numeric_limits<T>::lowest()/divided_by; }

template<class T = int> T gcd(T a, T b){ return b ? gcd(b,a%b) : a; }
template<class T = int> T lcm(T a, T b){ return a / gcd(a,b) * b; }
template<class T = int> T lcm_safe(T a, T b){ T p = a/gcd(a,b); return (b <= PINF<T>()/p) ? p*b:PINF<T>(); }
//オーバーフローするとき+INFを返す
//
int main() {
	cin.tie(nullptr); ios::sync_with_stdio(false);

	int n;
	cin >> n;

	int sum = 0;
	int counter = 0;
	while(sum < n){
		sum += counter;
		counter ++;
	}

	cout << counter-1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;
#define INT(x) int x; scanf("%d",&x)
#define INPUT(x) scanf("%d",&x)
#define REP1(x,n) for(int x = 0; x < n; x++)
#define REP2(x,s,e) for(int x = s; x <= e; x++)
#define BR printf("\n")
#define INF 2000000000

int main(){
    queue<int> Ca[3];
    REP1(i,3){
        char S[101] = {};
        cin >> S;
        int len = strlen(S);
        REP1(j,len){
            Ca[i].push(S[j]-'a');
        }
    }
    int t = 0;
    while (1) {
        if(Ca[t].empty()){
            printf("%c\n",'A'+t);
            break;
        }
        int next = Ca[t].front();
        Ca[t].pop();
        t = next;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
    vector<int> dp(3,0);

   	for(int day =0; day < n ; day++){
   		vector<int> c(3,0);
   		vector<int> new_dp(3,0);
   		for(int i=0 ; i<3 ; i++){
   			cin >> c[i];
   		}

   		for(int i=0; i<3 ;i++){
   			for(int j = 0 ; j<3 ;j++){
   				if(i != j) {
   					new_dp[j] = max(new_dp[j],dp[i] + c[j]);
   				}
   			}
   		}
   		dp = new_dp;
   	}

   	cout << max(dp[0],max(dp[1],dp[2])) << endl; 

    return 0;
};

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int i=0;
  for(;a%2+b%2+c%2==0;i++){
    if(a==b&&a==c) {
      i--;
      break;
    }
    int t=a+b+c;
    a=(t-a)/2;
    b=(t-b)/2;
    c=(t-c)/2;
  }
  cout << i << endl;
}

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

int main(){
  int N ; cin >> N ; 
  vector<vector<int>> D(N , vector<int>(2));
  for(int i = 0 ; i < N ; i++){
    for(int j = 0 ; j < 2 ; j++){
      cin >> D.at(i).at(j) ;
    }
  }
  int cnt = 0 ; 
  for(int i = 0 ; i < N ; i++){
    if(D.at(i).at(0) == D.at(i).at(1)){
      cnt++ ; 
      if(cnt == 3){
        cout << "Yes" << endl ; 
        return 0 ; 
      }
    }
    else cnt = 0 ; 
  }
  cout << "No" << endl ; 
}

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

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

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

int main(){
    int N;
    cin >> N;
    VV<int> D(N, V<int>(2));
    rep(i, N) cin >> D.at(i).at(0) >> D.at(i).at(1);
    int count = 0;
    bool flag = false;
    rep(i, N){
        if(D.at(i).at(0) == D.at(i).at(1)){
            count++;
            if(count == 3) flag = true;
        }
        else count = 0;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

vector<ll> ans(2001,0);

int main(){
    ans.at(0) = 1;
    ll s; cin >> s;
    for(int i=3;i<=s;i++){
        ll x = 0;
        for(int j=0;j<=i-3;j++){
            x = (x+ans.at(j))%mod;
        }
      	ans.at(i)=x;
    }
    cout << ans.at(s) << endl;
    return 0;
}

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

using namespace std;
#define EPS (1e-7)
#define INF (1e9)


typedef long long  ll;
#define endl '\n'




int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};


const int MOD = 1000000007;
const long double PI = (acos(-1));
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];

//////////////////////////////////////////


void COMinit() {
   fac[0] = fac[1] = 1;
   finv[0] = finv[1] = 1;
   inv[1] = 1;
   for (int i = 2; i < MAX; i++){
       fac[i] = fac[i - 1] * i % MOD;
       inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
       finv[i] = finv[i - 1] * inv[i] % MOD;
   }
}

ll a, b;


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


void Input() {

    cin >> a >> b;

}



void Solve() {


     int ans = 1;
     ll M = gcd(a, b);
     if(M % 2 == 0) ans++;
     while(M % 2 == 0) M /= 2;

     for(ll i = 3; i*i <= M; i++) {

         if(M%i == 0) {

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

     if(M != 1) ans++;

     cout << ans << endl;

}

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);
  Input();
  Solve();


  return 0;

}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

map<int, int> fact(int x) {
	int cx = x;
	map<int, int> ans;
	for (int i = 2; i * i <= x; i++) {
		int c = 0;
		while (cx % i == 0) {
			cx /= i;
			c++;
		}
		if (c) ans[i] = c;
	}
	if (cx > 1) ans[cx] = 1;
	return ans;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n, p;
	cin >> n >> p;
	auto fc = fact(p);
	int ans = 1;
	for (auto t : fc) {
		int f, s;
		tie(f, s) = t;
		for (int i = 0; i < s / n; i++) {
			ans *= f;
		}
	}
	cout << ans << endl;
}

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

int		main(void)
{
	int n;
	int m;
	cin >> n >> m;
	int c = 0;
	int a[n];
	double sum = 0;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	sum /= 4 * m;
	rep(i, n)
		if (sum <= a[i])
			c++;
	if (c >= m)
		puts("Yes");
	else
		puts("No");
	return (0);
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string S; cin >> S;
  map<char,ll> m;
  for (ll i = 0; i < S.size(); ++i) m[S[i]] += 1;
  bool bSN = (m['N'] > 0 && m['S'] > 0) || (m['N'] == 0 && m['S'] == 0);
  bool bEW = (m['E'] > 0 && m['W'] > 0) || (m['E'] == 0 && m['W'] == 0);
  if (bSN&&bEW) puts("Yes"); else puts("No");
  return 0;
}


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

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;
void print(string s, string op){
    for(int i = 0; i < 3; i++){
        cout << s[i] << op[i];
    }
    cout << s[3] << "=7";
    exit(0);
}
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    string s;
    cin >> s;
    int d1 = s[0] - '0';
    int d2 = s[1] - '0';
    int d3 = s[2] - '0';
    int d4 = s[3] - '0';
    if(d1 + d2 + d3 + d4 == 7){
        print(s, "+++");
    }else if(d1 + d2 + d3 - d4 == 7){
        print(s, "++-");
    }else if(d1 + d2 - d3 + d4 == 7){
        print(s, "+-+");
    }else if(d1 - d2 + d3 + d4 == 7){
        print(s, "-++");
    }else if(d1 - d2 - d3 - d4 == 7){
        print(s, "---");
    }else if(d1 - d2 - d3 + d4 == 7){
        print(s, "--+");
    }else if(d1 - d2 + d3 - d4 == 7){
        print(s, "-+-");
    }else if(d1 + d2 - d3 - d4 == 7){
        print(s, "+--");
    }
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

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

#define int long long

using namespace std;

int row , colum;

const int MOD=1e9+7;

int dp[1005][1005];

char a[1005][1005];

void init()
{
	for(int i=0 ; i<=row ; ++i)
	{
		for(int j=0 ; j<=colum ; ++j)
		{
			dp[i][j]=0;
		}
	}
	for(int i=1 ; i<=colum ; ++i)
	{
		if(a[1][i]=='.')dp[1][i]=1;
		else break;
	}
	for(int i=2; i<=row ; ++i)
	{
		if(a[i][1]=='.')dp[i][1]=1;
		else break;
	}
}

void dynamic()
{
	for(int i=1 ; i <= row ; ++i )
	{
		for(int j=1 ; j <= colum ; ++j )
		{
			if(a[i][j]=='#')continue;
			if(a[i-1][j]=='.'&&a[i][j-1]=='.')dp[i][j]=dp[i-1][j]%MOD+dp[i][j-1]%MOD;
			else if(a[i-1][j]=='.'&&a[i][j-1]=='#')dp[i][j]=dp[i-1][j]%MOD;
			else if(a[i-1][j]=='#'&&a[i][j-1]=='.')dp[i][j]=dp[i][j-1]%MOD;
		}
	}
	cout << dp[row][colum]%MOD<<endl;
}

main()
{
	cin >> row >> colum ;
	for( int i=1 ; i <= row ; ++i)
	{
		for( int j = 1; j<= colum ; ++j )
		{
			cin >> a[i][j];
		}
	}
	init();
	dynamic();
	
}



Measured memory_bytes: 12348
N, K = map(int, input().split())
d = list(map(int, input().split()))
a = []
for i in range(10):
    if d.count(i) == 0:
        a.append(i)
ans = []
def dfs(s):
    if int(s) >= N or len(s) > 6:
        return s
    for i in a:
        S = dfs(s + str(i))
        if int(S) >= N:
            ans.append(int(S))
    return s
    
dfs('0')
print(min(ans))

Measured memory_bytes: 44380
#include <stdio.h>
int main(void){
    int x,y;
    do{
	scanf("%d %d",&x,&y);
	if(x!=0 || y!=0){
		if(x<=y)
    			printf("%d %d\n",x,y);
		else
			printf("%d %d\n",y,x);
	}
    }while(x!=0 || y!=0);
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int A, B; cin >> A >> B;
    int A_res = ceil(A * 100.0 / 8);
    int B_res = B * 10;
    if (A_res < B_res) {
        if (B_res * 8 / 100 == A) {
            cout << B_res << endl;
        } else {
            cout << "-1" << endl;
        }
    } else {
        if (A_res / 10 == B) {
            cout << A_res << endl;
        } else {
            cout << "-1" << endl;
        }
    }
}


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

int main(){
  int M,D;
  cin>>M>>D;
  int j1,j2;
  int cnt=0;
  for(int i=1;i<=M;i++){
    for(int j=1;j<=D;j++){
      if(j<=9) continue;
      j1=j%10;
      j2=j/10;
      if(j1==1 || j2==1) continue;
      if(j1*j2==i){
        cnt++;
        //cout<<j1<<" "<<j2<<" "<<i<<" "<<endl;
      }
    }
  }
  cout<<cnt<<endl;

  return 0;
}


Measured memory_bytes: 3628