akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define double long double
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define all(a) a.begin(),a.end()
#define sort(a) sort(all(a))
#define rsort(a) sort(all(a),greater<>())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T> inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<int,int> P;
const long long MOD=1000000007;
clock_t time_ini = clock();
double time_diff(){
  ll time_tmp = clock();
  const double time = static_cast<double>(time_tmp - time_ini) / CLOCKS_PER_SEC * 1000.0;
  return time;
}
#define saiaku if(time_diff() > 1990)
vector <ll> dp;
vector <ll> H;

void solve(long long N, long long K, std::vector<long long> h){
  if(N<=K) K = N-1;
  dp = vector<ll> (N+1, 0);
  for (ll i = 0; i < K; i++)
  {
    dp[i] = abs(h[i]-h[0]);
  }

  for (ll i = K; i < N; i++)
  {
    vector <ll> d;
    for (ll j = 1; j < K+1; j++)
    {
      d.push_back(dp[i-j] + abs(h[i] - h[i-j]));
    }
    dp[i] = *min_element(d.begin(), d.end());
  }
  cout << dp[N-1] << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> h(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&h[i]);
    }
    solve(N, K, std::move(h));
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rrep(i,n) for (int i = 1; i <= (n); i++)
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

int enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    return res.size();
}

int main() {
  int n; cin >> n;
  int res = 0;
  for (int i = 1; i <= n; i+=2) {
    int num = enum_divisors(i);
    if (num == 8) res++;
  }
  cout << res << endl;
}


Measured memory_bytes: 3556
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<iomanip>
#include<cstring>
#include<string>
#include<set>

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

using namespace std;
using ll = long long int;

const ll INF = 1<<30;
const ll LINF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(void) {
    string s; cin >> s;
    cout << s.substr(0, 3) << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  int n; cin >> n;
  vector<int> a(n + 1);
  a[0] = 1, a[1] = 1;
  for (int i = 2; i <= n; i ++) {
    a[i] = a[i - 1] + a[i - 2];
  }

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



Measured memory_bytes: 3100
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            long H = in.nextLong();
            long W = in.nextLong();
            if (H == 1 || W == 1) {
                out.println(1);
                return;
            }
            long ans = 0;
            if (H % 2 != 0) {
                ans = H / 2L * W + (W + 1) / 2;
            } else {
                ans = H / 2L * W;
            }
            out.println(ans);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

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

    }
}



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

int main() {
  long n,p;
  cin >> n>>p;
  if(n==1){
    cout<<p<<endl;
  }
  else{
  vector<int>a(1000100);
  rep2(i,2,1000100){
    long w=p;
    while(w%i==0){
      w/=i;
      a.at(i)++;
    }
  }
  long ans=1;
  rep2(i,2,1000100){
    if(a.at(i)>=n){
      ans=i;
    }
  }
  
  cout<<ans<<endl;  
  }
}



Measured memory_bytes: 4096
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<cstring>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const int maxn = 5e5 + 5;
const int inf = 0x3f3f3f3f;
int main()
{
    int n;
    cin>>n;
    vector<int>a(n+1);
    for(int i=1;i<=n;i++)
        cin>>a[i];
    int num=0;
    for(int i=2;i<=n-1;i++)
    {
        if(a[i]>a[i-1]&&a[i]<a[i+1]) num++;
        if(a[i]<a[i-1]&&a[i]>a[i+1]) num++;
    }
    cout<<num;
}

Measured memory_bytes: 384
/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
//#include <show_vec.hh>

using namespace std;

#define DEBUG if(false)

using ll = long long;
#define LINE printf("LINE : %d\n", __LINE__);
#define loop(i, n) for(i = 0; i < n; i++)
template<class T> using vec = vector<T>;

const int MOD = 1000000007;

