akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 

using namespace std;
#define mod int(1e9+7)

int H, W;
void dfs(vector< vector<char> >& M, vector< vector<int> >& dp, vector< vector<int> >& visited, int y, int x){
    if(visited[y][x]==1)return;
    if(y==H-1 and x==W-1){dp[y][x]=1;return;}

    if(y+1<H and M[y+1][x]!='#'){
        dfs(M, dp, visited, y+1, x);
        dp[y][x]=(dp[y][x]+dp[y+1][x])%mod;
    }

    if(x+1<W and M[y][x+1]!='#'){
        dfs(M, dp, visited, y, x+1);
        dp[y][x]=(dp[y][x]+dp[y][x+1])%mod;
    }

    visited[y][x]=1;
}
int main(){
    cin>>H>>W;
    vector< vector<char> > M(H, vector<char>(W,'.'));
    vector< vector<int> > dp(H, vector<int>(W,0));
    vector< vector<int> > visited(H, vector<int>(W,0));
    for(int i=0;i<H;i++)
        for(int j=0;j<W;j++)
            cin>>M[i][j];
        
    dfs(M, dp, visited, 0, 0);

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

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

void initialize(int K, const auto& f, auto& V, auto& index) {
  int id = 0;
  vector<int> e(K);
  iota(begin(e), end(e), 0);
  do {
    index[e] = id++;
    V.emplace_back([e, &f](auto l, auto r) {
      for(auto i: e) if(f[l][i] != f[r][i]) return f[l][i] > f[r][i];
      return false;
    });
  } while(next_permutation(begin(e), end(e)));
}

int main() {
  int N, K;
  cin >> N >> K;

  vector<vector<int>> f(N, vector<int>(K));
  for(auto& i: f) for(auto& j: i) cin >> j;

  vector<set<int, function<bool(int, int)>>> V;
  map<vector<int>, int> index;
  initialize(K, f, V, index);

  int D;
  cin >> D;
  vector<vector<int>> G(N);
  vector<int> indegree(N);
  for(auto i = 0; i < D; ++i) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    G[a].emplace_back(b);
    ++indegree[b];
  }

  vector<int> e(K);
  for(auto& i: e) cin >> i, --i;
  auto order = index[e];

  int R;
  cin >> R;
  vector<pair<int, int>> update;
  for(auto i = 0; i < R; ++i) {
    int m;
    cin >> m;
    vector<int> e(K);
    for(auto& i: e) cin >> i, --i;
    update.emplace_back(m, index[e]);
  }
  update.emplace_back(N + 1, -1);

  vector<bool> visited(N);
  for(auto i = 0; i < N; ++i) if(!indegree[i]) for(auto& j: V) j.insert(i);
  for(auto step = 0; step < N; ++step) {
    if(update.front().first <= step) {
      order = update.front().second;
      update.erase(begin(update));
    }
    while(visited[*begin(V[order])]) V[order].erase(*begin(V[order]));
    auto v = *begin(V[order]);
    visited[v] = true;
    cout << v + 1 << endl;
    for(auto i: G[v]) if(!visited[i]) if(! --indegree[i]) for(auto& j: V) j.insert(i);
  }
}

Measured memory_bytes: 63944
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
signed main(){
    int n; cin>>n;
    vector<int>v(n);rep(i,n)cin>>v[i];
    int ans=0;
    int a; cin>>a;
    vector<int>u(a);rep(i,a)cin>>u[i];
    rep(i,a){
        int f=u[i];
        int imin=0;
        int imax=n;
        while(imax-imin>1){
            int mid=(imax+imin)/2;
            if(v[mid]>f)imax=mid;
            else imin=mid;
        }
        if(v[imin]==f)ans++;
    }
    cout<<ans<<endl;
}



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

int main()
{
	long long h,n,count=0;
	cin>>h;
	// vector<long long> a;
	// a.push_back(h);
	// int i=0;
	// while(a[i]!=1)
	// {		
	// 	h=floor(a[i]/2);
	// 	a.push_back(h);
	// 	a.push_back(h);
	// 	i++;
	// }
	long long k = floor(log2(h));
	long long e=pow(2,k+1) - 1;
	cout<<e;

	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int d = Integer.parseInt(sc.next());
		
		int []c = new int [26];
		int [][]s = new int[d][26];
		
		for(int i = 0 ; i < 26 ;i++) {
			c[i] = Integer.parseInt(sc.next());
		}
		
		for(int i = 0; i < d ;i++) {
			for(int j = 0 ; j < 26 ; j++) {
				s[i][j] = Integer.parseInt(sc.next());
			}
		}
		int []p = new int [d];
		
		for(int i = 0 ;i < d ;i++) {
			p[i] = Integer.parseInt(sc.next());
		}
		long []ans = new long [d+1];
		int []r = new int [26];
		
		for(int i = 0 ; i < d ; i++) {
			ans[i+1] = ans[i] + (long)s[i][p[i]-1];
			r[p[i]-1] = i+1;
			for(int j = 0 ; j < 26 ;j++) {
					 ans[i+1] -= (long)c[j]*(i+1 - r[j]);
				 
			}
		}
		
		for(int i = 1 ; i <= d ;i++) {
			System.out.println(ans[i]);
		}

		

	}

}


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

