akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>
#include <queue>

using namespace std;
typedef long long int ll;

int main(){

    ll N, C , K;
    cin >> N >> C >> K;
    vector<ll > T(N, 0);
    for(ll i = 0; i < N; i++){
        cin >> T[i];  
    }
    sort(T.begin(), T.end());

    ll ans = 0;    

    for(ll i = 0; i < N;){
        ans++;
        ll s = i;
        //K分経つか, バスの上限乗客C人集まったら出発
        while(i < N && T[i] - T[s] <= K && i - s < C){
            i++;
        }
    }


    cout << ans << endl;


} 

Measured memory_bytes: 1024
#include<stdio.h>
#define M 40

int n,pos;
int a[M],b[M];

void solve(int, int);





int main(){
  int i;

  scanf("%d", &n);
  for( i = 0 ; i < n ; i++){
    scanf("%d", &a[i]);
  }
  for( i = 0 ; i < n ; i++){
    scanf("%d", &b[i]);
  }
  pos = 0;
  solve( 0, n-1);
  printf("\n");


  return 0;
}


void solve(int l, int r) {
	int x, i;




	x = a[pos];
	if (l > r) return;
	if (l == r) {
		if (b[l] == a[0]) printf("%d", b[l]);
		else printf("%d ", b[l]);
		pos++;




		return;
	}
	pos++;




	for (i = l; i <= r; i++) {
		if (b[i] == x) break;
	}
	solve(l, i - 1);
	solve(i + 1, r);




	if (x == a[0]) printf("%d", x);
	else printf("%d ", x);
}





Measured memory_bytes: 2096
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
using Graph = vector<vector<int>>;

int main() {
	int n;
	double v[50], sum = 0;
	cin >> n;
	rep(i, n) cin >> v[i];
	sort(v, v + n);
	sum = v[0];
	for(int i = 1; i < n; i++) {
		sum = (sum + v[i]) / 2;
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'

//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

using namespace std;
template<class T, class T2> inline int chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline int chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const int MAXN = (1 << 20);

int L;

void read()
{
	cin >> L;
}

vector<pair<int, pair<int, int> > > answer;

inline void add_edge(int u, int v, int w) { answer.push_back({u, {v, w}}); }

void solve()
{
	for(int i = 2; i <= 19; i++)
	{
		add_edge(i, i + 1, 0);
		add_edge(i, i + 1, 1 << (20 - i - 1));
	}

	int curr_len = 0;
	for(int i = 20; i >= 0; i--)
		if(L & (1 << i))
		{
			if(1 != 20 - i) add_edge(1, 20 - i, curr_len);
			else 
			{
				add_edge(1, 2, 1 << 18);
				add_edge(1, 2, 0);
			}

			curr_len += (1 << i);
		}

	cout << 20 << " " << answer.size() << endl;
	for(auto i: answer) cout << i.first << " " << i.second.first << " " << i.second.second << endl;
}

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

	read();
	solve();
	return 0;
}



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

int main()
{
  /*処理系*/
  long long A, B, N;
  cin >> N >> A >> B;
  long long c = N / (A + B);
  long long ans = c * A;
  long long d = N - (A + B) * c;
  if (d > A)
  {
    ans += A;
  }
  else
  {
    ans += d;
  }
  cout << ans;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 500'000;
const int LOGN = 19;

int n, m, k;

int t[N * 4];
string s;

void build(int v, int l, int r) {
  if (l + 1 == r) {
    t[v] = 1 << (s[l] - 'a');
  } else {
    int mid = (l + r) / 2;
    build(v * 2 + 1, l, mid);
    build(v * 2 + 2, mid, r);
    t[v] = t[v * 2 + 1] | t[v * 2 + 2];
  }
}

int get(int v, int l, int r, int ql, int qr) {
  if (l == ql && r == qr) {
    return t[v];
  }
  int mid = (l + r) / 2;
  if (qr <= mid) {
    return get(v * 2 + 1, l, mid, ql, qr);
  }
  if (ql >= mid) {
    return get(v * 2 + 2, mid, r, ql, qr);
  }
  return get(v * 2 + 1, l, mid, ql, mid) | get(v * 2 + 2, mid, r, mid, qr);
}

void update(int v, int l, int r, int pos, int val) {
  if (l + 1 == r) {
    t[v] = 1 << val;
  } else {
    int mid = (l + r) / 2;
    if (pos < mid) {
      update(v * 2 + 1, l, mid, pos, val);
    } else {
      update(v * 2 + 2, mid, r, pos, val);
    }
    t[v] = t[v * 2 + 1] | t[v * 2 + 2];
  }
}

void solve(int) {
  cin >> n >> s >> m;
  build(0, 0, n);
  for (int i = 0; i < m; ++i) {
    int t, x;
    cin >> t >> x;
    --x;
    if (t == 1) {
      char y;
      cin >> y;
      update(0, 0, n, x, y - 'a');
    } else {
      int y;
      cin >> y;
      cout << __builtin_popcount(get(0, 0, n, x, y)) << '\n';
    }
  }
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}



Measured memory_bytes: 7196
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define vii vector < pii >
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class P , class Q > ostream& operator<<(ostream& stream, pair < P , Q > v){ stream << "(" << v.fi << ',' << v.se << ")"; return stream;}
template < class T > ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream;}
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void) {
    int n;
    cin>>n;
    cout << (n - 2) * 180 << '\n';
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_C
{
    class C074
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int A = int.Parse(s[0]), B = int.Parse(s[1]), C = int.Parse(s[2]);
            int D = int.Parse(s[3]), E = int.Parse(s[4]), F = int.Parse(s[5]);

            double pmax = -1;
            int sw = 0, ss = 0;
            for (int i = 0; i <= 30; i++)
            {
                for (int j = 0; j <= 30; j++)
                {
                    if (i == 0 && j == 0) continue;
                    int w = 100 * (A * i + B * j);
                    int smax = Math.Min(E * w / 100, F - w);
                    //k:操作３の回数
                    for (int k = 0; k <= 3000; k++)
                    {
                        if (C * k > smax) continue;
                        //x:操作４の回数
                        int x = (smax - C * k) / D;
                        int sg = k * C + x * D;
                        double p = (double)sg / w;
                        if (p > pmax)
                        {
                            pmax = p;
                            sw = w + sg;
                            ss = sg;
                        }
                    }
                }
            }
            Console.WriteLine(sw + " " + ss);
        }

    }
}


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

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] a = new int[M + 1];
		long[] step = new long[N + 1];
		final long mod = 1000000007;
		for (int i = 0; i <= N; i++)
			step[i] = 1;

		for (int i = 1; i <= M; i++) {
			a[i] = sc.nextInt();
			step[a[i]] = 0;
		}

		for (int i = N; i >= 2; i--) {
			if (step[i - 2] == 0)
				continue;
			else
				step[i - 2] = step[i - 1] + step[i];
			step[i - 2] %= mod;
		}

		System.out.println(step[0]);
	}
}

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;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		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() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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


