akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pranay2516
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ANot solver = new ANot();
        solver.solve(1, in, out);
        out.close();
    }

    static class ANot {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            if (in.nextInt() == 0) out.println(1);
            else out.println(0);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 32480
#include <bits/stdc++.h>
#define int long long
#define MOD 1000000007
using namespace std;

int power(int x,int y){
	if(!y) return 1;
	int res = power(x * x % MOD,y / 2);
	if(y % 2) res = res * x % MOD;
	return res;
}

signed main(){
	int n,k,ans = 0,cnt[10000] = {};
	vector<int> yaku;
	cin >> n >> k;
	for(int i = 1;i * i <= n;i++){
		if(n % i == 0){
			yaku.push_back(i);
			if(i != n / i) yaku.push_back(n / i);
		}
	}
	sort(yaku.begin(),yaku.end());
	for(int i = 0;i < yaku.size();i++){
		int tmp = power(k,(yaku[i] + 1) / 2);
		for(int j = 0;j < i;j++){
			if(yaku[i] % yaku[j] == 0) tmp = (tmp - cnt[j] + MOD) % MOD;
		}
		cnt[i] = tmp;
		if(yaku[i] % 2) (ans += tmp * yaku[i]) %= MOD;
		else (ans += tmp * yaku[i] / 2) %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, x, n) for (ll i = x; i < (ll)(n); i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 + 99);
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
//cin.tie(0);ios::sync_with_stdio(false);

signed main()
{
    ll n, m, ans = 0;
    cin >> n >> m;
    vector<vector<ll>> v(m, vector<ll>(0));
    vector<ll> nofs(m, 0);

    rep(i, n)
    {
        ll x;
        cin >> x;
        v.at(x % m).pb(x);
    }
    rep(i, m)
    {
        sort(all(v[i]));
        
        rep(j,siz(v[i])){
            if(j<siz(v[i])-1 && v[i][j]==v[i][j+1]){
                nofs[i]++;
                j++;
            }
        }

        //cout<<siz(v[i])<<" "<<nofs[i]<<endl;
    }

    for (int i = 1; i < m - i; i++)
    {
        ll a = siz(v[i]), b = siz(v[m - i]);
        if (a <= b)
        {
            ans += a;
            ans += min(nofs[m - i], (b - a) / 2);
        }
        else
        {
            ans += b;
            ans += min(nofs[i], (a - b) / 2);
        }
    }

    ans+=siz(v[0])/2;
    if(m%2==0){
        ans+=siz(v[m/2])/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (ll i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL) 
const int mod = 1e9 + 7, mxn = 1e5 + 1;

int solve(){
	int x, y;
	cin>> x>> y;
	if(y%2)
		return cout<< "No\n", 0;
	int minn = 2*x, maxx = 4*x;
	if(y < minn  or  y > maxx)
		return cout<< "No\n", 0;
	cout<< "Yes\n";
	return 0;
}
 
int main()
{
    fast;
    int t = 1;
    //cin>> t;
    while(t--){  
        solve();
    }
    return 0;
}
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);
 
/*  inv[1] = 1; // inv is ll
    for(int i=2; i<=mxn; ++i)
        inv[i]=mod-mod/i*inv[mod%i]%mod;*/
        
// lower bound   >=  
// upper bound   >
// vector<int>().swap(vec); //free memory from vec


Measured memory_bytes: 3620
class Dice():
	def __init__(self):
		self.number = [int(i) for i in range(1,7)]
	
	def set_number(self,n0,n1,n2,n3,n4,n5):
		self.number[0] = n0
		self.number[1] = n1
		self.number[2] = n2
		self.number[3] = n3
		self.number[4] = n4
		self.number[5] = n5

	def roll(self,s):
		tmp = self.number
		if s == "S":
			self.set_number(tmp[4],tmp[0],tmp[2],tmp[3],tmp[5],tmp[1])
		elif s == "E":
			self.set_number(tmp[3],tmp[1],tmp[0],tmp[5],tmp[4],tmp[2])
		elif s == "N":
			self.set_number(tmp[1],tmp[5],tmp[2],tmp[3],tmp[0],tmp[4])
		elif s == "W":
			self.set_number(tmp[2],tmp[1],tmp[5],tmp[0],tmp[4],tmp[3])

	def get_number(self,i):
		# top: 0, front: 1, right: 2, left: 3, back: 4, bottom: 5 
		return self.number[i]

	def get_position(self,i):
		return self.number.index(i)

if __name__ == '__main__':
	dice_numA = [int(i) for i in input().split()]
	dice_numB = [int(i) for i in input().split()]

	diceA = Dice()
	diceA.set_number(dice_numA[0],dice_numA[1],dice_numA[2],dice_numA[3],dice_numA[4],dice_numA[5])
	diceB = Dice()
	diceB.set_number(dice_numB[0],dice_numB[1],dice_numB[2],dice_numB[3],dice_numB[4],dice_numB[5])

	topA = diceA.get_number(0)
	frontA = diceA.get_number(1)

	while diceB.get_number(1) != frontA:
		if diceB.get_position(frontA) == 2 or diceB.get_position(frontA) == 3:
			diceB.roll("E")
		else:
			diceB.roll("S")
	while diceB.get_number(0) != topA:
		diceB.roll("E")

	if dice_numA == [diceB.get_number(0),diceB.get_number(1),diceB.get_number(2),diceB.get_number(3),diceB.get_number(4),diceB.get_number(5)]:
		print("Yes")
	else:
		print("No")


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

using namespace std;
long long gcd( long long m, long long n ){

  if ( n == 0) return m;
  return gcd(n,m%n);
}//gcd

long long lcm( long long m, long long n ){
  // 引数に０がある場合は０を返す
  if ( ( 0 == m ) || ( 0 == n ) ) return 0;

  return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm

int main(){
  long long N,M;
  cin >> N >> M;
  string S,T;
  cin >> S >> T;
  long long x = lcm(N,M);
  //cout << 'x' << x << endl;
  //for(int i = 1; M*N >= x; i++){
    long long L = x ;
    map<long long,char> Smemo;
    for(int j = 0; j < S.size(); j++){
      Smemo[j* L/N ] = S[j];
    }
    bool flag = true;
    for(long long j = 0; j < T.size(); j++){
      if(Smemo.count(j* L/M) == 0 || Smemo[j* L/M ] == T[j]) continue;
      else  flag = false;
    }
    if(flag){
      cout << L << endl;
      return 0;
    }
  //}
  cout << -1 << endl;

  return 0;
}


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

int main(){
  int N;
  cin>>N;
  vector<int> V(N);
  vector<int> Z(N);
  for(int i=0;i<N;i++){
    cin>>V.at(i);
    cin>>Z.at(i);
 
  }
  sort(V.begin(),V.end());
  reverse(V.begin(),V.end());
  sort(Z.begin(),Z.end());
  cout<<V.at(0)+Z.at(0)<<endl;
  
 
}




Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int y = 0;
  cin >> N;
  for (int i = 0; i < N; i++){
    string s;
    cin >> s;
    if (s == "Y") {
      cout << "Four" << endl;
      y = 1;
      break;
    }
  }
  if (y == 0) {
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	class Pair implements Comparable<Pair>{
		int x;
		int y;
		Pair(int x, int y){
			this.x=x;
			this.y=y;
		}
		@Override
		public int compareTo(Pair o) {
			return Integer.compare(this.y, o.y);
		}

	}
	public void run() {
		Scanner sc = new Scanner(System.in);

		int N=sc.nextInt();
		int M=sc.nextInt();
		ArrayList<Integer> A = new ArrayList<>();
		long sum = 0;
		for(int i=0; i<N; i++) {
			A.add(sc.nextInt());
			sum += A.get(i);
		}

		ArrayList<Pair> BC = new ArrayList<>();
		for(int i=0; i<M; i++) {
			int b=sc.nextInt();
			int c=sc.nextInt();
			Pair p = new Pair(b,c);
			BC.add(p);
		}

		Collections.sort(A);
		Collections.sort(BC, Collections.reverseOrder());

		ArrayList<Integer> D = new ArrayList<>();
		for(int i=0; i<BC.size(); i++) {
			Pair p = BC.get(i);
			for(int j=0; j<p.x; j++) {
				D.add(p.y);
				if(D.size()>=N) {
					break;
				}
			}
		}

		int j=0;
		for(int i=0; i<D.size(); i++) {
			if(j<A.size() && A.get(j)<D.get(i)) {
				sum += D.get(i)-A.get(j);
				j++;
			}else {
				break;
			}
		}
		System.out.println(sum);
		sc.close();
	}
}


Measured memory_bytes: 99560
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define trav(x,a) for (const auto& x: a)
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), x.end()
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int _i = 0; _i < (n); _i++) ni(a[_i])
#define nal(a, n) for (int _i = 0; _i < (n); _i++) nl(a[_i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int mod = 998244353;
const int inf = 1e9 + 7;
const int N = 1e6 + 5;
const double eps = 1e-9;
int mu[N+1], a[N], cnt[N+1], pre[N+1];

int solve(int n) {
  int r = 0;
  mu[1] = -1;
  for (int i = 1; i <= N; i++) {
  	mu[i] *= -1;
  	for (int j = 2*i; j <= N; j += i)
  		mu[j] += mu[i];
    for (int j = 1; j <= N / i; j++)
      pre[i] = (pre[i] + j * 1ll * cnt[j * i] % mod) % mod;
    pre[i] = pre[i] * 1ll * pre[i] % mod;
  }
  for (int k = 1; k < N; k++) {
    int v = 0;
    for (int l = 1; l <= N/k; l++) {
      int c = (l * 1ll * l % mod) * 1ll * pre[k * l] % mod;
      if (mu[l] > 0)
        v += v+c < mod ? c : c-mod;
      else if (mu[l] < 0)
        v += v < c ? mod-c : -c;
    }
    r = (r + k * 1ll * v) % mod;
  }
  return r;
}

int main() {
  int n; ni(n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    cnt[a[i]]++;
  }
  int ans = solve(n);
  for (int i = 1; i <= n; i++)
    ans += ans < a[i] ? mod - a[i] : -a[i];
  ans = ans * 1ll * (mod+1) / 2 % mod;
  printf("%d\n", ans);
  return 0;
}


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

namespace ConsoleApplication49
{
    class Program
    {
        static void Main()
        {
            while (true)
            {
                bool[] a = new bool[64];
                for(int b = 0; b < 8; b++)
                {
                    string c = Console.ReadLine();
                    if (c == null) goto end; 
                    for(int d = 0; d < 8; d++)
                    {
                        if (c[d] == '0') { a[b * 8 + d] = false; }
                        else { a[b * 8 + d] = true; }
                    }
                }
                int s = 0, l = 0;int q = 0;
                for (int e = 0; e < 64; e++)
                {
                    if (a[e])
                    {
                        if (s == 0) { l = e; s++; }
                        else if (s == 3) { q+= e - l; break; }
                        else { q+= e - l; s++; }
                    }
                }
                switch (q)
                {
                    case 18:  Console.WriteLine("A");      break;
                    case 48: Console.WriteLine("B"); break;
                    case 6: Console.WriteLine("C"); break;
                    case 30: Console.WriteLine("D"); break;
                    case 20: Console.WriteLine("E"); break;
                    case 34: Console.WriteLine("F"); break;
                    default: Console.WriteLine("G"); break;
                }
                Console.ReadLine();
            }
        end:;
        }
    }
}

Measured memory_bytes: 8852
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

object Solve {

  private val br = BufferedReader(InputStreamReader(System.`in`))
  private val out = PrintWriter(System.out)

  fun solve() {

    val n = br.readLine()!!.toInt()
    val s = br.readLine()!!

    var ans = 0

    for (i in 0 until 1000) {
      val str = i.toString().padStart(3, '0')
      var cnt = 0
      for (c in s) {
        if (c == str[cnt]) {
          cnt++
          if (cnt == 3) {
            ans++
            break
          }
        }
      }
    }

    out.println(ans)
    out.flush()
  }
}

fun main(args: Array<String>) {
  Solve.solve()
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

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

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

    int n;
    cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }

    int ans = 0;
    for(int i = 1; i < (n-1); i++){
        if((p[i] > p[i-1] && p[i] < p[i+1]) || (p[i] < p[i-1] && p[i] > p[i+1])){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
n = int(input())
string = input()
m = int(input())

target_word = string[m-1]

char_list = []

for i in range(n):
  if target_word == string[i]:
    char_list.append(target_word)
  else:
    char_list.append('*')
    
print(*char_list, sep = '')

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

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main() {
   int n,m;
   cin>>n>>m;
   vvll s(m,vll(10,0));
   rep2(i,0,m){
       int k;
       cin>>k;
       rep(j,k){
           int ss;
           cin>>ss;
           s.at(i).at(ss-1)=1;
       }
   }
   vll p(m,0);
   rep2(i,0,m)cin>>p.at(i);
   
   int ans=0;
   
   
   for (int tmp = 0; tmp < (1 << n); tmp++) {
    bitset<10> k(tmp);  
    bool allright=true;
    rep(i,m){
        int sum=0;
        rep(j,10){
            if(s.at(i).at(j)==1){
                if(k.test(j))sum++;
            }
        }
        //cout<<i<<" "<<sum<<endl;
        if(!(sum%2==p.at(i))){
            allright=false;
            break;
        }
    }
    if(allright)ans++;
    //cout<<endl;
    }
  cout<<ans<<endl;

}



Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int n;
    cin >> n;
    
    int arr[110];
    for(int i = 0; i < n; i++)
        cin >> arr[i];
        
    sort(arr,arr+n);
    
    cout << arr[n-1] - arr[0] << endl;
    
}


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

int main(){
	bool a[4];
	for(int i = 0; i < 4; ++i){
		a[i] = true;
	}
	int x, y;
	cin >> x >> y;
	a[x] = false;
	a[y] = false;
	for(int i = 1; i <= 3; i++){
		if(a[i] == true) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long num = Long.parseLong(sc.nextLine());
		Main main = new Main();
		int pow = main.divcount(num, 0);
		double ans = 0;
		for (int i = 0; i <= pow; i++) {
			ans += Math.pow(2, i);
		}
		System.out.println((long)ans);
	}

	public int divcount(long num,int con) {
		if (num > 1) {
			return divcount(num / 2, ++con);
		}
		return con;
	}

}

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

int N;
int A[210];

int main() {
  cin >> N;
  for (int i = 0; i < N; ++i)
    cin >> A[i];
  
  int res = 0;
  
  while (true) {
    bool exist_odd = false;
    for (int i = 0; i < N; ++i){
      if (A[i] % 2 != 0) exist_odd = true;
    }
    
    if (exist_odd) break;
    
    for (int i = 0; i < N; ++i){
      A[i] /= 2;
    }
    ++res;  
  }

  cout << res << endl;
}

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 100005;

int n;
int a[N];

int main() {

	FAST;

	cin >> n;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
	}
	map <int, int> mp;
	for (int i = 1; i <= n; i ++) {
		mp[a[i]] = i;
 	}
 	for (int i = 1; i <= n; i ++) {
 		cout << mp[i] << ' ';
 	}
 	return 0;
}

Measured memory_bytes: 5888
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node{
  int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;
void insert(int key);
int delete(int key);
int deleteFirst();
int deleteLast();
void init();     /* This fanction is initializing nil. */

main(){
  int n, i, keydata;
  char com[12];
  NodePointer p;
  scanf("%d",&n);
  nil=malloc(sizeof(struct node));
  init();

  for (i=0;i<n;i++){
    scanf("%s",com);
    if(strlen(com)>6){
      if(com[6]=='F') {
        deleteFirst();
      }else{
        deleteLast();
      }
    }else{
      scanf("%d",&keydata);
      if(com[0]=='i'){
        insert(keydata);
      }else{
        delete(keydata);
      }
    }
  }

  for(p=nil->next;p!=nil->prev;p=p->next){
    printf("%d ",p->key);
  }
  printf("%d\n",p->key);
  free(nil);
  return 0;
}

void insert(int keydata){
  NodePointer x;
  x=malloc(sizeof(struct node));
  x->key=keydata;
  x->next=nil->next;
  x->prev=nil;
  nil->next=x;
  x->next->prev=x;
}

int delete(int keydata){
  NodePointer p;
  p=nil->next;
  while(p!=nil&&p->key!=keydata){
    p=p->next; /* search */
  }
  if(p==nil){  /* If not found, this function is forced termination.  */
    return 0;
  }else{
    p->prev->next=p->next;
    p->next->prev=p->prev;
    free(p);
    return 0;
  }
}

int deleteFirst(){
  NodePointer p;
  p=nil->next;
  nil->next=p->next;
  p->next->prev=nil;
  free(p);
  return 0;
}

int deleteLast(){
  NodePointer p;
  p=nil->prev;
  p->prev->next=nil;
  nil->prev=p->prev;
  free(p);
  return 0;
}

void init(){
  nil->next=nil;
  nil->prev=nil;
}

Measured memory_bytes: 15000
import math
MOD = 10**9+7

N = int(input())
A = list(map(int,input().split()))
A.sort()
MAX = max(A[-1],2)

C = [0 for _ in range(MAX+1)]

for a in A:
  C[a] += 1

ans = 1
P = [1 for _ in range(MAX+1)] #素数かどうか
P[0] = 0
P[1] = 0
S = [0 for _ in range(MAX+1)] #最小公倍数の素因数分解したもの
for i in range(MAX+1):
  #素数でないなら以下の手順を行わない
  if P[i] == 0:
    continue
  #エラトステネスの篩
  k = i*2
  while k <= MAX:
    P[k] = 0
    k += i
  ind = 0
  k = 1
  while k <= MAX:
    k *= i
    ind += 1
  k = k // i 
  ind -= 1
  #最大のべきを調べる
  while k > 1:
    l = k
    flag = False
    while l <= MAX:
      if C[l] > 0:
        flag = True
        break
      l += k
    if flag:
      break
    k = k // i
    ind -= 1
  S[i] = ind
  ans *= pow(i,ind,MOD)
  ans %= MOD
  
#モジュラ逆数
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0

def modinv(a, m):
    g, x, y = xgcd(a, m)
    #if g != 1:
        #raise Exception('modular inverse does not exist')
    #else:
    return x % m
      
B = [0 for _ in range(MAX+1)]
ans_2 = 0
for a in A:
  if B[a] > 0:
    ans_2 += B[a]
  else:
    B[a] = modinv(a, MOD)
    ans_2 += B[a]    
  ans_2 %= MOD 

#print(ans, ans_2, P, S, B)
print((ans * ans_2) % MOD)
  

    

Measured memory_bytes: 41180
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <set>
#include <deque>
#include <map>
#include <bitset>
#include <functional>
#include <cmath>

#define INF 10000000000
using namespace std;
using P = pair<long, long>;

const int MOD = 1000000007;

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

//二分累乗法
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
	long long n;
	cin >> n;

	long long a0 = 0;
	long long b0 = 0;

	long long ab0 = 0;
	map<pair<long long, long long>, long long> m;

	long long i;
	for(i = 0; i < n; i++){
		long long a, b;
		cin >> a >> b;
		if(a == 0 && b == 0){
			ab0++;
		}else if(a == 0 && b != 0){
			a0++;
		}else if(a != 0 && b == 0){
			b0++;
		}else{
			long long g = gcd(abs(a), abs(b));
			a /= g;
			b /= g;

			if(a < 0 && b < 0){
				a = -a;
				b = -b;
			}
			if(a < 0 && b > 0){
				a = -a;
				b = -b;
			}
			
			//cout << a << " " << b << endl;
			m[{a, b}]++;
		}
	}

	map<pair<long long, long long>, long long> used;
	long long ans = 1;
	a0 = (modpow(2, a0, MOD) - 1 + MOD) % MOD;
	b0 = (modpow(2, b0, MOD) - 1 + MOD) % MOD;
	ans *= (a0 + b0 + 1) % MOD;
	//cout << ans << endl;
	for(auto pa : m){
		long long x = pa.second;
		long long a = pa.first.first;
		long long b = pa.first.second;

		if(used[{a, b}] > 0) continue;

		//cout << "a:" << a << " " << "b:" << b << endl;

		if(a > 0 && b > 0){
			used[{b, -a}] = 1;
			used[{a, b}] = 1;
		}else if(a > 0 && b < 0){
			used[{a, b}] = 1;
			used[{-b, a}] = 1;
		}

		//used[{a, b}] = 1;
		//used[{b, -a}] = 1;
		//used[{-b, a}] = 1;
		long long y;
		if(a > 0 && b > 0){
			y = m[{b, -a}];
		}else if(a > 0 && b < 0){
			y = m[{-b, a}];
		}

		//cout << "x:" << x << " " << "y:" << y << endl;

		x = (modpow(2, x, MOD) - 1 + MOD) % MOD;
		y = (modpow(2, y, MOD) - 1 + MOD) % MOD;
		ans *= ((x + y + 1)%MOD);
		ans %= MOD;
	}

	cout << ((ans - 1 + MOD) % MOD + ab0)%MOD << endl;
}

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

const int MAX = 20;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector<vector<ll>> dp(n - 1, vector<ll>(MAX + 1));
	dp[0][a[0]] = 1;
	for (int i = 1; i < n - 1; i++) {
		for (int j = 0; j <= MAX; j++) {
			if (0 <= j + a[i] && j + a[i] <= MAX) {
				dp[i][j + a[i]] += dp[i - 1][j];
			}
			if (0 <= j - a[i] && j - a[i] <= MAX) {
				dp[i][j - a[i]] += dp[i - 1][j];
			}
		}
	}
	cout << dp[n - 2][a[n - 1]] << endl;
	return 0;
}



Measured memory_bytes: 3160
#include<bits/stdc++.h>
#define endl  "\n"
#define ll long long
#define PI acos(-1.0)
#define test cout<<"\n****\n"
#define precise fixed(cout);cout<<setprecision(12)
#define fast  ios_base :: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using  namespace  std;


int main(){


    string str;
    cin>>str;

     if(str[0]=='R' && str[1]=='R' && str[2]=='R'){
        cout<<"3\n";
    }
    else if((str[0]=='R' && str[1]=='R') || (str[1]=='R' && str[2]=='R')){
        cout<<"2\n";
    }
     else if(str[0]=='R' || str[1]=='R' || str[2]=='R'){
        cout<<"1\n";
    } else{
        cout<<"0\n";
    }
    return 0;
}


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

inline void cmin(int&x, const int&y) {x > y && (x = y);}
inline void cmax(int&x, const int&y) {x < y && (x = y);}

const int N = 2003;
int arr[N], brr[N];
char str[N];
int a[N][N];
int fl[N][N], fr[N][N];
int n, m;

int main() {
	scanf("%d%d",&n,&m);
	scanf("%s", str+1);
	for(int i=1;i<=m;++i) arr[i] = str[i] == '#';
	for(int i=1;i<n;++i) {
		scanf("%s", str+1);
		for(int j=1;j<=m;++j) brr[j] = str[j] == '#';
		for(int j=1;j<m;++j)
			if(!(arr[j] xor arr[j+1] xor brr[j] xor brr[j+1]))
				a[i][j] = 1;
		for(int j=1;j<=m;++j) arr[j] = brr[j];
	}
	
	int Ans = n;
	cmax(Ans, m);
	--n, --m;
	for(int i=1;i<=n;++i) {
		for(int j=1;j<=m;++j) if(a[i][j])
			fl[i][j] = fl[i][j-1] + 1;
		for(int j=m;j;--j) if(a[i][j])
			fr[i][j] = fr[i][j+1] + 1;
	}
	
	
	for(int i=0;i<n;++i)
	for(int j=1;j<=m;++j) if(!a[i][j]) {
		int ml = 1e9, mr = 1e9;
		for(int k=i+1;k<=n;++k) {
			if(!a[k][j]) break;
			cmin(ml, fl[k][j]);
			cmin(mr, fr[k][j]);
			cmax(Ans, (ml+mr) * (k-i+1));
		}
	}
	
	printf("%d\n", Ans);
	return 0;
}

Measured memory_bytes: 47232
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
using namespace std;

int main(){
  int N,K,C,G,dp[11][2001]={};
  vector<int> type[10],price[10];
  cin>>N>>K;
  
  for(int i=0;i<N;i++){
    cin>>C>>G;
    type[--G].push_back(C);
    // cout<<type[G][i]<<endl;
  }
  for(int i=0;i<10;i++){
    sort(type[i].begin(),type[i].end(),greater<int>());
    int sum=0;
    price[i].push_back(0);
    for(int j=0;j<type[i].size();j++){
      sum+=type[i][j];
      price[i].push_back(sum+j*(j+1));
    }
  }
  for(int i=0;i<10;i++){
    for(int j=0;j<price[i].size();j++){
      for(int k=0;k+j<=K;k++)
	dp[i+1][k+j]=j?max(dp[i][k]+price[i][j],dp[i+1][k+j]):dp[i][k+j];
    }
  }
  cout<<dp[10][K]<<endl;
}

Measured memory_bytes: 1336
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int a=sc.nextInt();
    int b=sc.nextInt();
    int c=sc.nextInt();
    int asum=b+c;
    int bsum=c+a;
    int csum=a+b;
	if (a==asum || b==bsum || c==csum){
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
static const ll MOD = 1000000007;

int main(){
  int N,R;
  cin >> N >> R;
  if(N >= 10){
    cout << R << endl;
  }else{
    cout << R + 100 * (10 - N) << endl;
  }
    
}


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

const string YES = "Yes";
const string NO = "No";

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

    for (size_t i = 0; i < N.size(); i++)
    {
        if (N[i] == '7')
        {
            cout << YES << endl;
            return 0;
        }
        
    }
    cout << NO << endl;

    return 0;
}



Measured memory_bytes: 3632
/*
Iroha and Haiku (ABC Edition)
*/

#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
    int A, B, C;
    std::cin >> A >> B >> C;

    std::vector<int> L;
    L.push_back(A);
    L.push_back(B);
    L.push_back(C);
    std::sort(L.begin(), L.end());
    if (L[0] == 5 && L[1] == 5 && L[2] == 7)
    {
        std::cout << "YES\n";
    }
    else
    {
        std::cout << "NO\n";
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{       int a,b;
        char op;
    for(int i=1;i>0;i++){
        scanf("%d %c %d",&a,&op,&b);
       
        if(op=='+')
            printf("%d\n",a+b);
        else if(op=='-')
            printf("%d\n",a-b);
        else if(op=='*')
            printf("%d\n",a*b);
        else if(op=='/')
            printf("%d\n",a/b);
        else if(op=='?')
            break;
    }
        return 0;}



Measured memory_bytes: 2100
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
//#include <function>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


int main() {

  string sss;
  cin >> sss;

  int len = sss.size();

  int d_e = 0;
  int d_o = 0;
  REP(i, len){
    if (i % 2 == 0){
      if (sss[i] == '0') d_e++;
      else d_o++;
    }else{
      if (sss[i] == '1') d_e++;
      else d_o++;
    }
  }

  cout << min(d_e, d_o) << endl;

  return 0;
}


Measured memory_bytes: 512
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	x, t := nextInt(), nextInt()
	fmt.Println(max(x-t, 0))
}


Measured memory_bytes: 640
using System;

namespace Contest174
{
    class Program
    {
        static void Main()
        {
            string[] NK = Console.ReadLine().Split();
            int N = int.Parse(NK[0]);
            double D = double.Parse(NK[1]);
            double[] xary = new double[N];
            double[] yary = new double[N];
            double x;
            double y;
            double output = 0;
            double n;
            
            for(int i = 0; i < N; i++)
            {
                string[] str = Console.ReadLine().Split();
                xary[i] = double.Parse(str[0]);
                yary[i] = double.Parse(str[1]);
                x = xary[i] * xary[i];
                y = yary[i] * yary[i];
                
                n = x + y;
                n = System.Math.Sqrt(n);
               if (D >= n)
                {
                    output = output + 1;
                }

                
            }

Console.WriteLine(output);
        }
    }
}

Measured memory_bytes: 43700
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#define ll long long
#define mo 1000000007 
using namespace std;
int n;
ll a[100010],f[100010],inv[100010];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	f[0]=1;
	for (int i=1;i<=n;i++) f[i]=f[i-1]*i%mo;
	inv[0]=inv[1]=1;
	ll ans=0,sum=0;
	for (int i=2;i<=n;i++) inv[i]=(ll)(mo-mo/i)*inv[mo%i]%mo;
	for (int i=1;i<=n;i++) sum=(sum+f[n]*inv[i]%mo)%mo;
	for (int i=1;i<=n;i++)
	{
		ans=(ans+a[i]*sum%mo)%mo;
		(sum-=f[n]*inv[n-i+1]%mo)%=mo;
		(sum+=f[n]*inv[i+1]%mo)%=mo;
	}
	printf("%lld\n",(ans+mo)%mo);
	return 0;
}



