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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
int main()
{
    LL n,m,x;
    cin>>n>>m>>x;
    vector<LL>v(n,0),s(n,0);
    LL a[n][m];
    for(LL i=0; i<n; i++)
    {
        cin>>v[i];
        for(LL j=0; j<m; j++)
        {
            cin>>a[i][j];
        }
    }

    LL ans=INF;

    LL f=0;

    for(LL i=0; i<(1<<n); i++)
    {
        LL b[m]= {0};
         LL st=0;
        for(LL j=0; j<n; j++)
        {
            if(i&(1<<j))
            {
                for(LL k=0; k<m; k++)
                {
                    b[k]+=a[j][k];
                }
                st+=v[j];
            }
        }
        LL f=0;
        for(LL j=0;j<m;j++)
        {
          if(x>b[j])f=1;
        }
        if(f==0)
        {
            ans=min(ans,st);
        }

    }
    if(ans==INF)ans=-1;
    cout<<ans;




}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <limits>
#include <numeric>
#include <cassert>

#define seq(i, n) for (int i = 0; i < (n); i++)
#define seq2(i, f, t) for (int i = (f); i < (t); i++)
#define rev(i, n) for (int i = (n); i >= 0; i--)
#define rev2(i, f, t) for (int i = (f); i >= (t); i--)
#define all(x) (x).begin(),(x).end()
#define max(x, y) ((x) > (y) ? (x) : (y))
#define min(x, y) ((x) < (y) ? (x) : (y))

using namespace std;

using ll = long long;

ll dp[101000];

ll solve(int n, int m, vector<int> b) {
  for (int k:b){
    dp[k]=-1ll;
  }
  if(dp[n-1]!=-1){
    dp[n-1]=1; 
  }
  if(dp[n-2]!=-1) {
    dp[n-2]=1 + max(0,dp[n-1]);
  }
  rev2(i,n-3,0){
    if(dp[i] != -1)
      dp[i] = ((max(0,dp[i+1]) % 1'000'000'007) + (max(0,dp[i+2]) % 1'000'000'007)) % 1'000'000'007;
    else
      dp[i] = 0;
  }
  return dp[0];
}

int main() {
#ifdef TEST
  assert(solve(6, 1, {3}) == 4); 
  assert(solve(10, 2, {4, 5}) == 0); 
  assert(solve(100, 5, {1, 23, 45, 67, 89}) == 608200469); 
  assert(solve(1, 0, {}) == 1); 
  assert(solve(2, 1, {1}) == 1); 
#else
  int n,m;
  cin >> n >> m;
  vector<int> v;
  seq(_,m){
    int d;
    cin >> d;
    v.push_back(d);
  }
  cout << solve(n,m,v) << endl;
#endif

  return 0;
}


Measured memory_bytes: 1912
#include<stdio.h>

int main(void)
{
	char op;
	int number1, number2;
	while (1)
	{
		scanf("%d %c %d", &number1, &op, &number2);
		/*和*/
		if (op == '+')
		{
			printf("%d\n", number1 + number2);
		}
		/*差*/
		if (op == '-')
		{
			printf("%d\n", number1 - number2);
		}
		/*積*/
		if (op == '*')
		{
			printf("%d\n", number1*number2);
		}
		/*商*/
		if (op == '/')
		{
			printf("%d\n", number1 / number2);
		}
		/*終了*/
		if (op == '?')
		{
			break;
		}
	}
	return 0;
}


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

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

    int n;
    cin >> n;
    vector<ll> a(n);
    vector<int> bit(60);
    rep(i, 0, n) {
        cin >> a[i];
        rep(j, 0, 60) if (a[i] & (1LL << j)) bit[j]++;
    }

    ll odd = 0;
    rep(i, 0, 60) if (bit[i] % 2) odd += 1LL << i;

    rep(i, 0, n) a[i] &= ~odd;

    int j = 0, rank = 0;
    for (int i = 59; i >= 0; i--) {
        for (j = rank; j < n; j++)
            if (a[j] & (1LL << i))
                break;
        if (j == n)
            continue;
        if (j > rank)
            a[rank] ^= a[j];
        for (j = rank + 1; j < n; j++) {
            a[j] = min(a[j], a[j] ^ a[rank]);
        }
        rank++;
    }
    ll even = 0;
    rep(i, 0, n) even = max(even, even ^ a[i]);
    cout << even * 2 + odd << endl;

    return 0;
}

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

