akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE
  ScopedTypeVariables, BangPatterns, TupleSections, ExplicitForAll,
  LambdaCase, MultiWayIf, Unsafe, RecordWildCards, FlexibleContexts, CPP,
  NoMonomorphismRestriction, GADTs,
  RankNTypes, EmptyDataDecls, EmptyCase, ViewPatterns #-}


import Data.Bits
import Data.List
import Data.Maybe
import Data.Tuple
import Data.Ord
import Data.Int
import Data.Word
import Data.Function
import Data.STRef
import Data.IORef
import System.IO
import Control.Applicative
import Control.Monad
import Control.Monad.Primitive
import Control.Monad.State.Strict
import Control.Monad.ST
-- import Control.Monad.ST.Safe
import Control.DeepSeq
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BSL
import Data.IntMap (IntMap)
import qualified Data.IntMap.Strict as IMS
import qualified Data.IntMap.Lazy as IML
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
import qualified Data.Sequence as Seq
import Data.Sequence (Seq)
import qualified Data.Array.IArray as A
import qualified Data.Array.MArray.Safe as A
import qualified Data.Array.MArray as A
import Data.Array (Array)
import Data.Array.Unboxed (UArray)
import Data.Array.IArray (IArray)
import Data.Array.MArray.Safe (MArray)
import Data.Array.IO.Safe (IOArray, IOUArray)
import Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Vector.Primitive as VP
import qualified Data.Vector.Primitive.Mutable as VPM
import qualified Data.Vector.Generic as VG
import qualified Data.Vector.Generic.Mutable as VGM

main :: IO ()
main = do
  [a,b] <- map readInt . words <$> getLine
  print $ if b `mod` a == 0 then a + b else b - a 


rInt :: StateT BSL.ByteString Maybe Int
rInt = StateT $ BSL.readInt . BSL.dropWhile (<'!')

#define D(f,r,d) f::Integral a=>a->d;f=fromIntegral;r::String->d;r=read
#define C(f,r,g,h,d) D(f,r,d);g,h::RealFrac a=>a->d;g=floor;h=ceiling
C(_toInteger_,readInteger,floorInteger,ceilInteger,Integer)
C(toInt,readInt,floorInt,ceilInt,Int)
C(toI8,readI8,floorI8,ceilI8,Int8)
C(toI16,readI16,floorI16,ceilI16,Int16)
C(toI32,readI32,floorI32,ceilI32,Int32)
C(toI64,readI64,floorI64,ceilI64,Int64)
C(toWord,readWord,floorWord,ceilWord,Word)
C(toW8,readW8,floorW8,ceilW8,Word8)
C(toW16,readW16,floorW16,ceilW16,Word16)
C(toW32,readW32,floorW32,ceilW32,Word32)
C(toW64,readW64,floorW64,ceilW64,Word64)
D(toDouble,readDouble,Double)
D(toFloat,readFloat,Float)
#undef D
#undef C


#define N(f,g,a,m)\
  f :: forall e i s. (C(a,m)A.Ix i) => (i,i) -> e -> m (a i e); f=A.newArray;\
  g :: forall e i s. (C(a,m)A.Ix i) => (i,i) -> m (a i e); g=A.newArray_
#define C(a,m)
N(newIOA,newIOA_,IOArray,IO)
N(newSTA,newSTA_,STArray s,ST s)
#undef C
#define C(a,m) MArray (a) e (m), 
N(newIOUA,newIOUA_,IOUArray,IO)
N(newSTUA,newSTUA_,STUArray s,ST s)
#undef C
#undef N



Measured memory_bytes: 508
#include<stdio.h>

int main(){
	int i[10], j, k, swap;
	for(j = 0; j <= 9; j++){
		while(1){
			scanf("%d",&i[j]);
			if(0 <= i[j] && i[j] <=10000)break;
		}
	}
	for(k = 0; k <= 9; k++){
		for(j = k + 1; j <= 9; j++){
			if(i[j] >= i[k]){
				swap = i[k];
				i[k] = i[j];
				i[j] = swap;
			}
		}
	}
	for(j = 0; j <= 2; j++){
		printf("%d\n", i[j]);
	}
    return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> l(N);
    for (int i = 0; i < N; ++i) {
        cin >> l[i];
    }
    sort(l.begin(), l.end(), greater<int>());
    int sum = 0;
    for (int i = 0; i < K; ++i) {
        sum += l[i];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    int e = sc.nextInt();
    int k = sc.nextInt();

      if(b-a<=k && c-a<=k && d-a<=k && e-a<=k && c-b<=k && d-b<=k && e-b<=k && d-c<=k && e-c<=k && e-d<=k){
 	System.out.println("Yay!");
      }else{
	System.out.println(":(");        
      }
      }
}

Measured memory_bytes: 22868
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define MOD 1000000007
#define MAX 1000005
#define loop(i,a,b) for(long long int i=a;i<b;i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
typedef long long int ll;

using namespace std;
//using namespace boost::multiprecision;

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

ll n;
cin>>n;

double pi = 3.1415926535897;
cout<<2*pi*n<<"\n";



return 0;
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
#define N 1010
#define M 200010
vector <int> G[N];
int to[M],tag[N],q[2*N];
bool ans1[M],ans2[M];
int read(){
	int x=0,f=1;
	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;
}
signed main(){
	int n=read(),m=read();
	for (int i=1;i<=m;++i){
		int x=read();to[i]=read();
		G[x].push_back(i);
	}
	for (int i=1;i<=n;++i){
		for (int j=1;j<=n;++j) tag[j]=0;
		int t=1,w=0;
		for (auto &x:G[i]){
			q[++w]=to[x];tag[to[x]]=x;
		}
		while (t<=w){
			int x=q[t++],y=tag[x];
			for (auto &p:G[x]){
				int tmp=to[p];
				if (tmp!=i){
					if (tag[tmp]!=-1){
						if (tag[tmp]==0){
							q[++w]=tmp;tag[tmp]=y;
						}else if (tag[tmp]!=y){
							q[++w]=tmp;tag[tmp]=-1;
						}
					}
				}else ans1[p]=1;
			}
		}
		for (auto &x:G[i]){
			if (tag[to[x]]==-1) ans2[x]=1;
		}
	}
	for (int i=1;i<=m;++i) puts(ans1[i]^ans2[i]?"diff":"same");
	return 0; 
}