Measured memory_bytes: 2560
h, w, m = map(int, input().split())
h_cnt = [0 for i in range(h)]
w_cnt = [0 for i in range(w)]
bomb = set()

for i in range(m):
    _h, _w = map(int, input().split())
    h_cnt[_h-1] += 1
    w_cnt[_w-1] += 1
    bomb.add(((_h-1),(_w-1))) #爆破対象の位置を判断

h_max = max(h_cnt)
w_max = max(w_cnt)

max_h = []
max_w = []

for i in range(h):
    if h_cnt[i] == h_max:
        max_h.append(i)

for i in range(w):
    if w_cnt[i] == w_max:
        max_w.append(i)

flg = True

for i in max_h:
    for j in max_w:
        if (i,j) not in bomb:
            flg = False
            break
print(h_max+w_max-1 if flg else h_max+w_max)


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

const int N = 500009;
const int mod = 1000000007;

#define IOS                               \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);
#define int long long int
#define endl "\n"
#define sz(a) (int)((a).size())
#define all(a) a.begin(), a.end()

int n, m;
int a[N];
int suff[N];

bool check(int x)
{
	int ans = 0;
	for (int i = (n - 1); i >= 0; i--)
	{
		int sumWant = x - a[i];
		auto it = upper_bound(a, a + n, sumWant);
		int itneG = (n - (it - a));
		ans += itneG;
	}
	if (ans >= m)
		return 0;
	return 1;
}