int main(){
  int h,first,second,third;
  first = second = third = -1;
  for(int i=0;i<10;i++){
     cin >> h;
     if(third < h)third = h;
     if(second < third){
       int tmp = second; second = third; third = tmp;
     }
     if(first < second){
       int tmp = first; first = second; second = tmp;
     } 
  }
  cout << first << endl << second << endl << third << endl;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

double dp[3005][3005];

int main() {
  std::cout << std::fixed << std::setprecision(10);
  ll N;
  scanf("%lld", &N);

  vector<double> list(N);
  for (ll i = 0; i < N; i++) {
    double v;
    scanf("%lf", &v);
    list[i] = v;
  }

  dp[0][0] = 1;
  for (ll i = 1; i <= N; i++) {
    double p = list[i - 1];
    // cout << "p:" << p << endl;
    for (ll j = 0; j <= i; j++) {
      dp[i][j] += dp[i - 1][j] * (1 - p);
      dp[i][j + 1] += dp[i - 1][j] * p;
    }
  }

  double p = 0;
  ll n = (N / 2) + 1;
  for (ll i = n; i <= N; i++) {
    // cout << dp[3][i] << endl;
    p += dp[N][i];
  }
  cout << p << endl;
}


Measured memory_bytes: 68992
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
 
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.rbegin(), a.rend());
  long long ans = 0;
  int t = n-1;
  rep(i, n){
    int lim = 2;
    if(i == 0) lim = 1;
    rep(j, lim){
      if(t > 0){
        ans += a[i];
        t--;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4056
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int n;
    ll d;
    cin >> n >> d;
    int cnt = 0;
    for (int i=0; i<n; i++) {
        ll x, y; cin >> x >> y;
        if (x * x + y * y <= d * d) {
            cnt++;
        }
    }
    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
const int BLACK=1;
const int WHITE=2;
int n,m,q;
int table[10][10][10];//[x][y][z] 1=black 2=white
int cnt[10][10];//[x][y]のこすう
int d[26][3]={
{1,0,0},{0,1,0},{0,0,1},
{1,1,0},{0,1,1},{1,0,1},{-1,1,0},{0,-1,1},{1,0,-1},
//{1,1,1},{-1,1,1},{1,-1,1},{1,1,-1}
{1,1,1},{1,-1,1},{1,1,-1},{1,-1,-1}
};

int check(){

	rep(i,n){
		rep(j,n){
			rep(k,n){//i,j,kが始点
				int x=i,y=j,z=k;
				int nx=x,ny=y,nz=z;
				int WIN=table[x][y][z];
				if(WIN==0)break;


				for(int pat=0;pat<13;pat++){
				bool f=1;
					for(int c=0;c<m;c++){
						nx=x+c*d[pat][0];
						ny=y+c*d[pat][1];
						nz=z+c*d[pat][2];
						if(nx<0||ny<0||nz<0||nx>=n||ny>=n||nz>=n||table[nx][ny][nz]!=WIN)f=0;
					}
					if(f)return WIN;
				}
			}
		}
	}
	return 0;
}
int dist[3]={-1,0,1};
int main(){
while(cin>>n>>m>>q,n||m||q){
rep(i,10)rep(j,10)rep(k,10)table[i][j][k]=0;
rep(i,10)rep(j,10)cnt[i][j]=0;
bool ok=0;
int ct=0;
/*
rep(i,3){
	rep(j,3){
		rep(k,3){
			int x,y,z;
				x=dist[i];
				y=dist[j];
				z=dist[k];
				if(x+y+z==0)continue;
				d[ct][0]=x;
				d[ct][1]=y;	
				d[ct][2]=z;
				ct++;
		}
	}
}*/


//rep(i,27)cout<<d[i][0]<<" "<<d[i][1]<<" "<<d[i][2]<<endl;

int x,y;
rep(i,q){
	cin>>x>>y;
	x--;
	y--;
	int now=0,nz;
	if((i+1)%2)now=BLACK;
	else now=WHITE;
	
	nz=cnt[x][y];
	table[x][y][nz]=now;
	cnt[x][y]++;


	if(check()==WHITE&&!ok){cout<<"White "<<i+1<<endl;ok=1;}
	if(check()==BLACK&&!ok){cout<<"Black "<<i+1<<endl;ok=1;}
}



/*rep(i,n){
	rep(j,n){
		rep(k,n){
			cout<<table[i][j][k];
		}
		cout<<endl;
	}
		cout<<endl;
}*/

if(!ok)cout<<"Draw"<<endl;
}
	return 0;
}


Measured memory_bytes: 3076
sx,sy,tx,ty= map(int, input().split())
a=""
for i in range(tx-sx):
  a+="R"
for i in range(ty-sy):
  a+="U"
for i in range(tx-sx):
  a+="L"
for i in range(ty-sy):
  a+="D"
a+="D"
for i in range(tx-sx+1):
  a+="R"
for i in range(ty-sy+1):
  a+="U"
a+="LU"
for i in range(tx-sx+1):
  a+="L"
for i in range(ty-sy+1):
  a+="D"
a+="R"
print(a)

Measured memory_bytes: 3064
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for h in range(H):
        if h == 0:
            print('#' * W)
        elif h != 0 and h != H - 1:
            print('#', '.' * (W - 2), '#', sep='')
        elif h == H - 1:
            print('#' * W)
    print()


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

vector<pair<int, int> > bridge;
vector<int> graph[100010];
pair<int, int> edge[200010];
vector<pair<int, int> > treeGraph[200010];

int pre[100010];
int low[100010];
int com[100010];
int n, m;
int visited_cnt = 0;

int dis_dfs(int idx, int from){
    pre[idx] = visited_cnt;
    visited_cnt++;
    low[idx] = pre[idx];

    for(int i = 0;i < graph[idx].size();i++){
        int to = graph[idx][i];
        if(pre[to] == -1){
            low[idx] = min(low[idx], dis_dfs(to, idx));
            if(low[to] == pre[to]){
                //bridge.push_back(make_pair(min(idx, to), max(idx, to)));
            }
        }else{
            if(from != to){
                low[idx] = min(low[idx], low[to]);
            }
        }
    }

    return low[idx];
}

void disGraph(){
    memset(pre, -1, sizeof(pre));
    memset(low, -1, sizeof(low));

    dis_dfs(0, -1);

    for(int i = 0;i < m;i++){
        int fi = edge[i].first;
        int se = edge[i].second;
        if(pre[fi] < low[se] || pre[se] < low[fi]){
            bridge.push_back(make_pair(min(fi, se), max(se, fi)));
        }
    }

}

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

    for(int i = 0;i < m;i++){
        cin >> edge[i].first >> edge[i].second;
        //edge[i].first--, edge[i].second--;
        graph[edge[i].first].push_back(edge[i].second);
        graph[edge[i].second].push_back(edge[i].first);
    }

    disGraph();

    sort(bridge.begin(), bridge.end());

    for(int i = 0;i < bridge.size();i++){
        cout << bridge[i].first << " " << bridge[i].second << endl;
    }

    return 0;
}


Measured memory_bytes: 13604
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 1000000000
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;
vector<vector<bool>> graph;
vector<bool> reached;
ll MOD = 998244353;

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i=0;i<N;i++) cin >> A[i];
    vector<ll> ans;
    for(int i=N-1;i>=0;i-=2){
        ans.push_back(A[i]);
    }
    for(int i=N%2;i<N;i+=2){
        ans.push_back(A[i]);
    }
    for(int a : ans){
        cout << a << ' ';
    }
    cout << endl;
}


