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

#define fi first
#define se second
#define lch (o << 1)
#define rch (o << 1 | 1)

typedef double db;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> pint;

const int N = 200000 + 5;
const int INF = 0x3f3f3f3f;
const ll INF_LL = 0x3f3f3f3f3f3f3f3f;

int cnt[N];

int main(){
	ios::sync_with_stdio(0);

	int n, m; cin >> n >> m;
	for(int i=1; i<=m; i++){
		int u, v; cin >> u >> v;
		if(u > v) swap(u, v);
		if(u == 1) cnt[v]++;
		if(v == n) cnt[u]++;
	}

	bool f = 0;
	for(int i=0; i<N; i++)
		if(cnt[i] >= 2) f = 1;
	cout << (f ? "POSSIBLE\n" : "IMPOSSIBLE\n");

	return 0;
}

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

int main(){
  int H,W;
  cin >> H >> W;
  vector<string> grid(H);
  for(int i=0; i<H; i++) cin >> grid[i];
  
  vector<vector<int>> L(H, vector<int>(W));
  for(int y=0; y<H; y++){
    for(int x=0; x<W; x++){
      if(grid[y][x]=='#') L[y][x]=0;
      else if(x==0) L[y][x]=1;
      else L[y][x]=L[y][x-1]+1;
    }
  }
    
  vector<vector<int>> U(H, vector<int>(W));
  for(int y=0; y<H; y++){
    for(int x=0; x<W; x++){
      if(grid[y][x]=='#') U[y][x]=0;
      else if(y==0) U[y][x]=1;
      else U[y][x]=U[y-1][x]+1;
    }
  }
  
  vector<vector<int>> R(H, vector<int>(W));
  for(int yy=H-1; yy>=0; yy--){
    for(int xx=W-1; xx>=0; xx--){
      if(grid[yy][xx]=='#') R[yy][xx]=0;
      else if(xx==W-1) R[yy][xx]=1;
      else R[yy][xx]=R[yy][xx+1]+1;
    }
  }
  
  vector<vector<int>> D(H, vector<int>(W));
  for(int yy=H-1; yy>=0; yy--){
    for(int xx=W-1; xx>=0; xx--){
      if(grid[yy][xx]=='#') D[yy][xx]=0;
      else if(yy==H-1) D[yy][xx]=1;
      else D[yy][xx]=D[yy+1][xx]+1;
    }
  }   
  
  int max=1;
  for(int j=0; j<H; j++){
    for(int k=0; k<W; k++){
      int tmp = L[j][k]+U[j][k]+R[j][k]+D[j][k]-3;
      if(tmp>max) max=tmp;
    }
  }
  cout << max;
  
  return 0;
}

Measured memory_bytes: 67200
using System;
using System.Text.RegularExpressions;

namespace A___Good_Integer
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine();
            
            Console.WriteLine(Regex.IsMatch(N, @"(\d)\1{2}") ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 16204
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 200000000000000
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

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

#define S second
#define F first
#define int long long  

//////////

signed main()
{
    fastio;
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
    }
    int ans[n];
    ans[0]=0;
    ans[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;++i)
    {
        ans[i]=inf;
        int j=i-1;
        while(j>=0&&i-j<=k)
        {
            ans[i]=min(ans[i],ans[j]+abs(a[j]-a[i]));
            --j;
        }
    }
    cout<<ans[n-1];
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(){
  int a,b,c,k,i;
  scanf("%d%d%d%d",&a,&b,&c,&k);
  if(a>=b && a>=c)
    for(i=1;i<=k;i++)
      a*=2;
  else if(b>=a && b>=c)
    for(i=1;i<=k;i++)
      b*=2;
  else
    for(i=1;i<=k;i++)
      c*=2;
  printf("%d\n",a+b+c);
  return 0;
}


Measured memory_bytes: 128
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int hituji = sc.nextInt();
        int okami = sc.nextInt();
        if (hituji > okami) {
            System.out.println("safe");
        } else {
            System.out.println("unsafe");
        }
    }
}

Measured memory_bytes: 35836
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  int k,x;
  scanf("%d%d",&k,&x);
  FOR(i, x-k+1, x+k) cout << i << ' ';
  cout << endl;
}


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

int main() {
    string s;
    cin>>s;
    if(s[0]=='A' && s[1]=='A' && s[2]=='A' || s[0]=='B' && s[1]=='B' && s[2]=='B'){
        cout<<"No";
    }
    else{
        cout<<"Yes";
    }
    return 0;
       
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N, M;
    cin >> N >> M;
    vector<int> edgeNums(N, 0);
    int a, b;
    rep(i, 0, M)
    {
        cin >> a >> b;
        ++edgeNums[a - 1];
        ++edgeNums[b - 1];
    }
    rep(i, 0, N)
    {
        cout << edgeNums[i] << endl;
    }
}


Measured memory_bytes: 256
(defun solve (a b k)
  (if (<= a k)
      (list 0 (max 0 (- b (- k a))))
      (list (- a k) b)))

#-swank
(let ((a (read))
      (b (read))
      (k (read)))
  (format t "~{~A~^ ~}~%" (solve a b k)))


Measured memory_bytes: 12640
#include <iostream>

using namespace std;

int main() {
  int a, b;
  char op;

  while (1) {
    cin >> a >> op >> b;
    if (op == '?')
      return 0;
    else if (op == '+')
      cout << a + b << endl;
    else if (op == '-')
      cout << a - b << endl;
    else if (op == '*')
      cout << a * b << endl;
    else if (op == '/')
      cout << a / b << endl;
  }
}