Measured memory_bytes: 3968
//**************************
//*** writer  :  Alex Hu **
//************************

#include<bits/stdc++.h>

using namespace std;

#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mkp make_pair
#define pb push_back
#define rept(i,a,b) for(int i=(int)(a);i<(int)(b);i++)

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int maxn=1e5+10;

int n,m;
int ghead[maxn],gnxt[2*maxn],gto[2*maxn];
int nq;
int qx[maxn],qd[maxn],qc[maxn];

int been[maxn];
int col[maxn];

void dfs(int at,int d,int c)
{
	if (been[at]>=d) return;
	else been[at]=d;
	if (col[at]==0) col[at]=c;
	if (d>0)
	{
		for (int x=ghead[at];x!=-1;x=gnxt[x]) dfs(gto[x],d-1,c);
	}
}

void run()
{
	scanf("%d%d",&n,&m);
	rept(i,0,n) ghead[i]=-1;
	rept(i,0,m)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		a--;
		b--;
		gnxt[2*i]=ghead[a];
		ghead[a]=2*i;
		gto[2*i]=b;
		gnxt[2*i+1]=ghead[b];
		ghead[b]=2*i+1;
		gto[2*i+1]=a; 
	}
	scanf("%d",&nq);
	rept(i,0,nq)
	{
		scanf("%d%d%d",&qx[i],&qd[i],&qc[i]);
		qx[i]--;
	}
	CLEAN(been,-1);
	CLEAN(col,0);
	for (int i=nq-1;i>=0;i--) dfs(qx[i],qd[i],qc[i]);
	rept(i,0,n) printf("%d\n",col[i]);
}

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

Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
int main() {
  int k;
  cin >> k;
  string str;
  cin >> str;
  int a = str.size();
  if (a<=k) {
    cout << str << endl;
  }
  else {
     for ( int i = 0 ; i < k ; i++ ) {
       cout << str.at(i);
     }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int n, m;
	cin >> n >> m;
	int nodenum = n;
	vector<vector<pair<int, int> > > graph(n);
	map<pair<int, int>, int> ekiAndLineToNode;

	for(int i = 0; i < m; i++){
		int p, q, c;
		cin >> p >> q >> c;
		p--;
		q--;
		if(ekiAndLineToNode.find(make_pair(p, c)) == ekiAndLineToNode.end()){
			ekiAndLineToNode[make_pair(p, c)] = nodenum;
			graph.push_back(vector<pair<int, int> >());
			nodenum++;
		}
		if(ekiAndLineToNode.find(make_pair(q, c)) == ekiAndLineToNode.end()){
			ekiAndLineToNode[make_pair(q, c)] = nodenum;
			graph.push_back(vector<pair<int, int> >());
			nodenum++;
		}
		int pind = ekiAndLineToNode[make_pair(p, c)];
		int qind = ekiAndLineToNode[make_pair(q, c)];
		graph[pind].push_back(make_pair(qind, 0));
		graph[qind].push_back(make_pair(pind, 0));
		graph[pind].push_back(make_pair(p, 1));
		graph[p].push_back(make_pair(pind, 0));
		graph[qind].push_back(make_pair(q, 1));
		graph[q].push_back(make_pair(qind, 0));
	}
	priority_queue<pair<int, int> > qu;
	vector<int> result(nodenum, mod);
	qu.push(make_pair(0, 0));
	while(!qu.empty()){
		int node = (qu.top()).second;
		int cost = -(qu.top()).first;
		qu.pop();
		if(result[node] <= cost) continue;
		result[node] = cost;
		for(int i = 0; i < graph[node].size(); i++){
			int next = graph[node][i].first;
			int nextcost = -(graph[node][i].second + cost);
			qu.push(make_pair(nextcost, next));
		}
	}
	if(result[n - 1] == mod) cout << -1 << endl;
	else cout << result[n - 1] << endl;
}

Measured memory_bytes: 62056
num = gets.chomp.to_i
arr = []
num.times do
  arr << gets.chomp.to_i
end

max = 0
max_index = 0
nmax = 0
arr.each_with_index do |num, i|
  if num >= nmax
    nmax = num
  end
  if num >= max
    nmax = max
    max = num
    max_index = i
  end
end

arr.length.times do |i|
  p max_index == i ? nmax : max
end

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

using namespace std;

const int nr = 1000 * 1000 * 1000 + 7;

int main()
{
	int h, w;
	cin >> h >> w;
	vector<vector<long long> > dp(h + 1, vector<long long>(w + 1, 0));
	vector<string> a(h + 1,  string(w + 1, '.'));

	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			char c;
			cin >> c;
			a[i][j] = c;
		}
	}

	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (a[i][j] == '.') {
				if (i == 1 && j == 1) {
					dp[i][j] = 1;
				} else {
					dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
					dp[i][j] = dp[i][j] % nr;
 				}
			}
		}
	}

	//cout << nr << endl;
	cout << dp[h][w] % nr;
	return 0;
}

Measured memory_bytes: 9088
#include <iostream>
#include <stdio.h>
#include <cctype>
using namespace std;

int main(void){
  string s;
  int n,h,t=0;
  char tmp[200];
  while(1){
    cin >> s;
    if(s=="-") break;
    cin >> n;
    for(int i=0;i<n;i++){
      cin >> h;
      t=0;
      for(int j=0;j<s.size();j++){
        if(h+j<(s.size())) {
          tmp[j]=s[h+j];
        }
        else {
          tmp[j]=s[t++];
        }
      }
      for(int j=0;j<s.size();j++){
        s[j]=tmp[j];
      }
    }
    cout << s << endl;
  }
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    string s;
    string trans;
    cin >> s;
    int n = s.size();
    vector<int> label(n, 0);
    for(int i = 0; i < n; i++) {
        if (s[i] == 'B' && (i+1 < n && s[i+1] == 'C')) {
            label[i+1] = 1;
        }
    }
    int valid_cnt = 0;
    ll ans = 0;
    for(int i = n-1; i >= 0; i--) {
        if (label[i] == 1 || s[i] == 'A') {
            if (label[i] == 1) {
                valid_cnt += 1;
                i -= 1;
            } else if (s[i] == 'A') {
                ans += valid_cnt;
            }
        } else {
            valid_cnt = 0;
        }
    }
    cout << ans << endl;

    return 0;
}




