akhauriyash/Code-Regression huggingface dataset:
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial

def main():
    num = int(input())
    data = list(map(int, input().split()))

    now_num = data[0]

    for i in range(1, num):
        if data[i] > now_num:
            now_num = data[i] - 1
        elif data[i] == now_num:
            pass
        else:
            print('No')
            sys.exit()

    print('Yes')






if __name__ == '__main__':
    main()


Measured memory_bytes: 63984
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MAXN = 100 + 5;

int a[MAXN];

int main(void)
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1; i<=n; ++i) scanf("%d",&a[i]);
	
	int sum=0;
	for(int i=1; i<=n; ++i) sum += a[i];
	
	int cnt=0;
	for(int i=1; i<=n; ++i)
		if(a[i] * 4*m >= sum) ++cnt;
	
	if(cnt>=m) printf("Yes");
	else printf("No"); 
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, k, q;
    cin >> n >> k >> q;
    vector<ll> p(n, 0);
    rep(i, q) {
        ll a;
        cin >> a;
        p[a - 1]++;
    }
    rep(i, n) cout << ((p[i] > (q - k)) ? "Yes" : "No") << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int64_t> lc(N+1);
  
  lc.at(0) = 2;
  lc.at(1) = 1;
  for(int i=2; i<=N; i++)
    lc.at(i) = lc.at(i-1) + lc.at(i-2);
  
  cout << lc.at(N) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
 
       ll a[5];
       int n,ans;
       for(int i=0;i<5;i++)
           {
               cin>>n;
               if(n==0)
               cout<<i+1<<endl;
           }
 
 return 0;
}
 

Measured memory_bytes: 3576
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<utility>
#include<functional>
#include<iomanip>
#include<sstream>
#include<ctime>
#include<cassert>
using namespace std;
#define y0 y0z
#define y1 y1z
#define yn ynz
#define j0 j0z
#define j1 j1z
#define jn jnz
#define tm tmz
#define buli(x) (__builtin_popcountll(x))
#define bur0(x) (__builtin_ctzll(x))
#define bul2(x) (63-__builtin_clzll(x))
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fil(a,b) memset((a),(b),sizeof(a))
#define cl(a) fil(a,0)
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define foreach(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define rep(i,a,b) for (int i=(a),_ed=(b);i<_ed;i++)
#define per(i,a,b) for (int i=(b)-1,_ed=(a);i>=_ed;i--)
#define pw(x) ((ll(1))<<(x))
#define upmo(a,b) (((a)=((a)+(b))%mo)<0?(a)+=mo:(a))
#define mmo(a,b) (((a)=1ll*(a)*(b)%mo)<0?(a)+=mo:(a))
void getre(){int x=0;printf("%d\n",1/x);}
void gettle(){int res=1;while(1)res<<=1;printf("%d\n",res);}
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
template<typename T,typename S>inline bool upmin(T&a,const S&b){return a>b?a=b,1:0;}
template<typename T,typename S>inline bool upmax(T&a,const S&b){return a<b?a=b,1:0;}
template<typename N,typename PN>inline N flo(N a,PN b){return a>=0?a/b:-((-a-1)/b)-1;}
template<typename N,typename PN>inline N cei(N a,PN b){return a>0?(a-1)/b+1:-(-a/b);}
template<typename N>N gcd(N a,N b){return b?gcd(b,a%b):a;}
template<typename N>inline int sgn(N a){return a>0?1:(a<0?-1:0);}
#if ( ( _WIN32 || __WIN32__ ) && __cplusplus < 201103L)
    #define lld "%I64d"
#else
    #define lld "%lld"
#endif
inline void gn(long long&x){
	int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');
	while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;
}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
inline void gn(double&x){double t;scanf("%lf",&t);x=t;}
inline void gn(long double&x){double t;scanf("%lf",&t);x=t;}
inline void gs(char *s){scanf("%s",s);}
inline void gc(char &c){while((c=getchar())>126 || c<33);}
inline void pc(char c){putchar(c);}
#ifdef JCVB
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...) 
#endif
typedef long long ll;
typedef double db;
inline ll sqr(ll a){return a*a;}
inline db sqrf(db a){return a*a;}
const int inf=0x3f3f3f3f;
const db pi=3.14159265358979323846264338327950288L;
const db eps=1e-6;
//const int mo=0;
//int qp(int a,ll b){int n=1;do{if(b&1)n=1ll*n*a%mo;a=1ll*a*a%mo;}while(b>>=1);return n;}

