akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

vector<double> gauss_jordan(vector<vector<double> > A,vector<double> b){
  int n=A.size();
  vector<vector<double > > B(n,vector<double> (n+1));
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      B[i][j]=A[i][j];
    }
  }
  for(int i=0;i<n;i++)B[i][n]=b[i];
  for(int i=0;i<n;i++){
    int pivot=i;
    for(int j=i;j<n;j++){
      if(abs(B[j][i])>abs(B[pivot][i]))pivot=j;
    }
    swap(B[i],B[pivot]);
    for(int j=i+1;j<=n;j++)B[i][j]/=B[i][i];
    for(int j=0;j<n;j++){
      if(i!=j){
	for(int k=i+1;k<=n;k++)B[j][k]-=B[j][i]*B[i][k];
      }
    }
  }
  vector<double> x(n);
  for(int i=0;i<n;i++)x[i]=B[i][n];
  return x;
}

int main(){
  for(int n,s,t;cin>>n>>s>>t,n|s|t;){
    s--;
    t--;
    int q[123];
    for(int i=0;i<n;i++){
      cin>>q[i];
    }
    int a[123][123];
    int d[123][123];
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	cin>>a[i][j];
	d[i][j]=a[i][j]?a[i][j]:1e8;
      }
      d[i][i]=0;
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	for(int k=0;k<n;k++){
	  d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
	}
      }
    }
    if(d[s][t]>1e7){
      cout<<"impossible"<<endl;
    }else{
      vector<vector<double> > A(n);
      vector<double> b(n);
      for(int i=0;i<n;i++){
	A[i].resize(n);
	if(i==t){
	  A[i][i]=1;
	}else{
	  int f=0;
	  if(q[i]){
	    int md=1e9;
	    for(int j=0;j<n;j++){
	      if(i!=j&&a[i][j]){
		md=min(md,d[j][t]+a[i][j]);
	      }
	    }
	    
	    for(int j=0;j<n;j++){
	      if(i!=j&&a[i][j]&&d[j][t]+a[i][j]==md){
		A[i][j]=1;
		b[i]-=a[i][j];
		f++;
	      }
	    }
	  }else{
	    for(int j=0;j<n;j++){
	      if(a[i][j]){
		A[i][j]=1;
		b[i]-=a[i][j];
		f++;
	      }
	    }
	  }
	  A[i][i]-=f;
	}
      }
      cout.precision(9);
      cout<<fixed<<gauss_jordan(A,b)[s]<<endl;
    }
  }
}

Measured memory_bytes: 1596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
int n,col[100005],c1,c2;vector<int> v[100005],cpath,path;
void dfs(int x,int fa){
    cpath.pb(x);
    if(x==n) path=cpath;
    rap(i,0,v[x].size())
    if(fa!=v[x][i])
    dfs(v[x][i],x);
    cpath.pop_back();
}
void fill(int x,int fa){
    rap(i,0,v[x].size()){
        int to=v[x][i];
        if(to==fa||col[to]) continue;
        col[to]=col[x];
        fill(to,x);
    }
}
int main()
{
    scanf("%d",&n);
    rap(i,1,n){
        int t1,t2;
        scanf("%d%d",&t1,&t2);
        v[t1].pb(t2);v[t2].pb(t1);
    }
    dfs(1,0);
    int len=path.size();
    rap(i,0,len)
    if(i*2<len) col[path[i]]=1;else col[path[i]]=2;
    rap(i,0,len) fill(path[i],0);
    rep(i,1,n) if(col[i]==1) c1++;else c2++;
    //rep(i,1,n) printf("%d ",col[i]);
    puts(c1>c2?"Fennec":"Snuke");
    return 0;
}

Measured memory_bytes: 14840
fn main() {
    proconio::input! {
        n: usize,
        a: [u64; n],
    }

    let mo = 1000000007;

    let mut sum : u64 = a.iter().sum();

    let ans = a.iter()
        .fold(0, |cur, val| {
            sum -= val;
            return (cur + ((val * (sum % mo)) % mo)) % mo;
        });

    println!("{}", ans % mo);
}


