akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

const int inf = 1000000007;
// const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
const ll MOD = 998244353;

ll N, S;
ll A[3030];
ll dp[3030][3030][3];

int main() {
  cin >> N >> S;
  rep(i, 0, N) { cin >> A[i]; }

  dp[0][0][0] = 1;
  for (ll i = 0; i <= N - 1; i++) {
    for (ll j = 0; j <= S; j++) {
      dp[i + 1][j][0] += dp[i][j][0];
      dp[i + 1][j][0] %= MOD;
      if (j + A[i] <= S) {
        dp[i + 1][j + A[i]][1] += dp[i][j][0] * (i + 1) % MOD;
        dp[i + 1][j + A[i]][1] %= MOD;
        dp[i + 1][j + A[i]][2] += dp[i][j][0] * (i + 1) % MOD * (N - i) % MOD;
        dp[i + 1][j + A[i]][2] %= MOD;
      }

      dp[i + 1][j][1] += dp[i][j][1];
      dp[i + 1][j][1] %= MOD;
      if (j + A[i] <= S) {
        dp[i + 1][j + A[i]][1] += dp[i][j][1];
        dp[i + 1][j + A[i]][1] %= MOD;
        dp[i + 1][j + A[i]][2] += dp[i][j][1] * (N - i) % MOD;
        dp[i + 1][j + A[i]][2] %= MOD;
      }

      dp[i + 1][j][2] += dp[i][j][2];
      dp[i + 1][j][2] %= MOD;
    }
  }

  cout << dp[N][S][2] << endl;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { cout << p.first << ' ' << p.second; return os; }

void solve() {
  int H, W; cin >> H >> W;
  int N; cin >> N;
  vi32 a(N); cin >> a;

  vector<vi32> ans(H, vi32(W));

  int now = 0, cnt = 0;
  auto color = [&](int x, int y) {
    cnt++;
    if (cnt > a[now]) now++, cnt = 1;
    ans[x][y] = now + 1;
  };

  rep(i, H) {
    if (i % 2 == 0) {
      rep(j, W) color(i, j);
    } else {
      rrep(j, W) color(i, j);
    }
  }

  rep(i, H) cout << ans[i] << '\n';
}


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

//#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main(){
    int n; cin >> n;
    vector<int> a(n);
    int two[] = {0,0,0};
    rep(i,n){
        int a; cin >> a;
        if(a % 2 == 1){
            two[0]++;
        }else{
            a /= 2;
            two[!(a % 2)+1]++;
        }
    }
    
    if(two[0] == 0){
        cout << "Yes" << endl;
    }else{
        int bad_adjacent = two[0]-1 + !!two[1];
        cout << (bad_adjacent > two[2] ? "No" : "Yes") << endl;
    }
}

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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int X = int.Parse(Console.ReadLine());

            int q = X / 100;
            int r = X % 100;

            int a = r / 5;
            int b = r % 5;

            int ans = 0;
            if (b == 0) {
                if (a <= q) {
                    ans = 1;
                }
            } else {
                if (a + 1 <= q) {
                    ans = 1;
                }
            }

            Console.WriteLine(ans);
            
        }
    }
}


Measured memory_bytes: 13140
#include <stdio.h>

int main () {
	
	int a,b;
	
	scanf ("%d %d", &a, &b);
	
		if (b%a == 0)
		{
			printf ("%d", a+b);
			return 0;
		}
	
		else
		{
		printf ("%d", b-a);
		}
	
	return 0;
}

Measured memory_bytes: 1720
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 2e5 + 10;

vector<int> g[N];

void bipartition(int u, int p, vector<vector<int>>& bipartitions, int id);

int main() {
	fast_cin();
	int n; cin >> n;
	for (int i = 1; i < n; ++i) {
		int u, v;
		cin >> u >> v;
		g[u].pb(v);
		g[v].pb(u);
	}
	vector<vector<int>> numbers(3);
	for (int i = 1; i <= n; ++i) {
		numbers[i % 3].pb(i);
	}
	vector<vector<int>> bipartitions(2);
	bipartition(1, 0, bipartitions, 0);
	if (bipartitions[0].size() >= bipartitions[1].size()) {
		swap(bipartitions[0], bipartitions[1]);
	}
	vector<int> p(n + 1);
	if (bipartitions[0].size() >= numbers[1].size() and bipartitions[1].size() >= numbers[2].size()) {
		for (int i = 0; i < 2; ++i) {
			for (auto& u : bipartitions[i]) {
				if (!numbers[i + 1].empty()) {
					p[u] = numbers[i + 1].back();
					numbers[i + 1].pop_back();
				} else {
					p[u] = numbers[0].back();
					numbers[0].pop_back();
				}
			}
		}
	} else {
		for (int i = 0; i < 2; ++i) {
			for (auto& u : bipartitions[i]) {
				for (int j = 0; j < 3; ++j) {
					if (!numbers[j].empty()) {
						p[u] = numbers[j].back();
						numbers[j].pop_back();
						break;
					}
				}
			}
		}
	}
	for (int i = 1; i <= n; ++i) {
		cout << p[i] << ' ';
	}
	cout << endl;
}