int main(){
  int X, Y;
  cin >> X >> Y;
  int TSURU, KAME;
  bool boolean = true;
  if(Y % 2 == 0){
    TSURU = 2*X-Y/2;
    KAME = -X+Y/2;
    if(TSURU >= 0 && KAME >= 0){
      // nothing todo
    }else{
      boolean = false;
    }
  }else{
    boolean = false;
  }
  if(boolean){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main(void){
    while(true){
        string s1, s2;
        cin >> s1 >> s2;
        if(s1=="") break;
        int l1=s1.length();
        int l2=s2.length();
        int dp[4010][4010];
        for(int i=0; i<l1; i++){
            if(s1[i]==s2[0]) dp[i][0]=1;
            else dp[i][0]=0;
        }
        for(int j=0; j<l2; j++){
            if(s1[0]==s2[j]) dp[0][j]=1;
            else dp[0][j]=0;
        }
        for(int i=1; i<l1; i++){
            for(int j=1; j<l2; j++){
                if(s1[i]==s2[j]) dp[i][j]=dp[i-1][j-1]+1;
                else dp[i][j]=0;
            }
        }
        int ans=0;
        for(int i=0; i<l1; i++){
            for(int j=0; j<l2; j++){
                ans=max(ans, dp[i][j]);
            }
        }
        cout << ans << "\n";
        
    }
    
    
    return 0;
}


Measured memory_bytes: 65856
class Node():
  def __init__(self):
    self.parent = -1
    self.left = None
    self.right = None

def get_depth(u, p):
  D[u] = p
  if result[u].right is not None:
    get_depth(result[u].right, p)
  if result[u].left is not None:
    get_depth(result[u].left, p+1)

def get_depth_1(u, p):
  i = u
  d = 0
  while result[u].parent != -1:
    u = result[u].parent
    d += 1
  D[i] = d

n = int(input())
node  = [list(map(int, input().split())) for _ in range(n)] 
result = [Node() for _ in range(n)]
D = [0 for _ in range(n)]

def initiate(li):
  for l in li:
    n = l[0]
    child_num = l[1]
    child = []
    i = 1
    if child_num != 0:
      child = l[2:]
    for c in child:
      if i == 1:
        result[n].left = c 
        i += 1
      else:
        result[idx].right = c 
      idx = c
      result[c].parent = n

initiate(node)
u = 0
for i in range(n):
  if result[i].parent == -1:
    u = i
for u in range(n):
  get_depth_1(u, 0)
final = []
for i in range(n):
  n = i 
  p = result[i].parent
  d = D[i]
  c = [result[i].left]
  j = result[i].left
  if j is not None:
    while result[j].right is not None:
      c.append(result[j].right)
      j = result[j].right
  final.append([n, p, d, c])
  
for i in range(n+1):
  n, p, d, c = final[i]
  typ = ""
  if p == -1:
    typ = "root"
    if c == [None]:
      c = []
  else:
    if c == [None]:
      typ = "leaf"
      c = []
    else:
      typ = "internal node"
  print("node {}: parent = {}, depth = {}, {}, {}".format(n, p, d, typ, c))


Measured memory_bytes: 65256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    string s;
    cin >> s;
    string t = "";
    for(int i=0;i<s.size();++i){
        if(s[i] != 'x')t.push_back(s[i]);
    }
 
    int left = 0, right = t.size() - 1;
    bool flag = true;
    while(right > left){
        if(t[right] != t[left]){
            flag = false;
            break;
        }
        right--;
        left++;
    }
 
    if(flag){
        int l = 0, r = s.size() - 1, cnt = 0;
        while(r > l){
            if(s[r] == 'x' && s[l] != 'x'){
                r--;
                cnt++;
            }else if(s[r] != 'x' && s[l] == 'x'){
                l++;
                cnt++;
            }else{
                r--;
                l++;
            }
        }
        cout << cnt << endl;
    }else{
        cout << -1 << endl;
    }
 
    return 0;
}

Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main(){
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var S string
	fmt.Fscan(r, &S)
	N := len(S)
	ans := "Yes"
	for i:=0; i < N; i++{
		if(S[i] != S[N-i-1]){
			ans = "No"
		}
	}
	fmt.Println(ans)


}

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

int main() {
	int h, w, i, j;
	cin >> h >> w;
	vector<string> a(h), b(h+2, string(w+2, '#'));
	
	for (i = 0; i < h; i++) {
		cin >> a.at(i);
		b[i + 1] = "#" + a[i] + "#";
	}
	for (i = 0; i < h + 2; i++) {
		cout << b[i] << endl;
	}
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    char s;
    for (int i = 0; i < n; i++) {
        cin >> s;
        if (s == 'Y') {
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
}

Measured memory_bytes: 3568
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
class Solver{
public:
    ll cal(ll h){
        if(h==1)return 1;
        ll c=cal(h/2);
        return 2*c+1;
    }
    void solve(){
        ll H;
        cin>>H;
        ll ans=cal(H);
        cout<<ans;
    }
};
int main()
{
    // freopen("in.txt","r",stdin);
    (new Solver())->solve();   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long  x,a,b;
    cin>>x>>a>>b;
    if(abs(x-a)>abs(x-b))
     cout<<"B";
    else 
     cout<<"A";
    return 0;
}
     
   

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

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

	int N,Q;
	cin >> N >> Q;
	vector<pair<int,int>> x(N);
	vector<int> s(N),t(N);
	for(int i=0;i<N;++i){
		cin >> s[i] >> t[i] >> x[i].first;
		x[i].second = i;
		s[i] -= x[i].first;
		t[i] -= x[i].first;
	}
	sort(x.begin(),x.end());
	set<int> d;
	map<int,int> ma;
	for(int i=0;i<Q;++i){
		int di;
		cin >> di;
		ma[di] = i;
		d.insert(di);
	}
	vector<int> ans(Q,-1);
	for(int i=0;i<N;++i){
		int xi = x[i].first;
		int si = s[x[i].second];
		int ti = t[x[i].second];
		vector<int> del;
		auto l = d.lower_bound(si);
		auto r = d.lower_bound(ti);
		while(l!=r){
			ans[ma[*l]] = xi;
			del.push_back(*l);
			l++;
		}
		for(auto er:del) d.erase(er);
	}
	for(auto a:ans){
		cout << a << endl;
	}
}


Measured memory_bytes: 24576
import java.util.*;
public class Main
{
	public static void main(String[] args)
	{
	Scanner s=new Scanner(System.in);
	int n=s.nextInt();
	int a[][]=new int[n][3];
	for(int i=0;i<n;i++)
	{
	for(int j=0;j<3;j++)
	a[i][j]=s.nextInt();
	}
	int dp[][]=new int[n][3];
	dp[0][0]=a[0][0];dp[0][1]=a[0][1];dp[0][2]=a[0][2];
	for(int i=1;i<n;i++)
	{
	for(int j=0;j<3;j++)
	{
	dp[i][j]=a[i][j]+Math.max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]);
	
	}
	
	}
	System.out.println(Math.max(dp[n-1][2],Math.max(dp[n-1][0],dp[n-1][1])));
	}
}