Measured memory_bytes: 5476
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
    int N,x;
    cin>>N>>x;
    vector<int> a(N+1);
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    a[N] = 1000000000;
    sort(a.begin(),a.end());
    int sum = 0;
    int i = 0;
    while(true){
        if(sum+a[i]>x){
            if(i==N)i--;
            break;
        }else if (sum+a[i]==x){
            i++;
            break;
        }else{
            sum += a[i];  
            i++;
        }
    }
    cout<<i<<endl;
}


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

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

    int V, E;
    cin >> V >> E;

    vector<int> G[V];
    int in[V] = {};

    int s, t;
    for (int i=0; i<E; ++i) {
        cin >> s >> t;
        G[s].push_back(t);
        in[t] ++;
    }

    stack<int> can;
    for (int i=0; i<V; ++i) {
        if (in[i] == 0) {
            can.push(i);
        }
    }

    vector<int> res;

    while (can.size()) {
        int k = can.top(); can.pop();
        res.push_back(k);
        for (int &i: G[k]) {
            in[i] --;
            if (in[i] == 0) {
                can.push(i);
            }
        }
    }

    for (int i=0; i<res.size(); ++i) {
        cout << res[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3832
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;
  vvll dp(105, vll(220, -1));

  dp[0][0] = 0;
  rep(i, 105) {
    rep(j, 220) {
      set<ll> s;
      if (j > 0) s.insert(dp[i][j - 1]);
      repLRE(k, 1, min(i,j)) s.insert(dp[i - k][j]);
      if (i > 0 && j + 1 < 220) s.insert(dp[i - 1][j + 1]);
      ll g = 0;
      while (s.count(g) != 0) g++;
      dp[i][j] = g;
    }
  }

  ll xsum = 0;
  rep(i, n) { ll w, b;
    cin >> w >> b;
    xsum ^= dp[b][w];
    //cout << dp[b][w] << endl;
  }
  ll ans = xsum == 0 ? 1 : 0;

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3288
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int n,m,x,a,b,ans;
bool pay[200];
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m>>x;
    for(int i=1;i<=m;i++){
        int temp;cin>>temp;
        pay[temp]=true;
    }
    for(int i=x;i>=0;i--){
        if(pay[i])a++;
    }
    for(int i=x;i<=n+1;i++){
        if(pay[i])b++;
    }
    ans = min(a,b);
    cout<<ans<<newl;

}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  vector<int> b(n);
  for(int i = 0; i < n; i++) b[i] = a[i] - i - 1;
  sort(b.begin(), b.end());
  int p;
  if(n % 2 != 0) p = b[(n - 1) / 2];
  else p = (b[(n - 1) / 2] + b[(n - 1) / 2 + 1]) / 2;
  long long ans = 0;
  for(int i = 0; i < n; i++) ans += abs(b[i] - p);
  cout << ans << endl;
}

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

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 1e6+5;

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

    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int m = c/b;
    if(c%b)
        m++;
    int m2 = a/d;
    if(a%d)
        m2++;
    if(m<=m2)
        cout<<"Yes";
    else
        cout<<"No";

    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	string s;
	V dis;
	ll ans = 0LL;
	cin >>s;
	char last=0;
	int a    = 0;
	int bc   = 0;
	rep(i,s.size()){
		if(last=='A' and s[i]=='C'){
			a = 0;
		}
		if(last=='B' and s[i]!='C'){
			a = 0;
		}
		if(last =='C' and s[i]=='C'){
			a = 0;
		}
		if(s[i]=='A'){
			a++;
		}
		if(last =='B' and s[i]=='C'){
			ans += a;
		}
		last = s[i];
	}
	cout<<ans<<endl;
}
/*
a a o
a b o
a c x

b a   x
b b x
b c o

c a o
c b o
c c x
*/

Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cerr << v << " ";  \
  }                    \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
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;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
#define MAXN 110
int d[MAXN];
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  map<int, int> ma;
  REP(i, N) {
    int p;
    cin >> p;
    ma[p]++;
  }
  print(ma.size());
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <functional>

using namespace std;

int main()
{
	int n, m;
	long long a[100001];
	cin >> n >> m;
	if (n == 1)
	{
		cout << 0;
		return 0;
	}
	if (n > 2 && m == 0)
	{
		cout << "Impossible";
		return 0;
	}
	for (int i = 0; i < n; ++i)
	{
		int p;
		cin >> p;
		a[i] = p;
	}
	vector<int> v[100001];
	for (int i = 0; i < m; ++i)
	{
		int x, y;
		cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	bool used[100001];
	int isol = 0;
	long long sumi = 0;
	for (int i = 0; i < n; ++i)
	{
		if (v[i].size() == 0)
		{
			used[i] = true;
			isol++;
			sumi += a[i];
		}
		else
			used[i] = false;
	}
	queue<int> q;
	long long sum = sumi;
	priority_queue<long long, vector<long long>, greater<long long> > b;
	priority_queue<long long, vector<long long>, greater<long long> > c;
	int timer = 0;
	for (int i = 0; i < n; ++i)
	{
		if (!used[i])
		{
			q.push(i);
			while (!q.empty())
			{
				int cur = q.front(); 
				q.pop();
				used[cur] = 1;
				c.push(a[cur]);
				for (auto w : v[cur])
				{
					if (!used[w])
					{
						q.push(w);
					}
				}
			}
			sum += c.top();
			c.pop();
			while (!c.empty())
			{
				b.push(c.top());
				c.pop();
			}
			timer++;
		}
	}
	if (timer == 1 && isol == 0)
	{
		cout << 0;
		return 0;
	}
	if (n - 2*isol - 2*timer + 2 < 0)
		cout << "Impossible";
	else
	{
		for (int i = 0; i < isol + timer - 2; ++i)
		{
			sum += b.top();
			b.pop();
		}
		cout << sum;
	}
	return 0;
}

Measured memory_bytes: 8956
# -*- coding: utf-8 -*-
import math
a, b, x = map(int,input().split())

ans1 = math.degrees(math.atan((a*b*b)/(2*x)))
ans2 = math.degrees(math.atan(((2*(a*a*b-x))/a**3)))
if (a * b) / 2 > x / a:
    ans = ans1
else:
    ans = ans2

print(ans)

Measured memory_bytes: 3060
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        int[] x=new int[3];
        x[0]=a*10+b+c;
        x[1]=a+10*b+c;
        x[2]=a+b+10*c;
        Arrays.sort(x);
        out.println(x[2]);
    }
    //階乗
