akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.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 drep(i,n,m) for(int i = n;i >= m;i--)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(), v.end()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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


int r;

int main() {

	cin >> r;

	if (r < 1200)cout << "ABC" << endl;
	else if (r < 2800) cout << "ARC" << endl;
	else cout << "AGC" << endl;

	return 0;
}


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

int main(void){
  string b;
  cin>>b;
  int N=b.size();
  int count=0,maximum=0;
  for(int i=0;i<N;i++){
    if(b.at(i)=='A' || b.at(i)=='T' || b.at(i)=='G' || b.at(i)=='C'){
      count++;
      if(count>maximum) maximum=count;
   }
    else count=0;
  }
  cout<<maximum<<endl;
}

Measured memory_bytes: 256
// Problem : A - Not
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
 
#define endl "\n"
#define int long long
#define FAST {ios_base::sync_with_stdio(false);cin.tie(NULL);}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
#define rep(n) for(int i=0;i<(n);i++)
#define rrep(n) for(int i=(n)-1;i>=0;i--)
#define mem(a,b) memset((a),(b),sizeof (a))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define INF (long long) 1e18
#define MOD 1000000007


void solve(){
      int x;
      cin>>x;
      x =(x==0)?1:0;
      cout<<x<<endl;
}

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




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

#define Bye return 0
#define ll long long

using namespace std;

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

    int next = a[0];
    int cont = 1;
    for (int i=1; i<n; i++){
        if(a[i]<=next){
            next = a[i];
            cont++;
        }
    }
    cout<<cont<<endl;
}

int main(){
    solve();
    Bye;
}

Measured memory_bytes: 4344
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;
typedef pair<int,int> P;
set<P> B;
unsigned long long int Count[10];

int main(){
    int H,W,N;
    cin>>H>>W>>N;
    for(int i=0;i<N;i++){
        int a,b;
        cin>>a>>b;
        B.insert(P(b-1,a-1));
    }
    for(auto &p:B){
        int x=p.first, y=p.second;
        for(int cy=-1;cy<=1;cy++){
            for(int cx=-1;cx<=1;cx++){
                int c=0;
                if(x+cx<=0||x+cx>=W-1) continue;
                if(y+cy<=0||y+cy>=H-1) continue;
                for(int dy=-1;dy<=1;dy++){
                    for(int dx=-1;dx<=1;dx++){
                        if(B.find(P(x+cx+dx,y+cy+dy))!=B.end()) c++;
                    }
                }
                Count[c]++;
            }
        }
    }
    Count[0]=W-2;
    Count[0]*=H-2;
    for(int i=1;i<10;i++){
        Count[i]/=i;
        Count[0]-=Count[i];
    }
    for(int i=0;i<10;i++) cout<<Count[i]<<endl;
    return 0;
}

Measured memory_bytes: 4992
/*
Coded by XIZCM
*/

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <iomanip>
#include <vector>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <ctime>
#include <fstream>
#include <stdarg.h>

using namespace std;

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

const bool debug=false;
const bool INJUDGE=false;
const int MAXN=100005;
const int MOD=1000000007;
const int INF=1000000007;

template<class T>T emax(T& a,T b){return a=max(a,b);}
template<class T>T emin(T& a,T b){return a=min(a,b);}
template<class T>void byebye(T info){cout<<info<<endl;exit(0);}
template<class T1,class T2>ostream& operator<<(ostream& out,pair<T1,T2> P){out<<P.first<<" "<<P.second;return out;}
template<class T>ostream& operator<<(ostream& out,vector<T> V){for(int i=0;i<V.size();++i)out<<V[i]<<" ";return out;}

int n;
int a[100005];
int main() {
	scanf("%d",&n);
	for (int i=0;i<n;++i)scanf("%d",a+i);
	sort(a,a+n);
	int po=-1,ne=-1;
	for (int i=0;i<n;i++) {
		if(a[i]>=0 && i>=1) break;
		if(i==n-1) break;
		ne=i+1;
	}
	po=n-ne;
	int res=0;
	for (int i=0;i<ne;i++) {
		res-=a[i];
	}
	for (int i=ne;i<n;i++) {
		res+=a[i];
	}
	cout<<res<<endl;
	int now=0;
	if(ne==po-1) {
		printf("%d %d\n",a[0],a[ne]);
		int now=a[0]-a[ne];
		int ii=1,jj=ne+1,flag=1;
		for (int i=0;i<n-2;i++) {
			if(flag==0) {
				flag=1;
				printf("%d %d\n",a[ii],now);
				now=a[ii++]-now;
			} else {
				flag=0;
				printf("%d %d\n",a[jj],now);
				now=a[jj++]-now;
			}
		}
		return 0;
	}
	if(ne>=po) {
		printf("%d %d\n",a[ne],a[0]);
		now=a[ne]-a[0];
		int jj=ne+1,ii=1,flag=0;
		for (int i=0;i<po*2-2;i++) {
			if(flag==0) {
				flag=1;
				printf("%d %d\n",a[ii],now);
				now=a[ii++]-now;
			} else {
				flag=0;
				printf("%d %d\n",a[jj],now);
				now=a[jj++]-now;
			}
		}
		for (int i=po;i<ne;i++) {
			printf("%d %d\n",now,a[i]);
			now=now-a[i];
		}
		return 0;
	}
	if(ne==1) {
		int now=a[0];
		for (int i=1;i<n-1;i++) {
			printf("%d %d\n",now,a[i]);
			now=now-a[i];
		}
		printf("%d %d\n",a[n-1],now);
	} else {
		printf("%d %d\n",a[ne],a[0]);
		now=a[ne]-a[0];
		int jj=ne+1,ii=1,flag=0;
		for (int i=0;i<ne*2-3;i++) {
			if(flag==0) {
				flag=1;
				printf("%d %d\n",a[ii],now);
				now=a[ii++]-now;
			} else {
				flag=0;
				printf("%d %d\n",a[jj],now);
				now=a[jj++]-now;
			}
		}
		for (int i=jj;i<n-1;i++) {
			printf("%d %d\n",now,a[i]);
			now=now-a[i];
		}
		printf("%d %d\n",a[n-1],now);
		return 0;
	}
	return 0;
}

