akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define reps(i,x) for(ll i=1;i<=(ll)(x);i++)
#define rrep(i,x) for(ll i=((ll)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(ll)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;

int a[100001];
int b[100001];
int n, x;

char swtch(char c){
  return c == '0' ? '1' : '0';
}

int main() {
  string s;
  cin >> s;
  int cnt1 = 0;
  int cnt2 = 0;
  char com = '0';
  rep(i, s.size()){
    if(s[i] != com) cnt1++;
    com = swtch(com);
  }
  com = '1';
  rep(i, s.size()){
    if(s[i] != com) cnt2++;
    com = swtch(com);
  }
  cout << min(cnt1, cnt2) << endl;
  return 0;
}



Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<cstring>
#include<climits>
#include<sstream>
#include<deque>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)

using namespace std;

typedef long long ll;

#define MAX_N 100010

int n;
string s;
int ans[MAX_N];

bool check() {
  rep(i,n) {
    int next = ( i + 1 ) % n;
    int prev = ( i - 1 + n ) % n;
    if( ans[i] == 0 ) {
      if( s[i] == 'o' ) {
	if( !( ans[prev] == ans[next] ) ) return false;
      } else {
	if( !( ans[prev] != ans[next] ) ) return false;
      }
    } else {
      if( s[i] == 'o' ) {
	if( !( ans[prev] != ans[next] ) ) return false;
      } else {
	if( !( ans[prev] == ans[next] ) ) return false;
      }
    }
  }
  return true;
}

bool calc(int a,int b) {
  memset(ans,-1,sizeof ans);
  ans[0] = a, ans[1] = b;
  REP(i,1,n-1) {
    int next = ( i + 1 ) % n;
    int prev = ( i - 1 + n ) % n;
    if( s[i] == 'o' ) {
      if( ans[i] == 0 ) {
	ans[next] = ans[prev];
      } else {
	ans[next] = (ans[prev]+1)%2;
      }
    } else {
      if( ans[i] == 0 ) {
	ans[next] = (ans[prev]+1)%2;
      } else {
	ans[next] = ans[prev];
      }
    }
  }
  return check();
}

void compute() {
  rep(i,2) {
    rep(j,2) {
      if( calc(i,j) ) {
	rep(k,n) {
	  if( ans[k] == 0 ) cout << "S";
	  else cout << "W";
	} puts("");
	return;
      }
    }
  }
  puts("-1");
}

int main() {
  cin >> n >> s;
  compute();
  return 0;
}

Measured memory_bytes: 896
#include <complex.h>
#include <cmath>
#include <iostream>
#include <vector>
#include <stdio.h>

using namespace std;

typedef complex<double> xy_t;

double dot_product(xy_t a, xy_t b) {
  return (conj(a)*b).real();
}

double cross_product(xy_t a, xy_t b) {
  return (conj(a)*b).imag();
}

int main() {
  xy_t P[110];
  int N = 0;
  double x, y;
  
  while(scanf("%lf,%lf", &x, &y)!= EOF) {
    xy_t entry(x,y);
    P[N++] = entry;
  }

  //center all coordinates based on first element
  for (int i = 1; i < N; i++) {
    P[i] -= P[0];
  }
  
  //calculate sum
  double sum = 0.0;
  for (int i = 1; i+1 < N ; i++) {
    xy_t  a = P[i] , b = P[i + 1];
    sum += cross_product(a, b) / 2.0;
  }

  printf("%.6f\n", abs(sum));
  
}

Measured memory_bytes: 3112
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
bool isPrime(ll n); // 素数か
vector<ll> primes(ll n); // 素因数分解
int ctoi(char c){return c - '0';}

const ll COM_MAX = (ll)(1e6+100); // combinationの最大値
vector<ll> fac(COM_MAX),finv(COM_MAX),inv(COM_MAX);
void comb_init(); // 初期化
ll comb(ll n,ll k); // nCk


template<typename T>bool isOk(int key,T value){
  return key <= value.fi;
}
template<typename T>T binary_search(vector<pair<int,int>> a,T key){
  T ok = a.size();
  T ng = -1;
  while(abs(ok - ng) > 1){
    T mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}


// TODO: write
int main() { 
  string s;cin>>s;
  ll b = 0;
  ll ans = 0;
  for(auto&c : s){
    if(c == 'B')b++;
    else ans += b;
  }
  print(ans);
  return 0;
}




void comb_init(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<COM_MAX;++i){
    fac[i]=fac[i-1]*i%INF;
    inv[i]=INF-inv[INF%i]*(INF/i)%INF;
    finv[i]=finv[i-1]*inv[i]%INF;
  }
}

ll comb(ll n,ll k){
  if(n<k)return 0;
  if(n<0||k<0)return 0;
  return fac[n]*(finv[k]*finv[n-k]%INF)%INF;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}
vector<ll> primes(ll n){
  vector<ll> v;
  for (ll i = 2; i*i <= n; ++i) {
    while(n%i==0){
      n/=i;
      v.pb(i);
    }
  }
  if(n != 1)v.pb(n);
  return v;
}


