akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

int N, M, L;

struct State {
    int v, sum, dist;
    State(int v, int sum, int dist) : v(v), sum(sum), dist(dist) {}
    bool operator<(const State& a) const {
        return dist > a.dist;
    }
};

struct edge {
    int to, money, enemy;
    edge(int to, int money, int enemy):to(to),money(money),enemy(enemy){}
};

vector<edge> G[101];
int d[101][101];

void dijkstra(int s)
{
    for (int i = 0; i <= 100; ++i) for (int j = 0; j < N; ++j) d[i][j] = inf;

    priority_queue<State> q;
    q.push(State(s, 0, 0));

    d[0][s] = 0;

    while (q.size()) {
        State st = q.top(); q.pop();

        if (d[st.sum][st.v] < st.dist) continue;

        for (int i = 0; i < G[st.v].size(); ++i) {
            edge e = G[st.v][i];

            if (st.sum + e.money <= L && d[st.sum + e.money][e.to] > st.dist) {
                d[st.sum + e.money][e.to] = st.dist;
                q.push(State(e.to, st.sum + e.money, d[st.sum + e.money][e.to]));
            }

            if (d[st.sum][e.to] > st.dist + e.enemy) {
                d[st.sum][e.to] = st.dist + e.enemy;
                q.push(State(e.to, st.sum, d[st.sum][e.to]));
            }
        }
    }
}

signed main()
{
    while (scanf("%d%d%d", &N, &M, &L), N) {
        for (int i = 0; i < N; ++i) G[i].clear();

        for (int i = 0; i < M; ++i) {
            int A, B, D, E;
            scanf("%d%d%d%d", &A, &B, &D, &E);
            A--, B--;
            G[A].push_back(edge(B, D, E));
            G[B].push_back(edge(A, D, E));
        }

        dijkstra(0);

        int mi = inf;

        for (int i = 0; i <= 100; ++i) {
            chmin(mi, d[i][N - 1]);
        }

        printf("%d\n", mi);
    }
}

Measured memory_bytes: 1716
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << max(a*b,c*d);
}


