akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define INF (1LL << 60)
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,z,w;
    cin >> n >> z >> w;
    vl a(n);
    rep(i,n){
        cin >> a[i];
    }
    ll ans = a[n-1]-w;
    if(ans < 0){
        ans = -ans;
    }
    if(n == 1){
        cout << ans << "\n";
        return 0;
    }
    ll hoge = a[n-1] - a[n-2];
    if(hoge < 0){
        hoge = -hoge;
    }
    cout << max(ans,hoge) << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <fstream>
#include <string>
#include <cmath>
#include <algorithm>
#include <time.h>
using namespace std;

int main()
{
	int a, k;
	int cnt = 0;
	cin >> a;
	for (int i = 1; i <= a; i++) {
		cin >> k;
		if ((i*k) % 2)
			cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3628
N = int(input())
A = [int(i) for i in input().split()]

dp = [(0, -1e10)] * (N + 1)
for i in range(N):
    a = max(dp[i][0] + A[i], dp[i][1] - A[i])
    b = max(dp[i][0] - A[i], dp[i][1] + A[i])
    dp[i + 1] = (a, b)

print(dp[N][0])

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    ll ans = 0;
    ll ans2 = 0;
    int p = 0;
    int q;
    rep(i, (n - 2) / 2){
        ans -= a[i] * 2;
        ans2 += a[n - 1 - i] * 2;
        p++;
    }
    q = p;
    rep(i, n % 2 + 1){
        ans -= a[q + i];
        ans2 += a[n - 1 - q - i];
        p++;
    }
    q = p;
    rep(i, (n + 1) % 2){
        ans += a[q + i];
        ans2 -= a[n - 1 - q - i];
        p++;
    }
    q = p;
    rep(i, (n - 1) / 2){
        ans += a[q + i] * 2;
        ans2 -= a[n - 1 - q - i] * 2;
    }
    cout << max(ans, ans2) << endl;
}

Measured memory_bytes: 3772
/*


*/

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

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

#define endl '\n'
#define ld long double
#define ll long long
#define PI acos(-1.0)
#define OO 1e17
#define EPS 1e-12
#define MLOG 20
#define MAX 1* 100 * 1000+5
const int mod = 1e9 + 7;
int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }


void fast(){
#ifndef ONLINE_JUDGE
	freopen("E:\\Competitve\\solving\\input.txt", "r", stdin);
	freopen("E:\\Competitve\\solving\\output.txt", "w", stdout);
#endif
}
int n, k;
int a[MAX][3];
int dp[MAX][3];

int main(){
	//fast();

	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);

	cin >> n;
	for (int i = 1; i <= n; i++){
		for (int j = 0; j < 3; j++){
			cin >> a[i][j];
		}
	}

	for (int i = 0; i < 3; i++)
		dp[n][i] = a[n][i];

	for (int i = n - 1; i >= 1; i--){
		for (int j = 0; j < 3; j++){
			dp[i][j] = a[i][j] + max(dp[i + 1][(j + 1) % 3], dp[i + 1][(j + 2) % 3]);
		}
	}
	int ans = 0;
	for (int i = 0; i < 3; i++){
		ans = max(ans, dp[1][i]);
	}
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 2560
N = int(input())
A,B = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]
am = 0
ab = 0
bu = 0
for i in range(N):
    if P[i]<=A:
        am+=1
    if A+1<=P[i]<=B:
        ab +=1
    if B+1<=P[i]:
        bu+=1

print(min(am,ab,bu))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1