Measured memory_bytes: 2304
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let S = rl().chars().collect::<Vec<_>>();
    let N = S.len();

    let mut count = 0;
    for i in 0..N / 2 {
        if S[i] != S[N - 1 - i] {
            count += 1;
        }
    }

    println!("{}", count)
}


Measured memory_bytes: 4352
import fractions
a,b = map(int,input().split())
longer = max(a,b)
lcm = fractions.gcd(a,b)
i = 1
ans = 1
while True:
  i += 1
  if i * i >= longer:
    if lcm != 1:
      ans += 1
    break
  elif lcm == 1:
    break

  if lcm % i == 0:
    # print(i)
    ans += 1
    while lcm % i == 0:
      lcm //= i
# print(lcm)
print(ans)

Measured memory_bytes: 5176
N =int(input())
a =list(map(int,input().split()))

key =list(range(N))

def ca_pulse(n):
    return n +1
keys = map(ca_pulse, key)

dic = dict(zip(keys, a))

for k, v in sorted(dic.items(), key=lambda x: x[1]):
    print(k,end=" ")

Measured memory_bytes: 29556
import sys
input = sys.stdin.readline
N,M=[int(x) for x in input().strip().split()]
AN=[]
BN=[]
val={}
for i in range(N):
    Ai,Bi=[int(x) for x in input().strip().split()]
    val[Ai]=Bi+val.get(Ai,0)
    AN.append(Ai)
 
AN=sorted(set(AN))
m=0
ans=0
for Ai in AN:
    ans+=Ai*min(M-m,val[Ai])
    m+=min(M-m,val[Ai])
    if m==M:
        break
print(ans)

Measured memory_bytes: 23044
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int n, wei;
	long int ans, max=1000000;
	int x[1001];
	cin>>n;
	int i, j, k;
	for(i=1;i<=n;i++) cin>>x[i];
	for(wei=1;wei<=100;wei++){
		ans=0;
		for(j=1;j<=n;j++){
			ans+=(x[j]-wei)*(x[j]-wei);
		}
		if(ans<=max) max=ans;
	}
	cout<<max<<endl;
	return 0;
}

Measured memory_bytes: 256
$a=[],$b=[],$c=[],$d=[]
$flag=false

3.times do
  e,f=gets.split.map(&:to_i)
  if e==1
    $a<<=f
  elsif e==2
    $b<<=f
  elsif e==3
    $c<<=f
  elsif e==4
    $d<<=f
  end
  if f==1
    $a<<=e
  elsif f==2
    $b<<=e
  elsif f==3
    $c<<=e
  elsif f==4
    $d<<=e
  end
end

def a_loop(check,de,mae)
  if de >=4
    $flag = true
    return
  end
  if check==1
    $a.each{|i|
      a_loop(2,de+1,1) if i==2 && mae!=2
      a_loop(3,de+1,1) if i==3 && mae!=3
      a_loop(4,de+1,1) if i==4 && mae!=4
    }
  elsif check==2
    $b.each{|i|
      a_loop(1,de+1,2) if i==1 && mae!=1
      a_loop(3,de+1,2) if i==3 && mae!=3
      a_loop(4,de+1,2) if i==4 && mae!=4
    }
  elsif check==3
    $c.each{|i|
      a_loop(1,de+1,3) if i==1 && mae!=1
      a_loop(2,de+1,3) if i==2 && mae!=2
      a_loop(4,de+1,3) if i==4 && mae!=4
    }
  elsif check==4
    $d.each{|i|
      a_loop(1,de+1,4) if i==1 && mae!=1
      a_loop(2,de+1,4) if i==2 && mae!=2
      a_loop(3,de+1,4) if i==3 && mae!=3
    }
  end
end

a_loop(1,1,-1)
a_loop(2,1,-1)
a_loop(3,1,-1)
a_loop(4,1,-1)
if $flag
  puts "YES"
else
  puts "NO"
end

Measured memory_bytes: 1788
x,n = map(int,input().split())
if n == 0:
    print(x)
else:
    p = list(map(int,input().split()))
    
    if x not in p:
        print(x)
    else:

        num1 = x

        for i in range(n):
            num1 += 1
            if num1 not in p:
                dif1 = num1- x
                break

        num2 = x
        for k in range(n):
            num2 -= 1
            if num2 not in p:
                dif2 = x - num2
                break

        if dif1 > dif2:
            print(num2)
        elif dif1 < dif2:
            print(num1)
        elif dif1 == dif2:
            print(num2)


