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

int n;
int a[9][9];
bool ok[9][9];

int main() {
    cin >> n;
    for (int iter = 0; iter < n; ++iter) {
        for (int i = 0; i < 9; ++i) for (int j = 0; j < 9; ++j) {
            cin >> a[i][j];
            ok[i][j] = true;
        }
        for (int i1 = 0; i1 < 3; ++i1) for (int j1 = 0; j1 < 3; ++j1) {
            for (int i2 = 0; i2 < 3; ++i2) for (int j2 = 0; j2 < 3; ++j2) {
                int i = i1 * 3 + i2, j = j1 * 3 + j2;
                int num = a[i][j];
                
                // the mass
                for (int i3 = 0; i3 < 3; ++i3) for (int j3 = 0; j3 < 3; ++j3) {
                    int I = i1 * 3 + i3, J = j1 * 3 + j3;
                    if (I == i && J == j) continue;
                    if (a[I][J] == num) {
                        ok[i][j] = false;
                    }
                }
                
                // the row
                for (int J = 0; J < 9; ++J) {
                    if (J == j) continue;
                    if (a[i][J] == num) {
                        ok[i][j] = false;
                    }
                }
                
                // the col
                for (int I = 0; I < 9; ++I) {
                    if (I == i) continue;
                    if (a[I][j] == num) {
                        ok[i][j] = false;
                    }
                }
            }
        }
        
        for (int i = 0; i < 9; ++i) {
            for (int j = 0; j < 9; ++j) {
                cout << (ok[i][j] ? ' ' : '*');
                cout << a[i][j];
            }
            cout << endl;
        }
        if (iter != n-1) cout << endl;
    }
}


Measured memory_bytes: 1160
num=list(map(int,input().split()))
q=int(input())

def E(ls):
    ls=[ls[3],ls[1],ls[0],ls[5],ls[4],ls[2]]
    return ls

def N(ls):
    ls=[ls[1],ls[5],ls[2],ls[3],ls[0],ls[4]]
    return ls

def R(ls):
    ls=[ls[0],ls[2],ls[4],ls[1],ls[3],ls[5]]
    return ls

for i in range(q):
    num0,num1=list(map(int,input().split()))
    if num.index(num0) in [0,2,3,5]:
        while num[0]!=num0:
            num=E(num)
        while num[1]!=num1:
            num=R(num)
        print(num[2])
    else:
        while num[0]!=num0:
            num=N(num)
        while num[1]!=num1:
            num=R(num)
        print(num[2])
        


Measured memory_bytes: 5604
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int H, W; cin >> H >> W;
  vector<string> field(H);
  rep(i, H) cin >> field[i];

  vector<string> tmp;
  bool flag;
  rep(i, H){
    flag = false;
    rep(j, W) if (field[i][j] == '#') flag = true;
    if (flag) tmp.push_back(field[i]);
  }
  vector<string> ans((int)tmp.size());
  rep(j, W){
    flag = false;
    rep(i, (int)tmp.size()) if (tmp[i][j] == '#') flag = true;
    if (flag) {

      rep(i, (int)tmp.size()) ans[i].push_back(tmp[i][j]);
    }
  }

  rep(i, (int)ans.size()){
    rep(j, (int)ans[i].size()) cout << ans[i][j];
    cout << endl;
  }
}


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

int main()
{
ll k , x ;
cin >> k >> x ;
if(500*k>=x)cout << "Yes" << endl;
else cout << "No" << endl;
return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
h = list(map(int,input().split()))
ans = n
hi = [True] * n
for i in range(m):
    a,b = map(int,input().split())
    if h[a-1] < h[b-1]:
        hi[a-1] = False
    elif h[a-1] > h[b-1]:
        hi[b - 1] = False
    else:
        hi[b - 1] = False
        hi[a - 1] = False

# print(h)
for i in hi:
    if not i:
        ans -= 1

print(ans)

Measured memory_bytes: 20040
#include <stdio.h>

int     main(void)
{
    long a, b;
    long d, r;
    double f;
    
    scanf("%ld%ld", &a, &b);
    
    f =(double) a/(double) b;
    d = a / b;
    r = a % b;
    
    printf("%ld %ld %lf\n", d, r, f);
}


Measured memory_bytes: 2096
// EducationalDPContest.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int INF = 1 << 30;
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
int main()
{
	// C - Vacation
	int n;
	cin >> n;
	vector<vector<int>> dp(n, vector<int>(3, 0));
	int hi[3];
	for (int i = 0; i < n; i++) {
		cin >> hi[0] >> hi[1] >> hi[2];
		if (i == 0) {
			dp[0][0] = hi[0];
			dp[0][1] = hi[1];
			dp[0][2] = hi[2];
		}
		else {
			for (int j = 0; j < 3; j++) {
				for (int k = 0; k < 3; k++) {
					if (j == k)	continue;
					chmax(dp[i][j], dp[i - 1][k] + hi[j]);
					chmax(dp[i][j], dp[i - 1][k] + hi[j]);
				}
			}
		}
	}
	int ans = max(dp[n - 1][0], dp[n - 1][1]);
	ans = max(ans, dp[n - 1][2]);
	cout << ans << endl;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std; typedef long long int ll;
#define all(a) a.begin() , a.end()
#define print(x)   cout<<x<<"\n";
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; if (i != v.size() - 1) os << ", "; } os << "]\n"; return os;}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v)
{os << "["; for (auto it : v) {os << it; if (it != *v.rbegin())os << ", ";} os << "]\n"; return os;}
template <typename T, typename S>
ostream& operator<<(ostream& os, const map<T, S>& v)
{for (auto it : v)os << it.first << " : " << it.second << "\n"; return os;}
template <typename T, typename S>
ostream& operator<<(ostream& os, const pair<T, S>& v)
{os << "("; os << v.first << ", " << v.second << ")"; return os;}
/*******************************************************************************/
const double pi = 3.14159265358979323846L;
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);    freopen("output.txt", "w", stdout);
#endif

    int a, b, h, m;
    cin >> a >> b >> h >> m;
    long double angle = abs((30.0 * h + m * 0.5) - (6.0 * m));
    if (angle > 180.0)
        angle = 360.0 - angle;
    double long cs = (a * a) + (b * b) - 2 * a * b * cos(angle * pi / 180.0);
    cs = sqrt(cs);
    cout << fixed << setprecision(20) << cs << '\n';
}