Measured memory_bytes: 97516
# coding: utf-8


def solve(*args: str) -> str:
    s = args[0]
    r = ''
    if(s == 'Sunny'):
        r = 'Cloudy'
    elif(s == 'Cloudy'):
        r = 'Rainy'
    elif(s == 'Rainy'):
        r = 'Sunny'

    return str(r)


if __name__ == "__main__":
    print(solve(*[input() for _ in range(1)]))


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define show(x) cout << x << '\n'
#define showh(x) cout << x << ' '
#define go(i, a, n) for (ll i = a; i < n; i++)
#define gor(i, a, n) for (ll i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define ff first
#define ss second
auto t1 = chrono::high_resolution_clock::now();
bool prime[1000001];
ll expo(ll a, ll b)
{
  a = a % mod;
  b = b % mod;
  if (b == 0)
    return 1;
  if (b % 2)
    return ((a % mod) * (expo((a * a) % mod, b / 2) % mod)) % mod;
  return expo((a * a) % mod, b >> 1) % mod;
}
ll mul(ll a, ll b)
{
  a = a % mod;
  b = b % mod;
  if (b == 0)
    return 0;
  if (b % 2)
    return ((a % mod) + (mul((a + a) % mod, b >> 1) % mod)) % mod;
  return mul((a + a) % mod, b >> 1) % mod;
}

bool ispoweroftwo(ll x)
{
  return x && !(x & (x - 1));
}
ll xorcal(ll n)
{
  if (n % 4 == 0)
    return n;
  if (n % 4 == 1)
    return 1;
  if (n % 4 == 2)
    return n + 1;
  if (n % 4 == 3)
    return 0;
}
void sieve(ll n)
{
  memset(prime, true, sizeof(prime));
  prime[0] = false;
  prime[1] = false;
  for (ll i = 2; i * i <= n; i++)
  {
    if (prime[i] == true)
    {
      for (ll j = i * i; j <= n; j += i)
        prime[j] = false;
    }
  }
}
bool isprime(ll n)
{
  if (n <= 1)
    return false;
  if (n <= 3)
    return true;

  if (n % 2 == 0 or n % 3 == 0)
    return false;

  for (ll i = 5; i * i <= n; i += 6)
  {
    if (n % i == 0 or n % (i + 2) == 0)
      return false;
  }
  return true;
}

ll modinverse(ll a, ll m)
{
  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;
}

ll gcd(ll a, ll b)
{
  if (a == 0)
    return b;
  return (b % a, a);
}
bool ispalindrome(string s)
{
  string t = s;
  reverse(t.begin(), t.end());
  if (t == s)
    return true;
  return false;
}
void binary(ll a[], ll n)
{
  gor(i, 0, 64)
  {
    ll k = n >> i;
    a[i] = k & (ll)1;
  }
}
ll countBits(ll n)
{
  if (n == 0)
    return 0;
  return 1 + countBits(n & (n - 1));
}
bool isPower(unsigned int n)
{
  // Base case
  if (n <= 1)
    return true;

  // Try all numbers from 2 to sqrt(n) as base
  for (int x = 2; x <= sqrt(n); x++)
  {
    unsigned p = x;

    // Keep multiplying p with x while is smaller
    // than or equal to x
    while (p <= n)
    {
      p *= x;
      if (p == n)
        return true;
    }
  }
  return false;
}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll k, sum = 0;
  cin >> k;
  go(i, 1, k + 1)
  {
    go(j, 1, k + 1)
    {
      go(l, 1, k + 1) sum += __gcd(i, __gcd(j, l));
    }
  }
  show(sum);
  auto t2 = chrono::high_resolution_clock::now();
  auto duration = chrono::duration_cast<chrono::milliseconds>(t2 - t1).count();
  clog << "Time taken = " << duration * 1.0 / 1000 << " seconds" << endl;
  return 0;
}


Measured memory_bytes: 3828
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))

big = max(A)
sml = min(A)

ans = float('inf')

for i in range(sml, big + 1):
    cnt = 0
    for a in A:
        cnt += (abs(i - a))**2
    ans = min(ans, cnt)
print(ans)


Measured memory_bytes: 3060
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int cnt,i;
    int max = 0;
    int n = sc.nextInt();
    int[] h = new int[n];
    for(i = 0; i < h.length; i++){
      h[i] = sc.nextInt();
    }
    cnt = 0;
    for(i = 1; i < h.length; i++){
      if(h[i - 1] >= h[i]){
        cnt++;
      }else{
        if(max <= cnt){
          max = cnt;
        }
        cnt = 0;
      }
    }
    if(max <= cnt){
      max = cnt;
    }
    System.out.println(max);
  }
}


Measured memory_bytes: 50812
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll;
ll mod = 1e9+7;

int main() { 
	string s,t;
	cin>>s>>t;
	int a = s.length();
	int count = 0;
	for(int i=0; i<a; i++) {
		if(s[i] != t[i]) count++;
	}
	cout<<count;
  return 0;
} 
 