int main() {
  string s;
  cin >>s;
  if(s=="Sunny")
    cout << "Cloudy"<<endl;
  else if(s=="Cloudy")
    cout << "Rainy"<<endl;
  else
    cout << "Sunny"<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
 	long long int a,b,c;
	scanf("%lld %lld %lld",&a,&b,&c);
	if((a*b*c)%2==0) printf("0\n");
	else{
		if(a>b){
			if(c>a){
				printf("%lld\n",a*b);
			}else{
				printf("%lld\n",b*c);
			}
		}else{
			if(c>b){
				printf("%lld\n",a*b);
			}else{
				printf("%lld\n",a*c);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 128
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
B = [int(input()) for i in range(N)]

cards = A[0] + A[1] + A[2]

for b in B:
    cards = [c if c != b else 0 for c in cards]

if (sum(cards[0:3]) == 0):
    print('Yes')
elif (sum(cards[3:6]) == 0):
    print('Yes')
elif (sum(cards[6:9]) == 0):
    print('Yes')
elif ((cards[0] + cards[3] + cards[6]) == 0):
    print('Yes')
elif ((cards[1] + cards[4] + cards[7]) == 0):
    print('Yes')
elif ((cards[2] + cards[5] + cards[8]) == 0):
    print('Yes')
elif ((cards[0] + cards[4] + cards[8]) == 0):
    print('Yes')
elif ((cards[2] + cards[4] + cards[6]) == 0):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38384
#include<stdio.h>

int A[100001],B[100000];
int main(){
  int N;
  long long int ct=0;
  scanf("%d",&N);
  for(int i = 0;i <= N;i++){
    scanf("%d",&A[i]);
  }
  for(int i = 0;i < N;i++){
    scanf("%d",&B[i]);
  }
  for(int i = N;i > 0;i--){
    if(A[i] < B[i-1]){
      int n = B[i-1] - A[i];A[i] = 0;
      A[i-1] -= n;
      ct += (long long int)B[i-1];
      if(A[i-1] < 0){ct += A[i-1];A[i-1] = 0;}
    }
    else{
      A[i] -= B[i-1];
      ct += (long long int)B[i-1];
    }
  }
  printf("%lld\n",ct);
  return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
using namespace std;

int main(){


    string s;
    cin >> s;

    long long b_index = 0;
    long long b_count = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'W'){
            b_index += i;
            b_count ++;
        } 
    }

    if(b_count == 0){
        cout << 0 << endl;
    }
    else {
        cout << b_index - (b_count - 1) * b_count / 2 << endl;
    }


}

Measured memory_bytes: 640
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e3 + 10;
LL getans(LL a, LL b, LL c)
{
	if (min({ a,b,c }) == 0) return INF * INF;
	return max({ a,b,c }) - min({ a,b,c });
}
LL solve(int h, int w)
{
	LL ans = INF * INF;
	for (int i = 1; i <= h; i++)
	{
		ans = min({
			ans,
			getans(1LL * i * w, (h - i) / 2LL * w, (h - i - (h - i) / 2LL) * w),
			getans(1LL * i * w,(h - i) * (w / 2LL),(h - i) * (w - w / 2LL))
			});
	}
	return ans;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int h, w;
	cin >> h >> w;
	cout << min(solve(h, w), solve(w, h)) << endl;
	return 0;
}

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll a, b;
  cin >> a >> b;
  cout << a * b << endl;
	return 0;
}


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

//通过vector数组进行模拟
//利用upper_bound()查找其前边比其大的值进行替换为本值
//没有比其大的值就push_back()此值，拿此值作为另一串的开头。

int main ()
{
    int n;
    cin >> n;
    
    vector <int> v;
    while(n--)
    {
    	int x;
        cin >> x;
        x *= -1;
        int it = upper_bound(v.begin(),v.end(),x)-v.begin();
        if(it == v.size()) v.push_back(x);
        else v[it] = x;
        
        //for(int i = 0; i < v.size(); i++) cout << v[i] << " ";
        //cout << endl;
    }
    
    cout << v.size()<<endl;
    
	return 0;
}

Measured memory_bytes: 892
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  ll x;
  cin >> x;
  
  ll ans = 0;
  ans += x / 11 * 2;
  ll tmp = x % 11;
  if(tmp > 0){
    if(tmp <= 6) {
      ans += 1;
    }else{
      ans += 2;
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int p = sc.nextInt();
		int q = sc.nextInt();
		int r = sc.nextInt();

		if (Math.max(Math.max(p, q), r) == p) {
			System.out.print(q + r);
		} else if (Math.max(Math.max(p, q), r) == q) {
			System.out.print(p + r);
		} else {
			System.out.print(p + q);
		}
	}
}

Measured memory_bytes: 23124
#include<iostream>
#include<algorithm>
#include<deque>
#include<vector>

using namespace std;

#define sz(x) (int)(x.size())
#define fr(i,a,b) for(int i=a;i<b;++i)
//////////////////////

int const N = 2e5 + 41;
int const INF = 1e9 + 41;

vector<int> e[N];
int n, m;
deque<int> q;
int d[N];

void solve(){
	fr(i, 0, N) d[i] = INF;
	cin >> n >> m;	
	fr(i, 0, m){
		int u, v;
		cin >> u >> v;
		--u;--v;
		e[u].push_back(v);
		e[v].push_back(u);
	}
	q.push_back(0);
	d[0] = 0;
	while(sz(q)){
		int cur = q.front();
		q.pop_front();
		fr(i, 0, sz(e[cur])){
			int to = e[cur][i];
			if(d[to] > d[cur] + 1){
				d[to] = d[cur] + 1;
				q.push_back(to);
			}
		}
	}
	if(d[n-1] == 2) cout << "POSSIBLE";
	else cout << "IMPOSSIBLE";
	cout << endl;
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();

	return 0;
}

Measured memory_bytes: 13168
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
struct edge{
  int to,id;
  edge(int to,int id): to(to),id(id) {}
};
 V<edge> g[55];
int main(){
 int n,m;
 cin>>n;
 ll sum=(1ll<<(n-1));
 for(int i=0;i<n-1;i++){
   int a,b;
   cin>>a>>b;
   g[--a].emplace_back(--b,i);
   g[b].emplace_back(a,i);
 }
 set<P> s;
 cin>>m;
 V<P> a(m);
 for(int i=0;i<m;i++){
   cin>>a[i].fi>>a[i].se;
   --a[i].fi;--a[i].se;
 }
 V<ll> idx(m,0);
 for(int i=0;i<m;i++){
   V<int> d(n,1e5);
   d[a[i].fi]=0;
   queue<int> q;
   q.emplace(a[i].fi);
   while(q.size()){
     int now=q.front();
     q.pop();
     for(auto v:g[now]){
       if(d[v.to]>d[now]+1){
         d[v.to]=d[now]+1;
         q.emplace(v.to);
       }
     }
   }
   int val=d[a[i].se];
   sum-=(1ll<<val);
   int cur=a[i].se;
   while(val){
     for(auto v:g[cur]){
       if(d[v.to]==d[cur]-1){
         idx[i]|=(1ll<<v.id);
         val=d[v.to];cur=v.to;
         break;
       }
     }
   }
 }
V<ll> bit(m+1,0);
 for(int i=0;i<(1<<m);i++){
   ll mask=0;
   int d=__builtin_popcount(i);
   for(int j=0;j<m;j++){
       if(i&(1<<j)){
         mask|=idx[j];
       }
   }
   int com=__builtin_popcountll(mask);
   //comは白で塗ると辺の本数
   bit[d]+=(1ll<<(n-1-com));
 }
 ll ans=0;
 for(int i=0;i<=m;i++){
   if(i%2==0)ans+=bit[i];
   else ans-=bit[i];
 }
 cout<<ans<<"\n";
}


Measured memory_bytes: 384
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//数が大きい時のせぐふぉはコードテストで試してみる
//スペルミスに注意
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
	using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll M = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
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;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1)) % M;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else 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;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