ll n,x;

ll work(ll a,ll b){
	if(a==b)return a;
	if(a>b)swap(a,b);
	ll nu=b/a;if(b%a==0)nu--;

	return nu*2*a+work(b-nu*a,a);
}
int main()
{
#ifdef JCVB
	//freopen("1.in","r",stdin);
	//freopen("1.out","w",stdout);
	int _time_jc=clock();
#endif
	gn(n);gn(x);

	cout<<n+work(x,n-x)<<endl;
#ifdef JCVB
	debug("time: %d\n",int(clock()-_time_jc));
#endif
	return 0;
}




Measured memory_bytes: 256
N = int(input())
B = list(map(int,input().split()))
anslist = []

for i in range(N):
    if i == 0:
        anslist.append(B[0])
    elif i == N-1:
        anslist.append(B[i-1])
    else:
        anslist.append(min(B[i-1],B[i]))

# print(anslist)
print(sum(anslist))

Measured memory_bytes: 3060
#include <iostream>
#define dbg if(0)

using namespace std;
#define ll long long
int main(){
    char a,b;
    int cnt=0;
    int cpos=0;
    int ccnt=0;
    bool flag=true;
    bool cflag=false;
    while(cin>>a){
        b=a;
        if (cnt==0 && a!='A')flag=false;
        if (cnt==1 &&((a>= 'A') && (a<='Z')))flag=false;
        if (cnt>1 &&((a>= 'A') && (a<='Z'))){
            if (a=='C'){
                cpos=cnt;
                cflag=true;
                ccnt++;
            }else{
                flag=false;
            }
        }
        cnt++;
        dbg if (!flag){
            cout <<"error "<<cnt <<" "<<cpos<<endl;
            break;
        }
    }
    if (cpos==cnt-1||ccnt!=1)cflag=false;
    dbg cout <<cnt <<" "<<cpos<<endl;
    if (flag&&cflag)cout <<"AC"<<endl;
    else cout <<"WA"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int compare(const void*a,const void *b){
    if(*(int *)a>*(int *)b)return 1;
    return -1;
}
int main()
{   int n;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    qsort(a,n,sizeof(int),compare);
    int eat=0,var=0;
    for(int i=0;i<n;i++){
        if(a[i]==a[i+1]){
            eat++;
        }else{
            var++;
        }
    }
    if(var%2==0)eat++;
    printf("%d",n-eat);
    return 0;
}


Measured memory_bytes: 892
//Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
using namespace std;

typedef long long              ll;
typedef long double            ld;
typedef pair<int, int>         pi;
typedef vector<int>            vi;
typedef vector<pair<int, int>> vpi;

#define pb          push_back
#define pf          push_front
#define all(x)      begin(x), end(x)
#define sz(x)       (int)(x).size()
#define ff          first
#define ss          second
#define mp          make_pair
#define lb          lower_bound
#define ub          upper_bound
#define Tcase()     int t; cin >> t; while(t--)
#define Forn(i, x)  for(int i = 0; i < (x); i++)

const int MOD = 1e9 + 7; // 998244353;
const int MX  = 2e5 + 5;
const ll  INF = 1e18;
const ld  PI  = acos((ld) -1);

void setIO(string name = "") {
    ios_base::sync_with_stdio(0); cin.tie(0);
    if(sz(name)){
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}

int main(){

    setIO();

    int n;
    cin >> n;

    int cnt = 0;
    bool yes = false;

    while(n--){

        int a, b;
        cin >> a >> b;

        if(a == b) cnt++;
        else cnt = 0;

        if(cnt == 3) yes = true;
    }

    if(yes) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, k, q;
    cin >> n >> k >> q;
    
    vector<int> point(n, k - q);
    
    int a;
    rep(i, q)
    {
        cin >> a;
        --a;
        ++point[a];
    }
    
    rep(i, n)
    {
        if (point[i] > 0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1024
import sys

s=input()
t=input()
s1,t1="",""

for i in range(len(s)):
  if i!=0:
    if s1[0]>=s[i]:
      s1=s[i]+s1
    
    else:
      s1+=s[i]
      
  else:
    s1=s[i]
    
for i in range(len(t)):
  if i!=0:
    if t1[0]<=t[i]:
      t1=t[i]+t1
    
    else:
      t1+=t[i]
      
    if t1>s1:
      print("Yes")
      sys.exit()
      
  else:
    t1=t[i]
    
print("No")  

Measured memory_bytes: 3064
/*input
31 41 59 265
*/

// Nihesh Anderson - knandy

#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;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key
ll MOD=998244353;

#define endl '\n'
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
ll INF = 2000000000000000001;
long double EPS = 1e-9;
ll power(ll a, ll n, ll md){if(n==0){return 1;}else{ll res=power(a,n/2,md);res=(res*res)%md;if(n%2!=0){res=(res*a)%md;}return res;}}
random_device rndm;
mt19937 grndm(rndm());
void mix(ll* a, ll* b){shuffle(a,b,grndm);}

const ll MX = 3005;

ll dp[MX][MX];
ll a, b, c, d; 

ll solve(ll x, ll y) {
	if(x == c && y == d) {
		return 1;
	}
	else if(x > c || y > d) {
		return 0;
	}
	if(dp[x][y] != -1) {
		return dp[x][y];
	}
	return dp[x][y] = (x * solve(x, y + 1) + y * solve(x + 1, y) - x * y * solve(x + 1, y + 1) + MOD * MOD) % MOD;
}

int main(){
	fast_cin();
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
	memset(dp, -1, sizeof(dp));
	cin >> a >> b >> c >> d;
	cout << solve(a, b) << endl;
	return 0;
}

Measured memory_bytes: 74560
N = int(input())
s = [int(input()) for i in range(N)]

s.sort()
A = sum(s)
if A%10 == 0:
  for i in s:
    if i%10 != 0:
      ans = A - i
      break
  else:
    ans = 0
else:
  ans = A
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <math.h>
#include <queue>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    int cnt=0;
    rep(i,n) {
        int di, dj;
        cin >> di >> dj;
        if(di==dj) cnt++;
        else cnt=0;
        if(cnt==3) break;
    }
    if(cnt>=3) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<string>

int dp[201][201][201];

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
    int k;
    std::cin >> k;
    long long sum = 0;
    for(int a = 1; a <= k; a++){
        for(int b = 1; b <= k; b++){
            for(int c = 1; c <= k; c++){
                if(dp[a][b][c] != 0){
                    sum += dp[a][b][c];
                }else if(dp[a][c][b] != 0){
                    sum += dp[a][c][b];
                }else if(dp[b][a][c] != 0){
                    sum += dp[b][a][c];
                }else if(dp[b][c][a] != 0){
                    sum += dp[b][c][a];
                }else if(dp[c][a][b] != 0){
                    sum += dp[c][a][b];
                }else if(dp[c][b][a] != 0){
                    sum += dp[c][b][a];
                }else{
                    int tmp = euclidean_gcd(a, b);
                    dp[a][b][c] = euclidean_gcd(tmp, c);
                    sum += dp[a][b][c];
                }
            }
        }
    }

    std::cout << sum << std::endl;

    return 0;
}


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

int main(){
	int a=0;
	string s;
	cin>>s;
	for(int i=1;i<s.size();i++){
		if(s[i]!='9'){
			a=9*(s.size()-1);
			a+=s[0]-'1';
			cout<<a;
			return 0;
		}
	}
	for(int i=0;i<s.size();i++) a+=s[i]-'0';
	cout<<a;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int a,b;
    
    while(cin >> a && a>0) {
    
        int max = 0;
        int min = 1000;
        int sum = 0;
        
        
        for (int i = 0; i < a; ++i) {
            cin >> b;
            sum += b;
            
            if (b > max) max = b;
            if (b < min) min = b;
        }
        
        int avg = (sum - max - min) / (a-2);
        
        cout << avg << endl;
        
    }
}

Measured memory_bytes: 3052
#include<iostream>
#include<cstdio>
using namespace std;
#include <vector>
int main() {
	int n;
	string s;
	int t=0;
	cin>>n>>s;
	string str=s;
	for(int i=0; i<n; i++) {
		if(s[i]=='(') {
			break;
		}else{
			str='('+str;
		}
	}
	s=str;
	for(int i=s.length()-1;i>=0;i--){
		if(s[i]==')'){
			break;
		}else{
			str+=')';
		}
	}
	s=str;
	for(int i=0;i<s.length();i++){
		if(s[i]=='('){
			t++;
		}else{
			t--;
		}
		if(t<0){
			t=0;
			str='('+str;
		}
	}
	s=str;
	for(int i=0;i<t;i++){
		s+=')';
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		int D = 25 - nextInt();
		String s = "Christmas";
		for(int i = 1; i <= D; i++){
			s += " Eve";
		}
		myout(s);

	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 36556
c = [list(map(int, input().split())) for _ in range(3)]
a = [0,0,0]
b = [0,0,0]
for i in range(3):
    b[i] = c[0][i]-a[0]
for i in range(1,3):
    a[i] = c[i][0]-b[0]
for x in range(3):
    for y in range(3):
        if c[x][y] != (a[x]+b[y]):
            print("No")
            break
    else:
        continue
    break
else:
    print("Yes")

Measured memory_bytes: 3064
import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))

# 負の数が奇数か偶数か
cnt = np.where(a < 0)[0].shape[0]
a = np.abs(a)

print(a.sum() if cnt % 2 == 0 else a.sum() - a.min() * 2)

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

int main() {
  int N, K, r;
  
  r = 1;
  cin >> N >> K;
  
  for (int i = 0; i < N; i++)
  {
    if( r + K < 2 * r)
    {
      r = r + K;
    }
    else
    {
      r *= 2;
    }
  }
  cout << r << endl;

}


Measured memory_bytes: 256
def main():
    N = int(input())
    t, x, y, = [0], [0], [0]
    for i in range(N):
        ti, xi, yi = [int(_) for _ in input().split(" ")]
        t.append(ti)
        x.append(xi)
        y.append(yi)

    flag = "Yes"
    for i in range(N):
        dt = t[i+1] - t[i]
        dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])

        if dt < dist or dt%2 != dist%2:
            flag = "No"

    print(flag)
main()


Measured memory_bytes: 11740
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
using namespace std;
int main(){
    int q;
    cin>>q;
    int l[114514]={};
    int r[114514]={};
    int prime[114514];
  for(int i=0;i<=100000;i++){
    prime[i]=1;
  }
    for(int i=0;i<q;i++){
        cin>>l[i]>>r[i];
    }
    for(int i=2;i<=100000;i++){
        if(prime[i]==1){
            for(int j=i+i;j<=100000;j+=i){
                prime[j]=0;
            }
        }
    }
    int c[114514]={};
    for(int i=3;i<=100000;i+=2){
        if((prime[i]==1)&&(prime[(i+1)/2]==1)){
          c[i]++;
        }
    }
  for(int i=3;i<=100000;i++){
    c[i]+=c[i-1];
  }
    for(int i=0;i<q;i++){
        cout<<c[r[i]]-c[l[i]-1]<<endl;
    }
}



Measured memory_bytes: 2304
N,M = map(int,input().split())
s = list(map(int,input().split()))

count = 0
al = sum(s)

for i in range(N):
  if not(s[i] < al / (4 * M)):
    count += 1
    
if count >= M:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 61860
// {{{
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#if __cplusplus >= 201103
#include <numeric>
#endif
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#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 REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()

//#if __cplusplus >= 201103
typedef long long ll;
//#endif
typedef pair<int, int> P;
typedef pair<int, P> IP;

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

const int INF = 100000000;
//#if __cplusplus >= 201103
const ll LINF = 10000000000000000ll;
//#endif
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
// }}}

string s, t;

void init()
{
}

void solve()
{
    reverse(ALL(s));
    reverse(ALL(t));
    int slen = s.size();
    int tlen = t.size();
    //P p = mp(-1, 0);
    int p = -1;
    REP(i, slen - tlen + 1){
        REP(j, tlen){
            if(s[i+j] != t[j] && s[i+j] != '?') goto next;
        }
        p = i;
        break;
next:
        ;
    }
    if(p == -1) cout << "UNRESTORABLE" << endl;
    else{
        REP(i, tlen){
            s[p+i] = t[i];
        }
        REP(i, slen){
            s[i] = (s[i] == '?' ? 'a' : s[i]);
        }
        reverse(ALL(s));
        cout << s << endl;
    }
#if 0
    REP(i, tlen){
        int pos = 0;
        while(true){
            pos = s.find(t[i], pos);
            if(pos == string::npos) break;
            if(pos < i) goto next;
            REP(j, tlen){
                if(s[pos-i+j] != t[j] && s[pos-i+j] != '?') goto next;
            }
            p = pos - i;mp(pos, i);
            break;
next:
            pos++;
        }
        if(p.fi != -1) break;
    }
    string q;
    REP(i, tlen) q += "?";
    int pos = s.find(q);
    if(pos != string::npos && pos < p.fi - p.se) p = mp(pos, 0);
    if(p.fi == -1){
        cout << "UNRESTORABLE" << endl;
    }else{
        REP(i, tlen){
            s[p.fi-p.se+i] = t[i];
        }
        REP(i, slen){
            if(s[i] == '?') s[i] = 'a';
        }
        reverse(ALL(s));
        cout << s << endl;
    }
#endif
}

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

// vim:set foldmethod=marker:


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }



int main() {
	IOS;
	int k, n;
	cin >> n >> k;
	vector<int> p(n);
	vector<double> d(n);
	REP(i, n) {
		cin >> p[i];
		d[i] = (double)(1 + p[i]) / 2;
	}
	double res = 0;
	double tmp = 0;
	REP(i, k) {
		tmp += d[i];
	}
	chmax(res, tmp);
	REP(i, n - k) {
		tmp -= d[i];
		tmp += d[i + k];
		chmax(res, tmp);
	}
	cout << setprecision(20) << res << endl;
	return 0;
}



Measured memory_bytes: 2560
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(s: str):
    print(" ".join(s.split(",")))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    solve(s)


if __name__ == '__main__':
    main()


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

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

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) ((x).begin()), ((x).end())

