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

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}

#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

void err(vector<string>::iterator it) {}

template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> inline T tabs(T a) { return (a > 0) ? a : -a; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	int n;

	cin >> n;
	vector<int> a(n), t(n);
	REPU(i, 0, n) cin >> t[i];
	REPU(i, 0, n) cin >> a[i];
	if (t[n - 1] != a[0]) {
		puts("0"); return 0;
	}

	vector<int> x(n, -1);
	x[0] = t[0], x[n - 1] = a[n - 1];
	REPU(i, 1, n) {
		if (t[i] != t[i - 1]) {
			if (x[i] != -1 && x[i] != t[i]) {
				puts("0"); return 0;
			}
			x[i] = t[i];
			if (x[i] > a[i]) {
				puts("0"); return 0;
			}
		}
	}
	REPD(i, n - 2, -1) {
		if (a[i] != a[i + 1]) {
			if (x[i] != -1 && x[i] != a[i]) {
				puts("0"); return 0;
			}
			x[i] = a[i];
			if (x[i] > t[i]) {
				puts("0"); return 0;
			}
		}
	}
	ll ans = 1;
	REPU(i, 1, n - 1) if (x[i] == -1) {
		ans = ans * min(t[i], a[i]) % MOD;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1408
N = int(input())
D = list(map(int, input().split()))
rec = [0] * 13
for i in range(N):
    rec[D[i]] += 1

if rec[0] >= 1:
    print(0)
    exit()

ans = 0
for i in range(1 << 12):
    tmp = [0]
    for j in range(13):
        if rec[j] >= 3:
            print(0)
            exit()
        elif rec[j] == 2:
            tmp.append(j)
            tmp.append(24 - j)
        elif rec[j] == 1:
            if i & 1 << j:
                tmp.append(j)
            else:
                tmp.append(24 - j)
    tmp = sorted(tmp)
    pre = tmp[0]
    num = float("inf")
    for i in range(1, len(tmp)):
        num = min(num, tmp[i] - pre)
        pre = tmp[i]

    ans = max(min(num, 24 - tmp[-1]), ans)

print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

//-------------------------------------------------------------------
struct segtree{
  ll M=1;
  vector<ll> dat;
  segtree(ll N, ll num){
    while(M<N) M*=2;
    for(int i=0;i<M*2-1;i++)  dat.push_back(num);
  }
  void update(int x, int k, int l=0, int r=-1){
    if(r==-1) r = M;
    k+=M-1;
    dat[k] += x;
    while(k>0) k = (k-1)/2, dat[k] += x;
  }
  ll query(int a, int b=-1, int k=0, int l=0, int r=-1){
    if(r==-1) r = M;
    if(b==-1) b = M;
    if(r<=a || b<=l) return 0;
    if(a<=l && r<=b) return dat[k];
    ll A = query(a, b, k*2+1, l, (l+r)/2);
    ll B = query(a, b, k*2+2, (l+r)/2, r);
    return A + B;
  }
};
//-------------------------------------------------------------------
int main(int argc, char const *argv[]) {
  ll q;std::cin >> q;
  vll so(100001, 0);
  segtree seg(100001, 0);
  for(int i=2;i<=100000;i++){
    bool flag = true;
    for(int j=2;j*j<=i;j++){
      if(i%j==0) {
        flag = false;
        break;
      }
    }
    if(flag) so[i] = 1;
  }
  for(int i=1;i<=100000;i+=2) {
    if(so[i]==1&&so[(i+1)/2]==1) {
      //std::cout << i << '\n';
      seg.update(1, i);
    }
  }
  re(i, q){
    ll l, r;std::cin >> l >> r;
    std::cout << seg.query(l, r+1) << '\n';
  }

  return 0;
}


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

using namespace std;

int main() {
	while( true ) {
		long long int N, M;
		cin >> N >> M;
		if( N==0&&M==0 ) {
			break;
		}
		vector<pair<int, pair<int, int>>>d(M);
		for( size_t i = 0; i < M; i++ ) {
			cin >> d[i].first >> d[i].second.first >> d[i].second.second;
		}
		sort( d.begin() , d.end());
		set<int>X;
		X.insert( 1 );
		for( size_t i = 0; i < M; i++ ) {
			if( X.count(d[i].second.first) ) {
				X.insert( d[i].second.second );
			}
		}
		cout << X.size() << endl;
	}
}

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

using lint = long long int;
using Graph = std::vector<std::vector<lint>>;

template<class T>
struct edge
{
	T dist;
	lint to;
	edge(){}
	edge(const T &a_dist,const lint &a_to) : dist(a_dist), to(a_to) {}
	~edge(){}
};

int main(int argc,char *argv[])
{
	int n;
	std::cin >> n;

	int i;
	for(i = 9;i > 0;i--) if(n%i == 0) break;
	
	if(n/i < 10) std::cout << "Yes" << std::endl;
	else std::cout << "No" << std::endl;
	
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            int cntResult = 0;
            for(int i = 1; i <= N; i++)
            {
                //奇数だけ
                if (i % 2 != 0)
                {
                    int cnt = 0;
                    for(int j = 1; j <= i; j++)
                    {
                        
                        if (i % j == 0)
                        {
                            cnt++;
                        }
                    }
                    if (cnt == 8)
                    {
                        cntResult++;
                    }

                    
                }
            }
            Console.WriteLine(cntResult);

        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


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

using namespace std;

long long int k, n, i, j, a, b, c, h, sum;
const int maxn = 100000 + 20;
int q[maxn];
int w[maxn];

int main()
{
	cin >> n ;
	for(i = 1; i < n + 1; i++){
		cin >> q[i];
	}
	for(i = 1; i < n + 1; i++){
        w[q[i]] = i;
	}
	for(i = 1; i < n + 1; i++){
		cout << w[i] << " " ;
	}
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int N=2e2+5,mod=1e9+7;
ll n,m,k,dp[N][N],num[N][N];
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	cin>>n>>m>>k;
	for(int s=0;s<(1<<(m-1));s++){
		bool ok=true;
		for(int j=0;j<m-1;j++){
			int b1=(s>>j)&1;
			int b2=(s>>(j+1))&1;
			if(b1==b2&&b1)	ok=false;
		}
		if(!ok)	continue;
		for(int j=0;j<m;){
			if((s>>j)&1){
				num[j][j+1]++,num[j+1][j]++;
				j+=2;
			}
			else{
				num[j][j]++;
				j++;
			}
		}		
	}
	dp[0][0]=1;
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			for(int p=0;p<m;p++)	dp[i+1][p]=(dp[i+1][p]+(dp[i][j]*num[j][p])%mod)%mod;
	cout<<dp[n][k-1]<<'\n';
	return 0;
}

Measured memory_bytes: 384
use std::io::*;
use std::str::*;
use std::cmp;

fn read<T: FromStr>(s: &mut StdinLock) -> Option<T> {
    let s = s.by_ref().bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let mut inputs = [0; 200000];
    
    let s = stdin();
    let mut s = s.lock();
    let s = &mut s;
    let mut num = 0;
    if let Some(n) = read(s) {
        num = n;
    }
    for i in 0..num {
        if let Some(n) = read(s) {
            inputs[i] = n;
        }
    }
    
    let mut max_diff = -2000000000;
    let mut min = &inputs[0];

    for input in &inputs[1..num] {
        max_diff = cmp::max(max_diff, *input - min);
        min = cmp::min(min, input);
    }

    println!("{}", max_diff);
}


Measured memory_bytes: 5828
#include <bits/stdc++.h>
using namespace std;
   vector<long long int> vec;
void bfs(long long int i,long long int n)
 {
    long long  int num=i;
     queue<long long int> qw;
     if(num<=n) qw.push(num);
     while(!qw.empty())
       {
          long long  int l=qw.front();
           vec.push_back(l);
           qw.pop();
           if(l%10 ==9)
             {
               if(l*10+8<=n)
                 qw.push(l*10+8);
                if(l*10+9<=n)
                 qw.push(l*10+9);  
             }
           else if(l%10 ==0)
             {
               if(l*10+1<=n)
                 qw.push(l*10+1);
                  if(l*10+0<=n)
                 qw.push(l*10+0);
             }
             else
             {
               if(l*10+l%10 -1<=n)
                 qw.push(l*10+l%10 -1);
               if(l*10+l%10 +1<=n)
                 qw.push(l*10+l%10 +1);
                     if(l*10+l%10 <=n)
                 qw.push(l*10+l%10);
             }
       }
 }
int main() {
	     int nn;
	     cin>>nn;
	     long long int n=3234566667;
	  
	     //cout<<0<<" ";
	     for(long long int i=1;i<=9;i++)
	       {
	           bfs(i,n);
	       }
	       sort(vec.begin(),vec.end());
	       cout<<vec[nn-1]<<endl;
	      // for(int i=0;i<vec.size();i++)
	       // cout<<vec[i]<<" ";
	      // cout<<" "<<endl;
	       vec.clear();
	return 0;
}

Measured memory_bytes: 1368
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;

int a,b,c;
int n;
int input;

int main()
{
	cin>>n;
	rep(i,n)
	{
		cin>>input;
		if(input%4==0)
		{
			a++;
		}
		else if(input%2==0)
		{
			b++;
		}
		else c++;
	}
	if(b==0)
	{
		if(a+1>=c)
		{
			cout<<"Yes"<<endl;
		}
		else cout<<"No"<<endl;
	}
	else
	{
		if(a>=c)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}

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

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

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int aa; cin >> aa;
  int a[4]; for(int i = 3; i>=0; --i) {
    a[i] = aa%10;
    aa/=10;
  }

  rep(i, (1<<3)) {
    vector<int> v(3);
    rep(j, 3) {
      v[j] = (i>>j & 1);
      //      cout << v[j] << endl;
    }
    
    int sum = a[0];
    rep(k, 3) {
      //      cout << v[i] << endl;
      if(v[k]) sum -= a[k + 1];
      else sum += a[k + 1];
    }
    //cout << sum << endl;
    if(sum == 7) {
      rep(m, 4) {
	cout << a[m];
	if(m != 3) cout << (v[m] ? '-' : '+');
      }
      cout << "=7" << endl;
      return 0;
    }
  }
}
	


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

int main(){
    int n,k; cin >> n >> k;
    int d; bool have[n];
    for(int i = 0; i < n; i++) have[i] = false;

    for(int i = 0; i < k; i++){
        cin >> d;
        int a[d] = {};
        for(int j = 0; j < d; j++){
            cin >> a[j];
            have[a[j]-1] = true;
        }

    }
    int ans = 0;
     for(int i = 0; i < n; i++){
         if(!have[i]) ans++;
     }
     cout << ans;
    return 0;
}

Measured memory_bytes: 3636
package main

import "fmt"

func main() {
	var w, h, x, y, r int
	fmt.Scanln(&w, &h, &x, &y, &r)
	if x >= r && (w-x) >= r && y >= r && (h-y) >= r {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
	return
}



Measured memory_bytes: 1160
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int N, M; cin >> N >> M;
  string s[N], t[M];
  rep(i,N) cin >> s[i];
  rep(i,M) cin >> t[i];

  if (M>N) {
    cout << "No" << endl;
    return 0;
  }

  bool ans = false;
  rep(row,N-M+1){
    rep(col,N-M+1){
      // cout << row << " " << col << endl;
      bool check = true;
      for (int i=0;i<M;i++){
        if (s[row+i].substr(col,M)!=t[i]) check = false;
      }
      if (check) ans = true;
    }
  }
  cout << (ans ? "Yes" : "No") << endl;

  // cout << fixed << setprecision(10);
  
  return 0;
}


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

using namespace std;

bool can (int p) {
    char s = (char) p;
    return s == 'M' || s == 'A' || s == 'R' || s == 'C' || s == 'H';
}

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(26, 0);
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        a[s[0] - 'A']++;
    }
    long long ans = 0;
    for (int i = 0; i < 26; i++) {
        if (can(i + 65) && a[i])
        for (int j = i + 1; j < 26; j++) {
            if (a[j] && can(j + 65))
            for (int k = j + 1; k < 26; k++) {
                if (can(k + 65) && a[k])
                ans += a[k] * (long long) a[j] * a[i];
            }
        }
    }
    cout << ans;
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
using pl = pair<ll,ll>;
signed main(){
	ll n,m; cin>>n>>m;
	vvl g(n,vl(0));
	rep(i,0,m){
		ll a,b; cin>>a>>b;
		--a; --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	vl ans(n);
	vector<bool> seen(n);
	seen[0]=1;
	queue<ll> q;
	q.push(0);
	while(!q.empty()){
		ll k=q.front(); q.pop();
		for(auto c:g[k]){
			if(seen[c])continue;
			seen[c]=1;
			ans[c]=k;
			q.push(c);
		}
	}
	cout<<"Yes"<<endl;
	rep(i,1,n)cout<<ans[i]+1<<endl;

	return 0;
}

Measured memory_bytes: 12800
a=-1;z;i;
buf[114514];
char*p=buf;
main(){
  read(0,buf,222222);
  for(;*p>10;i+=1){
    if(a<0&&*p=='A')a=i;
    if(*p=='Z')z=i;
    p+=1;
  }
  printf("%d",z-a+1);
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define N 105
#define M 205
#define ll long long
#define mod 1000000007
void Read(int &p)
{
	p = 0;
	int c = getchar();
	for (; c < '0' || c > '9'; c = getchar());
	for (; c >= '0' && c <= '9'; c = getchar())p = p * 10 + c - '0';
}
int n, m, k, ans, tp, tim;
int inv[M << 1], fac[M << 1], rev[N << 1], pw[M << 1];
int dfn[N], low[N], s[M], hh[M], ss[M << 1];
int tar[M << 1], nex[M << 1], fir[N], tot = 1;
int gcd(int a, int b){return b ? gcd(b, a % b) : a;}
void Add(int x, int y)
{
	++tot;
	tar[tot] = y;
	nex[tot] = fir[x];
	fir[x] = tot;
}
void Sum(int &x, int y)
{
	x += y;
	if (x >= mod)
		x -= mod;
}
int Pow(int a, int k)
{
	if (!k)
		return 1;
	int p = Pow(a, k / 2);
	if (k & 1)
		return (ll)p * p % mod * a % mod;
	return (ll)p * p % mod;
}
int C(int n, int m)
{
	if (n < m)
		return 0;
	return (ll)fac[n] * inv[m] % mod * inv[n - m] % mod;
}
void Dfs(int x, int fa = 0)
{
    dfn[x] = low[x] = ++tim;
    for (int i = fir[x]; i; i = nex[i])
	{
		int y = tar[i];
		if (y != fa)
		{
		    if (!dfn[y])
		    {
		        s[++tp] = i >> 1;
			    Dfs(y, x);
			    low[x] = min(low[x], low[y]);
		        if (low[y] >= dfn[x])
		        {
		            hh[0] = 0;
		            while (1)
		            {
		                int z = s[tp--];
		                hh[++hh[0]] = z;
		                if (z == i >> 1)
		                	break;
		            }
		            if (hh[0] == 1)
		            {
		            	ans = (ll)ans * k % mod;
		            	continue;
		            }
					ss[0] = 0;
		            for (int i = 1; i <= hh[0]; i++)
		            {
		            	ss[++ss[0]] = tar[hh[i] << 1];
		            	ss[++ss[0]] = tar[hh[i] << 1 | 1];
					}
		            sort(ss + 1, ss + ss[0] + 1);
		            ss[0] = unique(ss + 1, ss + ss[0] + 1) - ss - 1;
		            if (ss[0] != hh[0])
		            {
		            	ans = (ll)ans * C(hh[0] + k - 1, k - 1) % mod;
		            	continue;
		            }
		            int cnt = 0;
				    for (int i = 0; i < hh[0]; ++i) 
				        Sum(cnt, pw[gcd(i, hh[0])]);
					ans = (ll)ans * cnt % mod * rev[hh[0]] % mod;
				}
		    }
		    else
		    {
		    	low[x] = min(low[x], dfn[y]);
		    	if (dfn[y] < dfn[x])
		    		s[++tp] = i >> 1;
			}
		}
	}
}
int main()
{
	fac[0] = 1;
	for (int i = 1; i <= 200; i++)
		fac[i] = (ll)fac[i - 1] * i % mod;
	inv[200] = Pow(fac[200], mod - 2);
	for (int i = 200; i >= 1; i--)
		inv[i - 1] = (ll)inv[i] * i % mod;
	rev[1] = 1;
	for (int i = 2; i <= 200; i++)
		rev[i] = (ll)(mod - mod / i) * rev[mod % i] % mod;
	Read(n), Read(m), Read(k);
    for (int i = 1; i <= m; i++) 
	{
		int x, y;
		Read(x), Read(y);
		Add(x, y), Add(y, x);
	}
	pw[0] = 1;
	for (int i = 1; i <= 200; i++)
    	pw[i] = (ll)pw[i - 1] * k % mod;
    ans = 1;
    for (int i = 1; i <= n; i++)
		if (!dfn[i])
			Dfs(i);
    printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
 
/*------------------------------------------------------------------*/
 
int main(){
    vector<long double> a(4);
    rep(i, 4) cin >> a[i];
    long double n; cin >> n;
    vector<pair<long double, long double>> b(4);
    b[0].first = 8 * a[0], b[0].second = 0.25;
    b[1].first = 4 * a[1], b[1].second = 0.5;
    b[2].first = 2 * a[2], b[2].second = 1.0;
    b[3].first = a[3], b[3].second = 2.0;
    sort(b.begin(), b.end());

    long double sum = 0;
    for(int i = 0; i < 4; i++){
        sum += (ll)(n / b[i].second) * (b[i].first * b[i].second) / 2;
        n -= (ll)(n / b[i].second) * b[i].second;
        //cout << sum << " " << n << endl;
    }
    cout << setprecision(20) << sum << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	var edge1 [200001]bool
	var edgen [200001]bool
	n := nextInt()
	m := nextInt()
	for i := 0; i < m; i++ {
		a := nextInt()
		b := nextInt()
		if a == 1 {
			edge1[b] = true
		}
		if b == n {
			edgen[a] = true
		}
	}
	for i := 0; i <= n; i++ {
		if edge1[i] {
			if edgen[i] {
				fmt.Println("POSSIBLE")
				return
			}
		}
	}
	fmt.Println("IMPOSSIBLE")
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define ll long long
#define vi vector <int>
#define vll vector<ll>
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define INF 1000000000000000000
#define pi atan(1)*4
#define MOD 1000000000+7L
#define eps 0.0000006
#define MAX_V 10000
 
using namespace std;
 
int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	
	int n;
	cin >> n;

	int dp[n][3][2];

	int abc[n][3];

	for (int i = 0; i < n; ++i){
		for (int j = 0; j < 3; ++j){
			cin >> abc[i][j];
		}
	}

	dp[0][0][1] = abc[0][0];
	dp[0][1][1] = abc[0][1];
	dp[0][2][1] = abc[0][2];

	dp[0][0][0] = max(dp[0][1][1],dp[0][2][1]);
	dp[0][1][0] = max(dp[0][0][1],dp[0][2][1]);
	dp[0][2][0] = max(dp[0][0][1],dp[0][1][1]);

	for (int i = 1; i < n; ++i){
		dp[i][0][1] = abc[i][0] + dp[i-1][0][0];
		dp[i][1][1] = abc[i][1] + dp[i-1][1][0];
		dp[i][2][1] = abc[i][2] + dp[i-1][2][0];

		dp[i][0][0] = max(dp[i][1][1],dp[i][2][1]);
		dp[i][1][0] = max(dp[i][0][1],dp[i][2][1]);
		dp[i][2][0] = max(dp[i][0][1],dp[i][1][1]);
	}

	int maxi = 0;

	for (int i = 0; i < 3; ++i){
		maxi = max(dp[n-1][i][1],maxi);
	}

	cout << maxi << '\n';


	return 0;
}

Measured memory_bytes: 3840
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){
    int A1,A2,A3;
    
    cin>>A1>>A2>>A3;
    
    if(A1+A2+A3>=22) cout<<"bust"<<endl;
    else cout<<"win"<<endl;
}



Measured memory_bytes: 3132
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
#include <cstdlib>
#include <regex>
#include <list>
int main() {
	long long n, m;
	std::cin >> n >> m;
	if (m >= n * 2) {
		std::cout << n + (m - n * 2) / 4 << std::endl;
	}
	else {
		std::cout << m / 2 << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/trie_policy.hpp>
//#include <ext/rope>
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define for0(i, a, b) for(int i = a; i < b; ++i)
#define for1(i, a, b) for(int i = a; i <= b; ++i)
#define forw0(i, a, b) for(int i = a; i > b; --i)
#define forw1(i, a, b) for(int i = a; i >= b; --i)
#define fora(v, a) for(auto v : a)
#define bp __builtin_popcount
#define bpll __builtin_popcountll

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

const int mod1 = 1e9 + 7, mod2 = 998244353, maxn = 1e5 + 5, maxlog = 20, K = 26;
const ll infll = 1e18;
const double pi = acos(-1);

int n; ll a[maxn], t1 = 0, t2 = 0;

void solve(){
	cin >> n; ll x = 0;
	for1(i, 1, n){
		cin >> a[i];
		if(i > 2) x ^= a[i];
	}
	ll s = a[1] + a[2], tmp = a[1] ^ a[2]; //cout << tmp << ' ' << (tmp ^ x);
	if((tmp ^ x) == 0){
		cout << 0; return;
	}
	if(s < x || (s - x) & 1){
		cout << -1; return;
	}
	ll an = (s - x) / 2; //cout << an << ' ' << x << '\n';
	forw1(bit, 43, 0){
		ll now = 1ll << bit;
		if((an & now) && (x & now)){
			cout << -1; return;
		}
		if((an & now) && !(x & now)){
			t1 += now; t2 += now;
		}
	}
	forw1(bit, 43, 0){
		ll now = 1ll << bit;
		if(!(an & now) && (x & now)){
			if(t1 + now <= a[1]){
				t1 += now;
			}
			else t2 += now;
		}
	}
	if(t1 == 0 || t1 > a[1]) cout << -1;
	else cout << a[1] - t1;
}

signed main(){
	//freopen(".inp", "r", stdin); freopen(".out", "w", stdout);
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	solve();
}
//hahahahahahahahhaahahahahaahahahahahahahahahahhahahahahahahhahahahhahahahhahahah





Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int const MAXN = 1e5 + 5;
char s[10];
int vis[MAXN], cnt[MAXN];

int main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  int n, m; cin >> n >> m;
  int ans1 = 0, ans2 = 0;
  for (RI i = 1; i <= m; ++i) {
    int num; cin >> num;
    cin >> s;
    if (s[0] == 'W')
      cnt[num] += !vis[num];
    else {
      ans1 += !vis[num];
      vis[num] = 1;
    }
  }
  for (RI i = 1; i <= n; ++i)
    if (vis[i]) ans2 += cnt[i];
  printf("%d %d\n", ans1, ans2);

  return 0;
}

// created by Daniel yuan


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

int linear(int A[],int n, int key){
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(A[i] == key){
            cnt++;
            i = n;
        }
    }
    return cnt;
}

int main(){
    int n;
    cin >> n;
    int s[n];
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }
    int q;
    cin >> q;
    int t[q];
    
    for(int i = 0; i < q; i++){
        cin >> t[i];
    }
    int ans = 0;
    for(int i = 0; i < q; i++){
        ans += linear(s,n,t[i]);
    }
    
    cout << ans << endl;
    return 0;
}


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

typedef long long int ll;

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

  int pos = 0;
  for(int i = 0 ; i < s.size() ; i++){
    if(s[i] != '1')break;
    pos++;
  }

  if(k <= pos){
    cout << 1 << endl;
  }
  else {
    cout << s[pos] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
typedef long long ll;
struct pt{
    int idx;
    int val;
};

vector<pt> v;
vector<ll> ans;

bool cmp(pt a, pt b) {
    if(a.val != b.val) {
        return a.val > b.val;
    } else {
        return a.idx < b.idx;
    }
}

int main() {
    scanf("%d", &n);
    v.assign(n, pt());
    ans.assign(n, 0);
    for(int i=0;i<n;i++) {
        scanf("%d", &v[i].val);
        v[i].idx = i;
    }
    sort(v.begin(), v.end(), cmp);
    int min_idx = 100020;
    v.push_back(pt());
    v[n].val = 0;
    for(int i=0;i<n;i++) {
        min_idx = min(min_idx, v[i].idx);
        ans[min_idx] += (ll)(i+1)*(v[i].val - v[i+1].val);
    }

    for(int i=0;i<n;i++) {
        printf("%lld\n", ans[i]);
    }
}

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

                int main()
                {
                      int n;scanf("%d",&n);

                      int arr[n];
                      for(int i = 0 ; i < n ; i++)
                      {
                            scanf("%d",&arr[i]);
                      }
                      int ans = INT_MAX;
                      for(int i = -100 ; i <= 100 ;i++)
                      {
                            int sum = 0;
                            for(int j = 0 ; j < n ; j++)
                            {
                                int x = abs(i - arr[j]);
                                sum += (x * x);
                            }
                            ans = min(ans, sum);
                      }
                      printf("%d\n",ans);

                }


Measured memory_bytes: 256
from math import factorial
from scipy.misc import comb

N, K = map(int, input().split())

big = 10**9+7

# print(comb(N-1, 1-1, exact=True))

for i in range(1, K+1):
    x = comb(K-1, i-1, exact=True)
    y = comb(N-K+1, i, exact=True)
    print((x * y) % big)

Measured memory_bytes: 13524
#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	scanf("\n");
	char c[n];
	int i;
	for(i=0;i<n;i++){
		scanf("%c",&c[i]);
	}
	int num=0;
	for(i=0;i<n-2;i++){
		if(c[i]=='A'&&c[i+1]=='B'&&c[i+2]=='C'){
			num++;
		}
	}
	printf("%d",num);
	return 0;
}

Measured memory_bytes: 128
int N,K,C;
char*S;
int R[2<<17];
char buf[2<<17],out[3<<19];sz;outsz;
char c[6];
main()
{
	read(0,buf,2<<17);
	for(;;)
	{
		char k=buf[sz++];
		if(k<'0')break;
		N=N*10+k-'0';
	}
	for(;;)
	{
		char k=buf[sz++];
		if(k<'0')break;
		K=K*10+k-'0';
	}
	for(;;)
	{
		char k=buf[sz++];
		if(k<'0')break;
		C=C*10+k-'0';
	}
	S=buf+sz;
	int now=K;
	for(int i=N;i-->0;)
	{
		if(S[i]=='o')
		{
			R[i]=now--;
			i-=C;
		}
	}
	now=0;
	for(int i=0;i<N;i++)
	{
		if(S[i]=='o')
		{
			if(R[i]==++now)
			{
				int t=i+1;
				int cs=6;
				do{
					c[--cs]=t%10+'0';
				}while(t/=10);
				for(;cs<6;)out[outsz++]=c[cs++];
				out[outsz++]='\n';
			}
			i+=C;
		}
	}
	write(1,out,outsz);
}


Measured memory_bytes: 3584
from collections import deque

h, w = map(int, input().split())
grid = [input() for i in range(h)]

dist = [[-1]*w for i in range(h)]

black = deque()
for i in range(h):
    for j in range(w):
        if grid[i][j] == "#":
            black.append((i, j))
            dist[i][j] = 0

def bfs(black, dist):
    d = 0
    while black:
        x, y = black.popleft()
        d = dist[x][y]
        for dx, dy in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            nx = x + dx
            ny = y + dy
            if not(0 <= nx < h) or not(0 <= ny < w):
                continue
            if dist[nx][ny] == -1:
                dist[nx][ny] = d+1
                black.append((nx, ny))
    return d

d = bfs(black, dist)
print(d)

Measured memory_bytes: 86620
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long h=sc.nextLong(),w=sc.nextLong();
        if(h*w%3==0){
            System.out.println(0);
            return;
        }
        long ans=Long.MAX_VALUE;
        for(int i=-1;i<3;i++){
            ans=Math.min(ans, Math.abs(Math.max(w*(h/3+i),Math.max((h-h/3-i)*(w/2),(h-h/3-i)*(w%2==0?w/2:w/2+1)))-Math.min(w*(h/3+i),Math.min((h-h/3-i)*(w/2),(h-h/3-i)*(w%2==0?w/2:w/2+1)))));
        }
        for(int i=-1;i<3;i++){
            ans=Math.min(ans, Math.abs(Math.max(h*(w/3+i),Math.max((w-w/3-i)*(h/2),(w-w/3-i)*(h%2==0?h/2:h/2+1)))-Math.min(h*(w/3+i),Math.min((w-w/3-i)*(h/2),(w-w/3-i)*(h%2==0?h/2:h/2+1)))));
        }
        System.out.println(Math.min(ans,Math.min(h,w)));
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define M 998244353
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t,count=0;
	cin>>t;
	for(int i0=0;i0<t;i0++)
	{
		int a;
      cin>>a;
      if((a%2!=0)&&(i0%2==0))
      {
        count++;
      }
      
	}
  cout<<count;
	return 0;
}

Measured memory_bytes: 3660
import sys
from math import gcd

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

def factorize(num: int) -> dict:
    """ 素因数分解 """
    from math import sqrt
    from collections import Counter

    d = Counter()
    for i in range(2, int(sqrt(num))+1):
        while num % i == 0:
            num //= i
            d[i] += 1
        if num == 1:
            break
    if num != 1:
        d[num] += 1
    return d

N = INT()
A = LIST()

def check(se, fact):
    for k in fact:
        if k not in se:
            se.add(k)
        else:
            return False
    return True

is_pc = 1
se = set()
for a in A:
    fact = factorize(a)
    if not check(se, fact):
        is_pc = 0
        break

is_sc = 1
g = 0
for a in A:
    g = gcd(g, a)
if g != 1:
    is_sc = 0

if is_pc:
    print('pairwise coprime')
elif is_sc:
    print('setwise coprime')
else:
    print('not coprime')


Measured memory_bytes: 201524
input = gets.chomp.split("")
if input[0] == input[1] then
    if input[2] == input[3] then
        if input[0] == input[2] then
            print "No"
        else
            print "Yes"
        end
    else
        print "No"
    end
elsif input[0] == input[2] then
    if input[1] == input[3] then
        print "Yes"
    else
        print "No"
    end
elsif input[0] == input[3] then
    if input[1] == input[2] then
        print "Yes"
    else
        print "No"
    end
else
print "No"
end

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
signed main() {
	vector<string>v; int n, l; cin >> n >> l;
	for (int i = 0; i < n; i++) {
		string s; cin >> s;
		v.push_back(s);
	}sort(v.begin(), v.end());
	for (int i = 0; i < n; i++)cout << v[i]; cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define vec vector
typedef int64_t intl;
#define fi first
#define se second
#define pushb push_back
#define popb pop_back
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(), v.rend())
vec<int> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};



int main(){
 char A,B,C;
 cin >>A>>B>>C;
 if ( B =='B' ) { B ='R';}
 else { B = 'B';}
  cout << A <<B <<C;
}
  

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

int main() {
  string s, t;
  cin >> s >> t;
  int count = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == t[i]) {
    count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3632
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
#define MAX_N 100000
#define MAX_E 100000
int N;
int par[MAX_N];
int r[MAX_N];
void init(int N)
{
	for (int i = 0; i < N; i++)
	{
		par[i] = i;
		r[i] = 0;
	}
}

int root(int x)
{
	if (par[x] == x)
	{
		return x;
	}
	else
	{
		return par[x] = root(par[x]);
	}
}


bool same(int x, int y)
{
	return root(x) == root(y);
}


void unite(int x, int y)
{
	x = root(x);
	y = root(y);
	if (x==y)
	{
		return;
	}
	
	
	if (r[x] < r[y])

	{
		par[x] = y;
	}
	else if(r[x]>r[y])
	{
		par[y] = x;
	}
	else if (r[x] == r[y])
	{
			par[y] = x;
			r[x]++;

	}
	
}

struct edge
{
	int u, v, cost;
};

bool comp(const edge& e1, const edge& e2)
{
	return e1.cost < e2.cost;
}


edge es[MAX_E];
int E;

int Kruskal()
{
	sort(es, es + E, comp);
	init(N);
	int res = 0;
	for (int i = 0; i < E; i++)
	{
		if (!same(es[i].u, es[i].v))
		{
			unite(es[i].u, es[i].v);
			res += es[i].cost;
		}
	}
	
	return res;
	
}

int main()
{
	cin >> N >> E;
	for (int i = 0; i < E; i++)
	{
		cin >> es[i].u >> es[i].v >> es[i].cost;
	}

	cout << Kruskal() << endl;
	return 0;
}







Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
using namespace std;

#define MAX 120

struct Node {
	int key;
	Node *p, *l, *r;
};

Node *root, *NIL;

void insert(int k) {
	Node *x = root;
	Node *y = NIL;
	Node *z;
	z = new Node;
	z->key = k; z->l = NIL; z->r = NIL;
	while (x != NIL) {
		y = x;
		if (z->key < x->key) x = x->l;
		else x = x->r;
	}
	z->p = y;

	if (y == NIL) root = z;
	else if (z->key < y->key) y->l = z;
	else y->r = z;
}

void preorder(Node *u) {
	if (u == NIL) return;
	cout << " " << u->key;
	preorder(u->l);
	preorder(u->r);
}

void inorder(Node *u) {
	if (u == NIL) return;
	inorder(u->l);
	cout << " " << u->key;
	inorder(u->r);
}

Node* find(int key) {
	Node* x = root;
	while (x != NIL && key != x->key) {
		if (key < x->key)  x = x->l;
		else x = x->r;
	}
	return x;
}

Node* treeMinimum(Node *x) {
	while (x->l != NIL) x = x->l;
	return x;
}

Node* treeSuccessor(Node* x) {
	if (x->r != NIL)  return treeMinimum(x->r);
	Node* y = x->p;
	while (y != NIL && x == y->r) {
		x = y;
		y = y->p;
	}
	return y;
}

void treeDelete(Node* z) {
	Node *x;  //y??????//
	Node *y;  //??????????±?//
	
	if (z->l == NIL || z->r == NIL) y = z;
	else y = treeSuccessor(z);

	if (y->l != NIL)  x = y->l;
	else  x = y->r;

	if (x != NIL)
		x->p = y->p;

	if (y->p == NIL) {
		root = x;
	}
	else {
		if (y == y->p->l) {
			y->p->l = x;
		}
		else {
			y->p->r = x;
		}
	}

	if (y != z)
		z->key = y->key;

	delete y;
}

void print() {
	inorder(root);
	cout << endl;
	preorder(root);
	cout << endl;
}

int main() {
	int n;
	int num;
	cin >> n; cin.ignore();
	string line;
	for (int i = 0; i < n; i++) {
		getline(cin, line);
		if (line[0] == 'i') {
			num = atoi(line.substr(7).c_str());
			insert(num); 
			
		}
		else if (line[0] == 'f') {
			num = atoi(line.substr(5).c_str());
			if (find(num) == NIL)  cout << "no" << endl;
			else cout << "yes" << endl;
		}
		else if (line[0] == 'd') {
			num = atoi(line.substr(7).c_str());
			treeDelete(find(num));
		}
		else print();
	}
}

Measured memory_bytes: 21840
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

//#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int h,w,n,sx,sy;
	string s,t;
	cin >> h >> w >> n >> sx >> sy >> s >> t; sx--;sy--;
	int xmin = 0,xmax = h,ymin = 0,ymax = w;
	for(int i = n - 1;i >= 0;i--){
		if(t[i] == 'U') xmax = min(h,xmax + 1);
		else if(t[i] == 'D') xmin = max(0,xmin - 1);
		else if(t[i] == 'L') ymax = min(w,ymax + 1);
		else if(t[i] == 'R') ymin = max(0,ymin - 1);
		
		if(s[i] == 'U') xmin++;
		else if(s[i] == 'D') xmax--;
		else if(s[i] == 'L') ymin++;
		else if(s[i] == 'R') ymax--;
		if(xmin >= xmax || ymin >= ymax){
			NO();
			return 0;
		}
	}
	if(xmin <= sx && sx < xmax && ymin <= sy && sy < ymax) YES();
	else NO();
}


Measured memory_bytes: 776
from fractions import math
a, b, x = map(int, input().split())
if x > a*b*a/2:
  print(math.atan(2*(a**2 * b - x)/(a**3))/math.pi * 180)
else:
  print(math.atan(a*(b**2)/2/x)/math.pi*180)


Measured memory_bytes: 5176
using System;
using System.Linq;

namespace testing
{
    class Program
    {

        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            if (a[0] == a[1] && a[2] == a[3] && a[0] != a[2]) { Console.WriteLine("Yes"); }
            else if (a[0] == a[2] && a[1] == a[3] && a[0] != a[1]) { Console.WriteLine("Yes"); }
            else if (a[0] == a[3] && a[1] == a[2] && a[0] != a[2]) { Console.WriteLine("Yes"); }
            else { Console.WriteLine("No"); }
        }
    }
}


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

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