Measured memory_bytes: 3000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(i = 0; i < n; i++)
//2D::rep(i,j)rep(j,j)cin>>bin[i][j];
//vector<int> a(n)
#define Graph vector<vector<int>>
#define A1 cout<<"No"<<endl
#define A2 cout<<"Yes"<<endl
#define A3 cout<<ans<<
#define AA(i) cout<<i<<endl;
const int U=2e5+5;
const ll MOD=1000000007;
const int INF = 1001001001;

int main(){
    int D,T,S; cin >> D>>T>>S;
    if(D>T*S){A1;}
    else A2;
    return 0;
}

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

const int N = 55;
const long long inf = 2e18;

string s[N];
int c[N], n;
long long dp[N][22][22][2];

long long yo(int k, int st, int en, int f) {
	string nw = s[k].substr(st, en - st + 1);
	string tmp(nw.rbegin(), nw.rend());
	long long &ans = dp[k][st][en][f];
	if (nw == tmp) return ans = 0;
	if (ans != -1) return ans;
	ans = inf;
	for (int i = 1; i <= n; i++) {
		int sz = min(en - st + 1, (int)s[i].size());
		if (f) {
			string X = s[k].substr(st, sz);
			string Y = s[i].substr((int)s[i].size() - sz);
			reverse(Y.begin(), Y.end());
			if (X == Y) {
				long long cur = c[i];
				if (en - st + 1 > sz) {
					cur += yo(k, st + sz, en, 1);
				}
				if (s[i].size() > sz) {
					cur += yo(i, 0, (int)s[i].size() - sz - 1, 0);
				}
				ans = min(ans, cur);
			}
		}
		else {
			string X = s[k].substr(en - sz + 1, sz);
			string Y = s[i].substr(0, sz);
			reverse(X.begin(), X.end());
			if (X == Y) {
				long long cur = c[i];
				if (en - st + 1 > sz) {
					cur += yo(k, 0, en - sz, 0);
				}
				if (s[i].size() > sz) {
					cur += yo(i, sz, (int)s[i].size() - 1, 1);
				}
				ans = min(ans, cur);
			}
		}
	}
	return ans;
}
int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	long long ans = inf;
	for (int i = 1; i <= n; i++) {
		cin >> s[i] >> c[i];
	}
	memset(dp, -1, sizeof dp);
	for (int i = 1; i <= n; i++) {
		ans = min(ans, 1LL * c[i] + yo(i, 0, (int)s[i].size() - 1, 0));
		ans = min(ans, 1LL * c[i] + yo(i, 0, (int)s[i].size() - 1, 1));
	}
	if (ans == inf) ans = -1;
	cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 4092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define ll long long
 
//const int INF = 1e8;
typedef pair<int,int>P;
int dx[4] = {1,0,-1,0};int dy[4] = {0,1,0,-1};
queue<P> que;

bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.first > secondElof.first;
}

int main(void){
  int n,m;cin >> n >> m;
  int a[n];rep(i,n){
     cin >> a[i];
  }
  sort(a,a+n);
  
  pair<int,int> d[m];
  rep(i,m) {
    int b,c;cin >> b >> c;
    d[i] = make_pair(c,b);
  }
  sort(d,d+m,pairCompare );
  //rep(i,n){ cout << a[i]<< " ";} cout << endl;
  //rep(i,m){ cout << d[i].first <<" "<< d[i].second <<endl;}
  int u = 0; ll sum = 0;int l = 0;
  while(u<n){
    int num =  d[l].first;int t = d[l].second;
    for(int i = 0;i<t;i++){
      sum += max(a[u],num);
      
      u++;
      if(u==n)break;
    }
    l++;
  }
  cout << sum << endl;
}

Measured memory_bytes: 1408
import itertools
n=int(input())
count=0
nums=["3","5","7"]

k=3
while k <= len(str(n)):
  for i in itertools.product(nums,repeat=k):
    count_3=0
    count_5=0
    count_7=0
    if (int("".join(i))) <=n:
      for j in i:
        if j == "7":
          count_7+=1
        if j == "3":
          count_3+=1
        if j == "5":
          count_5+=1
      if count_5>=1 and count_3>=1 and count_7>=1:
        count+=1
  k+=1
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;

int main() {
  string c;
  stack<int> s;
  int a, b;
  while (cin >> c) {
    if (c[0] == '+') {
      a = s.top();
      s.pop();
      b = s.top();
      s.pop();
      s.push(b + a);
    }
    else if (c[0] == '-') {
      a = s.top();
      s.pop();
      b = s.top();
      s.pop();
      s.push(b - a);
    }
    else if (c[0] == '*') {
      a = s.top();
      s.pop();
      b = s.top();
      s.pop();
      s.push(b * a);
    }
    else {
      s.push(stoi(c));
    }
  }

  cout << s.top() << endl;

  
  return 0;
}


Measured memory_bytes: 3160
fun main(args: Array<String>) {
  val T = readLine()!!
  
  val t_replace = T.replace("?","D")
  val p_replace = T.replace("?","P")
  
  val t_count = t_replace.chunked(1).filter { it == "D" }.size
  val p_count = p_replace.chunked(2).filter { it == "PD" }.size
  
  if (t_count > p_count)  {
    println(t_replace)
  } else {
    println(p_replace)
  }
}

Measured memory_bytes: 69464
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
 
#include<deque>
#define pi 3.141592653589793238
#include<chrono>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    //cin >> T;
    while (T--) {
        ll a ,b;
        cin >> a >> b;
        cout << max({a + b, a - b, a * b});
    }
    return 0;
}