/* 二分探索の時に使う
template<typename T>bool isOk(T key,T value){
  return key <= value;
}
template<typename T>T binary_search(vector<T> a,T key){
  T ok = a.size();
  T ng = -1;
  while(abs(ok - ng) > 1){
    T mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}
*/

Measured memory_bytes: 24068
#include<stdio.h>
int main(){

  int n;
  scanf("%d",&n);

  int MIN=100000000;
  int MAX=-100000000;
  long long SUM=0;
  int i;
  for(i=0;i<n;i++){

    int t;
    scanf("%d",&t);
    if(t<MIN){
      MIN=t;
    }
    if(t>MAX){
      MAX=t;
    }
    SUM+=t;
  }

  printf("%d %d %lld\n",MIN,MAX,SUM);
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <cstdio>
#include <cmath>

#define PI 3.141592
#define INF 100001
#define ll long long
#define loop(i,n) for(int i=0;i<n;i++)

using namespace std;

int main(){
    ll int n;
    cin>>n;
    char init[n];
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        init[i]=s[0];
    }
    ll int m=0;
    ll int a=0;
    ll int r=0;
    ll int c=0;
    ll int h=0;
    for(int i=0;i<n;i++){
        if(init[i]=='M'){
            m++;
        }else if(init[i]=='A'){
            a++;
        }else if(init[i]=='R'){
            r++;
        }else if(init[i]=='C'){
            c++;
        }else if(init[i]=='H'){
            h++;
        }
    }
    long long int ans=0;
    ans=m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    bool f[11][11] = {};
    rep(i, 0, m){
        int k;
        cin >> k;
        rep(j, 0, k){
            int in;
            cin >> in;
            in--;
            f[i][in] = true;
        }
    }
    vector<int> p(m);
    rep(i, 0, m) cin >> p[i];
    int ans = 0;
    for(int mask = 0; mask < (1 << n); mask++){
        bool g = true;
        for(int i = 0; i < m; i++){
            int cnt = 0;
            for(int j = 0; j < n; j++){
                if(f[i][j]){
                    if(mask & (1 << j)){
                        cnt++;
                    }
                }
            }
            if(cnt % 2 != p[i]){
                g = false;
            }
        }
        if(g) ans++;
    }
    cout << ans << endl;
}


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

namespace ConsoleAppAtCoderABC170
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(ReadLine());
            var A = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

            var aMax = A.Max();
            var cnt = new int[aMax + 1];

            foreach (var a in A)
            {
                if(cnt[a] != 0)
                {
                    cnt[a] = 2;
                    continue;
                }
                for (int i = a; i <= aMax; i+=a)
                {
                    cnt[i]++;
                }
            }

            var ans = 0;
            foreach (var a in A)
            {
                if(cnt[a] == 1)
                {
                    ans++;
                }
            }

            WriteLine(ans);
        }
    }
}


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

int main() {
    int n;
    cin >> n;
    vector<ll int> dp(n+1, 0);
    vector<int> h(n+1, 0);
    rep(i, 1, n+1) cin >> h[i];

    dp[2] = abs(h[1]-h[2]);

    for(int i = 3; i <= n; ++i) {
        dp[i] = min(dp[i-2] + abs(h[i]-h[i-2]), dp[i-1] + abs(h[i]-h[i-1]));
    }

    // rep(i,n+1) cout << i+1 << " " << dp[i+1] << endl;

    cout << dp[n] << endl;
}


Measured memory_bytes: 4184
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,d;
vector<int>q[15];
int main()
{
	cin>>n>>d;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=d;j++)
		{
			int m;
			cin>>m;
			q[i].push_back(m);
		}
	}
	int cou=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			int ans=0;
			for(int k=0;k<d;k++)
			ans+=(q[i][k]-q[j][k])*(q[i][k]-q[j][k]);
			int kk=sqrt(ans);
			if(kk*kk==ans)
			cou++;
		}
	}
	cout<<cou<<endl;
}

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

// int main(){
//     string s;
//     cin>>s;
//     int ans=0;
//     for(int i=0;i<s.size();i++){
//         for(int j=4;;j++){
//             if(i+j>s.size())break;
//             ll n=stoll(s.substr(i,j));
//             if(n%2019==0)ans++;
//         }
//     }
//     cout<<ans<<endl;
//     return 0;
// }

const int m=2019;