Measured memory_bytes: 24092
n, k = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n - 1)]

mod = 10 ** 9 + 7

from collections import defaultdict
g = defaultdict(set)
for a, b in ab:
    g[a-1].add(b-1)
    g[b-1].add(a-1)

ans = k
q = [0]
visited = set([0])

while q:
    cur = q.pop()

    if cur == 0:
        tmp = k - 1
    else:
        tmp = k - 2
    for target in g[cur]:
        if target not in visited:
            ans = (ans * tmp) % mod
            tmp -= 1

            q.append(target)
            visited.add(target)

print(ans)


Measured memory_bytes: 111320
#include<stdio.h>

int main(){
  int x,y,ns,nb,d;
  scanf("%d%d",&x,&y);
  if(x<y){
    ns=x;
    nb=y;
  }
  else if(y<x){
    ns=y;
    nb=x;
  }
  while(1){
    d=nb%ns;
    if(d==0) break;
    nb=ns;
    ns=d;
  }
  printf("%d\n",ns);
  return 0;
}


Measured memory_bytes: 2084
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s[3];
    cin >> s[0] >> s[1] >> s[2];
    int turn = 0;
    while(true) {
        if(s[turn].size() == 0) {
            cout << (char)(turn + 'A') << endl;
            return 0;
        }
        int prev_turn = turn;
        turn = s[turn].front() - 'a';
        s[prev_turn] = s[prev_turn].substr(1);
    }

    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

class Dice {
public:
    vector<int> eyes;
    Dice(vector<int> v) {
        eyes = v;
    }
    void rotate(char dist, bool rev);
    bool match(Dice dice);
};

void Dice::rotate(char dist, bool rev = false) {
    if (rev) {
        string s = "ENRLSW";
        dist = s[5 - s.find(dist)];
    }
    int temp;
    switch (dist) {
    case 'E':
        swap(eyes[0], eyes[3]);
        swap(eyes[3], eyes[5]);
        swap(eyes[5], eyes[2]);
        break;
    case 'W':
        swap(eyes[0], eyes[2]);
        swap(eyes[2], eyes[5]);
        swap(eyes[5], eyes[3]);
        break;
    case 'N':
        swap(eyes[0], eyes[1]);
        swap(eyes[1], eyes[5]);
        swap(eyes[5], eyes[4]);
        break;
    case 'S':
        swap(eyes[0], eyes[4]);
        swap(eyes[4], eyes[5]);
        swap(eyes[5], eyes[1]);
        break;
    case 'L':
        swap(eyes[1], eyes[2]);
        swap(eyes[2], eyes[4]);
        swap(eyes[4], eyes[3]);
        break;
    case 'R':
        swap(eyes[1], eyes[3]);
        swap(eyes[3], eyes[4]);
        swap(eyes[4], eyes[2]);
        break;
    }
}