Measured memory_bytes: 3656
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(dead_code)]
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

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

    fn input<T: FromStr>(&mut self) -> T {
        self.read().unwrap()
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.input()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}
const MOD: usize = 1_000_000_007;
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let k: usize = sc.input();
    let s: String = sc.input();
    let n = s.len();

    let max_n = 3_000_000;
    let mut pow25 = vec![1usize; max_n];
    let mut pow26 = vec![1usize; max_n];
    for i in 0..max_n - 1 {
        pow25[i + 1] = pow25[i] * 25 % MOD;
        pow26[i + 1] = pow26[i] * 26 % MOD;
    }

    let com = Combination::new(max_n);

    let mut ans: usize = 0;
    for i in 0..=k {
        let mut tmp = com.com(n - 1 + k - i, n - 1) * pow26[i] % MOD;
        tmp = tmp * pow25[k - i];
        tmp = tmp % MOD;
        ans += tmp;
        ans = ans % MOD;
    }
    println!("{}", ans);
}

struct Combination {
    fac: Vec<usize>,
    finv: Vec<usize>,
    #[allow(dead_code)]
    inv: Vec<usize>,
}

impl Combination {
    fn new(max_n: usize) -> Combination {
        let mut fac = vec![0; max_n];
        let mut finv = vec![0; max_n];
        let mut inv = vec![0; max_n];
        fac[0] = 1;
        fac[1] = 1;
        finv[0] = 1;
        finv[1] = 1;
        inv[1] = 1;
        for i in 2..max_n {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
        Combination {
            fac: fac,
            finv: finv,
            inv: inv,
        }
    }

    fn com(&self, n: usize, k: usize) -> usize {
        if n < k {
            0
        } else {
            self.fac[n] * (self.finv[k] * self.finv[n - k] % MOD) % MOD
        }
    }
}


Measured memory_bytes: 120068
import java.util.*;



public class Main {
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int max = 0;
		 Map<String, Integer> mMap = new HashMap<String, Integer>();
		 while(N > 0) {
			 String str = sc.next();
			if(mMap.containsKey(str)) {
				mMap.put(str,(mMap.get(str)+1));
			}
			else {
                mMap.put(str,1);
            }
			 if (mMap.get(str) > max) {
	                max = mMap.get(str);
	            }
			N--;
		 }
	        List<String> result = new ArrayList<>();
	        for (String str: mMap.keySet()){
	            if(mMap.get(str) == max){
	                result.add(str);
	            }
	        }
	        Collections.sort(result);
	        for(String s : result) {
	        	System.out.println(s);
	        }
	}
}

Measured memory_bytes: 86000
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sidha(i,a,b) for(int i=a;i<b;i++)

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
	int n;cin>>n;
	int a[n+1],b[n+1];
	memset(b,0,sizeof(b));
	for(int i=1;i<n+1;i++){
		cin>>a[i];
	}
	int c=0;
	for(int i=1;i<n+1;i++){
		if(b[i]==0){
			if(a[a[i]]==i){
				c++;
				b[i]=1;
				b[a[i]]=1;
			}
		}
	}
	cout<<c<<endl;
  return 0;
}

Measured memory_bytes: 4348
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#define ll long long
using namespace std;
int main(){
     ll N,M;
     vector<ll> map(N+1,true);
     cin >> N >> M;
     for(int i = 0; i < M; i++){
          int t = 0;
          cin >> t;
          map[t] = false;
     }
     vector<ll> dp(N+2);
     dp[N+1] = 0;
     dp[N] = 1;
     for(int i = N-1; i >= 0; i--){
          if(map[i]){
               dp[i] = dp[i+1] + dp[i+2];
          }else{
               dp[i] = 0;
          }
          dp[i] = dp[i]%1000000007;
     }
     cout << dp[0] << endl;
}

Measured memory_bytes: 33792
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int ll;

int main()
{
    ll N;
    vector<ll> A(5);
    vector<ll> time(5);
    cin>>N;
    for(int i=0;i<5;++i)
    {
        cin>>A[i];
        time[i]=(N%A[i]==0)?N/A[i]:N/A[i]+1;
    }
    cout<<*max_element(time.begin(),time.end())+4<<endl;
}

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

int main(){
  int n;
  string s;
  cin >> n;
  if (n%1000 == 0) cout << 0 << endl;
  else cout << 1000-n%1000 << endl;  
  return 0;
}