#define READ(x) (cin >> (x))
#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))
#define WRITE_YESNO(x) (WRITE_N((x) ? "Yes" : "No"))

#define PRECISE_COUT std::cout << std::setprecision(15) << std::fixed

bool xor_logic(bool x, bool y) { return (x && y) || (!x && !y); }

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N, K;
  cin >> N >> K;

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

  // main procedure
  // output
  for (size_t i = K; i < N; i++) {
    cout << ((A[i] > A[i - K]) ? "Yes" : "No") << endl;
  }

  return 0;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n; cin>>n;
    int x=0,y=0,z=0;
    for(int i=0;i<n;i++){
        int a; cin>>a;
        if(a%4==0)x++;
        else if(a%2==0)y++;
        else z++;
    }
    pair<int,int> dp[n][3];
    if(x>0)dp[0][0]=make_pair(x-1,y);
    else dp[0][0]=make_pair(-INF,-INF);
    if(y>0)dp[0][1]=make_pair(x,y-1);
    else dp[0][1]=make_pair(-INF,-INF);
    dp[0][2]=make_pair(x,y);
    for(int i=1;i<n;i++){
        dp[i][0]=max({dp[i-1][0],dp[i-1][1],dp[i-1][2]});
        if(dp[i][0].first<=0)dp[i][0]=make_pair(-INF,-INF);
        else dp[i][0].first--;
        if(dp[i-1][0].second>0&&dp[i-1][1].second>0){
            dp[i][1]=max(dp[i-1][0],dp[i-1][1]);
            dp[i][1].second--;
        }else if(dp[i-1][0].second>0&&dp[i-1][1].second<=0){
            dp[i][1]=dp[i-1][0];
            dp[i][1].second--;
        }else if(dp[i-1][0].second<=0&&dp[i-1][1].second>0){
            dp[i][1]=dp[i-1][1];
            dp[i][1].second--;
        }else{
            dp[i][1]=make_pair(-INF,-INF);
        }
        dp[i][2]=dp[i-1][0];
    }
    bool ok=false;
    for(int i=0;i<=2;i++){
        if(dp[n-1][i].first>=0&&dp[n-1][i].second>=0)ok=true;
    }
    cout<<(ok?"Yes":"No")<<endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1<<29;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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