using namespace std;

int main(){
	string s; cin>>s;
	if     (s=="SUN") cout<<"7\n";
	else if(s=="MON") cout<<"6\n";
	else if(s=="TUE") cout<<"5\n";
	else if(s=="WED") cout<<"4\n";
	else if(s=="THU") cout<<"3\n";
	else if(s=="FRI") cout<<"2\n";
	else if(s=="SAT") cout<<"1\n";
	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedList;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FScanner sc = new FScanner();
		String S = sc.next();
		List list = new LinkedList();
		list.add("SUN");
		list.add("MON");
		list.add("TUE");
		list.add("WED");
		list.add("THU");
		list.add("FRI");
		list.add("SAT");
		int index = list.indexOf(S);
		int ret = 7 - index;
		System.out.println(ret);
	}
}

class FScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 22228
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

ll mod_pow(ll a,ll b,ll p){ //(a^b)%p
	ll res=1;
	a%=p;

	while(b>0){
		if(b&1==1) res=((res%p)*(a%p))%p;
		a=(a%p*a%p)%p;
		b>>=1;
	}
	return res;
}

//mod_inv=mod_pow(denominator,MOD-2,MOD);

int32_t main(){
	fastio();
	string s;
	cin >> s;
	int ans = 0;
	int j = 1;
	int n = s.length();
	int cnt = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == '1'){
			ans += mod_pow(2,cnt,mod) * mod_pow(3,n - 1 - i, mod);
			ans %= mod;
			cnt++;
		}
	}
	ans += mod_pow(2,cnt,mod);
	ans %= mod;
	cout << ans;
}

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