bool Dice::match(Dice dice) {
    string rot = "RRRRERRRWRRRWRRRERRRERRR";
    for (int i = 0; i < rot.size(); i++) {
        dice.rotate(rot[i]);
        if (this->eyes == dice.eyes) {
            while (i >= 0) {
                dice.rotate(rot[i--], true);
            }
            return true;
        }
    }
    return false;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vi d1(6); for (int i = 0; i < 6; i++) cin >> d1[i];
    vi d2(6); for (int i = 0; i < 6; i++) cin >> d2[i];
    auto dice1 = Dice(d1), dice2 = Dice(d2);
    if (dice1.match(dice2)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3220
temp = list(map(int, input().split()))
X = temp[0]
N = temp[1]
if N > 0:
  num = list(map(int, input().split()))
  nums = [i for i in range(102) if i not in num]
  ans = 0
  for j in nums:
    if abs(j-X) < abs(ans-X):
      ans = j
  print(ans)
else:
  print(X)

Measured memory_bytes: 61976
#AGC003
s = input()

dicti = {'N':0, 'S':0, 'W':0, 'E':0}
for letter in s:
    dicti[letter] += 1
if dicti['N'] > 0 and dicti['S'] > 0:
    if dicti['W'] > 0 and dicti['E'] > 0:
        print('Yes')
    elif dicti['W'] == 0 and dicti['E'] == 0:
        print('Yes')
    else:
        print('No')
elif dicti['W'] > 0 and dicti['E'] > 0:
    if dicti['N'] > 0 and dicti['S'] > 0:
        print('Yes')
    elif dicti['N'] == 0 and dicti['S'] == 0:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f(z) for(int i=1;i<=z;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define vi vector<int>
#define pb push_back
#define si set<int>
#define mod  1000000007
#define cl(n,m) (n-1)/m  + 1 ;
#define T() int TT; cin>>TT; while(TT--)
#define P pair<int,int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

signed main(){
	int n; 
	cin>>n ;
	int p = sqrt(n) ;
	cout << p*p ;
}


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

int main(){

int N, cnt;
  cin >> N;
int ans = 0;
  
  for(int i = 105;i <= N;i=i+2){
    cnt = 0;
    for(int j = 1;j <= i;j++){      
    if(i % j == 0) cnt++;    
    }
    if(cnt > 7) ans++;
  }

  cout << ans << endl;  

return 0;
  
}

Measured memory_bytes: 256
# coding:utf-8

import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    a, b, c, k = LI()

    return b - a if k % 2 else a - b


print(main())


Measured memory_bytes: 3060
import java.util.Scanner;

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner as = new Scanner(System.in);
		
		int dice1[];
		int dice2[];
		int Pdice1[][];
		int Pdice2[][];
		int count = 0;
		int tr = 0;
		String str = "";
		String spn = "";
		Boolean breakp = null;
		
		dice1 = new int[6];
		dice2 = new int[6];
		Pdice1 = new int[6][6];
		Pdice2 = new int[6][6];
		
		for(int i=0;i<6;i++){
			
			dice1[i] = as.nextInt();
			
		}
		
		for(int i=0;i<6;i++){
			
			dice2[i] = as.nextInt();
			
		}
		
		for(int i=0;i<3;i++){
			
			
			
			switch (i){
			case 0:
				spn = "x";
				break;
				
			case 1:
				spn = "y";
				break;
				
			case 2:
				spn = "z";
				break;
				
			}
		
			breakp = Spin.Check(dice1, dice2, i);
			
			if(breakp == true){
				
				str = "Yes";
				break;
				
			}
			
			dice2 = Spin.diceSpin(dice2, "x");
			breakp = Spin.Check(dice1, dice2, i);
			
			if(breakp == true){
				
				str = "Yes";
				break;
				
			}
			
			dice2 = Spin.diceSpin(dice2, "x");
			dice2 = Spin.diceSpin(dice2, "x");
			breakp = Spin.Check(dice1, dice2, i);
			
			if(breakp == true){
				
				str = "Yes";
				break;
				
			}
			
			dice2 = Spin.diceSpin(dice2, "x");
			dice2 = Spin.diceSpin(dice2, "x");
			dice2 = Spin.diceSpin(dice2, "x");
			breakp = Spin.Check(dice1, dice2, i);
			
			if(breakp == true){
				
				str = "Yes";
				break;
				
			}
			
			str = "No";
		
		}
		
		System.out.println(str);

	}

}


class Spin{
	
	public static int[] diceSpin(int[] dice,String spn) {
		
	
		int tre = 0;
			
			
		switch (spn){
		case "x":
			tre = dice[4];
			dice[4] = dice[0];
			dice[0] = dice[1];
			dice[1] = dice[5];
			dice[5] = tre;
			break;
			
		case "y":
			tre = dice[3];
			dice[3] = dice[0];
			dice[0] = dice[2];
			dice[2] = dice[5];
			dice[5] = tre;
			break;
			
		case "z":
			tre = dice[2];
			dice[2] = dice[1];
			dice[1] = dice[3];
			dice[3] = dice[4];
			dice[4] = tre;
			break;
			
				
		}
			
		
			
		return dice;
		
		
		
	  }
	
	public static Boolean Samecheck(int[] dice1,int[] dice2){
		
		Boolean flag = null;
		
		for(int i=0;i<6;i++){
			
			if(dice1[i] != dice2[i]){
				
				flag = false;
				break;
			}
			else{
				
				flag = true;
				
			}
			
		}
		
		
		return flag;
		
	}
	
	public static Boolean Check(int[] dice1,int[] dice2,int sp){
		
		Boolean flag = null;
		String spn = null;
		
		switch (sp){
		case 0:
			spn = "x";
			break;
			
		case 1:
			spn = "y";
			break;
			
		case 2:
			spn = "z";
			break;
			
		}
		
		for(int j=0;j<4;j++){
			
			
			dice2 = Spin.diceSpin(dice2, spn);
			if(Spin.Samecheck(dice1, dice2)){
				
	
				flag = true;
				break;
			
			}
			flag = false;
			
		}
		
		
		return flag;
		
	}
	
	
	
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//end

ll mod=1e9+7;
struct Mint {
   ll val;
   ll inv() const{
      ll tmp,a=val,b=mod,x=1,y=0;
      while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
      if(x<0)x+=mod; return x;
   }
   Mint():val(0){}
   Mint(ll x):val(x>=0?x%mod:mod+(x%mod)){}
   Mint pow(ll t){Mint res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;}return res;}
   Mint& operator+=(const Mint& x){if((val+=x.val)>=mod)val-=mod;return *this;}
   Mint& operator-=(const Mint& x){if((val+=mod-x.val)>=mod)val-=mod; return *this;}
   Mint& operator*=(const Mint& x){val=val*x.val%mod; return *this;}
   Mint& operator/=(const Mint& x){val=val*x.inv()%mod; return *this;}
   Mint operator+(const Mint& x)const{return Mint(*this)+=x;}
   Mint operator-(const Mint& x)const{return Mint(*this)-=x;}
   Mint operator*(const Mint& x)const{return Mint(*this)*=x;}
   Mint operator/(const Mint& x)const{return Mint(*this)/=x;}
   bool operator==(const Mint& x)const{return val==x.val;}
   bool operator!=(const Mint& x)const{return val!=x.val;}
};
struct factorial {
   vector<Mint> Fact, Finv;
public:
   factorial(int maxx){
      Fact.resize(maxx+1),Finv.resize(maxx+1); Fact[0]=Mint(1); rep(i,0,maxx)Fact[i+1]=Fact[i]*(i+1);
      Finv[maxx]=Mint(1)/Fact[maxx]; rrep(i,maxx,0)Finv[i-1]=Finv[i]*i;
   }
   Mint fact(int n,bool inv=0){if(inv)return Finv[n];else return Fact[n];}
   Mint nPr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[n-r];}
   Mint nCr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[r]*Finv[n-r];}
};