int main() {
	ll N,M; cin >> N >> M;
	vector<ll> a(M); rep(i, M) cin >> a[i];

	ll sum = 0;
	rep(i, M) sum += a[i];

	if (sum > N)cout << -1 << endl;
	else cout << N - sum << endl;
}

Measured memory_bytes: 11012
#include <bits/stdc++.h>
using namespace std;
#define rep(i,x,to) for(int i=x;i<to;i++) 
 
int main() {
	int n,m,a[100][100]={},b[100]={};
	cin >> n >> m;
	rep(i,0,n){
		rep(j,0,m){
			cin >> a[i][j];
		}
	}
	rep(i,0,m) cin >> b[i];
	rep(i,0,n){
		int ans = 0;
		rep(j,0,m){
			ans = ans+a[i][j]*b[j];
		}
		cout << ans <<endl;
	}
	return 0;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
#define ll long long
#define maxn 100005
#define endl '\n'
using namespace std;
int arr[maxn];
ll ans[maxn];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for(int i=1;i<=n;i++)
		cin >> arr[i];
	vector<int> idxs(n);
	iota(idxs.begin(),idxs.end(),1);
	sort(idxs.begin(),idxs.end(),[=](int a,int b)->bool
		{return arr[a] != arr[b] ? arr[a] > arr[b] : a < b;});
	arr[n+1] = 0;
	idxs.emplace_back(n+1);

	ll sum = 0;
	int idx = n + 1;
	for(int i=0;i<n;) {
		idx = min(idx,idxs[i]);
		int j = i;
		for(;j<n && arr[idxs[j]] == arr[idxs[i]];j++)
			sum++;
		ans[idx] += sum * (arr[idxs[i]] - arr[idxs[j]]);
		i = j;
	}
	
	for(int i=1;i<=n;i++)
		cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 2680
/* **************************************************** */
/*                      Author : rakati                 */
/* **************************************************** */
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define RP(i,a,b) for(int i = (a); i < (int)(b); i++)
#define RV(i,a,b) for(int i = (a); i > (int)(b); i--)
#define SHOW(v,d) {RP(i,0,v.size()) cout << v[i] << d;cout << '\n';}
#define ALL(x) x.begin(),x.end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
 
const double EPS = 1e-9;
const double PI = 3.14159265359;
const int INF = 1e9;
 
using ll    = long long;
using ull   = unsigned long long;
using vi    = vector<int>;
using vl    = vector<ll>;
using vb    = vector<bool> ;
using vc    = vector<char>;
using vii   = vector<vi>;
using vll   = vector<vl>;
using pii   = pair<int, int>;
using pll   = pair<ll, ll>;
using vpii  = vector<pii>;
using vpll  = vector<pll>;
 
 
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
    int n;
    cin >> n;
    n--;
    ll c[n], s[n], f[n];
    for (int i = 0; i < n; i++) 
        cin >> c[i] >> s[i] >> f[i];
    for (int i = 0; i < n; i++) {
        ll t = 0;
        for (int j = i; j < n; j++) {
            if (t < s[j]) t = s[j];
            else t += (f[j] - t % f[j]) % f[j];
            t += c[j];
        }
        cout << t << endl;
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
import itertools
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

X = I()

if 400 <= X and X <= 599:
    print("8")
elif 600 <= X and X <= 799:
    print("7")
elif 800 <= X and X <= 999:
    print("6")
elif 1000 <= X and X <= 1199:
    print("5")
elif 1200 <= X and X <= 1399:
    print("4")
elif 1400 <= X and X <= 1599:
    print("3")
elif 1600 <= X and X <= 1799:
    print("2")
else:
    print("1")


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

int N, M, R;
int res;

template <typename T>
void warshallFloyd(T& v){
    for (int i = 0; i < v.size(); i++) v[i][i] = 0;

    for (int k = 0; k < v.size(); k++){
		for (int i = 0; i < v.size(); i++){
	    	for (int j = 0; j < v.size(); j++){
				v[i][j] = min(v[i][j], v[i][k]+v[k][j]);
	    	}
		}
    }
}

template <typename T1, typename T2, typename T3>
void f(const T1& v, T2& flg, const T3& r, int dist, int from){
	bool ok = true;
	for (int i = 0; i < r.size(); i++){
		if (flg[r[i]]) continue;
		ok = false;
	}
	if (ok){
		res = min(res, dist);
		return;
	}

	for (int i = 0; i < r.size(); i++){
		if (flg[r[i]]) continue;

		flg[r[i]] = true;
		dist += v[from][r[i]];
		f(v, flg, r, dist, r[i]);
		flg[r[i]] = false;
		dist -= v[from][r[i]];
	}
}

int main(){
	const int INF = 1e9;
	cin >> N >> M >> R;
	vector<int> r(R);
	for (int i = 0; i < R; i++){
		cin >> r[i];
	}
	vector<vector<int>> v(N+1, vector<int>(N+1, INF));
	for (int i = 0; i < M; i++){
		int a, b ,c;
		cin >> a >> b >> c;
		v[a][b] = c;
		v[b][a] = c;
	}

	warshallFloyd(v);

	res = INF;
	map<int, bool> mp;
	for (int i = 0; i < R; i++){
		mp[r[i]] = false;
	}
	for (int i = 0; i < R; i++){
		mp[r[i]] = true;
		int dist = 0;
		f(v, mp, r, dist, r[i]);
		mp[r[i]] = false;
	}

	cout << res << endl;

	return 0;
}


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

struct Sieve {
  vector<int> f, primes; // primesは素数集合，fは合成数に素因数を一つ示したもの
  Sieve(int N):f(N+1,0) {
    f[0] = f[1] = -1;
    for (int i = 2; i <= N; ++i) {
      if (!f[i]==0){
        continue;
      }
      primes.push_back(i);
      f[i] = i;
      if(i>sqrt(N)){
        continue;
      }
      for (int j = i*i; j <= N; j += i) {
        if (f[j]==0){
          f[j] = i;
        }
      }
    }
  }

  bool isPrime(int x) { //xが素数かどうかを判断するメンバ関数
    return f[x] == x;
  }

  vector<int> factorList(int x) { //xの素因数を小さい順ソートされた配列
    vector<int> res;
    if(x==0 || x==1){
      return { };
    }
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }

  vector<pair<int,int>> factor(int x) { //xのfactorListをランレングス圧縮したもの
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<pair<int,int>> res(1, make_pair(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      }
      else {
        res.push_back(make_pair(p, 1));
      }
    }
    return res;
  }

  vector<pair<ll,int>> factor(ll x) {
    vector<pair<ll,int>> res;
    for (int p : primes) {
      int y = 0;
      while (x%p == 0){
        x /= p, ++y;
      }
      if (y != 0){
        res.push_back(make_pair(p,y));
      }
    }
    if (x != 1){
      res.push_back(make_pair(x,1));
    }
    return res;
  }
};

int main(){
  int N;
  cin >> N;
  Sieve S(1e7+5);
  ll ans=0;
  for(int i=1;i<=N;i++){
    vector<pair<int,int>> dvi=S.factor(i);
    ll f=1;
    for(auto x:dvi){
      f*=(x.second+1);
    }
    ans+=(i*f);
  }
  cout << ans << endl;
}

Measured memory_bytes: 46504
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=90;
const int mod=1000000007;
ll f[maxn];
typedef pair<ll,ll> pr;
vector<pr> lv[maxn];
int F(ll a,ll b){
  if(a<b)swap(a,b);
  if(a%b==0)return 1;
  return F(b,a%b)+1;
}
void init(){
  f[0]=1;f[1]=1;
  int tot=1;
  while(f[tot]<=1e18){
    ++tot;f[tot]=f[tot-1]+f[tot-2];
  }
  lv[1].push_back(pr(1,2));lv[1].push_back(pr(1,3));
  ll a,b;
  for(int i=2;i<=tot;++i){
    for(vector<pr>::iterator pt=lv[i-1].begin();pt!=lv[i-1].end();++pt){
      a=pt->first;b=pt->second;
      for(int j=1;j<=2;++j){
	if(b*j+a>f[i+2])break;
	if(F(b,b*j+a)==i){
	  lv[i].push_back(pr(b,b*j+a));
	}
      }
    }
    sort(lv[i].begin(),lv[i].end());
    int N=lv[i].size();
    int cnt=0;
    for(int j=0;j<N;++j){
      if(j==0||lv[i][j]!=lv[i][j-1]){
	lv[i][cnt++]=lv[i][j];
      }
    }//printf("%d\n",cnt);
    lv[i].resize(cnt);
  }
  //  printf("%d %lld\n",tot,f[tot]);
}
void work(ll a,ll b){
  if(a==1||b==1){
    if(a==1){
      printf("%d %d\n",1,b%mod);
    }else{
      printf("%d %d\n",1,a%mod);
    }
    return;
  }
  if(a>b)swap(a,b);
  int t=0;
  while(f[t]<=a&&f[t+1]<=b)++t;
  printf("%d ",t-1);
  if(t-1==1)printf("%d\n",a%mod*1ll*(b%mod)%mod);
  else{
    int ans=0;//printf("%d\n",t-2);
    for(vector<pr>::iterator pt=lv[t-2].begin();pt!=lv[t-2].end();++pt){
      ll x=pt->first,y=pt->second;//printf("%d %d\n",x,y);
      if(x>a||x>b)continue;
      if(y<=a)ans=(ans+(b-x)/y)%mod;
      if(y<=b)ans=(ans+(a-x)/y)%mod;
    }
    printf("%d\n",ans);
  }
}
int main(){
  init();int q;scanf("%d",&q);
  ll a,b;
  while(q--){
    scanf("%lld%lld",&a,&b);
    work(a,b);
  }
  return 0;
}


Measured memory_bytes: 4096
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define MEMSET(a, n, x) REP(i, n) a[i]=x;
#define ARRIN(a, n) REP(i, n) cin>>a[i];
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;

struct qq{
  int y;
  int x;
  int v;
};

int main(){
  int h, w;
  queue<qq> q;
  cin>>h>>w;
  char a[h+2][w+2];
  int t[h+2][w+2];
  REP(i, h+2)REP(j, w+2){
    a[i][j]='#';
    t[i][j]=-1;
  }
  REP(i, h){
    REP(j, w){
      cin>>a[i+1][j+1];
      if(a[i+1][j+1]=='#'){
        q.push({i+1, j+1, 0});
      }
    }
  }
  int ans=0, i, j;
  while(!q.empty()){
    qq p = q.front();
    q.pop();
    i=p.y;
    j=p.x;
    
    ans=max(ans, p.v);
    if(a[i+1][j]=='.'&&t[i+1][j]==-1) t[i+1][j]=p.v+1, q.push({i+1, j, p.v+1});
    if(a[i-1][j]=='.'&&t[i-1][j]==-1) t[i-1][j]=p.v+1, q.push({i-1, j, p.v+1});
    if(a[i][j+1]=='.'&&t[i][j+1]==-1) t[i][j+1]=p.v+1, q.push({i, j+1, p.v+1});
    if(a[i][j-1]=='.'&&t[i][j-1]==-1) t[i][j-1]=p.v+1, q.push({i, j-1, p.v+1});
  }
  ECHO(ans);
  return 0;
}


Measured memory_bytes: 17296
xa = 0
bx = 0
ba = 0
ans = 0
N = int(input())

for _ in range(N):
    s = input()
    ans += s.count("AB")
    if s[0] == "B" and s[-1] == "A":
        ba += 1
    elif s[0] == "B":
        bx += 1
    elif s[-1] == "A":
        xa += 1

if xa == 0 and bx == 0 and ba != 0:
    print(ans+ba-1)
else:
    print(ans+min(xa,bx)+ba)

Measured memory_bytes: 9232
N = int(input())
A = list(map(int,input().split()))
kane = 1000
kabu = 0
buy = A[0]
max = 0

for i in range(1,N): 
  if(A[i-1] > A[i]):
    buy=A[i]
  elif(buy < A[i]):
    max = A[i]
    kabu = int(kane/buy)
    kane = kane + kabu*(max-buy)  
    kabu = 0
    buy = A[i]
print(kane)

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

string s;
const int maxn = 5e5+10;
int n, countN, front[maxn];
long long ans;

int main() {
	cin >> s;
	n = s.size();

	for(int i=0; i<n; i++){
		if(s[i] == '>'){
			countN=0;
		}
		else{
			countN++;
		}
		front[i+1]=countN;
	}

	countN=0;
	for(int i=n-1; i>-1; i--){
		if(s[i] == '<'){
			countN=0;
		}
		else{
			countN++;
		}
		ans += max(countN, front[i]);
	}
	ans += front[n];
	cout << ans << endl;
}

Measured memory_bytes: 2820
import java.util.Arrays;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	public static final int BIG_NUM = 2000000000;
	//public static final int MOD = 1000000007;
	public static final long HUGE_NUM = 99999999999999999L;
	public static final double EPS = 0.000000001;

	@SuppressWarnings("unchecked")
	public static void main(String[] args) {

		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Scanner scanner = new Scanner(System.in);

		int N = scanner.nextInt();
		int M = scanner.nextInt();
		int start = scanner.nextInt();

		final long NUM = 100;
		final long TOTAL = NUM*N; //1周のコスト

		long dist[] = new long[N]; //時計回りの距離
		long rev_dist[] = new long[N]; //半時計回りの距離
		int table[] = new int[M+1]; //買い物をする駅

		int tmp;

		table[0] = start;
		dist[start] = 0;
		rev_dist[start] = 0;

		for(int i = 1; i <= M; i++){

			tmp = scanner.nextInt();
			table[i] = tmp;

			if(tmp > start){ //時計回り

				dist[tmp] = (tmp-start)*NUM;
				rev_dist[tmp] = TOTAL-dist[tmp];

			}else{ //tmp < start 半時計周り

				rev_dist[tmp] = (start-tmp)*NUM;
				dist[tmp] = TOTAL-rev_dist[tmp];
			}
		}
		Arrays.sort(table);

		int start_loc = -1;
		for(int i = 0; i <= M; i++){
			if(table[i] == start){

				start_loc = i;
				break;
			}
		}

		int MOD = M+1;

		long ans = HUGE_NUM;

		for(int i = 0; i <= M; i++){
			//0駅以上時計回りに進んでから折り返す、または0駅以上半時計周りに進んでから折り返す()
			ans = Math.min(ans, Math.min(2*dist[table[(start_loc+i)%MOD]]+rev_dist[table[(start_loc+i+1)%MOD]],
					dist[table[(start_loc+i)%MOD]]+2*rev_dist[table[(start_loc+i+1)%MOD]]));
		}
		System.out.println(ans);
	}
}



class UTIL{

	//最大公約数
	public static long gcd(long x,long y){

		x = Math.abs(x);
		y = Math.abs(y);

		if(x < y){

			long tmp = y;
			y = x;
			x = tmp;
		}

		if(y == 0){

			return x;
		}else{

			return gcd(y,x%y);
		}
	}

	//最小公倍数
	public static long lcm(long x,long y){

		return (x*y)/gcd(x,y);
	}

	//String→intへ変換
    public static int getNUM(String tmp_str){

        return Integer.parseInt(tmp_str);
    }

    //文字が半角数字か判定する関数
    public static boolean isNumber(String tmp_str){

        if(tmp_str == null || tmp_str.length() == 0){

            return false;
        }

        Pattern pattern = Pattern.compile("\\A[0-9]+\\z");
        Matcher matcher = pattern.matcher(tmp_str);
        return matcher.matches();
    }
}


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

int main() {
  int n, m;
  ll k;
  cin >> n >> m >> k;

  vector<ll> a(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    ll num;
    cin >> num;
    a.at(i) = a.at(i - 1) + num;
  }

  vector<ll> b(m + 1, 0);
  for (int i = 1; i <= m; i++) {
    ll num;
    cin >> num;
    b.at(i) = b.at(i - 1) + num;
  }

  int ans = 0;
  for (int i = 0; i <= n; i++) {
    if (k < a.at(i)) {
      break;
    }
    ll limit = k - a.at(i);
    auto itr = upper_bound(b.begin(), b.end(), limit);
    int b_books = distance(b.begin(), itr) - 1;
    ans = max(ans, (i + b_books));
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6420
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    int count = 0;
    for(int i = 0; i < str.length(); i++) {
      if (str.charAt(i) - '0' == 1) count++;
    }
    System.out.println(count);
  }
}


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

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

  if (x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) {
    if (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  else if (x == 4 || x == 6 || x == 9 || x == 11) {
    if (y == 4 || y == 6 || y == 9 || y == 11) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
     
using namespace std;
     
int main(){

  int n,a;
  
  int cnt=0,cnt1=0;

  cin>>n;

  for(int i=0;i<n;i++){
    cin>>a;
    cnt=0;
    while(1){
      if(a%2==0){
	a/=2;
      }else{
	break;
      }
      cnt++;
    }
    cnt1+=cnt;
  }
  
  cout<<cnt1<<endl;
    		     
  return 0;
     
      
}


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

public class Main
{
	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			public void run() {
                solve();
            }
        }, "1", 1 << 26).start();
	}
	static void solve () {
		FastReader fr =new FastReader();	PrintWriter op =new PrintWriter(System.out);
 
 		int n =fr.nextInt() ,m =fr.nextInt() ,x =fr.nextInt() ,c[] =new int[n] ,a[][] =new int[n][m] ,i ,j ;
 		for (i =0 ; i<n ; ++i) {
 			c[i] =fr.nextInt() ;	for (j =0 ; j<m ; ++j)	a[i][j] =fr.nextInt() ;
 		}
 		int k =1<<n ,l ,dm[] ,p ,q ,cst =Integer.MAX_VALUE ;
 		for (i =1 ; i<k ; ++i) {
 			l =0 ;	dm =new int[m] ;

 			for (p =0 ; p<n ; ++p) {
 				if (((1<<p)&i) != 0) {
 					l += c[p] ;
 					for (q =0 ; q<m ; ++q)	dm[q] += a[p][q] ;
 				}
 			}
 			q =Integer.MAX_VALUE ;
 			for (p =0 ; p<m ; ++p)	q =Math.min(q , dm[p]) ;
 			if (q>=x)	cst =Math.min(cst , l) ;
 		}
 		if (cst==Integer.MAX_VALUE)	op.println("-1") ;
 		else 	op.println(cst) ;
		op.flush();	op.close();
	}
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br =new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st==null || (!st.hasMoreElements())) 
			{
				try
				{
					st =new StringTokenizer(br.readLine());
				}
				catch(IOException e)
				{
					e.printStackTrace();
				}
				
			}
			return st.nextToken();
		}

		String nextLine() {
			String str ="";

			try
			{
				str =br.readLine();
			}
			catch(IOException e)
			{
				e.printStackTrace();
			}

			return str;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next()) ;
		}
	}
}

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

