akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(void){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a < b) cout << a * c << endl;
  else cout << b * c +  d * (a - b) <<endl;
  return 0;
}


Measured memory_bytes: 256
object Main {
  def main (args: Array[String]) {
    var count:Int = 0
    for(line <- scala.io.Source.stdin.getLines()){
        val Array(min, max, o) = line.split(" ").map(_.toInt)
        var list: List[Int] = List() 
        for( i <-  min to max if ((o % i)  == 0 ) )  list = i::list
        println(list.length)
    }
  }
}

Measured memory_bytes: 44352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * The Number of Participants
 */
public class Main {

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

		int p, m, c;

		StringTokenizer st = new StringTokenizer(br.readLine());
		p = parseInt(st.nextToken());
		m = parseInt(st.nextToken());
		c = parseInt(st.nextToken());

		System.out.println(p + m + c);
	}
}

Measured memory_bytes: 24108
N, C = gets.split.map(&:to_i)
sushi_list = N.times.map { gets.split.map(&:to_i) }
reverse_sushi_list = sushi_list.map { |x, v| [C - x, v] }.sort_by(&:first)

def f(sl)
  tv = 0
  max_v = -Float::INFINITY
  d = -1

  sl.map do |x, v|
    tv += v

    if max_v < tv - x
      max_v = tv - x 
      d = x
    end

    [d, max_v]
  end
end

clock = [[0, 0]] + f(sushi_list)
reverse_clock = [[0, 0]] + f(reverse_sushi_list)

ans = 0

N.times do |i|
  c = clock[N - i][1] + reverse_clock[i][1] - reverse_clock[i][0]
  rc = reverse_clock[N - i][1] + clock[i][1] - clock[i][0]

  ans = [ans, c, rc].max
end

puts ans


Measured memory_bytes: 28864
import java.util.*;

class Main{
 public static void main(String args[]){
   Scanner scn = new Scanner(System.in);
   int a = scn.nextInt();
   int b = scn.nextInt();
   int max = 0;
   int min = 0;
   if(a<b){
     max = b;
     min = a;
   }else{
     max = a;
     min = b;
   }
   while(max%min!=0){
     int c = min;
     min = max%min;
     max = c;
   }
   long l = (long)(a/min) * (b/min) * min;
   System.out.println(l);
 }
}

Measured memory_bytes: 21972
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc134_a.cpp
 * time   : Sat May  2 01:16:30 2020
 * quest  : A - Dodecagon
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int r;
  cin >> r;
  cout << 3 * (r * r) << "\n";
  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);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int D = sc.nextInt();
    String S = "";
    for(int i=0; i<100; i++) {
      C -= B;
      A -= D;
      if(C<=0) {
        S = "Yes";
        break;
      }
      if(A<=0) {
        S = "No";
        break;
      }
    }
        System.out.println(S);
  }
}

Measured memory_bytes: 35620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn = 1e6 + 5;

int n,Q;
char s[maxn];
set<int>ss[30];

int main(){
	cin>>n>>s+1>>Q;
	for(int i=0;i<26;i++) 
        ss[i].insert(n+1);
	for(int i=1;i<=n;i++) 
        ss[s[i]-'a'].insert(i);
	
    while(Q--){
		int t,i,l,r;
		char c;
		cin>>t;
		if(t==1){
			cin>>i>>c;
			if(s[i]!=c) 
                ss[s[i]-'a'].erase(i);
			s[i]=c;
			ss[c-'a'].insert(i);
		}else{
			int ans=0;
			cin>>l>>r;
			for(int i=0;i<26;i++)
				if(*ss[i].lower_bound(l)<=r) 
                    ans++;
			cout<<ans<<'\n';
		}
	}
	return 0;
}

Measured memory_bytes: 24192
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main() {
    int x;
    cin >> x;
    if(x < 1200) cout << "ABC" << endl;
    else cout << "ARC" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int[] dp;
        while(scan.hasNext()){
            int n = scan.nextInt();
            if(n == 0){
                break;
            }
            int[] a = new int[n];
            for(int i = 0;i < n;i++){
                a[i] = scan.nextInt();
            }
            dp = new int[n];
            int res = dp[0] = a[0];
            for(int i = 1;i < n;i++){
                dp[i] = maximum(a[i],a[i]+dp[i-1]);
                res = maximum(res,dp[i]);
            }
            System.out.println(res);
        }
    }
    public static int maximum(int a,int b){
        return (a > b)?a:b;
    }
}

Measured memory_bytes: 26384
// Problem : E - Simple String Queries
// Contest : AtCoder - AtCoder Beginner Contest 157
// URL : https://atcoder.jp/contests/abc157/tasks/abc157_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 500005

//Solution

string s;
int n,q;

struct BIT{
    int fen[N];

    void add(int x, int val){
        for (int i=x+1;i<N;i+=i&(-i)) fen[i] += val;
    }
     
    int get(int x){
        int ans = 0;
        for (int i=x;i>0;i-=i&(-i)) ans += fen[i];
        return ans;
    }
     
    int sum(int x, int y){
        return get(y+1)-get(x);
    }
} b[26];