Measured memory_bytes: 256
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//ll a[Max];
ll n;
void solve(){
	cin>>n;
	cout<<n*(n-1)/2;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;

int main()
{
	int k, x;
	cin >> k >> x;
	for (int i = x - k + 1; i <= x + k - 1; i++) {
		if (i >= -1000000 && i <= 1000000)
			cout << i;
			if (i != x + k - 1)
				cout << " ";
	}
	cout << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {

	popular()
}

//popular C
func popular(){

var N,M int

	fmt.Scan(&N,&M)

	A := make([]float64,N)

	for i:=0;i<N;i++{

		fmt.Scan(&A[i])

	}

	var sum float64

	for i:=0;i<N;i++{

		sum += A[i]
	}



	var shikii float64

	fM := float64(M)


	shikii = sum/(4*fM)

	cnt :=0

	for i:=0;i<N;i++{

		if A[i] < shikii{
			
		}else
		{
			cnt = cnt+1
		}
	}


	if cnt >= M{

		fmt.Println("Yes")

	}else{

		fmt.Println("No")
	}


}

Measured memory_bytes: 512
n = int(input())
l = list(map(int, input().split()))

for i in range(n):
    if l[i] % 4 == 0:
        l[i] = 2
    elif l[i] % 4 == 2:
        l[i] = 1
    else:
        l[i] = 0

if n - (l.count(2)*2 + 1) <= 0:
    print("Yes")
elif n - (l.count(2)*2 + 1) < l.count(1):
    print("Yes")
else:
    print("No")

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

int main() {
  int N;
  cin >> N;
  vector<int> X(N), sum(N);
  for (int i = 0; i < N; i++) cin >> X[i];
  sort(X.begin(), X.end());
  int L = X[0];
  int R = X[N-1];
  int ans = INT_MAX;
  for (int i = L; i <= R; i++) {
    int cost = 0;
    for (int j = 0; j < N; j++) {
      cost += (X[j] - i) * (X[j] - i); 
    }
    ans = min(ans, cost);
  }
  cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  
  vector<int> h(n);
  for (int i=0; i<n; i++){
    cin >> h.at(i);
  }
  
  int cnt = 0;
  int m_h = h.at(0);
  
  for (int i=0; i<n; i++){
    if (h.at(i) >= m_h){
      cnt++;
      m_h = h.at(i);
    }
  }
  
  cout << cnt << endl;
  
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

L,R = map(int,readline().split())

if abs(R - L) >= 2019:
  print(0)
  exit(0)
  
L %= 2019
R %= 2019

if L > R:
  L,R = R,L

if L == R:
  print(0)
  exit(0)

ans = 2019
for i in range(L, R):
  for j in range(i + 1, R + 1):
    if (i * j) % 2019 < ans:
      ans = (i * j) % 2019
      
print(ans)

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

int main() {
	int N, x = 0, ans = 0; cin >> N;
	string S; cin >> S;
	for( char k : S ){
		if(k == 'I'){
			x++;
			ans = max(ans, x);
		} else {
			x--;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int k; cin >> k;
	if(k%2==0||k%5==0){
		cout << -1 << endl;
	}
	else{
		ll sum=0,p=1;
		int ans=0;
		for(int i=1;1;i++){
			sum+=p*7%k;
			sum%=k;
			p=p*10%k;
			if(sum==0){
				ans=i;
				break;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;

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

    ll ans = 1e18;
    for(int i = 0; i < n - 1; i++){
        l += a[i],r -= a[i];
        ans = min(ans,abs(r-l));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

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

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007


int main() {
	int K, S;
	cin >> K >> S;
	Int ans = 0;

	for (int x = 0; x <= K; x++) {
		for (int y = 0; y <= K; y++) {
			if (S - x - y <= K && S - x - y >= 0)ans++;
		}
	}
	cout << ans << endl;





	return 0;
}

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

class Program
{
    static void Main()
    {
        var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var A = input[0];
        var B = input[1];

        Console.WriteLine(Math.Ceiling((B - 1.0) / (A - 1.0)));
    }
}


Measured memory_bytes: 13268
#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 ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

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; }

const ll INF=(ll)1e19;
//const int INF=(1<<30);

int main(){
  double t,x;
  cin >> t >> x;
  printf("%05f\n", t/x);
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int N, i, A, B, maxA = 0, thenB;
	scanf("%d", &N);
	for(i = 0; i < N; i++){
		scanf("%d%d", &A, &B);
		if(A > maxA){
			maxA = A;
			thenB = B;
		}
	}
	printf("%d\n", maxA + thenB);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <regex>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include  <cassert>
#include <fstream>
#include <codecvt>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define int ll
const int INF = (1LL << 32);
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

static const int MAX = 1400;
struct Rectangle {
	int height;
	int pos;
};

int getLargestRectangle(int size, int buffer[]) {
	stack<Rectangle> S;
	int maxv = 0;
	buffer[size] = 0;
	for (int i = 0; i <= size; i++) {
		Rectangle rect;
		rect.height = buffer[i];
		rect.pos = i;
		if (S.empty()) {
			S.push(rect);
		}
		else {
			if (S.top().height < rect.height) {
				S.push(rect);
			}
			else if (S.top().height > rect.height) {
				int target = i;
				while (!S.empty() and S.top().height >= rect.height) {
					Rectangle pre = S.top();
					S.pop();
					int area = pre.height * (i - pre.pos);
					maxv = max(area, maxv);
					target = pre.pos;
				}
				rect.pos = target;
				S.push(rect);
			}
		}
	}
	return maxv;
}

int H, W;
int buffer[MAX][MAX];
int T[MAX][MAX];

int getLargestRectangle() {
	rep(j, W) {
		rep(i, H) {
			if (buffer[i][j]) {
				T[i][j] = 0;
			}
			else {
				T[i][j] = (i > 0) ? T[i - 1][j] + 1 : 1;
			}
		}
	}

	int maxv = 0;
	rep(i, H) {
		maxv = max(maxv, getLargestRectangle(W, T[i]));
	}
	return maxv;
}

signed main() {
	ios::sync_with_stdio(true);
	cin >> H >> W;
	rep(i, H) {
		rep(j, W) {
			cin >> buffer[i][j];
		}
	}
	cout << getLargestRectangle() << endl;
	return 0;
}


Measured memory_bytes: 33712
#include <stdio.h>
#define MAX 44

int F[MAX];

int fibonacci(int n){

	int i;

    F[0] = 1;
    F[1] = 1;
    for(i = 2; i < n+2; i++) F[i] = F[i-2] + F[i-1];

    return F[n];
}

int main(void){

	int n;

	scanf("%d",&n);
	printf("%d\n",fibonacci(n));

	return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int limit = 100010;
using edge = struct {
  int to; //行先
  ll cost; //距離
};
vector<edge> tree[limit];
ll depth[limit];
void dfs(int v, int p, ll d) { //v:行先,p:ひとつ前,d:累積距離
  depth[v] = d;
  for (auto &e : tree[v]) {
    if (e.to == p) continue; //逆戻り不可
    dfs(e.to, v, d + e.cost); //次の行き先,現在地,累積距離
  }
}
int main(void) {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    tree[a].push_back({b, c}); //aからbへの距離
    tree[b].push_back({a, c}); //bからaへの距離
  }
  int q, k;
  cin >> q >> k;
  k--;
  dfs(k, -1, 0); //kから各方面への距離
  for (int i = 0; i < q; ++i) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    cout << depth[x] + depth[y] << endl;
  }
  return 0;
}

/*
5
1 2 1
1 3 1
2 4 1
3 5 1
3 1
2 4
2 3
4 5

tree[0]=(1,1),(2,1)
tree[1]=(0,1),(3,1)
tree[2]=(0,1),(4,1)
tree[3]=(1,1)
tree[4]=(2,1)

dfs(0,-1,0){
  depth[0]=0
  dfs(1,0,0+1){
    depth[1]=1
    dfs(3,1,1+1){
      depth[3]=2
    }
  }
  dfs(2,0,0+1){
    depth[2]=1
    dfs(4,2,1+1){
      depth[4]=2
    }
  }
}
*/

Measured memory_bytes: 14336
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
using namespace std;
const int Maxn=505;
int n;
vector<vector<int> > L[Maxn],R[Maxn];
int ans[Maxn][Maxn];
void Go(int l,int r,int lvl){
	if (l==r) return;
	int mid=l+r>>1;
	Go(l,mid,lvl+1);
	Go(mid+1,r,lvl+1);
	vector<int> tmp;
	for (int i=l;i<=mid;i++) tmp.pb(i);
	L[lvl].pb(tmp);
	tmp.clear();
	for (int i=mid+1;i<=r;i++) tmp.pb(i);
	R[lvl].pb(tmp);
}
int main(){
	scanf("%d",&n);
	Go(1,n,1);
	for (int i=1;i<=Maxn;i++){
		if (L[i].empty()) break;
		for (int j=0;j<L[i].size();j++){
			vector<int> &l=L[i][j],&r=R[i][j];
			for (auto u:l){
				for (auto v:r){
					ans[u][v]=i;
				}
			}
		}
	}
	for (int i=1;i<=n;i++){
		for (int j=i+1;j<=n;j++){
			printf("%d ",ans[i][j]);
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  int n;
  cin >>n;
  n = n%10;
  string s;
  if (n==2||n==4||n==5||n==7||n==9) s = "hon";
  if (n==0||n==1||n==6||n==8) s = "pon";
  if (n==3) s = "bon";
  cout << s << endl;
}



Measured memory_bytes: 3628
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;


int main()
{
int n,m;
scanf("%d",&n);
int a,b;
int f=0;
for(int i=1;i<=9;i++)
{
  b=n/i;
  if(b>=10)
  continue;
  if(b*i==n)
  {
   f=1;
  break;
  }


}




if(f==1)
printf("Yes\n");
else
printf("No\n");
}


Measured memory_bytes: 256
#! python3
# structuredProgramming.py - 構造化プログラミングの練習

def checkNum(n):
  if n % 3 == 0:
    return True
  elif include3(n):
    return True
  else :
    k = n
    while k >= 30:
      k = int(k / 10)
      if include3(k):
        return True
  
def include3(n):
  if n % 10 == 3:
    return True
  else :
    return False

input_int = int(input())

numbers = []
for i in range(1, input_int+1):
  if checkNum(i):
    numbers.append(i)

str_numbers = list(map(str, numbers))
print(' '+' '.join(str_numbers))



Measured memory_bytes: 6196
#include<stdio.h>
int max(int a,int b){
  if(a>b) return a;
  return b;
}
int main(void){
  int n,i,ans=0;
  scanf("%d",&n);
  long long int a[n];
  int b[n];
  for(i=0;i<n;i++){
    scanf("%lld",&a[i]);
    b[i] = 0;
  }
  b[n-1] = 0;
  for(i=n-1;i>0;i--){
    if(a[i]<=a[i-1]) b[i-1] = b[i] + 1;
    else if(a[i]>a[i-1]) b[i-1] = 0;
  }
  for(i=0;i<n;i++) ans = max(ans,b[i]);
  printf("%d\n",ans);
  return 0;
}

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

int X;
bool is_prime(int x){
	for(int i=2;i<=sqrt(x);i++) if(x%i==0) return false;
	return true;
}

int main(){
	scanf("%d",&X);
	while(!is_prime(X)) X++;
	printf("%d\n",X);
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min};
use std::io::{stdin, stdout, BufWriter, Write};

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>,
}

impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn main() {
    let mut scan = Scanner::default();
    let out = &mut BufWriter::new(stdout());
    let n:usize = scan.next();
    let mut a = Vec::<i32>::new();
    for _ in 0..n {
        let x:i32 = scan.next();
        a.push(x);
    }

    write!(out, "{}", a[n-1]).ok();
    for i in 2..n+1 {
        write!(out, " {}", a[n-i]).ok();
    }
    writeln!(out).ok();
}



Measured memory_bytes: 5036
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define reads(s) string s; cin >> s;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define setprec(x) cout << fixed << setprecision(x)
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 

     
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    //start from here

    readb(a, b);
    if(a + b == 15) cout << '+';
    else if(a * b == 15) cout << '*';
    else cout << 'x';

    return 0;
}


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

double circle_r, circle_sum, circle_around, pi = 3.141592653589;

int main() {
	scanf("%lf", &circle_r);
	circle_sum = pow(circle_r, 2) * pi;
	circle_around = circle_r * 2 * pi;
	printf("%f %f\n", circle_sum, circle_around);
	
	return 0;
}


Measured memory_bytes: 2060
#include <stdio.h>
#pragma warning(disable : 4996)
long double a, b, c, d, e, f, x, y;
int main() {
    while (~scanf("%Lf%Lf%Lf%Lf%Lf%Lf", &a, &b, &c, &d, &e, &f)) {
        x = (c * e - b * f) / (a * e - b * d);
        y = (a * f - c * d) / (a * e - b * d);
        if (-0.0005 < x && x < 0.0005) x = 0.0;
        if (-0.0005 < y && y < 0.0005) y = 0.0;
        printf("%.3Lf %.3Lf\n", x, y);
    }
    return 0;
}

Measured memory_bytes: 2724
import java.util.*;

public class Main {

    static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
    static long mod = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] L = new long[N];

        for(int i=0;i<N;i++){
            L[i] = sc.nextLong();
        }
        Arrays.sort(L);

        int ans =0;
        for(int i=0;i<N-2;i++){

            for(int j=i+1;j<N-1;j++){
                for(int k = j+1;k<N;k++){
                    if(L[i] + L[j] > L[k]){
                        if(L[i] != L[j] && L[j] != L[k] && L[j] != L[k]){
                            ans++;

                        }

                    }
                }
            }
        }
        System.out.println(ans);

    }

}




Measured memory_bytes: 36052
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
#include <set>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;


int main() {
    int N;
    cin >> N;
    int shou = N/1.08;
    int ans;
    while(1){
        ans = shou * 1.08;
        if(ans == N){
            break;
        }
        shou++;
        if(ans > N){
            cout << ":(" << endl;
            return 0;
        }
    }
    cout << shou << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cctype>
int main(){
char ch[1500];
int i = 0;
while(1){
	i=0;
while(1){
    if(scanf("%c", &ch[i]) == EOF){
		return 0;
	}
    if ( ch[i] == '\n' ) break;
	i++;
}
i = 0;
while(1){

	if(islower(ch[i])){
		ch[i] = toupper(ch[i]);
	}	printf("%c",ch[i]);

	if ( ch[i] == '\n' ) break;
	i++;
}
}

}

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

# define x first
# define y second
# define mp make_pair
// everything goes according to my plan
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right

# ifdef Local
# define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
# else
# define debug(...) (__VA_ARGS__)
# define cerr if(0)cout
# endif

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") {
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}
const int N = 1e6 + 1;

int n;

char s[2*N];

ll cp[2*N];

ll pp[N];

ll dp[N];

ll solve (int k) {
  memset (dp, 0, sizeof dp);
  memset (cp, 0, sizeof cp);
  memset (pp, 0, sizeof pp);

  for (int i = 1; i <= 2*n; i++)
    cp[i] = cp[i - 1] + (s[i] == 'C');
  
  for (int i = 1; i <= n; i++)
    pp[i] = pp[i - 1] + (s[i] == 'D') * 1ll * cp[i + k - 1];

  for (int i = 1; i <= n; i++)
    dp[i] = dp[i - 1] + (s[i] == 'D');

  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    if (s[i] == 'M') {
      int l = max (0, i - k + 1);
      ll x = pp[i] - pp[l];
      x -= (dp[i] - dp[l]) * cp[i-1];
      ans += x;
    }
  }
  return ans;
}

int main()
{
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> s[i];

  int q;
  cin >> q;
  while (q--) {
    int k;
    cin >> k;
    cout << solve (k) << endl;
  }



  return 0;
}






// Coded by Z..

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

int main(){
  int N , X , T  ;
  cin >> N >> X >> T ; 
  
  if( N%X == 0 ){
    cout << (N/X)*T <<endl ; 
    return 0 ; 
  }
  cout << (N/X)*T + T << endl ; 
  
}

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

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

        long d = sc.NextLong();
        long[] c = sc.LongArray();
        long[,] s = new long[d, 26];
        for (int i = 0; i < d; i++)
        {
            for (int j = 0; j < 26; j++)
            {
                s[i, j] = sc.NextLong();
            }
        }

        long[] last = new long[26];

        for (int i = 0; i < d; i++)
        {
            long maxDiff = long.MinValue;
            long answerIndex = 0;
            long secondDiff = long.MinValue;
            long secondIndex = 0;
            for (int j = 0; j < 26; j++)
            {
                long diff = 0;
                diff += s[i, j];
                diff += c[j] * (i + 1 - last[j]);
                if (diff > maxDiff)
                {
                    secondDiff = maxDiff;
                    maxDiff = diff;
                    secondIndex = answerIndex;
                    answerIndex = j;
                }
            }
            if (i != d - 1 && s[i + 1, answerIndex] > s[i, answerIndex])
            {
                answerIndex = secondIndex;
            }
            last[answerIndex] = i;
            Console.WriteLine(answerIndex + 1);
        }
    }

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

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

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

            return _line[_index++];
        }

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

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

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


Measured memory_bytes: 28840
object Main {
  def main(args: Array[String]): Unit = {
    val factors                     = scala.io.StdIn.readLine.split(" ").map{_.toInt}
    var amount_of_waters: Array[Int] = Array.empty

    (0 to 30).foreach{ i =>
      (0 to 30).foreach{ j =>
        val water = ( factors(0)*i + factors(1)*j )*100
        if( !amount_of_waters.contains( water ) && water < factors(5) ) amount_of_waters = amount_of_waters :+ water

      }
    }

    var suger_rate            = 0.0
    var amount_of_suger       = 0
    var amount_of_suger_water = 0

    amount_of_waters.foreach { water =>
      ( 0 to ( water*factors(4)/100/factors(2) ).toInt + 1 ).foreach{ i =>
        ( 0 to ( water*factors(4)/100/factors(3) ).toInt + 1 ).foreach{ j =>
          val suger = ( factors(2)*i + factors(3)*j )
          val suger_water = water + suger
          if( suger_water <= factors(5) && water*factors(4)/100 >= suger ) {
                val rate = suger/suger_water.toDouble
                if( suger_rate < rate ) {
                amount_of_suger       = suger
                amount_of_suger_water = suger_water
                suger_rate            = rate
                }
                  }
        }
      }
    }

    if( amount_of_suger_water == 0 ) amount_of_suger_water = amount_of_waters( 1 )

    println( amount_of_suger_water + " " + amount_of_suger )
  }
}

Measured memory_bytes: 55028
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var N = Sarray()[0];
            WriteLine(N * (N + 1) / 2);
        }
    }
}

Measured memory_bytes: 28040
#include <bits/stdc++.h>
using namespace std;
int yakusuunokazu(int N)
{
    int a = 0, p = 1;
    while (N % 2 == 0)
    {
        a++;
        N /= 2;
    }
    p *= a + 1;
    a = 0;
    while (N % 3 == 0)
    {
        a++;
        N /= 3;
    }
    p *= a + 1;
    a = 0;
    while (N % 5 == 0)
    {
        a++;
        N /= 5;
    }
    p *= a + 1;
    a = 0;
    while (N % 7 == 0)
    {
        a++;
        N /= 7;
    }
    p *= a + 1;
    a = 0;
    while (N % 11 == 0)
    {
        a++;
        N /= 11;
    }
    p *= a + 1;
    a = 0;
    while (N % 13 == 0)
    {
        a++;
        N /= 13;
    }
    p *= a + 1;
    a = 0;
    return p;
}
int main(){
    int N,i,a = 0;
    cin >> N;
    for(i = 1;i <= N;i += 2){
        if(yakusuunokazu(i) == 8){
            a++;
        }
    }
    cout << a << endl;
}

Measured memory_bytes: 3616
R,C,k = map(int,input().split())
dp0 = [[0]*(C+1) for i in range(R+1)]
dp1 = [[0]*(C+1) for i in range(R+1)]
dp2 = [[0]*(C+1) for i in range(R+1)]
dp3 = [[0]*(C+1) for i in range(R+1)]
item = [[0]*(C+1) for i in range(R+1)]
for i in range(k):
    r,c,v = map(int,input().split())
    # item[r][c] = v
    dp1[r][c] = v
# for i in range(R+1):
    # print(item[i])

for i in range(1,R+1):
    for j in range(1,C+1):
        # a = item[i][j]
        # dp0[i][j] = max(dp0[i-1][j],dp1[i-1][j],dp2[i-1][j],dp3[i-1][j],dp0[i][j-1])
        # dp1[i][j] = max(dp0[i][j-1]+a,dp1[i][j-1])
        # dp2[i][j] = max(dp1[i][j-1]+a,dp2[i][j-1])
        # dp3[i][j] = max(dp2[i][j-1]+a,dp3[i][j-1])
        # dp0[i][j] = max(dp0[i-1][j],dp1[i-1][j],dp2[i-1][j],dp3[i-1][j],dp0[i][j-1],dp0[i][j])
        dp3[i][j] = max(dp2[i][j-1]+dp1[i][j],dp3[i][j-1])
        dp2[i][j] = max(dp1[i][j-1]+dp1[i][j],dp2[i][j-1])
        dp1[i][j] = max(dp1[i-1][j]+dp1[i][j],dp2[i-1][j]+dp1[i][j],dp3[i-1][j]+dp1[i][j],dp1[i][j-1],dp1[i][j])
        
        

# for i in range(R+1):
#     print(dp2[i])
print(max(dp0[R][C],dp1[R][C],dp2[R][C],dp3[R][C]))

Measured memory_bytes: 427464
import java.util.*;
class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);		
		String sc = in.nextLine();
		if (sc.length() < 4) {
			System.out.println("No");
		}else if (sc.charAt(0) == 'Y' && sc.charAt(1) == 'A' && sc.charAt(2) == 'K' && sc.charAt(3) == 'I') {
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
  	}
}