int main(int argc, const char * argv[]) {
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    map<ll,ll> A{};
    for (int i = 0; i < n; i++) {
        ll a; cin >> a;
        if (A.count(a)) A[a]++;
        else A.insert(make_pair(a,1));
    }
    
    ll Ans = 0;
    for (auto it = A.begin(); it != A.end(); it++) {
        if(it->first == it->second) continue;
        else if(it->first < it->second) Ans += ((it->second) - (it->first));
        else Ans += it->second;
    }
    
    cout << Ans << endl;
    
}



Measured memory_bytes: 6272
//BISMILLAH
#include <bits/stdc++.h>
using namespace std;
int main(){
    int minn = INT_MAX;
    string s,t;
    int i,j,len,len2,p,cnt = 0;
    cin >> s >> t;
    len = s.size();
    len2 = t.size();
    for(i = 0;i<=(len - len2);i++){
        p = i;
        for(j = 0;j<len2;j++){
            if(t[j] != s[p++]) cnt++;
        }
        minn = min(minn,cnt);
        cnt = 0;
    }
      cout << minn << endl;
    return 0;
}

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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

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

   int a=7%k;
   int b=a;
   int cnt=1;
   rep(_, 2000000){
      if(a%k==0) break;
      b=((ll)b*(10%k))%k;
      a=(a+b)%k;
      cnt++;
   }

   if(cnt!=2000001) cout<<cnt<<endl;
   else cout<<(-1)<<endl;
   return 0;
}