int N, K;
vector<int> A;
vector<int> SG;

int main() {
    scanf("%d %d", &N, &K);
    A.resize(N);

    for (int &a : A)
        scanf("%d", &a);

    SG.resize(K + 1, 0);
    vector<bool> seen;

    for (int k = 1; k <= K; k++) {
        seen.assign(N + 1, false);

        for (int i = 0; i < N; i++)
            if (k >= A[i])
                seen[SG[k - A[i]]] = true;

        SG[k] = 0;

        while (seen[SG[k]])
            SG[k]++;
    }

    puts(SG[K] ? "First" : "Second");
}


Measured memory_bytes: 768
# coding: utf-8
# Your code here!

n=int(input())
S=[]
for i in range(n):
    S.append(input())

a=0

for i in range(n):
    S=[S[-1]]+S[:-1]
#    print(S)
    flag=1
    for j in range(n):
        for k in range(j):
            if S[j][k] != S[k][j]:
                flag=0
                break
    if flag == 1:
        a = a+1

print(a*n)


Measured memory_bytes: 42748
// Includes

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <cstdlib>

// Defines

#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a, n) a, a + n
#define mem(name, value) memset(name, value, sizeof(name))
#define f(i,a) for(int i=0;i<a;i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;

int arr[100005],dp[100005];
int n;

