akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>

using namespace std;

bool orig[10][10];
bool work[10][10];
bool ans[10][10];


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

bool debug = false;

void flip(int x, int y){
	for(int i=0;i<5;i++){
		if(0 <= x+dx[i] && x+dx[i] <10 &&
		0 <= y+dy[i] && y+dy[i] < 10){
			work[x+dx[i]][y+dy[i]] = 1 - work[x+dx[i]][y+dy[i]];
		}
	}
	return;
}


int main(void){
	int n;
	int tmp;
	bool isfirst = true;
	string str;
	
	cin >> n;
	cin.ignore();
	
	for(int cas=0;cas<n;cas++){
		memset(orig, false, sizeof(orig));
		
		//if(!isfirst) cout << endl;
		for(int i=0;i<10;i++){
			getline(cin,str);
			istringstream iss(str);
			if(debug) cout << i << " " << str << endl;
			for(int j=0;j<10;j++){
				iss >> tmp;
				if(tmp == 0){
					orig[i][j] = false;
				}else{
					orig[i][j] = true;
				}
			}
		}
		
		for(int i=0;i < 1 << 10; i++){
			if(debug) cout << i <<endl;
			
			copy(orig, orig+10*10, work);
			//1sÚÉÎ·é
			for(int j=0;j<10;j++){
				if(i & 1 << j){
					flip(0,j);
					ans[0][j] = true;
				}else{
					ans[0][j] = false;
				}
			}
			
			for(int j=1;j<10;j++){
				for(int k=0;k<10;k++){
					if(work[j-1][k]){
						flip(j,k);
						ans[j][k] = true;
					}else{
						ans[j][k] = false;
					}
				}
			}
			
			//check ended or not
			bool isended = true;
			for(int j=0;j<10;j++){
				for(int k=0;k<10;k++){
					if(work[j][k]){ isended = false;}
				}
			}
			if(isended){
				for(int j=0;j<10;j++){
					for(int k=0;k<10;k++){
						if(k==9){
							cout << ans[j][k] << endl;
						}else{
							cout << ans[j][k] << " ";
						}
					}
				}
				isfirst = false;
				break;
			}
		}
	}
}

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

using ll = long long;
constexpr ll inf = static_cast<ll>(1e15);
constexpr ll mod = static_cast<ll>(1e9 + 7);

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

	if (n % 2 == 0) {
		std::cout << (n / 2) * (n / 2 - 1) * 2 << std::endl;
		for (int i = 1, end = n / 2; i <= end; ++i)
			for (int j = i + 1; j <= end; ++j) {
				std::cout << i << " " << j << std::endl;
				std::cout << i << " " << n + 1 - j << std::endl;
				std::cout << n + 1 - i << " " << j << std::endl;
				std::cout << n + 1 - i << " " << n + 1 - j << std::endl;
			}
	}
	else {
		std::cout << n - 1 + (n / 2)*(n / 2 - 1) * 2 << std::endl;
		for (int i = 0, end = n / 2; i <= end; ++i)
			for (int j = i + 1; j <= end; ++j) {
				if (i != 0) {
					std::cout << i << " " << j << std::endl;
					std::cout << i << " " << n - j << std::endl;
					std::cout << n - i << " " << j << std::endl;
					std::cout << n - i << " " << n - j << std::endl;
				}
				else {
					std::cout << n << " " << j << std::endl;
					std::cout << n << " " << n - j << std::endl;
				}
			}
	}
	return 0;
}


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

int main(){
  int n,m,a[100],b[100],tres,hres;

  for(;;){
    cin >> n >> m;
    if(n==0 && m==0)break;

    int tsum = 0, hsum = 0;
    for(int i=0;i<n;i++){
      cin >> a[i]; tsum += a[i];
    }
    for(int i=0;i<m;i++){
      cin >> b[i]; hsum += b[i];
    }
    tres = hres = -1;

    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	int t = tsum - a[i] + b[j];
	int h = hsum - b[j] + a[i];

	if(t==h){
	  if(tres<0 || tres+hres > a[i]+b[j]){
	    tres = a[i]; hres = b[j];
	  }
	}
      }
    }

    if(tres<0)cout << tres << endl;
    else cout << tres << " " << hres << endl;
  }
}

Measured memory_bytes: 1160
#include<stdio.h>

int main(void)
{
	int a, b;
	int area;
	int cir;
	scanf( "%d %d", &a, &b);
	area=a*b;
	cir=(a*2)+(b*2);
	printf( "%d %d\n", area, cir);
	
	return 0;
}

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

const int lim = 300000;
bool jud[lim];
int dis[lim];

int main()
{
    for(int i=0;i<lim;i++){
        jud[i] = false;     
    }
    
    int n;
    cin >> n;	
    for(int i=0;i<n;i++){
        int d;
        cin >> d;
        dis[i] = d;
    }

    int count = 0;
    jud[0] = true;            
    bool ans = false;
    while(jud[count]&&count<n){
        if(count==n-1){
            ans = true;
            break;
        }
        int jump;
        if(count+dis[count]/10>=lim){
            jump = lim-1;
        }else{
            jump = count+dis[count]/10;
        }
        for(int i=jump;!jud[i];i--){
            jud[i] = true;
        }
        count++;
    }
    
    if(ans){
        for(int i=0;i<lim;i++){
            jud[i] = false;     
        }
        jud[n-1] = true;            
        ans = false;
        while(jud[count]&&count<=n){
            if(count==0){
                ans = true;
                break;
            }
            /*for(int i=1;i<=dis[count]/10&&count-i>=0;i++){
                jud[count-i] = true;
            }
            count--;*/
            int jump;
            if(count-dis[count]/10<0){
                jump = 0;
            }else{
                jump = count-dis[count]/10;
            }
            for(int i=jump;!jud[i];i++){
                jud[i] = true;
            }
            count--;
        } 
    }

    if(ans){
        cout << "yes" << endl;
    }else{
        cout << "no" << endl;
    }

    return 0;
}


Measured memory_bytes: 4556
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>

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

using namespace std;