static long fact(long a){
    long b=1;
    for (long i = 1; i <= a; i++) {
        b*=i;
    }
    return b;
}
//最大公約数
static int gcd (int a, int b) {
    int temp;
    while((temp = a%b)!=0) {
        a = b;
        b = temp;
    }
    return b;
}
//※最小公倍数はa*b/gcd(a,b)である
//二項係数
static long combi (long a, long b) {
    b=min(a-b,b);
    return permu(a,b)/fact(b);
}
//順列
static long permu(long a,long b){
    long temp=1;
    for (long i =a ; i > a-b; i--) {
        temp*=i;
    }
    return temp;
}
}

Measured memory_bytes: 22356
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>

using namespace std;

#define int long long

signed main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	for (int i = 0; i < ty - sy; i++) {
		cout << "U";
	}
	for (int i = 0; i < tx - sx; i++) {
		cout << "R";
	}
	for (int i = 0; i < ty - sy; i++) {
		cout << "D";
	}
	for (int i = 0; i < tx - sx; i++) {
		cout << "L";
	}
	cout << "L";
	for (int i = 0; i < ty - sy+1; i++) {
		cout << "U";
	}
	for (int i = 0; i < tx - sx+1; i++) {
		cout << "R";
	}
	cout << "D";
	cout << "R";
	

	for (int i = 0; i < ty - sy + 1; i++) {
		cout << "D";
	}
	for (int i = 0; i < tx - sx + 1; i++) {
		cout << "L";
	}
	cout << "U" << endl;

	return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
//using namespace __gnu_pbds;

#define max_(x, y) (((x) > (y)) ? (x) : (y))
#define min_(x, y) (((x) < (y)) ? (x) : (y))
#define ___ ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
#define Mx 200001
#define inf 1e15
const int MOD = 1e9+7;
const double pi = 2 * acos (0.0);

typedef long long  L;
//typedef tree<L,null_type,less<L>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

L a,a1,a2,a3,c,c1,c2,c3,d,d1,d2,d3,d4,d5,f,h,k,m,n,m1,m2,n1,n2,o,p,p1,p2,p3,p4,q,q1,q2,q3,q4,s,t,
u,v,x,y,z,sum,mx=-inf,mn=inf,flg,flg1,flg2,id1,id2,id3,id4;

//double rat;
L A[Mx+5],lst[Mx+5],vis[Mx+5];
L rmqMin[Mx*3+5],rmqMax[Mx*3+5];
void init(L node,L b,L e){
    if(b==e){
        rmqMin[node]=A[b];
        rmqMax[node]=A[b];
        return;
    }
    if(b>e)return;
    init(node*2,b,(b+e)/2);
    init(node*2+1,(b+e)/2+1,e);
    rmqMin[node]=min(rmqMin[node*2],rmqMin[node*2+1]);
    rmqMax[node]=max(rmqMax[node*2],rmqMax[node*2+1]);
}