map<int,Mint> dp[6020];
Mint inv[6020];

int main(){
   int n; scanf("%d%lld",&n,&mod);
   dp[0][0]=1;
   rep(i,1,3*n+1)dp[0][0]*=i,inv[i]=Mint(i).inv();
   rep(i,0,3*n)for(auto p:dp[i]){
      int j=p.first; Mint x=dp[i][j];
      rep(k,1,4)if(i+k<=3*n){
         int add=0; if(k==1)add=1; if(k==2)add=-1;
         dp[i+k][j+add]+=x*inv[i+k];
      }
   } Mint res=0;
   for(auto p:dp[3*n])if(p.first>=0)res+=p.second;
   printf("%d\n",res.val);
   return 0;
}

Measured memory_bytes: 563456
#include<iostream>
using namespace std;
int main()
{
  int max;
  int num1,num2;
  int calc1, calc2, calc3;
  cin >> num1;
  cin >> num2;

  calc1 = num1 + num2;
  calc2 = num1 - num2;
  calc3 = num1 * num2;
  
  max = calc1;
  if( max < calc2 ) {
    max = calc2;
  }
  if( max < calc3 ) {
    max = calc3;
  }
  
  cout << max;
  

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int a,hoge=0,ans=0;
  while(1){
    cin>>a;
    if(a==-1){
      break;
    }
    if(a<=10){
      hoge=1150;
      ans=4280-hoge;
    }else if(a>10&&a<=20){
      a=a-10;
      hoge=1150+a*125;
      ans=4280-hoge;
    }else if(a>20&&a<=30){
      a=a-20;
      hoge=1150+1250+a*140;
      ans=4280-hoge;
    }else if(a>30){
      a=a-30;
      hoge=1150+1250+1400+a*160;
      ans=4280-hoge;
    }
    cout<<ans<<'\n';
  }
  return 0;
}