int main(){
	int N, cost = 0;
	scanf("%d", &N);
	vector<int> a(N);
	rep(i, N)scanf("%d", &a[i]);
	rep(i, N-1) {
		cost += abs(a[i + 1] - a[i]);
	}
	cost += abs(a[0]) + abs(a[N - 1]);
	printf("%d\n", cost - abs(a[0]) - abs(a[1] - a[0]) + abs(a[1]));
	for (int i = 1; i < N - 1; i++)printf("%d\n", cost - abs(a[i - 1] - a[i]) - abs(a[i] - a[i + 1]) + abs(a[i + 1] - a[i - 1]));
	printf("%d\n", cost - abs(a[N - 2] - a[N - 1]) - abs(a[N - 1]) + abs(a[N - 2]));
	return 0;
}

Measured memory_bytes: 1664
ans = 0
k = int(input())
def f(x,y):
  x,y= min(x,y),max(x,y)
  while y%x != 0:
    z = y%x
    y = x
    x = z
  else:
    return x
def ff(a,b,c):
  return f(c,f(a,b))
for i in range(1,k+1):
    for j in range(i,k+1):
        for k in range(j,k+1):
            if i == j == k:
              ans += ff(i,j,k)
            elif (i == j) or (j == k):
                ans += 3*ff(i,j,k)
            else:
                ans += 6*ff(i,j,k)            
print(ans)

Measured memory_bytes: 9208
package main

import (
	"fmt"
	"math"
)

func min(a, b int) int {
	if a >= b {
		return b
	}
	return a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func main() {
	var n int
	fmt.Scan(&n)
	w := make([]int, n)
	for i := range w {
		fmt.Scan(&w[i])
	}
	ans := math.MaxInt32

	for i := 0; i < len(w); i++ {
		var s1, s2 int
		for j := 0; j < i; j++ {
			s1 += w[j]
		}
		for j := i; j < n; j++ {
			s2 += w[j]
		}
		ans = min(ans, abs(s1-s2))
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
//package  com.company;

import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String s1=sc.nextLine();
        String s2=sc.nextLine();
        int n=s1.length();
        int ans=0;
        for(int i=0;i<n;++i){
            ans+=s1.charAt(i)!=s2.charAt(i)?1:0;
        }
        System.out.println(ans);
    }
}

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

int main(void){
    int n;
    cin >> n;
    
    int a[100001] = {0};
    int input;
    int i;
    for(i = 1; i <= n; i++){
        cin >> input;
        if(input >= 1){
            a[input - 1]++;
        }
        a[input]++;
        if(input <= 99999){
            a[input + 1]++;
        }
    }
    
    sort(a, a + 100001, greater<int>());
    
    cout << a[0] << endl;
    
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		int count=0;
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				for(int k=0;k<10;k++){
					for(int l=0;l<10;l++){
						if(i+j+k+l==n)
							count++;
		            }
	            }
            }
        }
		cout<<count<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
int main (void){
  char s[100],ch;
  int hoge;
  hoge = 0;
  while ( (ch = getchar()) != 10 ){
    s[hoge] = 'x';
    hoge++;
  }
  for ( hoge = 0 ; s[hoge] == 'x' ; hoge++)
    printf("%c",s[hoge]);
  printf("\n");
}


Measured memory_bytes: 128
package main

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

var sc = bufio.NewScanner(os.Stdin)

//Sliceconvtoi ...
func Sliceconvtoi() []int {
	strs := strings.Split(sc.Text(), " ")

	var ints []int
	var x int

	for _, s := range strs {
		x, _ = strconv.Atoi(s)
		ints = append(ints, x)
	}

	return ints
}

func main() {
	for sc.Scan() {
		var dt string
		i := Sliceconvtoi()
		t := time.Date(2017, 9, i[0], 0, 0, 0, 0, time.Local)

		switch t.Weekday() {
		case time.Monday:
			dt = "mon"
		case time.Tuesday:
			dt = "tue"
		case time.Wednesday:
			dt = "wed"
		case time.Thursday:
			dt = "thu"
		case time.Friday:
			dt = "fri"
		case time.Saturday:
			dt = "sat"
		case time.Sunday:
			dt = "sun"
		default:
		}

		fmt.Println(dt)
	}

}


Measured memory_bytes: 1200
#include<iostream>
#include<iterator>
#include<vector>
#include<algorithm>

using namespace std;
void print_postorder(size_t, size_t, size_t, size_t);

vector<int> pre;
vector<int> in;
bool printed = false;

int main() {
  int n; cin >> n;
  pre = vector<int>(n);
  in = vector<int>(n);
  for (int i = 0; i < n; ++i)
    cin >> pre[i];
  for (int i = 0; i < n; ++i)
    cin >> in[i];
  print_postorder(0, n, 0, n);
  cout << endl;
}

void pprint(int val) {
  if (!printed) {
    cout << val;
    printed = true;
  } else {
    cout << ' ' << val;
  }
}

// ranges: [start, end)
void print_postorder(size_t pidx, size_t pend, size_t iidx, size_t iend) {
  if (pidx >= pend) {
    return;
  } else if (pidx + 1 >= pend) {
    pprint(pre[pidx]);
    return;
  }
  int root_id = pre[pidx];
  auto root_it = find(in.begin(), in.end(), root_id);
  int left_subtree_size = distance(in.begin() + iidx, root_it);
  print_postorder(pidx + 1, pidx + 1 + left_subtree_size, iidx, iidx + left_subtree_size);
  print_postorder(pidx + left_subtree_size + 1, pend, iidx + left_subtree_size + 1, iend);
  pprint(root_id);
}


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

int main() {
  
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if (A*B > C*D) {
    cout << A*B << endl;
  }
  else {
    cout << C*D << endl;
  }
  
return 0;
}

Measured memory_bytes: 3548
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
#define PI 3.14159265358979
typedef long long int ll;

ll gcd(ll a,ll b){
	if(a<b)swap(a,b);
	return (a%b?gcd(a%b,b):b);
	
}