Measured memory_bytes: 3584
#!/usr/bin/env python3

import itertools


def judge(n):
    for a, b in itertools.product(range(1, 10), repeat=2):
        if a * b == n:
            return True
    else:
        return False


def main():
    n = int(input())
    print("Yes" if judge(n) else "No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
    int a,b,c,k;
    cin >> a>> b >> c >> k;

    int x = max(max(a,b),c);
    int sol = 0;
    for(int i = 1; i <= k; i++)
    {
        x *= 2;
    }
    sol += x;
    sol += a+b+c;
    sol -= max(max(a,b),c);
    cout << sol <<endl;

    return 0;
}

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

int main() {
	int h, w;
	cin >> h >> w;
	char a[100][100];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
		}
	}

	int b[100];
	int p = 0;
	int count = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				b[p] = i;
				p++;
				count++;
				break;
			}
		}
	}

	int c[100];
	int q = 0;
	int counta = 0;
	for (int i = 0; i < w; i++) {
		for (int j = 0; j < h; j++) {
			if (a[j][i] == '#') {
				c[q] = i;
				q++;
				counta++;
				break;
			}
		}
	}

	for (p = 0; p < count;p++) {
		for (q = 0; q < counta;q++) {
			cout << a[b[p]][c[q]];
		}
		cout << endl;
	}

	return 0;
}

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