int main() {
  int n, r;
  cin >> n >> r;
  if (n >= 10) cout << r << endl;
  else {
    cout << r + 100*(10-n) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
# input 入力を受け取る split 入力された文字列をスペースで分けて解釈 
# int integer整数 整数として解釈
# map ()内のものを、前の変数にそれぞれ割り当てる
D,T,S = map(int, input().split())

#T 時間 S 速さ の積が D 距離 を上回るかどうか？

# * 掛け算
if T * S >= D :
    print('Yes')
else :
    print('No')

Measured memory_bytes: 9064
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
const int INF = 1e9 + 7;

int main(){
    int n, t, a;  cin>>n>>t>>a;
    double mi = INF;
    int ans;
    for(int i = 0; i < n; i++){
        double m; cin>>m;
        m = t - m * 0.006;
        m = abs(m-(double)a);
        if(m<mi){
            mi = m;
            ans = i+1;
        }
    }
    cout<<ans;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <limits.h>

using namespace std;

int main(int argc, char const* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A1, A2, A3;
    vector<int> v(3);
    cin >> v[0] >> v[1] >> v[2];
    int minimum = 300;
    do {
        for (auto x: v) {
            int n = abs(v[0] - v[1]) + abs(v[1] - v[2]);
            minimum = min(minimum, n);
        }
    } while (next_permutation(v.begin(), v.end()));
    cout << minimum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <numeric>

//#include <map>

using namespace std;

int main()
{
	string s;
	while (1)
	{
		string st;
		getline(cin, st);
		if (st == "\0")break;

		s += st;
	}

	char ch[1200];
	memset(ch, 0, sizeof(ch));
	
	strcpy(ch, s.c_str());

	vector<string> vs;

	for (char i = 'a'; i <= 'z'; i++)
	{
		char * pth = ch;
		int count = 0;
		while (*pth)
		{
			if (*pth == i || *pth == (i - 0x20))
			{
				count++;
			}
			pth++;
		}
		ostringstream ss;
		ss << i << " : " << count;
		string st;
		st = ss.str();
		vs.push_back(st);
	}

	for (int i = 0; i < vs.size(); i++)
	{
		cout << vs.at(i) << endl;
	}

	return 0;
}

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

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<int> Array;
typedef vector<Array> Matrix;
const int loose = 0;
const int tight = 1;

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

//グラフ関連
struct Edge {//グラフ
	int to, cap, rev;
	Edge(int _to, int _cap, int _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, int from, int to, int cap, bool revFlag, int revCap) {
	G[from].push_back(Edge(to, cap, G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, G[from].size() - 1));
}

ll dfs(Graph &g, ll v, Array& used, Array& check, Array& ans){
	used[v]=true;
	bool flag = check[v];
	for(auto e:g[v]){
		if(!used[e.to] && dfs(g,e.to,used,check,ans)){
			//印が奇数個の場合は切る
			ans.push_back(e.cap);
			flag = !flag;
		}
	}
	return flag;
}

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

	ll n,m;
	cin>>n>>m;
	
	vector<P> ab(n);
	REP(i,n){
		ll a,b;
		cin>>a>>b;
		ab[i]={a,b};
	}

	
	//corner
	ab.push_back({0,0});
	ab.push_back({INF,0});
	sort(all(ab));

	Graph g(n+2);

	REP(i,m){
		ll l,r;
		cin>>l>>r;
		l = lower_bound(all(ab), make_pair(l,0LL))-ab.begin()-1;//l未満のスイッチを切り替える
		r = upper_bound(all(ab), make_pair(r,1LL))-ab.begin()-1;//r以下のスイッチを切り替える
		if(l!=r) add_edge(g,l,r,i+1,true,i+1);
	}
	

	Array used(n+2,false);
	Array check(n+2,false);
	Array ans;
	REP(i,n+1) if(ab[i].second!=ab[i+1].second) check[i]=true;//隣と違う場合は奇数操作である必要がある

	REP(i,n+2){
		if(!used[i] && dfs(g,i,used,check,ans)==true){
			cout<<-1<<en;
			return 0; 
		} 
	}

	sort(all(ans));
	cout<<ans.size()<<en;
	for(auto i:ans) cout<<i<<" ";
	cout<<en;
	
	return 0;
}

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

using ld=long double;
using P=complex<ld>;
const int SIZE=2000;
const ld EPS=1e-9;

int solve(int n){
    vector<P> ps(n);
    for(int i=0;i<n;i++){
        ld x,y;
        cin>>x>>y;
        x+=SIZE,y+=SIZE;
        ps[i]={x,y};
    }
    vector<map<int,vector<int>>> vmp(SIZE*3);
    for(int i=0;i<n;i++){
        P a=ps[i],b=ps[(i+1)%n];
        if(real(a)==real(b)) continue;
        if(real(a)>real(b)) swap(a,b);
        int lb=real(a),ub=real(b);
        if(imag(a)==imag(b)){
            int y=imag(a);
            for(int x=lb;x<ub;x++){
                vmp[x][y].push_back(-1);
            }
        }
        else{
            P vec=b-a;
            for(int x=lb;x<ub;x++){
                ld y0=imag(ld(x-lb)/(ub-lb)*vec+a);
                ld y1=imag(ld(x+1-lb)/(ub-lb)*vec+a);
                if(y0>y1) swap(y0,y1);
                int y0i=floor(y0+EPS),y1i=ceil(y1-EPS);
                for(int y=y0i;y<y1i;y++){
                    vmp[x][y].push_back(i);
                }
            }
        }
    }
    int res=0;
    for(auto &mp:vmp){
        int now=-1;
        int cnt=0;
        vector<int> flag(n);
        for(auto &e:mp){
            int y=e.first;
            auto& vec=e.second;
            int hc=count(vec.begin(),vec.end(),-1);
            if(cnt&1){
                res+=y-now-1;
            }
            if(hc==vec.size()){
                cnt++;
                if(cnt&1) res++;
            }
            else{
                res++;
                for(auto idx:vec){
                    if(idx!=-1 && !flag[idx]){
                        flag[idx]=true;
                        cnt++;
                    }
                }
                if(hc) cnt++;
            }
            now=y;
        }
    }
    return res;
}
int main(){
    int n;
    while(cin>>n,n){
        cout<<solve(n)<<endl;
    }
    return 0;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

  n = n % 10;
  if (n == 3) {
    cout << "bon" << '\n';
  } else if (n == 0 || n == 1 || n == 6 || n == 8) {
    cout << "pon" << '\n';
  } else {
    cout << "hon" << '\n';
  }
  return 0;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <tuple>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
    return (a == 0 ? b : gcd(b % a, a));
}
int main() {
    int a, b;
    cin >> a >> b;
    cout << gcd(a, b) << endl;
    return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n,m;
	int x,y,cost;
	int dp[100][100];
	int i,j,k;
	int flg;
	cin>>n>>m;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(i==j)	dp[i][j]=0;
			else		dp[i][j]=INT_MAX;
		}
	}
	for(i=0;i<m;i++){
		cin>>x>>y>>cost;
		dp[x][y]=cost;
	}
	for(k=0;k<n;k++){
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				if(dp[i][k]!=INT_MAX&&dp[k][j]!=INT_MAX){
					dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
				}
			}
		}
	}
	flg=0;
	for(i=0;i<n;i++){
		if(dp[i][i]<0)	flg=1;
	}
	if(flg==1)	cout<<"NEGATIVE CYCLE"<<endl;
	else{
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				if(j)	cout<<" ";
				if(dp[i][j]==INT_MAX)	cout<<"INF";
				else					cout<<dp[i][j];
			}
			cout<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3160
#include<stdio.h>

int main()
{
	int A, B, K;
	int w;

	scanf("%d",&K);
	scanf("%d %d", &A, &B);

	w = A / K;
	w = w * K;
	if (w == A)
		printf("OK");
	else {
		w += K;
		if (w <= B)
			printf("OK");
		else
			printf("NG");
	}

	return 0;
}

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

int main() {
  char a, b;
  cin >> a >> b;
  if (a == 'H') {
    if (b == 'H') cout << "H" << endl;
    else cout << "D" << endl;
  }
  else {
    if (b == 'H') cout << "D" << endl;
    else cout << "H" << endl;
  }
}


Measured memory_bytes: 256
using System;

namespace B
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			var num = int.Parse(Console.ReadLine().Replace(" ", ""));
			for (var i = 1; i < num; i++)
			{
				if (i * i == num)
				{
					Console.WriteLine("Yes");
					return;
				}
			}

			Console.WriteLine("No");
		}
	}
}