Measured memory_bytes: 5488
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

int main(){
	
	int A,B;
	cin >> A >> B;
	int ans = 0;
	for(int i=100;i<=999;i++){
		int num = i * 100 + (i / 10) % 10 * 10 + i / 100;
		if(InRange(num, A, B + 1)) ans++;
	}
	
	cout << ans << endl;
	
	
	
	
    return 0;
}

Measured memory_bytes: 256
use std::io::stdin;

fn main() {
    let mut nk = String::new();
    stdin().read_line(&mut nk).unwrap();
    let nk: Vec<usize> = nk.trim().split_whitespace().flat_map(str::parse).collect();
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();

    let (n, k) = (nk[0], nk[1]);
    let s = s.trim();
    let mut start = None;
    let mut ps = Vec::new();
    let mut ss: Vec<_> = s.chars().collect();
    ss.push('1');
    for i in 0..n + 1 {
        match ss[i] {
            '0' if start == None => {
                start = Some(i);
            }
            '1' if start != None => {
                ps.push((start.unwrap(), i));
                start = None;
            }
            _ => {}
        }
    }

    let mut result = None;
    for i in 0..if ps.len() as isize - k as isize + 1 <= 0 { 1 } else { ps.len() - k + 1 } {
        let start = if i > 0 { ps[i - 1].1 } else { 0 };
        let end = if i + k < ps.len() { ps[i + k].0 } else { n };
        if result == None || result < Some(end - start) {
            result = Some(end - start);
        }
    }
    println!("{}", result.unwrap());
}


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

int main() {
    int N, K;
    cin >> N >> K;
    if(K == 1){
        cout << 0;
    }else{
        cout << N - K;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int X,Y;
  cin >> X >> Y;
  bool ans= false;
  for(int i=0; i<=X; i++){
    if(4*X-2*i==Y){
      ans = true;
      break;
    }
  }
  if(ans){
    cout << "Yes" << endl;
  }
    else{
      cout<< "No" << endl;
    }
}

    
    


Measured memory_bytes: 3504
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) x.begin(),x.end()
#define fi first
#define se second
#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<LL> VLL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long double LD;
typedef pair<LD,LD> PLD;
typedef vector<LD> VLD;
typedef vector<PLD> VPLD;
typedef map<int, int> MII;
typedef map<int, VI> MIVI;
typedef map<LL, LL> MLLLL;
typedef map<LL, VLL> MLLVLL;

template<typename T>
void dbg(T a)
{
      #ifdef LOCAL
            cerr<<a<<"\n";
      #endif
}

template<typename T, typename ...Arg>
void dbg(T a,Arg ...arg)
{
      #ifdef LOCAL
            cerr<<a<<" ";
            dbg(arg...);
      #endif
}

const int maxn = (3e5)+7;
const int inf = (1e9)+7;
const LL LLinf = (1e18)+7;
const LD eps = 1e-9;
const LL mod = 998244353LL;

// ***************************** CODE ***************************** //

LL sil[maxn], odw[maxn];

LL pot(LL a, LL w)
{
      if(w == 0)
            return 1LL;
      LL b = pot(a, w / 2);
      b = (b * b ) % mod;
      if(w&1)
            b = (b * a) % mod;
      return b;
}

LL net(LL n, LL k)
{
      if(n >= k && k >= 0 && n < maxn)
            return (((sil[n] * odw[k]) % mod ) * odw[n - k] ) % mod;
      return 0LL;
}