int calc(int i) {
    if(i == n - 2)
        return std::abs(arr[n-2] - arr[n - 1]);
    if(i == n - 1)
        return 0;
    if(dp[i] != -1)
        return dp[i];
    int ans1 = std::abs(arr[i] - arr[i + 1]) + calc(i + 1);
    int ans2 = std::abs(arr[i] - arr[i + 2]) + calc(i + 2);
    return dp[i] = min(ans1,ans2);
}

int main(){

/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    
    cin >> n;
    f(i,n) {
        cin >> arr[i];
    }
    mem(dp,-1);

    cout << calc(0) << "\n";

    return 0;
}

Measured memory_bytes: 4224
#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int a[n+1];
	for(int i=1;i<=n;i++)
	cin>>a[i];
	int dp[n+1],tmp=0;
	memset(dp,0x3f,sizeof(dp));
	dp[1]=0;
	dp[2]=abs(a[2]-a[1]);
	for(int i=3;i<=n;i++)
	for(int j=1;j<=k;j++)
	{
		if(i-j>0)
		{
		tmp=dp[i-j]+abs(a[i]-a[i-j]);
		dp[i]=min(tmp,dp[i]);		
		}
		else break;
	}
	cout<<dp[n];
 }

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

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> cnt(n);
  for (int i = 0; i < q; ++i) {
    int a;
    cin >> a;
    --a;
    ++cnt[a];
  }
  for (int i = 0; i < n; ++i) {
    if (k - (q - cnt[i]) > 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<min(a,b)+min(c,d)<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector") 
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 998244353LL
#define MOD2 996491788296388609LL
#define MODL 7971934306371108872LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}

template<int N, typename T, T M>
struct ModFact {
    T fact[N+1];
    T ifact[N+1];
    constexpr ModFact() : fact(), ifact() {
        fact[0] = 1;
        for (int i=0; i<N; ++i)
            fact[i+1] = (fact[i]*(i+1))%M;
        ifact[N] = power(fact[N], M-2);
        for (int i=N-1; i >= 0; --i)
            ifact[i] = (ifact[i+1]*(i+1))%M;
    }
    constexpr T power(T a, T b) {
        T r = 1;
        while (b>0) {
            if((b&1)!=0) r = (r*a)%M;
            a = (a*a)%M;
            b >>= 1;
        }
        return r;
    }
    inline constexpr T comb(const T& n, const T& r) {
        return ((ifact[n-r]*ifact[r])%M)*fact[n]%M;
    }
};
 
ModFact<300000, ll, MOD> fact;

int main() {
    fastio();
    ll N, A, B, K, ans = 0;
	cin >> N >> A >> B >> K;
    ll g = gcd(A, B);
    if(K%g==0) {
        ll ca=B/g, cb=A/g;
        ll oa=min(N, K/A), ob=min(N, K/B);
        ll i=0, j=ob;
        while(i<=oa) {
            while (i*A+j*B>K) j--;
            if (i*A+j*B==K) break;
            i++;
        }
        while(i<=oa && j>=0) {
            ans += fact.comb(N,i)*fact.comb(N,j);
            if(ans >= MOD2) ans -= MOD2;
            i += ca; j -= cb;
        }
    }
    cout << ans%MOD << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 8
main(){
  char data[N][N];
  int i, j;
  
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      scanf("%c", &data[i][j]);
    }
    getchar();
  }
  
  printf("90\n");
  for(i=0;i<N;i++){
    for(j=N-1;j>=0;j--){
      printf("%c", data[j][i]);
    }
    printf("\n");
  }

  printf("180\n");
  for(i=N-1;i>=0;i--){
    for(j=N-1;j>=0;j--){
      printf("%c", data[i][j]);
    }
    printf("\n");
  }

  printf("270\n");
  for(i=N-1;i>=0;i--){
    for(j=0;j<N;j++){
      printf("%c", data[j][i]);
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 0
s = list(input())

flag = 0
pos_a, pos_z = 1, 1
length = 0

for i, ltr in enumerate(s, 1):
  if ltr == 'A' and flag == 0:
    pos_a = i
    flag = 1
  elif ltr == 'Z' and flag == 1:
    pos_z = i
    if pos_z - (pos_a -1) > length:
      length = pos_z - (pos_a -1)
    else:
      flag = 0

print(length)

Measured memory_bytes: 4840
n=int(input())
a=list(map(int,input().split()))
c=0
for i in range(n):
    if a[i]<0:
        c+=1
        a[i]=-1*a[i]
aa=list(map(abs,a))
if c%2==0:
    print(sum(aa))
else:
    print(sum(aa)-2*min(aa))


Measured memory_bytes: 65440
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		
		//テキスト入力クラス
		Scanner sc = new Scanner(System.in);
		
		//入力文字を取得
		int first = sc.nextInt();
		int second = sc.nextInt();
		int third = sc.nextInt();
		
		//3つの数が、条件を満たし、yesの場合
		if(first < second && second < third){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}		
	}
}

Measured memory_bytes: 17160
a,b=map(int,input().split())
mydict = {1:"a", 2:"c", 3:"a", 4:"b", 
          5:"a", 6:"b", 7:"a", 8:"a", 9:"b", 10:"a", 11:"b", 12:"a"}
if mydict[a] == mydict[b]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9040
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(150) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> A >> B >> C >> D;
  N=C-A;
  M=D-B;
  Out(C-M);
  Out(D+N);
  Out(C-M-N);
  Out(D+N-M);
}

Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>

#include <boost/algorithm/string/predicate.hpp>

using namespace std;

#if 0
// memo
abs()

start_with(str, "hoge");
ends_with(str, "hoge");

std::sort(d.begin(), d.end());
d.erase(std::unique(d.begin(), d.end()), d.end());
#endif

using namespace boost;
using namespace boost::algorithm;

static inline bool isOdd(int v)
{
    return v & 0x01;
}

int main()
{
    long long N, K;
    scanf("%lld%lld", &N, &K);

    if (K == 0) {
        cout << (N*N) << endl;
        return 0;
    }

    long long c = 0;
    for (long long b = K + 1; b <= N; ++b) {
        long long P = N / b;
        long long Q = N % b;

        c += (b - K) * P;

        if (Q >= K) {
            c += Q - K + 1;
        }
    }

    cout << c << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int r = sc.NextInt();
        int g = sc.NextInt();
        int b = sc.NextInt();

        Console.WriteLine((100 * r + 10 * g + b) % 4 == 0 ? "YES" : "NO");
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11092
import java.util.Scanner
import scala.util.control.Breaks

object Main extends App {
  val sc = new Scanner(System.in)
  val N = sc.nextInt
  val A = Array.fill(N)(BigInt(sc.nextLong))

  val z = if (A.contains(BigInt(0))) 0 else {
    val b = new Breaks
    var x = BigInt(1)
    b.breakable {
      for (i <- 0 until N) {
        x *= A(i)
        if (x < BigInt(0) || x > BigInt(1000000000000000000L)) {
          x = BigInt(-1)
          b.break
        }
      }
    }
    x
  }
  println(z)
}


Measured memory_bytes: 66412
n,m = map(int,input().split())
X = list(map(int,input().split()))
X.sort()
D = []
for i in range(m-1):
    D.append(abs(X[i+1]-X[i]))
D.sort()

if m-n<=0:
    print(0)
else:
    print(sum(D[0:m-n]))

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

int main() {
string S; 
  cin>>S;
  int Ans=0;
  if(S=="SUN") Ans=7;
  if(S=="MON") Ans=6;
  if(S=="TUE") Ans=5;
  if(S=="WED") Ans=4;
  if(S=="THU") Ans=3;
  if(S=="FRI") Ans=2;
  if(S=="SAT") Ans=1;
  cout<<Ans<<endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int N, M; cin >> N >> M;
	vector<ll> s(N+1), t(M+1);
	for (int i = 1; i <= N; i++) {
		cin >> s[i];
	}

	for (int i = 1; i <= M; i++) {
		cin >> t[i];
	}

	vector<vector<ll>> dp(N + 1, vector<ll>(M + 1)), sum(N + 1, vector<ll>(M + 1));
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			if (s[i] == t[j])
				dp[i][j] = (sum[i - 1][j - 1] + 1) % DIV;
			sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + dp[i][j];
			sum[i][j] = (sum[i][j] + DIV) % DIV;
		}
	}

	cout << (sum[N][M] + 1 + DIV) % DIV << endl;
}