Measured memory_bytes: 4196
//author-abhijit dey
 //Welcome to my code. btw I hate coding 😉
#include <bits/stdc++.h>
using namespace std;
#define     ff first
#define     ss second
#define     pb push_back
#define     mp make_pair
#define     INF 1000000005
#define     MOD 1000000007
#define     ninf -1000000000
#define     all(c) c.begin(), c.end()
#define     tinput long long int t;cin>>t;
#define     mem(a,x) memset(a,x,sizeof a)
#define     for0(i,n) for(long long int i=0;i<n;i++)
#define     pi 3.141592653589793238462643383279502884
#define     fori(i,a,n) for(long long int i=a;i<n;i++)
#define     forxy(i,x,y) for(int i=x;i<=y;i++)
#define     rfor(i,n) for(long long int i=n-1;i>=0;i--)
#define     ainput for(int i=0; i<n; i++) cin>>a[i];
#define     fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

typedef     long long int ll;
typedef     vector<long long int>vll;
typedef     vector<vector<int> >vvll;
typedef     pair<long long int,long long int>pr;
typedef     vector<pair<long long int,long long int> >vp;

inline long long  min2(long long  a, long long  b)  {return (a)<(b)?(a):(b);}
inline long long  max2(long long  a, long long  b)  {return (a)>(b)?(a):(b);}
inline long long  max3(long long  a, long long  b, long long  c)    {return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  min3(long long  a, long long  b, long long  c)    {return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std::chrono;

ll H,W;
ll dp[1001][1001];
ll a[1001][1001];
ll fun(ll i,ll j)
{
    ll sum=0;
    if(i==H && j==W)return 1;
    if(dp[i][j]!=-1)return dp[i][j];
    if(a[i][j]!=1)
    {
        if(j<W)
        sum=(sum+fun(i,j+1))%MOD;
        if(i<H)
        sum=(sum+fun(i+1,j))%MOD;
    }
    dp[i][j]=sum;
    return dp[i][j];
}

void process()
{
    cin>>H>>W;
    memset(a,0,sizeof(a));
    memset(dp,-1,sizeof(dp));
    for(ll i=1;i<=H;i++)
    {
        for(ll j=1;j<=W;j++)
        {
            char x;cin>>x;
            if(x=='#')a[i][j]=1;
        }
    }
    cout<<fun(1,1);
}
int main()
{
    fastio;
    //tinput;
    //while(t--)
        process();
}


Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }


int main(void){
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    vector<int> pos[26];
    rep(i,n){
        pos[s[i]-'a'].push_back(i);
    }
    ll turn = 0, k = -1;
    rep(i,m){
        if (pos[t[i]-'a'].size() == 0) {
            cout << -1 << endl;
            return 0;
        }
        int index = ub(pos[t[i]-'a'], k);
        if (index == (int)pos[t[i]-'a'].size()) {
            turn++;
            index = ub(pos[t[i]-'a'], -1);
        }
        k = pos[t[i]-'a'][index];
    }
    cout << turn * n + k + 1 << endl;
    return 0;
}


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

#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define lch (o << 1)
#define rch (o << 1 | 1)

typedef double db;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int, int> pint;
typedef tuple<int, int, int> tint;

const int N = 100 + 5;
const int INF = 0x3f3f3f3f;
const ll INF_LL = 0x3f3f3f3f3f3f3f3f;

int a[N];

int main() {
	ios::sync_with_stdio(0);

	int n;
	cin >> n;

	for (int i = 1; i <= n; i++)
		cin >> a[i];
	sort(a + 1, a + n + 1);

	int cnt = 0;
	for (int i = 1; i <= n; i++)
		for (int j = i + 1; j <= n; j++)
			for (int k = j + 1; k <= n; k++) {
				if (a[i] == a[j] || a[j] == a[k]) continue;
				if (a[i] + a[j] > a[k]) cnt++;
			}
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;

struct Linear {
    double a, b;
    double operator() (double x) {
        return a * x + b;
    }
    double cross(const Linear &l) {
        return -(l.b - b) / (l.a - a);
    }
};

int main() {
    int N;
    double C;
    cin >> N >> C;
    vector<double> h(N);
    for(auto &x : h) cin >> x;
    vector<double> p(N, 0.0);
    deque<Linear> q;
    for(int i = 1; i < N; i++) {
        Linear l = {-2.0 * h[i - 1], p[i - 1] + h[i - 1] * h[i - 1]};
        while(q.size() > 1) {
            Linear l1 = q[q.size() - 1], l2 = q[q.size() - 2];
            if(l1.cross(l2) > l1.cross(l)) q.pop_back();
            else break;
        }
        q.push_back(l);
        while(q.size() > 1) {
            Linear l1 = q[0], l2 = q[1];
            if(l1(h[i]) > l2(h[i])) q.pop_front();
            else break;
        }
        Linear optim = q.front();
        p[i] = C + h[i] * h[i] + optim(h[i]);
    }
    cout << (i64)p[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 8388
import collections
if __name__=='__main__':
    s  = input()
    maxs = 0
    r = 0
    for i in s:
        if i == 'R':
            r+=1
        else:
            r = 0
        maxs = max(maxs,r)
    print(maxs)
 

        
        
        
        
        
                    


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

int main(){
    int X,sq,max=0;

    scanf("%d",&X);

    for(int i=1;i<=sqrt(X);i++){
        for(int k=1;k<10;k++){
            sq=1;
            for(int n=1;n<=k;n++){
                if(sq*i>X)break;
                sq=sq*i;
            }
            if(sq>max)max=sq;
        }
    }

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

Measured memory_bytes: 128
def ll():
    return list(map(int,input().split()))
def l():
    return int(input())
n,l = ll()
x = [int(i) for i in range(l, n + l)]
if 0 in x:
    print(sum(x))
elif abs(x[0])<abs(x[-1]):
    print(sum(x)-x[0])
else:print(sum(x)-x[-1])

Measured memory_bytes: 3064
struct Read<R: std::io::BufRead> {
    stdin: R,
    v: Vec<String>,
    i: usize,
}
impl<R: std::io::BufRead> Read<R> {
    pub fn new(stdin: R) -> Self {
        Read {
            stdin: stdin,
            v: Vec::new(),
            i: 0,
        }
    }
    #[allow(dead_code)]
    pub fn read_one_line(&mut self) -> String {
        self.i = 0;
        self.v.clear();
        let mut buf = String::new();
        self.stdin.read_line(&mut buf).unwrap();
        buf.trim().to_owned()
    }
    pub fn read_line(&mut self) {
        self.i = 0;
        self.v.clear();
        let mut buf = String::new();
        self.stdin.read_line(&mut buf).unwrap();
        let buf = buf.trim().to_owned();
        let mut ws = buf.split_whitespace();
        loop {
            let x = ws.next();
            if x.is_none() {
                break;
            }
            let x = x.unwrap().to_owned();
            self.v.push(x);
        }
    }
    #[allow(dead_code)]
    pub fn read_a<T: std::str::FromStr>(&mut self) -> T {
        if self.i == self.v.len() {
            self.read_line();
        }
        let elem = &self.v[self.i];
        self.i += 1;
        elem.parse().unwrap_or_else(|_| panic!())
    }
}

use std::cmp;
use std::collections::HashMap;
fn main() {
    let stdin = std::io::stdin();
    let stdin = std::io::BufReader::new(stdin.lock());
    let mut r = Read::new(stdin);

    let n:usize = r.read_a();
    let mut s:Vec<String> = Vec::new();
    let mut map:HashMap<&str, i32> = HashMap::new();
    for i in 0..n {
        s.push(r.read_a());
    }

    let mut ac = 0;
    let mut wa = 0;
    let mut tle = 0;
    let mut re = 0;

    for i in 0..n {
        if s[i] == "AC" {
            ac+=1;
        }else if s[i] == "WA" {
            wa+=1;
        }else if s[i] == "TLE" {
            tle+=1;
        }else if s[i] =="RE" {
            re+=1;
        }
    }

    println!("AC x {}", ac);
    println!("WA x {}", wa);
    println!("TLE x {}", tle);
    println!("RE x {}", re);

}


Measured memory_bytes: 7536
#include<bits/stdc++.h>
using namespace std;
//size_t f = string::npos
//make pair, tuple

int main(){
      int curr = 0;
      int ans = 0;
      int n;cin >> n;
      string s;cin >> s;
      for(int i = 0;i < n;i++){
            if(s[i] == 'I')curr++;
            else curr--;
            ans = max(ans, curr);
      }
      cout << ans;
}

Measured memory_bytes: 256
def main():
    a, b, c, x, y = map(int, input().split())
    price = {x: a, y: b}
    answer = min(a * x + b * y, max(x, y) * 2 * c, min(x, y) * 2 * c + (max(x, y) - min(x, y)) * price[max(x, y)])
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
import collections
import math


def gcd(a, b):
    while True:
        a, b = b, a % b
        if b == 0:
            break
    return a


def eratosthenes(n):
    sieve = [True for _ in range(n + 1)]
    sieve[0] = False
    sieve[1] = False

    def _update(p):
        if sieve[p]:
            for i in range(p * 2, n + 1, p):
                sieve[i] = False

    if n > 1:
        _update(2)
    p = 3
    while p * p <= n:
        _update(p)
        p += 2
    return sieve


a, b = map(int, input().split())
c = gcd(a, b)

sieve = eratosthenes(math.ceil(math.sqrt(c)))
counter = collections.Counter()
for i in range(1, c):
    if i**2 > c:
        break
    if sieve[i]:
        while c % i == 0:
            counter[i] += 1
            c //= i
if c > 1:
    counter[c] += 1
print(len(counter) + 1)

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


int main()
{
	int a, b;
	cin >> a >> b;

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

Measured memory_bytes: 3108
#include<iostream>
using namespace std;
int n;
char a[101];
int cnt[4];
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] == 'P')cnt[0]++;
		if (a[i] == 'W')cnt[1]++;
		if (a[i] == 'G')cnt[2]++;
		if (a[i] == 'Y')cnt[3]++;
	}
	int total = 0;
	for (int i = 0; i < 4; i++)
		if (cnt[i])total++;
	if (total == 3)cout << "Three";
	else cout << "Four";
	return 0;
}

Measured memory_bytes: 256
// D - Gathering Children
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	string S; cin>>S;
	int N = S.size();
	S += "R";//end LR

	int e = 0, o = 0, l = 0, r = 0;
	int l_pos = -1, r_pos;

	rp(i, 0, N){

		if(i%2) o++; else e++;

		if(S[i]=='R' && S[i+1]=='L'){//RL
			r_pos = i;
			rp(j, l_pos+1, r_pos) cout<<"0 ";
			l_pos = i + 1;
			if(r_pos%2){ r += o; l += e; }
			else{ r += e; l += o; }
			o = e = 0;
		}

		else if(S[i]=='L' && S[i+1]=='R'){//LR
			if(r_pos%2){ r += o; l += e; }
			else{ r += e; l += o; }
			cout<<r<<" "<<l<<(l_pos+1<N?" ":"\n");
			o = e = 0;
			r = l = 0;
		}

	}

	if(l_pos+1<N) rp(i, l_pos+1, N) cout<<(i+1<N?"0 ":"0\n");
}

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

const int DIM = 5e5 + 5;

vector<int> edg[DIM];
priority_queue<int> prq;

int sgt[DIM << 2], pos[DIM], deg[DIM];

void update( int n, int l, int r, int p, int x ) {
    if( l > r || l > p || p > r )
        return;
    
    if( l == p && p == r )
        sgt[n] = x;
    else {
        int m = ( l + r ) >> 1;
        
        update( n << 1, l, m, p, x );
        update( n << 1 | 1, m + 1, r, p, x );
        
        sgt[n] = max( sgt[n << 1], sgt[n << 1 | 1] );
    }
    
    return;
}

int query( int n, int l, int r, int st, int en ) {
    if( l > r || l > en || st > r )
        return 0;
    
    int ans;
    if( st <= l && r <= en )
        ans = sgt[n];
    else {
        int m = ( l + r ) >> 1;
        
        ans = max( query( n << 1, l, m, st, en ),
                   query( n << 1 | 1, m + 1, r, st, en ) );
    }
    
    return ans;
}

int main( void ) {
    
    int n, k;
    cin >> n >> k;
    
    for( int i = 1; i <= n; i ++ ) {
        int x;
        cin >> x;
        
        pos[x] = i;
    }
    
    for( int i = 1; i <= n; i ++ ) {
        int qry1 = query( 1, 1, n, max( 1, pos[i] - k + 1 ), pos[i] );
        int qry2 = query( 1, 1, n, pos[i], min( n, pos[i] + k - 1 ) );
        
        if( qry1 != 0 ) {
            deg[pos[qry1]] ++;
            edg[pos[i]].push_back( pos[qry1] );
        }
        
        if( qry2 != 0 ) {
            deg[pos[qry2]] ++;
            edg[pos[i]].push_back( pos[qry2] );
        }
        
        update( 1, 1, n, pos[i], i );
    }
    
    for( int i = 1; i <= n; i ++ ) {
        if( deg[i] == 0 )
            prq.push( i );
    }
    
    for( int i = n; i >= 1; i -- ) {
        int x = prq.top(); prq.pop();
    
        pos[x] = i;
        for( int y : edg[x] ) {
            deg[y] --;
            
            if( deg[y] == 0 )
                prq.push( y );
        }
    }
    
    for( int i = 1; i <= n; i ++ )
        cout << pos[i] << "\n";
    
    return 0;
}

Measured memory_bytes: 40576
import java.util.*;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();

        int Ws[] = new int[N + 1];
        int Vs[] = new int[N + 1];
        long dp[][] = new long[N + 1][W + 1];
        for(int i = 0;i < N;i++){
            Ws[i] = sc.nextInt();
            Vs[i] = sc.nextInt();
        }

        for(int i = 0;i < N;i++){
            for(int w = 0;w <= W;w++){
                if(w >= Ws[i])
                    dp[i + 1][w] = Math.max(dp[i][w - Ws[i]] + Vs[i],dp[i][w]);
                else
                    dp[i + 1][w] = dp[i][w];
            }
        }

        System.out.println(dp[N][W]);
    }










    public static Integer min(List<Integer> ar){
        int min = 10000;
        int index = 0;
        for(int i = 0; i< ar.size();i++){
            if(min > ar.get(i)){
                min = ar.get(i);
                index = i;
            }
        }
        return min;
    }
}


