akhauriyash/Code-Regression huggingface dataset:
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    x = I()
    ans = 0
    cnt = 0

    while cnt<x:
        ans += 1
        cnt += ans

    print(ans)
    
main()            


Measured memory_bytes: 74568
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

int main(){
    int a,b;
    cin >> a>>b;
    if(a>b){
        swap(a,b);
    }
    if(a==1&&b==2){
        cout<<3<<endl;
    }else if(a==2&&b==3){
        cout<<1<<endl;
    }else{
        cout<<2<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<pair<long long, long long>> task1;
  vector<pair<long long, long long>> task2;
  for(int i = 0; i < n; i++){
    long long a,b; cin >> a >>b;
    task1.push_back(make_pair(a,b));
    task2.push_back(make_pair(b,a));
  }
  sort(task1.begin(),task1.end());
  sort(task2.begin(),task2.end());
  long long ans = 0;
  for(int i = 0; i < n; i++){
    if(ans + task1.at(i).first > task1.at(i).second)
      break;
    else
      ans += task1.at(i).first;
    if(i == n -1){
      cout << "Yes";
      return 0;
    }
  }
  ans = 0;
  for(int i = 0; i < n; i++){
    if(ans + task2.at(i).second > task2.at(i).first)
      break;
    else
      ans += task2.at(i).second;
    if(i == n -1){
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
  
  
}
  

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

int main(){
    string s;
    cin >>s;
    int ans = 0;
    int l = s.size();
    for(int i = 0;i< l/2;i++){
        if(s[i]!=s[l-i-1])ans++;
    }
    cout << ans;
    return 0;
}


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

using namespace std;
const int Max_N(1050);
const int Max_M(200050);

namespace io
{
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush (){fwrite (obuf, 1, oS - obuf, stdout);oS = obuf;}
	inline void putc (char x){*oS ++ = x;if (oS == oT) flush ();}
	template <class I>
	inline void gi (I &x) {for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;}
	template <class I>
	inline void print (I x){
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;while(x) qu[++ qr] = x % 10 + '0',  x /= 10;while (qr) putc (qu[qr--]);}
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io::gi;
using io::putc;
using io::print;

struct edge
{
	edge(int _t, int _pos) : t(_t), pos(_pos) {}
	int t, pos;
};
int N, M, S, Ans[Max_M];
vector<edge> G[Max_N];
bool done[Max_N], Can[Max_N][Max_N];

void dfs1(int u)
{
	if (Can[S][u])
		return;
	Can[S][u] = true;
	for (int i = 0, t;i < G[u].size();++i)
		dfs1(G[u][i].t);
}

void dfs2(int u)
{
	if (done[u])
		return;
	done[u] = true;
	for (int i = 0, t;i < G[u].size();++i)
		dfs2(G[u][i].t);
}

int main()
{
	gi(N), gi(M);
	for (int i = 1, s, t;i <= M;++i)
		gi(s), gi(t), G[s].push_back(edge(t, i)), Ans[i] = 0;
	for (S = 1;S <= N;++S)
	{
		Can[S][S] = true;
		for (int i = 0, t;i < G[S].size();++i)
			if (Can[S][t = G[S][i].t])
				Ans[G[S][i].pos] = 1;
			else
				dfs1(t);
	}
	for (S = 1;S <= N;++S)
	{
		memset(done, false, sizeof(done)), done[S] = true; 
		for (int i = G[S].size() - 1, t;i >= 0;--i)
			if (done[t = G[S][i].t])
				Ans[G[S][i].pos] = 1;
			else
				dfs2(t);
	}
	for (int s = 1;s <= N;++s)
		for (int i = 0;i < G[s].size();++i)
			if (Can[G[s][i].t][s])
				++Ans[G[s][i].pos];
	for (int i = 1;i <= M;++i)
	{
		if (Ans[i] != 1)
			putc('s'), putc('a'), putc('m'), putc('e');
		else
			putc('d'), putc('i'), putc('f'), putc('f');
		putc('\n');
	}
	return 0;
}

Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000



int main(){
	
	string S;
	cin>>S;
	S[5]=' ';
	S[13]=' ';
	cout<<S<<endl;
	
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#define ll long long

int n;
ll m, table[100010];

int main(){
	int i, a, s;
	scanf("%d %lld", &n, &m);
	for(i = 0; i < n; i++){
		scanf("%d %d", &a, &s);
		table[a] += s;
	}
	for(i = 1; i <= 1e5; i++){
		if(m <= table[i]){ printf("%d", i); return 0; }
		m -= table[i];
	}
	return 0;
}

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

int main(void){

  int pepl,gtrn;
  int tar[100] = {0};
  int res[100] = {0};
  int buff,wrong;

  cin >> pepl >> gtrn;
  for(int i = 0;i<gtrn;i++) cin >> tar[i];

  for(int i = 0;i<gtrn;i++){
    wrong = 0;
    for(int j = 0;j<pepl;j++){
      cin >> buff;
      if(buff == tar[i]) res[j]++;
      else wrong++;
    }
    res[tar[i]-1] += wrong;
  }

  for(int i = 0;i<pepl;i++) cout << res[i] << endl;

  return 0;
}

Measured memory_bytes: 3080
import java.util.Scanner;

class Main {
  private final static String INSERT = "insert";
  private static Tree ROOT = null;
  private static Tree END = null;

  public static void main(String... args) {
    Scanner sc = new Scanner(System.in);
    int times = Integer.parseInt(sc.next());
    // List<Tree> tree = new ArrayList<>(times - 1);

    for (int i = 0; i < times; i++) {
      if (sc.next().equals(INSERT)) {
        insert(Integer.parseInt(sc.next()));
      } else {
        createBuilderInorder(ROOT);
        System.out.println();
        createBuilderByRoot(ROOT);
        System.out.println();
      }
    }
  }

  public static void insert(int key) {
    Tree y = null;
    Tree x = ROOT;
    Tree z = new Tree();
    z.key = key;

    while (x != null) {
      y = x;
      if (z.key < x.key) {
        x = x.left;
      } else {
        x = x.right;
      }
    }

    z.parent = y;

    if (y == null) {
      ROOT = z;
    } else if (z.key < y.key) {
      y.left = z;
    } else {
      y.right = z;
    }
  }

  public static void createBuilderInorder(Tree tree) {
    if (tree != null) {
      createBuilderInorder(tree.left);
      System.out.print(" ");
      System.out.print(tree.key);
      createBuilderInorder(tree.right);
    }
  }

  public static void createBuilderByRoot(Tree tree) {
    if (tree != null) {
      System.out.print(" ");
      System.out.print(tree.key);
      createBuilderByRoot(tree.left);
      createBuilderByRoot(tree.right);
    }
  }
}

class Tree {
  public int key;
  public Tree left;
  public Tree right;
  public Tree parent;

  public Tree() { }
}



Measured memory_bytes: 214140
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, ans;
  cin >>n;
  ans = n/1.08;
  if(floor(ans*1.08)==n){
    cout << ans << endl;
  }
  else if(floor((ans+1)*1.08)==n){
    cout << ans+1 << endl;
  }
  else{
    cout << ":(" << endl;
  }
}

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

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> vec(n);
  
  for (int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    vec.at(a-1)++;
    vec.at(b-1)++;
  }
  
  for (int i = 0; i < n; i++){
    cout << vec.at(i) << endl;
  }
}
  
    
      



Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver1.9.4
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a[a.size()-1]<<endl;
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

signed main() {
  cout << fixed << setprecision(15);
  int n,m,k;
  cin >> n >> m >> k;
  set<int> kind;
  kind.insert(n*m);
  
  rep(i,0,m){
    kind.insert(n*i);
  }
  rep(i,0,n){
    kind.insert(m*i);
  }
  int memo;
  rep(i,0,m){
    rep(j,0,n){
      memo = i*n + j*m - 2*i*j;
      kind.insert(memo);
      //cout << memo <<' ';
    }
  }
  
  if(kind.count(k)) cYes;
  else cNo;
  return 0;
}


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

template <typename T,typename E>
struct SegmentTree{
  using F = function<T(T,T)>;
  using G = function<T(T,E)>;
  Int n;
  F f;
  G g;
  T ti;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(Int n_,F f,G g,T ti):
    f(f),g(g),ti(ti){
    init(n_);
  }
  void init(Int n_){
    n=1;
    while(n<n_) n*=2;
    dat.assign(2*n-1,ti);
  }
  void build(Int n_, vector<T> v){
    for(Int i=0;i<n_;i++) dat[i+n-1]=v[i];
    for(Int i=n-2;i>=0;i--)
      dat[i]=f(dat[i*2+1],dat[i*2+2]);
  }
  void update(Int k,E a){
    k+=n-1;
    dat[k]=g(dat[k],a);
    while(k>0){
      k=(k-1)/2;
      dat[k]=f(dat[k*2+1],dat[k*2+2]);
    }
  }
  
  inline T query(Int a,Int b){
    T vl=ti,vr=ti;
    for(Int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,dat[(l++)-1]);
      if(r&1) vr=f(dat[(--r)-1],vr);
    }
    return f(vl,vr);
  }

  Int find(Int a,Int b,function<bool(T)> &check,Int k,Int l,Int r){
    if(!check(dat[k])||r<=a||b<=l) return -1;
    if(k>=n-1) return k-(n-1);
    Int m=(l+r)>>1;
    Int vl=find(a,b,check,k*2+1,l,m);
    if(~vl) return vl;
    return find(a,b,check,k*2+2,m,r);
  }
  
  Int find(Int a,Int b,function<bool(T)> &check){
    return find(a,b,check,0,0,n);
  }
  
};

//INSERT ABOVE HERE
signed main(){
  Int n,q;
  cin>>n>>q;
  n*=2;
  vector<Int> a(n),b(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  for(Int i=0;i<n;i++) cin>>b[i];
  
  using P = pair<Int, Int>;
  auto f=[](P a,P b){return P(max(a.first+b.first ,a.second+b.second),
			      max(a.first+b.second,a.second+b.first));};
  auto g=[](P a,P b){return b;};

  const Int INF = 1e15;
  SegmentTree<P, P> seg(n,f,g,P(0,-INF));
  vector<P> v(n);
  for(Int i=0;i<n;i++) v[i]=P(a[i],b[i]);
  seg.build(n,v);
  
  for(Int i=0;i<q;i++){
    Int p,x,y;
    cin>>p>>x>>y;
    p--;
    a[p]=x;b[p]=y;
    seg.update(p,P(a[p],b[p]));
    Int ans=a[0]+a[n-1]+seg.query(1,n-1).first;
    cout<<ans<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 17792
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] num = new int[85715];
		int[] sosu = new int[35813];
		int[] tansaku = new int[300001];
		for(int i=6;i<=300000;++i){
			if(i%7==6 || i%7==1){
				tansaku[i]=1;
			}
		}
		int end=(int)Math.sqrt((double)300000);
		for(int i=6;i<=end;i++){
			if(tansaku[i]==1){
				for(int j=i+i;j<=300000;j+=i){  // 素数の定数倍は素数とならないので排除するループ
					if(tansaku[j]==1){
						tansaku[j]=0;
					}
				}
			}
		}
		int m=0;
		for(int i=6;i<=300000;++i){
			if(tansaku[i]==1){
				sosu[m]=i;
				++m;
			}
		}
		
		while(true){
			int n = sc.nextInt();
			if(n==1) break;
			Queue<Packet> que = new LinkedList<Packet>();
			HashSet<Integer> ans = new HashSet<Integer>();
			for(int i=0;i<sosu.length;++i){
				if(n%sosu[i]==0)
					if(n/sosu[i]==1) ans.add(sosu[i]);
					else que.add(new Packet(n/sosu[i],sosu[i]));
			}
			while(!que.isEmpty()){
				Packet pa = que.remove();
				for(int i=0;i<sosu.length;++i){
					if(pa.n%sosu[i]==0){
						if(pa.n/sosu[i]==1) ans.addAll(pa.set);
						else que.add(new Packet(pa.n/sosu[i],sosu[i]));
					}
				}
			}
			Iterator iterator = ans.iterator();
			int[] anss = new int[ans.size()];
			System.out.print(n+":");
			for(int i=0;i<ans.size();++i){
				anss[i]=(int) iterator.next();
			}
			Arrays.sort(anss);
			for(int i=0;i<anss.length-1;++i){
				System.out.print(" "+anss[i]);
			}
			System.out.println(" "+anss[anss.length-1]);
		}
	}
	
	public static class Packet{
		int n;
		HashSet<Integer> set = new HashSet<Integer>();
		Packet(int n,int sosu){
			this.n=n;
			set.add(sosu);
		}
	}
}



Measured memory_bytes: 37644
use std::cmp;
use std::collections::VecDeque;
use std::io;

#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

const SPLIT_DELIMITER: char = ' ';
#[allow(dead_code)]
fn input_vector<T>() -> VecDeque<T>
where
    T: std::str::FromStr,
{
    let mut v: VecDeque<T> = VecDeque::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push_back(buf);
    }
    v
}

fn main() {
    let n: usize;
    input!(n);
    let mut v = input_vector::<isize>();
    let mut anslist: Vec<isize> = Vec::new();
    v.push_back(0);
    v.push_front(0);

    let mut sum = 0;
    for z in 0..n + 1 {
        sum += (v[z] - v[z + 1]).abs();
    }

    for z in 1..n + 1 {
        if v[z - 1] < v[z] && v[z] < v[z + 1] || v[z - 1] > v[z] && v[z] > v[z + 1] {
            anslist.push(0);
        } else {
            anslist.push(cmp::min((v[z + 1] - v[z]).abs(), (v[z - 1] - v[z]).abs()));
        }
    }
    for z in anslist {
        p(sum - 2 * z);
    }
}

Measured memory_bytes: 7292
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  int co5=0; int co7=0;
  for(int i=0;i<3;i++){
    if(a[i]==5) co5 = co5+1;
    if(a[i]==7) co7 = co7+1;
  }
  if(co5==2 && co7==1) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
/*#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>

using namespace std;
# define ll long long
# define int long long  //comment it out when MLE
# define endl "\n"
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
# define mod 998244353
# define pi acos(-1)
# define fi first
# define se second
int add(int a, int b) {
	a += b;
	if (a >= mod) a -= mod;
	return a;
}

int mul(ll a, int b) {
	a *= b;
	return a % mod;
}
signed main()
{
    gok
  int n,k;
  cin>>n>>k;

  if(k>=n)
    cout<<"unsafe";
  else
    cout<<"safe";



















    return 0;
    }


Measured memory_bytes: 3580
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int a[200100];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i = 1;i <= n;i++)scanf("%d",&a[i]);
	if(n % 2)
	{
		for(int i = n;i >= 1;i -= 2)
			printf("%d ",a[i]);
		for(int i = 2;i < n;i += 2)
			printf("%d ",a[i]);
	}else
	{
		for(int i = n;i > 1;i -= 2)
			printf("%d ",a[i]);
		for(int i = 1 ;i < n;i += 2)
			printf("%d ",a[i]);
	}
}

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
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...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
void str(bool judge){
  if(judge)cout<<"First"<<endl;
  else cout<<"Second"<<endl;
}
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,0,n)cin>>a[i];
  if(n==1)str(0);
  else if(n==2){
    str((a[0]+a[1])&1);
  }
  else{
    ll now=0;
    while(1){
      ll odd=0,oddnum=0;
      rep(i,0,n)if(a[i]&1)odd++,oddnum=a[i];
      ll sum=0;rep(i,0,n)sum+=a[i]-1;
      if(sum&1){
        str(!now);
        break;
      }
      if(oddnum==1||odd!=1){
        str((now^sum)&1);
        break;
      }
      ll g=0;
      rep(i,0,n){
        if(a[i]&1)g=gcd(g,a[i]-1);
        else g=gcd(g,a[i]);
      }
      rep(i,0,n)a[i]/=g;
      now^=1;
    }
  }
  return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			//int x = Integer.parseInt(br.readLine());
			String input = br.readLine();

			if(input.equals("0")){
				break;
			}

			int sum = 0;
			for(int i = input.length() - 1; i >= 0 ; i--){
				sum += input.charAt(i) - '0';
			}

			System.out.println(sum);
		}
//		String input = br.readLine();

//		for(int i = 0; i < input.length() ; i++){
//			char c = input.charAt(i);
//
//			if(Character.isLowerCase(c)){
//				System.out.print(Character.toUpperCase(c));
//			}
//
//			else if(Character.isUpperCase(c)){
//				System.out.print(Character.toLowerCase(c));
//			}
//			else {
//				System.out.print(c);
//			}
//		}
//		System.out.println();

//		String[] tmpArray = br.readLine().split(" ");
//		int n = Integer.parseInt(tmpArray[0]);
//		int m = Integer.parseInt(tmpArray[1]);
//		int l = Integer.parseInt(tmpArray[2]);
//
//		long[][] a = new long[n][m];
//		long[][] b = new long[m][l];
//		long[][] c = new long[n][l];
//
//		for(int i = 0; i < n; i ++){
//			tmpArray = br.readLine().split(" ");
//			for(int j = 0; j < m; j++){
//				a[i][j] = Long.parseLong(tmpArray[j]);
//			}
//		}
//
//		for(int i = 0; i < m; i ++){
//			tmpArray = br.readLine().split(" ");
//			for(int j = 0; j < l; j++){
//				b[i][j] = Integer.parseInt(tmpArray[j]);
//			}
//		}
//
//		for(int i = 0; i < n; i++){
//			for(int j = 0; j < l; j++){
//				for(int k = 0; k < m; k++){
//					c[i][j] += a[i][k]*b[k][j];
//				}
//
//				if(j != 0 ){
//					System.out.print(" ");
//				}
//				System.out.print(c[i][j]);
//			}
//			System.out.println();
//		}


	}

}

Measured memory_bytes: 24448
#include<bits/stdc++.h>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007ll
#define PI 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
//--namespace
using namespace std;
//--useful function
ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
// --clock funtion
clock_t time_p=clock();
void TimeTaken()
{
    time_p=clock()-time_p;
    cerr<<"Completion time : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
// --solve function
void solve() {

}
//--main function
int main(){
	umap <int,int> o;
	int n,a,s=0;cin>>n;
	REP(i,0,n-1)
	{
		cin>>a;
		o[a]++;
	}
	for(auto x:o){
		if(x.second%2!=0)s++;
	}
	cout<<s;
		
		
	
	return 0;

//   TimeTaken();
}


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

using namespace std;

// MACROS

#define ll long long
#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define u_s unordered_set

#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i, n) for (ll (i) = 0; i < n; i++)
#define FORN(i, a, b) for (ll (i) = a; i < b; i++)
#define FORE(i, l) for (auto (i) : l)

#define pb push_back
#define pob pop_back
#define emp emplace
#define fi first
#define se second

#define all(n) (n).begin(), (n).end()
#define in(n) cin >> (n);
#define debug(n) cout << #n << ": " << n << '\n';

// FUNCTIONS

template< typename T >
inline T gcd(T a, T b) { if (b) return gcd(b, a % b); return a; }

template< typename T >
inline T ext_gcd(T a, T b, T & x, T & y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = ext_gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; }

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);	
    //cout << setprecision(15);
    int a[3][3];
    FOR(i, 3)
    {
        FOR(j, 3)
        {
            cin >> a[i][j];
        }
    }
    ll n;
    cin >> n;
    FOR(i, n)
    {
        ll x;
        cin >> x;
        FOR(i, 3)
        {
            FOR(j, 3)
            {
                if (a[i][j] == x) a[i][j] = -1;
            }
        }
    }
    bool works = false;
    FOR(i, 3)
    {
        if (a[i][0] == -1 && a[i][1] == -1 && a[i][2] == -1) works = true;
        if (a[0][i] == -1 && a[1][i] == -1 && a[2][i] == -1) works = true;
    }
    if (a[0][0] == -1 && a[1][1] == -1 && a[2][2] == -1) works = true;
    if (a[2][0] == -1 && a[1][1] == -1 && a[0][2] == -1) works = true;
    if (works) cout << "Yes\n";
    else cout << "No\n";
}



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

using namespace std;

#define boost                         \
    ios_base::sync_with_stdio(false); \
    fin.tie(NULL);                    \
    fout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<ll, ll>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for (auto &z : v)
#define sp << ' ' <<
#define sps << ' '
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353
#define PI_2 1.57079632679489661923

int main()
{
    // boost;
    // ifstream fin;
    // fin.open("./fb_d1.txt");
    // ofstream fout;
    // fout.open("./d1_out.txt");

    time_t tic, toc;
    ll tt = 1, n, m, k = 0, i, j, p, q;
    ll a, b, c, h, w, u, v, x, y, t;
    ll l = 0, r = 0;
    ll ans = 0;

    bool poss = true;

    string s;

    // cin >> tt;
    tic = clock();
    for(int _ = 1; _ <= tt; _++){
        // cout << "Case #" << _ << ": ";
        cin >> n;
        
        cout << (n >= 30?"Yes":"No") << nl;
    }
    // fin.close();
    // fout.close();
    // cerr << (clock() - tic*1.0) / CLOCKS_PER_SEC << nl;
    return 0;
}


Measured memory_bytes: 3624
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
 
t1, x1, y1 = 0, 0, 0 
for t2, x2, y2 in D:
  t = t2 - t1
  d = abs(x2 - x1) + abs(y2 - y1)
  if d > t or (t - d) % 2:
    print('No')
    break
  t1, x1, y1 = t2, x2, y2
else:
  print('Yes')
  

Measured memory_bytes: 27324
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *P = map(int, read().split())

    k = sum(1 for i, p in enumerate(P, 1) if i != p)

    if k > 2:
        print('NO')
    else:
        print('YES')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9136
n = int(input())
S = list(map(int, input().split(' ')))
S.sort()
q = int(input())
T = list(map(int, input().split(' ')))
T.sort()

count = 0
for t in T:
    min_idx = 0
    max_idx = len(S) - 1
    while min_idx <= max_idx:
        mid_idx = (min_idx+max_idx) // 2
        if t < S[mid_idx]:
            max_idx = mid_idx - 1
        elif t > S[mid_idx]:
            min_idx = mid_idx + 1
        else:
            count += 1
            break
print(count)


Measured memory_bytes: 6548
#include<stdio.h>
int main(void){
	
	char s[100000];
	scanf("%s",s);
	
	int i,len=strlen(s);
	
	
	
	if(len%2==0){
	for(i=0;i<len/2;i++){
		
		printf("%c",s[2*i]);
		
	}
	}else {
	
	for(i=0;i<len/2+1;i++){
		
		printf("%c",s[2*i]);
		
	}
	}	
	
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    b -= 1;
    a -= 1;
    if ( b%a == 0 ){
        cout << b / a;
    }
    else{
        cout << b / a + 1;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include<algorithm>
using namespace std;
int main()
{
    long long int n,sum=100;
    scanf("%lld",&n);
    int i;
    for(i=0; i<=3760; i++)
    {
        if(sum>=n)
            break;
        sum=sum+sum*0.01;
        //printf("%lld\n",sum);
    }
    printf("%d\n",i);
    return 0;
}


Measured memory_bytes: 3828
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

#define max(a,b) ((a > b) ? a : b)
#define min(a,b) ((a < b) ? a : b)

using namespace std;

int A, B;

int main()
{
	cin >> A >> B;
	double A2 = (double)A * 12.5;
	double A3 = ceil(A2);
	double B2 = (double)B * 10;
	double B3 = ceil(B2);
	double c = max(A3,B3);

	if( (int)(c*0.08) != A ||  (int)(c*0.1) != B)
	{
		cout << -1 << endl;
	}else{
		cout << (int)c << endl;
	}

	return 0;
}

/*long int N, A, B;

int main()
{
	cin >> N >> A >> B;

	long int num = N / (A + B);
	long int rest = N % (A + B);

	cout << A*num + min(A,rest) << endl;

	return 0;
}*/

Measured memory_bytes: 256
sx, sy, tx, ty=map(int,input().split())
ux=tx-sx
uy=ty-sy
S_ans=str('')
S_forw_x=str('')
S_forw_y=str('')
S_back_x=str('')
S_back_y=str('')
for i in range(ux):
    S_forw_x=S_forw_x+'R'
    S_back_x=S_back_x+'L'
for i in range(uy):
    S_forw_y=S_forw_y+'U'
    S_back_y=S_back_y+'D'
S_ans=S_forw_x+S_forw_y+S_back_x+S_back_y+'D'+S_forw_x+'RU'+S_forw_y+'LU'+S_back_x+'LD'+S_back_y+'R'
print(S_ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

int main() {
    int a,b,c,sum = 0,mx = 0,ans;
    cin >> a >> b >> c;
    sum = (a+b+c);
    mx = max(a,b);
    mx = max(mx,c);
    if(sum %2 == 3*mx%2){
        ans = (3*mx-sum)/2;
    }else{
        mx++;
        ans = (3*mx-sum)/2;
    }
    cout << ans << endl;
    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N, A, B;
    cin >> N >> A >> B;

    cout << min(N*A, B) << endl;
    return 0;
}

Measured memory_bytes: 256
input()
K = int(input())
l = list(map(int,input().split()))
ans = 0
for i in range(len(l)):
  if (K - l[i]) <= (l[i] - 0):
    ans += (K - l[i]) * 2
  elif (l[i] - 0) < (K - l[i]):
    ans += (l[i] - 0) * 2
print(ans)

Measured memory_bytes: 9028
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll,ll> P;
typedef long double ld;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep (i, n) cin >> a[i];
    int sum = 0;
    map<int, int> rem;
    rem[0]++;
    rep (i, n) {
        sum = (sum + a[i]) % m;
        rem[sum]++;
    }
    ll ans = 0;
    for (auto i : rem) ans += (ll)i.second * (ll)(i.second - 1LL) / 2LL;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3584
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static int Calc(int x, int y, int op)
        {
            if ( op == 0)
            {
                return x - y;
            }
            return x + y;
        }

        static void PrintOp(int op)
        {
            if (op == 0)
            {
                Console.Write("-");
                return;
            }

            Console.Write("+");
        }

        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int[] v = new int[4];

            for (int i = 0; i < 4; i++)
            {
                v[i] = (int)(s[i] - '0');
            }

            for(int op = 0; op < 8; op++)
            {
                int tmp;
                tmp = Calc(v[0], v[1], op & 0x01);
                tmp = Calc(tmp, v[2], op & 0x02);
                tmp = Calc(tmp, v[3], op & 0x04);

                if (tmp == 7)
                {
                    Console.Write(v[0]);
                    PrintOp(op & 0x01);
                    Console.Write(v[1]);
                    PrintOp(op & 0x02);
                    Console.Write(v[2]);
                    PrintOp(op & 0x04);
                    Console.Write(v[3]);
                    Console.WriteLine("=7");

                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fastio ios_base:: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define INF 0x3f3f3f3f3f

int main() {

    fastio;

    ll n,k, mini=INF;
    vector<ll> height(100005);
    vector<ll> dp(100005);

    cin >> n >> k;

    for( ll i = 1 ; i <= n ; i++)
    {
        cin >> height[i];
    }

    dp[1] = 0;

    for( ll i = 2; i <= min(k,n) ; i++)
    {
        for( ll j = 1 ; j <= i-1 ; j++)
        {
            mini = min ( mini , abs(height[j]-height[i]) + dp[j] ) ;
        }

        dp[i]= mini;
        mini = INF;
    }

    for( ll i = k+1; i<= n ; i++)
    {
        for( ll j = i-1 ; j >= i-k ; j--)
        {
            mini = min( mini,  abs(height[j] - height[i]) + dp[j] );
        }
        dp[i] = mini;
        mini = INF;
    }

    cout << dp[n];

    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

ll n,m;
vector<ll> par,sz,dep;
vector<vector<ll> > child;

ll find(ll x){
  if(par[x]==-1)return x;
  else return find(par[x]);
}

void rec(ll v,ll pre,ll add){
  dep[v]+=add;
  for(ll nv : child[v]){
    if(nv==v)continue;
    rec(nv,v,add);
  }
}

int main(){
  while(1){
    cin>>n>>m;
    if(n==0)break;
    par.resize(n);
    sz.resize(n);
    dep.resize(n);
    child.resize(n);
    rep(i,n){
      par[i]=-1;
      sz[i]=1;
      dep[i]=0;
      child[i].clear();
    }
    rep(i,m){
      char t;
      cin>>t;
      if(t=='!'){
        ll a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        ll pa=find(a);
        ll pb=find(b);
        if(pa==pb)continue;
        if(sz[pa]<sz[pb]){
          swap(pa,pb);
          swap(a,b);
          c=-c;
        }
        par[pb]=pa;
        ll x=dep[a]-dep[b]+c;
        rec(pb,pa,x);
        child[pa].push_back(pb);
        sz[pa]+=sz[pb];
      }else{ 
        ll a,b;
        cin>>a>>b;
        a--;b--;
        ll pa=find(a);
        ll pb=find(b);
        if(pa!=pb){
          cout<<"UNKNOWN"<<endl;
        }else{
          cout<<-dep[a]+dep[b]<<endl;
        }
      }
    }
  }
  return 0;
}



Measured memory_bytes: 9680
import sys
input = sys.stdin.readline
from collections import deque

def main():
    N, M = map(int, input().split())

    AB = [0] * N
    for i in range(N):
        AB[i] = list(map(int, input().split()))

    AB = sorted(AB)

    have = 0
    price = 0
    for x, y in AB:
        if M - have < y:
            price += x * (M - have)
            break

        else:
            price += x * y
            have += y


    print(price)

main()

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

int K;

int main() {
  cin >> K;
  long long sum=(K+1)*K/2;
  for(int i=1;i<=K;i++){
    for(int j=1;j<i;j++){
      sum+=gcd(i,j)*6;
    }
  }
  for(int i=1;i<=K;i++){
    for(int j=1;j<i;j++){
      for(int k=1;k<j;k++){
        sum+=gcd(i,gcd(j,k))*6;
      }
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3192
n,W=map(int,input().split())
stones=[None]*n
for i in range(n):
  w,v=map(int,input().split())
  stones[i]=[w,v]

import numpy as np
dp=np.zeros(W+1,dtype=int)

for i in range(len(stones)):
  w=stones[i][0]
  v=stones[i][1]
  np.maximum(dp[:-w]+v,dp[w:],dp[w:])

print(dp.max())

Measured memory_bytes: 21700
object Main extends App {
    val in = io.Source.stdin.getLines.map(_.split(" ").map(_.toInt))
    for (Array(n, m) <- in if n != 0 && m != 0) {
        val a = in.take(n).flatten.toList
        val b = in.take(m).flatten.toList
        a.sorted.find(b contains (b.sum - a.sum) / 2.0 + _) match {
            case Some(x) => println(x + " " + ((b.sum - a.sum) / 2 + x))
            case None => println(-1)
        }
    }
}

Measured memory_bytes: 44976
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int keta(int N){
  string s = to_string(N);
  return s.size();
}

//右からx桁目の数
int ketanum(int N, int x){
  for(int i = 0; i < x - 1; i++){
    N /= 10;
  }
  return N % 10;
}

int lketanum(int N, int x){
  int k = keta(N);
  return ketanum(N, k + 1 - x);
}

int main(){
  int N, M;
  cin >> N >> M;
  vector<P> sc(M);
  for(int i = 0; i < M; i++){
    int s, c;
    cin >> s >> c;
    sc.at(i) = make_pair(s, c);
  }
  int mini = 1;
  for(int i = 0; i < N - 1; i++){
    mini *= 10;
  }
  int result = mini;
  while(result < mini * 10){
    bool flag = true;
    for(int i = 0; i < M; i++){
      if(lketanum(result, sc.at(i).first) != sc.at(i).second){
        flag = false;
        break;
      }
    }
    if(flag) break;
    result++;
  }

  bool flag = true;
  for(int i = 0; i < M; i++){
    if(!(sc.at(i).first == 1 && sc.at(i).second == 0)) flag = false;
  }
  if(flag && N == 1) result = 0;
  else if(result >= mini * 10) result = -1;
  cout << result << endl;
}

Measured memory_bytes: 256
#include <utility>
#include <stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define YES(b) std::cout<< (b ? "Yes" : "No")
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a[3];
	REP(i, 3) {
		cin >> a[i];
	}
	sort(a, a + 3);
	YES(a[0] + a[1] == a[2]);
	
}


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

int main(void) {
  int n,m;
  cin >> n >> m;
  for(int i = 0;i < m;++i) {
    int a;
    cin >> a;
    n -= a;
  }
  cout << (n < 0 ? -1 : n) << endl;
  return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#define mp make_pair
#define pb push_back
#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n - 1); i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
const int MOD = 1e9+7;
const int inf = 1e9+9;
const long long INF = 1e18+3;
const ld eps = 1e-9;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    int a[n],f=0;
    forn(i,0,n) cin>>a[i];
    sort(a,a+n);
    ll ans=1;
    ford(i,1,n){
     if(a[i]==a[i-1]){
        ans*=a[i];
        --i;
        f++;
     }
     if(f==2) {
        cout<<ans<<endl;
        return 0;
     }
    }
    cout<<"0"<<endl;

 return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

int cnt[1000008];

int main()
{
	//freopen("1.in", "r", stdin);
	//freopen("1.out", "w", stdout);
	memset(cnt, 0, sizeof(cnt));
	
	int d = 0;
	int ans = 0;
	int K;
	cin >> K;
	while(ans == 0 || d != 0)
	{
		d = d * 10 + 7;
		d = d % K;
		ans++;
		cnt[d]++;
		if(cnt[d] > 1)
		{
			cout << -1;
			return 0;
		}
	}
	
	cout << ans;
	
	return 0;
}

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define dbg(var) {std::cout << #var << "  = " << var << nl;}
#define vi vector<int>
typedef long long ll;

using namespace std;

constexpr int MAXN = 202020;
struct SegTree
{
	vector<ll> t;
	 
	void set(int p , ll val){
		for(t[p += MAXN] = val ; p > 1 ; p /= 2){
			t[p / 2] = max(t[p] , t[p ^ 1]);
		}
	}
	 
	ll query(int l , int r){
		ll res = 0;
		for(l += MAXN , r += MAXN ; l < r ; l /= 2 , r /= 2){
			if(l % 2){
				res = max(res , t[l]);
				++l;
			}
			if(r % 2){
				--r;
				res = max(res , t[r]);
			}
		}
		return res;
	}
	
	SegTree()
		: t (2 * MAXN , 0)
	{}
} dp;

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

	int n;
	cin >> n;
	
	vi a(n) , h(n);
	
	for(auto& el : h)
		cin >> el;
	for(auto& el : a)
		cin >> el;

	rep(i , n)
	{
		ll mx = dp.query(0 , h[i]);
		dp.set(h[i] , mx + a[i]);
	}
	
	cout << dp.query(0 , MAXN - 1);

	return 0;
}

Measured memory_bytes: 4992
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        
        Queue<Integer> queue = new PriorityQueue<>();        
        for(int i = 0; i < N; i++){
            int A = sc.nextInt();
            queue.add(A);
        }
        
        int[][] BC = new int[M][2];
        for(int i = 0; i < M; i++){
            int B = sc.nextInt();
            int C = sc.nextInt();
            
            BC[i][0] = B;
            BC[i][1] = C;
        }
        
        Arrays.sort( BC, (BC1, BC2) -> BC2[1] - BC1[1] );
        
        for(int i = 0; i < M; i++){
            while( queue.peek() < BC[i][1] && BC[i][0] > 0 ){
                queue.add(BC[i][1]);
                queue.poll();
                BC[i][0]--;
            }
        }
        
        long total = 0;
        for(int i : queue){
            total += i;
        }
        
        System.out.println(total);

    }
}


Measured memory_bytes: 99868
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
  string s;
  cin>>s;
  int n=s.size();
  string ans="Yes";
  rep(i,n){
    if(i%2==0&&s[i]=='L'){
      ans="No";
    }
    if(i%2==1&&s[i]=='R'){
      ans="No";
    }
  }
    cout<<ans<<endl;
}


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

using namespace std;

int main(){
	long long n,k;
	scanf("%lld%lld",&n,&k);
	printf("%lld",(n/k)*(n/k)*(n/k)+((k&1)?0:((n+(k/2))/k)*((n+(k/2))/k)*((n+(k/2))/k)));
	
	return 0;
}

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

const int Maxn = 200005;

int n, m;
char s[Maxn];
vector <int> neigh[Maxn];
bool tk[Maxn];
int A[Maxn], B[Maxn];

int main()
{
    scanf("%d %d", &n, &m);
    scanf("%s", s + 1);
    for (int i = 0; i < m; i++) {
        int a, b; scanf("%d %d", &a, &b);
        if (a == b)
            if (s[a] == 'A') A[a]++;
            else B[a]++;
        else {
            if (s[b] == 'A') A[a]++;
            else B[a]++;
            if (s[a] == 'A') A[b]++;
            else B[b]++;
            neigh[a].push_back(b);
            neigh[b].push_back(a);
        }
    }
    vector <int> seq;
    for (int i = 1; i <= n; i++)
        if (A[i] == 0 || B[i] == 0) {
            tk[i] = true; seq.push_back(i);
        }
    for (int i = 0; i < seq.size(); i++) {
        int v = seq[i];
        if (s[v] == 'A')
            for (int i = 0; i < neigh[v].size(); i++) {
                int u = neigh[v][i];
                if (--A[u] == 0 && !tk[u]) {
                    tk[u] = true; seq.push_back(u);
                }
            }
        else for (int i = 0; i < neigh[v].size(); i++) {
            int u = neigh[v][i];
            if (--B[u] == 0 && !tk[u]) {
                tk[u] = true; seq.push_back(u);
            }
        }
    }
    if (seq.size() >= n) printf("No\n");
    else printf("Yes\n");
    return 0;
}


Measured memory_bytes: 13308
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
int32_t main(){
    SPEED;
    int n, a, b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    int passed = 0, over = b;
    for(int i = 0; i < len(s); ++i){
        if(s[i] == 'c') cout << "No" << endl;
        else{
            if(s[i] == 'a'){
                if(passed < (a + b)){
                    cout << "Yes" << endl;
                    passed++;
                }
                else cout << "No" << endl;
            }
            else{
                if(passed < (a + b) && over > 0){
                    cout << "Yes" << endl;
                    over--;
                    passed++;
                }
                else cout << "No" << endl;
            }
        }
    }
}


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

// int countWays(int n) 
// { 
// 	// table[i] will be storing the number of 
// 	// solutions for value i. We need n+1 rows 
// 	// as the table is consturcted in bottom up 
// 	// manner using the base case (n = 0) 
	

// 	return table[n]; 
// } 

void solve(){
	int p; cin>>p;
	
	if(p>=30){
		cout<<"Yes"<<"\n";
	}else{
		cout<<"No"<<"\n";
	}
}

int main(){
	
	 int t=1; //cin>>t;
	
	while(t--){
		solve();
	}
	
	return 0;
		
}

Measured memory_bytes: 3616