int main(){
    string s;
    cin>>s;
    int n=s.size();
    reverse(s.begin(),s.end());
    int x=1,tot=0;
    vector<int> cnt(m);
    ll ans=0;
    for(int i=0;i<n;i++){
        cnt[tot]++;
        tot+=(s[i]-'0')*x;
        tot%=m;
        ans+=cnt[tot];
        x=x*10%m;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int main() {
  int N, M;
  int a[100];
  cin >> N >> M;
  rep(i, N) {
    cin >> a[i];
  }

  int sum = 0;
  rep(i, N) {
    sum += a[i];
  }
  int key = sum / (4 * M);
  if(sum % (4 * M) == 0) key--;
  int ans = 0;
  rep(i, N) {
    if(a[i] > key) ans++;
  }

  if(ans >= M) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include <bits/stdc++.h>
#include<string>
#include<algorithm>
using namespace std;

int nextr[100010];
vector<int> rt[100100];
int record[100010];


int main(){
    int N,M;
    cin >> N >> M;
    /*
    for (int i =1;i<N+1;i++){
        for(int j=1;j<N+1;j++){
            route[i][j]=0;
        }
    }*/
    for(int i=1;i<N+1;i++)nextr[i]=record[i]=0;
    int A[M],B[M];
    for(int i=0;i< M;i++){
        cin >> A[i] >> B[i];
      //  route[A[i]][B[i]]= route[B[i]][A[i]]=1;
        rt[A[i]].push_back(B[i]);
        rt[B[i]].push_back(A[i]);
    }
    queue<int> q;
    q.push(1);
    record[1]=1;
    while (!q.empty()){
        int cur =q.front();
        q.pop();
        for(const auto&e:rt[cur]){
           if(record[e]==0){
               nextr[e]=cur;
               record[e]=1;//このタイミングで訪問済みにする
               q.push(e);
           } 
        }            

/*        for(int i=1;i<N+1;i++){
           if(route[cur][i]==1 && record[i]==0){
               nextr[i]=cur;
               record[i]=1;//このタイミングで訪問済みにする
               q.push(i);
           } 
        }
        */
    }
    cout << "Yes"<<endl;
    for(int i =2;i<N+1;i++){
        cout <<nextr[i] << endl;
    }
    return 0;
}



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

typedef vector<int> vi;

int N;
vector<vi> E;
vi G;

void dfs(int cur, int pre) {
	for (int i = 0; i < (int)E[cur].size(); ++i) {
		if (E[cur][i] != pre) {
			dfs(E[cur][i], cur);
			G[cur] ^= (G[E[cur][i]] + 1);
		}
	}
}

int main(void) {
	cin >> N;

	E.resize(N + 1);
	for (int i = 1; i < N; ++i) {
		int x, y;
		cin >> x >> y;
		E[x].push_back(y);
		E[y].push_back(x);
	}

	G.resize(N + 1, 0);
	dfs(1, 0);

	if (G[1] == 0)
		cout << "Bob\n";
	else
		cout << "Alice\n";
	return 0;
}


Measured memory_bytes: 10752
#include <iostream>
#include <cstdio>
using namespace std;
int N, W; long long f[101][100001], w[101], v[101];
int main()
{
    //freopen("KNAPSACK1.inp", "r", stdin);
    cin >> N >> W;
    for (int i = 1; i <= N; i++)
    {
        cin >> w[i] >> v[i];
    }
    for (int i = 0; i <= N; i++)
    {
        f[i][0] = 0;
    }
    for (int i = 0; i <= W; i++)
    {
        f[0][i] = 0;
    }
    for (int i = 1; i <= N; i++)
    {
        for (int j = 1; j <= W; j++)
        {
            if (j >= w[i])
            {
                f[i][j] = max(f[i-1][j], f[i-1][j-w[i]] + v[i]);
            }
            else
            {
                f[i][j] = f[i-1][j];
            }
        }
    }
    cout << f[N][W];
    return 0;
}


Measured memory_bytes: 79104
while s = gets do
  a, b, c, d, e, f = s.split().map(&:to_f)
  z = a*e - b*d 
  x = (c*e-f*b)/z + 0.000
  y = (f*a-c*d)/z + 0.000
  puts sprintf("%.3f %.3f", x, y)
end

Measured memory_bytes: 2336
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int h1 = sc.nextInt();
		int m1 = sc.nextInt();


		// 出力
		System.out.println(h1*m1);
	}
}

Measured memory_bytes: 35800
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def is_bipartite(graph, colors):
    stack = [(0, 1)]
    while stack:
        v, color = stack.pop()
        colors[v] = color
        for child in graph[v]:
            if colors[child] == color:
                return False
            if colors[child] == 0:
                stack.append((child, -color))
    return True


def solve():
    N, M = map(int, rl().split())
    graph = [[] for _ in range(N)]
    for _ in range(M):
        a, b = map(lambda x: int(x) - 1, rl().split())
        graph[a].append(b)
        graph[b].append(a)
    
    colors = [0] * N
    if is_bipartite(graph, colors):
        w = colors.count(1)
        ans = w * (N - w) - M
    else:
        ans = N * (N - 1) // 2 - M
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 61932
def examA():
    R = I()
    ans = R*2*3.141592
    print(ans)
    return

def examB():
    N, M = LI()
    A = LI()
    S = sum(A)
    if N>=S:
        ans = N-S
    else:
        ans = -1
    print(ans)
    return

def examC():
    N = I()
    A = LI()
    ans = [0]*N
    for i in range(N-2,-1,-1):
        ans[A[i]-1] +=1
    for v in ans:
        print(v)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(readline())
def LI(): return list(map(int,readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examA()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

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

int main(){
  int X, Y, Z, K;cin >> X >> Y >> Z >> K;
  vll A, B, C;
  for (int i=0;i<X;++i){
    ll a;cin>>a;
    A.push_back(a);
  }

  for (int i=0;i<Y;++i){
    ll b;cin>>b;
    B.push_back(b);
  }

  for (int i=0;i<Z;++i){
    ll c;cin>>c;
    C.push_back(c);
  }

  vll AB_sum;
  for (int i=0;i<X;++i){
    for (int j=0;j<Y;++j){
      AB_sum.push_back(A[i]+B[j]);
    }
  }

  sort(AB_sum.begin(), AB_sum.end(), greater<ll>());

  int L=AB_sum.size();

  int K_=min(K, L);

  vll ans_list;

  for (int i=0;i<K_;i++){
    for (int j=0;j<Z;++j){
      ans_list.push_back(AB_sum[i]+C[j]);
    }
  }

  sort(ans_list.begin(), ans_list.end(), greater<ll>());

  for (int i=0;i<K;++i){
    cout << ans_list[i] << endl;
  }

  return 0; 
}

Measured memory_bytes: 43384
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll multbig(ll a,ll b,ll mod){
    if(a==0 or b==0) return 0;
    if(a==1 or b==1) return (a*b)%mod;
    ll cur=multbig(a,b/2,mod);
    cur=(2*cur)%mod;
    if(b%2) cur=(cur+a)%mod;
    return cur;
}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}


void solve(){
	ll a;
	cin>>a;
	if(a%2) cout<<a*2<<endl;
	else cout<<a<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

void Main() {
  Cin(int, n);
  vector<int> v(n);
  for (auto& e : v) cin >> e;

  sort(all(v));
  cout << v.back() - v.front() << endl;
}

int main() {
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  int x = n;
  if (x == 0) cout << 0 << endl, exit(0);
  vector<int> v;
  while (x != 0) {
    if (abs(x) % 2 == 1) {
      x -= 1;
      x /= -2;
      v.push_back(1);
    //  cout << 1 << endl;
    } else {
      x /= -2;
      v.push_back(0);
   //   cout << 0 << endl;
    }
  }
  reverse(begin(v), end(v));
  for (auto&& w : v) cout << w;
  cout << endl;
}

Measured memory_bytes: 256
list_lower = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
              'u', 'v', 'w', 'x', 'y', 'z']
list_upper = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
              'U', 'V', 'W', 'X', 'Y', 'Z']
s = input()
if s[0] in list_lower:
    print("a")
else:
    print("A")

Measured memory_bytes: 61792
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		if ( s.equals(s.toUpperCase()) ) {
			System.out.println("A");
		} else {
			System.out.println("a");
		}
	}
}