Measured memory_bytes: 126416
#Nが問題数Mが提出数
N, M = map(int, input().split())
 
submit = []
for _ in range(M):
  temp = [x for x in input().split()]
  submit.append(temp)
 
ac = [0]*(N + 1)
wa = [0]*(N + 1)
  
for i in range(M):
  result = submit[i][1]
  question = int(submit[i][0])
  
  if result == 'AC' and ac[question] == 0:
    ac[question] = 1
  elif result == 'WA' and ac[question] == 0:
    wa[question] += 1
 
for i in range(N + 1):
  if ac[i] != 1:
    wa[i] = 0
 
print(sum(ac), sum(wa))
  

Measured memory_bytes: 27404
#include <stdio.h>
int main(void)
{
    int n;
    scanf("%d",&n);
    int a[n];
    long long int min=1;
    long long int plu=1;
    for(int p=0;p<n;p++)
    {
        scanf("%d",&a[p]);
        if(a[p]%2==0)
        {
            min*=2;
        }
        plu*=3;
    }
    long long int ans=plu-min;
    printf("%lld",ans);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
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; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    ll N;
    cin >> N;
    VLL p(N);
    rep(i,N){
        cin >> p[i];
    }
    ll ans=0;
    ll mini=p[0];
    rep(i,N){
        if(mini>=p[i]){
            mini=p[i];
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4780
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int fly[]={4,1,4,1,2,1,2,1},peo[8],remainder,num=0,point=0;
    while(cin>>peo[0]){
        for(int i=1;i<8;i++)cin>>peo[i];
        for(int i=0;i<8;i++){
            for(int j=0;j<8;j++)if(fly[(i+j)%8]<peo[j])num+=peo[j]-fly[(i+j)%8];
            if(remainder>num||i==0){
                remainder=num;
                point=i;
            }
            else if(remainder==num){
                for(int j=0;j<8;j++){
                    if(fly[(i+j)%8]>fly[(point+j)%8])break;
                    else if(fly[(i+j)%8]<fly[(point+j)%8]){
                        point=i;
                        break;
                        }
                    }
                }
            num=0;
        }
        for(int i=0;i<7;i++)cout<<fly[(point+i)%8]<<" ";
            cout<<fly[(point+7)%8]<<endl;
            point=0;
    }
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a; i<n; i++)
using namespace std;;
 
int main() {
  int N,M; cin >> N >> M;
  vector<bool> firstS(N+1,false);
  vector<bool> secondS(N+1,false);
  
  rep(i,0,M) {
    int x,y; cin >> x >> y;
    if (x == 1) firstS[y] = true;
    if (y == N) secondS[x] = true;
  }
  
  rep(i,1,N+1) {
    if (firstS[i] && secondS[i]) {
      cout << "POSSIBLE" << endl; return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}

Measured memory_bytes: 3628
s=input()
ans=[0]*2
a=int(s[:2])
b=int(s[2:])
if 1<=a<=12:
    ans[0]=1
if 1<=b<=12:
    ans[1]=1

if ans[0]==ans[1]==1:
    print('AMBIGUOUS')
elif ans[0]==ans[1]==0:
    print('NA')
elif ans[0]==1 and ans[1]==0:
    print('MMYY')
else:
    print('YYMM')

Measured memory_bytes: 9140
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))

n,m= m()

print(n%m)


Measured memory_bytes: 6012
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;

int main(){
    double x1,y1,x2,y2,ans;
    cin>>x1>>y1>>x2>>y2;
    ans=pow(x1-x2,2)+pow(y1-y2,2);
    ans=sqrt(ans);
    cout<<fixed<<setprecision(10);
    cout<<ans<<endl;
    return 0;
}


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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

template<typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	long long N;
	scanf("%lld",&N);
	long long M;
	scanf("%lld",&M);
	std::vector<long long> p(M);
	std::vector<std::string> S(M);
	for(int i = 0 ; i < M ; i++){
		scanf("%lld",&p[i]);
		std::cin >> S[i];
	}

	vector<ll> counters(N, 0);
	ll ok = 0;
	ll ps = 0;
	for (ll i = 0; i < M; ++i)
	{
		if (counters[p[i] - 1] < 0)		continue;
		if (S[i] == "AC")
		{
			++ok;
			ps += counters[p[i] - 1];
			counters[p[i] - 1] = -1;
		}
		else
		{
			++counters[p[i] - 1];
		}
	}

	cout << ok << " " << ps << endl;

	return 0;
}


Measured memory_bytes: 7296
# coding: utf-8
# hello worldと表示する
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
x,y=MI()
def nex(a,b,c,d):
    u=max(-(-a//c),-(-b//d))
    return [u*c,u*d]

for i in range(n-1):
    a,b=MI()
    x,y=nex(x,y,a,b)
print(x+y)
    
    
    
    


Measured memory_bytes: 9432
import sys
input = sys.stdin.readline
N,Q = map(int,input().split())
S = list(input())
LR = [list(map(int,input().split())) for _ in range(Q)]
lis = []
s = [0]*N
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        s[i] = 1

L = [0]*(N+1)
R = [0]*N

tmp = 0
for ind,i in enumerate(s):
    if i == 1:
        tmp += 1
    L[ind+1] = tmp

tmp = 0
for i in range(N-2,-2,-1):
    if s[i] == 1:
        tmp += 1
    R[i+1] = tmp

R.append(0)
sums =sum(s)
for i in range(Q):
    ans = sums-L[LR[i][0]-1]-R[LR[i][1]]
    print(ans)

Measured memory_bytes: 71176
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String s = sc.next();
		String t = sc.next();
		int num = 0;
      // 出力
		for (int i= 0;i<s.length();i++){
			if(s.charAt(i)!=t.charAt(i)){
				num++;
            }
        }
     	 System.out.println(num);
	}
}

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

#define INF INT_MAX/2
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long ;

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

   int N,K;
   cin>>N>>K;
   ll ans = 0;
   int x;
   for(int i=0;i<N;i++){
      cin>>x;
      ans+=2*min(abs(K-x),abs(x));
   }
   cout<<ans<<endl;
   return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int>h(n);
  rep(i,n) cin >> h[i];
  int cnt = 0;
  int ans = 0;
  rep(i,n-1) {
    if(h[i]>=h[i+1]) cnt++;
    else cnt = 0;
    ans = max(ans, cnt);
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
        using namespace std;
         
        int main(){
            int r, asw;
            cin >> r;
            
            if (400<=r && r<=599){
              asw = 8;
            }
            else if (600<=r && r<=799){
              asw = 7;
            }
            else if (800<=r && r<=999){
              asw = 6;
            }
            else if (1000<=r && r<=1199){
              asw = 5;
            }
            else if (1200<=r && r<=1399){
              asw = 4;
            }
            else if (1400<=r && r<=1599){
              asw = 3;
            }
            else if (1600<=r && r<=1799){
              asw = 2;
            }
            else if (1800<=r && r<=1999){
              asw = 1;
            }
           
           cout << asw << endl;
        }

Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	long long L,R,D;
	scanf("%lld%lld%lld",&L,&R,&D);
	if(L)
		L--;
	printf("%lld",R/D-L/D);
	return 0;
}

Measured memory_bytes: 3808
import java.util.*;

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

    int n = sc.nextInt();
    int k = sc.nextInt();
    
    Integer[] d = new Integer[k];
    for (int i = 0; i < k; i++) {
      d[i] = sc.nextInt();
    }

    boolean ok = true;
    while (ok) {
      int a1 = n / 10000;
      int a2 = (n % 10000) / 1000;
      int a3 = (n % 1000) / 100;
      int a4 = (n % 100) / 10;
      int a5 = n % 10;

      boolean ng1 = (n >= 10000 ? Arrays.asList(d).contains(a1) : false);
      boolean ng2 = (n >= 1000 ? Arrays.asList(d).contains(a2) : false);
      boolean ng3 = (n >= 100 ? Arrays.asList(d).contains(a3) : false);
      boolean ng4 = (n >= 10 ? Arrays.asList(d).contains(a4) : false);
      boolean ng5 = Arrays.asList(d).contains(a5);

      if (ng1 || ng2 || ng3 || ng4 || ng5) {
        n++;
      } else ok = false;
    }

    System.out.println(n);
  }
}