Measured memory_bytes: 3128
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long h = sc.nextInt();
        long w = sc.nextInt();
        long ans = solve(h,w);
        System.out.println(ans);
    }
    public static long solve(long h,long w){
        long a = pattern1(h,w);
        long b = pattern2(h,w);
        long c = pattern3(h,w);
        long d = pattern4(h,w);
        return Math.min(a,Math.min(b,Math.min(c,d)));
    }
    public static long pattern1(long h,long w){
        long ans = Integer.MAX_VALUE;
        for(long i = 1;i <= h;i++){
            long sa = i*w;
            long ww = w/2;
            long sb = (h-i) * ww;
            long sc = (h-i) * (w-ww);
            long max = Math.max(sa,Math.max(sb,sc));
            long min = Math.min(sa,Math.min(sb,sc));
            ans = Math.min(ans,max-min);
        }
        return ans;
    }
    public static long pattern2(long h,long w){
        long ans = Integer.MAX_VALUE;
        for(long i = 1;i <= h;i++){
            long sa = i*w;
            long half = (h-i)/2;
            long sb = half * w;
            long sc = (h-i-half) * w;
            long max = Math.max(sa,Math.max(sb,sc));
            long min = Math.min(sa,Math.min(sb,sc));
            ans = Math.min(ans,max-min);
        }
        return ans;
    }
    public static long pattern3(long h,long w){
        long ans = Integer.MAX_VALUE;
        for(long i = 1;i <= w;i++){
            long sa = h*i;
            long hh = h/2;
            long sb = hh * (w-i);
            long sc = (h-hh) * (w-i);
            long max = Math.max(sa,Math.max(sb,sc));
            long min = Math.min(sa,Math.min(sb,sc));
            ans = Math.min(ans,max-min);
        }
        return ans;
    }
    public static long pattern4(long h,long w){
        long ans = Integer.MAX_VALUE;
        for(long i = 1;i <= w;i++){
            long sa = h*i;
            long half = (w-i)/2;
            long sb = h * half;
            long sc = h * (w-i-half);
            long max = Math.max(sa,Math.max(sb,sc));
            long min = Math.min(sa,Math.min(sb,sc));
            ans = Math.min(ans,max-min);
        }
        return ans;
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
using namespace std;
#define N 1000002
typedef long long ll;
int n,k,p;
int dp[302][302],C[302][302],s[302][302];
int main()
{
	scanf("%d%d%d",&n,&k,&p);
	for(int i=0;i<=300;i++)C[i][0]=1;
	for(int i=1;i<=300;i++)for(int j=1;j<=i;j++)C[i][j]=(C[i-1][j]+C[i-1][j-1])%p;
	for(int i=0;i<=k;i++)dp[1][i]=1;
	for(int i=k;~i;i--)s[1][i]=(s[1][i+1]+dp[1][i])%p;
	for(int i=2;i<=n+1;i++)
	{
		for(int j=0;j<=k;j++)for(int ii=1;ii<i;ii++)
		dp[i][j]=(dp[i][j]+1ll*s[ii][j+1]*dp[i-ii][j]%p*C[i-2][ii-1]%p)%p;
		for(int j=k;~j;j--)s[i][j]=(s[i][j+1]+dp[i][j])%p;
	}
	printf("%d\n",dp[n+1][0]);
}


Measured memory_bytes: 1280
h, w = map(int, input().split())
a = [[0 for i in range(w+2)] for j in range(h+2)]
for i in range(1, h+1):
  s = input()
  for j in range(1, w+1):
    if ord(s[j-1]) is 35:
      a[i][j] = 1

for i in range(1, h+1):
  for j in range(1, w+1):
    if a[i][j] is 1:
      if a[i-1][j] is 0 and a[i+1][j] is 0 and a[i][j-1] is 0 and a[i][j+1] is 0:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 3064
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

ll fac[maxn],inv[maxn],n,k;
const ll mod=1000000007;

inline ll F(ll x)
{
	ll p1=(2*n-x+1)*x/2,p2=(x-1)*x/2;
	return (p1-p2+1+mod)%mod;
}

int main()
{
	n=read(); k=read(); ll ans=0;
	for(int i=k;i<=n+1;i++) ans=(ans+F(i))%mod; cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3636
N,Y = map(int,input().split())

flg = False
for i in range(N+1):
    for j in range(N+1-i):
        k = N-i-j
        if Y == i*10000 + j*5000 + k*1000:
            print(i,j,N-i-j)
            exit()

print(-1,-1,-1)

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

const int maxn = 1e5+5;
long long m,n,s=0,cnt=0;
long long a[maxn];
int main(){
	cin >> n >> m;
	for (long long i=1;i<=n;i++){
		cin >> a[i];
		s += a[i];	
	}
	for (long long i=1;i<=n;i++){
		if (a[i]*4*m >= s) cnt++;
	}
	cout << (cnt>=m? "Yes":"No");
	return 0;
}

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

int main() {
    std::cout<<std::fixed<<std::setprecision(10);
    
    int N, K; cin >> N >> K;
    int ans = 0;
    // vector<int> h(N);
    int h;
    rep(i, N) {
        cin >> h;
        if (h >= K) {
            ans += 1;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

      ll a,b,c;
      cin>>a>>b;


      for(int i=min(a,b);i<=max(a,b);i++)
      {
          ll k=a*b*i;
          if(k&1)
          {
              cout<<"Yes\n";
              return 0;

          }


      }

    cout<<"No\n";


return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());


int main(){
	int x,y,z;
	int a,b,c;
	int ans1=0,ans2=0,ans3=0;
	while(cin>>x>>y>>z){
		a=max(max(x,y),z);
		b=min(min(x,y),z);
		c=x+y+z-a-b;
		// cout<<a<<" "<<b<<" "<<c<<endl;
		if(a>=b+c){
			cout<<ans1+ans2+ans3<<" "<<ans1<<" "<<ans2<<" "<<ans3<<endl;
			return 0;
		}
		else{
			if(a*a==b*b+c*c){
				ans1++;
			}
			else if(a*a<b*b+c*c){
				ans2++;
			}
			else{
				ans3++;
			}
		}
	}
}

Measured memory_bytes: 1168
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000000
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str,str2;
    cin>>n>>d;
    vector<ll> v(n);
    rep(i,n) cin>>v[i];
    b=0;
    c=0;
    while(1){

        if(v[b]==c){ 
            b++;
            a=d;
        }
        c++;

                if(a>0) {sum++;
                 //   cout<<c<<" ";

        }
                a--;

        if(v[b]==*v.end()&&a==0) break; 
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<queue>

using namespace std;

#define MAXN 130
char s[MAXN];

int main()
{
    scanf("%s",s);
    int len=strlen(s);
    for(int i=0;i<len;i++)
        if(s[i]==',')
            printf(" ");
        else
            printf("%c",s[i]);
    printf("\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>

namespace myspace{
	
	class vector{
	public:
		void push_back(int);
		int size();
		int &operator[](int);
		vector();
		vector(const vector&);
		~vector();
	private:
		int s;
		int* box;
	};
	
	vector::vector()
	{
		box = NULL;
		s = 0;
	}
	
	vector::vector(const vector &X)
	{
		s = X.s;
		box = new int[X.s];
		for(int i=0; i<X.s; i++)box[i] = X.box[i];
	}
	
	vector::~vector()
	{
		if(box)delete[] box;
	}
	
	int &vector::operator[](int i)
	{
		return box[i];
	}
	
	int vector::size()
	{
		return s;
	}
	
	void vector::push_back(int input)
	{
		int* box2 = box;
		box = new int[s+1];
		for(int i=0; i<s; i++)box[i] = box2[i];
			
		box[s] = input;
		s++;
	}
}//??????????????????myspac

using namespace myspace;
using namespace std;

void Output(vector A)
{
    int i;
    for(i=0;i<A.size()-1;i++){
        cout << A[i] << " ";
    }
    cout << A[i] << endl;
}
 
void InsertionSort(vector A,int n)
{
    for(int i=0;i<n;i++)
    {
        int v = A[i];
        int j = i - 1;
        while(j>=0 && A[j]>v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        Output(A);
    }
}
 
int main()
{   
    int n;
    cin >> n;
     
    vector A;
	for(int i=0;i<n;i++){
		int a;
		cin >> a;
		A.push_back(a);
	}
    InsertionSort(A, n);
     
    return 0;
}

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

int main() {
	int n; cin >> n;
	while(n--) {
		int x; cin >> x;
		if(x & 1) continue;
		if((x % 3) && (x % 5)) return cout << "DENIED", 0;
	}
	cout << "APPROVED";
}


Measured memory_bytes: 256
import math
n,d,a=map(int,input().split())
XH=[[int(i)for i in input().split()] for _ in range(n)]
XH.sort(key=lambda x:x[0])
ans=0
l=0
before=0
T=[0]*n
for i,xh in enumerate(XH):
    x,h=xh
    while XH[l][0]+2*d<x:
        before-=T[l]
        l+=1
    h-=before*a
    if h<=0:
        continue
    T[i]=math.ceil(h/a)
    ans+=T[i]
    before+=T[i]
print(ans)

Measured memory_bytes: 47264
#include <iostream>
#include <math.h>

using namespace std;

int main(){
    double a,b,c,n;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> n;
    if(a >= b && a >= c)
        cout << (int)pow(2,n)*a+b+c << endl;
    else if(b > a && b > c)
        cout << (int)pow(2,n)*b+a+c << endl;
    else
        cout << (int)pow(2,n)*c+a+b << endl;
    
    return 0;
    
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

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

int main(void){
	int n,number,a[100001]={},max=0;
	
	cin>>n;
	REP(i,n){
		cin>>number;
		a[number]++;
	}

	FOR(i,1,100000) chmax(max,a[i-1]+a[i]+a[i+1]);
	
	cout<<max<<endl;
	return 0;
}



Measured memory_bytes: 640
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"input();a=s=0;d={0:1}\n"
"for i in input().split():s+=int(i);t=d.get(s,0);a+=t;d[s]=t+1\n"
"print(a)\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 45788
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

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


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

	string s; cin >> s;
	if (s.size() & 1) {
		if (s[0] == s.back()) cout << "Second" << endl;
		else cout << "First" << endl;
	}
	else {
	  if (s[0] == s.back()) cout << "First" << endl;
		else cout << "Second" << endl;
	}
}

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

void swap(int &a,int &b)
{
    if(b<a)
    {
        int i;
        i=a;
        a=b;
        b=i;
    }
}

int SelectSort(int n,int *p)
{
    int num=0,mini;
    for(int i=0;i<n-1;i++)
    {
        mini=i;
        for(int j=i+1;j<n;j++)
        {
            if(*(p+j)<*(p+mini))
            {
               mini=j;
            }
            
        }
        if(mini!=i)
        {
            swap(*(p+i),*(p+mini));
            num++;
        }
    }
    return num;
}

int main(int argc, char const *argv[])
{
    int N,*p,num;
    cin>>N;
    p=new int[N];
    for(int i=0;i<N;i++)    cin>>*(p+i);
    num=SelectSort(N,p);

    for(int i=0;i<N-1;i++)  cout<<*(p+i)<<" ";
    cout<<*(p+N-1)<<endl<<num<<endl;

    delete []p;
    //system("pause");
    return 0;
}



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

int main() {
  string S;
  cin >> S;
  int zero = 0;
  int one = 0;
  for (int i = 0; i < S.size(); i++) {
    if ( i % 2 == 0 ) {
      if (S.at(i) == '0') {
        zero ++;
      }
     else  if (S.at(i) == '1') {
        one ++;
      }
    }
    if ( i % 2 == 1 ) {
      if (S.at(i) == '0') {
        one ++;
      }
     else  if (S.at(i) == '1') {
       zero ++;
      }
    }
   }
   cout << min ( zero,one) << endl;
}


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

int main() {
  int N;
  int answer = 0;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++){
    cin >> d.at(i);
  }

for(int i = 0; i < N-1; i++){
  for(int j = 0; j < N-i-1; j++){
  answer += d.at(i) * d.at((j+1)+i);
  }
}

cout << answer;

}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int[] ABC=new int[3];
    for(int i=0;i<3;i++){
      ABC[i]=sc.nextInt();
    }
    Arrays.sort(ABC);
    boolean flg=false;
    if(ABC[0]==5){
      if(ABC[1]==5){
        if(ABC[2]==7){
          flg=true;
        }
      }
    }
    if(flg){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 20948
N,M,C = map(int,input().split())
weight = list(map(int,input().split()))
ans = 0
for i in range(N):
  feature = list(map(int,input().split()))
  feature = [f*w for f,w in zip(feature,weight)]
  if (sum(feature) + C) > 0:
    ans += 1
print(ans)

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

dp = [-1]*(n+1)
dp[0] = 1
dp[1] = 1
for i in a:
    dp[i] = 0

for i in range(2, n+1):
    if dp[i] == 0:
        pass
    else:
        dp[i] = dp[i-1] + dp[i-2]
    
print(dp[n]%(10**9+7))

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

int main() {
  int N;
  cin >> N;
  int ans = 1;
  int bi2[] = {1, 2, 4, 8, 16, 32, 64};
  for (int i = 0; i < 7; i++) {
    if (N >= bi2[i]) ans = bi2[i];
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int N = Integer.parseInt(sc.next());
        
        int[] a = new int[N];
        for(int i=0; i<N; i++){
            a[i] = Integer.parseInt(sc.next());
        }
        
        int ans = 0;
        while(true){
            boolean flag = false;
            for(int i=0; i<N; i++){
                if(a[i] % 2 != 0){
                    flag = true;
                    break;
                }
                a[i] /=2;
            }
            
            if(flag){
                break;
            }else{
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
//前置き
#pragma region

#include<stdio.h>
#include<iostream>
#include<cstdio>
#include <cstring>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>

using namespace std;

typedef  long long ll;

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)

#pragma end
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};

//関数定義
#pragma region 
//偶数 ->　true :: 奇数　-> false
bool EVEN(ll a){
    return a%2-1;
}

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

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

#pragma endregion

int dore(int a,int b,int c){
    
    if(a == max(a,max(b,c))) return 1;
    if(b == max(a,max(b,c))) return 2;
    if(c == max(a,max(b,c))) return 3;
}
int main(){
    int n,m;
    cin >> n >>m;

    vector<pair<int,int>> v(m);

    REP(i,m){
        cin >> v[i].second >> v[i].first;
    }
    sort(v.begin(),v.end());

    int ans = 1, tmp = v[0].first;

    REP(i,m){
        if(tmp<=v[i].second){
            tmp = v[i].first;
            ans ++;
        }
    }
    cout << ans <<endl;
}




Measured memory_bytes: 1024
# ABC_list = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
ABC_list = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')

n = input()
n = int(n)
s = input()

# 入力された文字列をリスト化
sList = list(s)

ans = ''

for i in range(len(sList)):
    # 1. 入力された文字列に相当するABC_listの要素番号をもらう
    ansnum = ABC_list.index(sList[i])
    # 2. ユーザから受けた数値を足しこむ
    ansnum = ansnum + n
    # はみ出た分は先頭に戻す
    if 25 < ansnum:
        ansnum = ansnum - 26
    # 3. 足しこまれた要素番号に対応する要素が答えになる
    temp = ABC_list[ansnum]
    # 4. リストに追加
    ans += temp

print(ans)

Measured memory_bytes: 3064
import java.io.*;
import java.util.StringTokenizer;
import java.util.Arrays;

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String buf;

		try {
			int n = 10000000;
			boolean list[] = new boolean[n+1];
			for (int i=2;i<=n;i++) list[i] = true;
			for (int i=2;i<=n;i++) {
				for (int j=2;i*j<=n;j++) {
					list[i*j] = false;
				}
			}

			while (!(buf = br.readLine()).equals("0")) {
				int N = Integer.parseInt(buf);
				if (N%2==0) N--;
				for (int i=N;i>=13;i-=2) {
					if (list[i]&&list[i-2]&&list[i-6]&&list[i-8]) {
						System.out.println(i);
						break;
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 35808
// JOI 2016 Q3 Refreshment Area - C++

#include <iostream>
using namespace std;

int main()
{

	int N, M, D, pos, ans = 0, cnt = 0;
	char MAP[101][101];

	// ??±?\??????????????????°??¨?????????????????????????????°??\???
	cin >> N >> M >> D;

	// ???????????\???
	for(int i = 0; i < N; i++) cin >> MAP[i];

	// ??¢?´¢????§?
	for(int i = 0; i < N; i++) {
		for(int j = 0; j < M; j++) {
			// ??????????¨??????????????????\??????????????????????????????????????´??????
			// ??¢?´¢???????????????????????????
			if(D <= M) {
				// ??¢?´¢????§????????????\??????
				pos = j;
				// ??±(???)???????????¢?´¢?????????????????????????????????????§?????????????
				// ????????????(#)??????????????????????????????????????????????????´?????????
				// break
				for(cnt = 0; cnt < D; cnt++) {
					if(MAP[i][pos] == '#' || pos >= M) break;
					pos++;
				}
				// ??????????????????????§?????????§????????°????????????
				if(cnt == D) ans++;
			}
			// ?????£????????????????????????
			if(D <= N) {
				pos = i;
				for(cnt = 0; cnt < D; cnt++) {
					if(MAP[pos][j] == '#' || pos >= N) break;
					pos++;
				}
				if(cnt == D) ans++;
			}
		}
	}

	// ???????????????????????°?????????
	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 3096
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<stdio.h>
#include<algorithm>
using namespace std;

typedef long long ll;
int p[100010],n,m;
int A[100010],B[100010];
ll ans[100010],size[100100];

int find_set(int x){
	if(x==p[x])
		return x;
	return p[x]=find_set(p[x]);
}

int main(){
	cin>>n>>m;
	ans[m]=(ll)n*(n-1)/2;
	for(int i=1;i<=n;i++)
		p[i]=i,size[i]=1;
	for(int i=1;i<=m;i++)
		cin>>A[i]>>B[i];
	for(int i=m;i>=1;i--){
		int pa=find_set(A[i]);
		int pb=find_set(B[i]);
		if(pa==pb)
			ans[i-1]=ans[i];
		else{
			ans[i-1]=ans[i]-size[pa]*size[pb];
			size[pa]+=size[pb];
			p[pb]=pa;
		}
	}
	for(int i=1;i<=m;i++)
		cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 4096
num = int(input())
A = list(map(int, input().split()))
cost = 100 ** 100
tmp = 0
for x1 in range(-100, 101):
    for x2 in range(num):
        tmp += (A[x2] - x1) ** 2
    cost = min(tmp, cost)
    tmp = 0
print(cost)

Measured memory_bytes: 3060
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf_int = 1e9 + 100;
const ll inf_ll = 1e18;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double dbl;
#define pb push_back
const double pi = 3.1415926535898;
#define dout if(debug) cout
#define fi first
#define se second
#define sp setprecision
#define sz(a) (int(a.size()))
#define all(a) a.begin(),a.end()
bool debug = 0;
const int MAXN = 2e5 + 100;
const int LOG = 25;
const int mod = 998244353;
const int MX = 2e6 + 100;
typedef long long li;
const li MOD = 1000000000949747713ll;

ll my_sqrt(ll x) {
    ll val = sqrt(x);
    while ((val + 1) * (val + 1) <= x) {
        val++;
    }
    return val;
}

ll XMX = 1e9;

ll area(ll x1, ll y1, ll x2, ll y2,ll x3,ll y3) {
    return (x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1);
}
ll s;
void print(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3) {
    assert(x1>=0 && x1<=XMX);
    assert(x2>=0 && x2<=XMX);
    assert(x3>=0 && x3<=XMX);

    assert(y1>=0 && y1<=XMX);
    assert(y2>=0 && y2<=XMX);
    assert(y3>=0 && y3<=XMX);

    assert(area(x1,y1,x2,y2,x3,y3) == s);
    
    cout <<x1 << " "<<y1 <<" "<<x2<<" "<<y2<<" "<<x3<<" "<<y3<<endl;
}

void solve() {
    cin >> s;

    ll x1 = 0;
    ll y1 = 0;

    ll sqr = my_sqrt(s);


    ll x3 = 1;
    ll y2 = 0;
    ll x2 = sqr;
    ll y3 = sqr;

    if (x2 * y3 == s) {
        print(x1,y1,x2,y2,x3,y3);
        return;
    }

    if ((x2 + 1) * y3 >= s) {
        x2++;
        y2 = (x2) * y3 - s;
        print(x1,y1,x2,y2,x3,y3);
        return;
    }
    dout <<"HERE "<<endl;
    x2++;
    y3++;
    y2 = x2 * y3 - s;
    print(x1,y1,x2,y2,x3,y3);
}

signed main() {
#ifdef zxc
    debug = 1;
    freopen("../input.txt", "r", stdin);
    //freopen("../output.txt", "w", stdout);
#else

#endif //zxc
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.precision(20);

    int t = 1;
    while (t--)
        solve();
    if (debug)
        cerr << endl << "time : " << (1.0 * clock() / CLOCKS_PER_SEC) << endl;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in(),M=in();
	map<int,int> X;
	REP(i,M){
		X[in()]++;
		X[in()]++;
	}
	for(auto& x:X){
		if(x.second%2){
			out("NO");
			return 0;
		}
	}
	out("YES");
	return 0;
}


Measured memory_bytes: 4352