Measured memory_bytes: 1428
#include<iostream>
#include<string>
using namespace std;
string x;
int sum,ans;
int main()
{
	cin>>x;
	int len=x.length();
	ans=len;
	for(int i=0;i<len;i++)
	{
		if(x[i]=='S')
		  sum++;
		else
		{
			sum--;
			if(sum>=0)
			  ans-=2;
			else sum=0;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
#ifdef ConanYu
#include "local.hpp"
#else
#pragma GCC optimize("-O3")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#define debug(...) do { } while (false)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main(); return 0;
}
#endif

void Main() {
  string s; cin >> s;
  bool a = false, b = false;
  for(int i = 0; i < 3; i++) {
    if(s[i] == 'A') a = true;
    else b = true;
  }
  cout << (a && b ? "Yes\n" : "No\n");
}

Measured memory_bytes: 256
#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 pair<int,int> PII;
typedef long long int ll;
typedef pair< ll,ll> PLL;
typedef unsigned long long int ULL;
typedef pair<ULL,int> PUI;
#define S second
#define F first
typedef tree<
PLL,
null_type,
less<PLL>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;


PLL operator+(PLL a,PLL b){ return {a.first + b.first, a.second + b.second}; }
PLL operator-(PLL a,PLL b){ return {a.first - b.first, a.second - b.second}; }
PLL operator*(PLL a,PLL b){ return {a.first * b.first, a.second * b.second}; }
PLL operator/(PLL a,PLL b){ return {a.first / b.first, a.second / b.second}; }
PLL operator%(PLL a,PLL b){ return {( b.first + a.first) % b.first, (b.second + a.second) % b.second}; }
PLL operator%(PLL a,ll b){ return {a.first % b, a.second % b} ;}
PLL operator+(PLL a,ll b){ return {a.first + b, a.second + b} ;}
PLL operator-(PLL a,ll b){ return {a.first - b, a.second - b} ;}
PLL operator*(PLL a,ll b){ return {a.first * b, a.second * b} ;}

ostream& operator<<(ostream &out,PLL a)
{
    out << "( " << a.first << ", " << a.second << " )" ;
    return out;
}

ostream& operator<<(ostream &out,PUI a)
{
    out << "( " << a.first << ", " << a.second << " )" ;
    return out;
}
/*
	Order Statistics Tree ( OST )

	find_by_order()
		takes an integer k and returns an iterator to the k'th largest element counting from zero
	order_of_key()
		takes an element, here an integer and returns the number of elements strictly smaller than input
*/


int const MOD = 1e9 + 7;

int const N = 1e5 + 10;
bool mark[N] ;

void sieve()
{
    for(int i = 2; i < N; i++){
        if(!mark[i]){
            for(int j = 2 * i ; j < N; j += i) 
                mark[j] = 1;
        }
    }
}
vector < int > v[100];

ll dd(int i,int j)
{
    ll ret = 0;
    for(int x = 0; x < v[i].size(); x++){
        ret += (v[i][x] - v[j][x]) * (v[i][x] - v[j][x]);
    }
    return ret;
}

int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    
    ll ans = 2030;
    ll l,r;
    cin >> l >> r;
    ll t1 = -1,t2 = -1;
    
    for(ll i = l; i <= min(r,l+2019); i++){
        for(ll j = i+1; j <= min(r,l+2019); j++){
            ll tmp = (i*j) % 2019;
            if(tmp < ans){
                ans = tmp;
                t1 = i, t2 = j;
            } 
        }
    }
    cout << ans << endl;
    //cout << t1 << " " << t2 << endl;
    return 0;

}

Measured memory_bytes: 256
# D - RGB Triplets
from collections import defaultdict


def main():
    _, S = open(0).read().split()
    indices, doubled_indices = defaultdict(list), defaultdict(set)
    for i, c in enumerate(S):
        indices[c].append(i)
        doubled_indices[c].add(2 * i)
    cnt = len(indices["R"]) * len(indices["G"]) * len(indices["B"])
    for x, y, z in ["RGB", "GBR", "BRG"]:
        cnt -= sum(i + j in doubled_indices[z] for i in indices[x] for j in indices[y])
    print(cnt)


if __name__ == "__main__":
    main()


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

int main() {
  int N, A, countMin, count;
  cin >> N;
  countMin = 999;
  count = 0;
   
  for (int i = 0; i < N; i++) {
    cin >> A;
    count = 0;
    while (A % 2 == 0) {
      A /= 2;
      count++;
    }
    if (count < countMin)
      countMin = count;
  } 
  
  cout << countMin << endl;
}


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

s = []
for i in range(N):
    s.append(list(map(int, input().split())))

c = []
for j in range(M):
    c.append(list(map(int, input().split())))

for t1 in s:
    l = list(map(lambda x: abs(t1[0] - x[0]) + abs(t1[1] - x[1]), c))
    print(l.index(min(l)) + 1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll N = 500030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    998244353;
ll p1[4005],p2[4005],p3[4005];
string s;
int n;

int main()
{  fast
cin>>n;
ll ans=0;
 cin>>s;

 for(int i=n-1;i>=0;i--)
 {
 	p1[i]=(s[i]=='R');
 	p2[i]=(s[i]=='G');
 	p3[i]=(s[i]=='B');
 	p1[i]+=p1[i+1];
 	p2[i]+=p2[i+1];
 	p3[i]+=p3[i+1];
 	
 }
 for(ll i=0;i<n;i++)
 {
	if(s[i]=='R')
	ans+=p2[i]*p3[i];
	else if(s[i]=='G')
	ans+=p1[i]*p3[i];
	else
	ans+=p1[i]*p2[i];

 }
for(ll len=1;len<=n;len++)
{
	ll x=0;
	ll y=x+len;
	ll z=y+len;
	while(z<n)
	{
	
		if((s[x]!=s[y])&&(s[y]!=s[z])&&(s[x]!=s[z]))
		ans--;
		z++;
		x++;
		y++;
	}
	
}
cout<<ans;


}


Measured memory_bytes: 3748
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
const int INF=1e9;

ll gcd(ll x,ll y){
    if(y==0) return x;
    return gcd(y,x%y);
}

int main(){
    ll n,m;cin>>n>>m;
    string s,t;
    cin>>s>>t;
    int i=0,j=0;
    ll g=gcd(n,m);
    while(i<n&&j<m){
        if(s[i]!=t[j]){
            cout<<-1<<endl;
            return 0;
        }
        i+=n/g;
        j+=m/g;
    }
    cout<<(n*m)/g<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
#define MAXN 200000
#define LL long long
#define INF 1000000000000000000
int n,top;
char s[MAXN+5],stk[MAXN+5];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='T')
		{
			if(stk[top]=='S')top--;
			else stk[++top]='T';
		}
		else stk[++top]='S';//
	}
	printf("%d",top);
}

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