Measured memory_bytes: 32980
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
const int INF = 1000000000;
int n,m,dp[200][20][100],gc[200];
vector<P> tobu[200];
int main(){
	while(1){
		scanf("%d%d",&n,&m);
		if(n + m == 0)break;
		for(int i = 0;i <= n;i++){
			tobu[i].clear();
		}
		for(int i = 1;i <= n;i++){
			scanf("%d",&gc[i]);
			for(int j = 0;j < gc[i];j++){
				int x,d;
				scanf("%d%d",&x,&d);
				tobu[i].push_back(P(x,d));
			}
		}
		for(int i = 0;i < 200;i++){
			for(int j = 0;j < 20;j++){
				for(int k = 0;k < 100;k++){
					dp[i][j][k] = INF;
				}
			}
		}
		for(int i = 0;i < 20;i++){
			dp[1][i][m] = 0;
			if(m != 0){
				dp[2][i][m-1] = 0;
			}
		}

		for(int i = 1;i <= n;i++){
			for(int j = 0;j < gc[i];j++){
				int nx = tobu[i][j].first,nd = tobu[i][j].second;
				for(int k = 0;k <= m;k++){
					for(int l = 0;l < gc[i+1];l++){
						int tx = tobu[i+1][l].first,td = tobu[i+1][l].second;
						dp[i+1][l][k] = min(dp[i+1][l][k],dp[i][j][k]+(nd+td)*abs(nx-tx));
					}
					if(k == 0)continue;
					for(int l = 0;l < gc[i+2];l++){
						int tx = tobu[i+2][l].first,td = tobu[i+2][l].second;
						dp[i+2][l][k-1] = min(dp[i+2][l][k-1],dp[i][j][k]+(nd+td)*abs(nx-tx));
					}
				}
			}
		}
		int ans = INF;

		for(int i = 0;i < 20;i++){
			for(int j = 0;j <= m;j++){
				ans = min(ans,dp[n][i][j]);
			}
		}
		for(int i = 0;i < 20;i++){
			for(int j = 1;j <= m;j++){
				ans = min(ans,dp[n-1][i][j]);
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}


Measured memory_bytes: 2776
#include <cstdio>
#include <algorithm>
int main(){
    int n;
    int mx=-1;
    int a[100001];
    scanf("%d",&n);
    for (int i=0;i<n;i++){
        scanf("%d",&a[i]);
        if (a[i]>mx){
            mx=a[i];
        }
    }
    int me[2];
    me[0]=me[1]=mx >> 1;
    if (mx & 1){
        ++me[1];
    }
    int ano;
    int diff=mx;
    if ( (mx & 1)==0 ){
        for (int i=0;i<n;i++){
            if (a[i]==mx){
                continue;
            }
            int t=abs(a[i]-me[0]);
            if (t < diff){
                ano=a[i];
                diff=t;
            }
        }
    }
    else {
        for (int i=0;i<n;i++){
            if (a[i]==mx){
                continue;
            }
            int t=abs(a[i]-me[0]);
            if (t < diff){
                ano=a[i];
                diff=t;
            }
            t=abs(a[i]-me[1]);
            if (t < diff){
                ano=a[i];
                diff=t;
            }
        }
    }
    printf("%d %d\n", mx,ano);
    return 0;
}


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

using namespace std;
using ll = long long;

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

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

  vector<int> primes;
  for (int i = 2; i <= 1e3; i++) {
    bool f = true;
    for (auto x : primes) {
      if (i % x == 0)
        f = false;
    }
    if (f)
      primes.push_back(i);
  }

  vector<bool> used(1e6 + 1, false);
  bool f = true;
  for (auto x : a) {
    if (x == 1)
      continue;
    for (auto p : primes) {
      if (x % p != 0)
        continue;
      if (used[p])
        f = false;
      if (x / p != 1 && used[x / p])
        f = false;
      used[p] = true;
      used[x / p] = true;
    }
    if (x > 1e3) {
      if (used[x])
        f = false;
      used[x] = true;
    }
  }

  if (f) {
    cout << "pairwise coprime" << endl;
    return 0;
  }

  int g = a[0];
  for (auto x : a) {
    g = __gcd(g, x);
  }
  if (g == 1) {
    cout << "setwise coprime" << endl;
    return 0;
  }

  cout << "not coprime" << endl;

  return 0;
}


Measured memory_bytes: 7368
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int Q = sc.nextInt();
		int[] A =new int[Q];
		for(int i = 0;i < Q;i++) {
			A[i] = sc.nextInt();
		}
		sc.close();
		int[] point = new int[N];
		for(int i = 0;i < N;i++) {
			point[i] = K - Q;
		}
		for(int i = 0;i < Q;i++) {
			point[A[i]-1]++;
		}
		for(int i = 0;i < N;i++) {
			System.out.println(point[i] > 0 ? "Yes" : "No");
		}
	}
}