Measured memory_bytes: 11092
import java.io.*;
import java.util.stream.*;

public class Main {
  public static void main(String[] args) {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    br.lines()
      .parallel()
      .map(line -> String.valueOf(Stream.of(line.split(" ")).mapToInt(Integer::parseInt).sum()).length())
      // .sequential()
      .forEach(System.out::println);
  }
}

Measured memory_bytes: 31416
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<utility>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long lo;
const int mod=1000000007,N=500005;
lo a,b,c,d,e,f,g,h[N],arr[N];

void solve(lo n,string s,char x){
	if(n==a+1){cout << s << endl; return;}
	for(lo i='a';i<=x;i++){
		string y;
		y+=(char)i;
		solve(n+1,s+y,max(x,(char)((lo)i+1)));
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// freopen("in.txt","r",stdin);
	// freopen("out.txt","w",stdout);
	cin >> a;
	solve(2,"a",'b');
}

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

using namespace std;

struct SuffixArray
{
  vector< int > SA;
  string s;

  void Build_SA(const string &str)
  {
    s = str;
    SA.resize(s.size());
    iota(begin(SA), end(SA), 0);
    sort(begin(SA), end(SA), [&](const int &a, const int &b)
    {
      if(s[a] == s[b]) return (a > b);
      return (s[a] < s[b]);
    });
    vector< int > classes(s.size()), c(s.size()), cnt(s.size());
    for(int i = 0; i < s.size(); i++) {
      c[i] = s[i];
    }
    for(int len = 1; len < s.size(); len <<= 1) {
      for(int i = 0; i < s.size(); i++) {
        if(i > 0 && c[SA[i - 1]] == c[SA[i]] && SA[i - 1] + len < s.size() && c[SA[i - 1] + len / 2] == c[SA[i] + len / 2]) {
          classes[SA[i]] = classes[SA[i - 1]];
        } else {
          classes[SA[i]] = i;
        }
      }
      iota(begin(cnt), end(cnt), 0);
      copy(begin(SA), end(SA), begin(c));
      for(int i = 0; i < s.size(); i++) {
        int s1 = c[i] - len;
        if(s1 >= 0) SA[cnt[classes[s1]]++] = s1;
      }
      classes.swap(c);
    }
  }

  int operator[](int k) const
  {
    return (SA[k]);
  }

  int size() const
  {
    return (s.size());
  }

  bool lt_substr(string &t, int si = 0, int ti = 0)
  {
    int sn = s.size(), tn = t.size();
    while(si < sn && ti < tn) {
      if(s[si] < t[ti]) return (true);
      if(s[si] > t[ti]) return (false);
      ++si, ++ti;
    }
    return (si >= sn && ti < tn);
  }

  int lower_bound(string &t)
  {
    int low = -1, high = SA.size();
    while(high - low > 1) {
      int mid = (low + high) >> 1;
      if(lt_substr(t, SA[mid])) low = mid;
      else high = mid;
    }
    return (high);
  }

  pair< int, int > lower_upper_bound(string &t)
  {
    int idx = lower_bound(t);
    int low = idx - 1, high = SA.size();
    t.back()++;
    while(high - low > 1) {
      int mid = (low + high) >> 1;
      if(lt_substr(t, SA[mid])) low = mid;
      else high = mid;
    }
    t.back()--;
    return (make_pair(idx, high));
  }

  void output()
  {
    for(int i = 0; i < size(); i++) {
      cout << i << ": " << s.substr(SA[i]) << endl;
    }
  }
};


int main()
{
  int K;
  string S;

  cin >> K;
  cin >> S;

  SuffixArray sa;
  sa.Build_SA(S);
  //sa.output();

  int L = (S.size() + K) / (K + 1);
  vector< int > rev(S.size());
  for(int i = 0; i < S.size(); i++) rev[sa[i]] = i;

  auto check = [&](int v)
  {
    int ret = 0;
    for(int i = 0; i < S.size(); ++ret) {
      int add = rev[i] < v ? L : L - 1;
      if(add == 0) return (false);
      i += add;
    }
    return (ret <= K + 1);
  };

  int low = 0, high = sa.size();
  while(high - low > 1) {
    int mid = (low + high) >> 1;
    if(check(mid)) high = mid;
    else low = mid;
  }
  cout << S.substr(sa[low], L) << endl;
}

Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


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


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

	if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
		cout << 0;
	}

	else {
		cout << min(A*B, min(B*C, C*A));
	}

	system("PAUSE");

}