void pre()
{
}

int32_t main()
{
	IOS;
	pre();
	cin >> n >> m;
	int l = 0;
	int r = 1e6;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	suff[n] = 0;
	for (int i = (n - 1); i >= 0; i--)
		suff[i] = suff[i + 1] + a[i];
	if (m == (n * n))
	{
		cout << (suff[0] * n * 2) << endl;
		return 0;
	}
	while (l < r)
	{
		if (check((l + r) / 2))
		{
			r = ((l + r) / 2);
		}
		else
		{
			l = ((l + r) / 2) + 1;
		}
	}
	int taken = 0;
	int ans = 0;
	for (int i = (n - 1); i >= 0; i--)
	{
		int sumWant = l - a[i];
		auto it = lower_bound(a, a + n, sumWant);
		int itneGE = (n - (it - a));
		int see = suff[n - itneGE];
		ans += (see + itneGE * a[i]);
		taken += itneGE;
		// cout << taken << endl;
	}
	// cout << taken << " : " << m << endl;
	ans -= (l * (taken - m));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define mod 1000000007 
#define eps 1e-9
#define PI 3.14159265358979323846
#define F first
#define S second
#define ll long long
#define pb push_back
#define mp make_pair
#define Fr(i,a,b) for(int i=a;i<=b;i++)
#define RF(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pii>
using namespace std;

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  
    int t=1;
    
    while(t--){
       int n,k;
       cin>>n>>k;int x;int count=0;
        for(int i=0;i<n;i++){
            cin>>x;
            if(x>=k){
                count++;
            }
        }
       cout<<count<<endl;
    }   
    return 0;
} 

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

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

	string s, t;
	cin >> s >> t;
	vector<vector<int>> c_next(s.size() + 1 /*最後は-1*/, vector<int>(26, -1));
	vector<vector<int>> c_pos(26, vector<int>());

	{
		// 最初だけ別処理
		int i = s.size() - 1;
		c_next[i][s[i] - 'a'] = i;

		for (int i = s.size() - 2; i >= 0; i--) {
			for (int j = 0; j < 26; j++) {
				if (s[i] == 'a' + j) {
					c_next[i][j] = i;
				} else {
					c_next[i][j] = c_next[i + 1][j];
				}
			}
		}
	}
	/*c_nextの表示
	for (int j = 0; j < 26; j++) {
	    printf(" %c ", j + 'a');
	}
	printf("\n");
	for (int i = 0; i < s.size(); i++) {
	    for (int j = 0; j < 26; j++) {
	        printf("%2d ", c_next[i][j]);
	    }
	    printf("\n");
	}
	*/

	long long x = 0, y = 0;
	for (int i = 0; i < t.size(); i++) {
		if (c_next[0][t[i] - 'a'] == -1) {
			cout << "-1";
			return 0;
		}
		if (c_next[y][t[i] - 'a'] != -1) {
			y = c_next[y][t[i] - 'a'] + 1;
		} else {
			y = c_next[0][t[i] - 'a'] + 1;
			x++;
		}
		// cout << t[i] << " " << x << " " << y << "\n";
	}

	// cout << x << "回ループ後の " << y - 1 << "文字目(0始まり)\n";

	cout << x * s.size() + y;
	return 0;
}