Measured memory_bytes: 56800
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#define forn(i, n) for (int64_t i = 0; i < (int64_t) (n); ++i)
#define endl '\n'

template<typename T> void _dbg(const char*_s,T _h) { cerr<<_s<<" = "<<_h<<"\n"; }

template<typename T, typename... Ts> void _dbg(const char*_s,T _h,Ts... _t) {
    for(int _b=0;((_b+=*_s=='(')-=*_s==')')!=0||*_s!=',';)cerr<<*_s++;
    cerr<<" = "<<_h<<",";_dbg(_s+1,_t...);
}

#define int long long

#ifdef LOCAL
    #define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
    #define dbg(...)
#endif

const int N = 500 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n;
int a[N], c[N];

bool read() {
    if (!(cin >> n))
        return false;

    forn (i, n)
        cin >> a[i];

    return true;
}

int getrank(int mask, int nn) {
    for (int b = 59; b >= 0; --b) {
        int j = -1;

        forn (i, nn)
            if ((c[i] >> b) == 1) {
                if (j == -1)
                    j = i;
                else
                    c[i] ^= c[j];
            }
    }

    int res = 0;

    forn (i, nn)
        res += (c[i] != 0);

    return res;
}

bool check(int mask) {
    forn (i, n)
        c[i] = (a[i] & mask);

    auto r1 = getrank(mask, n);

    forn (i, n)
        c[i] = (a[i] & mask);

    c[n] = mask;
    auto r2 = getrank(mask, n + 1);
    return r1 == r2;
}

