akhauriyash/Code-Regression huggingface dataset:
import sys
x, y = map(int,input().split())

if (x + y)%3:
  print(0)
  sys.exit()

n = y - (x+y)//3
m = x - (x+y)//3

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = m+n
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

print(cmb(m+n,n,mod))

Measured memory_bytes: 87972
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct work{
    char name[100];
    int time;
}work;

work Q[LEN];
int head,tail,n;

void enqueue(work w){
    Q[tail]=w;
    tail=(tail+1)%LEN;
}

work dequeue(){
    work w=Q[head];
    head=(head+1)%LEN;
    return w;
}

int min(int a,int b){
    return a<b?a:b;
}

int main(){
    int time_sum=0,time_use;
    int i,q;
    work wait_work,working;

    scanf("%d%d",&n,&q);
    for(i=0;i<n;i++){
        scanf("%s",wait_work.name);
        scanf("%d",&wait_work.time);
        enqueue(wait_work);
    }
    while(head!=tail){
       working=dequeue();
       time_use=min(working.time,q);
       time_sum+=time_use;
       working.time-=time_use;
       if(working.time>0){
            enqueue(working);
       }else{
            printf("%s %d\n",working.name,time_sum);
       }
    }
    return 0;
}

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

const long long mod = 1e9+7;