int main()
{
	ll N,ans;
	bool flag=true;
	cin>>N;
	ans=N;
	while(flag){
		flag=false;
		for(int i=2;i<sqrt(ans);i++)
		{
			if(ans%i==0){flag=true;break;}
		}
		if(flag)ans++;
	}
	cout<<ans;
}


Measured memory_bytes: 256
A,B=map(int,input().split())
def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)
a=gcd(A,B)
li=[]
while a%2==0:
    li.append(2)
    a//=2
waru=3
while waru*waru<=a:
    if a%waru==0:
        li.append(waru)
        a//=waru
    else:
        waru+=2
if a!=1:
    li.append(a)
print(len(set(li))+1)
        

Measured memory_bytes: 3064
#include <cstdio>
#include <vector>
#include <cstring>
#include <functional>
#include <algorithm>
#include <math.h>
#include <bitset>
#include <set>
#include <queue>
#include <assert.h>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <complex>
#include <numeric>
#include <map>
#include <time.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<int,ull> piu;
typedef pair<ull,ull> puu;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
typedef pair<pii,ll> ppl;
typedef pair<ll,pii> plp;
typedef pair<ll,pll> plP;
typedef pair<int,pii> pip;
typedef pair<pii,int> ppi;
typedef pair<pii,pii> ppp;
typedef pair<double,int> pdi;
typedef pair<int,double> pid;
typedef pair<double,pii> pdp;
typedef pair<double,double> pdd;
typedef pair<pdd,double> pd3;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i,n) for (int (i) = 0; (i) < (n); (i)++)
#define repn(i,a,n) for (int (i) = (a); (i) < (n); (i)++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define SORT(x) sort((x).begin(),(x).end())
#define SORTN(x,n) sort((x),(x)+(n))
#define ERASE(x) (x).erase(unique((x).begin(),(x).end()),(x).end())
#define COUNT(x,c) count((x).begin(),(x).end(),(c))
#define REMOVE(x,c) (x).erase(remove((x).begin(),(x).end(),(c)),(x).end())
#define REVERSE(x) reverse((x).begin(),(x).end())
#define FORIT(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))-(x).begin()
#define lb(x,a) lower_bound((x).begin(),(x).end(),(a))
#define LBN(x,a,n) lower_bound((x),(x)+(n),(a))-(x)
#define lbN(x,a,n) lower_bound((x),(x)+(n),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))-(x).begin()
#define ub(x,a) upper_bound((x).begin(),(x).end(),(a))
#define BS(x,a) binary_search((x).begin(),(x).end(),(a))
#define BS2(x,n,a) binary_search((x),(x)+(n),(a))
#define NB(x) (((x)&~((x)+((x)&-(x))))/((x)&-(x))>>1)|((x)+((x)&-(x)))
#define NP(x) next_permutation((x).begin(),(x).end())
#define MM(x,p) memset((x),(p),sizeof(x))
#define SQ(x) (x)*(x)
#define SC(c1,c2) strcmp(c1,c2)==0
#define mp make_pair
#define INF (1<<29)
#define INFL (1LL<<61)
#define fi first
#define se second
#define EPS 1e-9
#define MOD 1000000007
#define MIN(x,a) x=min(x,a)
#define MAX(x,a) x=max(x,a)
#define madd(x,a) x=(x+a)%MOD
#define msub(x,a) x=(x+MOD-a)%MOD
#define OUTPUT(x) rep(__,x.size())printf("%d%c",x[__],__+1==x.size()?'\n':' ')


int M1,D1,M2,D2;