// Vector 2D
template<class T>
struct Vec2D
{
    T x,y;
    explicit Vec2D(T x_=T(), T y_=T()):x(x_),y(y_){}
    Vec2D(const std::pair<T,T>& p):x(p.first),y(p.second){}
    Vec2D& operator+=(const Vec2D& v){ return *this = *this+v; }
    Vec2D& operator-=(const Vec2D& v){ return *this = *this-v; }
    friend Vec2D operator+(const Vec2D& l, const Vec2D& r){ return Vec2D(l.x+r.x,l.y+r.y); }
    friend Vec2D operator-(const Vec2D& l, const Vec2D& r){ return Vec2D(l.x-r.x,l.y-r.y); }
    friend T norm(const Vec2D& v){ return std::hypot(v.x,v.y); }
    friend T norm2(const Vec2D& v){ return v.x*v.x+v.y*v.y; }
    friend T dot(const Vec2D& l, const Vec2D& r){ return l.x*r.x+l.y*r.y; }
    friend T cross(const Vec2D& l, const Vec2D& r){ return l.x*r.y-l.y*r.x; }
    friend int dir(const Vec2D& l, const Vec2D& r)
    {
        // assert(norm2(l)!=0);
        const auto c = cross(l,r);
        if(c>0) return 1;
        if(c<0) return -1;
        if(dot(l,r)<0) return -2;
        if(norm2(l)<norm2(r)) return 2;
        return 0;
    }
};

// Triangle 2D
template<class T=double>
class Triangle2D
{
    Vec2D<T> a,b,c;
public:
    explicit Triangle2D(T ax=T(), T ay=T(), T bx=T(), T by=T(), T cx=T(), T cy=T()):a(ax,ay),b(bx,by),c(cx,cy){}
    Triangle2D(const Vec2D<T>& a_, const Vec2D<T>& b_, const Vec2D<T>& c_):a(a_),b(b_),c(c_){}
    T area() const
    {
        return std::abs(a.x*(b.y-c.y)+b.x*(c.y-a.y)+c.x*(a.y-b.y))/2;
    }
    T dist_a() const { return norm(b-c); }
    T dist_b() const { return norm(c-a); }
    T dist_c() const { return norm(a-b); }
    Vec2D<T> circumcenter() const
    {
        const Vec2D<T> vb(2*(b.x-a.x),2*(c.x-a.x)),
                       vc(2*(b.y-a.y),2*(c.y-a.y)),
                       vd(norm2(a)-norm2(b),norm2(a)-norm2(c));
        return Vec2D<T>(cross(vc,vd)/cross(vb,vc),
                        cross(vd,vb)/cross(vb,vc));
    }
    T R() const { return dist_a()*dist_b()*dist_c()/(4*area()); }
};