void solve(){
    cin>>n>>s>>q;
    for(int i=0;i<n;i++) b[s[i]-'a'].add(i,1);
    while(q--){
        int type,l,r; char c;
        cin>>type;
        if(type == 1){
            cin>>l>>c;
            b[s[l-1]-'a'].add(l-1,-1);
            b[c-'a'].add(l-1,1);
            s[l-1] = c;
        } else {
            cin>>l>>r; l--; r--;
            int ans = 0;
            for(int i=0;i<26;i++){
                if(b[i].sum(l,r) > 0) ans++;
            }
            cout<<ans<<endl;
        }
    }
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 105352
n,k = map(int, input().split())
d = []
a = []
for _ in range(k):
  D = int(input())
  A = list(map(int, input().split()))
  d.append(D)
  a += A

a = list(set(a))
check = [1] * n
for i in a:
  check[i-1] = 0
print(sum(check))

Measured memory_bytes: 9260
#include <bits/stdc++.h>
using namespace std;
const double g = 9.8;
const double eps = 1e-10;
double calc(double vy, double t){
    return vy * t - 0.5 * g * t * t;
}
const int N = 60;
int n;
double v,x,y, fy;
double L[N],B[N],R[N],T[N];

bool cmp(int i, double vx, double vy) {
    if (L[i] > x || L[i] > R[i]) return true;
   // if (R[i] > x && fy >= T[i] && y <= T[i]) return false;
    double yl = calc(vy, L[i] / vx), yr = calc(vy, R[i] / vx);
    if (yl > T[i] && yr > T[i]) return true;
    if (yl < B[i] && yr < B[i]) {
        double tx = vx * vy / g;
        if (tx > R[i] || tx < L[i]) return true;
        return calc(vy, vy / g) < B[i];
    }
    return false;
}

int cmp(double lb, double ub, double a) {
    return a < lb + eps ? -1 : a > ub - eps ? 1 : 0;
}

bool check(double qx, double qy) {
    double A = g * g, b = 4 * qy * g - 4 * v * v, C = 4 * (qx *qx + qy * qy);
    double delta = b * b - 4 * A * C;
    if (delta < 0) return false;
    for (int co = -1; co <= 1; co+=2) {
        double t2 = (-b+co * sqrt(delta)) / (2 * A);
        if (t2 < 0) continue;
        double t = sqrt(t2);
        double vx = qx / t, vy = sqrt(v*v - vx * vx);
        fy = calc(vy, x / vx);
        if (fy + eps < y) continue;
        bool ok = true;
        for (int i = 0; i < n;i++) {
            if (L[i] >= x) continue;
            if (R[i] == x && y <= T[i] && B[i] <= fy) ok = false;
            int yL = cmp(B[i], T[i], calc(vy, L[i] / vx));
            int yR = cmp(B[i], T[i], calc(vy, R[i] / vx));
            int xH = cmp(L[i], R[i], vx * (vy / g));
            int yH = cmp(B[i], T[i], calc(vy, vy / g));
            if (xH == 0 && yH >= 0 && yL < 0) ok = false;
            if (yL * yR <= 0) ok = false;
        }
        if (ok) return true;
    }
    return false;
}


int main() {
    scanf("%d%lf%lf%lf", &n, &v, &x, &y);
    for (int i = 0; i < n; i++) {
        scanf("%lf%lf%lf%lf", L + i, B + i, R + i, T + i);
        R[i] = min(x,R[i]);
    }
    bool ok = false;
    ok |= check(x,y);
    for (int i = 0; i < n && !ok; i++) {
        ok |= check(L[i],B[i]);
        ok |= check(L[i],T[i]);
        ok |= check(R[i],B[i]);
        ok |= check(R[i],T[i]);
    }
    if (ok) {
        puts("Yes");
    }
    else {
        puts("No");
    }
    



}


Measured memory_bytes: 3228
s=list(input())
s_o = s[::2]
s_e = s[1::2]

od = ["R","U","D"]
ev = ["L","U","D"]

for i in range(len(s_o)):
    if (s_o[i] not in od):
        print("No")
        exit()

for i in range(len(s_e)):
    if (s_e[i] not in ev):
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 3064
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[] l = new int[m];
    int[] r = new int[m];

    for (int i = 0; i < m; i++) {
      l[i] = sc.nextInt();
      r[i] = sc.nextInt();
    }

    int min = 0;
    int max = 100001;

    for (int i = 0; i < m; i++) {
      min = Math.max(min,l[i]);
      max = Math.min(max,r[i]);
    }

    if (min > max) {
      System.out.println(0);
    } else {
      System.out.println(max-min+1);
    }
  }

}


Measured memory_bytes: 78044
n=int(input())
p=list(map(int,input().split()))
ans=0
for i in range(1,n-1):
  temp=list()
  temp.append(p[i-1])
  temp.append(p[i])
  temp.append(p[i+1])
  if p[i]==sorted(temp)[-2]:
    ans+=1
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n;
	cin >> n;
	vi v(n);
	rep(i, n)cin >> v[i];
	sort(all(v));

	double ans = v[0];
	rep(i, n - 1)ans = (ans + v[i + 1]) / 2;
	
	cout << fixed << setprecision(8);
	cout << ans << endl;

}

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

int n, m, k, Start;
int a[Maxn][Maxn];