int main()
{
	cin>>M1>>D1>>M2>>D2;
	puts(M1!=M2?"1":"0");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 64
int a[N];

int main(){
	int n; scanf("%d", &n);
	REP(i, n) scanf("%d", a+i), a[i]--;
	int cnt = 0;
	REP(i, n) if(a[i] != i) cnt++;
	if(cnt == 0 || cnt == 2) printf("YES\n");
	else printf("NO\n");
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int mx = Math.max(a,b);
		int mn = Math.min(a,b);
		//
		while ( mn > 0 ) {
			if ( mx > mn ) {
				mx = mx % mn;
			} else {
				int wk = mx;
				mx = mn;
				mn = wk;
			}
		} 
		long ans = ((long)a * (long)b) / (long)mx;
		System.out.println(ans);
	}
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS  = 1e-9;

int main() {
	while (true) {
		string maps[3];
		cin >> maps[0];
		if (maps[0][0] == '0') break;
		cin >> maps[1] >> maps[2];
		
		int ans = -1;
		REP(i, 3) {
			if (maps[i][0] == maps[i][1] && maps[i][1] == maps[i][2] && maps[i][0] != '+') ans = maps[i][0] == 'b';
			if (maps[0][i] == maps[1][i] && maps[1][i] == maps[2][i] && maps[0][i] != '+') ans = maps[0][i] == 'b';
		}
		if (maps[0][0] == maps[1][1] && maps[1][1] == maps[2][2] && maps[1][1] != '+') ans = maps[1][1] == 'b';
		if (maps[2][0] == maps[1][1] && maps[1][1] == maps[0][2] && maps[1][1] != '+') ans = maps[1][1] == 'b';
		
		if (ans == -1) puts("NA");
		else if (ans == 1) puts("b");
		else puts("w");
	}
	return 0;
}

Measured memory_bytes: 3132
h,w = map(int,input().split())
s = [list(input()) for i in range(h)]

num = [[0]*w for i in range(h)]

for i in range(h):
    cnt = 0
    for j in range(w):
        if s[i][j] == '#':
            cnt = 0
        else:
            num[i][j] += cnt
            cnt += 1

    cnt = 0
    for j in range(w-1,-1,-1):
        if s[i][j] == '#':
            cnt = 0
        else:
            num[i][j] += cnt
            cnt += 1



for j in range(w):
    cnt = 0
    for i in range(h):
        if s[i][j] == '#':
            cnt = 0
        else:
            num[i][j] += cnt
            cnt += 1
    cnt = 0
 
    for i in range(h-1,-1,-1):
        if s[i][j] == '#':
            cnt = 0
        else:
            num[i][j] += cnt
            cnt += 1

res = -1
for i in range(h):
    for j in range(w):
        res = max(res,num[i][j])
print(res+1)

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

const int N = 2001;
vector<int> G[N];
int n,k;

int sub[N][N],d[N][N];
int a[N],b[N];
int  root;
void dfs(int x,int fa) {
    d[root][x] = d[root][fa]+1;
    sub[root][x] = 1;
    for(auto y:G[x]) {
        if(y==fa) continue;
        dfs(y,x);
        sub[root][x] += sub[root][y];
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin>>n>>k;
    for(int i=1;i<n;i++) {
        cin>>a[i]>>b[i];
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    for(int i=1;i<=n;i++) {
        root = i;
        d[root][0] = -1;
        dfs(i,0);
    }
    int ans = n;
    if(k&1) {
        for(int i=1;i<n;i++) {
            int u=a[i],v=b[i];
            int tmp = 0;
            for(int j=1;j<=n;j++) {
                int dist = min(d[u][j],d[v][j]);
                if(dist>k/2) tmp++;
            }
            ans = min(ans,tmp);
        }
    }else {
        for(int i=1;i<=n;i++) {
            int tmp = 0;
            for(int j=1;j<=n;j++) {
                if(d[i][j]>k/2) tmp++;
            }
            ans = min(ans,tmp);            
        }
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 31744
#include<iostream>
#include<cstdio>
#include<vector>
#include<utility>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<limits>
#include <bitset>      


#define LL long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define INF numeric_limits<int>::max()



using namespace std;


LL dp[102][100005];



int main(){

    int n, w;
    cin >> n >> w;

    int e[n+1], v[n+1];

    memset(dp, INF, sizeof dp);


    for(int i = 1; i <= n; i++){
        cin >> e[i] >> v[i];
      }

    
     for(int i = 0; i<= n; i++){
        for(int j = 0; j <= 100005; j++){
            dp[i][j] = INF;
        }
    }
    

    for(int i = 1; i <= n; i++){
        dp[i][v[i]] = e[i];
        for(int k = 1; k <= 100005; k++){
             dp[i][k] = min(dp[i][k], dp[i-1][k]);
             if(k >= v[i])
                dp[i][k] = min(dp[i][k], dp[i - 1][k - v[i]] + e[i]);
            }
        } 
    


    int ans = 0;

    for(int i = 100005; i >= 1 ; i--){
          if(dp[n][i] <= w)
                 ans = max(ans, i);
        }
    


    cout << ans;


    return 0;
}






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



int main() {
    bool prime[1000000];
    memset(prime, true, sizeof(prime));

    for (int p = 2; p * p <= 1000000; p++)
    {
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true)
        {
            for (int i = p * p; i < 1000000; i += p)
                prime[i] = false;
        }
    }

    int x;
    cin >> x;
    for (int i = x; i < 1000000; i++) {
        if (prime[i]) {
            cout << i;
            return 0;
        }
    }

	return 0;
}

Measured memory_bytes: 4584
# -*- coding: utf-8 -*-

def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    N, M, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    return N, M, K, A, B


def main(N: int, M: int, K: int, A: list, B: list) -> None:
    """
    メイン処理.

    Args:\n
        N (int): 机Aの本の数（1 <= N <= 200000）
        M (int): 机Bの本の数（1 <= M <= 200000）
        K (int): 合計所要時間の上限（1 <= K <= 10^9）
        A (list): 机Aの本を読むための時間
        B (list): 机Bの本を読むための時間
    """
    # 求解処理
    a, b = [0], [0]
    for i in range(N):
        a.append(a[i] + A[i])
    for j in range(M):
        b.append(b[j] + B[j])

    ans, j = 0, M
    for i in range(N + 1):
        if a[i] > K:
            break
        while b[j] > K - a[i]:
            j -= 1
        ans = max(ans, i + j)

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    N, M, K, A, B = get_input()

    # メイン処理
    main(N, M, K, A, B)


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

#define rep(i, a, b) for (int i = a, i##end = b; i <= i##end; ++i)
#define per(i, a, b) for (int i = a, i##end = b; i >= i##end; --i)
#define rep0(i, a) for (int i = 0, i##end = a; i < i##end; ++i)
#define per0(i, a) for (int i = (int)a-1; ~i; --i)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define chkmax(a, b) a = max(a, b)
#define chkmin(a, b) a = min(a, b)
#define x first
#define y second
#define enter putchar('\n')

typedef long long ll;
typedef double DB;

const DB eps = 1e-12;

int sgn(DB x) { return fabs(x) < eps ? 0 : (x > 0 ? 1 : -1); }

struct Point {
	DB x, y;
	Point(DB x = 0, DB y = 0) : x(x), y(y) {}
	Point operator + (Point a) { return Point(x + a.x, y + a.y); }
	Point operator - (Point a) { return Point(x - a.x, y - a.y); }
	Point operator - () { return Point(-x, -y); }
	friend Point operator * (DB k, Point a) { return Point(k * a.x, k * a.y); }
	DB operator % (Point a) { return x * a.x + y * a.y; }
	DB operator / (Point a) { return x * a.y - y * a.x; }
	operator DB() { return sqrt(x*x + y*y); }
};

Point gp() { Point a; scanf("%lf%lf", &a.x, &a.y); return a; }
void wp(Point a) { printf("%.10lf %.10lf ", a.x, a.y); }

struct Poly {
	std::vector<Point> a;
	Poly(int n = 0) { a.resize(n); rep0(i, n) a[i] = gp(); }
	int size() { return a.size(); }
	Point &operator [] (int i) { int n = a.size(); return a[i >= n ? i-n : i]; }
};

DB Area(Poly A) {
	DB res = 0;
	rep(i, 2, A.size()-1) res += (A[i]-A[0])/(A[i-1]-A[0]);
	return fabs(res)/2;
}

int q;

int main() {
	scanf("%d", &q);
	printf("%.1lf\n", Area(Poly(q)));
	/*
	scanf("%d", &q);
	while (q--) {
		Point P1 = gp(), P2 = gp(), Q1 = gp(), Q2 = gp();
		printf("%.10lf\n", SegDist(P1, P2, Q1, Q2));
		//wp(GetSegInter(P1, P2, Q1, Q2)); enter;
		//printf("%d\n", IsInter(P1, P2, Q1, Q2));
		//wp(Proj(P, P1, P2)); enter;
	}*/
	return 0;
}


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

using namespace std;

const int N = 550;

int a[N][N];

void Solve(vector <int> v, int Cur)
{
    if(v.size() < 2)    return ;

    int n = v.size();
    int m = n / 2;

    for(int i = 0; i < m; i++)
        for(int j = m; j < n; j++)
            a[v[i]][v[j]] = a[v[j]][v[i]] = Cur;

    vector <int> v1, v2;

    for(int i = 0; i < m; i++)  v1.push_back(v[i]);
    for(int j = m; j < n; j++)  v2.push_back(v[j]);

    Solve( v1, Cur + 1);
    Solve( v2, Cur + 1);
}

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

    vector <int> v;

    for(int i = 1; i <= n; i++) v.push_back(i);

    Solve( v, 1);

    for(int i = 1; i < n; i++, puts(""))
        for(int j = i + 1; j <= n; j++)
            printf("%d ", a[i][j]);
}


Measured memory_bytes: 1536
#include <stdio.h>
int main(){
  char str[10] = {0};
  int i = 0;
  int a,b;
  while(scanf("%d %d",&a,&b) != EOF){
    i = 0;
    sprintf(str,"%d",a+b);
    while(str[i] != '\0'){
      i++;
    }
    printf("%d\n",i);
  }
  return(0);
}

Measured memory_bytes: 612
n = gets.to_i
kumiawase = 10**n - (9**n + 9**n -8**n)
#0も9も含まれる組合せ=全通り-(0を含まない組合せ数+9を含まない組合せ数-0と9を含む組合せ数)

puts kumiawase % (10**9+7)

Measured memory_bytes: 23416
#include"bits/stdc++.h"

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



//メイン関数
int main()
{
	ll N, W;
	cin >> N >> W;
	vector<pair<ll, ll>> wv(N);
	REP(i, N)
	{
		ll a, b;
		cin >> a >> b;
		wv[i] = {a,b};
	}

	vector<vector<ll>> dp(N, vector<ll>(W + 1, 0));
	FOR(j, wv[0].first, W + 1)dp[0][j] = wv[0].second;

	FOR(i, 1, N)REP(j, W + 1)
	{
		dp[i][j] = dp[i - 1][j];
		if(j > 0)dp[i][j] = max(dp[i][j], dp[i][j - 1]);

		ll w = wv[i].first;
		ll v = wv[i].second;
		if(j - w >= 0) dp[i][j] = max(dp[i][j], dp[i - 1][j - w] + v);
	}
	cout << dp.back().back();
	cin>>N;
	return 0;
}


Measured memory_bytes: 79360
#include<iostream>
#include<string>

int main(){
	int n;
	std::cin >> n;
	std::cin.ignore();
	
	for(int i = 0; i < n; i++){
		std::string str;
		std::getline(std::cin, str);

		for(int a = 1; a < 26; a++){
			for(int b = 0; b < 26; b++){
				std::string str2 = str;
				for(int j = 0; j < str2.size(); j++){
					if(str2[j] != ' ')str2[j] = ((a * (str2[j] - 'a') + b) % 26) + 'a';
				}
				if(str2.find("that") != -1 || str2.find("this") != -1){
					std::cout << str2 << std::endl;
					goto end;
				}
			}
		}
		end:;
	}
	return 0;
}

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

#define ll long long

using namespace std;

ll popcount(ll n){
  if(n == 0) return 0;
  else return 1 + popcount(n & (n-1));
}

ll f(ll n){
 ll times = 0;
  
  while(n){
    n %= popcount(n);
    times++;
  }
  
  return times;
}

ll toggleBit(ll n, ll k){
  return (n ^ (1 << (k-1)));
}

ll binaryToDecimal(string x) 
{ 
    string num = x; 
    ll dec_value = 0; 
  
    ll base = 1; 
  
    ll len = num.length(); 
    for (ll i = len - 1; i >= 0; i--) { 
        if (num[i] == '1') 
            dec_value += base; 
        base = base * 2; 
    } 
  
    return dec_value; 
} 

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  int n;
  int count = 0;
  double x, y, d;
  cin >> n >> d;
  
  for(int i = 1; i <= n; i++){
    cin >> x >> y;
    double dis = sqrt(x*x+y*y);
    if(dis <= d) count++;
  }
  
  cout << count;
  
  return 0;
}



Measured memory_bytes: 3788
import java.util.*;
import static java.lang.Math.*;

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

		// 入力
		int n = sc.nextInt();// N

		ArrayList<Integer> numList = new ArrayList<Integer>();
		for(int i = 0; i < n; i++){
			int value = sc.nextInt();
			if(!numList.contains(value)){
				numList.add(value);
			}
		}

		// 出力
		System.out.println(numList.size());
	}
}