Measured memory_bytes: 3620
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  ll n, k; cin >> n >> k;
  map<ll, ll> M;
  loop(i,0,n) {
    ll a, b; cin >> a >> b;
    M[a] += b;
  }
  
  ll sum = 0;
  for (auto m: M) {
    sum += m.second;
    if (sum >= k) {
      cout << m.first << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 7420
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MAXN = 2e5 + 5;
const int mod = 1e9 + 7;

struct Edge
{
	int next,to;
}e[MAXN<<1];
int head[MAXN],etot=0;
inline void add(int u,int v)
{
	e[++etot]=(Edge){ head[u],v};
	head[u]=etot;
}

inline ll pw(ll a,int b)
{
	ll res=1;
	while(b)
	{
		if(b&1) res=res*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return res;
}

ll fac[MAXN],inv[MAXN];
ll c(int n,int m)
{
	if(n<0 || m<0 || n<m) return 0;
	return fac[n] * inv[m] %mod * inv[n-m] %mod;
}

int n;
ll size[MAXN],f[MAXN];

void dfs_f(int u,int fa)
{
	size[u]=1;
	f[u]=1;
	int sum=0;
	for(int i=head[u]; i; i=e[i].next)
	{
		int v=e[i].to;
		if(v==fa) continue;
		dfs_f(v,u);
		
		size[u]+=size[v];
		sum += size[v];
		f[u] = f[u] * f[v] %mod * c(sum,size[v]) %mod;
	}
}

ll g[MAXN];
void dfs_g(int u,int fa)
{
	for(int i=head[u]; i; i=e[i].next)
	{
		int v=e[i].to;
		if(v==fa) continue;
		
		g[v] = g[u] * pw(c(n-1, size[v]), mod-2) %mod * c(n-1, n-size[v]) %mod;
		dfs_g(v,u);
	}
}

int main(void)
{
	fac[0]=1;
	for(int i=1; i<MAXN; ++i) fac[i]=fac[i-1]*i%mod;
	inv[MAXN-1]=pw(fac[MAXN-1],mod-2);
	for(int i=MAXN-2; i>=0; --i) inv[i] = inv[i+1]*(i+1)%mod;
	
	scanf("%d",&n);
	for(int i=1; i<n; ++i)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v); add(v,u);
	}
	
	dfs_f(1,0);
	g[1]=f[1];
	dfs_g(1,0);
	
	for(int i=1; i<=n; ++i) printf("%lld\n",g[i]);
	return 0;
}

Measured memory_bytes: 14336
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
string s;
unsigned long long ans;
int main()
{
    cin>>s;
    if(s[0]!='C') 
		ans++;
    if(s[1]!='O') 
		ans++;
    if(s[2]!='D') 
		ans++;
    if(s[3]!='E') 
		ans++;
    if(s[4]!='F') 
		ans++;
    if(s[5]!='E') 
		ans++;
    if(s[6]!='S') 
		ans++;
    if(s[7]!='T') 
		ans++;
    if(s[8]!='I') 
		ans++;
    if(s[9]!='V') 
		ans++;
    if(s[10]!='A') 
		ans++;
    if(s[11]!='L') 
		ans++;
    if(s[12]!='2') 
		ans++;
    if(s[13]!='0') 
		ans++;
    if(s[14]!='1') 
		ans++;
    if(s[15]!='6') 
		ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();//人数
		int [][] card = new int [N][3];
		int [] flg = new int [N];
		int [] score = new int [N];
		for(int i = 0; i < N; i++){
			for(int m = 0; m < 3; m++){
				card[i][m] = in.nextInt();
			}
		}
		for(int m = 0; m < 3; m++){
			for(int i = 0; i < N; i++){
				for(int k = i + 1; k < N; k++){
					if(card[i][m] == card[k][m]){
						flg[i]++;
						flg[k]++;
					}
				}
				if(flg[i] == 0){
					score[i] += card[i][m];
				}
			}
			for(int p = 0; p < N; p++){
				flg[p] = 0;
			}
		}
		for(int i = 0; i < N; i++){
			System.out.println(score[i]);
		}
	}

}

Measured memory_bytes: 20820
# -*- coding: utf-8 -*-
import math

# input
a, b, x = map(int, input().split())

# solve
S = x / a
if (S >= (a * b) / 2):
    h = (a * b - S) * 2 / a
    rad = math.atan2(h, a)
else:
    w = S * 2 / b
    rad = math.atan2(b, w)

# output
print(rad / (2 * math.pi) * 360)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
int dp[100003][5];
using namespace std;
const int MOD=1e9+7;

struct UnionFind{
  int n;
  vector<int> r,p;
  UnionFind(){}
  UnionFind(int sz):n(sz),r(sz,1),p(sz,0){iota(p.begin(),p.end(),0);}
  int find(int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
  }
};

signed main() {
  int H,W;cin>>H>>W;
  std::vector<string> s(H);
  for(int i=0;i<H;i++)cin>>s[i];
  int x[4]={-1,1,0,0};
  int y[4]={0,0,-1,1};
  UnionFind uf(H*W);
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(s[i][j]=='#')continue;
      for(int k=0;k<4;k++){
        int nx=i+x[k],ny=j+y[k];
        if(nx<0||nx>=H||ny<0||ny>=W)continue;
        if(s[nx][ny]=='#')uf.unite(i*W+j,nx*W+ny);
      }
    }
  }
  int ans=0;
  std::vector<int> b(H*W,0),w(H*W,0);
  for(int i=0;i<H*W;i++){
    if(s[i/W][i%W]=='.')w[uf.find(i)]++;
    if(s[i/W][i%W]=='#')b[uf.find(i)]++;
  }
  for(int i=0;i<H*W;i++)ans+=w[i]*b[i];
  cout<<ans<<endl;
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define ll long long
#define ar array
#define AC ios_base::sync_with_stdio(0);
const int M = 1e9+7;
using namespace std;
char str[200000];