ans = ['']*n

ans[0] = input()

for i in range(1, n):
    w = input()
    if w[0] != ans[i-1][-1]:
        print('No')
        exit()
    if w in ans:
        print('No')
        exit()

    ans[i] = w
print('Yes')

Measured memory_bytes: 3064
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, k = map(int, readline().split())
graph = [[] for _ in range(n)]
for i in range(n - 1):
    x, y = map(int, readline().split())
    graph[x - 1].append(y - 1)
    graph[y - 1].append(x - 1)
ans = 1
mod = 10 ** 9 + 7


def dfs(now, par, num):
    global ans
    ans *= num
    ans %= mod
    num = k - 1
    if par != -1:
        num -= 1
    for next in graph[now]:
        if next != par:
            dfs(next, now, num)
            num -= 1


dfs(0, -1, k)
print(ans)


Measured memory_bytes: 87320
import itertools

n = int(input())
max_list_size = (110 + 110 + 110) ** 2
results = [0] * max_list_size

combinations = list(itertools.product(range(1, 109), repeat=3))
for x, y, z in combinations:
    calc_result = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
    results[calc_result] += 1
for i in range(1, n + 1):
    print(results[i])

Measured memory_bytes: 189420
#include <bits/stdc++.h>
using namespace std;
int main(){
  int k,a,b;
  cin >> k >> a >> b;
  bool ok=false;
  for(int i=a;i<=b;i++){
    if(i%k==0)ok=true;
  }
	if(ok)cout << "OK" <<endl;
  else cout << "NG" <<endl;
}

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