int main()
{
	scanf("%d", &n); n*=2;
	m=(int)sqrt(n);
	if (m*(m+1)!=n) { puts("No"); return 0; }
	else
	{
		puts("Yes");
		printf("%d\n", k=n/m);
		Start=1;
		for (int s=1; s<=m; s++)
		{
			for (int i=s; i<=m; i++) a[s][i]=Start+i-s;
			for (int i=s+1; i<=k; i++) a[i][s]=a[s][m+s-i+1];
			Start+=(m-s+1);
		}
		for (int i=1; i<=k; i++)
		{
			printf("%d ", m);
			for (int j=1; j<=m; j++) printf("%d ", a[i][j]); puts("");
		}
	}
	
}


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

using namespace std;

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

    int n;
    cin >> n;
    int a[n+1], b[n+1];

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

    sort(a+1, a+n+1);
    sort(b+1, b+n+1);

    int x, y;
    if(n&1) {
        x = a[n/2+1];
        y = b[n/2+1];
    } else {
        x = a[n/2] + a[n/2+1];
        y = b[n/2] + b[n/2+1];
    }

    cout << y-x+1 << endl;
}


Measured memory_bytes: 5148
#include <iostream>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  int odd = 0, two = 0, four = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (a % 4 == 0) {
      four++;
    } else if (a % 4 == 2) {
      two++;
    } else {
      odd++;
    }
  }
  if (odd == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  if (two > 0) {
    odd++;
  }
  cout << (four + 1 >= odd ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define fs first
#define sc second
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;

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

inline int encode(const vi &x, const int &w){
  int res = 0, k = 1;
  for(int p : x){
    res += k * p;
    k <<= 8;
  }
  return res;
}

inline vi decode(int x, const int &n, const int &w){
  int k = 1<<8;
  vi res(n);
  rep(i,n){
    res[i] = x & (k-1);
    x >>= 8;
  }
  return res;
}

short memo[1<<24];

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

  int h,w,n;
  string g[16];
  while(cin >> w >> h >> n, w){
    cin.ignore();

    vi start(n), end(n);
    rep(i,h){
      getline(cin,g[i]);
      rep(j,w){
	if(islower(g[i][j]))start[g[i][j]-'a'] = i*w+j;
	if(isupper(g[i][j]))end[g[i][j]-'A'] = i*w+j;
      }
    }
    int start_id = encode(start,w);
    int end_id = encode(end,w);

    vector<int> edge[256];
    rep(i,h)rep(j,w){
      if(g[i][j] == '#')continue;
      rep(d,5){
	int ny = i+dy[d], nx = j+dx[d];
	if(g[ny][nx] !='#')edge[i*w+j].push_back(ny*w+nx);
      }
    }

    memset(memo,-1,sizeof(memo));
    memo[start_id] = 0;
    queue<int> q;
    q.push(start_id);
    
    while(q.size()){
      int cur_id = q.front(); q.pop();
      vi cur = decode(cur_id,n,w), nxt(n);
      if(cur_id == end_id)break;

      vi dir(n,0); dir[0] = 0;
      while(dir[n-1]<(int)edge[cur[n-1]].size()){
	bool f = true;
	rep(i,n)nxt[i] = edge[cur[i]][dir[i]];
	int nxt_id = encode(nxt, w);

	if(memo[nxt_id]==-2)f = false;
	else{
	  for(int i=0;f && i<n;i++){
	    for(int j=0;f && j<i;j++){
	      if(nxt[i] == nxt[j])f = false;
	    }
	  }
	}

	if(!f)memo[nxt_id] = -2;
	else{
	  for(int i=0;f && i<n;i++){
	    for(int j=0;f && j<i;j++){
	      if(nxt[i] == cur[j] && nxt[j] == cur[i])f = false;
	    }
	  }
	}

	if(f){
	  if(memo[nxt_id] < 0){
	    memo[nxt_id] = memo[cur_id] + 1;
	    q.push(nxt_id);
	  }
	}

	dir[0]++;
	for(int i=0;i<n-1;i++){
	  if(dir[i]==(int)edge[cur[i]].size())dir[i] = 0, dir[i+1]++;
	}
      }

    }
    cout << memo[end_id] << endl;
  }
}

Measured memory_bytes: 34952
#include<cstdio>
#include<set>
#include<iostream>
#include <iterator>
#include <utility>
#include<map>
#define max 100005
using namespace std;
struct tree
{
	int parent;
	int left;
	int  right;
};
struct tree T[max];
void pre(int u)
{
	if(u==-1)
	return;
	cout<<" "<<u;
	pre(T[u].left);
	pre(T[u].right);
}
void ino(int u)
{
	if(u==-1)
	return;
	ino(T[u].left);
	cout<<" "<<u;
	ino(T[u].right);
}
void pos(int u)
{
	if(u==-1)
	return;
	pos(T[u].left);
	pos(T[u].right);
	cout<<" "<<u;
}
int main()
{
	int n;
	int id,left,right;
	cin>>n;
	for(int i=0;i<n;i++)
	T[i].parent=-1;
	for(int i=0;i<n;i++)
	{
		cin>>id>>left>>right;
		T[id].left=left;
		T[id].right=right;
	
		if(left!=-1)
		T[left].parent=id;
		if(right!=-1)
		T[right].parent=id;
	}
	int root;

	for(int i=0;i<n;i++)
		if(T[i].parent==-1)
			root=i;
	
	cout<<"Preorder"<<endl;
		pre(root);
	cout<<endl;
	
	cout<<"Inorder"<<endl;
		ino(root);
	cout<<endl;
	
	cout<<"Postorder"<<endl;
		pos(root);
	cout<<endl;
	
	return 0;
}


Measured memory_bytes: 3104
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		int n = sc.nextInt();
		
		Card[] A = new Card[n];
		for(int i=0; i<n; i++) {
			String suit = sc.next();
			int num = sc.nextInt();
			A[i] = new Card(suit, num, i);
		}
		
		quickSort(A, 0, n-1);
		
		boolean flag = true;
		for(int i=1; i<n; i++) {
			if(A[i-1].num == A[i].num && A[i-1].id > A[i].id) {
				flag = false;
				break;
			}
		}
		if(flag) {
			System.out.println("Stable");
		} else {
			System.out.println("Not stable");
		}
		
		StringBuilder ans = new StringBuilder();
		for(int i=0; i<n; i++) {
			ans.append(A[i].suit);
			ans.append(" ");
			ans.append(A[i].num);
			ans.append("\n");
		}
		System.out.print(ans);
	}
	
	static void quickSort(Card[] A, int p, int r) {
		if(p < r) {
			int q = partition_num(A, p, r);
			quickSort(A, p, q-1);
			quickSort(A, q+1, r);
		}
	}
	
	static int partition_num(Card[] A, int p, int r) {
		int x = A[r].num;
		int i = p-1;
		Card temp;
		for(int j=p; j<=r-1; j++) {
			if(A[j].num <= x) {
				i++;
				temp = A[j];
				A[j] = A[i];
				A[i] = temp;
			}
		}
		temp = A[r];
		A[r] = A[i+1];
		A[i+1] = temp;
		
		return i+1;
	}
	
	static class Card {
		String suit;
		int num;
		int id;
		Card(String suit, int num, int id) {
			this.suit = suit;
			this.num = num;
			this.id = id;
		}
	}

	static class FastScanner {
	    private final InputStream in = System.in;
	    private final byte[] buffer = new byte[1024];
	    private int ptr = 0;
	    private int buflen = 0;
	    private boolean hasNextByte() {
	        if (ptr < buflen) {
	            return true;
	        }else{
	            ptr = 0;
	            try {
	                buflen = in.read(buffer);
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	            if (buflen <= 0) {
	                return false;
	            }
	        }
	        return true;
	    }
	    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
	    public String next() {
	        if (!hasNext()) throw new NoSuchElementException();
	        StringBuilder sb = new StringBuilder();
	        int b = readByte();
	        while(isPrintableChar(b)) {
	            sb.appendCodePoint(b);
	            b = readByte();
	        }
	        return sb.toString();
	    }
	    public long nextLong() {
	        return Long.parseLong(next());
	    }
	    public int nextInt(){
	    	return Integer.parseInt(next());
	    }
	}
}