Measured memory_bytes: 61860
// By Shreehari Bodas

#include <bits/stdc++.h>

using namespace std;

const int MOD=1e9+7;

int main(){
	
	int n,k; cin>>n>>k;
	bool a[n];
	for(int i=0;i<n;i++) a[i]=false;
	
	for(int i=0;i<k;i++){
		int d; cin>>d;
		for(int j=0;j<d;j++){
			int x; cin>>x;
			a[x-1]=true;
		}
	}
	
	int count=0;
	for(int i=0;i<n;i++){
		if(a[i]==false) count++;
	}
	
	cout<<count<<endl;

	return 0;
} 

Measured memory_bytes: 3584
#include <iostream>

using namespace std;

int main()
{
    int A,B,C;
    cin>>A>>B>>C;
    if(A==5&&B==5&&C==7)
    {
        cout<<"YES"<<endl;
    }
    else if(A==5&&B==7&&C==5)
    {
        cout<<"YES"<<endl;
    }
    else if(A==7&&B==5&&C==5)
    {
        cout<<"YES"<<endl;
    }
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();

		double theta_min = 6.0*M;
		double theta_hour = 30.0*H+0.5*M;

		double theta = Math.abs(theta_min - theta_hour);

		double result = A*A + B*B - 2*A*B*Math.cos(Math.toRadians(theta));
	    System.out.println(Math.sqrt(result));

	}

}

Measured memory_bytes: 36076
#include <iostream>
#include <vector>
#include <string>

using namespace std;

void a()
{
    int n;
    cin >> n;
    string temp = to_string(n);
    if(temp[0] == '9')
    {
       cout << "Yes" << endl;
        return;
    }else if(temp[1] == '9')
    {
        cout << "Yes" << endl;
        return;
    }
    cout << "No" << endl;
}

void b()
{

}

void c()
{

}

void d()
{

}

int main() {
    a();
    return 0;
}


Measured memory_bytes: 256
/*
贪心，二分答案即可。
原来那个二分太烂了
*/
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<numeric>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int INF=1e9+7;
const int MOD=998244353;
const int N = 1e6 + 5;
const ll inv2=499122177;
const double pi=acos(-1);
ll a[1000005],f[1000005];
ll n,k,ans;
bool cmp(ll a,ll b)
{
	return a>b;
}
bool solve(ll o)
{
	ll sum=0;
	for(ll i=0;i<n;i++)
	{
		ll p=o/f[i];
		if(p<a[i])
			sum+=a[i]-p;
	}
	return sum<=k;
	
}
int main()
{
	ll sum=0;
	scanf("%lld%lld",&n,&k);
	for(ll i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
		sum+=a[i];
	}
	sort(a,a+n);
	for(ll i=0;i<n;i++)
	{
		scanf("%lld",&f[i]);
	}
	sort(f,f+n,cmp);
	ll L=0,R=1e12,mid;
	while(L+1<=R)
	{
		mid=(L+R)/2;
		if(solve(mid))
			R=mid;
		else
			L=mid+1;
	}
	printf("%lld\n",R);
    return 0;
}