const int MAX_SIZE = 1000;

int calc(int N, int c[], int w[]) {
  bool g[MAX_SIZE][MAX_SIZE];
  int s[MAX_SIZE][MAX_SIZE], a[MAX_SIZE];
  for (int i = 0; i < N; ++i) {
    for (int j = i; j < N; ++j) {
      s[i][j] = (j > 0 ? s[i][j - 1] : 0) + w[j];
    }
  }
  for (int i = 0; i < N; ++i) g[i][i] = true;
  for (int k = 1; k < N; ++k) {
    for (int i = 0; i < N - k; ++i) {
      int j = i + k;
      if ((g[i][j - 1] && s[i][j - 1] <= c[j]) ||
          (g[i + 1][j] && s[i + 1][j] <= c[i])) {
        g[i][j] = true;
      } else {
        g[i][j] = false;
      }
    }
  }
  a[0] = 1;
  for (int i = 1; i < N; ++i) {
    if (g[0][i]) {
      a[i] = 1;
      continue;
    }
    a[i] = a[i - 1] + 1;
    for (int j = 0; j < i; ++j) {
      if (g[j + 1][i] && a[j] + 1 < a[i]) a[i] = a[j] + 1;
    }
  }
  return a[N - 1];
}

int main() {
  int N, c[MAX_SIZE], w[MAX_SIZE];
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> c[i] >> w[i];
  }
  cout << calc(N, c, w) << endl;
}

Measured memory_bytes: 6052