Measured memory_bytes: 504
import bisect
N = int(input())
A = [0 for i in range(N)]
for i in range(N):
    A[i] = int(input())
now = [-A[0]]

for i in range(1, N):

    index = bisect.bisect_right(now, -A[i])
    if index == len(now):
        now.append(-A[i])
    else:
        now[index] = -A[i]

print(len(now))


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

int main()
{

  int N;
  cin>>N;

  vector<int64_t> L(100);
  L.at(0)=2;
  L.at(1)=1;
  for(int i=2;i<=87;i++)
  {
    L.at(i)=L.at(i-1)+L.at(i-2);
  }
  cout<<L.at(N)<<endl;
  
  return 0;
}

Measured memory_bytes: 256
//Jai Shree Ram
//#include <iostream>
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define loopi(stop) for(int i=0; i<stop; i++)
#define loopj(stop2) for(int j=0; j<stop2; j++)
#define loopk(stop3) for(int k=0; k<stop3; k++)
#define loopi1(stop) for(int i=1; i<=stop; i++)
#define loopj1(stop2) for(int j=1; j<=stop2; j++)
#define loopk1(stop3) for(int k=1; k<=stop3; k++)
#define loopse(kt,sstart, eend) for(int kt = sstart; kt<eend; kt++)
#define faster_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define file_io_cf freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define p_b push_back
#define pii pair<int,int>
#define fi first
#define se second
#define prec_10 << fixed << setprecision(10)
#define DEB cout<<"DEBUG"<<'\n';
#define SRAND srand(time(0));

using namespace std;

int mod = 1000000007;

template <typename T>
void O(T x) {
	cout << x << '\n';
}

///////////////////////////////////CODE STARTS HERE///////////////////////////////////////////

const int N = 200001;
vector <int> graph[N];
int vis [N] = {0};
	
int dfs(int src){
	vis[src]++;
	int size  = 1;
	for(int child : graph[src]){
		if(vis[child] == 0){
			size += dfs(child);
		}
	}

	return size;
}


int32_t main() {

	faster_io
	// file_io_cf

	int ans = 0;
	int n,m;cin>>n>>m;

	loopi(m){
		int u,v;cin>>u>>v;
		graph[u].p_b(v);
		graph[v].p_b(u);
	}

	loopi1(n){
		if(vis[i] == 0){
			ans = max(ans,dfs(i));
		}
	}
	O(ans);


	return 0;
}