void bipartition(int u, int p, vector<vector<int>>& bipartitions, int id) {
	bipartitions[id].pb(u);
	for (auto& v : g[u]) {
		if (v != p) {
			bipartition(v, u, bipartitions, id ^ 1);
		}
	}
}

Measured memory_bytes: 22296
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define INF 1 << 21

int main(){
    int n, costP, costT, calP, calT;
    cin >>n >>costP >>costT >>calP;
    vector<int> vec;
    for(int i = 0; i < n; i++){
        cin >>calT;
        vec.push_back(calT);
    }
    sort(vec.begin(), vec.end(), greater<int>());
    int sumT = 0;
    double ans = 0;
    for(int i = 0; i < vec.size(); i++){
        double ansN = ((calP + sumT + vec[i]) / (costP + costT * (i + 1) * 1.0));
        if(ansN < ans) break;
        sumT += vec[i];
        ans = ansN;
    }
    cout <<(int)ans <<endl;
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int max_time(int num){
	return (num + 9) / 10 * 10;
}

int re_max_time(int num){
	return max_time(num) - num;
}

int main() {
	int a,b,c,d,e;
	cin >> a >> b >> c >> d >> e;

	int sum_time = (max_time(a)+max_time(b)+max_time(c)+max_time(d)+max_time(e));
	sum_time -= max({re_max_time(a), re_max_time(b), re_max_time(c), re_max_time(d), re_max_time(e)});

	cout << sum_time << endl;
	return 0;
}


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

public class Main {
	/*??¶?´???????????????????*/
	public static void judge(int parse[]){
			if(parse[0]<=0||parse[0]>100){
				System.out.println("W?????\?????????1~100??\???????????§???.???????????????.");
				System.exit(0);
		}
			else if(parse[1]<=0||parse[1]>100){
				System.out.println("H?????\?????????1~100??\???????????§???.???????????????.");
				System.exit(0);
	    }
			else if(parse[2]<-100||parse[2]>100){
				System.out.println("x?????\?????????-100~100??\???????????§???.???????????????.");
				System.exit(0);
			}
			else if(parse[3]<-100||parse[3]>100){
				System.out.println("y?????\?????????-100~100??\???????????§???.???????????????.");
				System.exit(0);
			}
			else if(parse[4]<=0||parse[4]>100){
				System.out.println("r?????\?????????1~100??\???????????§???.???????????????.");
				System.exit(0);
			}
	}
	 public static void main(String[] args) throws IOException{
		int W,H,x,y,r;
		String str;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		str = br.readLine();

		String[] st = str.split(" ");
		/*for(int i=0;i<st.length;i++){
		 System.out.println("st["+i+"]="+st[i]); //?????????????´??¢????
		 }*/
		int len=st.length; //?????????????´???°
		int parse[] = new int[len]; //String???int????????¨??????

		for(int p=0;p<len;p++){
			parse[p]=Integer.parseInt(st[p]); //String???int??????
		}

		W=parse[0]; H=parse[1]; x=parse[2]; y=parse[3]; r=parse[4];

		judge(parse); //??¶?????????.????????????????????°????????????
		/*??????????????§????????¨?°???????????????\????????????????????\??????????????????????????????*/

		/*for(int i=0;i<st.length;i++){
		 System.out.println("st["+i+"]="+st[i]); //?????????????´??¢????
		 }*/

		/*????????¨????????????*/

		if((x-r<0||x+r>W)||(y-r<0||y+r>H))
			System.out.println("No");
		else if((x-r>=0&&x+r<=W)&&(y-r>=0&&y+r<=H))
			System.out.println("Yes");

	}

}

Measured memory_bytes: 24344
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

void print(vvi &c, vs &s, int p,int d){
    string dot(d,'.');
    cout<<dot<<s[p]<<endl;
    for(auto i:c[p]){
        print(c,s,i,d+1);
    }
}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int n;
	cin>>n;
	vector<vi> c(n);
	vector<string> s(n);
	rep(i,n){
	    int p; string q;
	    cin>>p>>q;
	    s[i]=q;
	    if(p!=0)
            c[p-1].push_back(i);
	}
	print(c,s,0,0);
	return 0;
}