void solve() {
    int mask = 0, ans = 0;

    for (int b = 59; b >= 0; --b) {
        int cnt = 0;

        forn (i, n)
            cnt += ((a[i] >> b) & 1);

        if (cnt > 0 && cnt % 2 == 0) {
            mask |= (1ll << b);
            
            if (!check(mask))
                mask ^= (1ll << b);
        } else if (cnt > 0) {
            ans += (1ll << b);
        }
    }

    cout << ans + 2ll * mask << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
        solve();

    return 0;
}



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

int main()
{
    /* ------- 宣言と入力 ------- */

    string S, T;
    int A, B;
    string U;

    cin >> S >> T;
    cin >> A >> B;
    cin >> U;

    /* ------- 計算 ------- */

    if (U == S)
    {
        A--;
    }
    else
    {
        B--;
    }

    cout << A << " " << B << endl;

    return 0;
}


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



int main() {
  char a;
  cin >> a;
  
  if(isupper(a)) cout << 'A' << endl;
  else cout << 'a' << endl;
  
  
  return 0;
}

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


#define ll long long
#define MOD 1000000007
#define PI 3.1415


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

    string s;
    cin>>s;

    ll r=0,w=0;
    for(int i=0;i<n;i++){
        if(s.at(i)=='W')w++;
        if(s.at(i)=='R')r++;
    }
    
    
    ll co=0;
    for(int i=0;i<r;i++){
        if(s.at(i)!='R')co++;
    }
    cout<<co<<endl;
}



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