Measured memory_bytes: 67692
#include "bits/stdc++.h"
using namespace std;

const int N=2e3+20,MOD=1e9+7;

int dp[N],n;

int main()
{
	cin>>n;
	dp[0]=1;
	for(int i=0;i<=n;i++)
	{
		for(int j=3;j<=n;j++)
		{
			if(j<=i)
			{
				dp[i]+=dp[i-j];
				dp[i]%=MOD;
			}
		}
	}

	cout<<dp[n];
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
//		String[] tmpArray = br.readLine().split(" ");
//		int n = Integer.parseInt(tmpArray[0]);
//		int m = Integer.parseInt(tmpArray[1]);
//		int c = Integer.parseInt(tmpArray[2]);
//		int y = Integer.parseInt(tmpArray[3]);
//		int r = Integer.parseInt(tmpArray[4]);

		//String[] tmpArray = br.readLine().split(" ");
		//int[] input = new int[n];
//		for(int i = 0; i < n; i++){
		while(true){
			String[] tmpArray = br.readLine().split(" ");
			int n = Integer.parseInt(tmpArray[0]);
			int x = Integer.parseInt(tmpArray[1]);
//			int r = Integer.parseInt(tmpArray[2]);
//			int v = Integer.parseInt(tmpArray[3]);
			
			if(n == 0 && x == 0){
				break;
			}
			
			int comb = 0;
			for(int i = 1; i <= n ;i++){
				for(int j = i + 1; j <= n; j++){
					for(int k = j + 1; k <= n; k++){
						if(i+j+k == x){
							comb++;
							break;
						}
					}
				}
			}
			
			System.out.println(comb);
		}
			
//		System.out.print(input[0]);
//		for(int i = 1 ; i < n; i++){
//			System.out.print(" "+ input[i]);
//		}
//		System.out.println();
////		
//		Arrays.sort(input);
//		System.out.printf("%d %d %d\n", input[0], input[input.length - 1], sum);
//		
//		while(true){
//			String[] tmpArray = br.readLine().split(" ");
//			int a = Integer.parseInt(tmpArray[0]);
//			int b = Integer.parseInt(tmpArray[1]);
//			if(a == 0 && b == 0){
//				break;
//			}
//			
//			for(int i = 0; i < a; i++){
//				for(int j = 0; j < b; j++){
//					if((i + j)%2 == 1){
//						System.out.print(".");
//					}
//					else{
//						System.out.print("#");
//					}
//				}
//				System.out.println();
//			}
//			System.out.println();
//		}

		//		int[] array = new int[3];
//		array[0] = a; array[1] = b; array[2] = c;
//
//		Arrays.sort(array);
//		System.out.printf("%d %d %d\n", array[0], array[1], array[2]);
		/*
		if(a < b && b < c){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}*/
	}

}