static void solve()
{
    typedef double F;
    F x1,y1,x2,y2,x3,y3; std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    const Triangle2D<F> tri(x1,y1,x2,y2,x3,y3);
    auto c = tri.circumcenter();
    std::cout << c.x << " " << c.y << " " << tri.R() << std::endl;
}

int main()
{
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(3);
    int n; std::cin >> n;
    for(int i=0; i<n; ++i) solve();
}

Measured memory_bytes: 1316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(x) (int)(x).size()
#define endl '\n'
#define FOR(a, b, c) for (auto a = (b); (a) < (c); ++(a))
#define F0R(a, b) FOR (a, 0, (b))
#define CEIL(a, b) ((a) + (b)-1) / (b)
template <class T>
bool ckmin(T& a, const T& b) {
  return a > b ? a = b, true : false;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, true : false;
}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
  if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << mt(__VA_ARGS__) << "] "
template <typename T>
struct IsC {
  template <typename C>
  static char test(typename C::const_iterator*);
  template <typename C>
  static int test(...);
  static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <>
struct IsC<string> {
  static const bool value = false;
};
template <typename C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(ostream&, const C&);
template <typename T1, typename T2>
ostream& operator<<(ostream&, const pair<T1, T2>&);
template <typename... T> using TS = tuple_size<tuple<T...>>;
template<size_t idx, typename... T>
typename enable_if<TS<T...>::value == idx + 1, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return o << ", " << get<idx>(t) << ')';
}
template<size_t idx, typename... T>
typename enable_if<0 < idx && idx + 1 < TS<T...>::value, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return operator<<<idx + 1>(o << ", " << get<idx>(t), t);
}
template<size_t idx = 0, typename... T>
typename enable_if<1 < TS<T...>::value && !idx, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return operator<<<idx + 1>(o << '(' << get<idx>(t), t);
}
template<typename T>
ostream& operator<<(ostream& o, const tuple<T>& t) {
  return o << get<0>(t);
}
template <typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p) {
  return o << mt(p.fi, p.se);
}
template <typename C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(
    ostream& o, const C& c) {
  o << '[';
  for (auto it = c.cbegin(); it != c.cend(); ++it)
    o << *it << (next(it) != c.cend() ? ", " : "");
  return o << ']';
}
template <typename T>
void tprint(vector<vector<T>>& v, size_t width = 0, ostream& o = cerr) {
  if (!DEBUG) return;
  for (const auto& vv : v) {
    for (const auto& i : vv) o << setw(width) << i;
    o << endl;
  }
}

int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0); cin.tie(0);

  int n; cin >> n;
  cout << (n >= 30 ? "Yes" : "No") << endl;
  
  return 0;
}


Measured memory_bytes: 3596
#include <stdio.h>

int main(void) {
    char S[4];
    int i ,result;
    result = 0;
    scanf("%s",S);
    if(S[0] == S[1]) result++;
    if(S[0] == S[2]) result++;
    if(S[0] == S[3]) result++;
    if(S[1] == S[2]) result++;
    if(S[1] == S[3]) result++;
    if(S[2] == S[3]) result++;
    
    if(result == 2) printf("Yes\n");
    else printf("No\n");
    
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String h = scanner.nextLine();
		
		String[]temp =h.split(" ");
		int W = Integer.parseInt(temp[0]);
		int H = Integer.parseInt(temp[1]);
		
		
		while((300 >= W  && 1 <= W )&&(300>= H  &&1 <= H )){
			
			for (int x=0;x<W;x++){
				for (int y=1;y<H;y++){
					System.out.print("#");}
					System.out.println("#");}
			 System.out.println("");
			  h = scanner.nextLine();
				
				String[]temp1 =h.split(" ");
			 W = Integer.parseInt(temp1[0]);
			 H = Integer.parseInt(temp1[1]);
			}
	}
}

Measured memory_bytes: 36528
from sys import stdin
input = stdin.readline


def main():
  N = int(input())
  # set_ = set(['AC', 'WA', 'TLE', 'RE'])
  # cnt = 0
  AC = 0
  WA = 0
  TLE = 0
  RE = 0
  for i in range(N):
    j = input()[:-1]
    if j == 'AC':
      AC += 1
    elif j == 'WA':
      WA += 1
    elif j == 'TLE':
      TLE += 1
    elif j == 'RE':
      RE += 1

  print('AC', 'x', AC)
  print('WA', 'x', WA)
  print('TLE', 'x', TLE)
  print('RE', 'x', RE)