import sys


class FactMod():
    '''
    modの値が素数の時のfactと組み合わせを求める
    フェルマーの小定理を用いているため、modが素数以外の時は使えない
    '''

    def __init__(self, n, mod):
        '''
        コンストラクタ
        f:nまでの i!の値を　配列に入れる
        inv: (i!)^-1　の値を配列に入れる
        '''
        self.mod = mod
        self.f = [1]*(n+1)
        for i in range(1, n+1):
            self.f[i] = self.f[i-1]*i % mod

        self.inv = [pow(self.f[-1], mod-2, mod)]
        for i in range(1, n+1)[::-1]:
            self.inv.append(self.inv[-1]*i % mod)
        self.inv.reverse()

    def fact(self, n):
        '''
        n!の値を返す
        '''
        return self.f[n]

    def comb(self, n, r):
        '''
        nCrの値を返す
        '''
        ret = self.f[n] * self.inv[n-r]*self.inv[r]
        ret %= self.mod
        return ret


# python template for atcoder1
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

n = int(input())
N = n+1
A = list(map(int, input().split()))
MOD = 10**9+7
already = set()
for i, l in enumerate(A):
    if l in already:
        dup_ind = i
        dup_num = l
        break
    else:
        already.add(l)
before_first_dup_num = A.index(dup_num)
after_dup_num = N-dup_ind-1