Measured memory_bytes: 66072
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
int main() {
    int N; cin >> N;
    vector<int> X(1e5+3);
    for(int i = 0; i < N; i++) {
        int ai; cin >> ai;
        int a[3] = {ai-1,ai,ai+1};
        for (auto x : a){
            if (x==-1) X[1e5+2]++;
            else X[x]++;
        }
    }
    sort(X.begin(),X.end(),greater<int>());
    cout << X[0] << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int[]a=new int[N+1];
		for(int i=1;i<=N;i++){
			a[i]=sc.nextInt();
		}
		int[]b=new int[N+1];
		if(N%2==0){
			for(int i=1;i<=N/2;i++){
				b[i]=a[N-2*(i-1)];
			}
			for(int i=1;i<=N/2;i++){
				b[N/2+i]=a[i*2-1];
			}
		}else{
			for(int i=1;i<=N/2+1;i++){
				b[i]=a[N-2*(i-1)];
			}
			for(int i=1;i<=N/2;i++){
				b[N/2+i+1]=a[i*2];
			}
		}
		
		for(int i=1;i<=N;i++){
			System.out.print(b[i]+" ");
		}
		
		System.out.println();
	}

}


Measured memory_bytes: 95480
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		long[] H = new long[N];
		int ans = N;
		boolean[] flg = new boolean[N];
		for(int i = 0;i < N;i++){
			H[i] = sc.nextLong();
		}
		
		for(int i = 0;i < M;i++){
			int A = sc.nextInt() - 1;
			int B = sc.nextInt() - 1;
			if(H[A] > H[B]){
				flg[B] = true;
			}else if(H[A] < H[B]){
				flg[A] = true;
			}else{
				flg[A] = true;
				flg[B] = true;
			}
		}
		
		for(int i = 0;i < N;i++){
			if(flg[i]){
				ans--;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 60536