int main(){
    AC
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>str[i];
    int l=0, r=n-1;
    int ans=0;
    while(l<r){
        if(str[l]=='R'&&str[r]=='R')
            l++;
        else if(str[l]=='W'&&str[r]=='W')
            r--;
        else if(str[l]=='W'&&str[r]=='R'){
            ans++;
            l++;
            r--;
        }
        else{
            l++;
            r--;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3800
A_str=input()
B_str=input()
C_str=input()
X_str=input()
A=int(A_str)
B=int(B_str)
C=int(C_str)
X=int(X_str)
saisho=X
tori=0
for i in range(A+1):
  X=saisho

  X=X-500*i

  if X==0:
    tori=tori+1
  elif X>0:
    saishoB=X
    for j in range(B+1):
      X=saishoB

      X=X-100*j
      if X==0:
        tori=tori+1
      elif X>0:
        saishoC=X
        for k in range(C+1):
          X=saishoC

          X=X-50*k
          if X==0:
            tori=tori+1
print(str(tori))
      
  

Measured memory_bytes: 9096
#include <iostream>
using namespace std;
int main(void){
    int N;
    cin>>N;
    int P[200]={};
    bool flag=true;
    for(int i=0;i<N;i++){
        cin>>P[i];
        if(P[i]%2==1)
            flag=false;
    }
    if(flag==false){
        cout<<0<<endl;
        return 0;
    }
    int count=0;
    flag=true;
    while (flag){
        for(int i=0;i<N;i++){
            P[i]=int(P[i]/2);
            if(P[i]%2==1){
                flag=false;
                break;
            }
            }
            count+=1;
        }
    cout<<count<<endl;   
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
using ll = long long;
using namespace std;
template <class T> inline void chmax(T & a, T const & b) { a = max(a, b); }

ll powmod(ll x, ll y, ll p) {
    assert (0 <= x and x < p);
    assert (0 <= y);
    ll z = 1;
    for (ll i = 1; i <= y; i <<= 1) {
        if (y & i) z = z * x % p;
        x = x * x % p;
    }
    return z;
}
constexpr int mod = 1e9 + 7;

array<int, 3> dp_append(array<int, 3> const & a, array<int, 3> const & b) {
    array<int, 3> c = {};
    REP (i, 3) REP (j, 3) {
        (c[min(2, i + j)] += a[i] *(ll) b[j] % mod) %= mod;
    }
    return c;
}

int main() {
    // input
    int n; scanf("%d", &n);
    vector<int> parent(n + 1);
    vector<vector<int> > children(n + 1);
    parent[0] = -1;
    REP (i, n) {
        int p_i; scanf("%d", &p_i);
        parent[i + 1] = p_i;
        children[p_i].push_back(i + 1);
    }

    // solve
    vector<int> count_depth(n + 1);
    function<shared_ptr<deque<array<int, 3> > > (int, int)> go = [&](int i, int depth) {
        count_depth[depth] += 1;
        auto cur_ptr = make_shared<deque<array<int, 3> > >();
        auto & cur = *cur_ptr;
        int prv_size_max = 0;
        for (int j : children[i]) {
            auto prv_ptr = go(j, depth + 1);
            auto & prv = *prv_ptr;
            if (cur.size() < prv.size()) {
                cur.swap(prv);
            }
            REP (i, prv.size()) {
                cur[i] = dp_append(cur[i], prv[i]);
            }
            chmax<int>(prv_size_max, prv.size());
        }
        REP (i, prv_size_max) {
            (cur[i][0] += cur[i][2]) %= mod;
            cur[i][2] = 0;
        }
        cur.emplace_front();
        cur.front() = { { 1, 1, 0 } };
        return cur_ptr;
    };
    auto cur_ptr = go(0, 0);
    auto & cur = *cur_ptr;
    ll result = 0;
    REP (i, cur.size()) {
        result += cur[i][1] *(ll) powmod(2, n + 1 - count_depth[i], mod) % mod;
    }
    result %= mod;

    // output
    printf("%lld\n", result);
    return 0;
}


Measured memory_bytes: 178432
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

int main() {
  int M, N;
  std::cin >> N >> M;
  std::vector<int> X(M);
  for (int i=0;i<M;i++) {
    std::cin >> X[i];
  }
  std::sort(X.begin(), X.end());
  std::vector<int> d(M-1);
  for (int i=0;i<M-1;i++) {
    d[i] = X[i+1] - X[i];
  }
  std::sort(d.begin(), d.end());
  auto sum_begin = d.begin();
  auto sum_end = d.end() - std::min<int>(N - 1, d.size());
  int sum = std::accumulate(sum_begin, sum_end, 0);
  std::cout << sum << std::endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

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;
}
constexpr int mod = 998244353;
constexpr int inf = 3e18;


signed main(){
	int N;cin>>N;
	int ans=0;
	REP(i,N+1){
		int mn=i,mx=N/i*i;
		int ko=(mx-mn)/i+1;
		ans+=(mn+mx)*ko/2;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,l,r) for (int i=l; i<=r; i++)
typedef long long ll;
using namespace std;

const int N=1000010;
int n,a[N],cnt[N][2],mx,mx1,mx2,mx3,mx4;

int main(){
	scanf("%d",&n);
	rep(i,1,n) scanf("%d",&a[i]),cnt[a[i]][i&1]++,mx=max(mx,a[i]);
	rep(i,1,mx){
		if (cnt[i][0]>cnt[mx1][0]) mx2=mx1,mx1=i;
		else if (cnt[i][0]>cnt[mx2][0]) mx2=i;
		if (cnt[i][1]>cnt[mx3][1]) mx4=mx3,mx3=i;
		else if (cnt[i][1]>cnt[mx4][1]) mx4=i;
	}
	if (mx1!=mx3) printf("%d\n",n-cnt[mx1][0]-cnt[mx3][1]);
	else printf("%d\n",min(n-cnt[mx2][0]-cnt[mx3][1],n-cnt[mx1][0]-cnt[mx4][1]));
	return 0;
}

Measured memory_bytes: 5120
#include <stdio.h>
#include <math.h>
int main()
{
	int x,h;
	double S;
	while(1)
	{
		scanf("%d",&x);
		scanf("%d",&h);
		if(x==0&&h==0) break;
		S=x*x;
		S+=sqrt(0.25*x*x+h*h)*x*2;
		printf("%lf\n",S);
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

int n;
int memo[100005][3];
int datas[100005][3];
int solve(int ix, int sta)
{
	if(ix==n) return 0;
	if(memo[ix][sta]!=-1) return memo[ix][sta];
	int ret=0;
	for(int z=0;z<3;z++)
	{
		if(z==sta) continue;
		ret=max(ret, datas[ix+1][z]+solve(ix+1, z));
	}
	return memo[ix][sta]=ret;
}
int main()
{
	scanf("%d", &n);
	for(int a=1;a<=n;a++)
	{
		for(int b=0;b<3;b++)
		{
			scanf("%d", &datas[a][b]);
		}
	}
	memset(memo, -1, sizeof(memo));
	int hasil=0;
	for(int z=0;z<3;z++)
	{
		hasil=max(hasil, datas[1][z]+solve(1, z));
	}
	printf("%d\n", hasil);
	return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#pragma GCC target("avx2")
using namespace std;

const int maxh = 101, maxw = 9;
const int mod = 1000000007;
 
int h, w, k;
int dp[maxh][maxw];
 
int rec (int r, int c) {
    if (r == h)
        return int(c == k - 1);
    else if (dp[r][c] != -1)
        return dp[r][c];
    else {
        int res = 0;
        for (int mask = 0; mask < (1 << (w - 1)); ++mask) {
            bool ok = 1;
            for (int i = 1; i < w - 1; ++i) {
                if ((mask & (1 << (i - 1))) && (mask & (1 << i))) {
                    ok = 0;
                    break;
                }
            }
            if (ok) {
                int nc = c;
                if (c + 1 < w && (mask & (1 << c)))
                    nc = c + 1;
                else if (c - 1 >= 0 && (mask & (1 << (c - 1))))
                    nc = c - 1;
                (res += rec(r + 1, nc)) %= mod;
            }
        }
        return dp[r][c] = res;
    }
}
 
signed main () {
	cin >> h >> w >> k;
	memset(dp, -1, sizeof(dp));
	cout << rec(0, 0) << '\n';
}


Measured memory_bytes: 256
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

ll modpow(ll a, ll n, ll mod){
  ll res = 1;
  while(n > 0){
    if(n & 1) res = res*a%mod;
    a = a*a%mod;
    n >>= 1;
  }
  return res;
}

ll moddiv(ll a, ll mod){
  return modpow(a,mod-2,mod);
}

int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  ll ans = 0;
  ans = modpow(2,n,mod);
  // printf("%lld\n", ans);
  ans -= 1;
  ll memo = 1;
  for(int i = n-a+1; i <= n; i++) memo = memo*i%mod;
  for(int i = 1; i <= a; i++) memo = memo*moddiv(i,mod)%mod;
  ans -= memo;
  ans %= mod;
  memo = 1;
  for(int i = n-b+1; i <= n; i++) memo = memo*i%mod;
  for(int i = 1; i <= b; i++) memo = memo*moddiv(i,mod)%mod;
  ans -= memo;
  ans %= mod;
  if(ans < 0){
    ans += mod;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define show(x) cout << x << '\n'
#define showh(x) cout << x << ' '
#define go(i, a, n) for (ll i = a; i < n; i++)
#define gor(i, a, n) for (ll i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
auto t1 = chrono::high_resolution_clock::now();
bool prime[100001];
ll expo(ll a, ll b)
{
    a = a % mod;
    b = b % mod;
    if (b == 0)
        return 1;
    if (b % 2)
        return ((a % mod) * (expo((a * a) % mod, b / 2) % mod)) % mod;
    return expo((a * a) % mod, b >> 1) % mod;
}
ll mul(ll a, ll b)
{
    a = a % mod;
    b = b % mod;
    if (b == 0)
        return 0;
    if (b % 2)
        return ((a % mod) + (mul((a + a) % mod, b / 2) % mod)) % mod;
    return mul((a + a) % mod, b >> 1) % mod;
}

bool ispoweroftwo(ll x)
{
    return x && !(x & (x - 1));
}
ll xorcal(ll n)
{
    if (n % 4 == 0)
        return n;
    if (n % 4 == 1)
        return 1;
    if (n % 4 == 2)
        return n + 1;
    if (n % 4 == 3)
        return 0;
}
void sieve(ll n)
{
    memset(prime, true, sizeof(prime));
    prime[0] = false;
    prime[1] = false;
    for (ll i = 2; i * i <= n; i++)
    {
        if (prime[i] == true)
        {
            for (ll j = i * i; j <= n; j += i)
                prime[j] = false;
        }
    }
}
bool isprime(ll n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    if (n % 2 == 0 or n % 3 == 0)
        return false;

    for (ll i = 5; i * i <= n; i += 6)
    {
        if (n % i == 0 or n % (i + 2) == 0)
            return false;
    }
    return true;
}

ll modinverse(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m;
        a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return (b % a, a);
}
bool ispalindrome(string s)
{
    string t = s;
    reverse(t.begin(), t.end());
    if (t == s)
        return true;
    return false;
}
void binary(ll a[], ll n)
{
    gor(i, 0, 64)
    {
        ll k = n >> i;
        a[i] = k & (ll)1;
    }
}
ll countBits(ll n)
{
    if (n == 0)
        return 0;
    return 1 + countBits(n & (n - 1));
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, m;
    cin >> n >> m;
    n--, m--;
    ll ans = ((n * (n + 1)) / 2) + ((m * (m + 1)) / 2);
    show(ans);
    auto t2 = chrono::high_resolution_clock::now();
    auto duration = chrono::duration_cast<chrono::milliseconds>(t2 - t1).count();
    clog << "Time taken = " << duration * 1.0 / 1000 << " seconds" << endl;
    return 0;
}

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

int main() {
    string s; cin >> s;
    for (int i = 0; i * 2 < s.size(); i++) {
        if (s[i] != s[s.size()-1-i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    string first_s = s.substr(0, (s.size()-1)/2);
    // cout << first_s << endl;
    for (int i = 0; i < first_s.size(); i++) {
        if (first_s[i] != first_s[first_s.size()-1-i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    string latter_s = s.substr((s.size()+1)/2, s.size() - (s.size()+1)/2);
    // cout << latter_s << endl;
    for (int i = 0; i < latter_s.size(); i++) {
        if (latter_s[i] != latter_s[latter_s.size()-1-i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;


int main(){
  ll K; cin >> K;

  cout << 50 << endl;
  vector <ll> ans(50);

  if (K > 0){
    ll cnt = K % 50;
    if (cnt == 0){
      cnt = 50; K -= 50;
    }

    for (int i = 0; i < 50; i++){
      if (i < cnt){
        ans[i] = 50 - i;
      }else if(i == cnt){
        ans[i] = ans[i - 1] - 2;
      }else{
        ans[i] = ans[cnt];
      }
    }

    for (int i = 0; i < 50; i++){
      ans[i] += K / 50;
    }
  }
  
  for (int i = 0; i < 50; i++){
    cout << ans[i];
    if (i == 49) cout << endl;
    else cout << " ";
  }

  return 0;
}

Measured memory_bytes: 256
x1, y1, x2, y2 = map(int,input().split())
x3 = x2 - y2 + y1
y3 = y2 + x2 - x1
x4 = x3 - x2 + x1
y4 = y3 - y2 + y1
print(x3, y3, x4, y4)


Measured memory_bytes: 2940
#include<stdio.h>
#define MAX 101

main()
{
  int n, u, v, k, i, j, Adj[MAX][MAX];

  scanf("%d", &n);
  for(i=1; i<=n; i++)
    {     
      for(j=1; j<=n; j++)
	{
	  Adj[i][j] = 0;
	}
    }

  for(i=1; i<=n; i++)
    {
      scanf("%d %d", &u, &k); 
      for(j=1; j<=k; j++)
	{
	  scanf("%d", &v);
	  Adj[i][v] = 1;
	}
    }

  for(i=1; i<=n; i++)
    {
      for(j=1; j<=n; j++)
	{
	  printf("%d", Adj[i][j]);
	  if(j<n) printf(" ");
	}
      printf("\n");
    }

  return 0;
}

Measured memory_bytes: 636
import sys

input = sys.stdin.readline
N, K = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N - 1)]
P = int(1e9+7)
if N == 1:
    print(K % P)
    sys.exit(0)
kaizyo = [0]
kaizyo_inv = [0]
tmp = 1
for i in range(1, K+1):
    tmp = (tmp*i) % P
    kaizyo.append(tmp)
    kaizyo_inv.append(pow(tmp, P - 2, P))


def comb(n, r):
    if n < r or n < 0:
        return 0
    elif n == r or r == 0:
        return 1
    else:
        return kaizyo[n] * kaizyo_inv[r] * kaizyo_inv[n - r]


g=[[] for _ in range(N)]
for a, b in ab:
    g[a-1].append(b-1)
    g[b - 1].append(a - 1)

children = [[] for _ in range(N)]
q = [(0, None)]
while len(q) > 0:
    v, p = q.pop()
    for u in g[v]:
        if u != p:
            q.append((u, v))
            children[v].append(u)

if len(children[0]) > K - 1:
    print(0)
    sys.exit()
ans = 1
ans *= K
n_child = len(children[0])
ans = (ans * comb(K - 1, n_child)*kaizyo[n_child]) % P
q = [i for i in children[0]]
while len(q) > 0:
    v = q.pop()
    n_child = len(children[v])
    if n_child > K - 2:
        print(0)
        sys.exit()
    if n_child != 0:
        ans = (ans * comb(K - 2, n_child)*kaizyo[n_child]) % P
    q += children[v]
print(ans)


Measured memory_bytes: 126780
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

template <class T>
struct compressor {
  vector<T> xs;
  void put(const T& x) {
    xs.push_back(x);
  }
  void compress() {
    sort(xs.begin(), xs.end());
    xs.erase(unique(xs.begin(), xs.end()), xs.end());
  }
  int get1(const T& x) const {
    return distance(xs.begin(), lower_bound(xs.begin(), xs.end(), x)) + 1;
  }
  int size() const {
    return xs.size();
  }
};

struct edge_t {
  int to;
  int id;
};

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N, M;
  while (cin >> N >> M) {
    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) cin >> A[i] >> B[i];
    vector<int> L(M), R(M);
    for (int i = 0; i < M; i++) cin >> L[i] >> R[i];
    compressor<int> zip;
    for (int x : A) zip.put(x);
    zip.compress();
    vector<int> bombs(N + 1, 0);
    for (int i = 0; i < N; i++) {
      int x = zip.get1(A[i]);
      bombs[x] = B[i];
    }
    vector<int> goal(N + 1, 0);
    for (int i = 1; i < N; i++) {
      if (bombs[i] != bombs[i + 1]) {
        goal[i] = 1;
      } else {
        goal[i] = 0;
      }
    }
    goal[N] = bombs[N];
    vec<edge_t, 2> G(N + 1);
    for (int i = 0; i < M; i++) {
      int a = zip.get1(L[i]);
      int b = zip.get1(R[i] + 1) - 1;
      if (a > b) continue;
      --a;
      assert(0 <= a && b <= N);
      G[a].push_back({b, i});
      G[b].push_back({a, i});
    }
    vector<int> used(N + 1, 0);
    vector<int> res;
    auto dfs = [&](auto& dfs, int v) -> void {
      used[v] = 1;
      for (auto& e : G[v]) {
        if (used[e.to]) continue;
        dfs(dfs, e.to);
        if (goal[e.to]) {
          res.push_back(e.id);
          goal[e.to] ^= 1;
          goal[v] ^= 1;
        }
      }
    };
    for (int v = 0; v <= N; v++) {
      if (!used[v]) dfs(dfs, v);
    }
    if (accumulate(goal.begin() + 1, goal.end(), 0) > 0) {
      cout << -1 << endl;
      continue;
    }
    sort(res.begin(), res.end());
    cout << res.size() << endl;
    for (int x : res) cout << x + 1 << " ";
    cout << endl;
  }
  return 0;
}


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

using namespace std;

#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int H, W;
string s[100];
int cnt[26];

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

    cin >> H >> W;
    rep(i, H) cin >> s[i];
    rep(i, H) rep(j, W) ++cnt[s[i][j] - 'a'];
    int mod[4] = {0};
    rep(i, 26) ++mod[cnt[i] % 4];
    if(H % 2 == 0 && W % 2 == 0) {
        rep(i, 26) if(cnt[i] % 4) {
            cout << "No" << endl;
            return 0;
        }
    }
    else if(H % 2 && W % 2) {
        if(mod[3] || mod[1] != 1 || mod[2] > (H - 1) / 2 + (W - 1) / 2) {
            cout << "No" << endl;
            return 0;
        }
    }
    else {
        if(W % 2) {
            if(mod[3] || mod[1] || mod[2] > H / 2) {
                cout << "No" << endl;
                return 0;
            }
        }
        else {
            if(mod[3] || mod[1] || mod[2] > W / 2) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
/*
    BY - Darkworld1 ( Tanu kumar )
    college - AIT
    Problem - contest ( div 3 )
*/
#include<bits/stdc++.h>
#include <cstdio>
using namespace std;
#define ll  long long
#define PB push_back
#define ld long double
#define ff first
#define ss second
# define st(v) (v).begin(),(v).end()
#define rep(i,a,n) for( int i = a ; i < n ; i++ )
#define prep( i, a , n ) for ( int i = a ; i>= n ; i--)
#define   pr pair<int,int>
const int N = 13 , M=N,inf=(int)1e9;
const int mod=1e9+7;
int fastAbs(int n) { return (n ^ (n >> 31)) - (n >> 31); }
ll multiply(ll a, ll b){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
ll ans ;
map< pair<int,int> , int > mp;
const int dx[4] = {1,0,0,-1};
const int dy[4] = {0,-1,1,0};
void solve(){

      ll n , m ;
      cin >> n >> m ;
      ll i = m / n;
      ans =  1 ;
      for( ; i>=1 ; i--){
            if( m % i == 0 && ( (m/i) >= n) ){
                    cout << i ;
                    return ;
            }
      }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q=1;
    //cin >> q;
    while(q--)
        solve();
}
/*
    ---------------- lemmas-----------------------------------
   1)
   2)
   3)

*/


Measured memory_bytes: 256
n, m = map(int, input().split())
s = []
c = []
for _ in range(m):
    inp = list(map(int, input().split()))
    s.append(inp[0])
    c.append(inp[1])
ans = -1
for i in range(1000):
    if len(str(i)) == n:
        for j in range(m):
            if str(i)[s[j]-1] != str(c[j]):
                break
        else:
            ans = i
            break
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
ll inf = 1000000000;
typedef pair<ll, ll> P;
ll a[100005];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int count = 1;
	int up = 0;
	for (int i = 0; i < n - 1; i++) {
		if (up == 1 && a[i] > a[i + 1]) {
			count++;
			up = 0;
		}
		else if (up == 2 && a[i] < a[i + 1]) {
			count++;
			up = 0;
		}
		else if (up == 0 && a[i] < a[i + 1]) {
			up = 1;
		}
		else if (up == 0 && a[i] > a[i + 1]) {
			up = 2;
		}
	}
	cout << count << endl;
	return 0;
}

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



int main() {

	vector<char>N(3);
	rep(i, 3) {
		cin >> N[i];
		if (i != 0) {
			if (N[i - 1] != N[i]){
				cout << "Yes" << endl;
				return 0;
			}

		}
	}
	
	cout <<"No"<< endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long minn, n, q, h, ans, s, d,minnn;
int main()
{
	scanf("%lld%lld%lld%lld%lld", &q, &h, &s, &d, &n);
	minn = min(4*q, 2*h);
	minn = min(minn, s);
	//printf("%lld\n", minn);
	minnn = min(2*minn, d);
	ans = n/2;
	ans*=minnn;
	ans += (n%2)*minn;
	printf("%lld\n",ans );
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  bool now_inc = false;
  bool now_dec = false;

  if(n == 1){
    cout << 1 << endl;
    return 0;
  }

  int ans = 1;
  rep(i, n-1){
    if(a[i] < a[i+1]){
      if(now_dec){
        now_dec = false;
        ans++;
      }else{
        now_inc = true;
      }
    }else if(a[i] > a[i+1]){
      if(now_inc){
        now_inc = false;
        ans++;
      }else{
        now_dec = true;
      }
    }
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <queue>
#define N 1003
using namespace std;
struct edge{
	int to,nxt;
}e[N*N*3];
int n,cnt;
int ins[N*N],mp[N][N],fir[N*N],t[N*N];
queue<int >Q;
int id(int x,int y){
	if(x>y)	swap(x,y);
	return	(x-1)*n+y;
}

void add(int u,int v){
	e[++cnt]=(edge){v,fir[u]};fir[u]=cnt;++ins[v];
}
int main(){
	scanf("%d",&n);int ans=0;
	for(int i=1;i<=n;++i)
		for(int j=1;j<n;++j)
			scanf("%d",mp[i]+j);
	for(int i=1;i<=n;++i)
		for(int j=2;j<n;++j)
			add(id(i,mp[i][j-1]),id(i,mp[i][j]));
	for(int i=1;i<=n*n;++i){
		if(!ins[i])Q.push(i);
		t[i]=1;
	}
	while(!Q.empty()){
		int u=Q.front();Q.pop();ans=max(ans,t[u]);
		for(int i=fir[u];i;i=e[i].nxt){
			int v=e[i].to;
			--ins[v];
			if(!ins[v])
				Q.push(v),t[v]=t[u]+1;
		}
	}
	for(int i=1;i<=n;++i)
		if(ins[i])ans=-1;
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 26880