Measured memory_bytes: 25480
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        String s = sc.next();
        String t = sc.next();
        sc.close();

        // 主処理
        long l = lcm(n, m);
        int lpn = (int) (l / n);
        int lpm = (int) (l / m);

        boolean judge = true;
        Map<Integer, String> map = new HashMap<>();

        for (int i = 0; i < n; i++) {
            String w = String.valueOf(s.charAt(i));
            int index = (i * lpn) + 1;
            if (!map.containsKey(index) || w.equals(map.get(index))) {
                map.put(index, w);
            } else {
                judge = false;
                break;
            }
        }

        for (int i = 0; i < m; i++) {
            String w = String.valueOf(t.charAt(i));
            int index = (i * lpm) + 1;
            if (!map.containsKey(index) || w.equals(map.get(index))) {
                map.put(index, w);
            } else {
                judge = false;
                break;
            }
        }

        long result = judge ? l : -1;

        // 出力
        System.out.println(result);
    }

    public static long lcm(long a, long b) {
        long gcd = gcd(a, b);
        return a / gcd * b;
    }

    public static long gcd(long a, long b) {
        return b == 0 ? a : gcd(b, a % b);
    }
}

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

typedef long long ll;
#define rep(i, n) for(ll i=0; i<n; i++)
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define sz(v) ll(v.size)


void solve(std::vector<std::string> c){
    cout << c[0][0] << c[1][1] << c[2][2] << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::vector<std::string> c(3);
    for(int i = 0 ; i < 3 ; i++){
        std::cin >> c[i];
    }
    solve(std::move(c));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
	long long h, ans=0,count = 1;

	cin >> h;

	while (h > 0)
	{
		h /= 2;
		ans+=count;
		count*=2;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#pragma  warning (disable:4996)
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
int x[10002];
int y[10002];
int fa[10002];
int n, m;
int num;
struct edge{
	int u;
	int v;
	double cost;
};
bool cmp(edge a, edge b){
	return a.cost < b.cost;
}
edge es[1000000];
int find(int a){
	if (a == fa[a]) return a;
	else return fa[a] = find(fa[a]);
}
bool same(int a, int b){
	int aa = find(a);
	int bb = find(b);
	if (aa==bb) return true;
	else return false;
}

void unite(int a, int b){
	int aa = fa[a];
	int bb = fa[b];
	if (aa != bb){
		fa[aa] = bb;
	}
}
double krusal(){
	sort(es, es + num, cmp);
	double res = 0;
	for (int i = 1; i <= n; i++) fa[i] = i;
	for (int i = 0; i < num; i++){
		edge e = es[i];
		if (!same(e.u, e.v)){
			unite(e.u, e.v);
			res += e.cost;
		}
	}
	return res;
}
int main(){
	
	cin >> n >> m;
	for (int i = 1; i <= n; i++)cin >> x[i] >> y[i];
	num = 0;
	int u, v;
	double d;
	double  sum = 0;
	while (m--){
		cin >> u >> v;
		d = (x[u] - x[v])*(x[u] - x[v]) + (y[u] - y[v])*(y[u] - y[v]);
			d = sqrt(d);
			es[num].u = u;
			es[num].v = v;
			es[num++].cost = -d;
			sum += d;
	}
	double ans = sum + krusal();
	printf("%.3lf\n", ans);
	return 0;
}

Measured memory_bytes: 1768
N = list(input())
if N.count(N[0]) == 3 and N[3] != N[0]:
    print("Yes")
elif N.count(N[0]) == 4:
    print("Yes")
elif N.count(N[3]) == 3 and N[3] != N[0]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
function main(input) {
  const args = input.split(' ').map(n => parseInt(n, 10));
  const A = args[0];
  const B = args[1];
  
  if (A * B % 2 === 0) {
    console.log('No');
  } else {
    console.log('Yes');
  }
  
}

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

Measured memory_bytes: 29580
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m, K = na()
b = []
for i in range(n):
    b.append(ns())

ans = 999999999999999
for ptn in range(1<<n-1):
    lans = 0
    x = ptn
    while x > 0:
        lans += x&1
        x //= 2

    to = [0] * n
    for i in range(1,n):
        if ptn>>i-1&1:
            to[i] = i
        else:
            to[i] = to[i-1]
    f = [0] * n
    ok = True
    o = ord("0")
    for j in range(m):
        plus = [0] * n
        for r in range(n):
            plus[to[r]] += ord(b[r][j])-o
            if plus[to[r]] > K:
                ok = False
                break

        if not ok:
            break
        reset = any(f[r] + plus[r] > K for r in range(n))
        if reset:
            lans += 1
            f = plus
        else:
            for i in range(n):
                f[i] += plus[i]
    if not ok:
        continue
    ans = min(ans, lans)
print(ans)


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n;
    cin >> n;
    int a = 0, b = 0;
    for (int i = 0; i < n; i++)
    {
        string s, t;
        cin >> s >> t;
        if (s < t)
            b += 3;
        else if (s > t)
            a += 3;
        else
        {
            a += 1;
            b += 1;
        }
    }
    cout << a << " " << b << endl;
}



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

P f(int x) {
  int a = x%10;
  int b = 0;
  while(x){
    b = x;
    x/=10;
  }
  return P(a,b);
} 

int main(){
  int n;
  cin >> n;
  map<P,int> freq;
  //nまでの末尾、先頭の組をカウント
  for(int i=1;i<=n;++i){
    P p = f(i);
    freq[p]++;
  }
  //末尾、先頭反転してカウント
  ll ans = 0;
  for(int i=1;i<=n;++i){
      P p = f(i);
      swap(p.first,p.second);
      ans += freq[p];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>

using namespace std;
using ll = long long int;
using vec = vector<int>;

#define rep(n) for(int i = 0; i < (n); ++i)
#define Sort(a)    sort(a.begin(), a.end())
#define gSort(a)   sort(a.begin(), a.end(), greater<int>())
const int INF = 2147483647;
const ll  MOD = 1000000007;

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

    map<int, int> ans;
    for(int i = 1; i <= n-1; ++i) ans[i] = 0;

    for(int i = 1; i < n; ++i) {
        for(int j = i + 1; j <= n; ++j) {
            int length = j - i;
            if(j > x) {
                length = min(length, abs(i - x) + abs(j - y) + 1);
            }

            // cout << "(" << i << ", " << j << ")" << " = " << length << endl;
            ans[length]++;
        }
    }

    // for(auto i : ans) cout << i.first << " : " << i.second << endl;
    for(auto i : ans) cout << i.second << endl;
}

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

int main() {
	int N, D;
	cin >> N >> D;
	if(N %(2*D+1) == 0){
		cout << N/(2*D+1) << endl;
	} else {
		cout << N/(2*D+1) +1 << endl;
	}
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int A,B;
int i,x;
  scanf("%d",&A);
int data[A];
int kaitou[A];
long z;
 for(i=0;i<A;i++){
 scanf("%d",&data[i]);
 }

  for (i=0;i<A;i++){
    for (x=i+1;x<=A-1;x++){
  z=z + (data[i] * data[x]);
    }
    x=i+1;
  }
  printf("%ld", z);
  return 0;
}


Measured memory_bytes: 128
n,q=map(int,input().split())
s=input()
l=[0]*(len(s)+1)
for i in range(1,len(s)):
    l[i+1]=l[i]
    if s[i-1]=='A' and s[i]=='C':
        l[i+1]+=1
ans=[0]*q
for i in range(q):
    a,b=map(int,input().split())
    ans[i]=l[b]-l[a]
print(*ans,sep='\n')

Measured memory_bytes: 11804
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int n,l;
    vector<string>moji;
    string buf;
    cin >> n >> l;
    for (int i = 0; i < n; ++i) {
        cin >> buf;
        moji.push_back(buf);
    }
    sort(moji.begin(),moji.end());
    for (int j = 0; j < n; ++j) {
        cout << moji[j];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	static int n;
	static int mod=1000000007;
	static int[][] dp=new int[112345][2];
	static ArrayList<Integer>[] G=new ArrayList[112345];
	static void dfs(int u,int fa) {
		dp[u][0]=dp[u][1]=1;
		for (int i=0;i<G[u].size();++i) {
			int v=G[u].get(i);
			if (v==fa) continue;
			dfs(v,u);
			dp[u][0]=(int)(1L*dp[u][0]*(dp[v][0]+dp[v][1])%mod);
			dp[u][1]=(int)(1L*dp[u][1]*dp[v][0]%mod);
		}
	}
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		n=in.nextInt();
		for (int i=1;i<=n;++i)
			G[i]=new ArrayList<Integer>();
		for (int i=0;i<n-1;++i) {
			int x=in.nextInt();
			int y=in.nextInt();
			G[x].add(y);
			G[y].add(x);
		}
		dfs(1,0);
		System.out.println((dp[1][0]+dp[1][1])%mod);
	}
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int t1 = (C+B-1)/B;
	int t2 = (A+D-1)/D;
	if (t1 > t2) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
}

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


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin>>s;
if (s=="SAT")
cout<<"1";

else if (s=="SUN")
cout<<"7";
else if (s=="MON")
cout<<"6";
else if (s=="TUE")
cout<<"5";
else if (s=="WED")
cout<<"4";
else if (s=="THU")
cout<<"3";
else if (s=="FRI")
cout<<"2";
else cout<<"wrong";
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define NMAX 100005
#define MMAX 100005

//コメントアウトするとdebug()を実行しない
#define DEBUG

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

typedef long long ll;
typedef pair<ll ,ll > P;

ll A[NMAX],B[NMAX],C[NMAX],N,K,M,W,H,ans,dp[MMAX] = {};
string S;
static const ll dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){
	for (ll i = 0; i < N; ++i)
	{
		dp[A[i]] += B[i];
	}
	for (ll i = 0; i < MMAX; ++i)
	{
		if(K > dp[i]){
			K -= dp[i];
		}else{
			ans = i;
			break;
		}
	}
}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	cin >> N >> K;
	for (ll i = 0; i < N; ++i)
	{
		cin >> A[i] >> B[i];
	}
	
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