int main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  
  long long ans = 1;
  for(long long i = 1; i <= n; i++)
  {
    ans *= i;
    ans %= mod;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    cout << a-b+1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  cin>>N;
  const int M=N;
  long long int l[M]={};
  l[0]=2;
  l[1]=1;
  for(int i=2;i<=M;i++){
    l[i]=l[i-1]+l[i-2];
  }
  cout<<l[M]<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.HashMap;
public class Main{
	static int n;
	static int m;
	static boolean[] re;
	static HashMap<Integer,Integer>[] map;
	static int[] cor;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		m = sc.nextInt();
		re=new boolean[n+1];
		cor=new int[n+1];
		int[] l = new int[m];
		int[] r = new int[m];
		int[] d = new int[m];
		for(int i = 0; i < m; i++){
			l[i]=sc.nextInt();
			r[i]=sc.nextInt();
			d[i]=sc.nextInt();
		}
		map=new HashMap[n+1];
		for(int i=0; i<=n; i++){
			map[i]=new HashMap<>();
		}
		for(int i = 0; i<m; i++){
			map[l[i]].put(r[i],d[i]);
			map[r[i]].put(l[i],-d[i]);
		}
		for(int i = 1; i<=n; i++){
			if(!re[i]){
				boolean flag=dfs(i,0);
				if(!flag){
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
	}
	public static boolean dfs(int i,int pos){
		if(re[i]){
			return pos==cor[i];
		}
		re[i]=true;
		cor[i]=pos;
		for(Integer w: map[i].keySet()){
			if(!dfs(w,map[i].get(w)+pos)){
				return false;
			}
		}
		return true;
	}
}

Measured memory_bytes: 195204
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N,K; cin>>N>>K;
  vector<long long>A(N);
  long long minimum=100000000000;
  vector<long long>B(N-1);
  for(int i=0;i<N;i++){
    cin>>A[i];
    if(i!=0){
      B[i-1]=A[i]-minimum;
    }
    minimum=min(minimum,A[i]);
  }
  sort(B.begin(),B.end());
  reverse(B.begin(),B.end());
  int ans=0;
  for(int i=0;i<N-1;i++){
    if(B[i]==B[0])ans++;
    else break;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4812
#include<set>
#include<map>
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cstring>
#include<math.h>
using namespace std;

string s;
int p = 0, n = 0;
int main()
{
	
	cin >> s;
	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] == '+') p++;
		else if (s[i] == '-') n++;
	}
	printf("%d\n", p - n);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(a) int((a).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

#define _deb(x) cout<<x;
void _print() {cerr << "]\n";} template <typename T, typename... V>void _print(T t, V... v) {_deb(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
template <class T, class U> void print_m(const map<T,U> &m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}
template<class T, class U>void debp(const pair<T, U> &pr, bool end_line=1){cout<<"{"<<pr.first<<" "<<pr.second<<"}"; cout<<(end_line ? "\n" : ", ");}
template <class T> void print_vp(const T &vp, int sep_line=0){if(vp.empty()){cout<<"Empty"<<endl; return;}if(!sep_line) cout<<"{ ";for(auto x: vp) debp(x,sep_line);if(!sep_line) cout<<"}\n";cout<<endl;}
template <typename T>void print(const T &v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<sz(v); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<endl;}
template <typename T>void print_vv(const T &vv){if(sz(vv)==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<sz(*vv.begin()); j++)cout<<setw(w)<<j<<" ";cout<<endl;int i = 0;for(auto &v: vv){cout<<i++<<" {";for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<"},\n";}cout<<endl;}

const int nax = 2e5+10;
vi cur;
vb vis;
vi a;
ll n,k;
int last = 0;

void dfs(int x){
    if(vis[x]){
        last = x;
        return;
    }
    vis[x] = 1;
    cur.push_back(x);
    dfs(a[x]);
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n>>k;
    a.resize(n+1);
    vis.resize(n+1);
    fore(i,1,n+1)
        cin>>a[i];

    dfs(1);

    ll sz = sz(cur);

    // print(cur);

    if(k<sz){
        cout<<cur[k]<<endl;
        return 0;
    }

    k-=(sz);

    vi nw;
    bool found = false;
    for(auto x: cur){
        if(x==last) found = true;
        if(found){
            nw.push_back(x);
        }
    }
    
    int nsz = sz(nw);
    k%=nsz;
    
    // print(nw);
    // deb(k);

    cout<<nw[k]<<endl;

    // print(cur);


    return 0;
}

Measured memory_bytes: 11240
#include<stdio.h>
int main(){
	int a,b;
	char op;
	while(1){
	scanf("%d %c %d",&a,&op,&b);
	if(op=='?')break;
	printf("%d\n",op=='+'?a+b:op=='-'?a-b:op=='*'?a*b:a/b);
	}
}

Measured memory_bytes: 1792
n=int(input())
if 0<=n<=1:
  print(1)
elif 2<=n<=3:
  print(2)
elif 4<=n<=7:
  print(4)
elif 8<=n<=15:
  print(8)
elif 16<=n<=31:
  print(16)
elif 32<=n<=63:
  print(32)
elif 64<=n<=100:
  print(64)


Measured memory_bytes: 38416
#include <stdio.h>
#include <string.h>

int main(){
	char s[202];
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n*2;i++){
		scanf("%c",&s[i]);
	}
	int a=0,b=0,c=0,d=0;
	for(i=0;i<n*2;i++){
		if(s[i]=='P'){
			a = 1;
		}else if(s[i]=='W'){
			b = 1;
		}else if(s[i]=='G'){
			c = 1;
		}else if(s[i]=='Y'){
			d = 1;
		}
	}
	int temp = a+b+c+d;
	if(temp ==3){
		printf("Three");
	}else{
		printf("Four");
	}
	return 0;
}

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

int main(){
    int n,m;
    cin>>n>>m;
    ll sum=0;
    int a;
    for(int i=0;i<m;i++){
        cin>>a;
        sum+=a;
    }
    ll j=n-sum;
    if(j<0)cout<<-1<<endl;
    else cout<<j<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int n,t1,t2,t3;
bool color[100005],vis[100005];
vector<pair<int,bool> > a[100005];
void dfs(int x,bool c){
	if(vis[x]){
		return;
	}
	color[x]=c;
	vis[x]=1;
	for(int i=0;i<a[x].size();i++){
		if(a[x][i].second){
			dfs(a[x][i].first,!c);
		}else{
			dfs(a[x][i].first,c);
		}
	}
}
int main(){
	cin>>n;
	for(int i=1;i<n;i++){
		cin>>t1>>t2>>t3;
		if(t3%2==0){
			a[t1].push_back({t2,0});
			a[t2].push_back({t1,0});
		}else{
			a[t1].push_back({t2,1});
			a[t2].push_back({t1,1});
		}
	}
	dfs(1,0);
	for(int i=1;i<=n;i++){
		cout<<color[i]<<endl;
	}
	return 0;
} 

Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
const int mod=998244353;
int qpow(int a,int b) {
    int ret=1;
    while(b) {
        if(b&1) ret=1ll*ret*a%mod;
        a=1ll*a*a%mod,b>>=1;
    }
    return ret;
}
int n,m,fac[N],ifac[N];
int C(int n,int m) {
    if(n<0||m<0||n<m) return 0;
    return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
int main() {
    cin>>n>>m;
    if(n<m) swap(n,m);
    fac[0]=1;for(int i=1;i<=2*n;i++) fac[i]=1ll*fac[i-1]*i%mod;
    ifac[2*n]=qpow(fac[2*n],mod-2);
    for(int i=2*n-1;i>=0;i--) ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
    int ans=0;
    for(int i=1;i<=m;i++) ans=(ans+1ll*C(n+m-i-i,n-i)*C(i+i,i)%mod)%mod;
    ans=1ll*ans*qpow(2,mod-2)%mod*qpow(C(n+m,n),mod-2)%mod;
    ans=(ans+n)%mod,printf("%d\n",ans);
    return 0;
}


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

n,m = map(int,raw_input().split())

students = [map(int,raw_input().split()) for _ in range(n)]
checkpoints = [map(int,raw_input().split()) for _ in range(m)]

#%%

for a,b in students:
    idx = -1
    dist = 10**9
    for j in range(m):
        c,d = checkpoints[j]
        manhat = abs(a-c)+abs(b-d)
        if manhat < dist:
            dist = manhat
            idx = j+1
    print(idx)

Measured memory_bytes: 2568
// AOJ
// ALDS1_11_C Breadth First Search
// https://onlinejudge.u-aizu.ac.jp/problems/ALDS1_11_C
#include <bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i, n) for(int i = 0; i < (n); i++)

int main()
{
    int n; cin >> n;
    vvi g(n, vi(n, 0));
    rep(i, n) {
        int u, k; cin >> u >> k; u--;
        rep(j, k) {
            int v; cin >> v; v--;
            g[u][v] = 1;
        }
    }

    vi ans(n, -1);
    queue<int> q;
    q.push(0);
    ans[0] = 0;
    while (!q.empty()) {
        int u = q.front(); q.pop();
        rep(i, n) {
            if (g[u][i] == 1 && ans[i] == -1) {
                q.push(i);
                ans[i] = ans[u]+1;
            }
        }
    }

    rep(i, n) cout << i+1 << " " << ans[i] << endl;
}



Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;

const int MOD = 1e9 + 7;

inline int add(int x, int y){
	int res = x + y;	
	while(res >= MOD)res-=MOD;
	return res;
}

inline int mul(int x,int y){
	return (1LL * x * y) % MOD;
}

int modpow(int x,int p){
	int res = 1;
	while(p){
		if(p&1)gmul(res,x);
		gmul(x,x);
		p/=2;
	}
	return res;
}

inline int invert(int x){
	return modpow(x,MOD - 2);
}

const int N = 4e5 + 5;

int fac[N], inv[N];

void init(int n){
	fac[0] = inv[0] = 1;
	for(int i = 1;i < n; ++i){
		fac[i] = mul(fac[i-1], i);	
		inv[i] = invert(fac[i]); 
	}
}

int comb(int n,int k){
	return mul(fac[n],mul(inv[k], inv[n-k]));	
}


int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n,k;
	cin >> n >> k;
	init(N);
	gmin(k,n-1);
	int ans = 0;
	rep(i,0,k+1){
		gadd(ans, mul(comb(n,i),comb(n-1,(n-i)-1)));
	}
	cout << ans << '\n';
}


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 100010
#define inf 1e9

int main()
{

    ll n;
    string ss;
    cin >> n >> ss;
    if(n%2)
    {

        cout << "No";
        return 0;
    }
    string a, b;
    for(ll i = 0, j = n/2; i < n/2; i++, j++)
    {
        a.pb(ss[i]);
        b.pb(ss[j]);
    }
    if(a==b) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
# 入力高速化
import sys
input = lambda: sys.stdin.readline().rstrip()

# 入力 (0-indexedにしつつ)
h, w, m = map(int, input().split())
hw = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]

# 行/列 で爆破対象の出現回数をカウント
hcount = [0] * h
wcount = [0] * w
for a, b in hw:
  hcount[a] += 1
  wcount[b] += 1

# 出現回数の最大値を求める
hmax = max(hcount)
wmax = max(wcount)

# 爆弾を置く場所の候補数
x = hcount.count(hmax) * wcount.count(wmax)

# 爆破対象を見ていって、そこが爆弾を置く候補だったらxを-1
for a, b in hw:
  if hcount[a] == hmax and wcount[b] == wmax:
    x -= 1

# x=0になるということは、爆破できる対象がhmax+wmaxになる位置が存在しないということ
# 爆弾を置く候補すべてに既に爆破対象が置かれている
if x == 0:
  print(hmax + wmax - 1)
else:
  print(hmax + wmax)


Measured memory_bytes: 68292
//usr/bin/env picoc $0 - $@;exit
#include <stdio.h>
int main(){
	int a,b,c,x,i,j,k,r=0;
	scanf("%d%d%d%d",&a,&b,&c,&x);
	for(i=0;i<=x/500;i++)for(j=0;j<=(x-500*i)/100;j++){
		k=x-500*i-100*j;
		r+=k%50==0&&c>=k/50&&a>=i&&b>=j;
	}
	printf("%d\n",r);
	return 0;
}


Measured memory_bytes: 128
N = int(input())
A = [int(input()) for i in range(N)]
ans = 0
for i in range(N):
    if i != 0:
        if A[i] != 0 and A[i-1] != 0:
            tmp = min(A[i], A[i-1])
            ans += tmp
            A[i] -= tmp
            A[i-1] -= tmp
    ans += A[i] // 2
    A[i] = A[i] % 2
print(ans)


Measured memory_bytes: 7192
#include <stdio.h>

int main()
{
    char s;

    int a=scanf("%s",&s);

    if(s=='A'){
        printf("T");
    }
    else if(s=='C'){
        printf("G");
    }
    else if(s=='G'){
        printf("C");
    }
    else if(s=='T'){
        printf("A");
    }
  return 0;
}

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

const int INF = 1001001001;
//int dist[100005][3];
vector<vector<int>> dist(100005, vector<int>(3));

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>> to(n);
	for (int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		a--; b--;
		to[a].push_back(b);
	}
	int sv, tv;
	cin >> sv >> tv;
	sv--; tv--;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			dist[i][j] = INF;
		}
	}
	queue<pair<int, int>> q;
	q.push(pair<int, int>(sv, 0));
	dist[sv][0] = 0;
	while (!q.empty()) {
		int v = q.front().first;
		int l = q.front().second;
		q.pop();
		for (int u : to[v]) {
			int nl = (l + 1) % 3;
			if (dist[u][nl] != INF) continue;
			dist[u][nl] = dist[v][l] + 1;
			q.push(pair<int, int>(u, nl));
		}
	}
	int ans = dist[tv][0];
	if (ans == INF) ans = -1;
	else ans /= 3;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int K;
  cin >> K;

  if(K%2==0 || K%5==0){
    cout << -1 << endl;
    return 0;
  }

  if(K%7==0)  K/=7;
  K*=9;
  int now=10;
  for(int i=1;;i++){
    now%=K;
    if(now==1){
      cout << i << endl;
      return 0;
    }
    now*=10;
  }

  return 0;
}

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

int main()
{
	int a, b, c;
  	cin >> a >> b >> c;
  
  	if ((a==5 && b==5 && c==7) || (a==5 && b==7 && c==5) || (a==7 && b==5 && c==5))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;
int time(int x){
  return(x+9)/10*10;
}
int over(int x){
  return time(x)-x;
}
int main(){
  int a, b, c, d, e; cin >> a >> b >> c >> d >> e;
  int rsl=0;
  rsl = time(a) + time(b) + time(c) + time(d) + time(e);
  rsl -= max({over(a), over(b), over(c), over(d), over(e)});
  cout << rsl << endl;
}

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

int main() {
  string s;
  cin >> s;
  bool flag = true;
  for(char c='a'; c <= 'z'; c++) {
    int count=0;
    for(int i=0; i<s.size(); i++) {
      if(s[i] == c) count++;
    }
    if(count%2 != 0) flag = false;
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N,M=map(int,readline().split())
    s=[0]*M
    c=[0]*M
    for i in range(M):
        a,b=map(int,readline().split())
        s[i]=a
        c[i]=b

    for n in range(10**N):
        n=str(n)
        if len(n)!=N:
            continue
        for i in range(M):
            if n[s[i]-1]!=str(c[i]):
                break
        else:
            print(n)
            break
    else:
        print(-1)
if __name__=="__main__":
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
struct mat{
  long a,b;
  mat(){}
  mat(long a_,long b_):a(a_),b(b_){}
};
mat dot(mat m1,mat m2){
  return mat(m1.a*m2.a,m1.a*m2.b+m1.b);
}
bool cmp(mat m1,mat m2){
  return dot(m1,m2).b>dot(m2,m1).b;
}

int main(){
  long N,T;cin>>N>>T;
  vector<long>A(N),B(N);
  for(long i=0;i<N;i++)cin>>A[i]>>B[i];
  vector<long>C;vector<mat>M;
  for(long i=0;i<N;i++){
    if(A[i]==0)C.push_back(B[i]+1);
    else M.push_back(mat(A[i]+1,A[i]+B[i]+1));
  }
  
  sort(C.begin(),C.end());sort(M.begin(),M.end(),cmp);  
  vector<long>S(C.size()+1,0);
  for(long i=0;i<C.size();i++)S[i+1]=S[i]+C[i];
  
  //DP準備
    //i個まで見て, j個使う時の経過時間の最小値
  vector<vector<long>>DP(M.size()+1,vector<long>(min(32,(int)M.size()+1),T+1));
  for(long i=0;i<DP.size();i++)DP[i][0]=0; 
  long ans=0;
  for(long i=0;i<DP.size();i++)for(long j=0;j<DP[i].size();j++){  
    if(i!=0&&j!=0)DP[i][j]=min(DP[i-1][j],M[i-1].a*DP[i-1][j-1]+M[i-1].b);
    if(T-DP[i][j]>=0){//Sでbinsearch: S[z]<=T-DP[i][j]となる最大のzを返すと, それが個数
      long l=0,r=C.size()+1;
      while(r-l!=1){
        long z=(l+r)/2;
        if(S[z]<=T-DP[i][j])l=z;
        else r=z;
      }
      ans=max(ans,l+j);
    }
  }
  cout<<ans;
}



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

public class Main {
	static int[] cache;
	public static void main(String[] args) throws IOException{
		// TODO Auto-generated method stub
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String[] inputs=br.readLine().split(" ");
		int a=Integer.parseInt(inputs[0]);
		int b=Integer.parseInt(inputs[1]);
		cache=new int[999];
		cache[0]=1;
		for(int i=1;i<999;i++)
			cache[i]=cache[i-1]+(i+1);
		
		int diff=b-a;
		System.out.println(cache[diff-1]-b);
	}

}


Measured memory_bytes: 24916
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
ll hell=pow(10,15);
void solve(){
	ll n;
	cin>>n;
	vector<ll> v(n+1),per(n+1,0);
	for(ll i=0;i<=n;i++)
	cin>>v[i];
	if(!n){
		if(v[0]==1)
		cout<<"1";
		else
		cout<<"-1";
		exit(0);
	}
	if(v[0]){
		cout<<"-1";
		exit(0);
	}
	per[0]=1;
	for(ll i=1;i<=n;i++){
		per[i]=2*min(per[i-1],hell)-v[i];
		if(per[i]<0){
			cout<<"-1";
			exit(0);
		}
	}
	ll res=v[n],cur=v[n];
	for(ll i=n-1;i>=0;i--){
		ll val=min(per[i],cur);
		if(2*val<cur){
			cout<<"-1";
			exit(0);
		}
		cur=v[i]+val;
		if(!cur){
			cout<<"-1";
			exit(0);
		}
		res+=cur;
	}
	cout<<res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll qc=1;
    for(ll i=1;i<=qc;i++)
    solve();
}


Measured memory_bytes: 5152
#include <stdio.h>

int main(void){
	int n, max, min, sum, s;
	while(1){
		scanf("%d", &n);
		if(n == 0)break;

		max = sum = 0; min =1001;
		for(int i=0; i<n; i++){
			scanf("%d", &s);
			if(s < min) min = s;
			if(max < s) max = s;
			sum += s;
		}
		printf("%d\n", (sum-min-max)/(n-2));
	}//endwhile
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
#define int int64_t
#define rep(i, N) for(int i=0; i<N; i++)
using namespace std;
using pair = pair<int, int>;
using tup  = tuple<int, int, int>;
using vec  = vector<int>;
using vvec = vector<vec>;
// " ", ' '
// std::string str;
// str = std::to_string(int i);

// プロトタイプ宣言
// int myfunc(int, vvec);

// グローバル変数
// int N, M;
// vvec data(N, vec(M));

// 関数：

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	double N;
	double a=0.0;
	double b=0.0;
	cin>>N;
	for(int i=1;i<N+1;i++){
		if(i%2==1){
			a+=1.0;
		}
	}
	b=a/N;
		cout<<b<<endl;
	return(0);
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

#define MOD 1000000007

const int maxn = 1000000 + 10;
int fac[maxn], invfac[maxn];

long long qpow(long long a, long long b){
    long long s = 1;
    while (b > 0) {
        if (b & 1)s = s * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return s;
}
void init() {
    int n = maxn - 1;
    fac[0] = 1;
    for (int i = 1; i <= n; ++i)
        fac[i] = 1ll * fac[i - 1] * i % MOD;
    invfac[n] = qpow(fac[n], MOD - 2);
    for (int i = n - 1; i >= 0; --i) {
        invfac[i] = 1ll * invfac[i + 1] * (i + 1) % MOD;
    }
}
long long comb(int n, int m) {
    if (n < m) return 0;
    return 1ll * fac[n] * invfac[m] % MOD * invfac[n - m] % MOD;
}


int main(){
  init();
  int x, y;
  cin >> x >> y;
  int t = -1;
  for(int i = 0 ; i < x; i++){
    if(i*2 > x || y > i + (x-i*2)*2) break;
    if((x - 2*i)*2 == y-i){
      t = i;
      break;
    }
  }
  if(t == -1){
    cout << 0 << endl;
    return 0;
  }
  cout << comb(t+(x-t*2), t) << endl;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=(a-1); (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll X,Y,Z,K,tmp;
  cin>>X>>Y>>Z>>K;
  vll A,B,C;
  REP(i,X){cin>>tmp;A.push_back(tmp);}
  REP(i,Y){cin>>tmp;B.push_back(tmp);}
  REP(i,Z){cin>>tmp;C.push_back(tmp);}
  sort(ALL(A),greater<ll>());
  sort(ALL(B),greater<ll>());
  sort(ALL(C),greater<ll>());
  vll rank;
  REP(i,X){
    REP(j,Y){
      REP(k,Z){
        if((i+1)*(j+1)*(k+1)>K)break;
        else rank.push_back(A[i]+B[j]+C[k]);
      }
    }
  }
  sort(ALL(rank),greater<ll>());
  REP(i,K)cout<<rank[i]<<"\n";
  return 0;
}

Measured memory_bytes: 1412
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] cur = new int[4];
        for(int i=3;i>=0;i--){
            cur[i] = N%10;
            N = N/10;
        }
        String ans = "No";
        if(cur[0]==cur[1]&&cur[1]==cur[2]) ans = "Yes";
        if(cur[1]==cur[2]&&cur[2]==cur[3]) ans = "Yes";
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){

  int N;
  cin>>N;
  vector<int>P(N);
  vector<int>Q(N);
  for(int i=0;i<=N-1;i++){
  
    cin>>P[i];
  }
  for(int i=0;i<=N-1;i++){
  
    cin>>Q[i];
  }
  int ans=0;
  vector<int>Psort(N);
  for(int i=0;i<=N-1;i++){
  
    Psort[i]=P[i];
  }
  sort(Psort.begin(),Psort.end());
  vector<int>Qsort(N);
  Qsort=Q;
  sort(Qsort.begin(),Qsort.end());
  int countP=1;
  bool flag=0;
  bool findflag=0;
  while(findflag==0){
    flag=1;
    for(int i=0;i<=N-1;i++){
    
      if(P[i]==Psort[i]){
      }
      else {
        flag=0;
        break;
      }
    }
    if(flag==1){
      break;
    }
    else {
      countP++;
      next_permutation(Psort.begin(),Psort.end());
    }
  }
  flag=0;
  int countQ=1;
  while(findflag==0){
    
    flag=1;
    for(int i=0;i<=N-1;i++){
    
      if(Q[i]==Qsort[i]){
      }
      else {
        flag=0;
        break;
      }
    }
    if(flag==1){
      break;
    }
    else {
      countQ++;
      next_permutation(Qsort.begin(),Qsort.end());
    }
  }
  ans=countP-countQ;
  if(ans<0)ans*=-1;
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3552
import sys
input = sys.stdin.readline

n = int(input())

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

a = []

for i in range(2, 55556):
    if is_prime(i) and i % 5 == 1:
        a.append(i)

print(*a[:n])

Measured memory_bytes: 41052
#include<iostream>
using namespace std;
long long n,m,S;
int main()
{
    cin >> n >> m;S=2*n;
    if(S>m) cout << m/2 << endl;
    else if(S==m) cout << n << endl;
    else
	{
        m-=S;m/=4;
        cout << n+m << endl;
    }
    return 0;
}

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

int main(){
	string str;
	int ans;
	
	ans = 0;
	while(cin >> str){
		for(int i = 0; i <= str.size() / 2; i++){
			if(str[i] != str[str.size() - (1 + i)]) break;
			else if(i == str.size() / 2) ans++;
		}
	}
	
	cout << ans << endl;

return 0;
}

Measured memory_bytes: 1184
#include <iostream>
using namespace std;
int main() {
	int x1, x2, x3, x4, y1, y2, y3, y4;

	cin >> x1 >> y1 >> x2 >> y2;
	
	x3 = x2-(y2-y1);
	y3 = y2+(x2-x1);
	x4 = x3 - (y3 - y2);
	y4 = y3 + (x3 - x2);

	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

	return 0;
}

Measured memory_bytes: 888
/*
Keep clam  Believe youself
*/
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<stack>
#include<set>
#include<cmath>
#define Xiaobo main
#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
const int maxn=2e5+7;
const int mod=1e9+7;
const double eps=1e-15;
const double pi=acos(-1);
const int INF=0x3f3f3f3f;
typedef long long ll;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b);}
//别急 dp找状态 问题看看本身的规律 贪心找方法
int Xiaobo()
{
	ll n,a,b;
	cin>>n>>a>>b;
	ll ans=(n/(a+b))*a;
	ans+=min(n%(a+b),a);
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M, Q;
  cin >> N >> M >> Q;
  vector<vector<int>> seg(N + 1, vector<int>());
  for (int i = 1; i <= M; ++i) {
    int l, r;
    cin >> l >> r;
    seg[l].push_back(r);
  }

  for (auto &e : seg) {
    sort(e.begin(), e.end());
  }

  vector<pair<int, int>> pq;
  for (int i = 1; i <= Q; ++i) {
    int p, q;
    cin >> p >> q;
    pq.push_back(make_pair(p, q));
  }

  for (auto &e : pq) {
    int p = e.first;
    int q = e.second;
    int ans = 0;
    for (int i = p; i <= q; ++i) {
      ans += upper_bound(seg[i].begin(), seg[i].end(), q) -
             lower_bound(seg[i].begin(), seg[i].end(), p);
    }
    cout << ans << '\n';
  }
  return 0;
}


Measured memory_bytes: 3060
IDENTIFICATION DIVISION.
PROGRAM-ID. 158A.
 
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP.
   03 S1       PIC X.
   03 S2       PIC X.
   03 S3       PIC X.
 
PROCEDURE DIVISION.
MAIN-001.
  ACCEPT INP.
 
  IF (S1 = S2) AND (S1 = S3)
    DISPLAY 'No'
  ELSE
    DISPLAY 'Yes'
  END-IF.
MAIN-EXIT.
  STOP RUN.


Measured memory_bytes: 892
#include<iostream>
#include<cmath>
#define INF 100000
using namespace std;
bool is_prime[INF+1];
void preprocess(){
  is_prime[0]=is_prime[1]=true;
  for(int i=2;i<sqrt(INF);i++){
    if(is_prime[i]==false){
      for(int j=2*i;j<INF;j+=i)is_prime[j]=true;
    }
  }
}
int main(){
  preprocess();
  int n;
  while(cin>>n,n){
    int cnt=0;
    for(int i=0;i<=n/2;i++){
      //cout << i << " " << is_prime[i] << endl;
      if(is_prime[i]==false && is_prime[n-i]==false)
	cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int h,w;cin>>h>>w;
	vector<string> s(h);
	for(auto&& w:s)cin>>w;
	int cnt=0;
	for(int i=0;i<h;i++){for(int j=0;j<w;j++){if(s[i][j]=='#')cnt++;}}
	if(cnt==h+w-1)cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    N, H = map(int, input().split())
    A = [None]*N
    B = [None]*N
    for i in range(N):
        A[i], B[i] = map(int, input().split())
    
    A_max = max(A)
    B.sort(reverse=True)
    throw_max = 0
    while B[throw_max] >= A_max:
        throw_max += 1
        if throw_max == N:
            break


    count = 0
    Damage = 0
    for i in range(throw_max):
        Damage += B[i]
        count += 1
        if Damage >= H:
            break
    if Damage < H:
        count += int((H - Damage)/A_max)
        if (H - Damage)%A_max != 0:
            count += 1
    print(count)

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

int main(void){
    char s[10];
    int min=1000,x,i=0,j;
    scanf("%s",s);
    while(s[i+2]!='\0'){
        x=0;
        for(j=0;j<3;j++){
            x=x*10+s[i+j]-'0';
        }
        if(min>abs(x-753)){
            min=abs(x-753);
        }
        i++;
    }
    printf("%d\n", min);
    return 0;
}

Measured memory_bytes: 128
# Problem B
a, b, c, d = input().split(' ')
hp_takahashi = int(a)
at_takahashi = int(b)
hp_aoki = int(c)
at_aoki = int(d)

while hp_takahashi > 0 and hp_aoki > 0:
    hp_aoki -= at_takahashi
    if hp_aoki <= 0:
        print('Yes')
        break
    hp_takahashi -= at_aoki
    if hp_takahashi <= 0:
        print('No')
        break


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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

ll N, T;
vector<ll> A;

int main(int argc, char **argv)
{
	cin >> N >> T;
	A.resize(N);
	REP(i, N) cin >> A[i];

	ll mi = A.front();
	map<ll, ll> di;
	for (ll i = 1; i < N; ++i)
	{
		ll tmp = A[i] - mi;
		di[tmp]++;
		mi = min(mi, A[i]);
	}

	std::cout << di.rbegin()->second << std::endl;
}


Measured memory_bytes: 7296
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    h, w, m = i_map()
    num_list = i_row_list(m)

    if h == 1 or w == 1:
        print(m)
        exit()

    h_list = []
    w_list = []

    count = 0

    for num in num_list:
        h_list.append(num[0])
        w_list.append(num[1])

    co_h_list = Counter(h_list)
    co_w_list = Counter(w_list)

    # print(num_list)
    # print(co_h_list.most_common())
    # print(co_w_list.most_common())

    h_max_key = co_h_list.most_common()[0][0]
    h_max_value = co_h_list.most_common()[0][1]

    w_max_key = co_w_list.most_common()[0][0]
    w_max_value = co_w_list.most_common()[0][1]

    if h_max_value > w_max_value:
        max_index = h_max_key
        count = h_max_value

        tmp_list = []
        for num in num_list:
            if num[0] == max_index:
                continue
            tmp_list.append(num[1])

        if len(tmp_list) != 0:
            count += Counter(tmp_list).most_common()[0][1]
    elif h_max_value == w_max_value:
        max_index = h_max_key
        h_count = h_max_value

        tmp_list = []
        for num in num_list:
            if num[0] == max_index:
                continue
            tmp_list.append(num[1])

        if len(tmp_list) != 0:
            h_count += Counter(tmp_list).most_common()[0][1]     


        max_index = w_max_key
        w_count = w_max_value

        tmp_list = []
        for num in num_list:
            if num[1] == max_index:
                continue
            tmp_list.append(num[0])

        if len(tmp_list) != 0:  
            w_count += Counter(tmp_list).most_common()[0][1]

        count = max(h_count, w_count)
    else:
        max_index = w_max_key
        count = w_max_value

        tmp_list = []
        for num in num_list:
            if num[1] == max_index:
                continue
            tmp_list.append(num[0])

        if len(tmp_list) != 0:  
            count += Counter(tmp_list).most_common()[0][1]

    print(count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 262236
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int x1,x2,y1,y2;
	cin>>x1>>y1>>x2>>y2;
	int n; cin>>n;
	if( x1 > x2 ){
		swap(x1,x2);
		swap(y1,y2);
	}
	int fugo = 1;
	if( y1 > y2 ){
		y1 = -y1;
		y2 = -y2;
		fugo = -1;
	}
	const double pi = 3.141592653589793238462643383279;
	vector< pair<int,int> > vec;
	for(int i=0;i<n;i++){
		int xx,yy;
		cin>>xx>>yy;
		yy = yy * fugo;
		if( x1 <= xx && xx <= x2 && y1 <= yy && yy <= y2){
			vec.pb( mp(xx,yy) );
		}
	}
	sort( vec.begin(), vec.end() );
	int wi = min( y2-y1+1, x2-x1+1 );
	vector<int> dp;
	for(int i=0;i<=vec.size();i++){
		dp.pb(LINF);
	}
	for(int i=0;i<vec.size();i++){
		*lower_bound( dp.begin(), dp.end(), vec[i].second ) = vec[i].second;
	}
	int k = lower_bound( dp.begin(), dp.end(), LINF ) - dp.begin();
	double bas = 100.0 * ( abs(x1-x2) + abs(y1-y2) );
	double curve = 20.0 - 5.0 * pi;
	double straight = 10.0 * pi - 20.0;
	if( wi > k ){
		double ans = bas - k * curve;
		cout<<setprecision(20)<<ans<<endl;
	}
	else{
		double ans = bas - (k-1) * curve + straight;
		cout<<setprecision(20)<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 7916
<?php

fscanf(STDIN, "%d%d", $a, $b);

$big = max($a, $b);
$small = min($a, $b);
$ans = 0;
for($i=1;$i<=$small;$i++){
    $ans+=$big;
    if(($ans % $small) ==0){
        echo $ans;
        exit;
    }
}


Measured memory_bytes: 4856
#include <bits/stdc++.h>
using namespace std;
void swap(int &a,int &b){
    int tmp=a;
    a=b;
    b=tmp;
}
void roll(int &dice1,int &dice2,int &dice3,int &dice4){
    swap(dice1,dice2);
    swap(dice2,dice3);
    swap(dice3,dice4);
}
void roll_dice(int a,int (&one)[7])
{
    if (a == 4)//E
        roll(one[1], one[3], one[6], one[4]);
    if (a == 2)//S
        roll(one[1], one[5], one[6], one[2]);
    if (a == 5)//N
        roll(one[1], one[2], one[6], one[5]);
    if (a== 3)//W
        roll(one[1], one[4], one[6], one[3]);
    if (a==6) {
        roll(one[1], one[3], one[6], one[4]);
        roll(one[1], one[3], one[6], one[4]);
    }
}
int main()
{
    int fir;
    int matrix1[7]={0},matrix2[7]={0},tmp[7]={0};
    string m1,m2;
    for(int i=1;i<=6;i++)
        cin>>matrix1[i];
    for(int i=1;i<7;i++)
        cin>>matrix2[i];
        int count=0;
    if(!(tmp[1]==matrix1[1]&&tmp[6]==matrix1[6])){
        for(int i=1;i<7;i++)
        {
            for(int j=0;j<7;j++)
                tmp[j]=matrix2[j];
            roll_dice(i,tmp);
            if(tmp[1]==matrix1[1]&&tmp[6]==matrix1[6])
                count = i;
        }
    }
    if(count==0) cout<<"No"<<endl;
    else {
        roll_dice(count,matrix2);
        int circle[4] = {2, 3, 5, 4};
        for (int i = 0; i < 4; i++) {
            m1 += to_string(matrix1[circle[i]]);
            m2 += to_string(matrix2[circle[i]]);
        };
        m1 += m1;
        cout << (m1.find(m2) == -1 ? "No" : "Yes") << endl;
    }
    return 0;
}


Measured memory_bytes: 3276
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;

int my_abs(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

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

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

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

    int ans, count;
    ans = 0;
    count = 0;
    for (int j = 0; j < N-1; j++) {
        if (masu.at(j) >= masu.at(j + 1)) {
            count++;
        }
        else {
            count = 0;
        }
        if (count >= ans) {
            ans = count;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
A, B = list(map(int, input().split()))

_A, _B = min(A, B), max(A, B)

pres = _A
while True:
    res = _B % _A
    if res == 0:
        break
    else:
        pres = res
        _B = _A
        _A = res

print((A * B) // pres)

Measured memory_bytes: 3060
n,m = map(int,input().split())

if n %2 == 0:
    left = 1
    right = 2*m+1
    al = set()
    for i in range(m):
        if right -left in al:
            right -= 1
        if right-left == n//2:
            right -= 1
        print(left,right)
        outs = n - (right-left)
        al.add(outs)
        left += 1
        right -= 1

else:
    left = 1
    right = 2*m
    for i in range(m):
        print(left,right)
        left += 1
        right -= 1

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


int64_t A, B, N;

int64_t f(int64_t x) {
    return std::floor(A * x / B) - A * std::floor(x / B);
}

int main() {
    std::cin >> A >> B >> N;

    if (N < B) {
        std::printf("%ld\n", f(N));
    } else {
        std::printf("%ld\n", f(B - 1));
    }

    return 0;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
const int INF=999999999;

int main() {
 int A,B;
 string S;
 cin>>A>>B>>S;
 bool ok=false;
 for(int i=0;i<A;i++){if(!(S.at(i)<='9'&&S.at(i)>='0')){cout<<"No"<<endl;return 0;}}
 if(S.at(A)!='-'){cout<<"No"<<endl;return 0;}
 for(int i=A+1;i<A+B;i++){if(!(S.at(i)<='9'&&S.at(i)>='0')){cout<<"No"<<endl;return 0;}}
 cout<<"Yes"<<endl;
 return 0;}

Measured memory_bytes: 256
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>

// container library
#include <deque>
#include <list>
#include <map>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VII;
typedef vector<string> VS;

// container
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define SZ(x) ((int)(x).size())
#define MEMSET(c, v) memset((c), v, sizeof(c))

//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)

// constant
// const ll MOD = 1e9 + 7;
const int INF = static_cast<int>(1e9);
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define debug(x) cout << #x << " = " << x << endl

// --------------------------------------------------------


int main()
{
    int N, A, MIN = INF;
    cin >> N;
    REP(i, N)
    {
        cin >> A;
        int div = 0;
        while (A % 2 == 0) {
            div++;
            A /= 2;
        }
        if (MIN > div) {
            MIN = div;
        }
    }

    cout << MIN << endl;
    return 0;
}

Measured memory_bytes: 256
class UnionFind():

  def __init__(self, n):
    self.par = [i for i in range(n)]
    self.rank = [0] * n

  def find(self, x):
    if self.par[x] != x:
      self.par[x] = self.find(self.par[x])
    return self.par[x]

  def union(self, x, y):
    xroot, yroot = self.find(x), self.find(y)
    if xroot == yroot:
      return False
    elif self.rank[xroot] < self.rank[yroot]:
      self.par[xroot] = yroot
    elif self.rank[xroot] > self.rank[yroot]:
      self.par[yroot] = xroot
    else:
      self.par[yroot] = xroot
      self.rank[xroot] += 1
    return True

  def same(self, x, y):
    return self.find(x) == self.find(y)

n, m = list(map(int, input().split()))
uf = UnionFind(n+1)
ans = 0
for i in range(m):
  x, y, z = list(map(int, input().split()))
  ans += uf.union(x, y)
print(n-ans)

Measured memory_bytes: 73632
/**
 *    author: gxfireball       
**/
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
using namespace std;

void solve(){
   ll n;
   cin >> n;
   if(n%2 != 0) cout << n/2 + 1;
   else cout << n/2;
}

int main(){
    fastio;
    int t;
    t = 1;
    //cin>>t;
    while(t--){
    	solve();
    }
    return 0;
}


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

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;


int main(){
  ll n; cin >> n;
  vi a(n),b(n),c(n);
  rep(i, n) cin >> a[i]; sort(all(a));
  rep(i, n) cin >> b[i]; sort(all(b));
  rep(i, n) cin >> c[i]; sort(all(c));

  ll ans = 0LL;
  rep(i, n){
    ll A = lower_bound(all(a), b[i]) - a.begin();
    ll C = upper_bound(all(c), b[i]) - c.begin();
    ans += A*(n-C);
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
const ll MOD = 1000000007;

int cnt[202020] = {0};
//int ccnt[202020][2];

ll mlpow(ll x, ll p, ll mod) { //x^p(long long)%MOD
    ll tmp = 1;
    if(p == 0) return 1;
    //繰り返し二乗法
    while(p != 0) {
        if(p & 1) tmp = tmp*x % mod;
        x = x*x % mod;
        p = p >> 1;
    }
    return tmp;
}

int main() {
    int N; cin >> N;
    string X; cin >> X;
    queue<ll> ans;
    cnt[0] = 0;
    cnt[1] = 1;
    int pcnt = 0;
    ll ssum = 0, nsum = 0, dsum = 0;
    rep(i,N-1){
        cnt[i+2] = cnt[(i+2)%__builtin_popcount(i+2)]+1;
    }
    rep(i,N) if(X[i] == '1') pcnt++;


    if(pcnt == 0){
        rep(i,N) ans.push(1);
    }else if(pcnt == 1){
        rep(i,N) if(X[i] == '1') ssum = mlpow(2, N-1-i, 2);
        rep(i,N){
            if(X[i] == '1') ans.push(0);
            else{
                ans.push(cnt[(ssum+mlpow(2, N-1-i, 2))%2]+1);
            }
        }
    }else{
        rep(i,N){
            if(X[i] == '1') {
                ssum += mlpow(2, N-1-i, pcnt+1);
                ssum %= pcnt+1;
                dsum += mlpow(2, N-1-i, pcnt-1);
                dsum %= pcnt-1;
            }     
        }
        rep(i,N){
            if(X[i] == '1'){
                ans.push(cnt[(dsum-mlpow(2, N-1-i, pcnt-1)+pcnt-1)%(pcnt-1)]+1);
            }else{
                ans.push(cnt[(ssum+mlpow(2, N-1-i, pcnt+1))%(pcnt+1)]+1);
            }
        }
    }

    while(!ans.empty()) {
        cout << ans.front() << "\n";
        ans.pop();
    }
    return 0;
}


Measured memory_bytes: 6060
#include <iostream>
#include <set>

using namespace std;

typedef long long ll;

const int INF = 1e7;
ll n, m, ans;
ll dp[1<<15];

int main() {
  cin >> n >> m;  
  
  for (int bit = 1; bit < (1<<n); bit++) {
    dp[bit] = INF;
  }
  
  for (int i = 0; i < m; i++) {
    ll a, b;
    cin >> a >> b;
    ll bit = 0;
    for (int j = 0; j < b; j++) {
      ll c;
      cin >> c;
      c--;
      bit += (1<<c);
    }
    dp[bit] = min(dp[bit], a);
  }
  
  for (int bit1 = 1; bit1 < (1<<n)-1; bit1++) {
    for (int bit2 = bit1+1; bit2 < (1<<n); bit2++) {
      dp[bit1 | bit2] = min(dp[bit1 | bit2], dp[bit1] + dp[bit2]);
    }
  }
  
  ans = (dp[(1<<n)-1] == INF) ? -1 : dp[(1<<n)-1]; 
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String c = sc.next();
		char ch = c.charAt(0);
		ch++;
		print(ch);
		sc.close();
	}

	public static void print(Object obj) {
		System.out.println(obj);
	}

}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define ALL(v) v.begin(), v.end()
const int INF = 1e9;
const int MAX = 510000;
const int MOD = 1000000007;
using namespace std;
typedef long long ll;

/*DP使ったほうがよくない？？WOWWOW*/

int main(){
    ll N, K, C; cin>>N>>K>>C;
    string S; cin>>S;
    ll A[K], B[K];
    ll a=0, keya=0, b=K-1, keyb=0;
    for(int i=0; i<N; i++){
        if(S.at(i)=='o' && keya<=0){
            A[a]=i;
            a++;
            keya=C;
        }
        else{
            keya--;
        }
        if(a==K){
            break;
        }
    }
    for(int i=N-1; i>=0; i--){
        if(S.at(i)=='o' && keyb<=0){
            B[b]=i;
            b--;
            keyb=C;
        }
        else{
            keyb--;
        }
        if(b<0){
            break;
        }
    }
    for(int i=0; i<K; i++){
        if(A[i]==B[i]){
            cout<<A[i]+1<<endl;
        }
    }
}

Measured memory_bytes: 4996
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vec> mat;
ll dp[1001][10001];
int main(){
    ll h,n,A[200001],B[200001],inf=1e15;
    cin>>h>>n;
    rep(i,n) cin>>A[i]>>B[i];
    rep(i,h+1) dp[0][i]=inf;
    dp[0][0]=0;
    rep(i,n)rep(j,h+1){
        if(j<A[i]) dp[i+1][j]=min(dp[i][j],B[i]);
        else dp[i+1][j]=min(dp[i][j],dp[i+1][j-A[i]]+B[i]);
    }
    cout<<dp[n][h];
}

Measured memory_bytes: 80512