Measured memory_bytes: 3896
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD7 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    int max_n = max({A, B, C});
    int min_n = min({A, B, C});
    int mid_n = A + B + C - max_n - min_n;
    int count = 0;
    while(mid_n != max_n){
        mid_n++;
        min_n++;
        count++;
    }
    while(min_n < max_n){
        min_n+=2;
        count++;
    }
    if(min_n == max_n + 1) cout << count + 1 << endl;
    else cout << count << endl;
}

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

bool issame(char a,char b){
     if(a=='(')return b==')';
     if(a=='[')return b==']';
}

int main(){
     while(1){
	  char in;
	  in=cin.peek();
	  //cout<<in;
	  if(in=='.')return 0;
	  stack<char> sta;
	  bool iscorrect=true;
 
	  while(cin.get(in),in!='.'){
	       if(cin.eof())return 0;
	       if(in=='('||in=='['){
		    sta.push(in);
	       }else if(in==')'||in==']'){
		    if(sta.empty()||!issame(sta.top(),in)){
			 iscorrect=false;
			 break;
		    }
		    sta.pop();
	       }
	  }
	  cout<<((iscorrect&&sta.empty())? "yes":"no")<<endl;
	  cin.ignore(100,'\n');
     }
}

Measured memory_bytes: 888
import sys
import bisect


def slove():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    a.sort()
    cnt = 0
    for i in range(n-2):
        for j in range(i + 1, n-1):
            p = bisect.bisect_left(a, a[i] + a[j])
            cnt += (p - j - 1)
    print(cnt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 42204
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
    int b = s.nextInt();
    int c = s.nextInt();
    if (a < b && b < c)
      System.out.println("Yes");
    else
      System.out.println("No");
	}
}



Measured memory_bytes: 26268
a,b,c,d = map(int,input().split())

cnt = 0
while (a > 0 and c > 0):
    if cnt % 2 == 0:
        c = c - b
    else:
        a = a - d
    cnt += 1

if c <= 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9180
fn main() {
    let s = read_line();
    let s = read_num_vec(s, 2);
    let n = s.get(0).unwrap().to_owned();
    let k = s.get(1).unwrap().to_owned();

    println!("{}", std::cmp::min(n % k, (n % k - k).abs()));
}

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_right().to_owned()
}

fn read_num_vec(s: String, length: usize) -> Vec<i64> {
    let mut ws = s.split_whitespace();
    let mut result = vec![];
    for _ in 0..length {
        result.push(ws.next().unwrap().parse().unwrap());
    }
    result
}


Measured memory_bytes: 4352
{
  const main = (input: string) => {
    const r = reader(input)
    const a = r.n()
    const b = r.s()

    console.log(a < 3200 ? 'red' : b)
  }

  // const values = obj => Object.keys(obj).map(e => obj[e]);

  const reader = (str: string) => {
    const lines = str.trim().split('\n')
    const s = () => lines.shift() || ''
    const line = s
    const n = () => Number(s())

    const ss = () => s().split(' ')
    const ns = () => ss().map(Number)
    return { lines, line, s, n, ss, ns }
  }

  main(require('fs').readFileSync('/dev/stdin', 'utf8'))
}