Measured memory_bytes: 23764
n = int(input())
a  = list(map(int, input().split()))
sum = [a[0]]
for i in range(1, n):
	sum.append(sum[i-1]+a[i])
ans = abs(2*sum[0]-sum[n-1])
for i in range(1, n-1):
	ans = min(ans, abs(2*sum[i]-sum[n-1]))
print(ans)

Measured memory_bytes: 24832
N,M=map(int,input().split())
H = list(map(int,input().split()))
A = [0]*M
B = [0]*M
for i in range(M):
  A[i],B[i]=map(int,input().split())
list = []
for i in range(M):
  if H[A[i]-1]>=H[B[i]-1]:
    list.append(B[i])
  if H[A[i]-1]<=H[B[i]-1]:
    list.append(A[i])
#print("N:{} M:{} H:{} list:{} set(list):{}".format(N,M,H,list,set(list)))
print(N-len(set(list)))

Measured memory_bytes: 24372
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		int N = Integer.parseInt(in.readLine());
		String[] tokens = in.readLine().split(" ");
		int[] p = new int[N];
		int[] q = new int[N];
		for (int i = 0; i < N; ++i) {
			p[i] = Integer.parseInt(tokens[i]);
			q[i] = p[i];
		}
		Arrays.sort(q);
		int count = 0;
		for (int i = 0; i < N; ++i) {
			if(p[i] != q[i]) {
				++count;
			}
		}
		if (count <= 2) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 23252