Measured memory_bytes: 3920
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long

signed main() {
  int n;
  cin >> n;
  int a[3 * n];
  for (int i = 0; i < 3 * n; i++) {
    cin >> a[i];
  }
  sort(a, a + 3 * n);
  int sum = 0;
  for (int i = n; i < 3 * n; i += 2) {
    sum += a[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int n = 1;
  cin >> N;
  int sum = 0;
  while (n <= N) {
    int a = N % n;
    n *= 10;
    int b = N % n;
    sum = sum + (b - a) * 10/ n;
  }
  if ((N % sum) == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 
ll N;
ll NN;

int main(){

    cin >> N;
    int K;
    cin >> K;

    string S;
    cin >> S;

    int Flag[N+100];
    int Fsum[N+100];
    int tmp[N+100];
    int cnt=0;
    rep(i,N){
        if(S.substr(i,1)=="L")  Flag[i+1] = -1;
        else Flag[i+1] = 1;
        cnt += Flag[i+1];
    }
    if(N==1) cout << 0 << endl;
    else if(N==2) cout << 1 << endl;
    else if(cnt==-N || cnt == N) cout << N-1 << endl;
    else{
        int ans=0;
        int minus = 0;
        int plus = 0;
        for( int i = 1 ; i <N ; i++ ){
            Fsum[i] = Flag[i] - Flag[i+1];
            if(Fsum[i]==0) ans++;
            else if(Fsum[i]==2) plus++;
            else if(Fsum[i]==-2) minus++;
        }

        int sousa=0;
        //cout << ans << endl;
        //cout << plus << endl;
        //cout << minus << endl;
        sousa = min(plus,minus);
        if(K>sousa){
            ans += sousa*2;
            ans += min(K-sousa,abs(plus-minus));
        }else ans += K * 2;

        cout << ans << endl;
    }
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

map<ll,ll> mp;
int n,m;
ll a[100001];
int main(){
    cin>>n>>m;
    rep(i,n) cin>>a[i];
    ll sum=0;
    ++mp[0];
    rep(i,n){
        sum+=a[i];
        ++mp[sum%m];
    }
    ll ans=0;
    for(auto it:mp){
        ans+=it.second*(it.second-1)/2;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4992
# for i in range(1,300):
#     a = i**5 - (i-1)**5
#     print(f"{i} : {a}, {a < 10**9}")

X = int(input())

def main():
    for a in range(-200, 200):
        for b in range(-200, 200):
            if X == a**5 - b**5:
                print(f"{a} {b}")
                return

main()


Measured memory_bytes: 9160
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
	int N,i,temp,ans=0;
	vector<int> a;
	cin>>N;
	for(i=0;i<N;i++){
		cin>>temp;
		a.push_back(temp);
		ans+=temp;
	}
	cout<<ans-N;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz size()
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define mod 1000000007
#define forn(i, n) for (int i = 0; i < (int) (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,b;
    char op;
    cin >> a >> op >> b;
    if(op == '+'){
        cout << a+b;
    }else{
        cout << a-b;
    }
    return 0;
}



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

int main() 
{
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
	
	long long int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k<=a)
		cout<<k;
	else if(k<=b+a)
		cout<<a;
	else
	{
		cout<<a-(k-b-a);
	
	}
	
	return 0;
}

Measured memory_bytes: 3652
// CPP program to demonstrate use of std::map 
#include<iostream>
#include<stdio.h>
#include<string>
#include<stack>
#include<string.h>
using namespace std;
int main(){ 
    long long int N;
    cin >> N;
    long long int data;
    cin >> data;
    long long int max=data;
    long long int answer=0;
    for(int i=1;i<N;i++){
        cin >> data;
        if(data < max){
            answer+=max-data;
        }
        else{
            max=data;
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 3100
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ITP1_3_C
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> x = new List<int>();
            List<int> y = new List<int>();
            int temp = 0;

            while(true)
            {
                string[] input = Console.ReadLine().Split(' ');

                if (int.Parse(input[0]) == 0 && int.Parse(input[1]) == 0) break;

                x.Add(int.Parse(input[0]));
                y.Add(int.Parse(input[1]));
            }

            for (int i=0; i < x.Count; i++)
            {
                if (x[i] > y[i])
                {
                    temp = x[i];
                    x[i] = y[i];
                    y[i] = temp;
                }
            }

            for (int j=0; j < x.Count; j++)
            {
                Console.WriteLine("{0} {1}", x[j], y[j]);
            }

            
        }
    }
}



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

#define BUF_SIZE 10
int main(void) {
  FILE *fp = stdin;
  char line[BUF_SIZE];

  if(!fgets(line, BUF_SIZE, fp)) return 0;
  int cities, roads;
  int i;
  sscanf(line, "%d %d", &cities, &roads);
  int *city_hist = malloc(sizeof(int)*(cities+1));
  for(i = 0; i < roads; i++) {
    if(!fgets(line, BUF_SIZE, fp)) return 0;
    int c1, c2;
    sscanf(line, "%d %d", &c1, &c2);
    city_hist[c1]++; city_hist[c2]++;
  }
  for(i = 1; i <= cities; i++) {
    printf("%d\n", city_hist[i]);
  }

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 1005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

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

  ll n, m;
  cin >> n >> m;
  vector<ll> adj[n + 5];

  vector<ll> radj[n + 5];
  for (ll i = 1; i <= m; i++) {
    ll x, y;
    cin >> x >> y;
    adj[x].emplace_back(y);
    radj[y].emplace_back(x);
  }

  vector<ll> res;
  ll minCycle = n + 5;

  for (ll i = 1; i <= n; i++) {
    bool visited[n + 5];
    memset(visited, false, sizeof(visited));
    ll prev1[n + 5];
    ll dist[n + 5];
    for (ll i = 1; i <= n; i++)
      dist[i] = inf;
    memset(prev1, -1, sizeof(prev1));
    queue<ll> que;
    que.push(i);
    visited[i] = true;
    dist[i] = 0;

    while (!que.empty()) {
      ll curr = que.front();
      que.pop();
      for (ll x : adj[curr]) {
        if (!visited[x]) {
          visited[x] = true;
          dist[x] = dist[curr] + 1;
          prev1[x] = curr;
          que.push(x);
        }
      }
    }
    ll minVal = inf;
    ll resIndx;
    for (ll x : radj[i]) {
      if (!visited[x])
        continue;
      minVal = min(minVal, dist[x] + 1);
      if ((dist[x] + 1) == minVal)
        resIndx = x;
    }
    if (minVal >= minCycle)
      continue;

    ll curr = resIndx;

    vector<ll> path;

    while (curr != -1) {
      path.emplace_back(curr);
      curr = prev1[curr];
    }

    res = path;
    minCycle = minVal;
  }

  if (minCycle != n + 5) {
    cout << res.size() << en;
    for (ll x : res)
      cout << x << en;
  } else
    cout << -1 << en;

  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
int main()
{
    int n;
    cin >> n;
    vector<lint> R(n);
    REP(i, n) cin >> R[i];
    vector<lint> maxR(n-1);
    maxR[n-2] = R[n-1];
    IFOR(i, 0, n-2) {
        maxR[i] = max(maxR[i+1], R[i+1]);
    } 
    lint ans = -1e10;
    REP(i, n-1) {
        lint x = maxR[i] - R[i];
        if(x > ans) ans = x;
    }
    cout << ans << endl;
}



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



int main() {
	double a, b, x;
	double ans;
	cin >> a >> b >> x;
	if (2 * x < b * a * a) {
		ans = a * b * b / x / 2;
		//cout << "%"<< endl;
	}
	else ans = (2 * a * a * b -2* x) / (a * a * a);
	//cout << ans << endl;
	printf("%.12lf\n", atan(ans) / asin(1.0) *double( 90));
}


Measured memory_bytes: 512
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=998244353;
const int N=3e3+5;

int dp[N][N];

void solve()
{
    int n,sum;
    cin>>n>>sum;

    vi v(n);
    for(int i=0;i<n;++i)
        cin>>v[i];

    mem(dp,0);
    dp[0][0]=1;
    for(int i=1;i<=n;++i)
    {
        for(int j=0;j<=sum;++j)
        {
            dp[i][j]=(2*dp[i-1][j])%M;

            if(j-v[i-1]>=0)
                dp[i][j]=(dp[i][j]+dp[i-1][j-v[i-1]])%M;
        }
    }

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

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}


Measured memory_bytes: 74164
/*

                              Jai Shree Krishna !!
                                 Radhe Radhe !!
                                 
             उद्यमेन हि सिद्ध्यन्ति कार्याणि न मनोरथैः। नहि सुप्तस्य सिंहस्य मुखे प्रविशन्ति मृगाः।।
             
*/
   
   
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
typedef long long ll;
#define loop(i,n)  for(int i=0;i<n;i++)
#define read(a) int a; cin >>a;
#define readarr(a,n) int a[n] ; for(int i=0;i<n;i++) cin >> a[i];
#define readmat(a,n,m) int a[n][m]; for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin >> a[i][j];
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define pi pair<int,int>
#define vvi vector<vector<int>>
#define sti set<int>
#define vpi vector<pair<int,int>>
#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define printmat(a,n,m) for(int i=0;i<n;i++) {for(int j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl;}
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define endl "\n"
#define mp make_pair
#define ins insert
#define rep(i,s,e)  for(int i=s;i<=e;i++)
#define repd(i,s,e)  for(int i=e;i>=s;i--)
#define vb vector<bool>
#define read2(n,m) int n,m; cin >> n >> m;
#define range(v) v.begin(),v.end()
#define sortd(v) sort(v.begin(),v.end(),greater<int>())
#define sorti(v) sort(v.begin(),v.end())

const ll inf = 1e18;
const ll mod = 1e9 + 7;
 
signed main()
{
 
    fast;
    read2(n,m);
    readarr(a,n);
    int k=0;
    int lcm = a[0]/2;
    sti v;
    rep(i,0,n-1) {
    	a[i]=a[i]/2;
    	int x=a[i];
    	k=0;
    	while(x%2==0){
    		 k++;
    		 x=x/2;
    	}
    	v.ins(k);
    	lcm = (lcm*a[i])/__gcd(a[i],lcm);
    }
    
    
    if(v.size()!=1) {
    	cout<<0<<endl;
    	return 0;
    }
    
    int i=1,ans=0;
    if(m<lcm) {
    	cout<<0<<endl;
    	return 0;
    }
    ans = m/lcm;
    ans = (ans+1)/2;
    cout<<ans<<endl;
    return 0;
}

/* Pooja Yadav */

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define rep(i, n) for(int i = 0; i < (int)n; ++i)

using namespace std;

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  vector<int> ans(n);
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      int dist = min(j-i, abs(x-i)+1+abs(j-y));
      dist = min(dist, abs(y-i)+1+abs(j-x));
      ans[dist]++;
    }
  }
  for (int i = 1; i <= n-1; ++i) cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 256
N, K = int(input()), int(input())
memo = dict()

def dfs(i, s):
  if i == N:
    return s
  else:
    if (i, s) in memo:
      return memo[(i, s)]
    tmp = min(dfs(i + 1, s * 2), dfs(i + 1, s + K))
    memo[(i, s)] = tmp
    return tmp

print(dfs(0, 1))

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

int cal(string &prevS, string &nextS){
	int count=0;
	for(int i=1; i<prevS.size(); ++i){
		if(prevS.at(i-1)==prevS.at(i)){
			prevS.at(i)='-';
			++count;
		}
	}
	nextS.front()=prevS.back();
	return count;
}

int main(){
	string S;
	int K;
	cin >> S >> K;
	string evenS='-'+S, oddS='-'+S;
	int64_t first=cal(S,evenS), even=cal(evenS,oddS), odd=cal(oddS,evenS);
	cout << first + K/2*even + (K-1)/2*odd << "\n"s;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s;
    getline(cin, s); //1行読み込む
    for(int i = 0; i < s.size(); i++){
        char c = s[i];
        if('A' <= c && c <= 'Z'){
            //c = tolower(c);
            c = c + 32;
        }
        else if('a' <= c && c <= 'z'){
            c = c - 32;
        }
        cout << c;
    }
    cout << endl;
}


Measured memory_bytes: 3136
#include<cstdio>
#include<vector>
std::vector<int>g[100005];

int main(){
    int n;
    scanf("%d",&n);
    int m = 2*n, find = -1;
    for(int i = 1; i <= m; i++){
        if(m%i==0){
            int j = m/i;
            if(j==i-1){
                find = i;
                break;
            }
        }
    }
    if(find==-1) printf("No\n");
    else{
        printf("Yes\n%d\n",find);
        int cur = 0;
        for(int i = 1; i <= find; i++){
            for(int j = i+1; j <= find; j++){
                cur++;
                g[i].push_back(cur);
                g[j].push_back(cur);
            }
        }
        for(int i = 1; i <= find; i++){
            printf("%d ",(int)g[i].size());
            for(int j = 0; j < (int)g[i].size(); j++) printf("%d ",g[i][j]);
            printf("\n");
        }
    }
    return 0;
}


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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if((a==b&&a!=c) || (b==c && b!=a) || (c==a && c!=b)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
N, P = map(int, input().split())
S = input()[::-1]

dp = [0] * (N+1)
digit = 1
if P in [2, 5]:
  count = 0
  for i, s in enumerate(S, 1):
    s = int(s)
    if s%P == 0:
      count += 1
    dp[i] = dp[i-1] + count
else:
  mod_count = dict(zip(range(P), [0]*P))
  pre_r = 0
  for i, s in enumerate(S, 1):
    s = int(s)
    r = (digit * s + pre_r) % P
    dp[i] = dp[i-1] + mod_count[r]
    if r == 0:
      dp[i] += 1
    mod_count[r] += 1
    pre_r = r
    digit = (digit * 10) % P

print(dp[-1])

Measured memory_bytes: 12320
#include<iostream>
using std::cin;
using std::cout;
using std::endl;
int main()
{
    long long x,a,b,ans,c;
    cin>>x>>a>>b;
    ans=x-a;
    c=ans/b;
    if(ans%b==0)
    cout<<"0"<<endl;
    else cout<<x-a-b*c<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())

max_cnt = 0
ans = 0
for i in range(1, n+1):
    cnt = 0
    x = i
    while x % 2 == 0:
        x //= 2
        cnt += 1
    if cnt >=  max_cnt:
        max_cnt = cnt
        ans = i

print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define LL long long
#define MOD 1000000007
using namespace std;
char g[1005][1005];
int dp[1005][1005];
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int H, W;
  cin >> H >> W;
  char ch;
  for (int i = 0; i < H; ++i)
    for (int j = 0; j < W; ++j)
      {
        cin >> g[i][j];
      }
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;
  for (int i = 0; i < H; ++i)
    for (int j = 0; j < W; ++j)
      {
        if (i == 0 && j == 0) continue;
        if (g[i][j] == '#') continue;
        if (i != 0) dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
        if (j != 0) dp[i][j] = (dp[i][j] + dp[i][j - 1]) % MOD;
      }
  cout << dp[H - 1][W - 1] % MOD << endl;
  return 0;
}


Measured memory_bytes: 8524
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef vector<int> vi;

int main() {FIN

	int n, i;
	cin >> n;
	vi hs(n), dp(n);
	
	for (i = 0; i < n; i++)
		cin >> hs[i];

	for (i = 0; i < n; i++) {
		if (i > 0) {
			dp[i] = dp[i - 1] + abs(hs[i] - hs[i - 1]);
			if (i > 1)
				dp[i] = min(dp[i], dp[i - 2] + abs(hs[i] - hs[i - 2]));
		}
	}

	cout << dp[n - 1] << "\n";

	return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010

// 400, 15min + 15min + 15min

ll N;
ll A[MAX_N];

int main()
{
    cin >> N;
    ll ans = 0;
    REP(i, N) {
        cin >> A[i];
    }
    for(int i = 0; i < N-1; ++i) {
        if(A[i] % 2 == 0 && i > 0 &&
           A[i-1] % 2 != 0 && A[i+1] != 0 && A[i] >= 2) {
            A[i-1]++;
            A[i+1]++;
            A[i] -= 2;
        }
        else if(A[i] % 2 != 0 && A[i+1] % 2 != 0) {
            A[i]++;
            A[i+1]--;
        }
    }
    REP(i, N) {
        //DBG("A[%d]: %lld\n", i, A[i]);
        ans += A[i] / 2;
    }
    printf("%lld\n", ans);
    return 0;
}


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

string s;
int num[15];

int main(){
    cin >> s;
    int size = s.size()-1;
    // 数字と数字の間に+を入れるか入れないか。
    // 2^n 
    ll ans = 0;
    // bit全探索 : どこに+を入れるかの組み合わせを全列挙
    REP(bit, (1<<size)){
        int before = 0;
        REP(i,s.size()){
            if(bit & (1<<i)){
                string temp = s.substr(before, i - before + 1);
                ans += stoll(temp);
                before = i + 1;
            }
        }
        string temp = s.substr(before, size - before + 1);
        ans += stoll(temp);
    }
    
    cout << ans << endl;
    return 0;
}


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

struct S {
  public int s, t, e;
  public S(int[] a) {
    s = a[0];
    t = a[1];
    e = a[2];
  }
}

class Program {
  static void Main() {
    var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
    int n = a[0];
    int m = a[1];
    var lst = new List<S>();
    var str = "";
    while ((str = Console.ReadLine()) != "0 0 0") {
      a = str.Split().Select(int.Parse).ToArray();
      lst.Add(new S(a));
    }
    int L = int.Parse(Console.ReadLine());
    while (L-- > 0) {
      int[] c = new int[n];
      var b = Console.ReadLine().Split().Select(int.Parse).ToArray();
      foreach (var v in lst) c[v.s - 1] += b[v.t - 1] * v.e;
      var sb = new StringBuilder();
      for (int i = 0; i < n - 1; i++) {
        sb.Append(c[i] + " ");
      }
      sb.AppendLine(c[n - 1].ToString());
      Console.Write(sb);
    }
  }
}


Measured memory_bytes: 40104
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] set = br.readLine().split(" ");
		double x1 = Double.parseDouble(set[0]);
		double y1 = Double.parseDouble(set[1]);
		double x2 = Double.parseDouble(set[2]);
		double y2 = Double.parseDouble(set[3]);

		double r = Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
		System.out.printf("%.8f\n", r);
	}
}

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

        int aa=Integer.valueOf(a);
        int bb=Integer.valueOf(b);
        if(aa<bb) {
            for(int x=0;x<bb;x++) {
                System.out.print(aa);
            }
        } else {
            for(int y=0;y<aa;y++) {
                System.out.print(bb);
            }
        }
        
    }
}

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;