Measured memory_bytes: 5888
#include<iostream>
using namespace std;
int n, i, nr, c;
int v[100005];
int main(){
    cin>> n;
    for(i = 1; i <= n; i++){
        cin>> v[i];
        c = max(v[i], c);
    }
    for(i = 1; i <= n; i++){
        if(c - v[i] > 1){
            cout<<"No";
            return 0;
        }
        if(c > v[i]){
            nr++;
        }
    }
    if(nr == 0 && c == n - 1){
        cout<<"Yes";
        return 0;
    }
    if(nr >= c || nr + (n - nr) / 2 < c){
        cout<<"No";
    }
    else{
        cout<<"Yes";
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<int> n(N);
  for (int i = 0; i < N; i++) cin >> n[i];
  sort(n.begin(), n.end());
  int kind = 0;
  int res = 1;
  for (int i = 0; i < N - 1; i++) {
    if (n[i] == n[i + 1]) {
      res++;
    }
    else {
      kind += res % 2;
      res = 1;
    }
  }
  kind += res % 2;
  cout << kind << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char * argv[]) {
    int H,W;
    cin >> H >> W;
    
    vector<string> min(H);
    for(int i=0;i<H;i++)
    {
        cin >> min[i];
    }
    
    vector<vector<int>> ans(H+2,vector<int>(W+2));
    
    for(int i=0;i<H;i++)
    {
        for(int j=0;j<W;j++)
        {
            if(min[i][j] == '#')
            {
                ans[i+1][j+1] = -10000;
                ans[i][j]++;
                ans[i][j+1]++;
                ans[i][j+2]++;
                ans[i+1][j]++;
                ans[i+1][j+2]++;
                ans[i+2][j]++;
                ans[i+2][j+1]++;
                ans[i+2][j+2]++;
            }
            
        }
    }
    
    for(int i=1;i<H+1;i++)
    {
        for(int j=1;j<W+1;j++)
        {
            if(ans[i][j] < 0)
            {
                cout << "#";
            }
            else
            {
                cout << ans[i][j];
            }
        }
        cout << endl;
    }
    cout << endl;
    return 0;
    
}


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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout<<fixed<<setprecision(10);
  ll res=0,buf=0;
  bool judge = true;
  ll a,b,c,d;cin>>a>>b>>c>>d;
  ans(b>d,1,0);
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func min(nums []int) int {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	s := next()
	maxCnt := make([]int, 26)
	cnt := make([]int, 26)
	for _, c := range s {
		if cnt[c-'a'] > maxCnt[c-'a'] {
			maxCnt[c-'a'] = cnt[c-'a']
		}
		for j := range cnt {
			cnt[j]++
		}
		cnt[c-'a'] = 0
	}
	for i := range cnt {
		if cnt[i] > maxCnt[i] {
			maxCnt[i] = cnt[i]
		}
	}
	puts(min(maxCnt))
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

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 T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

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,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {

	ll R;
	std::cin >> R;

	std::cout << std::fixed << std::setprecision(15) << 2 * R * 3.1415926535 << endl;

	return 0;
}


Measured memory_bytes: 3784
#include<stdio.h>

typedef long long int * pint;

int main()
{
  int n;
  scanf("%d", &n);
  
  long long int num[n], cursum[n], sum = 0;
  scanf("%lld", num);
  (*cursum) = (*num);
  for (pint p = num + 1, q = cursum + 1, pd = num + n; p < pd; p++, q++)
  {
  	scanf("%lld", p);
    (*q) = (*(q - 1)) + (*p);
    if ((*q) > (2 << 60)) (*q) %= 1000000007LL;
  }
  
  for (pint p = num + 1, q = cursum, pd = num + n; p < pd; p++, q++)
  {
    sum += (*p) * (*q);
    if (sum > (2 << 60)) sum %= 1000000007;
  }
  
  printf("%lld", sum);
  
  return 0;
}
  


Measured memory_bytes: 6220
#include <stdio.h>
#include <math.h>

int n;
int a[100];
int count;

void print() {
	for (int i = 0; i < n; i ++) {
		if (i > 0) printf(" ");
		printf("%d", a[i]);
	}
	printf("\n");
}

void swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

void bubblesort() {
	for (int i = 0; i < n; i ++) {
		for (int j = n - 1; j >= i + 1; j --) {
			if (a[j] < a[j-1]) {
				swap(&a[j], &a[j-1]);
				count ++;
			}
		}
	}
}

int main(void) {
	scanf("%d", &n);
	for (int i = 0; i < n; i ++) {
		scanf("%d", &a[i]);
	}
	bubblesort();
	print();
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 1036
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"s=t=0\n"
"for _ in[0]*int(input()):a=int(input());s+=(a+t)//2;t=(a+t)%2&(a>0)\n"
"print(s)\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 4800
dp = [[0] * 100100 for i in range(110)]

N, W = map(int, input().split())
w = [0] * N
v = [0] * N
for i in range(N):
    w[i], v[i] = map(int, input().split())

for i in range(1, N+1):
    for sum_w in range(W+1):
        if sum_w - w[i-1] >= 0:
            dp[i][sum_w] = max(dp[i][sum_w], dp[i-1][sum_w-w[i-1]] + v[i-1])
        
        dp[i][sum_w] = max(dp[i][sum_w], dp[i-1][sum_w])

print(dp[N][W])


Measured memory_bytes: 120984
# abc162_d.py
n = int(input())
s = input()
r = s.count("R")
g = s.count("G")
b = s.count("B")
cnt= 0
for i in range(n):
    for j in range(i,n):
        if 2*j-i<n:
            if s[i] != s[j] and s[i] != s[2*j-i] and s[j] != s[2*j-i]:
                cnt += 1
print(r*g*b-cnt)

Measured memory_bytes: 9200
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);

        int a = Integer.parseInt(scan.next());
        String b = scan.next();
        int c = Integer.parseInt(scan.next());
        String answer = "No ";
        String rep = "[^"+(b.charAt(c-1))+"]";
        answer = b.replaceAll(rep,"*");

       PrintWriter out = new PrintWriter(System.out);
        out.println(answer);
        out.flush();
        scan.close();
    }
}

Measured memory_bytes: 21332
#include <stdio.h>

