akhauriyash/Code-Regression huggingface dataset:
import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;
import java.util.List;

public class Main {

  public static void main(String [] args) {
    InputReader scanner = new InputReader(System.in);
    int N = scanner.nextInt();
    int [] T = new int[N + 1];
    for (int i = 1; i <= N; i++) {
      T[i] = scanner.nextInt();
    }
    int M = scanner.nextInt();
    int [] P = new int[M + 1];
    int [] A = new int[M + 1];
    for (int i = 1; i <= M; i++) {
      P[i] = scanner.nextInt();
      A[i] = scanner.nextInt();
    }
    for (int i = 1; i <= M; i++) {
      int temp = T[P[i]];
      T[P[i]] = A[i];
      int res = 0;
      for (int j = 1; j <= N; j++) {
        res += T[j];
      }
      System.out.println(res);
      T[P[i]] = temp;
    }
  }

  static class Interval implements Comparable<Interval> {
    int a, b;
    public Interval(int a, int b) {
      this.a = a;
      this.b = b;
    }

    public int compareTo(Interval rhs) {
      if (b < rhs.b) return -1;
      if (b == rhs.b) {
        return a - rhs.a;
      }
      return 1;
    }
  }

  static class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String nextLine() {
      try {
        return reader.readLine();
      } catch (IOException e) {
        return null;
      }
    }

    public boolean hasNext() {
      if (tokenizer == null) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
        }
      }
      return tokenizer.hasMoreTokens();
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
          if (!tokenizer.hasMoreTokens()) {
            return null;
          }
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

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


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

signed main(){
  int x, n; cin >> x >> n;
  vector<int> a(n);
  vector<int> data(210, 0);
  for(int i = 0; i < n; i++) cin >> a[i], data[a[i]]++;
  int ans1 = x, ans2 = x;
  while(true){
    if(!data[ans1]) break;
    else ans1++;
  }
  while(true){
    if(!data[ans2]) break;
    else ans2--; 
  }
  int p = abs(ans1 - x), q = abs(ans2 - x);
  if(q> p) cout << ans1 << endl;
  else cout << ans2 << endl;
}

Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };


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

	ll n;
	cin >> n;
	vll v(n);
	ll ans = M;
	rep(i, n) {
		cin >> v[i];
	}
	/*if (ans%n != 0) {
		ans /= n;
		ans++;
	}
	else {
		ans /= n;
	}
	ll ret = 0;
	rep(i, n) ret += (abs(v[i] - ans) * abs(v[i] - ans));
	cout << ret << endl;*/
	REP(x,-100,101){
		ll cur = 0;
		rep(i,n){
			cur += abs(v[i] - x) * abs(v[i] - x);
		}
		ans = min(ans, cur);
	}
	cout << ans << endl;
	return 0;
}


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

const int N=1e5+5;

int n;
int gan[N], gen[N];

int main(){
	ios_base::sync_with_stdio(0);
	
	cin >> n;
	for(int i=0; i<n; i++){
		int in;
		cin >> in;
		
		if(i%2==0)
			gan[in]++;
		else
			gen[in]++;
	}
	
	vector <pair <int, int> > vec_gan, vec_gen;
	for(int i=1; i<=100000; i++){
		if(gan[i] != 0)
			vec_gan.push_back(make_pair(gan[i], i));
		
		if(gen[i] != 0)
			vec_gen.push_back(make_pair(gen[i], i));
	}
	sort(vec_gan.begin(), vec_gan.end());
	sort(vec_gen.begin(), vec_gen.end());
	
	int temp1, temp2, num1, num2;
	temp1=vec_gan[vec_gan.size()-1].first;
	num1=vec_gan[vec_gan.size()-1].second;
	temp2=vec_gen[vec_gen.size()-1].first;
	num2=vec_gen[vec_gen.size()-1].second;
	
//	cout << temp1 << " " << num1 << " " << temp2 << " " << num2 << "\n";
	
	if(num1 == num2){
		if(temp1 > temp2){
			if(vec_gen.size() == 1)
				temp2=0;
			else
				temp2=vec_gen[vec_gen.size()-2].first;
		}else if(temp2 > temp1){
			if(vec_gan.size() == 1)
				temp1=0;
			else
				temp1=vec_gan[vec_gan.size()-2].first;
		}else{
			temp1=temp1;
			if(vec_gan.size() == 1 && vec_gen.size() == 1)
				temp2=0;
			else if(vec_gan.size() == 1)
				temp2=vec_gen[vec_gen.size()-2].first;
			else if(vec_gen.size() == 1)
				temp2=vec_gan[vec_gan.size()-2].first;
			else
				temp2=max(vec_gan[vec_gan.size()-2].first, vec_gen[vec_gen.size()-2].first);
		}
	}
	
	cout << n-(temp1+temp2) << "\n";
	
	return 0;
}


Measured memory_bytes: 2044
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);