Measured memory_bytes: 24848
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#define MOD 1000000007
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
signed main(){
    int n,x;
    cin>>n>>x;
    int a[114514];
    int ans=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(i>0){
            if(a[i-1]+a[i]>x){
                if(a[i]<a[i-1]+a[i]-x){
                    ans+=a[i];
                    a[i]=0;
                    ans+=a[i-1]-x;
                    a[i-1]-=a[i-1]+a[i]-x-a[i];
                }else{
                    ans+=a[i]+a[i-1]-x;
                    a[i]=x-a[i-1];
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}



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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  ll n,k;
  cin>>n>>k;
  ll ans=0;
  if(k%2==1) ans=(n/k)*(n/k)*(n/k);
  else{
    ans=(n/k)*(n/k)*(n/k);
    ll cnt=0;
    for(int i=k/2; i<=n; i+=k){
      cnt++;
    }
    ans+=cnt*cnt*cnt;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (500000)
#define pii pair<int, int>
#define vc vector
#define a first
#define b second
#define pb pusu_back

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

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> &V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

template<typename T>
T euclid(T a, T b){
  if(b == 0) return a;
  else return euclid(b, a % b);
}

vector<ll> fact(MAX, 0), fact_inv(MAX, 0);

ll pow_mod(ll a, ll b){
	ll res = 1;
	while(b > 0){
		if(b & 1) res = res * a % MOD;
		a = a * a % MOD;
		b >>= 1;
	}
	return res;
}

void prepare_comb_mod(ll n){
	fact[0] = 1LL;
	for(ll i = 0; i < n; i++) fact[i+1] = fact[i] * (i + 1) % MOD;
	fact_inv[n] = pow_mod(fact[n], MOD - 2);
	for(ll i = n - 1; i >= 0; i--) fact_inv[i] = fact_inv[i + 1] * (i + 1) % MOD;
}

ll comb_mod(ll n, ll r){
	return (fact[n] * fact_inv[r]) % MOD * fact_inv[n - r] % MOD;
}

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

void Main() {
  int N, M, Q; cin >> N >> M >> Q;
  vc<pii> LR(M);
  rep(i, 0, M){
    cin >> LR[i].a >> LR[i].b;
  }
  vc<vc<int>> vv(N + 1, vc<int>(N + 1, 0));
  rep(i, 0, M) vv[LR[i].a][LR[i].b]++;
  vc<vc<int>> cum(N + 1, vc<int>(N + 1, 0));
  rep(i, 1, N + 1){
    int sum = 0;
    rep(j, 1, N + 1){
      sum += vv[i][j];
      cum[i][j] += sum;
      cum[i][j] += cum[i - 1][j];
    }
  }
  rep(q, 0, Q){
    int s, t; cin >> s >> t;
    cout << cum[t][t] - cum[t][s - 1] - cum[s - 1][t] + cum[s - 1][s - 1] << endl;
  }
}

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

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 12288
use std::io::Read;

fn main() {
    let mut buff = String::new();
    std::io::stdin().read_to_string(&mut buff).unwrap();
    let mut iter = buff.split_whitespace();

    let s: String = iter.next().unwrap().parse().unwrap();

    let mut chars: Vec<char> = s.chars().collect();
    chars.sort_by(|a, b| b.cmp(a));

    match s.find('a').and(s.find('b').and(s.find('c'))) {
        Some(ref _p) => println!("Yes"),
        None => println!("No"),
    }
}


Measured memory_bytes: 4352
// MAGRANT - GNC19 - TEMPLATE 3.1
// 2017/8/19 - AtCoder Regular Contest 059 - D
// PRACTISING TIME TAGS:
// ALGORITHM: 2MIN, STARTED AT: 17:09
// CODING: ## (3)MIN, STARTED AT: 17:12
// SUMMARY: [MISTAKES / REQUISITES]

// FOR COMPATIBILITY:
#define _CRT_SECURE_NO_WARNINGS

// UNIVERSAL DEFINITIONS:
#define N (1<<17)
#define MODULO (1000000007)
#define HA1 (2420609)
#define HA2 (19260817)

// FREQUENT HEADER FILES:
#include <cstdio>
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <complex>
using namespace std;

// TEMPLATE BEGINS HERE.
//#define MAGRANT_ALLOWS_CTMP
// IMPORTANT: DO NOT OPEN UNLESS AS CONTESTANT.
// CAUTION: BEWARE OF CONFLICT.
#ifdef MAGRANT_ALLOWS_CTMP
namespace CTMP
{
	// ELEMENTARY MATHEMATICAL COMPUTATIONS:
	long long fact[N], inv[N];
	long long KissMe(long long xx, long long yy)
	{
		if (yy == 0LL)
		{
			return 1LL;
		}
		long long Res = KissMe((xx*xx) % (long long)MODULO, yy >> 1);
		if (yy % 2LL == 1LL)
		{
			Res *= xx;
			Res %= (long long)MODULO;
		}
		return Res;
	}
	inline void InitFactInv()
	{
		fact[0] = 1LL;
		for (int i = 1;i < N - 4;i++)
		{
			fact[i] = fact[i - 1] * (long long)i;
			fact[i] %= (long long)MODULO;
		}
		inv[N - 5] = KissMe(fact[N - 5], (long long)(MODULO - 2));
		for (int i = N - 6;i >= 0;i--)
		{
			inv[i] = inv[i + 1] * (long long)(i + 1);
			inv[i] %= (long long)MODULO;
		}
	}
	inline long long Choose(int xx, int yy)
	{
		if (xx < yy)
		{
			return 0LL;
		}
		else if (xx == yy)
		{
			return 1LL;
		}
		long long Res = fact[xx];
		Res *= inv[yy];
		Res %= (long long)MODULO;
		Res *= inv[xx - yy];
		Res %= (long long)MODULO;
		return Res;
	}
	inline long long GridWays(int fx, int fy, int sx = 0, int sy = 0)
	{
		fx -= sx, fy -= sy;
		if (fx < 0 || fy < 0)
		{
			return 0LL;
		}
		long long Res = fact[fx + fy];
		Res *= inv[fx];
		Res %= (long long)MODULO;
		Res *= inv[fy];
		Res %= (long long)MODULO;
		return Res;
	}
}
#endif
// TEMPLATE FINISHES HERE.

int n;
char s[N];
int pre[30];

int main()
{
	// IMPORTANT: DO NOT OPEN UNLESS AS CONTESTANT.
	// CAUTION: BEWARE OF CONFLICT.
	//using namespace CTMP;

	// REAFFIRM THE FOLLOWING BEFORE CODING.
	// 1. THE ALGORITHM IS CORRECT.
	// 2. THE COMPLEXITY IS PROPER.
	// 3. THE ALGORITHM CANNOT BE SIMPLER.
	// 4. CODING DETAILS WERE CONSIDERED.

	scanf("%s", s);
	n = strlen(s);
	for (int i = 0;i < 26;i++)
	{
		pre[i] = -N;
	}
	for (int i = 0;i < n;i++)
	{
		int tmp = pre[s[i] - 'a'];
		if (i - tmp <= 2)
		{
			printf("%d %d\n", tmp + 1, i + 1);
			system("pause");
			return 0;
		}
		pre[s[i] - 'a'] = i;
	}
	printf("-1 -1\n");
	// REAFFIRM THE FOLLOWING BEFORE SUBMITTING.
	// 1. THE ARRAYS ARE IN PROPER SIZE.
	// 2. THE CORNER CASES WILL NOT LEAD TO VIOLATION.
	// 3. NO TYPO LIKE N->M EXISTS.
	// 4. THE INPUT/OUTPUT IS IN THE SPECIFIED FORMAT.
	//system("pause");
	return 0;
}


Measured memory_bytes: 632
s = input() + '#'

odd_count = 0
even_count = 0
t = [0] * len(s)
flag = True
for i in range(len(s)):
    if flag:
        if s[i] == 'R':
            if i % 2 == 0:
                even_count += 1
            else:
                odd_count += 1
        else:
            flag = False
            pos = i
            if i % 2 == 0:
                even_count += 1
            else:
                odd_count += 1
    else:
        if s[i] == 'R' or s[i] == '#':
            if pos % 2 == 0:
                t[pos-1] = odd_count
                t[pos] = even_count
            else:
                t[pos-1] = even_count
                t[pos] = odd_count
            if i % 2 == 0:
                even_count = 1
                odd_count = 0
            else:
                even_count = 0
                odd_count = 1
            flag = True
        else:
            if i % 2 == 0:
                even_count += 1
            else:
                odd_count += 1
print(' '.join(map(str, t[:-1])))


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

#define ll long long int
#define ld long double
#define pb push_back

ll mod = 1000000007;

using namespace std;

ll countDivisibles(ll A, ll B, ll M) 
{ 
    
    if (A % M == 0) 
        return (B / M) - (A / M) + 1; 
  
       return (B / M) - (A / M); 
} 

int main()
{
	
	 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	 
	 ll a,b,c,d;
	 cin>>a>>b>>c>>d;
	 ll t1 = countDivisibles(a,b,c);
	 ll t2 = countDivisibles(a,b,d);
	 ll gc = __gcd(c,d);
	 ll multi = c*d;
	 ll e = multi/gc;
	 ll t3 = countDivisibles(a,b,e);

	 ll tt = t1+t2-t3;

	 ll r = b-a+1;
	 cout<<r-tt<<"\n";



	return 0;
}

Measured memory_bytes: 256
s = input()
n = len(s)
t = s.replace('x', '')
if t != t[::-1]:
    print(-1)
else:
    u = s[::-1]
    cnt = 0
    l = r = 0
    while l < n or r < n:
        if l >= n:
            cnt += 1
            r += 1
        elif r >= n:
            cnt += 1
            l += 1
        elif s[l] == u[r]:
            l += 1
            r += 1
        elif s[l] == 'x':
            cnt += 1
            l += 1
        else:
            cnt += 1
            r += 1
    print(cnt // 2)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <variant>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s,t;
  cin>>s>>t;
  int n = size(s);
  int m = size(t);
  int mn = n;
  REP(i,n) {
    if (i + m > n) break;
    int cnt = 0;
    REP(j,m) {
      if (s[i+j] != t[j]) ++cnt;
    }
    mn = min(mn, cnt);
  }
  cout<<mn<<endl;
  return 0;
}


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

int main(){
	long long a, b, c, x, y;
	std::cin >> a >> b >> c >> x >> y;
	
	long long A = std::min(a + b, 2 * c);
	
	
	if(x == y){
		cout << A * x << endl;
	}else if(x < y){
		long long ans = std::min(y * A, x * A + (y - x) * b);
		cout << ans << endl;
	}else{
		long long ans = std::min(x * A, y * A + (x - y) * a);
		cout << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
ans=[-1 for i in range(n)]
for i in range(m):
    s,c=map(int,input().split())
    if ans[s-1]==-1 or ans[s-1]==c:
        ans[s-1]=c
    else:
        print(-1)
        break
else:
    if ans[0]>0 or ans[0]==-1:
        if ans[0]==-1:
            if n>1:
                print(1,end="")
            else:
                print(0,end="")
        else:
            print(ans[0],end="")
        for i in range(1,n):
            if ans[i]==-1:
                print(0,end="")
            else:
                print(ans[i],end="")
        print()
    else:
        if n==1:
            print(0)
        else:
            print(-1)
    
    

Measured memory_bytes: 3064
import bisect
q = int(input())
LR = [tuple(map(int,input().split())) for i in range(q)]
ans = []
sosuu = [2]
A = 100000
for L in range(3, A, 2): # 2 以外の素数は奇数なので
    for L2 in sosuu:
        if L % L2 == 0:
            break # 素数でないことがわかったらそれ以上ループする必要はない
    else: # break で抜けることがなかったら L は素数（Python 特有の制御構文）
        sosuu.append(L)
        if (L+1)/2 in sosuu:
          ans.append(L)
for lr in LR:
  print(bisect.bisect_right(ans,lr[1]) - bisect.bisect_left(ans,lr[0]))

Measured memory_bytes: 91116
from fractions import gcd
A,B=map(int,input().split())
C=gcd(A,B)

if C==1:
   print(1)
else:
   count=1
   C_copy=C
   n=2
   while n**2<=C:
      flag=False
      while C_copy%n==0:
         C_copy//=n
         flag=True
      if flag:
         count+=1
         n=n+1 if n==2 else n+2
      else:
         n=n+1 if n==2 else n+2
   
   if C_copy!=1:
      count+=1

   print(count)

Measured memory_bytes: 5180
N = int(input())
S = input()

ans = 0
for i in range(1000):
    target = str(i).zfill(3)
    char_idx = 0
    for c in S:
        if c == target[char_idx]:
            char_idx += 1

        if char_idx == 3:
            ans += 1
            break

print(ans)

Measured memory_bytes: 41180
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

void cout_vec(vector<int> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}


int main(){
    int N;
    cin >> N;
    vector<int> vec(N,0);
    for(int i=0; i<N; i++){
        int A;
        cin >> A;
        vec[--A]=i+1;
    }
    cout_vec(vec);
}

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)
int main(){
    int N;
    cin >> N;

    vll A(3*N);
    for (int i=0;i<3*N;i++) cin >> A[i];
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());

    ll ans = 0;
    for (int i=0;i<N;i++) ans += A[1+2*i];

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2688
#include <stdio.h>
#include <stdlib.h>

int main()
{
  int x,y,r=1;/* 変数の宣言 */
  scanf("%d%d",&x,&y);/* 変数の格納 */
  if(x<1 || y >1000000000){/* 制約 */
    exit(0);/* 変数が正しくない場合、プログラムを終了する */
  }
  r = x % y;
  while(r!=0){
    x = y;
    y = r;
    r = x % y;
  }/* ユークリッドの互除法 */
  printf("%d\n",y);/* 最大公約数の表示 */

  return 0;
}



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

typedef long long ll;
#define INF INT_MAX

bool comp(int a,int b){
    return a > b;
}

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

    int N;
    cin >> N;
    map<string,int> m;
    int mx = 0;
    string s;
    for(int i = 0 ; i < N ; i++){
        cin >> s;
        m[s]++;
        mx = max(mx,m[s]);
    }
    for(auto x : m){
        if(x.second == mx)
            cout << x.first << '\n';
    }

    return 0;
}


Measured memory_bytes: 23808
#include <bits/stdc++.h>
#define N 100050
#define INF (1<<29)
using namespace std;
inline int rd() {
	int x=0,f=1;char ch=getchar();
	while (ch>'9'||ch<'0') {if(ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
	return x*f;
}

int a[N],b[N],n,k,tot;
vector<int> E[N];

void dfs(int u,int f,int d) {
	if (d > k/2) return ;
	tot++;
	for (int i=0;i<(int)E[u].size();i++) {
		int v = E[u][i];
		if (v == f) continue;
		dfs(v,u,d+1);
	}
}

int main() {
	n = rd(), k = rd();
	for (int i=1;i<n;i++) {
		int u = rd(), v = rd();
		a[i] = u, b[i] = v;
		E[u].push_back(v);
		E[v].push_back(u);
	}
	
	int ans = INF;
	if (k%2 == 0) {
		for (int i=1;i<=n;i++) {
			tot = 0;
			dfs(i, i ,0);
			ans = min(ans, n - tot);
		}
	} else {
		for (int i=1;i<n;i++) {
			tot = 0;
			dfs(a[i], b[i], 0);
			dfs(b[i], a[i], 0);
			ans = min(ans, n - tot);
		}
	}
	
	cout << ans << endl;
	return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(n, m);
    vector<pii> data(m);
    for (int i = 0; i < m; i++) {
        cin >> data[i].fir >> data[i].sec;
        data[i].fir--; data[i].sec--;
    }

    sort(all(data));

    int right = data[0].sec, ans = 0;
    Rep(i, m) {
        if (data[i].fir >= right) {
            ans++;
            right = data[i].sec;
        } else {
            right = min(right, data[i].sec);
        }
    }
    cout << ans + 1 << endl;

    

    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <inttypes.h>

int main(void) {
	uint64_t A, B, C, D;
	uint64_t AB, CD;
	if (scanf("%" SCNu64 "%" SCNu64 "%" SCNu64 "%" SCNu64, &A, &B, &C, &D) != 4) return 1;
	AB = A * B;
	CD = C * D;
	printf("%" PRIu64 "\n", AB >= CD ? AB : CD);
	return 0;
}


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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	//~ cout.tie(0);
	int n; cin >> n;
	map<string,int> cnt;
	int mc = 0;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		++cnt[s];
		mc = max(mc, cnt[s]);
	}

	for (const auto &p : cnt) {
		if (p.second == mc) cout << p.first << endl;
	}
}


Measured memory_bytes: 25216
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
  int a;
  string s;
  cin >> a >> s;
  print(a >= 3200 ? s : "red");
  return 0;
}
#include <algorithm>


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

int main(){
    int year, month, day;
    scanf("%d/%d/%d",&year,&month,&day);
    if (year > 2019) {
        //2019以降
        cout << "TBD" << endl;
    }else if (year == 2019){
        //2019年
        if (month > 4) {
            //4月以降
            cout << "TBD" << endl;
        }else{
            //4月以前
            cout << "Heisei" << endl;
        }
        
    }else{
        cout << "Heisei" << endl;
    }
    
}


Measured memory_bytes: 256
"""
    Author : thekushalghosh
    Team   : CodeDiggers
"""
import sys,math,cmath,time
start_time = time.time()
################# ---- USER DEFINED INPUT FUNCTIONS ---- #################
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(s[:len(s) - 1])
def invr():
    return(map(int,input().split()))
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################
 
def solve():
  n = inp()
  if "7" in list(str(n)):
    print("Yes")
  else:
    print("No")
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
ONLINE_JUDGE = __debug__
if not ONLINE_JUDGE:
    sys.stdin = open('input.txt','r')
    sys.stdout = open('output.txt','w')
else:
    input = sys.stdin.readline
t = 1
for tt in range(t):
    solve()
if not ONLINE_JUDGE:
    print("Time Elapsed:",time.time() - start_time,"seconds")
sys.stdout.close()

Measured memory_bytes: 62520
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
int next[9][4] = {
  {0,1,0,3},
  {0,2,1,4},
  {1,2,2,5},
  {3,4,0,6},
  {3,5,1,7},
  {4,5,2,8},
  {6,7,3,6},
  {6,8,4,7},
  {7,8,5,8}
};
int n;
int s,t,b;
char s_,t_,b_;
int memo[20][10];
int dfs(int time,int place){
  if(memo[time][place]!=-1) return memo[time][place];
  if(time == n) return place == t;
  int ret = 0;
  REP(r,4){
    int nplace = next[place][r];
    if(nplace==b) nplace = place;
    ret += dfs(time+1, nplace);
  }
  return memo[time][place] = ret;
}
int main(){
  while(cin>>n,n){
    memset(memo,-1,sizeof(memo));
    cin>>s_>>t_>>b_;
    s = s_-'A';
    t = t_-'A';
    b = b_-'A';
    cout<<(double)dfs(0,s)/(1<<(2*n))<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
{-# LANGUAGE MultiWayIf #-}

import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Data.List
import Control.Monad
import Data.Ord

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine



main :: IO ()
main = do
    n <- (`mod` 10) <$> readLn
    putStrLn $ if
                | n `elem` [2,4,5,7,9] -> "hon"
                | n `elem` [0,1,6,8] -> "pon"
                | otherwise -> "bon"


Measured memory_bytes: 3924
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
	unsigned short *A,*B;
	
	int C[VMAX+1];
	int n,i,j;
	scanf("%d",&n);
	
	A=malloc(sizeof(short)*n+1);
	B=malloc(sizeof(short)*n+1);
	
	for(i=0;i<=VMAX;i++)C[i]=0;
	
	for(i=0;i<n;i++){
		scanf("%hu",&A[i+1]);
		C[A[i+1]]++;
	}
	
	for(i=1;i<=VMAX;i++)C[i]=C[i]+C[i-1];
	
	for(j=1;j<=n;j++){
		B[C[A[j]]]=A[j];
		C[A[j]]--;
	}
	
	for(i=1;i<=n;i++){
		if(i>1)printf(" ");
		printf("%d",B[i]);
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 9660