struct edge {
    int to; number cost;
    edge(int a, number b) : to(a), cost(b) {}
};
using wgraph = vector<vector<edge>>;

vector<number> dijkstra(int s, int V, const wgraph &G) {
    minPQ<pair<number, int>> q;
    vector<number> dist(V, INF);
    dist[s] = 0;
    q.push(mp(0, s));

    while (!q.empty()) {
        auto p = q.top(); q.pop();
        int v = p.second;
        if (dist[v] > p.first) continue;
        for (auto e : G[v]) {
            if (dist[e.to] > dist[v] + e.cost) {
                dist[e.to] = dist[v] + e.cost;
                q.push(mp(dist[e.to], e.to));
            }
        }
    }
    return dist;
}


int main() {
    int n, m, s, t; cin >> n >> m >> s >> t;
    s--, t--;
    wgraph yen(n), snuke(n);
    int u, v; ll a, b;
    rep(i, m) {
        cin >> u >> v >> a >> b;
        u--, v--;
        yen[u].pb(edge(v, a));
        yen[v].pb(edge(u, a));
        snuke[u].pb(edge(v, b));
        snuke[v].pb(edge(u, b));
    }

    vll dy = dijkstra(s, n, yen);
    vll ds = dijkstra(t, n, snuke);

    /*for (auto x : dy) cout << x << endl;
        cout << " " << endl;
    for (auto x : ds) cout << x << endl;
*/
    const ll num = pow(10, 15);
    vll ans(n + 1, 0);
    for (int i = n - 1; i >= 0; i--) {
        ans[i] = max(ans[i + 1], num - dy[i] - ds[i]);
    }

    rep(i, n) cout << ans[i] << endl;

}