Measured memory_bytes: 35628
import numpy as np
from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix

import sys
sys.setrecursionlimit(10**9)
n,m,k=[int(i) for i in input().split()]
frends_num=[0 for i in range(n)]
def make_frends(m,n):
    data=[1 for i in range(m)]

    row=[]
    col=[]
    for k in range(m):
        i,j=[int(l) for l in input().split()]
        new_i=min(i,j)-1
        new_j=max(i,j)-1
        row.append(new_i)
        col.append(new_j)
        frends_num[new_i]+=1
        frends_num[new_j]+=1
    frend_sparce_matrix=csr_matrix((data, (row, col)),shape=(n,n))
    return frend_sparce_matrix


frends=make_frends(m,n)
l,labels=connected_components(frends)
labels
labels=list(labels)

class Group:
    def __init__(self,labels):
        self.labels=labels
        self.group_num=[0 for i in range(l)]
        for i in labels:
            self.group_num[i]+=1
    def get_group_num(self,i):
        return self.group_num[self.labels[i]]

group=Group(labels)


def get_frend_num(i):
    return frends_num[i]


def make_block(k,n):
    block_num=[0 for i in range(n)]
    for p in range(k):
        i,j =[int(l)-1 for l in input().split()]
        new_i=min(i,j)
        new_j=max(i,j)
        if labels[new_i]==labels[new_j]:
            block_num[i]+=1
            block_num[j]+=1
    return block_num

block=make_block(k,n)

def get_block_num(i):
    return block[i]

ans=[]
for i in range(n):
    ans.append(str(group.get_group_num(i)-1-get_frend_num(i)-get_block_num(i)))
print(" ".join(ans))


Measured memory_bytes: 53288
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define UP(i,a,b) for(int i=(a); i<=(b); ++i)
#define DOWN(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) UP(i,0,n-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //NOTE: <a> must be sorted in advance

lng power(lng b, lng n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n

const int MOD = 1000000007; //10^9+7


/*********** variables ************/

/**********************************/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s >> s;
    cout << 'A' << s[0] << 'C' << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int tsuru,kame;
  int x,y;
  
  scanf("%d %d",&x,&y);
  
  for(tsuru=0;tsuru<=x;tsuru++){
    kame=x-tsuru;
      if((tsuru*2+kame*4)==y){
        printf("Yes");
        return 0;
      }
  }
  printf("No");
}