Measured memory_bytes: 2560
import java.util.Arrays;
import java.util.Scanner;

class Main{


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		long[]x = new long[n];
		long[]y = new long[n];
		long[]z = new long[n];

		for(int i = 0;i < n;i++){
			x[i] = sc.nextLong();
			y[i] = sc.nextLong();
			z[i] = sc.nextLong();

		}

		long[] ppp = new long[n];
		long[] ppm = new long[n];
		long[] pmp = new long[n];
		long[] mpp = new long[n];
		long[] pmm = new long[n];
		long[] mmp = new long[n];
		long[] mpm = new long[n];
		long[] mmm = new long[n];

		for(int i = 0;i < n;i++){
			ppp[i] = x[i] + y[i] + z[i];
		}
		for(int i = 0;i < n;i++){
			ppm[i] = x[i] + y[i] - z[i];
		}
		for(int i = 0;i < n;i++){
			pmp[i] = x[i] - y[i] + z[i];
		}
		for(int i = 0;i < n;i++){
			mpp[i] = (-x[i]) + y[i] + z[i];
		}
		for(int i = 0;i < n;i++){
			pmm[i] = x[i] - y[i] - z[i];
		}
		for(int i = 0;i < n;i++){
			mmp[i] = -x[i] - y[i] + z[i];
		}
		for(int i = 0;i < n;i++){
			mpm[i] = -x[i] + y[i] - z[i];
		}
		for(int i = 0;i < n;i++){
			mmm[i] = -x[i] - y[i] - z[i];
		}
		Arrays.sort(ppp);
		Arrays.sort(ppm);
		Arrays.sort(pmp);
		Arrays.sort(pmm);
		Arrays.sort(mmp);
		Arrays.sort(mpp);
		Arrays.sort(mpm);
		Arrays.sort(mmm);