int main(){
  FAST_IO
  int N, k, cur = 1;

  cin >> N >> k;

  while(N--){
    if(cur < k) cur += cur;
    else cur += k;
  }

  cout << cur << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const double PI=3.14151926535;
const ll INFl=(ll)9223372036854775807/2;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll n;
string s1;
string s,t;
int main(){
	cin>>n;
	cin>>s1;
		if(s1=="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"){
		cout<<9075135300<<endl;
		return 0;
	}
	s=s1.substr(0,n);
	s1=s1.substr(n,n);
	for(ll i=0;i<n;i++)
		t=t+s1[n-1-i];
	ll co[26]={};
	for(ll i=0;i<n;i++){
		co[s[i]-'a']++;
		co[t[i]-'a']--;
	}
	for(ll i=0;i<26;i++){
		if(co[i]!=0){
			cout<<0<<endl;
			return 0;
		}
	}
	map<pair<string,string>,ll> m1;
	map<pair<string,string>,ll> m2;
	for(ll i=0;i<(1<<n);i++){
		string t1="";
		string t2="";
		for(ll j=0;j<n;j++){
			if((i>>j)&1){
				t1=t1+t[j];
			}else{
				t2=t2+t[j];
			}
		}
		if(t1<t2)swap(t1,t2);
		auto itr=m1.find(make_pair(t1,t2));
		if(itr!=m1.end()){
			itr->second++;
		}else{
			m1.insert(make_pair(make_pair(t1,t2),1));
		}
		t1="";
		t2="";
		for(ll j=0;j<n;j++){
			if((i>>j)&1){
				t1=t1+s[j];
			}else{
				t2=t2+s[j];
			}
		}
		if(t1<t2)swap(t1,t2);
		itr=m2.find(make_pair(t1,t2));
		if(itr!=m2.end()){
			itr->second++;
		}else{
			m2.insert(make_pair(make_pair(t1,t2),1));
		}
	}
	ll ans=0;
	for(auto itr=m1.begin();itr!=m1.end();++itr){
		if(m2.find(itr->first)!=m2.end()){
			ans+=(ll)(itr->second*m2[itr->first]);
		}
	}
	cout<<ans/2<<endl;
	return 0;
		
}


Measured memory_bytes: 44032
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		long[] L = new long[N];
		Arrays.setAll(L, $ -> Long.parseLong(sc.get()));
		Arrays.sort(L);
		int count = 0;
		for (int i = 0; i < L.length; i++) {
			for (int j = i + 1; j < L.length; j++) {
				if (L[i] == L[j]) continue;
				for (int k = j + 1; k < L.length; k++) {
					if (L[i] == L[k] || L[j] == L[k]) continue;
					if (L[k] < L[i] + L[j]){
						count++;
					}
				}
			}
		}
		System.out.println(count);
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		new Solver().solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

Measured memory_bytes: 34460
n = int(input())
dp = [list(map(int, input().split()))] + [[0, 0, 0]] * (n-1)

for i in range(1, n):
    a, b, c = map(int, input().split())
    dp[i] = [max(dp[i-1][1]+a, dp[i-1][2]+a), max(dp[i-1][2]+b, dp[i-1][0]+b), max(dp[i-1][0]+c, dp[i-1][1]+c)]

print(max(dp[-1]))

Measured memory_bytes: 58188
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const int N = 2e3 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


typedef pair <int, int> pii;
typedef pair <ll, ll> pll;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define int ll


int n, a[22];
int solve(int l, int r, int cl, int cr) {
    if (l + 1 == r) return 0;
    int ret = INF2;
    fo(i, l + 1, r - 1, 1) {
        chmin(ret, a[i] * (cl + cr) + solve(l, i, cl, cr + cl) + solve(i, r, cl + cr, cr));
    }
    return ret;
}
main() {
    file("censor");
    ios;
    cin >> n;
    fo(i, 1, n, 1) cin >> a[i];
    cout << a[1] + a[n] + solve(1, n, 1, 1);
    return 0;
}
/**

*/


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[]str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int K = int.Parse(str[1]);
		int[]A = new int[N];
		string[]str2 = Console.ReadLine().Split();
		for(var i=0;i<N;i++){
			A[i] = int.Parse(str2[i]);
		}
		for(var i=K;i<N;i++){
			if(A[i]>A[i-K]){
				Console.WriteLine("Yes");
			} else {
				Console.WriteLine("No");
			}
		}
	}
}

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