if(__name__ == '__main__'):
  main()

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

using namespace std;

int main()
{int n;cin>>n;
    string s;int c=0;
    cin>>s;
    for(int i=0;i<n;i++)
    {
        if(s[i]!=s[i-1])
        c++;

    }cout<<c<<endl;

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
#include <numeric>
#include <queue>
#include <set>

#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;

int main(int argc, char const *argv[])
{
  ll n;
  cin >> n;
  vector<ll> a(n);
  vector<pair<ll, ll>> ope;
  ll res;
  REP(i, n)
  {
    cin >> a[i];
  }
  sort(ALL(a));
  if (a[0] >= 0)
  {
    ll tmp = a[0];
    for (int i = 1; i < a.size() - 1; i++)
    {
      ope.push_back({tmp, a[i]});
      tmp -= a[i];
    }
    ope.push_back({a[a.size() - 1], tmp});
    res = a[a.size() - 1] - tmp;
  }
  else if (a[a.size() - 1] < 0)
  {
    ll tmp = a[a.size() - 1];
    for (int i = a.size() - 2; i >= 0; i--)
    {
      ope.push_back({tmp, a[i]});
      tmp -= a[i];
    }
    res = tmp;
  }
  else
  {
    ll maxi = a[a.size() - 1];
    ll mini = a[0];
    for (int i = 1; i < a.size() - 1; i++)
    {
      if (a[i] < 0)
      {
        ope.push_back({maxi, a[i]});
        maxi -= a[i];
      }
      else
      {
        ope.push_back({mini, a[i]});
        mini -= a[i];
      }
    }
    ope.push_back({maxi, mini});
    res = maxi - mini;
  }
  cout << res << endl;
  for (auto o : ope)
  {
    cout << o.first << " " << o.second << endl;
  }
  return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int n;
string s, t;
bool f(ll sx, ll w, char back, char next) {
  ll ngl = sx, ngr = sx;
  bool ok = true;
  for (int i = 0; i < n; i++) {
    if (s[i] == next) {
      ngr += 1;
    } else if (s[i] == back) {
      ngl -= 1;
    }
    if (ngr > w || ngl < 1) {
      ok = false;
    }
    if (t[i] == next) {
      ngl += 1;
    } else if (t[i] == back) {
      ngr -= 1;
    }
    ngr = max(ngr, 1LL);
    ngl = min(ngl, w);
    if (ngr > w || ngl < 1) {
      ok = false;
    }
  }
  return ok;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int h, w, sx, sy;
  cin >> h >> w >> n >> sy >> sx;
  cin >> s >> t;
  if (f(sx, w, 'L', 'R') && f(sy, h, 'U', 'D')) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


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

int n, m;
pair<int, int> requests[100100];
bool bridges[100100] = {true};
int ans = 0;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
  if(a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

bool is_achieved(int r) {
  int a = requests[r].first;
  int b = requests[r].second;
  for (int i = a; i < b; i++) {
    if (bridges[i] == false) return true;
  }
  return false;
}

int main () {
  cin >> n >> m;
  for (int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    requests[i] = make_pair(a, b);
  }

  sort(requests, requests + m, compare_by_b);

  int last = -1;

  for (int i = 0; i < m; i++) {
    if (requests[i].first > last) {
      last = requests[i].second - 1;
      ans++;
    }
  }

  cout << ans << endl;

}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
//const int mod = 100000;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
// h(n, r) = c(n+r-1, r)
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
    fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
    ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
    return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main()
{
  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll ans = a[0];
  rep(i, n) ans = __gcd(ans, a[i]);
  cout << ans << endl;
}

Measured memory_bytes: 4032
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);cout<<"\n";};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts> auto make_v(size_t a,Ts... ts){   return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }
template<typename T,typename U,typename... V> typename enable_if<is_same<T, U>::value!=0>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V> typename enable_if<is_same<T, U>::value==0>::type fill_v(U &u,const V... v){ for(auto &e:u) fill_v<T>(e,v...);}
//FUNCTION  


void solve(void)
{

  int N,M,K;
  cin>>N>>M>>K;
  int S =N*M;
  set<int> SET;
  for (int i = 0; i < N; i++)
  {
    static int D = N;
    for (int j = 0; j <= M; j++)
    {
      SET.insert(S - j*D);
    }
    S -= M;
    D -= 2;
  }
  if(SET.find(K) != SET.end())
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
  

  
  return;
}
  
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 13056