using ll = long long;
using pii = pair<int, int>;

template<class T>
using max_heap = priority_queue<T>;
template<class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 50);

const string YES = "Yes";
const string NO = "No";
void solve(long long H, long long N, std::vector<long long> A){
    ll ans = 0;
    rep(i, N) ans += A[i];
    cout << (ans >= H ? YES: NO) << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    long long H;
    scanf("%lld",&H);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(H, N, std::move(A));
    return 0;
}


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

int main(){
    int N,K;
    cin >> N;
    vector<int> P(N);
    for(int i=0;i<N;i++){
        cin >> P[i];
    }
    int ans=1;
    int p_min=P[0];
    for(int i=1;i<N;i++){
        p_min=min(P[i],p_min);
        if(P[i]<=p_min) ans++;
    }

    cout << ans << endl;

}

Measured memory_bytes: 1024
/*
Author: CNYALI_LK
LANG: C++
PROG: a.cpp
Mail: cnyalilk@vip.qq.com
*/
#include<bits/stdc++.h>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define DEBUG printf("Passing [%s] in LINE %lld\n",__FUNCTION__,__LINE__)
#define Debug debug("Passing [%s] in LINE %lld\n",__FUNCTION__,__LINE__)
#define all(x) x.begin(),x.end()
using namespace std;
const double eps=1e-8;
const double pi=acos(-1.0);
typedef long long ll;
typedef pair<ll,ll> pii;
template<class T>ll chkmin(T &a,T b){return a>b?a=b,1:0;}
template<class T>ll chkmax(T &a,T b){return a<b?a=b,1:0;}
template<class T>T sqr(T a){return a*a;}
template<class T>T mmin(T a,T b){return a<b?a:b;}
template<class T>T mmax(T a,T b){return a>b?a:b;}
template<class T>T aabs(T a){return a<0?-a:a;}
#define min mmin
#define max mmax
#define abs aabs
ll read(){
	ll s=0,base=1;
	char c;
	while(!isdigit(c=getchar()))if(c=='-')base=-base;
	while(isdigit(c)){s=s*10+(c^48);c=getchar();}
	return s*base;
}
char WritellBuffer[1024];
template<class T>void write(T a,char end){
	ll cnt=0,fu=1;
	if(a<0){putchar('-');fu=-1;}
	do{WritellBuffer[++cnt]=fu*(a%10)+'0';a/=10;}while(a);
	while(cnt){putchar(WritellBuffer[cnt]);--cnt;}
	putchar(end);
}
int main(){
#ifdef cnyali_lk
	freopen("a.in","r",stdin);
	freopen("a.out","w",stdout);
#endif
	ll a,cnt=0,b;
	a=read();
	while(a){
		b=a%10;
		a/=10;
		if(b==9)cnt+=b;
		else if(a){
			cnt+=9;
			--a;
		}
		else cnt+=b;
	}
	printf("%lld\n",cnt);
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

ll dp[55][55][2510]; // i枚目までのカードの中でj枚選んで合計sになる組み合わせ数

int main() {
  // 入力
  int N, A;
  cin >> N >> A;
  int x[N+1];
  for (int i = 1; i < N + 1; i++) cin >> x[i];

  dp[0][0][0] = 1;
  for (int i = 1; i < N + 1; i++) {
    for (int j = 0; j < N + 1; j++) {
      for (int s = 0; s <= 2500; s++) {
        if (s < x[i]) {
          dp[i][j][s] = dp[i-1][j][s];
        } else if (j >= 1) {
          dp[i][j][s] = dp[i-1][j][s] + dp[i-1][j-1][s-x[i]];
        }
      }
    }
  }

  ll ans = 0;
  for (int j = 1; j < N + 1; j++) {
    ans += dp[N][j][j*A];
  }

  // 解答
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 54400
class SegmentTree():
    def __init__(self, size):
        self.size = 2**((size-1).bit_length())
        self.e = -1
        self.val = [self.e]*(self.size*2)
    
    def op(self, a, b):
        return max(a, b)
    
    def update(self, i, x):
        i += self.size
        self.val[i] = x
        
        while i > 0:
            i = i >> 1
            self.val[i] = self.op(self.val[2*i], self.val[2*i+1])
    
    def query(self, l, r):
        l += self.size
        r += self.size

        l_sum = 0
        r_sum = 0

        while l < r:
            if l & 1:
                l_sum = self.op(l_sum, self.val[l])
                l += 1
            l = l >> 1

            if r & 1:
                r -= 1
                r_sum = self.op(r_sum, self.val[r])
            r = r >> 1

        return self.op(l_sum, r_sum)

N, K = map(int, input().split())
A = [int(input()) for _ in range(N)]

max_val = 300000

dp = SegmentTree(max_val + 1)

for i in range(N):
    dp.update(A[i], dp.query(max(0, A[i] - K), min(max_val, A[i] + K) + 1) + 1)
print(dp.query(1, max_val + 1))

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

// MOD p でいくつクラス
#define MOD 1000000007 // 10^9 + 7
class mll {
	unsigned long long val = 0;
public:
	mll(long long y = 0) : val(((y % MOD) + MOD) % MOD) {}
	mll operator + (const mll& y) { return mll(*this) += y; }
	mll& operator += (const mll& y) {
		val = (val + y.val) % MOD;
		return *this;
	}
	mll operator - (const mll& y) { return mll(*this) -= y; }
	mll& operator -= (const mll& y) {
		val = (val - y.val + MOD) % MOD;
		return *this;
	}
	mll operator * (const mll& y) { return mll(*this) *= y; }
	mll& operator *= (const mll& y) {
		val = (val * y.val) % MOD;
		return *this;
	}
	mll operator / (const mll& y) { return mll(*this) /= y; }
	mll& operator /= (const mll& y) {
		long long a = y.val, b = MOD, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		mll c = val * u; // この計算でoverflowしないか？
		val = c.val;
		return *this;
	}
	bool operator >= (const mll& y) {
		return this->val >= y.val;
	}
	mll pow(long long t) const {
		if (!t) return 1;
		mll a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	unsigned long long getVal() {
		return val;
	}
	friend ostream& operator <<(ostream& os, mll& y) {
		os << y.val;
		return os;
	}
};
#undef MOD

mll factorial(int x) {
	if (x <= 0) return 1;
	return(mll(x) * factorial(x - 1));
}

int main() {

	int K, M;
	string S;
	cin >> K >> S;
	M = S.size();

	mll p25 = mll(25).pow(K);
	mll p26 = mll(1);
	mll C = factorial(K + M - 1) / (factorial(K) * factorial(M - 1));

	mll ans = mll(0);
	for (int i = 0; i <= K; i++) {
		ans += C * p25 * p26;
		C *= mll(K - i) / mll(K - i + M - 1);
		p25 /= mll(25);
		p26 *= mll(26);
	}
	cout << ans.getVal() << endl;


	return(0);
}


Measured memory_bytes: 35572
a,b,c,d = map(int,input().split())
if a>=0 and c>=0:
    print(b*d)
elif a>=0 and c<0<=d:
    print(b*d)
elif a>=0 and d<0:
    print(a*d)
elif a<0<=b and c>=0:
    print(b*d)
elif a<0<=b and c<0<=d:
    print(max(b*d,a*c))
elif a<0<=b and d<0:
    print(a*c)
elif b<0 and c>=0:
    print(b*c)
elif b<0 and c<0<=d:
    print(a*c)
elif b<0 and d<0:
    print(a*c)

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

int main(void) {

	//0005
	/*
	int a, b, G, R, L, r;
	while (cin >> a >> b) {
		R = a;
		L = b;
		int tmp;
		if (b > a) {
			tmp = a;
			a = b;
			b = tmp;
		}
		while (1) {
			r = a%b;
			if (r == 0)break;
			a = b;
			b = r;
		}
		G = b;
		R = R / G;
		L = L / G;
		cout << G << " " << R*L * G << endl;
	}
	*/

	string name;
	cin >> name;
	int L = name.size();
	string a, Ans;
	for (int i = 0; i < L; i++) {
		a = name.substr(L-i-1, 1);
		Ans += a;
	}
	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    int S=0;
    for(int i=1;i<=N;i*=10){
      S +=   N/i%10;
    }
    if(N%S==0){
        cout <<"Yes"<<endl;
    }
      else {
          cout <<"No" << endl;
      }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <limits>
#include <vector>
#define ll long long
#define rep(i,n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    ll n;
    cin >> n;
    vector<ll> a(n),b(n);
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n){
        cin >> b[i];
    }

    ll a_s = 0,b_s = 0;

    if(n == 1){
        if(a[0] != b[0]){
            cout << "No" << endl;
            return 0;
        }
        else{
            cout << "Yes" << endl;
            return 0;
        }
    }

    rep(i,n){
        if(a[i] > b[i]){
            b_s += a[i] - b[i];
            b[i] = a[i];
        }
        else if(a[i] < b[i]){
            if((b[i] - a[i])%2 == 0){
                a_s += (b[i] -a[i])/2;
            }
            else{
                a_s += (b[i] + 1 - a[i])/2;
                b_s++;
            }
        }
    }

    if(a_s >= b_s){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 384
a = input().split()
low = 0
high = int(a[0])
for i in range(int(a[1])):
    b = input().split()
    if int(b[0]) > low:
        low = int(b[0])
    if int(b[1]) < high:
        high = int(b[1])

r = high - low
if r < 0:
    print("0")
    exit()
print(r + 1)

Measured memory_bytes: 3064
s = input()

for bit in range(1 << 3):
    ans = int(s[0])
    f = s[0]

    for i in range(3):
        # フラグが立っていれば "+" 、なければ "-"
        if bit & (1 << i):
            ans += int(s[i + 1])
            f += "+"
        else:
            ans -= int(s[i + 1])
            f += "-"
        f += s[i + 1]

    if ans == 7:
        print(f + "=7")
        exit()

Measured memory_bytes: 3060
#include <cstdio>
#include <string>
#include <iostream>
#include <math.h>

using namespace std;



int main() {
    int d,i,j,k;
    int c[26];
    int s[365][26];
    cin >> d;
    for(i = 0; i < 26; ++i) cin >> c[i];
    for(i = 0; i < d; ++i) for(j = 0; j < 26; ++j) cin >> s[i][j];

    int arr[365] = {};
    
    int t1,t2,s1,s2, diff, count;
    count = 0;
    while(true) {
        label1:
        for(i = 0; i < 365; ++i) {
            for(j = 0; j < 26; ++j) {
                if(arr[i]==j) continue;
                if(count>10000000) goto label2;
                ++count;
                for(s1 = i+1; s1 < 365; ++s1) {
                    if(arr[s1]==arr[i]) break;
                }
                for(t1 = i-1; t1 >= 0; --t1) {
                    if(arr[t1]==arr[i]) break;
                }
                for(s2 = i+1; s2 < 365; ++s2) {
                    if(arr[s2]==j) break;
                }
                for(t2 = i-1; t2 >= 0; --t2) {
                    if(arr[t2]==j) break;
                }
                diff = s[i][j]-s[i][arr[i]]+(((s1-i)*(s1-i-1))/2+((i-t1)*(i-t1-1))/2-((s1-t1)*(s1-t1-1))/2)*c[arr[i]] + (-((s2-i)*(s2-i-1))/2-((i-t2)*(i-t2-1))/2+((s2-t2)*(s2-t2-1))/2)*c[j];
                if(diff>0) {
                    arr[i] = j;
                    goto label1;
                }
            }
        }
    }
    label2:
    for(i = 0; i < 365; ++i) {
        cout<<(arr[i]+1)<<"\n";
    }


    return 0;
}

Measured memory_bytes: 3652
// 各学生について全探索.
#include<iostream>
#include<utility>
using namespace std;
int main(){
  int n,m; cin >> n >> m;
  pair<int,int> s[55]; //student
  pair<int,int> c[55]; //checkpoint
  for(int i=1;i<=n;i++) cin >> s[i].first >> s[i].second;
  for(int i=1;i<=m;i++) cin >> c[i].first >> c[i].second;
  for(int i=1;i<=n;i++){
    int ans=1;
    int D = abs(s[i].first-c[1].first)+abs(s[i].second-c[1].second); 
    for(int j=1;j<=m;j++){
      int d = abs(s[i].first-c[j].first)+abs(s[i].second-c[j].second);
      if(d<D){ // ここを不等号にすることで複数ポイントがある場合に対応できる.
        D = d;
        ans = j;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main(){
  int N,x,l;
  cin >> N;
  vector<pair<int, int>> r(N);
  for(int i=0; i<N; i++){
    cin >> x >> l;
    r[i] = make_pair(x+l, x-l);
  }
  sort(r.begin(), r.end());
  int c=0,p=-1e9;
  for(int i=0; i<N; i++){
    if(p <= r[i].second){
      c++;
      p = r[i].first;
    }
  }
  cout << c;
  return 0;
}

Measured memory_bytes: 3984
//コンテスト後に自力実装できた
//もうマジ無理死にたい
#include <bits/stdc++.h>

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

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; }
const ll INF = 1LL << 60;

//Write From this Line
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
int Row , Colum ;
vector<string> field;
queue<pair<int,int>> q;
int main()
{
	//迷路、x座標とy座標をバグらせガチなので注意
	cin >>  Row >> Colum;
	field.resize(Row);//行数に合わせる

	rep(i,Row) cin >> field[i] ; //行数だけ入力を受け取る

	int ans = 0 ;
	for(int sy = 0 ; sy < Row ; sy++){
		for(int sx = 0 ; sx < Colum ; sx ++){
			//壁からは始められない！！
			if(field[sy][sx] == '#') continue;
			int Count[25][25];//bfsなので勝手に最小が取られるはず。
			rep(i,25)rep(j,25) Count[i][j] = 0 ;
			bool seen[25][25];//これで毎回falseで埋まるのかな？
			rep(i,25)rep(j,25) seen[i][j] = false;
			q.push(make_pair(sy,sx));
			seen[sy][sx] = true ;
			while(!q.empty()){
				auto point = q.front();
				q.pop();
				int ry =point.first;
				int rx = point.second;
				for(int dir = 0 ; dir < 4 ; dir++ ){
					int ny = ry + dy[dir];
					int nx = rx + dx[dir];
					if(ny < 0 || ny >= Row || nx < 0 || nx >= Colum) continue;
					if(field[ny][nx] == '#' ) continue;
					if(seen[ny][nx]) continue;
					q.push(make_pair(ny,nx));
					seen[ny][nx] = true; 
					Count[ny][nx] = Count[ry][rx] + 1;
					chmax(ans,Count[ny][nx]);
				}
			}
			//for(int y =0 ; y < Row ; y ++){
			//	for(int x = 0 ; x < Colum ; x ++){
			//		cout << Count[y][x] <<" " ;
			//	}
			//	cout << endl;
			//}
		}
	}
	printf("%d\n",ans); 
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
char s[105];
bool b;
int i,len;
int main()
{
	scanf("%s",s+1);
	len=strlen(s+1);
	for (i=1;i<=len;i++)
	{
		b|=s[i]=='C';
		if (b&&s[i]=='F')
		return printf("Yes\n")&0;
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define frst first
#define sec second
#define fast cin.tie(0) , ios_base :: sync_with_stdio(0)
#define db double
#define mod 1000000007
void online_judge()
{
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}


ll lpp(string s)
{
	string rev = s;
	reverse(rev.begin() , rev.end());
	s = s + '#' + rev;
	////cout << s << " ";
	vector<ll> z(s.size() , 0);
	ll l = 0 , r = 0;
	for (int i = 1; i < s.size(); ++i)
	{
		if (i > r) {
			l = r = i;
			while (s[r] == s[r - l]) {
				r++;
			}
			z[i] = (r - l);
			r--;
		}
		else {
			if (z[i - l] + i <= r)z[i] = z[i - l];
			else {
				l = i;
				while (s[r] == s[r - l])r++;
				z[i] = (r - l);
				r--;
			}
		}
	}
	ll ans = 0;
	for (int i = 0; i < s.size(); ++i)
	{
		if (z[i] + i == s.size()) {
			ans = max(ans , z[i]);
		}
	}
	return ans;
}

string binary(ll n)
{
	string s;
	while (n) {
		if ((n & 1))s += '1';
		else s += '0';
		n >>= 1;
	}
	reverse(s.begin() , s.end());
	return s;
}

bool pos(vector<ll> &v , ll val , ll painters)
{
	ll cur = 0;
	ll k = 1;
	for (int i = 0; i < v.size(); ++i)
	{
		if (v[i] > val)return 0;
		if (cur + v[i] <= val)cur += v[i];
		else {
			k++;
			cur = v[i];
		}
	}
	cout << k << endl;
	return (k <= painters);
}

class node {
	node* next;
	node* random;
	ll val;
	node(ll x)
	{
		next = random = NULL;
		val = x;
	}
};

ll dp[101][101][1001];

ll cal(ll a[] , ll cur , ll n , ll sum , ll c , ll tot)
{
	if (n == 0)
	{
		///cout << cur << " " << sum << " " << c << endl;
		if (cur == tot / 2)return abs((sum - c) - c);
		return 1e8;
	}
	if (dp[n][cur][c] != 1e8) {
		///cout << dp[n][cur][c] << " ";
		return dp[n][cur][c];
	}
	///cout << dp[n][cur][c] << " ";
	dp[n][cur][c] = cal(a , cur , n - 1 , sum , c , tot);
	dp[n][cur][c] = min(dp[n][cur][c] ,
	                    cal(a , cur + 1 , n - 1 , sum, c + a[n - 1] , tot));
	//cout << ans << endl;
	return dp[n][cur][c];
}


void go() {
	ll n , k;
	cin >> n >> k;
	ll a[n];
	for (int i = 0; i < n; ++i)cin >> a[i];
	//memset(dp , 0, sizeof dp);
	ll dp[n];
	for (int i = 0; i < n; ++i)dp[i] = 1e18;
	dp[0] = 0;
	for (int i = 1; i < n; ++i)
	{
		for (int j = 1; j <= k; ++j)
		{
			if ((i - j) >= 0) {
				dp[i] = min(dp[i] , dp[i - j] + abs(a[i] - a[i - j]));
			}
		}
	}
	cout << dp[n - 1];
}


int main() {
	fast;
	//online_judge();
	go();
}

Measured memory_bytes: 1792
N = int(input())
len_list = [int(each) for each in input().split()]
len_list.sort()
max_side = len_list[N-1]
sum_o = 0.0
for i in range(N-1):
    sum_o += len_list[i]
if(sum_o > max_side):
    print("Yes")
else:
    print("No")

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

int main(){
    int m, n;
    while(1){
        cin >> m >> n;
        if(m == 0 && n == 0) break;
        for(int i = 0; i < m; ++i){
            for(int j = 0; j < n; ++j){
                if((i + j) % 2 == 0){
                    cout << "#" << flush;
                }else{
                    cout << "." << flush;
                }
                
            }
            cout << endl;
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3048
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
#define F real()
#define S imag()
#define EPS (1e-6)
int N;
P D[333];
struct Circle{
  double r;
  P c;
  Circle(){ r = 1.0; }
  Circle(P c1){
    c = c1;
    r = 1.0;
  }
};
double getK(P a,P b ){
  return sqrt((a.F-b.F)*(a.F-b.F)+(a.S-b.S)*(a.S-b.S));
}

int getC(P a){
  // cout << a.F << " " << a.S << endl;
  int ret = 0;
  for(int i=0;i<N;i++){
    //cout << " k " << getK(a,D[i]) << endl;
    if( 1.0+EPS >= getK(a,D[i]) ) ret++;
  }
  return ret;
}

double getAngle( P a ,P b ){
  return atan((b.S-a.S)/(b.F-a.F));
}

vector<P> getIntersectCC(Circle C1,Circle C2){
  vector<P> res;
  double r1 = C1.r, r2 = C2.r, d;
  P p1 = C1.c, p2 = C2.c;
  d = abs(p1-p2);
  
  if( d < EPS && abs( r1 - r2 ) < EPS ) return res;
  if( r1 + r2 < d - EPS || d + EPS < abs(r1-r2) ) return res;
  
  double a = (r1*r2 - r2*r2 + d*d ) / (2*d);
  double h = sqrt( max( r1 * r1 - a*a , 0.0 ) );
  P tmp1 = p1 + a/d * (p2-p1);
  P tmp2 = h/d * (p2-p1);
  
  if( abs(tmp2) < EPS) res.push_back(tmp1);
  else {
    res.push_back( P(real(tmp1) - imag(tmp2), imag(tmp1) + real(tmp2)));
    res.push_back( P(real(tmp1) + imag(tmp2), imag(tmp1) - real(tmp2)));
  }
}

vector<P> getP(P a, P b){
  return getIntersectCC( Circle(a), Circle(b) );
}

int main(){
  while( cin >> N && N ){
    for(int i=0;i<N;i++) {
      cin >> D[i].real() >> D[i].imag();
    }
    int res = 1;
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
	if( i==j ) continue;
	P r,l;
	vector<P> p = getP( D[i],D[j]);
	for(int i=0;i<(int)p.size();i++){
	  res = max( res, getC(p[i]) );
	  res = max( res, getC(p[i]) );
	}
	//res = max( res, solve(i) );
      }
    }
    cout << res << endl;
  }
}

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

int main(void){
    string S,T;cin>>S>>T;
    for(int i=0;i<S.size();i++){
        char tmp=S[S.size()-1];
        for(int l=0;l<S.size()-1;l++){
            S[S.size()-l-1]=S[S.size()-l-2];
        }
        S[0]=tmp;
        if(S==T){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3600
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;

#define rep(i,s,n) for(ll (i)=(s);(i)<(n);(i)++)
#define repd(i,s,n) for(ll (i)=(n-1);(i)>=(s);(i)--)
#define all(x) x.begin(),x.end()
#define size(x) ((ll)(x).size()
#define PB push_back

int main(){
   int s,w;
   cin >> s >> w;
   if(s<=w){
       cout << "unsafe" << endl;
   }else{
       cout << "safe" << endl;
   }

   return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<map>
#include<algorithm>
#include <iomanip>
#include <cmath>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <vector>
#include <bitset>
#include <queue>
#include <set>
#include <stack>
#include <string>

using namespace std;

int main() {
	int a, b; cin >> a >> b;
	if (a*b == 15) {
		cout << "*" << endl;
	}
	else if (a + b == 15) {
		cout << "+" << endl;
	}
	else {
		cout << "x" << endl;
	}
}

Measured memory_bytes: 256
class Shellsort():
    def __init__(self, x, n):
        self.x = x
        self.n = n
    
    def sorting(self):
        self.cnt = 0
        self.G = [1]
        i = 0
        while 1:
            z = self.G[i] * 3 + 1
            if z > self.n or len(self.G) == 20:
                break
            self.G.append(z)
            i += 1
        
        self.G.sort(reverse = True)
        self.m = len(self.G)
        for i in range(self.m):
            self.insertation(self.G[i])
        return self
    
    def insertation(self, g):
        for i in range(g, self.n):
            v = self.x[i]
            j = i - g
            while j >= 0 and self.x[j] > v:
                self.x[j + g] = x[j]
                j = j - g
                self.cnt += 1
            self.x[j + g] = v

n = int(input())
x = [0] * n
for i in range(n):
    x[i] = int(input())

a = Shellsort(x, n).sorting()

print(a.m)
L = [str(i) for i in a.G]
print(' '.join(L))
print(a.cnt)
for i in a.x:
    print(i)


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

ll solve(const int N, vector<pair<int, int>> v) {
  sort(v.begin(), v.end());
  v.emplace_back(N+1, 0);
  priority_queue<int, vector<int>, greater<>> q;
  int idx = 0;
  for (int i = 0; i <= N; i++) {
    while (v[idx].first == i) if (i) q.push(v[idx++].second); else idx++;
    while (i < q.size()) q.pop();
  }
  ll res = 0;
  while (q.size()) {
    res += q.top();
    q.pop();
  }
  return res;
}

int main() {
  int T; cin >> T;
  while (T--) {
    ll res = 0;
    int N; cin >> N;
    vector<pair<int, int>> l, r;
    for (int i = 0; i < N; i++) {
      int K, L, R; cin >> K >> L >> R;
      res += min(L, R);
      if (L >= R) l.emplace_back(K, L - R);
      else r.emplace_back(N - K, R - L);
    }
    res += solve(N, l) + solve(N, r);
    cout << res << endl;
  }
}
      


Measured memory_bytes: 7192
from heapq import*
import sys
r=sys.stdin.readline
def g(n,E,S,G):
 F=[1e7]*-~n;F[S]=0;H=[(0,S)]
 while H:
  c,u=heappop(H)
  if u==G:return c
  for f,v in E[u]:
   t=c+f
   if t<F[v]:F[v]=t;heappush(H,(t,v))
 return-1
def s(n,k):
 E=[[]for _ in[0]*-~n]
 for _ in[0]*k:
  f=r()
  if'0'==f[0]:print(g(n,E,*map(int,f[2:].split())))
  else:c=[*map(int,f[2:].split())];[E[c[i]].append([c[2],c[1-i]])for i in[0,1]]
for e in iter(r,'0 0\n'):s(*map(int,e.split()))


Measured memory_bytes: 6308
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <stack>
#include <queue>
#include <tuple>
#include <regex>
#include <cmath>
#include <map>
#include <set>
#include <functional>
#include <cstring>

using namespace std;

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

using ll = long long;
using Pint = pair<int, int>;
using Pll  = pair<ll, ll>;

#define eb emplace_back
#define pb push_back
#define mp make_pair

#define F first
#define S second

#define popcnt __builtin_popcountll

#define rep( i, n ) for ( ll i = 0; i < (ll)( n ); ++i )
#define reps( i, n ) for ( ll i = 1; i <= (ll)( n ); ++i )
#define rrep( i, n ) for ( ll i = (ll)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( ll i = (ll)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

template<typename T = ll> constexpr T MAX = numeric_limits<T>::max();
template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }
template<typename T> T lcm( const T a, const T b ) { return ( a / gcd( a, b ) * b ); }


int main()
{
	ll x; cin >> x;
	ll k = 1;
	while ( ( k * x ) % 360 != 0 )
		++k;

	cout << k << endl;

	return ( 0 );
}


Measured memory_bytes: 3156
import java.awt.Point;
import java.util.ArrayDeque;
import java.util.Scanner;
import java.util.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import java.util.Collection;



public class Main{

        static final Scanner sc=new Scanner(System.in);






        public static void main(String[]args){
          int N=sc.nextInt();
          int T=sc.nextInt();
          int[]c=new int[N];
          int[]t=new int[N];
          for(int i=0;i<N;i++){
            c[i]=sc.nextInt();
            t[i]=sc.nextInt();
          }
          int min=10000;
          for(int i=0;i<N;i++){
            if(t[i]<=T){
              if(min>c[i]){
                min=c[i];
              }
            }
          }
          if(min==10000){
            System.out.println("TLE");
          }else{
            System.out.println(min);
          }
                
    }






                



        }





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

typedef long long ll;

const int MAX_N = 5e5;

int bit[MAX_N + 1], n;

int sum(int i) {
    int s = 0;
    while (i > 0) {
        s += bit[i];
        i -= i & -i;
    }
    return s;
}

void add(int i, int x) {
    while (i <= n) {
        bit[i] += x;
        i += i & -i;
        //cout << i << " ";
    }
    //cout << endl;
}

int main() {
    int Q;
    cin >> n >> Q;
    vector<int> c(n), b(n, -1), l(Q), r(Q);
    vector<vector<int>> ls(n);
    map<pair<int, int>, int> ans;
    rep(i, n) {
        cin >> c[i];
        c[i]--;
    }
    rep(i, Q) {
        cin >> l[i] >> r[i];
        l[i]--;
        r[i]--;
        ls[r[i]].push_back(l[i]);
    }
    rep(i, n) {
        add(i + 1, 1);
        if (b[c[i]] > -1) add(b[c[i]] + 1, -1);
        b[c[i]] = i;
        rep(j, ls[i].size()) {
            ans[make_pair(ls[i][j], i)] = sum(i + 1) - sum(ls[i][j]);
        }
    }
    rep(i, Q) {
        cout << ans[make_pair(l[i], r[i])] << "\n";
    }
}

Measured memory_bytes: 65460
#include<bits/stdc++.h>
using namespace std;
int main  ()
{
    int i=0;
    char S[4];

    for(i=0;i<3;i++)
     {
         cin>>S[i];
     }

         if(S[0]==S[1] && S[0]!=S[2] || S[0]==S[2] && S[0]!=S[1] || S[1]==S[2] && S[0]!=S[1])
         {cout<<"Yes"<<endl;}
         else
         {cout<<"No"<<endl;}




}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long ans = 0;
		for(int jj=0;jj<N;jj++){
			bool chk = true;
			int r0 = 0;
			int c0 = jj;
			for(int i=0;i<N;i++){
				for(int j=0;j<i;j++){
					int r = (r0 + i )% N;
					int c = (c0 + j )% N;
					int tr = (r0 + j) % N;
					int tc = (c0 + i) % N;
					chk &= S[r][c] == S[tr][tc];
				}
			}
			if(chk) ans += N;
		}
		Console.WriteLine(ans);
	}
	int N;
	String[] S;
	public Sol(){
		N = ri();
		S = new String[N];
		for(int i=0;i<N;i++){
			S[i] = rs();
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13140
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <string>

#define INF 99999999
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

using namespace std;

int main(void){
    int64_t x;
    cin >> x;
    
    int64_t n =(int64_t)sqrt(2*x+0.25d) - 5;
    
    if( n < 0 )n=0;
    
    while( n*(n+1) < 2*x )n++;
    cout << n << endl;
    
    return 0;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
cnt = 0
for i in range(n):
    if l[i] % 2 == 0:
        if l[i] % 3 == 0:
          cnt += 1
        elif l[i] % 5 == 0:
          cnt += 1
        else:
            print("DENIED")
            quit()
print("APPROVED")


Measured memory_bytes: 3060