Measured memory_bytes: 19740
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
//#include <ostream>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  int N,x_min,x_max,sum;
  cin >> N;
  vector<int> X(N);
  rep(i,N)cin >> X[i];
  x_min = INF;
  x_max = 0;
  rep(i,N){
    x_min = min(x_min,X[i]);
    x_max = max(x_max,X[i]);
  }
  ll ans = INF;
  for(int i = x_min;i <= x_max;i++){
    sum = 0;
    rep(j,N){
      sum += pow(abs(X[j]-i),2);
    }
    if(ans>sum)ans=sum;
  }
  cout << ans << endl;
}


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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var Instance = new Question();
			Instance.Exec();
		}
	}

	public class Question
	{
		public void Exec()
		{
			var nml = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
			int n = nml[0];
			int m = nml[1];
			int l = nml[2];
			int[,] A = new int[n, m];
			for (int j = 0; j < n; ++j) {
				var aij = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
				for (int k = 0; k < aij.Length; ++k) {
					A[j, k] = aij[k];
				}
			}

			int[,] B = new int[m, l];
			for (int j = 0; j < m; ++j) {
				var bij = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
				for (int k = 0; k < bij.Length; ++k) {
					B[j, k] = bij[k];
				}
			}

			long[,] C = new long[n, l];
			for (int j = 0; j < C.GetLength(0); ++j) {
				for (int k = 0; k < C.GetLength(1); ++k) {
					for (int i = 0; i < m; ++i) {
						C[j, k] += (long)A[j, i] * (long)B[i, k];
					}
				}
			}

			for (int j = 0; j < C.GetLength(0); ++j) {
				for (int k = 0; k < C.GetLength(1); ++k) {
					Console.Write($"{C[j, k]}");
					if (k < C.GetLength(1) - 1) {
						Console.Write(" ");
					}
				}
				Console.WriteLine("");
			}

			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 18476
#include<bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define inlld(x) scanf("%lld", &x)
#define ind(x) scanf("%d", &x)
#define inlld2(x, y) scanf("%lld%lld", &x, &y)
#define inlld3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z)
#define ind2(x, y) scanf("%d%d", &x, &y)
#define ind3(x, y, z) scanf("%d%d%d", &x, &y, &z)

const int N=1e2+5;
const int K=1e5+5;
const int MOD=1e9+7;

typedef long long ll;
typedef long double ld;

using namespace std;

ll n, k, arr[N], dp[2][K], pref[2][K];

int main()
{
    inlld2(n, k);
    for(ll a=1; a<=n; a++)
        inlld(arr[a]);
    dp[(n+1)%2][0]=1;
    for(ll a=0; a<=k; a++)
        pref[(n+1)%2][a]=1;
    for(ll a=n; a>=1; a--)
    {
        for(ll b=0; b<=k; b++)
        {
            dp[a%2][b]=pref[(a+1)%2][b];
            if(b-arr[a]-1>=0)
                dp[a%2][b]-=pref[(a+1)%2][b-arr[a]-1];
            dp[a%2][b]%=MOD;
            while(dp[a%2][b]<0)
                dp[a%2][b]+=MOD;
        }
        pref[a%2][0]=dp[a%2][0];
        for(ll b=1; b<=k; b++)
            pref[a%2][b]=(pref[a%2][b-1]+dp[a%2][b])%MOD;
    }
    printf("%lld\n", dp[1][k]);
    return 0;
}

Measured memory_bytes: 3328
# include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long 
int dp[10005][105][2];
int n;string str;int k;
//vector<int> v;
ll get(int pos,int sum,bool  f)
{ int & ans=dp[pos][sum][f];
  
  if(pos==n)
 { 
    if(sum%k==0) return (ans=1);
    else
      return (ans=0);
 }
 
 if(ans!=-1) return ans;
 ans=0;
  int lim=(f)? 9:(str[pos]-'0');
  for(int i=0;i<=lim;i++)
  { 
    ans=((ll)ans%mod+(get(pos+1,(sum+i)%k,f | (i<lim)))%mod)%mod;

  }
   return ans;
  
}

int main()
{  //ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  //string str;
 // cin.ignore();
  cin>>str;
  cin>>k;
  n=str.size();
 // cout<<str<<" ";
 //cout<<k<<" ";

   memset(dp, -1, sizeof (dp));
 cout<<(get(0,0,0)-1+mod)%mod;
  return 0;
  
}

Measured memory_bytes: 9472
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define per(i,r,l) for(int i=r;i>=l;i--)
#define IMAX 0x3f3f3f3f
#define LLMAX 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
typedef double db;
inline int read() {
  int x=0,f=1;
  char c=getchar();
  while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
  while(isdigit(c)){x=x*10+c-'0';c=getchar();}
  return x*f;
}

signed main() {
  int _=1;//_=read();
  while(_--){
    string s;
    cin >> s;
    if (s[2]==s[3]&&s[4]==s[5]) puts("Yes");
    else puts("No");
  }
}

Measured memory_bytes: 256
n=int(input())

l=list(map(int,input().split()))

dp=[0]*n
dp[0]=0
dp[1]=abs(l[1]-l[0])
for i in range(2,n):
  dp[i]=min([
  	    dp[i-1] + abs(l[i]-l[i-1]),
    	dp[i-2] + abs(l[i]-l[i-2])
  ])
print(dp[-1])

Measured memory_bytes: 13980
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int cpos=-1,fpos=-1;
	string h;
	cin>>h;
	for(int j=0;j<=h.size();j++)
	{
		if(h[j]=='C') cpos=j;
		if(h[j]=='F') fpos=j;
	}
	if(cpos!=-1&&fpos!=-1&&fpos>cpos) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256