		long ans = 0l;
		long[] data = new long[8];
		for(int i = 0;i < m;i++){
			data[0] += ppp[n-1-i];
			//			System.out.println("ppp "+ppp[n-1-i]);
		}
		for(int i = 0;i < m;i++){
			data[1] += ppm[n-1-i];
		}
		for(int i = 0;i < m;i++){
			data[2] += pmp[n-1-i];
		}
		for(int i = 0;i < m;i++){
			data[3] += mpp[n-1-i];
		}
		for(int i = 0;i < m;i++){
			data[4] += pmm[n-1-i];
		}
		for(int i = 0;i < m;i++){
			data[5] += mmp[n-1-i];
		}
		for(int i = 0;i < m;i++){
			data[6] += mpm[n-1-i];
		}
		for(int i = 0;i < m;i++){
			data[7] += mmm[n-1-i];
		}

		Arrays.sort(data);
//		for(int i = 0;i < 8;i++){
//			System.out.println(data[i]);
//		}
		System.out.println(data[7]);

	}

}

class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}



Measured memory_bytes: 27756
n=int(input())
a=sorted(list(map(int,input().split())))
max=a[-1]
min=a[0]
if n==2:
    print(max-min)
    print(max,min)
    exit()
ans=0
if a[-1]<0:
    ans+=-sum(a)+max*2
elif a[0]>0:
    ans+=sum(a)-min*2
else:
    for x in a:
        ans+=abs(x)
print(ans)
X=max
Y=min
for i in range(1,n-1):
    if a[i]>=0:
        x=Y
        y=a[i]
        print(x,y)
        Y=x-y    
    else:
        x=X
        y=a[i]
        print(x,y)
        X=x-y
print(X,Y)


Measured memory_bytes: 14492
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  double *dp = ALLOC (n + 2, double) + 1;
  dp[0] = 1;
  for (i32 i = 1; i <= n; ++i) {
    double p;
    scanf ("%lf", &p);
    for (i32 j = i; j >= 0; --j) {
      dp[j] = p * dp[j] + (1 - p) * dp[j - 1];
    }
  }
  double ans = 0;
  for (i32 i = 0; i <= n / 2; ++i) {
    ans += dp[i];
  }
  printf ("%.10f\n", ans);
}

int main (void) {
  run();
  return 0;
}

Measured memory_bytes: 128
def fizz_buzz():
    c = 1
    while True:
        res = ''
        if c % 3 == 0:
            res = res + 'Fizz'
        if c % 5 == 0:
            res = res + 'Buzz'
        if res == '':
            yield str(c)
        else:
            yield res
        c += 1

while True:
    m,n = map(int,input().split())
    if m == 0: break

    player = list(range(m))

    p = 0
    fb = fizz_buzz()
    for i in range(n):
        inp = input()
        if len(player) > 1:
            if  inp != next(fb):
                del player[p] 
                p = p % len(player)
            else:
                p = (p+1) % len(player)

    result = str(player[0]+1)
    if len(player) > 1:
        for pi in player[1:]:
            result += ' ' + str(pi+1)

    print(result)

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

int N,M;
int P[100010];
int cnt;
int K[100010];
bool vis[100010];
int ans = 0;
vector<int> G[100010],V;

void DFS(int v)
{
    if(vis[v])return;
    vis[v] = true;
    V.push_back(P[v]);
    K[v] = cnt;
    for(int i = 0; i < G[v].size(); i++)DFS(G[v][i]);
    return;
}

int main()
{
    scanf("%d%d",&N,&M);
    for(int i = 0; i < N; i++)scanf("%d",P + i + 1);
    for(int i = 0; i < M; i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        G[P[a]].push_back(P[b]);
        G[P[b]].push_back(P[a]);
    }

    for(int i = 1; i <= N; i++)if(!vis[i])
    {
        cnt++;
        V.clear();
        DFS(i);
        for(int j = 0; j < V.size(); j++)if(K[V[j]] == cnt)ans++;
    }

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


Measured memory_bytes: 9080
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
void main() {
    int n, k; 
    int[] x;
    bool input() {
        scanf("%d %d\n", &n, &k);
        if (n == 0 && k == 0) return false;
        x = new int[n];
        foreach (i; 0 .. n) {
            scanf("%d\n", &x[i]);
        }
        return true;
    }

    void solve() {
        int MaxPoint() {
            int CalcK(int i) {
                if (i + k > n) return 0;
                int Ret = 1;
                foreach (j; 0 .. k) {
                    Ret *= x[i + j];
                }
                return Ret;
            }
            int ck = 0;
            foreach (i; 0 .. n) {
                ck = max(ck, CalcK(i));
            }
            return ck;
        }

        int Ans = int.min;
        int o = MaxPoint;
        foreach (i; 0 .. n) {
            foreach (j; i + 1 .. n) {
                swap(x[i], x[j]);
                Ans = max(Ans, MaxPoint);
                swap(x[j], x[i]);
            }
        }
        writeln(Ans - o);
    }

    while (input) solve;
}

Measured memory_bytes: 1052
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        boolean[] ac = new boolean[n];
        int[] pn = new int[n];
        for (int i = 0; i < m; i++) {
            int p = sc.nextInt();
            String s = sc.next();
            if (s.equals("AC")) ac[p - 1] = true;
            else if (!ac[p - 1]) pn[p - 1]++;
        }
        int ans1 = 0, ans2 = 0;
        for (int i = 0; i < n; i++) {
            if (ac[i]) {
                ans1++;
                ans2 += pn[i];
            }
        }
        System.out.println(ans1 + " " + ans2);
    }
}