L queryMin(L node,L b,L e,L i,L j){
    if(b>=i&&e<=j){
        return rmqMin[node];
    }
    if(b>j||e<i)return inf;
    return min(queryMin(node*2,b,(b+e)/2,i,j),queryMin(node*2+1,(b+e)/2+1,e,i,j));
}
L queryMax(L node,L b,L e,L i,L j){
    if(b>=i&&e<=j){
        return rmqMax[node];
    }
    if(b>j||e<i)return -1;
    return max(queryMax(node*2,b,(b+e)/2,i,j),queryMax(node*2+1,(b+e)/2+1,e,i,j));
}
int main()
{
    scanf("%I64d%I64d",&n,&k);
    for(L i=1;i<=n;i++){
        scanf("%I64d",&A[i]);
    }c=0;
    init(1,1,n);
    lst[n]=A[n];A[0]=inf;
    for(L i=n-1;i>=1;i--){
        if(A[i]<A[i+1])lst[i]=lst[i+1];
        else lst[i]=i;
    }
    for(L i=1;i+k-1<=n;i++){
        if(lst[i]==lst[i+k-1]){
            c++;vis[i]=1;
        }
    }
    if(c){
        c=1;
    }
    for(L i=1;i+k-1<=n;i++){
        if(!vis[i]){
            mn=queryMin(1,1,n,i,i+k-2);
            mx=queryMax(1,1,n,i,i+k-2);
            if(mn>A[i-1]&&mx<A[i+k-1]){
                vis[i]=1;
            }else{ 
                c++;
            }
        }
    }
    printf("%I64d\n",c);
    return 0;
}
/// I64d push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() 


Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  int fr = 0, re = 0, frre = 0;
  int ans = 0;
  int ad = 0;
  rep(i, n){
    string s;
    cin >> s;
    rep(j, s.size()-1){
      if(s.at(j) == 'A' && s.at(j+1) == 'B') ans++;
    }
    if(s.front() == 'B'){
      if(s.back() == 'A') frre++;
      else fr++;
    }else if(s.back() == 'A') re++;
  }
  cerr << frre << " " << fr << " " << re << " " << ans << endl;
  if(frre >= 1){
    ad += frre-1;
    if(re > 0){
      re--;
      ad++;
    }
    if(fr > 0){
      fr--;
      ad++;
    }
  }
  ad += min(fr, re);
  ans += ad;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	string s;cin>>s;
	int n = s.size();
	string t = "keyence";
	for(int i = 0; i < n; i++) {
		for(int j = i; j < n; j++) {
			string tmp = s.substr(0,i) + s.substr(j);
			// cout << tmp << endl; 
			if(tmp == t){
				cout << "YES" << endl;
				return 0;
			}
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 3628
def resolve():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    ans = 1 << 60

    for i in range(N - K + 1):
        l = A[i]
        r = A[i + K - 1]
        l_to_r = abs(l) + abs(l - r)
        r_to_l = abs(r) + abs(r - l)
        res = min(l_to_r, r_to_l)
        ans = min(ans, res)

    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 19980
a, b, c = map(int, input().split())
K = int(input())

for i in range(K+1):
    for j in range(K+1-i):
        k = K - i - j
        #print(i, j, k)
        if a * 2**i < b * 2**j and b * 2**j < c * 2**k:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 9180
// Programming Education

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main() {
    int n;
    cin >> n;
    if (n == 1) {
        cout << "Hello World" << endl;
        return 0;
    }

    int a, b;
    cin >> a >> b;
    cout << a + b << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
using namespace std;
//using namespace boost::multiprecision;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}


int main(){
  
  int a,b;
  cin>>a>>b;
  bool c[4] = {};
  c[a] = c[b] = true;
  REPP(i,3){
    if(c[i])continue;
    cout<<i<<endl;
  }
  return 0; 
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, m; cin >> n >> m;
  cout << 100 * pow(2, m) * (18 * m + n) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define pb push_back
using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

long long int ncr(long long int n,long long int r){
  long long int i,ans;
  ans=1;
  for(i=1;i<=(n-r);i++){
    ans*=(n-i+1);
    ans/=i;
  }
  return ans;
}


int main(void){
  int n;
  vector<ll> a;
  ll t,sum,res;
  cin>>n;
  sum=res=0;
  map<ll,ll> mp;
  mp[0]=1;
  
  for(int i=0;i<n;i++){
    cin>>t;
    sum+=t;
    a.pb(t);
    if(mp.count(sum)==0) mp[sum]=1;
    else mp[sum]=mp[sum]+1;
  }

  for(map<ll,ll>::iterator itr = mp.begin();itr!=mp.end();++itr){
    if(itr->second <= 1) continue;
    //cout<<itr->second<<","<<2<<endl;
    ll tmp=itr->second;
    res+=tmp*(tmp-1)/2;
  }
  
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 14320
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int, int>
#define fi first
#define se second 
using namespace std;
//const LL INF = (LL) 1e9 + 5;
const LL MOD = (LL) 2019;
//const int MAXN = 200005;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	string s;
	cin >> s;
	
	LL ans = 0, suf = 0, n = s.size(), pw = 1;
	map<LL, LL> cnt;
	cnt[0] = 1;
	for (int i = n - 1; i >= 0; i--) {
		suf = (suf + (s[i] - '0') * pw) % MOD;
		ans += cnt[suf];
		cnt[suf]++;
		pw = pw * 10 % MOD;
//		cout << "At " << i << ' ' << suf << '\n';
	}
	cout << ans << '\n';
	
	return 0;
}

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

int main(){
  string S;
  cin>> S;
  if(S[0]==S[1]||S[1]==S[2]||S[2]==S[3]){
    cout<< "Bad"<< endl;
  }
  else{
    cout<< "Good"<< endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
#include <algorithm>
//#include <iomanip> : 表示桁数, ex) cout << fixed << setprecision(15) << ...
//#include <unordered_set>

#define pi 3.14159265358979323846
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using ld = long double;
using Byte = unsigned char;
using namespace std;

//string ans = "Yes";


int SetAns() {
	int ans;
	cin >> ans;
	return (1000- (ans % 1000)) % 1000;
}

int main() {
	int ans = SetAns();
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3152
#include <iostream>
using namespace std;
 
int main() {
  int R;
  cin >> R;
  if (R < 1200) {
    cout << "ABC" << endl;
  }
  else if (R < 2800) {
    cout << "ARC" << endl;
  }
  else {
    cout << "AGC" << endl;
  }
}

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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (int i = j; i < (n); i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<int,int>P;
const ll mod=1e9+7;
const ll INF = 1e9;

int main(){

  int a,b;cin>>a>>b;

  if(abs(a-b)>16-(a+b))out(":(");
  else out("Yay!");

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string a,b;
int dp[4000][4000];

int recur(int it1, int it2){
    if(it1 == a.size() || it2 == b.size()){
        return 0;
    }
    if(dp[it1][it2] != -1){
        return dp[it1][it2];

    }
    if(a[it1] == b[it2]){
        return dp[it1][it2] = 1 + recur(it1+1,it2+1);
    }else{
        return dp[it1][it2] = max(recur(it1+1,it2),recur(it1,it2+1));
    }
}

string build(int it1, int it2){
    if(it1 == a.size() || it2 == b.size()){
        return "";
    }
    if(a[it1] == b[it2] && dp[it1][it2] == 1 + recur(it1+1,it2+1)) {
        return a[it1] + build(it1+1, it2+1);
    } else {
        if(dp[it1][it2] == recur(it1+1,it2)) {
            return build(it1+1, it2);
        }
        return build(it1, it2+1);
    }
}



int main(){
    memset(dp,-1,sizeof dp);
    cin>>a>>b;
    int ans = recur(0,0);
    if(ans == 0){
        cout<<" ";
    }else{
        cout<<build(0,0);
    }
}


Measured memory_bytes: 63360
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
r=gi
puts r**2

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1e9+7;
const int INF=1001001001;

int main() {
  int64_t X,Y;
  cin>>X>>Y;
  int cnt=1;
  while(X*2<=Y){
    cnt++;
    X*=2;
  }
  cout<<cnt<<endl;
  return 0;  
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k;
    cin >> n >> k;
    int sum = 0;
    for( int i = 0; i < n; ++i ) {
        int x;
        cin >> x;
        sum += min( x, abs( k - x ) ) * 2;
    }

    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;

ll n;
ll a[20][20];
const ll N=(1<<17);
ll dp[N];bool vis[N];
ll sum[N];
vector<ll>v,all;

void f(ll i,ll b){
    if(i==v.size()){
        if(!b)return;
        all.pb(b);
        return;
    }
    f(i+1,b);
    f(i+1,b+(1<<v[i]));
}
ll solve(ll bit){
    if(bit==(1<<n)-1)return 0;
    ll &ans=dp[bit];
    if(vis[bit])return ans;
    vis[bit]=1;
    v.clear();
    for(ll i=0;i<n;i++){
        if(((1<<i)&bit)==0)v.pb(i);
    }
    all.clear();
    f(0,0);
    for(auto i:all){
        ans=max(ans,sum[i]+solve(bit+i));
    }
    return ans;
}

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

    for(ll i=0;i<(1<<n);i++){
        for(ll j=0;j<n;j++){
            for(ll k=j+1;k<n;k++){
                if(((1<<j)&i)&&((1<<k)&i)){
                    sum[i]+=a[j][k];
                }
            }
        }
    }

    cout<<solve(0);
    return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N = 100005;
ll x[MAX_N],v[MAX_N],clo[MAX_N],cclo[MAX_N],mclo[MAX_N],mcclo[MAX_N];

int main()
{
	ll N,C;
	cin >> N >> C;
	rep(i,N)
	{
		cin >> x[i] >> v[i];
	}

	ll ans = 0;
	clo[0] = ll(0);
	mclo[0] = ll(0);
	clo[1] = v[0] - x[0];
	mclo[1] = max(mclo[0],clo[1]);
	for (int i = 1; i < N; ++i)
	{
		clo[i+1] += clo[i] + v[i] - (x[i] - x[i-1]);
		mclo[i+1] = max(mclo[i],clo[i+1]);
	}
	cclo[0] = ll(0);
	mcclo[0] = ll(0);
	cclo[1] = v[N-1] - (C - x[N-1]);
	mcclo[1] = max(mcclo[0],cclo[1]);
	for (int i = 1; i < N; ++i)
	{
		cclo[i+1] += cclo[i] + v[N-1-i] - (x[N-i] - x[N-1-i]);
		mcclo[i+1] = max(mcclo[i],cclo[i+1]);
	}
	/*
	rep(i,N+1)
	{
		cout << clo[i] << " " << mclo[i] << " ";
	}
	cout << endl;
	rep(i,N+1)
	{
		cout << cclo[i] << " " << mcclo[i] << " ";
	}
	cout << endl;
	*/
	rep(i,N+1)
	{
		ans = max(ans,max(mclo[i],mcclo[i]));
	}
	rep(i,N+1) //時計回りにi個
	{
		ll temp = clo[i];
		if (i == 0) temp += mcclo[N-i];
		else temp += mcclo[N-i] - x[i-1];
		ans = max(ans,temp);
	}
	rep(i,N+1) //反時計回りにi個
	{
		ll temp = cclo[i];
		if (i == 0) temp += mclo[N-i];
		else temp += mclo[N-i] - (C - x[N-i]);
		ans = max(ans,temp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<cstring>
#include<cassert>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<vector>
#include<time.h>
#include<algorithm>
using namespace std;
#define REP(i,x,y) for(int i=x;i<=y;i++)
#define rep(i,n) REP(i,1,n)
#define rep0(i,n) REP(i,0,n-1)
#define repG(i,x) for(int i=pos[x];~i;i=e[i].next)
#define ll long long
#define db double
const int N=3e5+7;
const int INF=1e9+7;
int n;
int a[N],s[N];
bool check(int x){
	int mn=0;
	for(int i=2;i<n;i+=2){
		if(s[i-1]-mn>=x)mn=min(mn,s[i]);
	}
	return s[n]-mn>=x;
}
int main(){
	scanf("%d",&n);
	rep(i,n)scanf("%d",&a[i]);
	if(n%2==0){
		int s1=0,s2=0;
		rep(i,n)if(i&1)s1+=a[i];else s2+=a[i];
		printf("%d %d\n",max(s1,s2),min(s1,s2));
	}
	else{
		int l=0,r=0,ans,s1=0,s2=0;
		rep(i,n)r+=a[i];
		rep(i,n)if(i&1)s1+=a[i];else s2+=a[i];
		rep(i,n)s[i]=s[i-1]+((i&1)?a[i]:-a[i]);
		while(l<r-1){
			int mid=(l+r)>>1;
			if(check(mid))l=mid;
			else r=mid;
		}
		if(check(r))ans=r;
		else ans=l;
		printf("%d %d\n",s2+ans,s1-ans);
	}
	return 0;
}


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

int main() {
	string s1, s2;
	cin >> s1 >> s2;
	int A, B;
	cin >> A >> B;
	string S;
	cin >> S;
	if (S == s1) A--;
	if (S == s2) B--;
	cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2],R[MAX/2+2];
int count;


void merge(int A[],int n,int left,int mid,int right)
{
	int n1=mid-left;
	int n2=right-mid;
	for(int i=0;i<n1;i++)
	{
		L[i]=A[left+i];
	}
	for(int i=0;i<n2;i++)
	{
		R[i]=A[mid+i];
	}

	L[n1]=R[n2]=SENTINEL;
	int i=0;
	int j=0;
	for(int k=left;k<right;k++)
	{
		count++;
		if(L[i]<=R[j])
		{
			A[k]=L[i++];
		}
		else
		{
			A[k]=R[j++];
		}
	}
}
void mergesort(int A[],int n,int left,int right)
{
	if(left+1<right)
	{
		int mid =(left+right)/2;
		mergesort(A,n,left,mid);
		mergesort(A,n,mid,right);
		merge(A,n,left,mid,right);
	}
}

int main(void)
{
	int A[MAX],n,i;
	count=0;

	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&A[i]);
	}
	mergesort(A,n,0,n);

	for(i=0;i<n;i++)
	{
		if(i!=0)
		{
			printf(" ");
		}
		printf("%d",A[i]);
	}
	printf("\n");
	printf("%d\n",count);

	return 0;
}



Measured memory_bytes: 5704
#include <stdio.h>

int main(void) {

  int am,pm;
  char cls[20];

  int i;

  
  for(i=0;i<9;i++) {

    scanf("%s %d %d",cls,&am,&pm);
    
    printf("%s %d %d\n",cls,am+pm,am*200+pm*300);
    
  }

  return 0;

}

Measured memory_bytes: 0
#include<stdio.h>
int main()
{
  int r,c,i,j,ok;
  char a[1000][1000];
  scanf("%d %d",&r,&c);
  for(i=0;i<r;i++)
    scanf("%s", a[i]);
  for(i=0;i<r;i++){
    ok=1;
    for(j=0;j<c;j++)
      if(a[i][j]!='.' && a[i][j]!=' ')
        ok=0;
    if(ok==1)
      for(j=0;j<c;j++)
        a[i][j]=' ';
  }
  for(j=0;j<c;j++){
    ok=1;
		for(i=0;i<r;i++)
      if(a[i][j]!='.' && a[i][j]!=' ')
        ok=0;
    if(ok==1)
      for(i=0;i<r;i++)
        a[i][j]=' ';
	}

  for(i=0;i<r;i++){
    for(j=0;j<c;j++)
      if(a[i][j]!=' ')
        printf("%c",a[i][j]);
        printf("\n");
	}
	return 0;
}


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

namespace AtTest.ABC_144
{
    class D
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            double[] abx = ReadDoubles();
            double a = abx[0];
            double b = abx[1];
            double x = abx[2];
            if (x <= 0.5 * a * a * b)
            {
                double y = 2 * x / a / b;
                double theta = 90 - Atan2(y, b) * 180 / PI;
                WriteLine(theta);
            }
            else
            {
                double y = 2 * x / a / a - b;
                double theta = 90 - Atan2(a, b - y)*180/PI;
                WriteLine(theta);
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

int d(int n){
    int sum=0;
    while(n > 0){
        sum += n%10;
        n /= 10;
    }
    return sum;
}

int main(){
    int n; cin >> n;
        int sum = d(n);
        if(n%sum==0){
            cout << "Yes" << endl;
            return 0;
    }
    cout << "No" << endl;
    return 0;
}


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

int main()
{
	char num[1000];
	int i, j, len, sum;
	
	i = 0;
	while (1){
		scanf("%s", num);
		len = strlen(num);
		
		if (num[0] == '0'){
			break;
		}
		i++;
		
		sum = 0;
		for (j = 0; j < len; j++){
			sum += num[j] - '0';
		}
		printf("%d\n", sum);
	}
	
	return 0;
}


Measured memory_bytes: 2104
import numpy as np
import sys
input = sys.stdin.readline

def main():
    N, X, Y = map(int, input().split())

    link = np.array([[N if i!=j else 0 for j in range(N)] for i in range(N)])
    link[X-1, Y-1] = 1
    link[Y-1, X-1] = 1

    for i in range(1, N):
        link[i] = np.minimum(link[i], link[i-1] + 1)
    for i in range(N-2, -1, -1):
        link[i] = np.minimum(link[i], link[i+1] + 1)
    for i in range(1, N):
        link[:,i] = np.minimum(link[:,i], link[:,i-1] + 1)
    for i in range(N-2, -1, -1):
        link[:,i] = np.minimum(link[:,i], link[:,i+1] + 1)
    
    ans = [0] * N
    for i in range(N-1):
        for j in range(i+1, N):
            ans[link[i, j]] += 1
    
    for i in range(1, N):
        print(ans[i])

if __name__ == "__main__":
    main()

Measured memory_bytes: 75888
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }


int main() {
	int n, m, X, Y;
	cin >> n >> m >> X >> Y;
	vector<int>x(n), y(m);
	int X_max = X;
	int Y_min = Y;
	rep(i, n) {
		cin >> x[i];
		X_max = max({ X_max,x[i] });
	}
	rep(i, m) {
		cin >> y[i];
		Y_min = min({ Y_min,y[i] });
	}
	if (X_max < Y_min)puts("No War");
	else puts("War");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a, b;
	int i = 1;
	int feea, feeb;

	scanf("%d %d", &a, &b);

	while (i <= 1000000) {
		feea = i * 8 / 100;
		feeb = i * 10 / 100;
		if (feea == a && feeb == b) {
			printf("%d", i);
			break;
		}
		i++;
	}
	if (i == 1000001) {
		printf("-1");
	}
	return 0;
}

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

int main()
{
    int N, a, j;
    cin >> N;
    vector<int> v(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a;
        v[i] = a;
    }
    if (v[0] == 2)
    {
        cout << 1 << endl;
    }
    else
    {
        j = v[0] - 1;
        for (int k = 0; k < N; k++)
        {
            if (v[j] == 2)
            {
                cout << k + 2 << endl;
                break;
            }
            else if (k == N - 1)
            {
                cout << -1 << endl;
            }
            j = v[j] - 1;
        }
    }
}


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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)

const int maxn = 5e5 + 5;
const int mx = 1 << 20;
const int mod = 1e9 + 7;

inline void add(int &x, int y) {
	x += y;
	if (x >= mod) x -= mod;
}

inline int qp(int x, int n) {
	int ans = 1;
	for (; n; n >>= 1, x = 1LL * x * x % mod)
		if (n & 1) ans = 1LL * ans * x % mod;
	return ans;
}

int n;
int a[maxn];
vector <int> occ[mx];
int cnt0[maxn];

int main() {
	scanf("%d", &n);
	rep(i, n) scanf("%d", &a[i]);
	rep(i, n) a[i] = (i ? a[i - 1] : 0) ^ a[i];
	rep(i, n) cnt0[i] = (i ? cnt0[i - 1] : 0) + (a[i] == 0);
	rep(i, n) occ[a[i]].pb(i);
	if (!cnt0[n - 1]) { puts("1"); return 0; }
	int ed = a[n - 1], ans = ed == 0 ? qp(2, cnt0[n - 1] - 1) : 0;
	rep(v, mx) if (v && (ed == 0 || ed == v)) {
		if (occ[v].empty()) continue;
		vector <int> dp(occ[v].size());
		int sum0 = 0, sum1 = 0;
		rep(i, occ[v].size()) {
			dp[i] = (1 + 1LL * sum0 * cnt0[occ[v][i]] % mod + mod - sum1) % mod;
			add(sum0, dp[i]);
			add(sum1, 1LL * dp[i] * cnt0[occ[v][i]] % mod);
		}
		add(ans, ed == 0 ? sum0 : dp[occ[v].size() - 1]);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 41132
N, M = map(int,input().split())
list1 = [0]*M
ans = 0
for i in range(N):
	a = list(map(int, input().split()))
	a.pop(0)
	for n in a:
		list1[n-1] = list1[n-1] + 1
for m in range(M):
	if list1[m] == N:
		ans = ans + 1
print(ans)

Measured memory_bytes: 3060
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int a, b, c;
	std::cin >> a >> b >> c;
	if (a+c == b*2)
		std::cout << "YES\n";
	else
		std::cout << "NO\n";
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s1=scan.nextLine();
		String s2=scan.nextLine();
		String s3=scan.nextLine();
		System.out.println(s1.charAt(0)+""+s2.charAt(1)+""+s3.charAt(2));
	}

}


Measured memory_bytes: 27004
N, K = map(int, input().split())
dic = {i: 0 for i in range(1, N+1)}
for _ in range(K):
  dt = int(input())
  A = list(map(int, input().split()))
  for a in A:
    dic[a] += 1

ans = 0
for k, v in dic.items():
  if v == 0:
    ans += 1

print(ans)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
 
int main() {
  int ss;
  string stdr;
  cin >> stdr;
  ss = stdr.size();
  if(stdr.at(ss-1)=='s')stdr += "es";
  else stdr += "s";
  
  cout << stdr << endl;
  
  return 0;
  
}

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



int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    string s, t; cin >> s >> t;
    int s_len = s.length(), t_len = t.length();

    bool completed = false;
    for (int i = s_len - t_len; i >= 0; i--) {
        bool succeed = true;
        for (int j = i; j < i + t_len; j++) {
            if (s[j] == '?') continue;
            if (s[j] != t[j - i]) {
                succeed = false;
                break;
            }
        }
        if (succeed) {
            completed = true;
            for (int j = i; j < i + t_len; j++) {
                s[j] = t[j - i];
            }
            break;
        } else {
            continue;
        }
    }

    if (!completed) {
        cout << "UNRESTORABLE\n";
    } else {
        for (int i = 0; i < s_len; i++) {
            if (s[i] == '?') s[i] = 'a';
        }
        cout << s << '\n';
    }

    return 0;
}


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

char x[1001];
char y[1001];
int matrix[1001][1001];

void LCSlength(int,int);

int main(){
  int q,i;

  for(i=0;i<1001;i++){
    matrix[0][i] = 0;
    matrix[i][0] = 0;
  }

  scanf("%d",&q);


  for(i=0;i<q;i++){
    scanf("%s",x);
    scanf("%s",y);
    LCSlength(strlen(x),strlen(y));

    printf("%d\n",matrix[strlen(x)][strlen(y)]);
  }
  
    return 0;
}

void LCSlength(int m,int n){
  int i,j;
  
   for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(x[i-1] == y[j-1]) matrix[i][j] = matrix[i-1][j-1] + 1;

      else if( matrix[i-1][j] >  matrix[i][j-1])  matrix[i][j] = matrix[i-1][j];
      else  matrix[i][j] = matrix[i][j-1];
    }
   }
}

Measured memory_bytes: 4516