F = FactMod(n+1, MOD)
for k in range(1, n+2):
    all_pattern = F.comb(N, k)
    rem_pattern = F.comb(before_first_dup_num+after_dup_num,
                         k-1) if before_first_dup_num+after_dup_num >= k-1 else 0
    print((all_pattern-rem_pattern+MOD) % MOD)


Measured memory_bytes: 62420
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w,a,b;
    ll sum=0;
    cin>>h>>w>>a>>b;
    ll ans[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if((i+1)%a==0 && (j+1)%b==0){
                ans[i][j]=-1e3*(a*b-1)-1;
            }
            else{
                ans[i][j]=1e3;
            }
            sum+=ans[i][j];
        }
    }
    if(sum<=0){
        cout <<"No"<<endl;
        return 0;
    }
    cout <<"Yes"<<endl;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3584
#include <stdio.h>

#define pi 3.141592653589

int main()
{
    double r;
    double ar,cf;
    
    r = 0,ar = 0,cf = 0;
    scanf("%lf",&r);
    // printf("%f\n",r);
    ar = r * r * pi;
    cf = r * 2 * pi;
    
    printf("%f %f\n",ar,cf);
}


Measured memory_bytes: 2072
#include <stdio.h>

int main(){
	int ans[100];
	int n;
	double t, s;
	int i=0;
	while(scanf("%d", &n)!=EOF){
		scanf(",%lf,%lf", &t, &s);
		if(t/s/s>=25){
			ans[i]=n;
			i++;
		}
	}
	int m=i;
	for(i=0;i<m;i++){
		printf("%d\n", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

int main() {
	ll a;
	cin>>a;
	ll st=100,i=0;
	while(st<a){
		st+=st/100;
		i++;
	}
	cout<<i;
} 

Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	int K;
	cin >> K;
	if (K == 1) {
		cout << 1 << endl;
		cout << 1 << endl;
		return 0;
	}
	int n = 2 * ((K + 3) / 4);
	int m = 2 * n - K;
	cout << n << endl;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i % 2 == 0) {
				cout << (i + j) % n + 1 << " ";
			}
			else {
				if ((i + j) % n >= n - m) cout << (i + j) % n + 1 << " ";
				else cout << n + (i + j) % n + 1 << " ";
			}
		}
		cout << endl;
	}
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;

signed main(){
    cin>>N;

    set<pint>s;
    s.insert({0,0});

    rep(i,N){
        int x;cin>>x;
        auto it=s.lower_bound({x+1,-1});
        if(it==s.begin()){
            cout<<"No"<<endl;
            continue;
        }
        it--;
        pint p=*it;
        s.erase(it);

        if(p.se<x){
            if(p.fi!=p.se)s.insert({p.fi,p.se-1});
            s.insert({p.se+1,x});
        }
        else{
            if(p.fi!=x)s.insert({p.fi,x-1});
            if(p.se!=x)s.insert({x+1,p.se});
        }
        cout<<"Yes"<<endl;
    }

    return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;

int main() {
    int n;cin >>n;
    vector<P>sc(n);
    for (int i = 0; i < n; ++i) {
        int a,b;cin >>a>>b;
        sc[i]={a,b};
    }
    sort(all(sc));
    reverse(all(sc));
    ll ans=sc[0].first+sc[0].second;
    cout <<ans<<endl;
}


Measured memory_bytes: 3912
n = gets.to_i
r = []
n.times {r << gets.to_i}

min_r = r[0]
max = -Float::INFINITY
(n - 1).times do |i|
  a = r[i + 1]
  dif = a - min_r
  max = dif if dif > max
  min_r = a if a < min_r
end
puts max


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

#define FOR(a, b, c) for (int a = (b), _for = (c); a < _for; ++a)
#define REP(a, n) FOR(a, 0, n)
#define x first
#define y second
#define pb push_back
#define pii pair<int, int>
#define ll long long
#define lf double

using namespace std;

const int MAX = (int)1e6 + 5;

int n,x,y;
vector<int> v[MAX];
int mdep;
bool fin;
int good,bad;

int dfs(int cx,int par,int dep){
	mdep=dep;
	if (cx==y){
		fin=1;
		return 1;
	}
	for (auto nx:v[cx]){
		if (nx==par) continue;
		if (dfs(nx,cx,dep+1)) break;
	}
	if (fin){
		if ((mdep-1)/2==dep) good=cx;
		if ((mdep+1)/2==dep) bad=cx;
		return 1;
	}
	return 0;
}

int ans;
int add;

void d2(int cx,int par,int dep){
	ans=max(ans,dep);
	if (cx==x) add=dep;
	for (auto nx:v[cx]){
		if (nx==par) continue;
		d2(nx,cx,dep+1);
	}
}

int main(){
	scanf ("%d%d%d",&n,&x,&y);
	if (x==y){
		puts ("0");
		return 0;
	}
	x--;y--;
	REP(i,n-1){
		int a,b;
		scanf ("%d%d",&a,&b);
		a--;b--;
		v[a].pb(b);
		v[b].pb(a);
	}
	if ((int)v[x].size()==1 && v[x][0]==y){
		puts ("0");
		return 0;
	}
	dfs(x,-1,0);
	d2(good,bad,0);
	printf ("%d\n",ans+add+!(mdep&1));
	return 0;
}


Measured memory_bytes: 31232