Measured memory_bytes: 63388
class _in{struct my_iterator{int it;const bool rev;explicit constexpr my_iterator(int it_, bool rev=false):it(it_),rev(rev){}constexpr int operator*(){return it;}constexpr bool operator!=(my_iterator& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const my_iterator i,n;public:explicit constexpr _in(int n):i(0),n(n){}explicit constexpr _in(int i,int n):i(i,n<i),n(n){}constexpr const my_iterator& begin(){return i;}constexpr const my_iterator& end(){return n;}};

#include <bits/stdc++.h>
using namespace std;

int main() {
    string s1, s2;
    cin >> s1 >> s2;
    int N = s1.size(), M = s2.size();
    vector<vector<int>> dp(N + 1, vector<int>(M + 1, 0));
    for(int i : _in(N + 1)) dp[i][0] = i;
    for(int j : _in(M + 1)) dp[0][j] = j;
    for(int i : _in(N)) for(int j : _in(M)) {
        dp[i + 1][j + 1] = dp[i][j];
        if(s1[i] != s2[j]) ++dp[i + 1][j + 1];
        int temp = min(dp[i][j + 1] + 1, dp[i + 1][j] + 1);
        dp[i + 1][j + 1] = min(dp[i + 1][j + 1], temp);
    }
    cout << dp[N][M] << endl;
}

Measured memory_bytes: 6828
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define fr1(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define viii vector <pair<ll,pair<ll,ll> > >
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define input(a,n) fr(i,0,n)cin>>a[i]
#define output(a,n) fr(i,0,n)cout<<a[i]<<endl
#define dbg cout<<"hurr"<<endl;
#define dbg2 cout<<"hurr2"<<endl;
#define md 1000000007
#define inf 999999999999999999
#define sp << " " <<
#define endl "\n"
#define pi 3.14159265358979323846
#define fixd(x) cout << fixed << setprecision(x);
#define sz size()
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
bool compare(pair<ll,string> p1,pair<ll,string> p2){
return p2.fi>p1.fi;
}
void solve(){
 ll a,b,n;
 cin>>a>>b>>n;
 ll x=min(b-1,n);
 cout<<(a*x)/b-a*(x/b)<<endl;
}
int main()
{   fast;
    ll t=1;
    //cin>>t;
    fr(zz,1,t+1){
    solve();
    }
}


Measured memory_bytes: 3584
import sys
S = list(input())
S = [S[0]+S[1],S[2]+S[3]]
month = ['01','02','03','04','05','06','07','08','09','10','11','12']

# 月表示、年表示についてのステータス
# [前表示、後ろ表示]
mon = [0,0]
yer = [0,0]

if S[0] in month:
	mon[0] = 1
if S[1] in month:
	mon[1] = 1


if mon[0] == 1 and mon[1] == 1:
	print('AMBIGUOUS')
	sys.exit()
if mon[0] == 1:
	print('MMYY')
	sys.exit()
if mon[1] == 1:
	print('YYMM')
	sys.exit()
else:
	print('NA')
	sys.exit()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

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 = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

int main(int argc, char* argv[])
{
  int n;
  cin >> n;
  for (int i = 0; i*7 <= n; i++) {
    if ((n - i*7) % 4 == 0) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;
using plli=pair<ll,int>;
using vplli=vector<pair<ll,int>>;
using pllll=pair<ll,ll>;
using vpllll=vector<pair<ll,ll>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    char a;
    cin>>a;
    if(a>='a'&&a<='z')cout<<'a'<<endl;
    else cout<<"A"<<endl;
    return 0;
}




Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main()
{
    string s;
    int n, m;
    cin >> n >> m;
    if  ( m > n ) swap(n,m);
    for (int i= 1; i<= n ; i ++)
    {
        s += char(m+48);
    }
    cout << s;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split(" ")))

def print_list(A):
    for a in A[:-1]:
        print ("%d "%a, end="")
    print(A[-1])

def SelectionSort(A, N):
    count = 0
    for i in range(N):
        minj = i
        for j in range(i, N):
            if A[j] < A[minj]:
                minj = j
        if minj != i:
            v = A[i]
            A[i] = A[minj]
            A[minj] = v
            count += 1
    return A, count
        
A_sorted, c = SelectionSort(A, N)

print_list(A_sorted)
print(c)

Measured memory_bytes: 7752