int main()
{
      _upgrade
      sil[0] = 1;
      odw[0] = 1;
      for(int i = 1; i < maxn;i++)
      {
            sil[i] = (sil[i - 1] * (LL) i) % mod;
            odw[i] = pot(sil[i], mod - 2);
      }
      LL res = 0LL;
      int n;
      LL a, b, k;
      cin>>n>>a>>b>>k;
      for(int i = 0 ;i <= n;i++)
      {
            LL cur = k - i * a;
            if(cur % b != 0)
                  continue;
            LL j = cur / b;
            if(n >= j && j >= 0)
                  res = (res + net(n, i) * net(n, j)) % mod;
      }
      res = (res% mod + mod) % mod;
      cout<<res;
      return 0;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
    ll n,m;cin>>n>>m;
    vector<ll>a(n);
    vector<ll>h(n);
    rep(i,n)cin>>h[i];
    rep(i,m){
        ll u,v;cin>>u>>v;
        u--;v--;
        if(h[u]>=h[v])a[v]=1;
        if(h[u]<=h[v])a[u]=1;
    }
    ll ans=0;
    rep(i,n){
        if(a[i])continue;
        //cout<<i<<endl;
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4844
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <random>
#include <set>
#include <map>
#include <queue>
#include <bitset>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)

int main(){
	int n;
	cin >> n;
	int k = 1000000009,t,ans=0;
	FOR(i,0,n){
		cin >> t;
		ans += (t>k);
		k = t;
	}
	cout << ans << endl;
}



Measured memory_bytes: 3108
use std::io;
use std::cmp::min;

fn main() {
    let mut nums: Vec<i32> = Vec::with_capacity(4);
    for _ in 0..4 {
        let mut buf: String = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        nums.push(buf.trim().parse::<i32>().unwrap());
    }
    let x = nums[3];
    let mut a = min(x / 500, nums[0]);
    let mut cnt = 0;
    while a >= 0 {
        let mut b = min((x - a * 500) / 100, nums[1]);
        while b >= 0 {
            let c = (x - a * 500 - b * 100) / 50;
            if c > nums[2] { break; }
            cnt += 1;
            b -= 1;
        }
        a -= 1;
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4352
#include <iostream>
#include<string>
using namespace std;
int main()
{
  int a,b,v,m;
  string op;
  cin>>a>>op>>b;
  if(op=="+"){
    v=a+b;
    cout<<v;
  }
  else if(op=="-"){
      m=a-b;
      cout<<m;
  }

        return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

    ll count = 0;
    for (int i = 0; i <= 9; i++) {
        for (int j = 0; j <= 9; j++) {
            for (int k = 0; k <= 9; k++) {
                for (int h = 0; h <= 9; h++) {
                    if (i+j+k+h >= a && i+j+k+h <= b && 1000*i + 100*j + 10*k + h <= n && 1000*i + 100*j + 10*k + h >= 1) {
                        count += 1000*i + 100*j + 10*k + h;
                    } 
                }
            }
        }
    }
    if (n == 10000 && a == 1) {
        count += 10000;
    } 

    cout << count << endl;

    return 0;
}





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

struct S {
	int x,d;
};

int n,m;
int a[100005],v[100005];
vector<S> e[100005];
int ok = 1;

void dfs(int at) {
	v[at] = 1;
	for (int i=0; i<e[at].size(); i++) {
		int nt = e[at][i].x;
		int nd = e[at][i].d;
		//printf("%d -> %d = %d\n",at,nt,nd);
		if (v[nt] == 0) {
			a[nt] = a[at]+nd;
			dfs(nt);
		}
		else {
			if (a[nt] != a[at]+nd) ok = 0;
		}
	}
}

int main() {
    scanf("%d%d",&n,&m);
    for (int i=0; i<m; i++) {
		int xx,yy,dd;
        scanf("%d%d%d",&xx,&yy,&dd);
		S s;
		s.x = yy; s.d = dd;
        e[xx].push_back(s);
        s.x = xx; s.d = -dd;
        e[yy].push_back(s);
    }
    memset(v,0,sizeof(v));
    for (int i=1; i<=n; i++) {
		if (v[i] == 0) {
			a[i] = 0;
			dfs(i);
		}
    }
	if (ok) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 12416
i = 1
while i <= 4:
    t,n =map(int,input().split())
    if t ==1:
        n1 = n * 6000
        print(n1)
    elif t == 2:
        n2 = n * 4000
        print(n2)
    elif t == 3:
        n3 = n*3000
        print(n3)
    else:
        n4 = n*2000
        print(n4)
        
    i += 1


Measured memory_bytes: 5596
#include <cstdio>
int N, M, a, b, l, r, z = 1 << 29, q[5009], c[5009], t[5009], s[5009], d[5009], g[5009][5009], v[5009][5009];
int main() {
	scanf("%d%d", &N, &M);
	for (int i = 0; i < N; i++) scanf("%d%d", &c[i], &t[i]);
	for (int i = 0; i < M; i++) scanf("%d%d", &a, &b), a--, b--, g[a][s[a]++] = b, g[b][s[b]++] = a;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) d[j] = v[i][j] = z;
		for (l = r = d[i] = 0, q[r++] = i; l != r; l++) {
			for (int j = 0; j < s[q[l]]; j++) {
				if (d[g[q[l]][j]] == z) d[g[q[l]][j]] = d[q[l]] + 1, q[r++] = g[q[l]][j];
			}
		}
		for (int j = 0; j < N; j++) {
			if (d[j] <= t[i]) v[i][j] = c[i];
		}
	}
	for (int i = 0; i < N; i++) d[i] = t[i] = z; d[0] = 0;
	for (int i = 0; i < N; i++) {
		int u = z;
		for (int j = 0; j < N; j++) {
			if (t[j] && (u == z || d[u] > d[j])) u = j;
		}
		t[u] = 0;
		for (int j = 0; j < N; j++) {
			if (d[j] > d[u] + v[u][j]) d[j] = d[u] + v[u][j];
		}
	}
	printf("%d\n", d[N - 1]);
	return 0;
}


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

int main(){
  int k,s;
  cin>>k>>s;
  ll cnt=0;
  REP(i,k+1){
    REP(j,k+1){
      if(s-i-j<=k&&s-i-j>=0){
        cnt++;
      }
    }
  }
  cout<<cnt<<endl;
  }

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int n,m,p,i,summ,sump,div;
  for(;;)
    {
      sump=0;
      scanf("%d %d %d",&n,&m,&p);
      if(m==0 && n ==0 && p==0){break;}
      int player[n];
      for(i=0;i<n;i++)
	{
	  scanf("%d",&player[i]);
	  sump=sump+player[i];
	}
      summ=sump*(100-p);
      if(player[m-1]==0){printf("%d\n",0);}
      else
	{
	div=summ/player[m-1];
	/*printf("sump=%d summ=%d div=%d\n",sump,summ,div);*/
	printf("%d\n",div);
	}
    }
  return 0;
}

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

using namespace std;

typedef map<int, int> mp;

int main() {
	
	int n, m, val;
	scanf("%d", &n);
	m = n;
	mp p;
	for (int i = 0; i < n; i++) {
		scanf("%d", &val);
		if (val == 1)
			m--;
		if(val % 2 == 0) {
			p[2]++;
			while(val % 2 == 0)
				val /= 2;
		}
		for(int j = 3; j < sqrt(val) + 1; j+= 2){
			if(val % j == 0) {
				p[j]++;
				while(val % j == 0)
					val /= j;
			}
		}
		if (val > 1)
			p[val]++;
	}
	
	int pairwise = 1;
	int no = 0;
	mp::iterator it;
	for(it = p.begin(); it != p.end(); it++) {
		if (it->second > 1)
			pairwise = 0;
		if (it->second == m)
			no = 1;
	}
		
	if (pairwise)
		printf("pairwise coprime");
	else if (!no || m < n)
		printf("setwise coprime");
	else
		printf("not coprime");
	
	return 0;
}

Measured memory_bytes: 7496
n = int(input())
p = list(map(int,input().strip().split()))

cnt = 0
for i in range(1,n-1):
	if int(p[i-1])<int(p[i]) and int(p[i])<int(p[i+1]):
		cnt+=1
	if int(p[i-1])>int(p[i]) and int(p[i])>int(p[i+1]):
		cnt+=1
print(cnt)



Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef pair<int,int> P;
P q[101000];int n;
int col[620][620],s[620][620],top=0;
void dfs(int x,int y,int t)
{
	col[x][y]=t;
	for(int i=1;i<=top;i++)
	{
		int dx=x+q[i].first,dy=y+q[i].second;
		if(dx<0||dx>=2*n||dy<0||dy>=2*n||col[dx][dy]!=-1)continue;
		dfs(dx,dy,t^1);
	}
}
void solve(int d)
{ 
	top=0;
	for(int i=0;i*i<=d;i++)
	for(int j=0;j*j<=d;j++)
		if(i*i+j*j==d)
		top++,q[top].first=i,q[top].second=j,top++,q[top].first=-i,q[top].second=-j,
		top++,q[top].first=-i,q[top].second=j,top++,q[top].first=i,q[top].second=-j,
	memset(col,-1,sizeof(col));
	for(int i=0;i<2*n;i++)
	for(int j=0;j<2*n;j++)if(col[i][j]==-1)dfs(i,j,1);
}
int main()
{
	int d1,d2;scanf("%d%d%d",&n,&d1,&d2); 
	solve(d1);
	for(int i=0;i<2*n;i++)
	for(int j=0;j<2*n;j++)s[i][j]=col[i][j];
	solve(d2);
	for(int i=0;i<2*n;i++)
	for(int j=0;j<2*n;j++)s[i][j]=s[i][j]*2+col[i][j]; 
	for(int k=0;k<=3;k++)
	{
		int sum=0;
		for(int i=0;i<2*n;i++)
		for(int j=0;j<2*n;j++)
			if(s[i][j]==k)sum++;
		if(sum>=n*n)
		{
			sum=n*n;
			for(int i=0;i<2*n;i++)
			for(int j=0;j<2*n;j++)
				if(s[i][j]==k&&sum>0)sum--,printf("%d %d\n",i,j);
			return 0;
		 } 
	}
	return 0;
}

Measured memory_bytes: 20736
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define MAX ((ll)(2e9))
#define pi (acos(-1))
#define M ((ll)(998244353))
#define NN ((ll)(1e4+2))
#define N ((ll)(1e5 + 5))
#define eps 0
#define log 20


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;

typedef tree < ll,  null_type,  less < ll >,  rb_tree_tag,  tree_order_statistics_node_update > o_set;
/// typedef tree < pair < ll,ll >,  null_type,  less < pair < ll,ll > >,  rb_tree_tag,  tree_order_statistics_node_update > o_setp;
/// o_set s;
/// s.order_of_key(k) : Number of items strictly smaller than k .
/// *(s.find_by_order(k)) : K-th element in a set (counting from zero).

int arr[N];


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

    for(int i = 0; i<n; i++){
        cin>>arr[i];
    }

    sort(arr,arr+n);

    if(arr[0]==arr[n-1] && arr[0]==n-1){
        cout<<"Yes\n";
        return 0;
    }

    if(arr[0]!=arr[n-1] && arr[0]+1!=arr[n-1]){
        cout<<"No\n";
        return 0;
    }

    int col = arr[n-1];
    int rem;
    if(arr[0]!=arr[n-1]){

        for(int i = 0; ; i++){
            if(arr[i]==arr[n-1]){
                col -= i;
                rem = n-i;
                break;
            }
        }
    }
    else rem = n;

    if(col>0 && col*2<=rem){
        cout<<"Yes\n";

    }
    else{
        cout<<"No\n";

    }

    return 0;


}


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

int main()
{
    string s;
    long long int k;
    cin >> s >> k;
    long long int ans = 0, b = 0, c = 0;

    long long int size = s.size() - 1;
    for(long long int i = 0;i < size;i++){
        if(s[i] == s[i + 1]){
            c++;
        }
        else{
            if(c != 1){
                c++;
                b += c / 2;
            }
            else{
                
                b += c;
            }
            c = 0;
        }
    }
    if(c != 1){
        c++;
        b += c / 2;
    }
    else{
        b += c;
    }
    ans = b * k;
    long long int g = 1, o = 1;
    for(long long int i = 0;i < size;i++){
        if(s[i] == s[i + 1]){
            g++;
        }
        else{
            break;
        }
    }
    for(long long int i = size;i > 0;i--){
        if(s[i] == s[i - 1]){
            o++;
        }
        else{
            break;
        }
    }
    if(s[0] != s[size]){
        g = o = 0;
    }
    if(g % 2 == 1 && o % 2 == 1 && g != size + 1){
        ans += k - 1;
    }

    if(size + 1== g){
        ans = (g * k) / 2;
    }

    cout << ans;

    return 0;
}


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


int main() {
  int n, k;
  cin >> n >> k;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  sort(l.rbegin(),l.rend());
  int ans = 0;
  rep(i,k){
    ans += l[i];
  } 
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<stdlib.h>
#include<ctime>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LL long long
#define FOR(i,a,b) for (int i=a;i<=b;i++)
#define FORD(i,a,b) for (int i=a;i>=b;i--)
using namespace std;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
char s[500010];
int n,m,he,ta,q[500010],nxt[500010],hed[500010],too[500010],x,y,A[500010],B[500010],nedge;
bool gg[500010];
void ae(int x,int y){
	nxt[++nedge]=hed[x];
	hed[x]=nedge;
	too[nedge]=y;
}
int main(){
	cin>>n>>m;
	scanf("%s",s+1);
	FOR(i,1,m){
		getint(x),getint(y);
		A[x]+=(s[y]=='A');
		B[x]+=(s[y]=='B');
		A[y]+=(s[x]=='A');
		B[y]+=(s[x]=='B');
		ae(x,y),ae(y,x);
	}
	he=0,ta=0;
	FOR(i,1,n) if (!A[i] || !B[i]) gg[i]=1,q[++ta]=i;
	while (he!=ta){
		int x=q[++he];
		for (int i=hed[x];i;i=nxt[i]){
			int y=too[i];
			if (s[x]=='A') --A[y]; else --B[y];
			if ((!A[y] || !B[y]) && !gg[y]){
				gg[y]=1;
				q[++ta]=y;
			}
		}
	}
	if (he!=n) puts("Yes"); else puts("No");
    return 0;
}

Measured memory_bytes: 11520
def main():
    S = list(input())
    r = 0

    for i in range(len(S) - 1):
        if S[i] != S[i + 1]:
            r += 1

    S.reverse()
    l = 0

    for i in range(len(S) - 1):
        if S[i] != S[i + 1]:
            l += 1        

    print(min(r, l))
if __name__ == "__main__":
    main()

Measured memory_bytes: 9628
using System;

class MyClass
{
    static void Main(string[] args)
    {
        string str = "";
        while ((str = Console.ReadLine()) != null)
        {
            int n = int.Parse(str);
            int count = 0;
            for (int a = 0; a < 10; a++)
            {
                for (int b = 0; b < 10; b++)
                {
                    for (int c = 0; c < 10; c++)
                    {
                        for (int d = 0; d < 10; d++)
                        {
                            if (a + b + c + d == n) { count++; }
                        }
                    }
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    map<char, int> m;
    for(int i =0; i<s.size(); i++){
        m[s[i]]++;
    }
    for(auto it:m){
        if(it.second%2==1) {cout<<"No"; return 0;}
    }

    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define read cin >>
#define echo cout <<
#define fin << '\n'
#define _ << ' ' <<
#define in :
#define var auto&&
#define let const auto

int gcd ( int a, int b ) {
    return b == 0 ? a : gcd ( b, a%b );
}

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

signed main ( ) {

    int n, m;
    read n >> m;

    vector<int> a(n);

    int tmp = 1;

    for ( var i in a ) {
        read i, i /= 2, tmp = lcm(tmp, i);
        if ( tmp > m ) {
            echo 0 fin;
            return 0;
        }
    }

    int cnt = 0;
    for ( int i = a[0]; i % 2 == 0; i /= 2, cnt++ );
    for ( int i = 0; i < n; i++ ) {
        int CNT = 0;
        for ( int j = a[i]; j % 2 == 0; j /= 2, CNT++ );
        if ( CNT != cnt ) {
            echo 0 fin;
            return 0;
        }
    }

    int ans = 0;
    for ( int i = tmp; i <= m; i += tmp + tmp ) {
        ans++;
    }
    echo ans fin;

    return 0;
}

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

const int N = 110;

int a[N];
int n;

int main(){
	scanf("%d", &n);
	int sum = 0;
	for (int i = 0; i < n; ++ i){
		scanf("%d", &a[i]);
		sum += a[i];
	}
	if (sum % 10){
		return printf("%d\n", sum), 0;
	}
	int max = 0;
	for (int i = 0; i < n; ++ i){
		if ((sum - a[i]) % 10){
			max = std::max(max, sum - a[i]);
		}
	}
	return printf("%d\n", max), 0;
}

Measured memory_bytes: 256
import copy
N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

A_copy = copy.copy(A)
A_copy.sort(reverse=True)

for i in range(N):
    if A[i] == A_copy[0]:
        print(A_copy[1])
    else:
        print(A_copy[0])

Measured memory_bytes: 14584
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int X;
  cin>>X;
  rep(i,X){
    for(int b=1;b<=31;b++){
      for(int k=2;k<=9;k++){
        if(X-i==pow(b,k)){
          cout<<X-i<<endl;
          return 0;
        }
      }
    }
  }
}

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

using namespace std;
int main(void) {
	int N;
	bool isYes = true;
	string W[100];
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		cin >> W[i];
	}
	for (int i = 1; i < N; i++) {
		if (W[i].front() != W[i - 1].back()) {
			isYes = false;
			break;
		}
		for (int j = 0; j < i; j++) {
			if (W[i] == W[j]) {
				isYes = false;
			}
		}

		if (isYes == false) {
			break;
		}
	}

	if (isYes == true) {
		printf("Yes");
	} else {
		printf("No");
	}

	return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.lang.*;


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


        int N = in.nextInt();

        Set<Integer> batya = new HashSet<Integer>();
        for(int i = 0; i<N; i++){
            int n = in.nextInt();
            if(batya.contains(n))
                batya.remove(n);
            else batya.add(n);
        }
        System.out.println(batya.size());
    }
}

Measured memory_bytes: 63048
n = int(input())
h = list(map(int,input().split()))
lst = []
cnt = 0
z = n - 1

for idx,i in enumerate(h):
	if idx == z:
		lst.append(cnt)
		break
	if i >= h[idx+1]:
		cnt += 1
	else:
		lst.append(cnt)
		cnt = 0
		
print(max(lst))

Measured memory_bytes: 14252
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
#include <ios>
using namespace std;
int main(void){
  int N;
  cin >> N;

  vector<vector<int> >height(N,vector<int>(3,0));

  for(int i=0;i<N;i++){
    for(int j=0;j<3;j++){
      cin >> height[i][j];
    }
  }

  int ans_x = 0;
  int ans_y = 0;
  int height_ans = 0;

  for(int x=0;x<101;x++){
    for(int y=0;y<101;y++){
      int height_pre;
      for(int i=0;i<N;i++){
        if(height[i][2] != 0){
        height_pre = height[i][2] + abs(height[i][0] - x) + abs(height[i][1] - y);
        break;
      }
    }

      bool fit_height = true;
      for(int i=0;i<N;i++){
        int height_ans_pre = height_pre - abs(height[i][0] - x) - abs(height[i][1] - y);
        if(height[i][2] != max(height_ans_pre,0))
        fit_height = false;
      }

      if(fit_height){
        ans_x = x;
        ans_y = y;
        height_ans = height_pre;
      }
      if(fit_height)
      break;
      //cout << x << " " << y << endl;
    }
    if(height_ans)
    break;
  }

    cout << ans_x << " " << ans_y << " " << height_ans << endl;

    return 0;

  }


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        String S = scan.next();
        StringBuilder sb = new StringBuilder(S);
        if (N % 2 != 0) {
            System.out.println("No");
            return;
        }
        String sub = sb.substring(0, N / 2);
        if (S.equals(sub+sub)) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 21844
N,K = map(int,input().split())
unchecked = set((range(1,N+1)))
#print(unchecked)
checked = set()

for i in range(K):
  d = int(input())
  A = set(map(int,input().split()))
  checked = A | checked

#print(checked)
unchecked -= checked
print(len(unchecked))

Measured memory_bytes: 9188
# 解説を見て解き直し
N, K = [int(x) for x in input().split()]

ranges = [tuple(int(x) for x in input().split()) for _ in range(K)]
ranges.sort()
p = 998244353

dpsum = [0] * (N + 1)
dpsum[1] = 1

for i in range(2, N + 1):
    dp = 0
    for l, r in ranges:
        rj = i - l
        lj = max(1, i - r)  # 1以上
        if rj <= 0: continue
        dp += dpsum[rj] - dpsum[lj - 1]
        dp %= p
    dpsum[i] = dpsum[i - 1] + dp
    dpsum[i] %= p

print(dp)

Measured memory_bytes: 16860
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#define maxn 100009
using namespace std;
const int MOD = 1e9 + 7;
int n, m;
int a[maxn];
long long cnt[maxn], num[maxn];
int main(){
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
	}
	for(int i = 1; i < n; i++){
		if(a[i] < a[i + 1]){
			cnt[a[i] + 1] += a[i];
			cnt[a[i + 1] + 1] -= a[i];
			num[a[i] + 1]++;
			num[a[i + 1] + 1]--;
		}
		else{
			if(a[i] + 1 <= m){
				cnt[a[i] + 1] += a[i];
				cnt[m + 1] -= a[i];
				num[a[i] + 1]++;
				num[m + 1]--;
			}
			cnt[1] += a[i] - m;
			cnt[a[i + 1] + 1] -= (a[i] - m);
			num[1]++;
			num[a[i + 1] + 1]--;
		}
	}
	for(int i = 0; i <= m + 1; i++){
		num[i] += num[i - 1];
		cnt[i] += cnt[i - 1];
	}
	long long ans = 0;
	for(int i = 1; i < n; i++){
		if(a[i] < a[i + 1]){
			ans += a[i + 1] - a[i];
		}
		else{
			ans += m - a[i] + a[i + 1];
		}
	}
	long long res = ans;
	//cout << res << endl;
	for(int i = 1; i <= m; i++){
		res = min(res, ans -(1LL * i * num[i] - cnt[i]  - num[i]));
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
using ull = unsigned long long;

#define rep(i,x) for(int i = 0; i<x; i++)

int main(){
    int x;
    cin >> x;
    if(x){
        cout << "0";
    }else{
        cout << "1";
    }
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repq(i,a,n) for(int i=a; i<=n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int main() {
    ll n, q, x; cin >> n >> x;
    ll a[100010]; rep(i,0,n) cin >> a[i];
    rep(i,0,x){
        cin >> q;
        ll sum = 0, ans = 0;
        ll j = 0;
        rep(i,0,n) {
            sum += a[i];
            while(sum > q) sum -= a[j++];
            ans += i - j + 1;
        }
        cout << ans << endl;
    }
    return 0;
}

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

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using i32 = int_fast32_t;
using u32 = uint_fast32_t;
using i64 = int_fast64_t;
using u64 = uint_fast64_t;

namespace chrono = std::chrono;
using namespace std::string_literals;

#define all(c) (c).begin(), (c).end()

__attribute__((constructor))
void fast_iostream() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);
}

int main() {
  u32 n; cin >> n;
  std::vector<i32> d(n);
  for (u32 i = 0; i < n; ++i) {
    cin >> d[i];
  }
  std::multiset<i32> ds(all(d));
  u32 m; cin >> m;
  std::vector<i32> t(m);
  for (u32 i = 0; i < m; ++i) {
    cin >> t[i];
  }

  for (i32 x: t) {
    auto p = ds.find(x);
    if (p == ds.end()) {
      cout << "NO"s << endl;
      std::exit(0);
    }
    ds.erase(p);
  }
  cout << "YES"s << endl;
}


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

int solve(const vector<int>& v, int k) {
  int x = 0;
  while (k * x - x + 1 < v.size()) {
    x++;
  }
  return x;
}

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; i++)
    cin >> v[i];
  cout << solve(v, k) << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef signed long long int ll;

int n;
vpii pos(10);
double avg=0;

void f(int c, int b, double sum) {
    if(b+1==(1<<n)) {
        avg += sum;
        return;
    }
    FOR(i,n) {
        if((b&(1<<i))==0) {
            double d = c>=0 ? hypot(pos[i].first-pos[c].first, pos[i].second-pos[c].second) : 0;
            f(i, b|(1<<i), sum+d);
        }
    }
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    cin>>n;
    FOR(i,n) {
        cin>>pos[i].first>>pos[i].second;
    }

    f(-1, 0, 0);
    RNG(i,2,n)
    avg/=i;
    cout<<setprecision(12)<<avg<<endl;
    return 0;
}



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

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  if(a[0] == 0){
    cout << 0 << endl;
    return 0;
  }
  ll ans = 1;
  rep(i,n){
    if(ans > 1000000000000000000 / a[i]){
      cout << -1 << endl;
      return 0;
    }
    ans *= a[i];
  }
  cout << ans << endl;
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n;cin >> n;
    vector<int> a(n);rep(i,n)cin >> a[i];
    int i;
    int ans = 0;
    int mn = INF;
    for (i = -100; i <= 100; i++)
    {
        int diff = 0;
        for (int j = 0; j < n; j++)
        {
            diff += (abs(i - a[j]) * abs(i - a[j]));
        }
        if(diff < mn)
        {
            mn = diff;
            ans = diff;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

using ull = unsigned long long;


constexpr ll initVal = 0LL;     //TODO: fix type and value
constexpr ll initLazy = 0LL;    //TODO: fix type and value
template <typename T>
struct Node {
    T val;
    T lazy;
    ull l, r;
    Node<T>* l_node = nullptr;
    Node<T>* r_node = nullptr;
    Node(ull l, ull r, const T& val = initVal) : l(l), r(r), val(val), lazy(initLazy) {}
    T getVal() {
        return val + lazy * (r - l); //TODO: fix
    }
    T f1(const T& a, const T& b) {
        return a+b;               //TODO: fix
    }
    T f2(const T& a, const T& b) {
        return a+b;                       //TODO: fix
    }
    void push() {
        if(r - l > 1) {
            auto m = (l+r)/2;
            {
                if(l_node == nullptr) l_node = new Node(l, m);
                if(lazy != initLazy) l_node->lazy = f2(l_node->lazy, this->lazy);
            }
            {
                if(r_node == nullptr) r_node = new Node(m, r);
                if(lazy != initLazy) r_node->lazy = f2(r_node->lazy, this->lazy); 
            }
        }
        val = getVal();
        lazy = initLazy;
    }
    void fix() {
        if(r - l == 1) return;
        val = f1(l_node->getVal(), r_node->getVal());
    }
    T query(ull qL, ull qR) {
        if(qR <= l || r <= qL) return initVal;
        if(qL <= l && r <= qR) return getVal();
        if(r - l == 1)  return getVal();

        push();
        T l_val = l_node->query(qL, qR), r_val = r_node->query(qL, qR);
        return f1(l_val, r_val);
    }
    void update(ull uL, ull uR, const T& uVal) {
        if(uR <= l || r <= uL) return;
        if(uL <= l && r <= uR) lazy = f2(lazy, uVal);
        else {
            push();
            l_node->update(uL, uR, uVal);
            r_node->update(uL, uR, uVal);
            fix();
        }
    }
};

template <typename T>
struct DynamicLazySegTree {
    Node<T> root;
    DynamicLazySegTree(ull l, ull r, const T& val) : root(l, r, val) {}
    T query(ull l, ull r) {
        return root.query(l, r);
    }
    void update(ull l, ull r, const T& val) {
        root.update(l, r, val);
    }
};


int main(){
    int n, q;
    cin >> n >> q;
    DynamicLazySegTree<ll> st(0, n, initVal);
    rep(i, q) {
        int query;
        cin >> query;
        if(query == 0) {
            int s, t, x;
            cin >> s >> t >> x;
            --s;
            st.update(s, t, x);
        }
        else {
            int s, t;
            cin >> s >> t;
            --s;
            cout << st.query(s, t) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 14916
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int a[4005] = {0};
    int n;

    rep(i,1001) rep(j,1001) a[i + j]++;

    while(cin >> n){
        int ans = 0;
        rep(i,n + 1){
            ans+= a[i] * a[n - i];
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1184
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int k; readV(k);
  writeln((k/2) * ((k+1)/2));
}


Measured memory_bytes: 256