Measured memory_bytes: 1728
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n, m, x = map(int, input().split())
    ca = [list(map(int, input().split())) for _ in range(n)]
    min_ans = 10 ** 20
    max_count = 0
    for i in range(2 ** n):
        ii = list(format(i, 'b').zfill(n))
        sum_a = [0] * m
        ans = 0
        for j in range(n):
            if ii[j] == '1':
                c, *a = ca[j]
                ans += c
                for k in range(m):
                    sum_a[k] += a[k]
        check = True
        for j in range(m):
            if sum_a[j] < x:
                check = False
        if check and min_ans > ans:
            min_ans = ans

    if min_ans == 10 ** 20:
        print(-1)
    else:
        print(min_ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 74264
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int n = in.nextInt();
        int k = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }

        int[] dp = new int[n];
        dp[1] = Math.abs(a[1] - a[0]);

        if (n == 2) {
            out.println(dp[n - 1]);
            return;
        }

        for (int i = 2; i < n; i++) {
            int min = Integer.MAX_VALUE;
            for (int j = 1; j <= Math.min(i, k); j++) {
                min = Math.min(min, dp[i - j] + Math.abs(a[i - j] - a[i]));
            }
            dp[i] = min;
        }

        out.println(dp[n - 1]);
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}

Measured memory_bytes: 34744
n = int(input())
a = [list(map(int, input().split())) for _ in range(2)]

ans = 0


for i in range(n):
    r = 0
    line = 0
    for j in range(n):
        r += a[line][j]
        if j==i:
            line = 1
            r += a[line][j]
    ans = max(ans, r)

print(ans)

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int Ans = 1;
    for (int i = 0; i < 5; i++) {
        int x; cin >> x; Ans ^= x;
    }
    cout << Ans << "\n";
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
 
using namespace std;
bool vis[200];
int que[100],sum[100];
int tot;
void get(){
    tot=0;
    for(int i=2;i<=100;i++){
        int tmp=i*i;
        if(!vis[i]){
            que[++tot]=i;
            //cout<<i<<endl;
        if(tmp>100) continue;
            while(tmp<=100){
                vis[tmp]=true;
                tmp+=i;
            }
        }
    }
}
int main(){
    int n;
    get();
    scanf("%d",&n);
    int res=0,ans=0;
    for(int i=1;i<=tot;i++){
        int pp=0;
        for(int j=que[i];j<=n;j+=que[i]){
            int tmp=j;
            while(!(tmp%que[i])){
                pp++;
                tmp/=que[i];
            }
        }
        //cout<<pp<<' '<<i<<endl;
        sum[i]=pp;
        /*if(que[i]>=5){
            if(que[i]*4<=n) ans++,res++;
            else if(que[i]*2<=n) ans++;
        }
        else if(que[i]<5){
            if(que[i]*que[i]<=n) ans++,res++;
            else if(que[i]*2<=n) ans++;
        }*/
    }
    int a=0,b=0,c=0,d=0,p=0;
    //cout<<res<<' '<<ans<<endl;
    for(int i=1;i<=tot;i++){
        if(sum[i]>=74) p++;
        if(sum[i]>=24) a++;
        if(sum[i]>=14) b++;
        if(sum[i]>=4) c++;
        if(sum[i]>=2) d++;
    }
    //cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
    int ANS=a*(d-1);
    ANS+=b*(c-1);
    ANS+=((c-1)*c/2)*(d-2);
    ANS+=p;
    printf("%d\n",ANS);
    return 0;
}

Measured memory_bytes: 3804
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define INF 9223372036854775807 / 2
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair


using namespace std;

std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }


signed main() {
	int N;
	string s;
	cin >> N >> s;
	int r = 0, b = 0;
	for (int i = 0; i < N; i++) {
		if (s[i] == 'R') r++;
		else b++;
	}
	
	if (r > b) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn=2*100001;
struct WORK{
	int a;
	int b;
};
WORK w[maxn];

bool cmp(WORK x,WORK y){
	return x.b<y.b;
}

int main(){
	int n,t=0;
	cin>>n;
	for (int i=1;i<=n;i++){
		cin>>w[i].a>>w[i].b;
	}
	sort(w+1,w+n+1,cmp);
	for (int i=1;i<=n;i++){
		t+=w[i].a;
		if (t>w[i].b){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 1792
n,k = map(int,input().split())
h = list(map(int,input().split()))
dp = [0]*n
dp[0] = 0
dp[1] = abs(h[1]-h[0])
# dp[2] = min(abs(h[2]-h[0]), dp[1]+abs(h[2]-h[1]))
# dp[3] = min((abs(h[3]-h[1])+dp[1]), abs(h[3]-h[2])+dp[2])
for i in range(2,n):
    ans = 10000000000000000000000000
    for j in range(1,k+1):
        if i-j >= 0:
            tmp = abs(h[i]-h[i-j])+dp[i-j]
            ans = min(ans,tmp)
    # dp[i] = min((abs(h[i]-h[i-2])+dp[i-2]), abs(h[i]-h[i-1])+dp[i-1])
    dp[i] = ans
print(dp[-1])

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

int main(void){
  char buf[32] = { 0 };
  int N,A,B;
  int sum = 0; //位の和
  int total = 0;
  
  //入力読み込み
  fgets(buf, sizeof(buf), stdin);
  sscanf(buf, "%d %d %d", &N, &A, &B);
  
  for(int num = 1; num <= N; num++){
    int n_tmp = log10((double)num);
    int num_tmp = num;
    int pow_tmp = (int)pow(10, n_tmp);
    sum = 0;
    for(;n_tmp >= 0; n_tmp--,pow_tmp = (int)pow(10, n_tmp)){
      if(num_tmp < pow_tmp) continue;
      sum += num_tmp / pow_tmp;
      num_tmp = num_tmp % pow_tmp;   
    }
    if(sum >= A && sum <= B) total += num;
  }
  
  printf("%d\n", total);
  return 0;
}

Measured memory_bytes: 2620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// N W
// assumption was wrong: can only carry one instance of the item
// at a time

int main() {
  ll n, max_w;
  cin >> n >> max_w;

  // values and weights
  vector<ll> v(n);
  vector<ll> w(n);

  for (ll i = 0; i < n; i++) {
    cin >> w[i] >> v[i];
  }

  vector<ll> dp(max_w+1, 0); // max sum for each exact weight


  // direction of the pass is important
  // so that we don't add weights that`
  // have already been computed
  for (ll i = 0; i < n; i++) {
    ll weight = w[i];
    for (ll j = max_w-weight; j >= 0; j--) {
      dp[j+weight] = max(dp[j+weight], dp[j] + v[i]);
    }
  }

  ll res = 0;
  for (auto sc: dp)
    res = max(res, sc);

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
using namespace std;
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
int n,k,a[10005],b[10005];
bool dpa[5005][5005],dpb[5005][5005],aa[5005][5005],bb[5005][5005],temp[5005],tem2[5005];
int main(){
	scanf("%d%d",&n,&k);
	int xb,x2;
	for(xb=0;xb<n;xb++) {
		scanf("%d",&a[xb]);
		a[xb]=MIN(a[xb],k);
	}
	if(n==1){
		if(a[0]<k) printf("1\n"); else printf("0\n");
		return 0;
	}
	memcpy(b,a,sizeof(a));
	reverse(b,b+n);
	dpa[0][a[0]]=1;
	dpa[0][0]=1;
	for(xb=1;xb<n;xb++){
		for(x2=0;x2<k;x2++){
			dpa[xb][x2]=dpa[xb-1][x2];
			if(x2>=a[xb]){
				dpa[xb][x2]|=dpa[xb-1][x2-a[xb]];
			}
		}
		dpa[xb][k]=dpa[xb-1][k];
		for(x2=0;x2<k;x2++){
			if(x2+a[xb]>=k) dpa[xb][k]|=dpa[xb-1][x2];
		}
	}
	dpb[0][b[0]]=1;
	dpb[0][0]=1;
	for(xb=1;xb<n;xb++){
		for(x2=0;x2<k;x2++){
			dpb[xb][x2]=dpb[xb-1][x2];
			if(x2>=b[xb]){
				dpb[xb][x2]|=dpb[xb-1][x2-b[xb]];
			}
		}
		dpb[xb][k]=dpb[xb-1][k];
		for(x2=0;x2<k;x2++){
			if(x2+b[xb]>=k) dpb[xb][k]|=dpb[xb-1][x2];
		}
	}
	int cnt=0;
	memcpy(aa,dpa,sizeof(dpa));
	memcpy(bb,dpb,sizeof(dpb));
	for(xb=0;xb<n;xb++){
		for(x2=k-3;x2>=0;x2--){
			dpa[xb][x2]|=dpa[xb][x2+1];
			dpb[xb][x2]|=dpb[xb][x2+1];
		}
	}
	for(xb=0;xb<n;xb++){
		if(xb==0){
			if(!dpb[n-2][k-a[xb]]) cnt++;
			continue;
		}
		if(xb==n-1){
			if(!dpa[n-2][k-a[xb]]) cnt++;
			continue;
		}
		memset(temp,0,sizeof(temp));
		bool *sor=bb[n-2-xb];
		int CNT=0;
		for(x2=0;x2<a[xb];x2++) CNT+=sor[x2];
		if(CNT) temp[0]=1;
		for(x2=1;x2+a[xb]<=k+1;x2++){
			CNT-=sor[x2-1];
			CNT+=sor[x2+a[xb]-1];
			if(CNT) temp[x2]=1;
		}
		// F: k-a[xb]-v~~~~k-1-v 
		bool ok=1;
		for(x2=0;x2<=k-a[xb];x2++){
			if(aa[xb-1][x2]&&temp[k-a[xb]-x2]){
				ok=0;
				break;
			}
		}
		if(ok){
			bool got=0;
			for(x2=k-1;x2>=k-a[xb];x2--){
				got|=sor[k-1-x2];
				if(aa[xb-1][x2]&&got){
					ok=0;
					break;
				}
			}
		}
		if(ok)cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 98176
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 10;
int n,a,b,c;
int main() {
	scanf("%d%d%d",&a,&b,&c);
	if ((a == b && b != c) || (a == c && b != c) || (b == c && a != c)) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N, K;
ll choice(ll k){
	ll ret = 0;
	ret += k;
	ret += 3 * k * (k - 1);
	ret += k * (k - 1) * (k - 2);
	return ret;
}

int main(void){
	cin >> N >> K;
	ll ret = 0;
	ret += choice(N / K);
	if(K % 2 == 0){
		ret += choice(((N / (K / 2)) + 1) / 2);
	}
	cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<62;
const int IINF = 1000000000;
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; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;

int main(){
    int N;
    ll C;
    cin >> N >> C;
    vector<ll> x(N), v(N);
    rep(i,N) cin >> x[i] >> v[i];
    
    vector<ll> rcum(N+1, 0), lcum(N+1);
    vector<ll> max_rcum(N+1,-INF), max_lcum(N+1,-INF);

    rep(i,N){
        rcum[i+1] = rcum[i] + v[i];
        max_rcum[i+1] = max(max_rcum[i], rcum[i+1]-x[i]);
    }
    rep(i,N){
        lcum[i+1] = lcum[i] + v[N-i-1];
        max_lcum[i+1] = max(max_lcum[i], lcum[i+1]-(C-x[N-i-1]));
    }

    ll ans = 0;
    for(int i = 0; i <= N; i++){
        if (i == 0) ans = max(ans, max_lcum[N]);
        else ans = max(ans, rcum[i]-2*x[i-1]+max_lcum[N-i]);
    }
    for(int i = 0; i <= N; i++){
        if (i == 0) ans = max(ans, max_rcum[N]);
        else ans = max(ans, lcum[i]-2*(C-x[N-i])+max_rcum[N-i]);
    }
    
    cout << ans << endl;
    
}

Measured memory_bytes: 7932
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  ll M;
  cin >> N >> M;
  vector<pair<ll,ll>> v;
  rep(i,N){
    ll a, b;
    cin >> a >> b;
    v.emplace_back(a,b);
  }
  sort(ALLOF(v));

  ll ret = 0;
  rep(i,v.size()){
    ll a = min(v[i].second, M);
    ret += v[i].first * a;
    M -= a;
  }

  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 2420
n = int(input())
b = list(map(int, input().split()))

total = 0
for i in range(len(b)):
    if i == 0:
        a = b[i]
        total += a
    else:
        a = min(b[i-1], b[i])
        total += a
    
print(total + b[-1])

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

const ll MOD = 1e9 + 7;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second




int main() {
	ll n, c, x[100010], y[100010], ans = 0, ruir[100010] = { 0 }, ruil[100010] = { 0 }, sumr[100010] = { 0 }, suml[100010] = { 0 }, ml[100010] = { 0 }, mr[100010] = { 0 };
	cin >> n >> c;
	x[n + 1] = c;
	for (int i = 1;i <= n;i++) {
		cin >> x[i] >> y[i];
	}
	for (int i = 1;i <= n;i++) {
		ruir[i] = ruir[i - 1] + y[i];
	}

	for (int i = n;i > 0;i--) {
		ruil[i] = ruil[i + 1] + y[i];
	}

	for (int i = n;i > 0;i--) {
		ml[i] = max(ml[i + 1], ruil[i] - (c - x[i]));
	}

	for (int i = 1;i <= n;i++) {
		ll res = ruir[i] + ml[i + 1];
		ans = max(ans, res - x[i]*2);
	}


	for (int i = 1;i <= n;i++) {
		mr[i] = max(mr[i - 1], ruir[i] - x[i]);
	}

	for (int i = n;i > 0;i--) {
		ll res = ruil[i] - (c - x[i]) * 2;
		ans = max(ans, res + mr[i - 1]);
	}


	ll sum = 0, mm = 0;
	for (int i = 1;i <= n;i++) {
		sum = sum + (y[i] - (x[i] - x[i - 1]));
		mm = max(mm, sum);
	}
	ans = max(ans, mm);
	sum = 0, mm = 0;

	for (int i = n;i >= 1;i--) {
		sum = sum + (y[i] - (x[i + 1] - x[i]));
		mm = max(mm, sum);
	}

	ans = max(mm, ans);
	cout << ans << endl;
}


Measured memory_bytes: 4992
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

const string YES = "Yes";
const string NO = "No";

void solve(ll K, ll X) {
  bool pred = K*500 >= X;
  cout << (pred ? YES : NO) << endl;
}

int main() {
  ll K;
  cin >> K;
  ll X;
  cin >> X;
  solve(K, X);
  return 0;
}


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

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int H, W;
    string tmp;
    cin >> H >> W;
    vector<vector<int>> obsv;
    vector<vector<int>> obsh;
    vector<string> grid;
    for (int i=0; i<W; i++){
        obsv.emplace_back(vector<int>({-1}));
    }
    for (int i=0; i<H; i++){
        cin >> tmp;
        grid.push_back(tmp);
        vector<int> tmp2;
        tmp2.push_back(-1);
        for (int j=0; j<W; j++){
            if (tmp[j] == '#'){
                obsv[j].push_back(i);
                tmp2.push_back(j);
            }
        }
        tmp2.push_back(W);
        obsh.emplace_back(tmp2);
    }

    for (int i=0; i<W; i++){
        obsv[i].push_back(H);
    }
    int maximum = -1;
    for (int i=0; i<H; i++){
        for (int j=0; j<W; j++){
            int lbh = lower_bound(obsh[i].begin(), obsh[i].end(), j) - obsh[i].begin();
            int lbv = lower_bound(obsv[j].begin(), obsv[j].end(), i) - obsv[j].begin();
            int fh = obsh[i][lbh] - obsh[i][lbh - 1] - 1;
            int fv = obsv[j][lbv] - obsv[j][lbv - 1] - 1;
            if (grid[i][j] != '#'){
                maximum = max(maximum, fh + fv - 1);
            }
        }
    }
    cout << maximum << endl;
    return 0;
}

Measured memory_bytes: 36352
/**
*   Bismillahir Rahmanir Rahim.
*   Imtiaz_rafi
*   PCIU, CHITTAGONG
**/
#include<bits/stdc++.h>
using namespace std;
#define speed ios::sync_with_stdio(0);cin.tie(0);
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
#define rep(i,a) for(ll i=0;i<a;i++)
#define rep1(i,begin,end) for(ll i=begin;i<=end;i++)
#define all(v)   v.begin(),v.end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define pi acos(-1)
// bitshift (1LL<<(3)) *2^3
typedef long long int ll;
typedef vector<ll>vi;
typedef map<ll,ll>m;
typedef map<char,ll>mc;
typedef set<ll>st;
typedef set<char>sc;
ll dx[] ={-1,+1,0,0,+1,-1,+1,-1};
ll dy[] ={0,0,-1,+1,+1,+1,-1,-1};
const ll inf = 2000000000;
const ll mx = 1e5+123;
bool vis[mx];
vi adj[mx];
int a,b[mx],dp[mx];

int solve(int i)
{
    if(i==a-1)
        return 0;
    if(dp[i]!=-1)
        return dp[i];
    int x=inf,y=inf;

    x=abs(b[i]-b[i+1])+solve(i+1);
    if(i+2<=a-1)
        y=abs(b[i]-b[i+2])+solve(i+2);
    return dp[i]=min(x,y);
}


int main()
{
    speed;
    cin>>a;
    rep(i,a)
        cin>>b[i];
    memset(dp,-1,sizeof(dp));
    cout<<solve(0)<<endl;
}

Measured memory_bytes: 11392
/* ex3_4
   seira3 */

#include<stdio.h>
#include<stdlib.h>

int main(void){
    int number; //変数宣言
    scanf("%d",&number); //numberに入力
    int count=0; //カウンターを宣言
    for(int i=1;i<10;i++){ //iで割り切れてかつ商が1から9におさまるならcountに1を足す
        if(0<number/i&&10>number/i&&number%i==0){
            count++;
        }
    }
    if(count==0){ //countに一回も足されなかった時はNo
        printf("%s\n","No");
    }
    else{ //それ以外はYes
        printf("%s\n","Yes");
    }
    return 0;
}

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

const long long INF = 1LL << 60;

typedef long long ll;

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n,0);
    int tmp;
    rep(i,n-1){
        cin >> tmp;
        a[tmp-1] += 1;
    }
    ll tot = 0;
    rep(i,n){
        cout << a[i] << endl;
    }
    return 0;
}


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


int main(){
    int n,k;
    cin >> n >> k;
    vector<ll> v(n);
    rep(i,n) cin >> v[i];
    sort(v.begin(),v.end());
    ll ans=1LL << 60;
    for (int i=0;i+k-1 < n;i++){
        ans=min(v[k+i-1]-v[i],ans);
    }
    cout << ans << endl;

    
}

Measured memory_bytes: 1024
from typing import List
import sys


def read_data(file_name: str, std_in=True):
    satisfactions_list = list()
    file = sys.stdin if std_in else open(file_name, 'r')
    days = int(file.readline().rstrip())
    satisfaction_decreases = [int(c) for c in file.readline().rstrip().split(" ")]
    for i in range(days):
        satisfactions_list.append([int(c) for c in file.readline().rstrip().split(" ")])
    if not std_in:
        file.close()
    return days, satisfaction_decreases, satisfactions_list


class Contest:
    def __init__(self, _type: int, satisfactions: List[int], satisfaction_decrease: int):
        self.satisfaction = 0
        self.type = _type
        self.satisfactions = satisfactions
        self.satisfaction_decrease = -satisfaction_decrease

    def __getitem__(self, key: int):
        return self.satisfactions[key - 1]

    def __str__(self):
        return str(self.type)

    def __repr__(self):
        return f"Contest(_type={self.type}, satisfactions={self.satisfactions}, satisfaction_decrease={self.satisfaction_decrease})"

    def get_satisfaction_increase(self, day):
        return self[day] - (self.satisfaction + self.satisfaction_decrease)

    def winner(self, day):
        self.satisfaction += self[day]

    def loser(self):
        self.satisfaction += self.satisfaction_decrease


def get_best(contests :List[Contest], day: int):
    # improve this by optimistically making everyone a loser and then going back to undo that for the winner
    best = contests[0]
    for contest in contests:
        if contest.get_satisfaction_increase(day) > best.get_satisfaction_increase(day):
            best = contest
    return best


def main(file_name="input.txt"):
    contests = list()
    days, satisfaction_decreases, satisfactions_list = read_data(file_name)
    picks = list()

    for (_type, (satisfactions, satisfaction_decrease)) in enumerate(zip(zip(*satisfactions_list), satisfaction_decreases), start=1):
        contests.append(Contest(_type, satisfactions, satisfaction_decrease))

    for day in range(days):
        best = get_best(contests, day + 1)
        for contest in contests:
            if contest.type == best.type:
                contest.winner(day + 1)
                picks.append(contest)
            else:
                contest.loser()

    return "\n".join([str(pick) for pick in picks])


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 10576