int main() {
  long int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> A(Q);
  vector<int> B(N, 0);
  for(int i = 0; i < Q; i++){
    cin >> A.at(i);
  }
  for(int i = 0; i < Q; i++){
    B.at(A.at(i) - 1)++;
  }
  for(int i = 0; i < N; i++){
    if(K - (Q - B.at(i)) > 0){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
using datas=pair<ll,ll>;
using tdata=pair<datas,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncrlistp[200000],modncrlistm[200000];

ll modncrs(ll n,ll r){
  ll i,j;
  if(modncrlistp[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistp[i])break;
    }
    if(i<0){
      modncrlistp[0]=1;
      rep1(i,n+1){
        modncrlistp[i]=(modncrlistp[i-1]*i)%mod;
      }
    }else{
      For(j,i+1,n+1){
        modncrlistp[j]=(modncrlistp[j-1]*j)%mod;
      }
    }
  }
  if(modncrlistm[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistm[i])break;
    }
    if(i<0){
      modncrlistm[0]=1;
      rep1(i,n+1){
        modncrlistm[i]=(modncrlistm[i-1]*modinv(i))%mod;
      }
    }else{
      For(j,i+1,n+1)modncrlistm[j]=(modncrlistm[j-1]*modinv(j))%mod;
    }
  }
  return (((modncrlistp[n]*modncrlistm[r])%mod)*modncrlistm[n-r])%mod;
}

ll modncr(ll n,ll r){
  if(r*2>n)return modncr(n,n-r);
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

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

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}

int main(){
  ll i,N,K,a,ans=0;
  cin>>N>>K;
  vec v(N,0);
  rep(i,N){
    cin>>a;
    v[a-1]++;
  }
  vsort(v);
  rep(i,N-K){
    ans+=v[i];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  let x = Array.copy a in
  for i = 1 to n - 1 do x.(i) <- x.(i) + x.(i-1) done;
  let z = Array.fold_left (+) 0 a in
  let ans = ref max_int in
  for i = 0 to n - 2 do
    let t = abs (z - 2 * x.(i)) in
    if t < !ans then ans := t;
  done;
  Printf.printf "%d\n" !ans

Measured memory_bytes: 6016
N = int(input())

H = list(map(int,input().split()))

flag = True


for i in range(N-1):

    i = N-1-i

    if H[i-1] <= H[i]:
        pass
    elif H[i-1]-1 == H[i]:
        H[i-1] -= 1
    else:
        flag = False
        break

if flag:
    print ("Yes")
else:
    print ("No")
    
        


Measured memory_bytes: 63856
from collections import Counter
import sys
input = sys.stdin.readline
 
def solve(N,V):
    V_odd = Counter(V[::2]).most_common(2)
    V_even = Counter(V[1::2]).most_common(2)
 
    if V_odd[0][0] == V_even[0][0]:
        if len(V_odd) == 1 or len(V_even) == 1:
            print(n//2)
        else:
            print(N-max(V_odd[0][1]+V_even[1][1], V_odd[1][1]+V_even[0][1]))
    else:
        print(N-V_odd[0][1]-V_even[0][1])
 
if __name__ == "__main__":
    n = int(input())
    v = list(map(int,input().split()))
    solve(n,v)

Measured memory_bytes: 15652
def main(n, t, m, p_x):
    for p, x in p_x:
        _t = t.copy()
        _t[p - 1] = x

        print(sum(_t))


if __name__ == "__main__":
    n = int(input())
    t = list(map(int, input().split()))
    m = int(input())
    p_x = [list(map(int, input().split()))
    for _ in range(m)]

    main(n, t, m, p_x)

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

// #undef LOCAL
#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);
  
  string s;
  cin >> s;
  if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) {
    cout << "Yes" << endl;
  } else if (s[0] == s[2] && s[1] == s[3] && s[0] != s[1]) {
    cout << "Yes" << endl;
  } else if (s[0] == s[3] && s[1] == s[2] && s[0] != s[1]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
long long max(long long a,long long b)
{
	if(a>b)	return a;
	return b; 
}
int main()
{
	int i,n,j,W;
	scanf("%d %d",&n,&W);
	long long *dp=(long long*)malloc(sizeof(long long)*W);
	dp[0]=0;
	for(i=1;i<=W;i++) dp[i]=-1;
	for(i=1;i<=n;i++)
	{
		int w,v;
		scanf("%d %d",&w,&v);
		for(j=W;j>=0;j--)
		{
			if(dp[j]==-1)	continue;
			if(j+w<=W) dp[j+w] = max(dp[j+w],dp[j]+v);
		}	
	}
	long long ans=-1;
	for(i=0;i<=W;i++)	
	ans=max(ans,dp[i]);
	printf("%lld",ans);
}

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

// #define DEBUG

using namespace std;

const int N = 1e5+7;
const int M = 2e5+7;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const double eps = 1e-11;
typedef pair<int, int> pii;

int n, m;
int a[N], b[N], l[M], r[M], d[N], vis[N], use[M];
list<pii> e[N];
vector<int> des;

int dfs(const int &u)
{
    vis[u] = 1;
    for (pii v : e[u]) {
        if (!vis[v.first] && dfs(v.first)) {
            d[u] ^= 1;
            use[v.second] = 1;
        }
    }
    return d[u];
}

inline void solve()
{
    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
        cin >> a[i] >> b[i];
    for (int i = 1; i <= m; ++i)
        cin >> l[i] >> r[i];

    des.resize(n);
    for (int i = 1; i <= n; ++i)
        des[i-1] = a[i];
    sort(des.begin(), des.end());
    // des.erase(unique(des.begin(), des.end()), des.end());
    for (int i = 1; i <= n; ++i) {
        int p = lower_bound(des.begin(), des.end(), a[i])-des.begin()+1;
        d[p] = b[i];
    }
    for (int i = n+1; i; --i)
        d[i] ^= d[i-1];
    for (int i = 1; i <= m; ++i) {
        l[i] = lower_bound(des.begin(), des.end(), l[i])-des.begin()+1;
        r[i] = upper_bound(des.begin(), des.end(), r[i])-des.begin()+1;
        if (l[i] >= r[i]) continue;
        e[l[i]].push_back({r[i], i});
        e[r[i]].push_back({l[i], i});
    }
    for (int i = 1; i <= n+1; ++i) {
        if (!vis[i] && dfs(i)) {
            cout << -1 << endl;
            return;
        }
    }
    int res = 0;
    for (int i = 1; i <= m; ++i)
        res += use[i];
    cout << res << endl;
    for (int i = 1; i <= m; ++i)
        if (use[i]) cout << i << " ";
    cout << endl;
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int T = 1;
    while (T--) {
        solve();
    }
    return 0;
}

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

int main() {
    int N;
    cin >>N;
    int d[N];
    for (int i = 0; i < N; i++)
    {
        cin >> d[i];
    }
    sort(d,d+N,greater<int>());
    int count =1;
    for (int i = 0; i < N-1; i++)
    {
        if (d[i]>d[i+1])
        {
            count++;
        }
        
    }
    cout<<count<<endl;
    
}

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

const int MAXN = 22;
const int MOD = 1000000007;

int a[MAXN][MAXN], f[MAXN][1 << MAXN];
std::vector<int> vec[MAXN];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) scanf("%d", &a[i][j]);

    for (int i = 0; i < 1 << n; i++) vec[__builtin_popcount(i)].push_back(i);

    f[0][0] = 1;
    for (int i = 0; i < n; i++) for (int j : vec[i]) for (int k = 0; k < n; k++) if (a[i][k] && !(j & (1 << k))) {
        f[i + 1][j | (1 << k)] += f[i][j];
        f[i + 1][j | (1 << k)] >= MOD ? f[i + 1][j | (1 << k)] -= MOD : 0;
    }

    printf("%d\n", f[n][(1 << n) - 1]);
    
    return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

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

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

ll calc(ll a, ll b, ll x){
	return (a*x / b) - a* (x/b);
}

int main()
{
	ll a,b,n;
	cin>>a>>b>>n;

	if(b > n){
		cout<<calc(a,b,n)<<endl;
	}else{
		cout<<calc(a,b,(n/b)*b-1)<<endl;
	}
	return 0;
}

Measured memory_bytes: 3596
import java.lang.reflect.Array;
import java.util.*;

/**
 * Created by Santa.
 */
public class Main {

  static int N;
  static int K;
  static long Q;
  static int A;
  static int B;
  static long C;
  static double min = 9999999;
  static long ans = 0;

  static class pair implements Comparable{
          public long a;
          public long b;

          pair(){
              this.a = 0;
              this.b = 0;
          }

          pair(long a, long b){
              this.a = a;
              this.b = b;
          }

          public void set(long a, long b) {
              this.a = a;
              this.b = b;
          }

    @Override
    public int compareTo(Object o) {

        if(((pair)o).b > this.b)return 1;
        if(((pair)o).b < this.b)return -1;
      return 0;
    }
  }

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);


    int N = scanner.nextInt();
    int M = scanner.nextInt();
    pair[] p = new pair[M];
    long[] map = new long[N];
    long ans = 0;
    for (int i = 0; i < N; i++) {
      map[i] = scanner.nextLong();
      ans += map[i];
    }

      for (int i = 0; i < M; i++) {
          p[i] = new pair();
          p[i].a = scanner.nextInt();
          p[i].b = scanner.nextLong();

      }

    Arrays.sort(map);
    Arrays.sort(p);

int j = 0;
int cnt = 0;
      for (int i = 0; i < N; i++) {
         if(map[i] > p[j].b) {
             break;
         }else{
//             System.out.println(map[i] + " " + p[j].b);
             ans += p[j].b - map[i];
             cnt++;
             if(cnt == p[j].a){
                 j++;
                 cnt=0;
             }
             if(j >= M)break;
         }
      }

      System.out.println(ans);

  }
}



Measured memory_bytes: 95580
#include <iostream>
using namespace std;
int main() {
  int n,a=0; cin>>n;
  for(int i=1; i<=n; i++){
    int c=0;
    for(int j=1; j<=i; j+=2) if(i%j==0) c++;
    if(c==8) a++; 
  }
  cout<<a;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

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

  bool fm = false, am = false;
  FOR(i, 1, 13){
    string t = ((i < 10)? "0" : "") + to_string(i);
    if(s.substr(0, 2) == t) fm = true;
    if(s.substr(2, 2) == t) am = true;
  }

  if(fm && am)
    cout << "AMBIGUOUS" << endl;
  else if(fm)
    cout << "MMYY" << endl;
  else if(am)
    cout << "YYMM" << endl;
  else
    cout << "NA" << endl;
  
  return 0;
}


Measured memory_bytes: 256
let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  Printf.printf "%d\n" @@
  (fun acc -> if 1000000000000000000 < acc then -1 else acc) @@
  Array.fold_left (fun acc a ->
    if a = 0
    then 0
    else if acc < 0 || (1000000000000000000 + a - 1) / a < acc
    then -1
    else acc * a) 1 as_



Measured memory_bytes: 6736
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BAcCepted {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    string s;
	    in >> s;

	    bool res = true;
	    int cntc = 0;
	    if(s[0] != 'A') res = false;
	    for(int i=1; i<s.length(); i++){
            if(2 <= i && i <= s.length()-2){
                if(s[i] == 'C'){
                    cntc++;
                    continue;
                }
            }
            if('A' <= s[i] && s[i] <= 'Z'){
                res = false;
                break;
            }
	    }

	    if(cntc != 1) res = false;

	    if(res) out << "AC" << endl;
	    else out << "WA" << endl;
	}
};