int main(void){
    
    int a,i;
    
    int array[100];
    
    scanf("%d", &a);
    
    for(i=1; i<=a;i++){
        scanf("%d",&array[i]);
    }
    
    for(i=a;i>0;i--){
        if(i>1){
        printf("%d ", array[i]);
        }else printf("%d", array[i]);
    }
    printf("\n");
    
    
    
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  vector<int> t(n);
  for(int i = 0; i < n; i++) cin >> s.at(i) >> t.at(i);
  string x;
  cin >> x;
  
  int ans = 0;
  bool ok = true;
  for(int i = 0; i < n; i++){
    if(s.at(i) == x){
      ok = false;
      continue;
    }
    if(ok) continue;
    ans += t.at(i);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;

int main() {
    int N;
    cin >> N;
    cout << "ABC" << N << endl;
}

Measured memory_bytes: 256
N, X = map(int, input().split())
L = list(map(int, input().split()))
a = 0
li = [0]
for i in range(len(L)):
    a += L[i]
    li.append(a)

ans = 0
for x in li:
    if x <= X:
        ans += 1

print(ans)

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

  int a,b;cin>>a>>b;
  if(a>b)swap(a,b);
  for(int i=a;i<=b;i++)
    if((a*b*i)%2)cout<<"Yes"<<endl,exit(0);
  cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int gcd(int a, int b){
	if(b==0){
		return a;
	}
	return gcd(b, a%b);
}
int a,b;
int32_t main(){
	
	//code
	cin>>a>>b;
	cout<<(a*b)/gcd(a,b)<<endl;
	//code
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin>>s;
	int p=0;
	int l=s.length();
	for(int i=0;i<l;i++)
	{
		if(s[i]=='o')
		{
			p++;
		}
	}
	if((l-p)<=7)
	{
		cout<<"YES"<<endl;
	}
	else
	{
		cout<<"NO"<<endl;
	}
}

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

int main(){
    typedef pair<int, int> P;

    int n, q;
    cin >> n >> q;

    vector<vector<int>> a(n, vector<int>(3));
    int s, t, x;
    for (int i = 0; i < n; i++){
        cin >> s >> t >> x;
        a[i][0] = x;
        a[i][1] = s - x;
        a[i][2] = t - x;
    }
    sort(a.begin(), a.end());

    set<P> p;
    int d;
    for (int i = 0; i < q; i++){
        cin >> d;
        p.insert({d, i});
    }

    vector<int> ans(q, - 1);
    for (int i = 0; i < n; i++){
        x = a[i][0];
        s = a[i][1];
        t = a[i][2];
        auto it = p.lower_bound(P(s, -1));
        while (it != p.end()){
            if (it -> first >= t) break;
            ans[it -> second] = x;
            p.erase(it++);
        }
    }

    for (int i = 0; i < q; i++) cout << ans[i] << endl;
}

Measured memory_bytes: 23040
from fractions import gcd
def dfs(p, q, r, b, s):
    if s == 0: return 1
    x = dfs(p, q, r, b, r[s]) * p[s]
    y = dfs(p, q, r, b, b[s]) * q[s]
    z = x / gcd(x, y) * y
    return z / p[s] + z / q[s]
while 1:
    n = input()
    if n == 0: break
    ret = n*(n+1) / 2
    p = [0]*(n+1); q = [0]*(n+1); r = [0]*(n+1); b = [0]*(n+1)
    for i in range(1, n+1):
        p[i],q[i],r[i],b[i] = map(int, raw_input().split())
        ret -= r[i] + b[i]
    print dfs(p, q, r, b, ret)

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

template<typename T>
struct Seg{
private:
    vector<T> node;
    int n;
    function<T(T,T)> f;
    T def;

public:
    Seg(int siz, T d, function<T(T,T)> f) : def(d), f(f) {
        n = 1;
        while(n < siz)  n *= 2;
        node.resize(2*n-1, def);
    }
    Seg(vector<T> v, T d, function<T(T,T)> f) : def(d), f(f){
        n = 1;
        while(n < v.size())  n *= 2;
        node.resize(2*n-1);
        for(int i = 0; i < v.size(); i++)   node[n-1+i] = v[i];
        for(int i = n-2; i >= 0; i--)   node[i] = f(node[2*i+1], node[2*i+2]);
    }

    void update(int x, T val){
        x += n-1;
        node[x] = f(node[x],val); /* ! */
        while(x){
            x = (x-1)/2;
            node[x] = f(node[2*x+1], node[2*x+2]);
        }
    }

    T query(int a, int b, int k=0, int l=0, int r=-1){
        if(r < 0)   r = n;
        if(b <= l || r <= a)    return def;
        if(a <= l && r <= b)    return node[k];
        T lx = query(a, b, 2*k+1, l, (l+r)/2);
        T rx = query(a, b, 2*k+2, (l+r)/2, r);
        return f(lx, rx);
    }
};

typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> h(n), a(n);
    for(int i = 0; i < n; i++)  cin >> h[i];
    for(int i = 0; i < n; i++)  cin >> a[i];
    vector<int> z = h;
    // z.push_back(0); z.push_back(1<<30);
    sort(z.begin(), z.end());
    z.erase(unique(z.begin(),z.end()),z.end());
    int siz = z.size();
    auto f = [&](int val)->int{
        return lower_bound(z.begin(),z.end(),val)-z.begin();
    };
    Seg<ll> seg(siz, 0, [](ll x, ll y){return max(x,y);});
    for(int i = 0; i < n; i++){
        seg.update(f(h[i]), seg.query(0, f(h[i]))+a[i]);
    }
    cout << seg.query(0, siz+1) << endl;
    return 0;
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n; cin >> n;
  if (n % 2 == 1) {
    cout << ((n-2)*n + 1) / 2 << endl;
    REP(i, n) {
      rep(j, i+1, n) {
        if (i == j) continue;
        if (i + j + 2 == n) continue;
        cout << i+1 << ' ' << j+1 << endl;
      }
    }
  } else {
    cout << ((n-2)*n) / 2 << endl;
    REP(i, n) {
      rep(j, i+1, n) {
        if (i == j) continue;
        if (i + j + 2 == n + 1) continue;
        cout << i+1 << ' ' << j+1 << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
S = input()

t = {
    1: ['L', 'U', 'D'],
    0: ['R', 'U', 'D'],
}

ans = 0

for i in range(len(S)):
    if S[i] in t[i % 2]:
        ans += 1

if ans == len(S):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38384
#include <stdio.h>
#include <stdlib.h>
     
typedef struct{
    int key;
    int left;
    int right;
} Node;
     
void insert(Node*, int, int);
void print1(Node*, int);
void print2(Node*, int);
     
int main()
{
    char s[10];
    Node *t;
    int m;
    int a;
    int i;
    int cnt=0;   
  
    scanf("%d", &m);
  
    t=(Node*)malloc(sizeof(Node)*m);
     
    for(i=0; i<m; i++)
    {
        scanf("%s", &s);
  
        if(s[0]=='i'){scanf("%d", &a);insert(t, cnt, a);cnt++;}
        if(s[0]=='p')
        {
            if(cnt>0) print1(t, 0);
            printf("\n");
            if(cnt>0) print2(t, 0);
            printf("\n");
        }
    }
         
    return 0;
     
}
     
void print1(Node *t, int p)
{
    if(t[p].left>=0)print1(t, t[p].left);
    printf(" %d", t[p].key);
    if(t[p].right>=0)print1(t, t[p].right);
}
     
void print2(Node *t, int p)
{
    printf(" %d",t[p].key);
    if(t[p].left>=0)print2(t,t[p].left);
    if(t[p].right>=0)print2(t,t[p].right);
}
     
void insert(Node *t, int cnt, int z)
{
    int x=0, y;
    if(cnt<1) x=-1;
     
    t[cnt].key = z;
    t[cnt].left = -1;
    t[cnt].right= -1;
     
    while(x>=0){
        y = x; 
        if(z < t[x].key)
            x = t[x].left; 
        else
            x = t[x].right; 
    }
     
    if(cnt<1){}
    else if(z < t[y].key)
    {
        t[y].left = cnt; 
    }
    else {
        t[y].right = cnt;
    }
}

Measured memory_bytes: 7632
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
using namespace std;
int main() {
	string S;
	char T;
	int ans = 0;
	cin >> S;
	T = S[0];
	for (int i = 0; i < S.size(); i++)
	{
		if (T != S[i]) {
			ans++;
			T = S[i];
		}
	}
	cout << ans;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

const ll MAX_N=100010;

ll dp[MAX_N];

ll l_last,N;

string s;

string alp="abcdefghijklmnopqrstuvwxyz";

int main(){
  cin>>N>>s;
  ll ans=0;
  for(l_last=1;l_last<N-1;l_last++){
    ll tmp=0;
    for(ll i=0;i<26;i++){
      bool lfl=false,rfl=false;
      for(ll j=0;j<l_last;j++){
        if(s[j]==alp[i])lfl=true;
      }
      for(ll j=l_last;j<N;j++){
        if(s[j]==alp[i])rfl=true;
      }
      if(lfl&&rfl)tmp++;
    }
    ans=max(ans,tmp);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define input freopen("1.txt","r",stdin);
#define output freopen("output.txt","w",stdout);
#define ll long long int
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
#define pll pair<ll,ll>
#define mp make_pair
#define vpl vector<pll> 
using namespace std;
 
const int mod=1e9+7;
const int maxn=2e5+2;

void solve() {
    int N;
    cin>>N;
    int temp=N;
    while(temp>1000) {
        temp-=1000;
    }
    cout<<1000-temp<<"\n";
}

int main() {
    fast
    int t; 
    t=1;
    while(t--) solve();
    return 0;
}

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

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

const int INF = 1000000007;

int main(void){
	int n; cin>>n;
	map<string, int> mp;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		mp[s]++;
	}
	int m; cin>>m;
	for(int i=0;i<m;i++){
		string t;
		cin>>t;
		mp[t]--;
	}

	int maxv=0;
	for(auto ite = mp.begin();ite != mp.end();ite++){
		maxv = max(maxv, ite->second);
	}

	cout<<maxv<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
main(){
  int n,a,b,c,d,x[400],all,wari,ans[400];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    cin>>b;
    cin>>c;
    cin>>d;
    all=a*c+b*d;
    while(c<5){
      c++;
    }
    while(d<2){
      d++;
    }
    wari=0.8*(double)(a*c+b*d);
    if(all>wari){
      all=wari;
    }
    ans[i]=all;
  }
  for(int i=0;i<n;i++){
    cout<<ans[i]<<endl;
  }
  return(0);
}



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

int main() {
  int N;
  cin >> N;
  bool x = true;
  for(int i=0;i<50000;i++){
    if(floor(i*1.08) == N){
      cout << i << endl;
      x = false;
      break;
    }
  }
    if(x)
      cout << ":(" << endl;
      
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;



int main() {
	string s, t;
	cin >> s >> t;

	vector<int> s_num(26), t_num(26);
	vector<int> s_ple(s.length()), t_ple(t.length());

	int s_cnt = 0;
	int t_cnt = 0;
	char s_che = s[0];
	char t_che = t[0];

	for (int i = 0; i < s.length(); ++i) {
		if (s_che == s[i]) {
			s_cnt++;
			s_che = s[i];
		}
		else {
			s_ple.push_back(s_cnt);
			s_cnt = 1;
			s_che = s[i];
		}
		if (t_che == t[i]) {
			t_cnt++;
			t_che = t[i];
		}
		else {
			t_ple.push_back(t_cnt);
			t_cnt = 1;
			t_che = t[i];
		}
		s_num[s[i] - 'a'] += 1;
		t_num[t[i] - 'a'] += 1;
	}

	int s_sum = 1, t_sum = 1;
	for (int i = 0; i < 26; ++i) {
		if (s_num[i] != 0) {
			s_sum *= s_num[i];
		}
		if (t_num[i] != 0) {
			t_sum *= t_num[i];
		}
	}

	bool flg = true;

	if (s_ple != t_ple || s_sum != t_sum) {
		flg = false;
	}
	else {
		for (int i = 0; i < max(s_ple.size(), t_ple.size()); ++i) {
			if (s_ple[i] != t_ple[i]) {
				flg = false;
				break;
			}
		}
	}

	if (flg) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;
}

Measured memory_bytes: 3816
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (a, b) = (v[0], v[1]);
    println!("{}", max(max(a + b, a - b), a * b));
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
ll a,b,c,k;
ll absx(ll a)
{
	if(a>0)  return a;
	return -a;
}
int main()
{
	cin>>a>>b>>c>>k;
	if(absx(a-b)>=1000000000000000000)
	{
		puts("Unfair");
		return 0;
	}
	else{
		k%=2;
		if(k==0)
		{
			cout<<a-b<<endl;
		}
		else{
			cout<<b-a<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
n,a,b,k=map(int,input().split())
mod=998244353

# コンビネーション、さらに高速。あらかじめO(N)の計算をすることでのちの計算が早くなる
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
g1=[1,1] # g1[i]=i! % mod　:階乗
g2=[1,1] # g2[i]=(i!)^(-1) % mod　:階乗の逆元
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)

def func(na,nb):
  if 0<=na<=n and 0<=nb<=n:
    ret=1
    ret*=cmb(n,na,mod)
    ret%=mod
    ret*=cmb(n,nb,mod)
    ret%=mod
    return ret
  else:
    return 0
ans=0
for na in range(n+1):
  if (k-na*a)%b==0:
    ans+=func(na,(k-na*a)//b)
    ans%=mod
print(ans)

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

int main() {
    int a,b,i,j;
    while (!((a==0)and(b==0))){
        cin >> a >> b;
        for (i=1;i<=a;i++){
            for (j=1;j<=b;j++)
                cout << (((i==1)or(j==1)or(i==a)or(j==b))?'#':'.');
            cout << endl;
        }
        if (!((a==0)and(b==0)))
            cout << endl;
    }
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int cnt=0,ans=0;
	for(int i=0;i<s.size();i++)
		if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T')
			ans++;
		else{
			cnt=max(ans,cnt);
			ans=0;
		}
	cnt=max(ans,cnt);
	cout<<cnt;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    string s; cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) ATYN(true)
    else ATYN(false)

    return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
maps = []
for i in range(h):
	maps.append(str(input()))
row = [False] * h
col = [False] * w
for i in range(h):
	for j in range(w):
		if maps[i][j] == '#':
			row[i] = True
			col[j] = True

for i in range(h):
	if row[i]:
		for j in range(w):
			if col[j]:
				print(maps[i][j], end = '')
		print()


Measured memory_bytes: 4468
# -*- coding: utf-8 -*-
def remainder_2019(l, r):
    min_r = 2019
    for i in range(l, r):
        for j in range(i+1, r+1):
            min_r = min(min_r, (i*j) % 2019)
            if min_r == 0:
                return 0
    return min_r

l, r = map(int, input().split())
if r - l >= 2019:
    print(0)
else:
    print(remainder_2019(l, r))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
typedef long long LL;
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second

using namespace std;

const int mod=1000000007;

LL modpow(int a, LL n){
    LL res=1;
    if (n&1){
        res=a;
    }
    if (n==0){
        return res;
    }
    LL p2=modpow(a,n/2);
    res*=p2;
    res%=mod;
    res*=p2;
    res%=mod;
    return res;
}

LL inv(int a){
    return modpow(a,mod-2);
}

int main(){
    DRII(n,k);
    VL facts(2*n+1,1);
    REP(i,2*n){
        facts[i+1]=(facts[i]*(i+1))%mod;
    }
    LL res;
    if (k>=n-1){
         res=facts[2*n-1] * inv(facts[n]);
         res%=mod;
         res*= inv(facts[n-1]);
         res%=mod;
    }
    else{
        res=0;
        REP(i,k+1){
            LL rr=facts[n];
            rr*=inv(facts[i]);
            rr%=mod;
            rr*=inv(facts[n-i]);
            rr%=mod;
            rr*=facts[n - 1];
            rr%=mod;
            rr*=inv(facts[i]);
            rr%=mod;
            rr*=inv(facts[n - i -1]);
            rr%=mod;
            res+=rr;
            res%=mod;
            //cout<<i<<" "<<rr<<endl;
        }
    }
    printf("%lld\n",res);

}


Measured memory_bytes: 3328
//int -> ll
//http://web.mit.edu/~ecprice/acm/acm08/notebook.html#file12
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include<bits/stdc++.h>
typedef long long ll;
#define x first
#define y second
#define REP(i,sss,eee) for(int i=sss;i<=eee;++i)
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
#define N 1000000007
using namespace __gnu_pbds;
using namespace std;
template <class T>
T MAX(T a, T b){return ((a>b)?a:b);}
template <class T>
T MIN(T a, T b){return ((a<b)?a:b);}
template <class T>
T MOD(T a){return ((a>=0)?a:(-1*a));}
template <class T>
void SWAP(T &a,T &b){T temp=a;a=b;b=temp;}
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
long long ex(long long a, long long b){
	if(b==0||a==1){return 1;}
	if(a==0||b==1){return a;}
	long long tmp=ex(a,(b/2));
	if(b%2){return ((((tmp*tmp)%N)*a)%N);}
	else{return ((tmp*tmp)%N);}
}
long long inv(long long k){
	if(k==1){return 1;}
	else{return ex(k,N-2);}
}
/*****************default********************/
string s,t;
std::vector<std::vector<int>> dp;
int lcs(int n, int m)
{
	if(n<0||m<0){return 0;}
	if(dp[n][m]!=-1){return dp[n][m];}
	if(s[n]==t[m])
	{
		dp[n][m]=(lcs(n-1,m-1)+1);
	}
	else
	{
		dp[n][m]=MAX(lcs(n-1,m),lcs(n,m-1));
	}
	return dp[n][m];
}
string str(int n, int m)
{
	string ans="";
	if(n<0||m<0){return "";}
	if(s[n]==t[m])
	{
		ans=str(n-1,m-1);
		ans+=s[n];
		return ans;
	}
	if(n==0||m==0)
	{
		if(n==0&&m==0)
		{
			if(s[0]==t[0]){ans+=s[0];return ans;}
			else
			{
				return ans;
			}
		}
		else
		{
			if(n==0)
			{
				ans=str(n,m-1);
			}
			else
			{
				ans=str(n-1,m);
			}
			return ans;
		}
	}
	if(dp[n-1][m]>dp[n][m-1])
	{
		ans=str(n-1,m);
	}
	else
	{
		ans=str(n,m-1);
	}
	return ans;
}
int main(){
	cin>>s>>t;
	int n=s.length(),m=t.length();
	dp.resize(n,std::vector<int>(m,-1));
	lcs(n-1,m-1);
	cout<<str(n-1,m-1)<<"\n";
}

Measured memory_bytes: 38016
#define _CRT_SECURE_NO_WARNINGS

#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds

#define eps 1e-6
#define M_PI 3.141592653589793
#define bs 1000000007
#define bsize 350

using namespace std;

const int INF = 1e9;
const int N = 110000;

string st;
int cnt;

int main(){
	//freopen("fabro.in","r",stdin);
	//freopen("fabro.out","w",stdout);
	//freopen("F:/in.txt", "r", stdin);
	//freopen("F:/output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin >> st;
	for (int i = 0; i < st.size(); i++)
	{
		if (i == 0 || st[i] != st[i - 1])
			++cnt;
	}
	cout << cnt - 1<< endl;

	cin.get(); cin.get();
	return 0;
}

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

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


  int counter = 0;
  for (int i = 1; i <= n; ++i) {
    string tmp = to_string(i);
    if (tmp.size() % 2 == 1) ++counter;
    else continue;
  }

  cout << counter << "\n";

  return 0;
}

Measured memory_bytes: 3664
gets
inputs = gets.split(' ').map(&:to_i)
results = inputs

inputs.each_with_index do |input, i|
  k = 0
  results.each_with_index do |result, j|
    k = j
    break if input == result || input <= result
  end

  tmp = results[i]
  results.delete_at(i)
  results.insert(k, tmp)

  puts results.join(' ')
end


Measured memory_bytes: 6892
//  SMOKE SHISHA PLAY FIFA  // 
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007
#define lp(start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;


ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

int main()
{
	fastio
	ll n;
	cin >> n;
	ll arr[n+1];
	ll c1[n+1];
	ll c2[n+1];
	for(ll i=1;i<=n;i++){
		cin >> arr[i];
		c1[i]=0;
		c2[i]=0;
	}
	if(arr[1]<arr[2])
		c1[1]=1;
	if(arr[n]>arr[n-1])
		c2[n]=1;

	for(ll i=2;i<=n-1;i++)
	{
		if(arr[i-1]>=arr[i] && arr[i+1] >= arr[i])
			c1[i]=1;
		if(arr[i-1]<=arr[i] && arr[i+1] <= arr[i])
			c2[i]=1;
	}

	ll val = 1000;
	ll st=0;
	for(ll i=1;i<=n;i++)
	{
		if(c1[i]==1)
		{
			st+= val/arr[i];
			val -= (val/arr[i])*arr[i];
	//		cout << i << "dgsfd"<<  endl;
		}
		if(c2[i]==1)
		{
		//	st -= val/arr[i];
			val += st*arr[i];
			st=0;
	//		cout << i << endl;
		}
	//	deb3(i,st,val);
	}
	cout << val << endl;
	return 0;	
}


Measured memory_bytes: 3660