Measured memory_bytes: 7372
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define LIM 1000007
#define ll long long
using namespace std;
int main() {
  bool v[1000];
  for (int i = 0; i < 1000; i++) {
    v[i] = false;
  }
  string s;
  cin >> s;
  for (auto c : s) {
    v[(int)c] = !v[(int)c];
  }
  for (int i = 0; i < 1000; i++) {
    if (v[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int a,b; cin>>a>>b;
  int ans = 0;
  if(b==1) return cout<<ans<<endl, 0;
  ans = 1;
  int cnt = a;
  while(cnt<b){
    cnt += a-1; ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a, b, c, i;
	int syou, amari, kosuu = 0;
	scanf("%d %d %d", &a, &b, &c);
	for (int i = a; i <= b; i = i + 1){
		syou = c / i;
		amari = c%i;
		if (amari == 0){
			kosuu = kosuu + 1;
		}
		else;

	}
	printf("%d\n", kosuu);
	return 0;
}

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

using namespace std;

/**/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define wt(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define wt(x...)
#endif
/**/

#define LL long long
const int MAXN = 212345;
const int INF  = 0x3f3f3f3f;



int main () {

	ios_base::sync_with_stdio(false);  cin.tie(NULL); 

	int n; cin >> n; 
	std::vector<int> v(n);
	for (int &x : v) cin >> x;

	int cnt = 0;
	for (int i = 1; i < n - 1; ++i) {
		if (v[i] < v[i + 1] && v[i] > v[i - 1]) ++cnt;
		else if (v[i] > v[i + 1] && v[i] < v[i - 1]) ++cnt;
	}	

	cout << cnt << '\n';


	return 0;
}



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

int main() {
	int a, b=0, c=0;
	array<int, 10> number = { 0 };
	for (a = 0; a <= 2; a++) {
		cin >> number[a];
		if (number[a] == 5) {
			b++;
		}
		else if (number[a] == 7) {
			c++;
		}
	}
	if (b == 2 && c == 1) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
	return 0;
}



Measured memory_bytes: 256
m, n = [int(_) for _ in raw_input().split()]
MOD = 1000000007

# print pow(m, n, MOD)


ans = 1
r = m
while n:
    if n & 1:
        ans = (ans * r) % MOD
    r = (r * r) % MOD
    n >>= 1

print ans

Measured memory_bytes: 6372
#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;

int main() {
    int a, b, c;
    unsigned long long k;
    scanf("%d %d %d %llu", &a, &b, &c, &k);
    int arr[2][3];
    arr[0][0] = b + c;
    arr[0][1] = a + c;
    arr[0][2] = a + b;
    arr[1][0] = arr[0][1] + arr[0][2];
    arr[1][1] = arr[0][0] + arr[0][2];
    arr[1][2] = arr[0][0] + arr[0][1];
    if (k % 2 == 1) {
        unsigned long long ab = abs(arr[0][0] - arr[0][1]);
        if (ab > 1e18) {
            printf("Unfair\n");
        } else {
            printf("%d\n", arr[0][0] - arr[0][1]);
        }
    } else {
        unsigned long long ab = abs(arr[1][0] - arr[1][1]);
        if (ab > 1e18) {
            printf("Unfair\n");
        } else {
            printf("%d\n", arr[1][0] - arr[1][1]);
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

char s[10][10];
bool used[10][10];
int dx[]{ 1,0}, dy[]{ 0,1 };
int h, w;

int main() {
	scanf("%d%d", &h, &w);
	rep(i, h)scanf("%s", s[i]);
	int px = 0, py = 0;
	used[0][0] = true;
	while (px != h - 1 || py != w - 1) {
		bool flag = false;
		int xx = -1, yy = -1;
		rep(i, 2) {
			int nx = px + dx[i], ny = py + dy[i];
			if (0 <= nx&&nx < h && 0 <= ny&&ny < w&&s[nx][ny] == '#') {
				if (flag) {
					puts("Impossible"); return 0;
				}
				used[nx][ny] = true;
				flag = true;
				xx = nx, yy = ny;
			}
		}
		if (!~xx || !~yy) {
			puts("Impossible"); return 0;
		}
		px = xx, py = yy;
	}
	rep(i, h)rep(j, w) {
		if (s[i][j] == '#' && !used[i][j]) {
			puts("Impossible");
			return 0;
		}
	}
	puts("Possible");
}

Measured memory_bytes: 256
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
#include <chrono>

using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pii>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=5e5+10,oo=0x3f3f3f3f,MOD=998244353;
const long double PI = acos(-1),eps=1.0e-14;
ll cnt(ll A, ll B, ll M)
{
    if (A % M == 0)
        return (B / M) - (A / M) + 1;
    return (B / M) - (A / M);
}
void solve(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<b-a+1-cnt(a,b,c)-cnt(a,b,d)+cnt(a,b,c/__gcd(c,d)*d)<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


Measured memory_bytes: 3628
import java.io.*;
import java.util.*;
import java.lang.ArrayIndexOutOfBoundsException;
import java.math.BigInteger;

/**
 * @author yoshikyoto
 */
class Main {
	static Scanner sc = new Scanner(new InputStreamReader(System.in));
	public static void main(String[] args) throws Exception {
		while(true) {
			int n = sc.nextInt();
			if(n == 0) break;
			System.out.println(solve(n));
		}
	}
	
	static int solve(int n) {
		HashMap<String, ArrayList<Integer>> timeMap = new HashMap<String, ArrayList<Integer>>();
		for (int i = 0; i < n; i++) {
			int m = toMinutes(sc.next(), sc.next());
			String io = sc.next();
			String id = sc.next();
			if(!timeMap.containsKey(id)) {
				timeMap.put(id, new ArrayList<Integer>());
			}
			timeMap.get(id).add(m);
		}
		if(!timeMap.containsKey("000")) {
			return 0;
		}
		ArrayList<Integer> goddessList = timeMap.get("000");
		
		int ans = 0;
		for(String id : timeMap.keySet()) {
			if(id.equals("000")) continue;
			ArrayList<Integer> list = timeMap.get(id);
			
			int sum = 0;
			for (int i = 0; i < list.size(); i+=2) {
				for (int j = 0; j < goddessList.size(); j+=2) {
					int start = Math.max(goddessList.get(j), list.get(i));
					int end = Math.min(goddessList.get(j+1), list.get(i+1));
					int time = end - start;
					if(time > 0) {
						sum += time;
					}
				}
			}
			ans = Math.max(ans, sum);
		}
		return ans;
	}
	
	static int toMinutes(String str1, String str2) {
		String[] month_date = str1.split("/");
		String[] hour_minute = str2.split(":");
		int month = Integer.valueOf(month_date[0]);
		int date = Integer.valueOf(month_date[1]);
		int hour = Integer.valueOf(hour_minute[0]);
		int minute = Integer.valueOf(hour_minute[1]);
		int ans = minute + hour * 60 + date * 24 * 60 + month * 31 * 24 * 60;
		return ans;
	}
}

Measured memory_bytes: 64024
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M = map(int, readline().split())
if M == 0:
    print([0, 10, 100][N - 1])
    exit()
m = map(int, read().split())
S, C = zip(*zip(m, m))

def test(n):
    st = str(n)
    if len(st) != N:
        return False
    for i, c in zip(S, C):
        i -= 1
        if st[i] != str(c):
            return False
    return True

def main():
    for n in range(1000):
        if test(n):
            return n
    return -1

print(main())


Measured memory_bytes: 9104
class TestCase
  attr_reader :x, :y
  def initialize(nums_str)
    nums_array = nums_str.split
    nums = nums_array.map{|num_str| num_str.to_i}
    @x = nums[0]
    @y = nums[1]
  end

  def ==(compared)
    if @x == compared.x && @y == compared.y
      true
    elsif
      false
    end
  end

  def solve
    if @x > @y
      @x, @y = @y, @x
    end
    puts "#{@x} #{@y}"
  end
end

termination = TestCase.new("0 0")

testCases = Array.new(0)

while true
  nums_str = gets
  testCase = TestCase.new(nums_str)
  if testCase == termination
    break
  end
  
  testCases << testCase
end

testCases.each do |testCase|
  testCase.solve
end

Measured memory_bytes: 8804
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	n = int(input())
	cc=0
	for _ in range(n):
		b , c = tin()
		if b == c:
			cc += 1
			if cc == 3:
				return 'Yes'
		else:
			cc = 0
	return 'No'
	#s = input()	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 62612
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>

using namespace std;

int main(){
  int N, M;
  long long ans;
  long long fac(int N);

  cin >> N >> M;
  if(N == M){
    ans = fac(N);
    ans *= ans;
    ans *= 2;
  }else if(N == M+1 || N+1 == M){
    ans = fac(M);
    ans *= fac(N);
  }else{
    cout << 0 << endl;
    return 0;
  }
  ans %= 1000000007;
  cout << ans << endl;
  return 0;
}

long long fac(int N){
  long long ans=1;
  for(long long i = 1; i <= N; i++){
    ans *= i;
    if(ans > 100000007)ans %= 1000000007;
  }
  return ans;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int n,x,y,z,vfs[10050],rez;
int main()
{
    cin >> n;
    for(x=1; x<=105; x++)
      for(y=1; y<=105; y++)
        for(z=1; z<=105; z++) {
          rez=x*x+y*y+z*z+x*y+y*z+x*z;
          if(rez<10050)
            vfs[rez]++;
        }
    for(int i=1; i<=n; i++)
      cout << vfs[i] << "\n";
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
int ans = 0;
int i_index;
int tmp;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};
string board[64];
string a[64];
int main(){
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    N = min(C * 2, A + B);//A, Bそれぞれ1枚買う際に安い方
    
    int z = min(X, Y);//X, Y少ない方
    ans = z * N;
    int dx = X - z;
    int dy = Y - z;
    int xx = min(dx * A, dx * N);
    int yy = min(dy * B, dy * N);
    ans += xx + yy;
    /*if(N == C * 2 && X < Y){
        ans += N * (Y - X);
    }
    else if(N == C * 2 && X >= Y){
        ans += N * (X - Y);
    }
    else
        ans += (X - z) * A + (Y - z) * B;*/
    //if(Y > X)
    //    ans -= (Y - X);
    cout << ans << endl;
    return 0;
}

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


    int main()
    {


         ios_base::sync_with_stdio(false);
         cin.tie(NULL);
       /* #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif*/
    int a,b;
    cin>>a>>b;
    int first=a+b;
    int second=a-b;
    int third=a*b;
    cout<<max(first,max(second,third))<<endl;

     return 0;

    }

Measured memory_bytes: 3652
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
using namespace std;
ll a,b,c,d;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
bool okay(ll a,ll b,ll c,ll d)
{
	ll g=gcd(d,b); ll x=(b-a)/g*g;
	if((x+a)%b>c)	return 0;
	x=(b-a-1)/g*g;
	if((x+a)%b>c)	return 0;
	return 1; 
}
int main()
{
	int t; scanf("%d",&t);
	while(t--)
	{
		scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
		if(a<b || b>d){printf("No\n"); continue;}	a%=b;
		if(okay(a,b,c,d))	printf("Yes\n");
		else	printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int n,arr[12][10],b,f,r,v;
int main() {
	cin>>n;
	while(n--)
	{
		cin>>b>>f>>r>>v;
//		if(arr[(b-1)*3+f-1][r-1]+=v>9)
//			arr[(b-1)*3+f-1][r-1]=9;
//		else if(arr[(b-1)*3+f-1][r-1]+=v<0)
//			arr[(b-1)*3+f-1][r-1]=0;	
//		else
			arr[(b-1)*3+f-1][r-1]+=v;
	}
	for(int i=0;i<12;i++)
	{
		for(int j=0;j<10;j++)
			cout<<" "<<arr[i][j];
		cout<<endl;
		if((i+1)%3==0&&i!=11)
			cout<<"####################"<<endl;
		
	}
	return 0;
}


Measured memory_bytes: 3096
#include <iostream>

using namespace std;

int a,b;

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


Measured memory_bytes: 3088
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <deque>
#include <math.h>
#include <cstring>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <stack>
#include<cassert>
#include <cfloat>
#include <list>
using namespace std ;
#define ll long long
#define submitStage int TCF = 1 ;
#define testStage int TCF = 1000 ;
#define testMyStupedCode TCF--
void FastInputOutput(){
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
void ReadFromFile( string name , string extention ){
    string fullPath = name + "." + extention ;
    freopen( fullPath.c_str() , "r" , stdin ) ;
}
inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}
inline char C(){
    char c ;
    scanf( "%c" , &c ) ;
    return c ;
}
inline ll power(ll x, ll p, ll m){
    ll res = 1;
    while(p){
        if(p & 1)
            res = (res * x) % m;
        x = (x * x) % m;
        p >>= 1;
    }
    return res;
}
long double ModLog(long double base, long double x) {
    return (logl(x) / logl(base));
}

const int N = 1e5 + 5;
ll dp[N];
int w[101], v[101];
ll inf = 1e13 + 5, n;
int main(){
     //freopen("//Users//Mr.X//Desktop//tests//tst.text", "r", stdin);
     n = D();
     int W = D();
     int V = 0;
     for(int i = 0; i < n; ++i){
          w[i] = D(), v[i] = D();
          V += v[i];
     }
     for(int i = 0; i <= V; ++i)
          dp[i] = inf;
     dp[0] = 0;
     int ans = 0;
     for(int i = 0; i < n; ++i)
         for(int j = V - v[i]; j >= 0; --j){
               dp[j + v[i]] = min(dp[j + v[i]], dp[j] + w[i]);
               if(dp[j] <= W)
                    ans = max(j, ans);
               if(dp[j + v[i]] <= W)
                    ans = max(ans, j + v[i]);
         
         }
     printf("%d", ans);
     return 0;
}


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

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

 //    #ifndef ONLINE_JUDGE
	// 	freopen("../../a.in","r",stdin);
	// 	freopen("../../a.out","w",stdout);
	// #endif

	string s;
	int ct1=0, ct2=0;
	cin >> s;
	for (int i=0; i<s.length(); i++){
		if (i%2==0 && s[i]=='0') ct1++;
		if (i%2==0 && s[i]=='1') ct2++;
		if (i%2==1 && s[i]=='1') ct1++;
		if (i%2==1 && s[i]=='0') ct2++;
	}

	cout << min(ct1,ct2) << "\n";
}

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

int main(){
    

int N,M;
cin>>N>>M;
int s[100][100];
int p[100];
for(int i=0; i<M; i++){
    int k;
    cin>>k;
    for(int j=0; j<k; j++){
        int r;
    cin>>r;
    s[i][j]=r;
    }
}
for(int i=0; i<M; i++){
    cin>>p[i];
}

int res=0;

for(int bit=0; bit<(1<<N); bit++){
    


bool t=true;

for(int i=0; i<M; i++){
    
    int counter=0;
    
    for(int j:s[i]){

if (bit & (1<<j)) counter++;

}

if (counter%2==p[i]) t=true;
else {t=false; break;}
}

if(t) res++;

}

cout<<res<<endl;
}

Measured memory_bytes: 256
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("avx,avx2,fma")
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> ppl;
#define ain(a,n) for(ll i=0;i<(n);++i)  cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define mp make_pair
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
// #define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 300005
#define BLOCK 555
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 200005;
const long double epsilon = 1e-9;
inline ll myceil(ll a, ll  b) {
    return (ceil(1.0 * a / b * 1.0));
}
ll binexp(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
ll modinvfermat(ll a, ll m)
{
    return binexp(a, m - 2, m);
}
void task(bool flag)
{
    if (flag)
        cout << "YES\n";
    else
        cout << "NO\n";
}
ll lcm(ll a, ll b)
{
    return ((1LL * a * b) / (__gcd(a, b)));
}



signed main() {
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    fast
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll v1 = b * d;
    ll v2 = a * c;
    cout << max({v1, v2, a * d, b * c}) << END;


// #ifndef ONLINE_JUDGE
//     cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif
    return 0;
}



Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int p = s.size ();
	
	int x=p/2;
	
	for(int i=0;i<x;i++)
	if(s[i]==s[p-i-1])
	cout<<"Yes";
	else
	cout<<"No";

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		//入力表示
		String S = sc.next();
		char[] c = S.toCharArray();

		for (int i = 0; i < S.length(); i++) {
			if (i % 2 == 0) {
				if (c[i] == 'L') {
					System.out.println("No");
					return;
				}
			} else {
				if (c[i] == 'R') {
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 22996
/**   
 *   Author:    @glaucoacassioc
 *   Created on 11.09.2020, 15:32:16
**/
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;

int dp[200002];
int mx[200002];
string s;
int n, k, c;

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

	cin >> n >> k >> c;
	cin >> s;
	s = ' ' + s;
	for(int i=n; i>=1; i--)
	{
		if(s[i] == 'o')
			dp[i] = 1 + mx[min(n+1, i + c + 1)];
		else
			dp[i] = mx[i+1];
		mx[i] = max(dp[i], mx[i+1]);
	}
	int mxr = k;
	int lst = 1;
	int bgrm = 0;
	deque<int> v;
	while(mxr)
	{
		for(int i = lst; i<=n; i++)
			if(s[i] == 'o' && dp[i] >= mxr)
				v.push_back(i);
			else
			{
				if(mx[i] < mxr)
				{
					lst = i;
					break;
				}
			}
		if(v.size() == 1)
			cout << v[0] << endl;
		if(v.size())
			lst = max(lst, v[0] + c + 1);
		int prv_val = v[0];
		while(!v.empty() && prv_val + c + 1 > v[0])
			v.pop_front();
		--mxr;
	}
	return 0;
}             


Measured memory_bytes: 5764
def s()
  gets().chomp
end
def i()
  gets.to_i
end
def li()
  gets.split.map(&:to_i)
end
def ili()
  n = gets.to_i
  as = gets.split.map(&:to_i)
  [n, as]
end
class Array
  def sum
    total = 0
    self.each do |item|
      total += item
    end
    total
  end
end

n, m = li()
as = []
m.times{
  as << li()
}
as.sort_by!{|a, b| b}
remove = as[0][1] - 1
count = 1
as.shift
as.each{|a, b|
  if a > remove
    remove = b-1
    count += 1
  end
}
puts count


Measured memory_bytes: 12664
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define all(x) x.begin(), x.end()
#define cat(x) cerr << #x << " = " << x << endl
 
using namespace std;	

const int N = 1e6;
const int MOD = 998244353;

void add(int &a, int b) {
	a += b;
	if (a >= MOD) a -= MOD;
	if (a < 0) a += MOD;
}

int pt(int a, int b) {
	int c = 1;
	while (b) {
		if (b & 1) c = 1LL * c * a % MOD;
		a = 1LL * a * a % MOD;
		b /= 2;
	}
	return c;
}

int n, a[N+1], cnt[N+1], mob[N+1], out;
vector <int> divi[N+1];

int main() {
	scanf ("%d", &n);
	rep(i, 1, n) {
		scanf ("%d", a + i);
		cnt[a[i]]++;
		add(out, -a[i]);
	}
	
	rep(i, 1, N) {
		mob[i] += i == 1;
		for (int j = i + i; j <= N; j += i)
			mob[j] -= mob[i];
		//printf ("%d ", mob[i]);
	}
	
	rep(i, 1, N)
		for (int j = i; j <= N; j += i)
			divi[j].pb(i);
	
	rep(f, 1, N) {
		int val = 0, odw = pt(f, MOD - 2);
		for (int g = 1; g * f <= N; g ++)
			add(val, 1LL * g * f % MOD * cnt[g * f] % MOD);
			
		for (auto m : divi[f])
			add(out, 1LL * mob[m] * m * odw % MOD * val % MOD * val % MOD);
	}
	printf ("%lld\n", 1LL * out * ((MOD + 1) / 2) % MOD);
	
	return 0;
}


Measured memory_bytes: 126748
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int n;
    cin>>n;
    unordered_map<int,int>m;
    ll sum=0;
    for(int i=0;i<n;i++){
        int d;
        cin>>d;
        m[d]++;
        sum+=d;
    }
    int q;
    cin>>q;
    while(q--){
        int b,c;
        cin>>b>>c;
        int x=m[b];
        m[b]=0;
        m[c]+=x;
        sum-=(ll)x*b;
        sum+=(ll)c*x;
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 7032
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
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 string dir = "DRUL";
*/

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

    string s;
    cin >> s;
    int N = s.size();
    s.push_back('-');
    rep(i,N){
        if(s[i] == '?'){
            cout << 'D';
        }
        else{
            cout << s[i];
        }
    }
        cout << endl;

}

Measured memory_bytes: 3716
#include<stdio.h>

int main(void){

char s[11];
int i = 0;
int count = 0;
int a[11];
int k = 0;
int temp = 0;

for(i = 0; i < 11; i++){
    a[i] = 0;
}

scanf("%s", &s);

for(i = 0; i < 11; i++){
    if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
        count += 1;
    }
    else{
        a[i] = count;
        count = 0;
    }
}


    for(k = 1; k < 11; k++){
        if(a[0] < a[k]){
            temp = a[0];
            a[0] = a[k];
            a[k] = temp;
        }
    }

printf("%d\n", a[0]);

return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
int main() {
    int n,d;
    scanf("%d%d",&n,&d);
    int ans=0;
    for(int i=22;i<=d;i++) {
        int t=(i%10)*(i/10);
        if(i%10<2) continue;
        if(i/10<2) continue;
        if(t<=n&&t>0) ans++;
    }
    printf("%d\n",ans);
    return 0;
}


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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

ll n, x;

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

    V<Pll> p(51);
    p[0] = {1, 0};
    REP2(i, 1, 51) {
        p[i] = {1+2*p[i-1].first, 2+2*p[i-1].second};
    }

    ll res = 0;
    while (n >= 0 && x > 0) {
        if (x <= (p[n].first + p[n].second) / 2) {
            n--;
            x--;
        } else if (x == (p[n].first + p[n].second) / 2 + 1) {
            if (n == 0) {
                res += 1;
            } else {
                res += p[n-1].first + 1;
            }
            break;
        } else {
            res += p[n-1].first + 1;
            x -= (p[n].first + p[n].second) / 2 + 1;
            n--;
        }
    }
    cout << res << '\n';

    return 0;
}


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

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

  long long dp[3010][3010]={0};

  for(int l=1; l<=n; ++l){
    for(int i=0; i+l<=n; ++i){
      int j=i+l;

      if((n-l)%2==0)dp[i][j]=max(dp[i+1][j]+a[i], dp[i][j-1]+a[j-1]);
      else dp[i][j]=min(dp[i+1][j]-a[i], dp[i][j-1]-a[j-1]);
    }
  }

  cout<<dp[0][n]<<endl;
}


Measured memory_bytes: 71040
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    string t = "";
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '1') t += '1';
        else if (s[i] == '0') t += '0';
        else if (t.size() > 0) t.erase(t.end() - 1);
    }
    cout << t;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String[] data = {"SAT","FRI","THU","WED","TUE","MON","SUN"};
    for (int i = 0; i < 7; i++) {
      if (data[i].equals(s)) {
        System.out.println(i+1);
      }
    }

  }

}


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

signed main(){
  
  int n;
  cin>>n;
  
  int ans = n - 1;
  
  for(int i=1;i<=1000000;i++){
    
    if( n % i == 0 ) ans = min( ans, (n/i) - 1 + i - 1 );
    
  }
  
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 256