Measured memory_bytes: 21972
import sys

while True:
	n, x = [ int( val ) for val in sys.stdin.readline().split( " " ) ]
	if 0 == n and 0 == x:
		break
		
	cnt = 0
	for i in range( 1, n-1 ):
		if  x <= i:
			break
		for j in range( i+1, n ):
			if  x <= ( i+j ):
				break
			for k in range( j+1, n+1 ):
				s = ( i + j + k )
				if x == s:
					cnt += 1
					break
				elif   x < s:
					break
	
	print( cnt )

Measured memory_bytes: 4224
package main

import (
	"fmt"
	"math"
)

func main() {
	var X int
	fmt.Scan(&X)

	var m float64
	m = 100.0

	for i := 1; ; i++ {
		m = math.Trunc(m * 1.01)

		if int(m) >= X {
			fmt.Println(i)
			break
		}
	}
}

Measured memory_bytes: 1760
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	int sum = a + b;
	if (sum % 2 == 0) {
		cout << sum / 2 << endl;
	} else {
		cout << "IMPOSSIBLE" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
#define endl '\n'
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 namespace std;

signed main(){
    int n; cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a.at(i);
    int ans=0,xorsum=0,sum=0,right=0;
    rep(left,n){
        while(right<n){
            if((xorsum^a.at(right))!=sum+a.at(right))break;
            xorsum^=a.at(right); sum+=a.at(right);
            right++;
        }
        ans+=right-left;
        if(left==right)right++;
        else{
            xorsum^=a.at(left); sum-=a.at(left);
        }
    }
    cout<<ans<<endl;
}

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

vac = []
firstDay = list(map(int, input().split()))

for _ in range(n-1):
    newTotal = [0,0,0]
    
    secondDay = list(map(int, input().split()))
    for j, second in enumerate(secondDay):
        temp = 0
        for i, first in enumerate(firstDay):
            if i != j:
                temp = max(temp, first + second)
                
        newTotal[j] = temp   
                    
    firstDay = newTotal
    
print(max(firstDay))

Measured memory_bytes: 75816
import bisect

def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    b_list = list(map(int, input().split()))
    c_list = list(map(int, input().split()))

    ans = 0

    a_list.sort()
    c_list.sort()

    for i in range(n):
        toa_insert_index = bisect.bisect_left(a_list, b_list[i])
        toc_insert_index = bisect.bisect_right(c_list, b_list[i])
        ans += toa_insert_index * ( n - toc_insert_index )

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 105444
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int N;
vector<long long> a;


int main() {
    while (cin >> N) {
        a.resize(N);
        for (int i = 0; i < N; ++i) cin >> a[i];
        long long res = 0;
        for (int i = 0; i < N; ++i) {
            int tmp = 0;
            while (a[i] % 2 == 0) {
                ++tmp;
                a[i] /= 2;
            }
            res += tmp;
        }
        cout << res << endl;
    }
}



























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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
// #define endl '\n'


int main() {
  int p, q, r;
  cin >> p >> q >> r;
  cout << p + q + r - max({p, q, r}) << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long 
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
 
#define y1 what

using namespace std;
 
const int N = (int) 4e5 + 10;
const int M = (int) 1e6 + 10;
const ll LINF = (ll) 2e18;
const int INF = (int) 1e9 + 7;
const double EPS = (double) 1e-9;
const double PI =  3.14159265359;

int n;
vector<int> v[N];
int sz[N];

int dfs(int x, int p = -1) {
    int ans = 0;
    for (auto it : v[x]) {
        if (it != p) {
            ans ^= dfs(it, x) + 1;
        }
    }
    return ans;
}

int main() {
    #define fn "euler"
    #ifdef witch                                                            
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
        //freopen(fn".in", "r", stdin);
        //freopen(fn".out", "w", stdout);
    #endif      
    cin >> n;
    for (int i = 1, x, y; i < n; i++) {
        cin >> x >> y;
        v[x].pb(y);
        v[y].pb(x);
    }
    if (dfs(1)) cout << "Alice";
    else cout << "Bob";
    return 0;
}

Measured memory_bytes: 17408
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

a,b = i2()
cnt = 0
for i in range(a,b+1):
	memo = str(i)
	if memo[0] == memo[4] and memo[1] == memo[3]:
		cnt += 1
print(cnt)

Measured memory_bytes: 9100
import collections 

N = int(input())
l_a  = list(map(int,input().split()))

c = collections.Counter(l_a)

t = 0
for i in c.values():
  t = t + i*(i-1)//2

###
for k in range(1,N+1):
  n = c[l_a[k-1]]
  print(t-(n-1))

Measured memory_bytes: 87756
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/

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

// #define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 2e9 + 7;
const int MAX_N = 5e5 + 5;
int dx[] = { -1LL,0,1LL,0 }, dy[] = { 0,1LL,0,-1LL };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1LL; while (b > 0) { if (b & 1LL) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1LL] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) { a[i] = 1LL; }for (int i = 2; i < n + 1LL; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

typedef pair<int, pair<int, int>> edge;

class UnionFind {
private:
	vector<int> par;
public:
	UnionFind(int N) { par = vector<int>(N, -1LL); }
	int find(int x);
	ll size(int x);
	void unite(int x, int y);
	bool same(int x, int y);
};



class Kruskal {
private:
	UnionFind *uf;
	vector<edge> e;
public:
	vector<edge> mst;
	Kruskal(int N) { uf = new UnionFind(N); }
	void add(int x, int y, ll z);
	void run();
};



//----UnionFind-------------------------------
int UnionFind::find(int x) {
	if (par[x] < 0) return x;
	else return par[x] = find(par[x]);
}

ll UnionFind::size(int x) {
	return -par[find(x)];
}

void UnionFind::unite(int x, int y) {
	x = find(x);
	y = find(y);

	//大きい方に小さい方をくっ付ける
	if (size(x) < size(y)) swap(x, y);
	par[x] += par[y];
	par[y] = x;
}

bool UnionFind::same(int x, int y) {
	x = find(x);
	y = find(y);
	return x == y;
}



//----Kruskal-------------------------------
void Kruskal::add(int x, int y, ll z) {
	//x < y
	if (x > y) swap(x, y);
	e.push_back({ z,{x,y} });
}

void Kruskal::run() {
	sort(e.begin(), e.end());
	e.erase(unique(e.begin(), e.end()), e.end());
	for (auto x : e) {
		if (uf->same(x.second.first, x.second.second)) {
			continue;
		}
		else {
			mst.push_back(x);
			uf->unite(x.second.first, x.second.second);
		}
	}
}

signed main() {
	int n;cin >> n;
	int even = 0;
	REP (i,n) if (in()%2) even++;
	if (even%2) cout << "NO" << endl;
	else cout << "YES" << endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
	ll cost;
};
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RES(a, n) (a).resize(n)
#define VLCIN(a, n) REP(i,n){cin >> a[i];}
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = (ll)pow(10,7);
/****** define constant end ********/
/****** define variable start ******/
ll x, k, d;
/******* define variable end *******/
int solve() {
	cin >> x >> k >> d;
	ll count = k;
	if(x > 0){
		count -= x / d;
		if (count <= 0){
			cout << x - k * d << endl;
			return 0;
		}
		if(count % 2 == 0){
			cout << x - x / d * d << endl;
			return 0;
		}else{
			cout << abs(x - x / d * d - d) << endl;
			return 0;
		}
	}else if(x == 0) {
		if(k % 2 == 0){
			cout << 0 << endl;
		}else{
			cout << d << endl;
		}
	}else{
		count -= abs(x) / d;
		if(count <= 0){
			cout << abs(x) - k * d << endl;
			return 0;
		}
		if(count % 2 == 0){
			cout << abs(abs(x) - abs(x) / d * d) << endl;
		}else{
			cout << abs(abs(x) - abs(x) / d * d - d) << endl;
			return 0;
		}
	}
	return 0;
}
int main() {
	// clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 3652
a = (1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51)
k = int(input())
print(a[k-1])

Measured memory_bytes: 3060
x1,y1,x2,y2 =map(int,input().split())
x3 = x2-(y2-y1)
y3 = y2+(x2-x1)
x4 = x1-(y2-y1)
y4 = y1+(x2-x1)
print(x3,y3,x4,y4)

Measured memory_bytes: 9144
from collections import deque
dd0 = ((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0))
dd1 = ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0))

def solve(S, p, q):
    INF = 10**9
    L = [[0]*M for i in range(N)]
    D = [[INF]*M for i in range(N)]
    que = deque()
    for i, (x, y) in enumerate(S):
        L[y][x] = 1
        D[y][x] = 0
        que.append((x, y))
    L[q][p] = 2
    D[q][p] = 0
    que.append((p, q))
    while que:
        x, y = que.popleft()
        l = L[y][x]
        d0 = D[y][x] + 1
        for dx, dy in (dd1 if y % 2 else dd0):
            nx = x + dx; ny = y + dy
            if not 0 <= nx < M or not 0 <= ny < N or D[ny][nx] < d0:
                continue
            d = D[ny][nx]
            if d == INF:
                D[ny][nx] = d0
                que.append((nx, ny))
            L[ny][nx] |= l
    res = 0
    for i in range(N):
        for j in range(M):
            if L[i][j] == 2:
                res += 1
    return res

while 1:
    M, N = map(int, input().split())
    if M == N == 0:
        break
    s = int(input())
    S = []
    for i in range(s):
        x, y = map(int, input().split())
        S.append((x-1, y-1))
    t = int(input())
    ans = 0
    for i in range(t):
        p, q = map(int, input().split())
        ans = max(ans, solve(S, p-1, q-1))
    print(ans)


Measured memory_bytes: 6052
S = gets.chomp
=begin
実装するアルゴリズムに関する説明
入力された文字列 S の文字数を求め(n文字目)と(文字数-n+1文字目)を比較し、
異なってる文字数を算出する
=end

num=0
count =0

while num < S.length/2
    if S[num] != S[S.length-num-1]
        count+=1
    end
    num+=1
end

p count

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
#define INF 20000010

using namespace std;

long long cost[210][210];
long long d[210];
bool used[210];
long long V;
long long r[9];
long long  e[210][210];
vector<int> n;

void dijkstra(int s){
	fill (d,d+V,INF);
	fill (used,used+V,false);
	d[s] = 0;
	
	while(true){
		int v = -1;
		for(int u=0;u<V;u++){
			if(used[u]!=true && (v==-1 || d[u]<d[v])){
				v = u;
			}
		}
		if(v==-1){
			break;
		}
			
		used[v] = true;
			
	
		for(int u = 0; u<V;u++){
			d[u] = min(d[u],d[v]+cost[v][u]);
		}
	}
}
		
int main(){
	cin >> V;
	long long i,j,m,k,a,b,ans,sna;
	cin >> m >> k;
	for(i=0;i<V;i++){
		for(j=0;j<V;j++){
			cost[i][j] = INF;
		}
	}
	
	for(i=0;i<9;i++){
		r[i] = 2000;
	}
	
	for(i=0;i<k;i++){
		cin >> r[i];
		r[i]--;
	}
	
	for(i=0;i<m;i++){
		cin >> a >> b;
		a--; b--;
		cin >> cost[a][b];
		cost[b][a] = cost[a][b];
	}
	
	for(i=0;i<k;i++){
		dijkstra(r[i]);
		for(j=0;j<k;j++){
			e[r[i]][r[j]] = d[r[j]];
		}
	}
	
	sort(r,r+k);
	for(i=0;i<k;i++){
		n.push_back(r[i]);
	}
	
	ans = 0;
	for(i=0;i<k-1;i++){
		ans += e[n[i+1]][n[i]];
	}

	sna = 0;
	
	while(next_permutation(n.begin(),n.end())){
		for(i=0;i<k-1;i++){
			sna += e[n[i+1]][n[i]];
		}
		ans = min(ans,sna);
		sna = 0;
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 640