import java.util.*;


public class Main{ 


    public static void main(String args[]) {
    Scanner s=new Scanner(System.in);
	int n=s.nextInt();
	int k=s.nextInt();
	int arr[]=new int[n+1];
	
	for(int i=1;i<=n;i++) {
		arr[i]=s.nextInt();
	}
	
	long dp[][]=new long[n+1][k+1];
	int mod=1000000007;
	
	//aapke paas j candies hai and i persons hai
	
	for(int j=0;j<=k;j++) {
		if(j<=arr[1])
		dp[1][j]=1;
		else
		dp[1][j]=0;
	}
	
	for(int i=2;i<=n;i++) {
		for(int j=0;j<=k;j++) {
			if(j==0)
				dp[i][j]=dp[i-1][j];
			else
				dp[i][j]=(mod+dp[i][j-1]+dp[i-1][j]- ((j-1-arr[i]>=0)?dp[i-1][j-1-arr[i]]:0)) % mod;
		}
	}
	
	
	System.out.println(dp[n][k]);
   }
}

Measured memory_bytes: 139648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin>>n>>s;
    int x=0;
    int ans=0;
    rep(i,n){
        if(s[i]=='I'){
            x++;
            if(ans<x){
                ans=x;
            }
        }else{
            x--;
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

typedef complex<double> P;

int x[12],y[12];
int w,h,r,vx,vy;
int n;

double cross(P a,P b){
  return a.real()*b.imag()-a.imag()*b.real();
}

double dot(P a,P b){
  return a.real()*b.real()+a.imag()*b.imag();
}

vector<int> col(P a,P b){
  vector<int> rv;
  for(int i=0;i<n-1;i++){
    double d;
    P p(x[i],y[i]);
    if(dot(a-b,p-b)>0&&dot(b-a,p-a)>0){
      d=fabs(cross(a-b,p-b)/abs(a-b));
    }else{
      d=min(abs(a-p),abs(b-p));
    }
    if(d<=r+r){
      rv.push_back(i+2);
    }
  }
  return rv;
}

int main(){
  for(;cin>>n,n;){
    cin>>w>>h>>r>>vx>>vy;
    int x1,y1;
    cin>>x1>>y1;
    for(int i=0;i<n-1;i++){
      cin>>x[i]>>y[i];
    }
    P p(x1,y1);
    double rem=10000;
    for(;;){
      double hm;
      if(vx==0){
	hm=1e9;
      }else if(vx>0){
	hm=(w-r-p.real())/vx;
      }else{
	hm=(p.real()-r)/-vx;
      }
      double vm;
      if(vy==0){
	vm=1e9;
      }else if(vy>0){
	vm=(h-r-p.imag())/vy;
      }else{
	vm=(p.imag()-r)/-vy;
      }
      P v(vx,vy);
      double m=min(hm,vm);
      double rov=rem/abs(v);
      P d=p+min(m,rov)*v;
      auto cb=col(p,d);
      if(cb.size()==1){
	cout<<cb[0]<<endl;
	goto next;
      }else if(cb.size()>1){
	P l=p,h=d;
	for(;;){
	  P m=(l+h)/2.;
	  auto cb=col(p,m);
	  if(cb.size()==1){
	    cout<<cb[0]<<endl;
	    goto next;
	  }else if(cb.empty()){
	    l=m;
	  }else{
	    h=m;
	  }
	}
      }
      if(rov<=m){
	cout<<-1<<endl;
	break;
      }
      rem-=abs(p-d);
      if(hm<=vm){
	vx*=-1;
      }
      if(vm<=hm){
	vy*=-1;
      }
      p=d;
    }
  next:
    ;
  }
}
      
      

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
#define pb push_back
typedef long long ll;
const ll INF = 1LL << 60;

int main()
{
    ll MAX = 100000;
    vector<bool> isp(MAX, 1);
    isp[0] = isp[1] = false;
    for (ll p = 2; p < MAX; ++p) {
        if (!isp[p]) continue;
        for (ll i = p * 2; i < MAX; i += p) isp[i] = false;
    }

    vector<int> isOK(MAX+1);
    rep(i,MAX+1){
        if(i%2==0){continue;}
        if(isp[i] && isp[(i+1)/2]){
            isOK[i] = 1;
        }
    }

    vector<int> sum(MAX+2);
    rep(i,MAX+1){
        sum[i+1] = sum[i] + isOK[i];
    }
    ll q;
    cin >> q;
    vector<ll> ans(q);
    rep(i,q){
        ll l,r;
        cin >> l >> r;
        ans[i] = sum[r+1]-sum[l];
    }
    rep(i,q){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

void print(Vl vec){
    rep(i, 0, sz(vec)){
        if(i) cout << " ";
        cout << vec[i];
    }
    coel;
}

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


int main() {
    ll n; cin >> n;
    string s; cin >> s;
    ll cnt = 0;
    ll a = 0, b = 0;
    rep(i, 0, n){
        if(s[i]=='(') cnt++;
        else{
            if(cnt==0) a++;
            else cnt--;
        }
    }
    cnt = 0;
    for(int i = n-1; i >= 0; i--){
        if(s[i]==')') cnt++;
        else{
            if(cnt==0) b++;
            else cnt--;
        }
    }
    rep(i, 0, a) cout << '(';
    cout << s;
    rep(i, 0, b) cout << ')';
    coel;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    vector<vector<int>> v(3, vector<int>(3));
    rep(i, 3) rep(j, 3) cin >> v[i][j];
    int a[3], b[3];
    a[0] = 0;
    rep(i, 3) b[i] = v[0][i];
    Rep(i, 1, 3) a[i] = v[i][0] - b[0];
    rep(i, 3) {
        rep(j, 3) {
            if(v[i][j] != a[i] + b[j]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}*/
const ll MAXN = 8020;

int main()
{
	string s;
	cin >> s;
	int x, y;
	cin >> x >> y;

	vector<int> t;
	int cnt = 0;
	//文字列を変形する
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'T') {
			if (cnt != 0) t.push_back(cnt);
			t.push_back(0);
			cnt = 0;
		}
		else {
			cnt++;
			if (i == s.size() - 1) t.push_back(cnt);
		}
	}

	bool dp_x[MAXN][MAXN * 2] = { false }, dp_y[MAXN][MAXN * 2] = { false };
	dp_x[0][8000] = true;
	dp_y[0][8000] = true;

	bool flag = false;
	bool xy = true; // trueならx軸について見ている
	int cnt_x = 0, cnt_y = 0;

	for (int i = 0; i < t.size(); i++) {
		if (t[i] == 0) {
			xy = !xy;
		}
		else if (xy) {
			cnt_x++;
			for (int j = 0; j < MAXN * 2; j++) {
				if (dp_x[cnt_x - 1][j]) {
					if (j + t[i] < MAXN * 2) dp_x[cnt_x][j + t[i]] = true;
					if (j - t[i] >= 0 && flag) dp_x[cnt_x][j - t[i]] = true;
				}
			}
		}
		else if (!xy) {
			cnt_y++;
			for (int j = 0; j < MAXN * 2; j++) {
				if (dp_y[cnt_y - 1][j]) {
					if (j + t[i] < MAXN * 2) dp_y[cnt_y][j + t[i]] = true;
					if (j - t[i] >= 0) dp_y[cnt_y][j - t[i]] = true;
				}
			}
		}

		if (!flag) flag = true;
	}

	cout << ((dp_x[cnt_x][x + 8000] && dp_y[cnt_y][y + 8000]) ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 251648
#include "bits/stdc++.h"
#pragma warning(disable:4996)
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;
vector<int>G[12];
int p[12];
signed main() {
	int n, m; cin >> n >> m;
	rep(i, m) {
		int k; cin >> k;
		rep(j, k) {
			int s; cin >> s; s--;
			G[i].push_back(s);
		}
	}
	rep(i, m)cin >> p[i];
	int cnt = 0;

	rep(i, 1 << n) {
		int cnt2 = 0;
		rep(j, m) {
			int cnt3 = 0;
			rep(k, G[j].size()) {
				if (i & (1 << G[j][k]))cnt3++;
			}
			if (cnt3 % 2 == p[j])cnt2++;
		}
		if (cnt2 == m)cnt++;
	}
	cout << cnt << endl;
}

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

namespace ACTest
{
    class AOJDSL2A
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int num = int.Parse(input[0]);
            int query = int.Parse(input[1]);
            int[] com = new int[query];
            int[] x = new int[query];
            int[] y = new int[query];
            for (int i = 0; i < query; i++)
            {
                input = Console.ReadLine().Split(' ');
                com[i] = int.Parse(input[0]);
                x[i] = int.Parse(input[1]);
                y[i] = int.Parse(input[2]);
            }
            // make set
            int tree = 1;
            while (tree < num + 1)
            {
                tree *= 2;
            }
            int[] dat = new int[2 * tree - 1];
            dat = Enumerable.Repeat<int>(2147483647, 2 * tree - 1).ToArray();
            for (int i = 0; i < query; i++)
            {
                if (com[i] == 0)
                {
                    update(tree, x[i], y[i], dat);
                }
                else if (com[i] == 1)
                {
                    Console.WriteLine(findQuery(x[i], y[i] +1, 0, 0, tree, dat));
                }
            }
            //while (true) ;

        }
        /// <summary>
        /// ?????¨??? com0
        /// </summary>
        /// <param name="n">?????????????????°num????????§??????????°????2????????????</param>
        /// <param name="k">k?????????</param>
        /// <param name="a">a????????????</param>
        /// <param name="dat">?????¨2?????¨</param>
        static void update(int n, int k, int a, int[] dat)
        {
            k += n - 1;
            dat[k] = a;
            while (k > 0)
            {
                k = (k - 1) / 2;
                dat[k] = Math.Min(dat[2 * k + 1], dat[2 * k + 2]);
            }
        }
        static int findQuery(int a, int b, int k, int l, int r, int[] dat)
        {
            if (r <= a || b <= l)
            {
                return 2147483647;
            }
            if (a <= l && r <= b)
            {
                return dat[k];
            }
            else
            {
                int vl = findQuery(a, b, 2 * k + 1, l, (l + r) / 2, dat);
                int vr = findQuery(a, b, 2 * k + 2, (l + r) / 2, r, dat);
                return Math.Min(vl, vr);
            }

        }
    }
}

Measured memory_bytes: 16148
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>



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

using namespace std;
int a,b,c;

int main(){
  cin >> a >> b >> c;
  if(a<=c&&c<=b) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <map>
using namespace std;

int num[31], rank[31];
map<int,int> m;

int main() {
  string str;
  fill(num, num+31, 0);
  while(cin >> str) {
    replace(str.begin(), str.end(), ',', ' ');
    stringstream ss;
    ss << str;
    int a, b;
    ss >> a >> b;
    if(a == 0 && b == 0) break;
    m[a] = b;
    ++num[b];
  }
  for(int i = 30, p = 1; i >= 0; --i) {
    if(num[i] != 0) rank[i] = p++;
  }

  int id;
  while(cin >> id) {
    cout << rank[m[id]] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
#define LIMIT1 200010
#define LIMIT2 500010
typedef long long ll;
typedef long double ld;
typedef const void cv;
//BIT start
const int MAX_N=LIMIT2;
ll bit[MAX_N+1]={0},n;
//1-indexed BIT
ll sum(int i){
  ll s=0;
  while(i>0){
    s += bit[i];
    i -= i&(-i);
  }
  return s;
}
void add(int i,ll x){
  while(i<=n){
    bit[i] += x;
    i += i&(-i);
  }
}
ll rangesum(int l,int r){
  return sum(r)-sum(l-1);
}
//BIT end
int main(){
  ll i,q,x;
  cin >> n >> q;
  for(i=1;i<=n;i++){
    cin >> x;
    add(i,x);
  }
  int t,a,b;
  for(i=1;i<=q;i++){
    cin >> t >> a >> b;
    if(t==0) add(a+1,(ll)b);
    else cout << rangesum(a+1,b) << endl;
  }
  return 0;
}

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

using namespace std;

int h, w;
int c[10][10];
int a[222][222];

int main() {

    //input
    int h, w;cin >> h >> w;
    for(int i = 0;i < 10;i++){
        for(int j = 0;j < 10;j++){
            cin >> c[i][j];
        }
    }
    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            cin >> a[i][j];
        }
    }

    //Use the Virtual Floyd method to find the shortest distance from all vertices to all vertices about matrix 'C'
    for(int k = 0;k < 10;k++){
        for(int i = 0;i < 10;i++){
            for(int j = 0;j < 10;j++){
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }

    //Calculate the cost to make all the numbers '1'
    int ans = 0;
    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            if(a[i][j] == -1)continue;
            int thisNumber = a[i][j];
            ans += c[thisNumber][1];
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};


int main(){
  int n,m; cin >> n >> m;
  vector<pii> key(m);
  rep(i,m) {
    int a,b; cin >> a >> b;
    int s = 0;
    rep(j,b) {
      int c; cin >> c;
      c--;
      s |= (1 << c);
    }
    key[i] = mp(a,s);
  }

  vi dp((1<<n),1e9);
  dp[0] = 0;
  rep(bit,(1<<n)) {
    rep(i,m) {
      int s = key[i].second;
      s |= bit;
      int cost = key[i].first;
      chmin(dp[s],dp[bit] + cost);
    }
  }
  int ans = dp.back();
  if(ans == 1e9) ans = -1;
  cout << ans << endl;
}

Measured memory_bytes: 256
// AOJ 0121: Seven Puzzle 
// 2017.8.4 bal4u@uu
// 2017.11.1 retry

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define HASHSIZ 52009		// must > 20160
typedef struct { int s; char v; } HASH;
HASH hash[HASHSIZ+3], *hashend = hash + HASHSIZ;

int lookup(int s)
{
	HASH *hp = hash + s % HASHSIZ;
	while (hp->s) {
		if (hp->s == s) return hp->v;
		if (++hp == hashend) hp = hash;
	}
	return 0;
}

void insert(int s, char v)
{
	HASH *hp = hash + s % HASHSIZ;
	while (hp->s) {
		if (hp->s == s) { hp->v = v; break; }
		if (++hp == hashend) hp = hash;
	}
	hp->s = s, hp->v = v;
}

#define MAGIC 37
typedef struct { char x; int a; } T;
T s[50]; int top;
int to[8][4] = {
	{ 1,4,-1 }, { 0,2,5,-1 }, { 1,3,6,-1 }, { 2,7,-1 },
	{ 0,5,-1 }, { 1,4,6,-1 }, { 2,5,7,-1 }, { 3,6,-1 } };
char buf[30], *p;

int swap(int a, int x, int y)
{
	int xx, yy;

	x = (7-x) << 2,      y = (7-y) << 2;
	xx = (a >> x) & 0xf, yy = (a >> y) & 0xf;
	a = a & ~(0xf << x) & ~(0xf << y);
	a = a |  (xx << y)  | (yy << x);
	return a;
}

int main()
{
	int i, x, y, a, n;

	s[0].a = 0x1234567, s[0].x = 0, top = 1, insert(0x1234567, 1);
	while (top > 0) {
		x = s[--top].x, a = s[top].a, n = lookup(a)+1;
		if (n > MAGIC) continue;
		for (i = 0; (y = to[x][i]) >= 0; i++) {
			int k = swap(a, x, y);
			int m = lookup(k);
			if (!m || n < m) s[top].a = k, s[top++].x = y, insert(k, n);
		}
	}

	while (fgets(p=buf, 30, stdin) != NULL) {
		a = 0, i = 8; while (i--) a = (a<<4) + (*p++ & 0xf), p++;
		printf("%d\n", lookup(a) - 1);
	}
	return 0;
}

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

int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<char>> S(55, vector<char>(55));
  for (int i = 1; i <= H; i++){
    for (int j = 1; j <= W; j++){
      cin >> S.at(i).at(j);
    }
  }
  int ans = 0;
  for (int i = 1; i <= H; i++){
    for (int j = 1; j <= W; j++){
      if (S.at(i).at(j) == '#'){
        cout << '#';
      }
      else if(S.at(i).at(j) == '.'){
        if (S.at(i - 1).at(j - 1) == '#') ans++;
        if (S.at(i).at(j - 1) == '#') ans++;
        if (S.at(i + 1).at(j - 1) == '#') ans++;
        if (S.at(i - 1).at(j) == '#') ans++;
        if (S.at(i + 1).at(j) == '#') ans++;
        if (S.at(i - 1).at(j + 1) == '#') ans++;
        if (S.at(i).at(j + 1) == '#') ans++;
        if (S.at(i + 1).at(j + 1) == '#') ans++;
        cout << ans;
        ans = 0;
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define ll long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int s[20],n,m,c[20],a[20][20],x,sum,ans=-1;
void dfs(int p){
	if(p==n+1){
		bool f=1;
		FOR(i,1,m){
			if(s[i]<x){
				f=0;break;
			}
		}
		if(f){
			if(ans==-1||ans>sum){
				ans=sum;
			}
		}
		RE;
	}
	dfs(p+1);
	sum+=c[p];
	FOR(i,1,m)s[i]+=a[p][i];
	dfs(p+1);
	sum-=c[p];
	FOR(i,1,m)s[i]-=a[p][i]; 
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>m>>x;
	FOR(i,1,n){
		cin>>c[i];
		FOR(j,1,m)cin>>a[i][j];
	}
	dfs(1);
	cout<<ans;
	RE 0;
}




Measured memory_bytes: 3656