Measured memory_bytes: 13824
N=int(input())
A = list(map(int,input().split(' ')))
power=0
trig=0
while power <31 and trig==0:
    p = int(2**power)
    for a in A:
        if int(int(a/p)%2)==1 and trig==0:
            print(int(power))
            trig=1
            break
    power+=1

Measured memory_bytes: 3060
from operator import itemgetter
import sys
sys.setrecursionlimit(1000000)
ans=0

n=int(input())
v=[int(x) for x in input().split()]
c=[int(x) for x in input().split()]
for i in range(n):
    k=v[i]-c[i]
    if k>0:
        ans+=k
        
print(ans)

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

int main() {
  LL N;
  cin >> N;
  for (LL h = 1; h <= 3500; h ++) {
    for (LL n = 1; n <= 3500; n ++) {
      if ((4*h*n - N*n - N*h) > 0 && (N*h*n) % (4*h*n - N*n - N*h) == 0) {
        LL w = (N*h*n) / (4*h*n - N*n - N*h);
        cout << h << " " << n << " " << w << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
def otoshi(n, y):
    x=0
    for i in range(n+1):
        x = i*10000
        if x >y :
            break
        for i2 in range(n+1 - i):
            x = i*10000 + i2 * 5000
            if x > y :
                break
                
            i3 = n - i - i2
            x =  i*10000 + i2 * 5000 + i3 *1000
            if x > y :
                break

            if i + i2 + i3 != n :
                pass
            else :
                if x  == y :
                    print(i, i2, i3)
                    return 

    print(-1, -1, -1)
    return 

n, y = [int(i)  for i in input().split()]

otoshi(n, y)

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

queue<int> stand[10];

int main(){
	int n,m;	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b;	cin>>a>>b;
		if(a==1){
			int mSize=100000, p=-1;
			for(int i=0;i<n;i++){
				if(mSize>stand[i].size()){
					mSize=stand[i].size();
					p=i;
				}
			}
			stand[p].push(b);
		}else if(a==0){
			cout<<stand[b-1].front()<<endl;
			stand[b-1].pop();
		}
	}

	return 0;
}



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

using namespace std;

#define SEGTREE_MAX_N (1<<21)

class SegmentTree {
private:
  
  int size;
  vector<int> dat;
  
  int query(int a, int b, int k, int l, int r) {
    if( r <= a || b <= l ) return INT_MAX;
    
    if( a <= l && r <= b ) return dat[k];
    int vl = query(a, b, k*2+1, l, (l+r)/2);
    int vr = query(a, b, k*2+2, (l+r)/2, r);
    
    return min(vl, vr);
  }
  
public:
  
  SegmentTree(int n_) {
    size = 1;
    while(size < n_) size *= 2;
    dat.resize(2*size-1, INT_MAX);
  }
  
  // RangeMinimumQuery
  /*
    find(s, t) : int
    [s, t) 区間の最小値を求める。
   */
  int find(int s, int t) {
    return query(s, t, 0, 0, size);
  }
  
  /*
    update(s, t) : int
    [s, t) 区間の最小値を求める。
   */
  void update(int idx, int x) {
    idx += size-1;
    dat[idx] = x;
    while(idx>0) {
      idx = (idx-1) / 2;
      dat[idx] = min(dat[idx*2+1], dat[idx*2+2]);
    }
  }
};

int main() {
    
  int nn, q;
  int c;
  cin >> nn >> q;
  
  SegmentTree stree(nn);
  
  for(int i=0; i<q; i++) {
    cin >> c;
    
    if(c) {
      int s, t; cin >> s >> t;
      cout << stree.find(s, t+1) << endl;
    }
    else {
      int idx, x; cin >> idx >> x;
      stree.update(idx, x);
    }
  }
  
  return 0;
}

Measured memory_bytes: 2060
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N,M;
int dv[100009];
bool vis[100009];
vector<int> G[100009], ans;

void dfs(int cur){
    vis[cur]=1;
    ans.push_back(cur);
    bool f=true;
    for(auto &v:G[cur]){
        if(!vis[v]){
            f=false;
            dfs(v);
            break;
        }
    }
    if(f) return;
}

void pr(){
    cout1(ans.size())
    rep(i,ans.size()){
        if(i) cout<<" ";
        cout<<ans[i];
    }
    cout<<endl;
    exit(0);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N>>M;
    rep(i,M){
        int a,b; cin>>a>>b;
        G[a].push_back(b);
        G[b].push_back(a);
        dv[a]++;
        dv[b]++;
    }
    
    rep1(i,N){
        if(dv[i]==1){
            dfs(i);
            pr();
        }
    }
    
    dfs(1);
    reverse(all(ans));
    for(auto &v:G[1]){
        if(!vis[v]){
            dfs(v);
            break;
        }
    }
    pr();
}

Measured memory_bytes: 10488
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to,cap,rev; 
	edge (int from, int to, int cap, int rev){
		this->from=from; this->to=to; this->cap=cap; this->rev=rev;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;



int main(){
	int w, a, b;
	cin >> w >> a >> b;

	cout << max(abs(a-b) - w,0) << endl;

	return 0;
}


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

#define INF 1000000007;

bool isPrime(int readVal){
    switch(readVal){
        case 0:
            return false;
        case 1:
            return false;
        case 2:
            return true;
    }

    if(0 == readVal % 2){
        return false;
    }

    for(int i = 3; i * i <= readVal; i += 2){
        if(0 == readVal % i){
            return false;
        }
    }

    return true;
}

int main(){
    int n; 
    std::cin >> n;

    std::vector<int> vec;
    for(int i = 2; i <= n; ++i){
        if(isPrime(i)){
            vec.push_back(i);
        }
    }

    int sz = vec.size();
    long long ans = 1;
    for(int i = 0; i < sz ; ++i){
        int count = 0;
        for(int j = 1; j <= n; ++j){
            int buf = j;
            while(0 == buf % vec.at(i)){
                ++count;
                buf /= vec.at(i);
            }
        }

        ans *= count + 1;
        ans %= INF;
    }

    std::cout << ans << std::endl;

    return 0;
}

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

int main(void){
  int n, h, h_prev = 0;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> h;
    if(h > h_prev) h_prev = h-1;
    else if(h == h_prev) h_prev = h;
    else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string.h>
#include<iostream>
using namespace std;
int cmd(int a ,int b){
    return abs(a)>abs(b);
}

int main() {

    int a,b;
    cin >>a>>b;
    if(a<b)cout<<0<<endl;
    else if(a>b)cout<<10<<endl;
    else cout<<10<<endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	static int num, idx = 0;
	
	
	static int dfs(int pos, int[] weight) {
		int ret = 0;
		if(pos >= weight.length) return(0);
		
		ret += dfs(pos + 1, weight);
	
		if(num - weight[pos] >= 0) {
			num -= weight[pos];
			ret += weight[pos];
		}
		
		return(ret);
	}
	
	static int len(int[] array) {
		int len = 0;
		for(int r = 0; r < 10; r++) {
			if(array[r] == 0) break;
			len++;
		}
		return(len);
	}
	
	static void input(int numeric, int[] weight, int[] input) {
		//System.out.println("numeric = " + numeric);
		int count = 0;
		for(int r = 9; r >= 0; r--) {
			int minus = weight[r];
			if(numeric - minus >= 0) {
				input[count++] = minus;
				numeric -= minus;
			}
		}
	}
	
	static void output(int[] output) {
		int len = len(output);
		for(int r = len - 1; r >= 0; r--) {
			System.out.print(output[r]);
			if(r != 0) System.out.print(" "); 
		}
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner stdIn = new Scanner(System.in);
		int[] weight = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
		while(stdIn.hasNext()) {
			int[] output = new int[10];
			num = stdIn.nextInt();
			input(dfs(0, weight), weight, output);
			output(output);
			System.out.println();
			idx = 0;
		}
	}	
}

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

using ll = long long;
const ll MOD = 1e9 + 7;

int main() {
    int A, B, M, amin = 1e6, bmin = 1e6;
    cin >> A >> B >> M;
    vector<int> a(A), b(B), x(M), y(M), c(M);
    rep(i, A) {
        cin >> a[i];
        amin = min(amin, a[i]);
    }
    rep(i, B) {
        cin >> b[i];
        bmin = min(bmin, b[i]);
    }
    int ans = amin + bmin;
    rep(i, M) {
        cin >> x[i] >> y[i] >> c[i];
        ans = min(ans, a[x[i] - 1] + b[y[i] - 1] - c[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2176