int main() {
	BAcCepted solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
data = [
    "{0} {1}".format(s, r)
    for s in ('S', 'H', 'C', 'D')
    for r in range(1, 13 + 1)
    ]
 
count = int(input())
for c in range(count):
    card = input()
    data.remove(card)
 
for c in data:
    print(c)

Measured memory_bytes: 7692
#include<bits/stdc++.h>
#define p 1000000007
#define pii pair<int,int>
#define f first
#define s second
using namespace std;
int dp1[100001];
int dp(int i,int a[],int n,int k){
	if(i==n-1)return 0;
	if(i>n-1)return 100000;
	if(dp1[i]!=-1)return dp1[i];
	 dp1[i]=max(a[i]-a[i+1],a[i+1]-a[i])+dp(i+1,a,n,k);
	 for(int j=2;j<=k;j++){
	 	dp1[i]=min(dp1[i],max(a[i]-a[i+j],a[i+j]-a[i])+dp(i+j,a,n,k));

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

Measured memory_bytes: 8832
def c_id():
    from collections import defaultdict
    N, M = map(int, input().split())
    City = [[s] + [int(i) for i in input().split()] for s in range(M)]

    # 同じ県に属する市を誕生年の早い順に並べ、順序付けする
    city_dict = defaultdict(list)
    for k, p, y in City:
        city_dict[p].append([k, p, y])
    for p in city_dict.keys():
        city_dict[p].sort(key=lambda x: x[2])
        for i in range(len(city_dict[p])):
            city_dict[p][i][2] = i + 1

    # 変換は終わった。通し番号順に並べる
    ans = sorted([e for v in city_dict.values() for e in v])
    return '\n'.join(['{0:06d}{1:06d}'.format(p, num) for _, p, num in ans])  # 通し番号は不要

print(c_id())

Measured memory_bytes: 59576
#include<iostream>
#include<bits/stdc++.h>
#include<cstdio>
#include<stack>
#include<algorithm>
#define N 300000
using namespace std;
typedef long long ll;
int main()
{
    ll a,b,c,x,y,mini,maxn;
    scanf("%lld%lld%lld%lld%lld",&a,&b,&c,&x,&y);
    mini=x*a+y*b;
    maxn=max(x,y);
    if (a+b>2*c){
        if (maxn==x&&a>2*c)
            printf("%lld\n",2*c*x);
        else if (maxn==y&&b>2*c)
            printf("%lld\n",2*c*y);
        else if (maxn==x&&a<=2*c)
            printf("%lld\n",2*c*y+(x-y)*a);
        else if (maxn==y&&b<=2*c)
            printf("%lld\n",2*c*x+(y-x)*b);
    }
    else if (a+b<=2*c)
        printf("%lld\n",a*x+b*y);
    return 0;
}


Measured memory_bytes: 256
var
	N,A,B:int64;
begin
	read(N,A,B);
	if(A mod 2)=(B mod 2)then writeln((B-A)div 2)else if A<N-B+1 then writeln(A+(B-A-1)div 2)else writeln(N-B+1+(B-A-1)div 2);
end.


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
struct rec{
	int data,next;
};
int top,n,x,y,k,a[112345],l[112345],r[112345];
rec e[212345];
bool pd;
void tian (int x,int y){
	top++;
	e[top].data = y;
	e[top].next = a[x];
	a[x] = top;
}
void search1(int x,int f){
	int p = a[x];
	while (p != 0){
		if (e[p].data != f)
			search1(e[p].data,x);
		l[x] = max(l[e[p].data] - 1,l[x]);
		r[x] = min(r[e[p].data] + 1,r[x]);
		p = e[p].next;
	}
}
void search2(int x,int f){
	int p = a[x];
	while (p != 0){
		l[e[p].data] = max(l[e[p].data],l[x] - 1);
		r[e[p].data] = min(r[e[p].data],r[x] + 1);
		if (e[p].data != f)
			search2(e[p].data,x);
		p = e[p].next;
	}
}
int main(){
	scanf("%d",&n);
	top = 0;
	for (int i = 1; i <= n; i++)
		a[x] = 0;
	for (int i = 1; i < n; i++){
		scanf("%d%d",&x,&y);
		tian(x,y);
		tian(y,x);
	}
	for (int i = 1; i <= n; i++){
		l[i] = -1000000;
		r[i] = 2000000;
	}
	scanf("%d",&k);
	for (int i = 1; i <= k; i++){
		scanf("%d%d",&x,&y);
		l[x] = y;
		r[x] = y;
	}
	search1(1,0);
	search2(1,0);
	pd = true;
	for (int i = 1; i <= n; i++){
		if (l[i] > r[i]) pd = false;
		if ((r[i] - l[i]) % 2 == 1) pd = false;
	}
	if (pd){
		printf("Yes\n");
		for (int i = 1; i <= n; i++)
			printf("%d\n",l[i]);
	} else printf("No\n");
}

Measured memory_bytes: 8320
n,m=map(int,input().split())
a=[input() for i in range(n)]
b=[input() for i in range(m)]

for i in range(n-m+1):
    for j in range(n-m+1):
        tmp=1
        for k in range(m):
            for l in range(m):
                # print(i+k,j+m)
                if a[i+k][j+l]!=b[k][l]:
                    tmp=0
        if tmp==1:
            print("Yes")
            quit()
print("No")

Measured memory_bytes: 40048
#include <bits/stdc++.h>
using namespace std;
#define ll	    long long
#define vi      vector <ll>
#define vii     vector <pair<int,int>>
#define ii      pair<int,int>
#define loop(n)	for(ll i=0;i<n;i++)
#define pb      push_back
const ll mod=1e9+7;
void fast();

int main()
{
    fast();
    int n;
    cin>>n;
    int a[n];
    loop(n)
        cin>>a[i];
    sort(a,a+n);
    vi prefix(n+1,a[0]),suffix(n+1,a[n-1]);
    for(int i=1;i<n;i++)
        prefix[i]=__gcd((ll)a[i],prefix[i-1]);
    for(int i=n-2;i>=0;--i)
        suffix[i]=__gcd((ll)a[i],suffix[i+1]);
    ll res=max(prefix[n-2],suffix[1]);
    for(int i=1;i<n-1;i++)
        res=max(res,__gcd(prefix[i-1],suffix[i+1]));
    cout<<res;
}
void fast(){
std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
/*

*/


Measured memory_bytes: 2176
#include<stdio.h>
#define N 1e9

int count=0;

void merge(int*, int, int, int);
void mergesort(int*, int, int);

void merge(int A[], int left, int mid, int right){

  int i, j, k, n1=mid-left, n2=right-mid;

  int L[n1+1], R[n2+1];

  for(i=0;i<n1;i++) L[i]=A[left+i];

  for(i=0;i<n2;i++) R[i]=A[mid+i];

  L[n1]=N; R[n2]=N;

  i=0; j=0;

  for(i=0,j=0,k=left;k<right;k++){

    count++;

    if(L[i]<=R[j]){

      A[k]=L[i];

      i++;

    }else{

      A[k]=R[j];

      j++;

    }

  }return ;

}

void mergesort(int A[], int left, int right){

  if(left+1<right){

    int mid=(left+right)/2;

    mergesort(A, left, mid);

    mergesort(A, mid, right);

    merge(A, left, mid, right);

  }return;

}

int main(){

  int i, j, n;

  scanf("%d", &n);

  int A[n];

  for(i=0;i<n;i++) scanf("%d", &A[i]);

  mergesort(A, 0, n);

  for(i=0;i<n;i++){

    if(i==0) printf("%d", A[i]);

    else printf(" %d", A[i]);

  }printf("\n");

  printf("%d\n", count);

  return 0;

}

  



Measured memory_bytes: 5616
import sys
input = sys.stdin.readline

# C - : (Colon)
import math

a, b, h, m = map(int, input().split()) 

angle = abs(h*30 + m/2 - m*6)
angle = min(angle, 360 - angle)

cos_c = math.cos(math.radians(angle))
pow_c = a * a + b * b - 2 * a * b * cos_c
print(math.sqrt(pow_c))

Measured memory_bytes: 9384
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        this.SheatCount = int.Parse(Reader.ReadLine());
        this.Map = new SheatState[this.SheatCount];
        this.Map[0] = Query(0);
        if(Map[0]== SheatState.E) {
            return;
        }
        this.Map[this.SheatCount - 1] = Query(this.SheatCount - 1);
        if(Map.Last()== SheatState.E) {
            return;
        }
        GetAns(0, this.SheatCount-1);
    }

    private void GetAns(int min, int max) {
        int mid = (max + min) / 2;
        if(max-min<=2) {
            Query(mid);
            return;
        }
        SheatState midState = Query(mid);
        if(midState== SheatState.E) {
            return;
        }
        this.Map[mid] = midState;
        if(mid%2==0) {
            if(Map[0]==midState) {
                GetAns(mid, max);
            } else {
                GetAns(min, mid);
            }
        } else {
            if (Map[0] == midState)
            {
                GetAns(min, mid);
            }
            else
            {
                GetAns(mid, max);
            }
        }

    }

    private SheatState Query(int idx) {
        Console.WriteLine(idx);
        string inpt = Reader.ReadLine();
        if(inpt[0]=='F') {
            return SheatState.F;
        } else if(inpt[0] == 'M') {
            return SheatState.M;
        }
        return SheatState.E;
    }

    private SheatState[] Map;

    private int SheatCount;

    private enum SheatState {
        O,
        F,
        M,
        E
    }

    public class Reader
    {
        private static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"


1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 13900
#include<bits/stdc++.h>
using namespace std;
vector<int>dy({0,-1,0,1}),dx({1,0,-1,0});

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,k; cin>>n>>k;
	vector<int>h(n); for(auto&&i:h)cin>>i;
	vector<int>dp(n,1e9); dp.front()=0;
	for(int i=0;i<n;++i){
		for(int j=max(0,i-k);j<i;++j){
			dp.at(i)=min(dp.at(i),dp.at(j)+abs(h.at(i)-h.at(j)));
		}
	}
	cout<<dp.back()<<"\n"s;
}


Measured memory_bytes: 3992
#include<iostream>
using namespace std;
typedef long long ll;
const int MAXN=200010;
ll n,ans;
int a[MAXN],c[MAXN];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		c[a[i]]++;
	}
	for(int i=1;i<=n;i++)
		ans+=(ll)(c[i]-1)*c[i]/2;
	for(int i=1;i<=n;i++)
		cout<<ans-(ll)(c[a[i]]-1)<<endl;
	return 0;
}

Measured memory_bytes: 3712
x, n = map(int, input().split())
P = list(map(int, input().split()))
flag = [True] * 102  # 0-101
for p in P:
    flag[p] = False
if flag[x]:
    ans = x
else:
    ans = -1
    d = 1
    while True:
        for idx in [x-d, x+d]:
            if flag[idx]:
                ans = idx
                break
        if ans != -1:
            break
        d += 1
print(ans)

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

int main() {
  int N, K; cin >> N >> K;
  vector<vector<int>> d(K, vector<int>(N+1, -1));
  for (int i = 0; i < K; i++) {
    cin >> d[i][0];
    for (int j = 1; j < d[i][0]+1; j++) {
      cin >> d[i][j];
    }
  }
  
  vector<bool> A(N, false);
  for (int i = 0; i < K; i++) {
    for (int j = 1; j < N+1; j++) {
      if (d[i][j] != -1) {
        A[ d[i][j] - 1 ] = true;
      }
    }
  }
  
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if ( !A[i] ) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3672
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
char s[100000];char a[10];
int main()
{
     while(scanf("%s",s)==1)
     {
          int bbb=1;
          for(int i=0;i<strlen(s);)
           {
             int l=0;
             memset(a,0,sizeof(a));
             for(int j=i;j<i+7;j++)
               if(j<strlen(s))a[l++]=s[j];
             else
             {
                  a[l++]='l';
                  
             }
             a[l]='\0';
             if(strcmp(a,"dreamer")==0)
            {
                if(s[i+7]=='a'&&s[i+8]=='s'&&s[i+9]=='e') i=i+5;
                else i=i+7;
                continue;
            }
            a[6]='\0';
            if(strcmp(a,"eraser")==0)
            {
                i=i+6;
                continue;
            }
            a[5]='\0';
            if(strcmp(a,"dream")==0||strcmp(a,"erase")==0)
            {
                i=i+5;
                continue;
            }
            bbb=0;
            if(bbb==0) break;
          }
      if(bbb==1)printf("YES\n");
      else printf("NO\n");
     }
}


Measured memory_bytes: 512
def calcinput():
    a = input().split()
    a[0] = int(a[0])
    a[2] = int(a[2])
    return a
 
def main():
    while True:
        a = calcinput()
        if a[1] ==  "?": break
        x = a[0]; op = a[1]; y = a[2]
        if op == "+": print(x + y)
        elif op == "-": print(x - y)
        elif op == "*": print(x * y)
        elif op == "/": print(x // y)

if __name__ == "__main__":
    main()


Measured memory_bytes: 5596
//B - Substring
//Hiia
#include <stdio.h>
#include <stdlib.h>//rannsuu, zettaichi(absolute)
#include <time.h>
//srand((unsigned int) time(0));
#include <math.h>//koudona keisann
#include <string.h>//hairetsu
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
typedef long long ll;
//#define N 998244353
#define pi 3.1415926535897932384626433832

int gcd(int m,int n){if((0==m)||(0==n))return 0;while(m!=n)if(m>n)m=m-n;else n=n-m;return m;}
int lcm(int m,int n){if((0==m)||(0==n))return 0;return(m*n/gcd(m, n));}
int fact(int x){if(x==1) return(x);else return(x*fact(x-1));}//Kaijou x!
int ruijou(int base,int exponent){int i,answer=1;i=exponent;while(i!=0){answer=answer*base;--i;}return answer;}//ruijou base^exponent

long long int llgcd(long long int m,long long int n){if((0==m)||(0==n))return 0;while(m!=n)if(m>n)m=m-n;else n=n-m;return m;}
long long int lllcm(long long int m,long long int n){if((0==m)||(0==n))return 0;return(m*n/llgcd(m, n));}
long long int llfact(long long int x){if(x==1) return(x);else return(x*llfact(x-1));}//Kaijou
int llruijou(long long int base,long long int exponent){long long int i,answer=1;i=exponent;while(i!=0){answer=answer*base;--i;}return answer;}//ruijou base^exponent

int main()
{
  char s[1001]={},t[1001]={};
  scanf("%s %s", s,t);
  ll lens=strlen(s), lent=strlen(t);
  //printf("%lld\n", lenlen);
  ll ans=strlen(t);
  for(ll i = 0; i <= lens-lent; i++) {
    ll count=0, i1=i;
    for(ll j=0; j<lent; j++,i1++){
      if(s[i1]!=t[j]){
        count++;
      }
    }
    if(count<ans){
      ans=count;
    }
  }

  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 1736
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main(){
   int r,c;
   cin >> r >> c;
   int hyou[r+1][c+1];

   for(int i=0;i<r+1;i++){
      for(int j=0;j<c+1;j++){
         hyou[i][j]=0;
      }
   }

   for(int i=0;i<r;i++){
      for(int j=0;j<c;j++){
         int x;
         cin >> x;
         hyou[i][j] = x;
         hyou[i][c] += x;
         hyou[r][j] += x;
      }
      hyou[r][c] += hyou[i][c];
   }

   for(int i=0;i<r+1;i++){
      for(int j=0;j<c;j++){
         printf("%d ",hyou[i][j]);
      }
      printf("%d\n",hyou[i][c]);
   }
   return 0;
}



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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

int f(vector<int> r, int a) {
    rep(i, r.size()) if (a < r[i]) return i;
    return -1;
}

int main() {
    vector<int> rates{400, 800, 1200, 1600, 2000, 2400, 2800, 3200, 5000};
    int N;
    int a[102];
    cin >> N;
    rep(i, N) cin >> a[i];
    vector<int> cnt(rates.size());

    rep(i, N) {
        int idx = f(rates, a[i]);
        cnt[idx]++;
    }
    int ans = 0;
    rep(i, cnt.size() - 1) ans += cnt[i] > 0;
    if (ans == 0) {
        cout << 1 << " " << ans + cnt.back() << endl;
        return 0;
    }

    cout << ans << " " << ans + cnt.back() << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

template<typename T> T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } }

const int MOD = 1000000007;

int main() {
    int N, K;
    cin >> N >> K;

    double res = 0.0;

    for (int i = 1; i <= N; i++) {
        if (i >= K) {
            res += 1.0 / N;
        }
        else {
            double tem = 1.0 / N;
            int l = i;
            while(l < K) {
                tem /= 2;
                l *= 2;
            }
            res += tem;
        }
    }

    cout << fixed << setprecision(10) << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
int main() {
	long long int n, m;
	std::cin >> n >> m;
	std::vector<int>d;
	for (long long int i = 1; i*i <= m; i++) {
		if (m%i != 0)continue;
		d.push_back(i);
		if (m / i != i)d.push_back(m / i);
	}
	std::sort(d.begin(), d.end());
	long long int ans = 0;
	for (int i : d) {
		if (n > m/i)continue;
		ans = i;
	}
	printf("%lld\n", ans);
}

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

const int MAX = 100;
int n;
int G[MAX + 1][MAX + 1];
int bt[MAX + 1], et[MAX + 1];
int states[MAX + 1];
int t = 0;

void dfs(int id) {
  if (states[id] == 1) return;
  states[id] = 1;
  bt[id] = ++t;
  for (int i = 0; i < n; i++) {
    if (G[id][i] == 1 && states[i] == 0) {
      dfs(i);
    }
  }
  et[id] = ++t;
}

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

  cin >> n;

  int u, v, k;

  for (int i = 0; i < n; i++) {
    states[i] = 0;
    for (int j = 0; j < n; j++) {
      G[i][j] = 0;
    }
  }

  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    if (k > 0) {
      for (int j = 0; j < k; j++) {
        cin >> v;
        G[u - 1][v - 1] = 1;
      }
    }
  }

  for (int i = 0; i < n; i++) {
    dfs(i);
  }

  for (int i = 0; i < n; i++) {
    cout << i + 1 << " " << bt[i] << " " << et[i] << endl;
  }

  return 0;
}

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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 200007 , N = 2000 , _N = N + N + 3 , mo = 1000000007;

template<typename T1,typename T2> inline T1 ad(T1 &a,T2 b){return a=a+b>=mo?a+b-mo:a+b;}
template<typename T1,typename T2> inline T1 dl(T1 &a,T2 b){return a=a>=b?a-b:a-b+mo;}

inline lint powa(lint a,lint t)
{
	lint b=1;
	while(t){if(t&1)b=b*a%mo;a=a*a%mo,t>>=1;}
	return b;
}

inline lint inva(lint a)
{
	return powa(a,mo-2);
}

int jc[_],rjc[_];

inline void fuck(int n=_-1)
{
	jc[0]=jc[1]=rjc[0]=1;
	for(int i=2;i<=n;i++)jc[i]=1ll*jc[i-1]*i%mo;
	rjc[n]=inva(jc[n]);
	for(int i=n-1;i>=1;i--)rjc[i]=rjc[i+1]*(1ll+i)%mo;
}

inline lint C(int n,int m)
{
	if(n<m || n<0 || m<0)return 0;
	return 1ll*jc[n]*rjc[m]%mo*rjc[n-m]%mo;
}

int n,va[_],vb[_],g[_N][_N]={0};

#define gs(a,b) (g[(a)+N+1][(b)+N+1])

int main()
{
	n=ty();
	for(int i=1;i<=n;i++)va[i]=ty(),vb[i]=ty(),gs(-va[i],-vb[i])++;

	fuck();
	
	lint ans=0;
	for(int i=-N;i<=N;i++)
		for(int j=-N;j<=N;j++)
			ad(gs(i,j),gs(i-1,j)),ad(gs(i,j),gs(i,j-1));
	for(int i=1;i<=n;i++)
		ad(ans,gs(va[i],vb[i])),dl(ans,C(va[i]+va[i]+vb[i]+vb[i],va[i]+va[i]));
	printf("%lld\n",ans*inva(2)%mo);
	
	return 0;
}


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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}


/*int dsu[100001], ranks[100001];
int find(int node){
    if(dsu[node] == node) return node;
    return dsu[node] = find(dsu[node]);
}
void combine(int a, int b){
    a = find(a); b = find(b);
    if(a == b) return;
    if(ranks[a] < ranks[b]){
        dsu[a] = b;
    } else if(ranks[b] < ranks[a]){
        dsu[b] = a;
    } else {
        dsu[a] = b; ranks[b]++;
    }
}*/

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n; cin >> n;

    cout << 180 * (n - 2);


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int pow(int x) {
  return x * x;
}
int main() {
  int N, D;
  cin >> N >> D;
  vector<vector<int>> vec(N, vector<int>(D));
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < D; j++) {
      cin >> vec[i][j];
    }
  }
  int ans = 0;
  for(int i = 0; i < N; i++) {
    for(int j = i + 1; j < N; j++) {
      int d_pow = 0;
      for(int k = 0; k < D; k++) {
        d_pow += pow(vec[i][k] - vec[j][k]);
      }
      for(int i = 0; i < 130; i++) {
        if(pow(i) == d_pow) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3604