akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
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++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
typedef priority_queue<string> priquest;
typedef priority_queue<string,vector<string>,greater<string>> rpriquest;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

const ll big=1000000007;
ll exp(ll x,ll y){
    if(y==0)return 1;
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x)%big;
    ll t=exp(x,y/2);
    return (t*t)%big;
}


int main(){
    int n,k;cin >> n >> k;
    vector<ll> memo(k+1,0);
    for(int g=k;g>=1;g--){
        ll s=k/g;
        memo[g]=exp(s,n);
        for(int gg=2*g;gg<=k;gg+=g){
            memo[g]-=memo[gg];
            memo[g]%=big;
        }
    }
    ll ans=0;
    rep(i,k){
        ans+=memo[i+1]*(i+1);
        ans%=big;
    }
    if(ans<0)ans+=big;
    printf("%lld\n",ans);
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC() ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);

const int N = 1e5 + 100;
int arr[N];
int dp[N];
int n, k;

ll f(int id){
    if(id >= n) return (1LL<<40);
    if(id == n-1) return 0;
    if(dp[id] != -1) return dp[id];
    ll ret = LLONG_MAX;
    for(int i = 1; i <= k; i++) ret = min(ret, f(id+i) + abs(arr[id+i] - arr[id]));
    return dp[id] = ret;
}

int main()
{
    int i = 0, j = 0, cs = 0, in;
    cin>>n>>k;
    for(i = 0; i < n; i++) cin>>arr[i];
    mem(dp,-1);
    cout << f(0) << endl;
    return 0;
}


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

int main(){
    int H,W;
    while(1){
        cin >> H  >> W;
        if ( H==0 && W==0) break;
        
        for ( int i = 0; i < H; i++){
            for ( int j = 0; j < W;j++){
                cout << "#";
            }
            cout<<"\n";
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3084
import numpy as np

N = int(input())
X = list(map(int, input().split()))
X_arr = np.asarray(X)

point1 = min(X)
point2 = max(X)
Ans = 100000000000

for i in range(point1, point2+1):
    tmp = sum((X_arr - i) ** 2)
    if tmp < Ans:
        Ans = tmp

print(Ans)


Measured memory_bytes: 12508
object Main  {
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val a, b = sc.nextInt // 最初の数字を読み取る

    val result =
      if ((a * b) % 2 == 0) "Even"
      else "Odd"

    println(result)
  }
}

Measured memory_bytes: 25532
from fractions import gcd
def lcm(a,b):
    return (a*b)//gcd(a,b)
n,m = map(int,input().split())
a = list(map(int,input().split()))
ans = 1
for i in a:
    ans = lcm(ans,i)
for i in a:
    if (ans//i) % 2 == 0:
        print(0)
        exit()
print(((m//(ans//2))+1)//2)

Measured memory_bytes: 89580
n=int(input())
g=[[] for i in range(n)]
for _ in range(n-1):
  u,v,c=map(int,input().split())
  g[u-1].append((v-1,c))
  g[v-1].append((u-1,c))
Q,k=map(int,input().split())
d=[-1]*n
d[k-1]=0
q=[k-1]
while q:
  t=q.pop()
  for x,cost in g[t]:
    if d[x]==-1:
      d[x]=d[t]+cost
      q.append(x)
for _ in range(Q):
  x,y=map(int,input().split())
  print(d[x-1]+d[y-1])

Measured memory_bytes: 43312
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		double a = scan.nextDouble();
		double b = scan.nextDouble();
		double angle = Math.toRadians(scan.nextDouble());
		
		double height = b * Math.sin(angle);
		double area = a * height / 2;
		double c = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(angle));
		
		System.out.printf("%f\n%f\n%f\n", area, a + b + c, height);
	}
}

Measured memory_bytes: 18920
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    int x,y,z;cin>>x>>y>>z;
    int ans = x/(y+z);
    if(x%(y+z)<z)ans--;
    cout<<ans<<endl; return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}

ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}

int main(){
    
    ll a,b;
    cin >> a >> b;
    cout << a*b << endl;
    return 0;
}
 
 



Measured memory_bytes: 3596
import fs = require('fs')
const input = fs.readFileSync('/dev/stdin', 'utf8').split('\n')

const N = +input[0]
const W = input[1].split(' ').map(Number)

let diffMin = Number.MAX_SAFE_INTEGER

for (let T = 1; T < N; T++) {
    // const t = T - 1
    let S1 = 0
    let S2 = 0

    for (let w = 0; w < T; w++) {
        S1 += W[w]
    }
    for (let w = T; w < N; w++) {
        S2 += W[w]
    }
    const diffAbs = Math.abs(S1 - S2)
    if (diffMin > diffAbs) {
        diffMin = diffAbs
    }
}

console.log(diffMin)

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1005;
const int M = 7005;

int a[N], b[N], c[N], d[N], e[N], f[N];
vector <int> vx, vy;
int dx[] = {0, 0, -1, 1}, dy[] = {-1, 1, 0, 0};
bool vis[M][M], ma[M][M];

int get_x(int val){
    return lower_bound(vx.begin(), vx.end(), val) - vx.begin();
}

int get_y(int val){
    return lower_bound(vy.begin(), vy.end(), val) - vy.begin();
}

int main(){
    int n, m; scanf("%d%d", &n, &m);
    vx.push_back(-1.1e9), vx.push_back(0);
    vy.push_back(-1.1e9), vy.push_back(0);
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i] >> c[i];
        vx.push_back(a[i]), vx.push_back(b[i]);
        vy.push_back(c[i]);
    }

    for(int i = 0; i < m; i++){
        cin >> d[i] >> e[i] >> f[i];
        vy.push_back(e[i]), vy.push_back(f[i]);
        vx.push_back(d[i]);
    }

    sort(vx.begin(), vx.end()), vx.erase(unique(vx.begin(), vx.end()), vx.end());

    sort(vy.begin(), vy.end()), vy.erase(unique(vy.begin(), vy.end()), vy.end());


    for(int i = 0; i < n; i++){
        a[i] = get_x(a[i]), b[i] = get_x(b[i]), c[i] = get_y(c[i]);
        for(int j = a[i]*2 - 1; j < 2 * b[i]; j++)
            ma[j][2*c[i] - 1] = true;
    }

    for(int i = 0; i < m; i++){
        d[i] = get_x(d[i]), e[i] = get_y(e[i]), f[i] = get_y(f[i]);
        for(int j = e[i]*2-1; j < f[i]*2; j++)
            ma[2*d[i]-1][j] = true;
    }

    int sx = get_x(0)*2 - 1, sy = get_y(0)*2 - 1;

    queue<pair<int, int>> qu;
    qu.push({sx, sy}), vis[sx][sy] = true;
    ll ans = 0;
    bool flag = false;
    while(!qu.empty()){
        int ux = qu.front().first, uy = qu.front().second; qu.pop();
        if(ux == M-1 || uy == M-1 || ux == 0 || uy == 0){
            flag = true;
            break;
        }
        if(ux % 2 == 0 && uy % 2 == 0){
            int x = ux / 2, y = uy / 2;
            ans += 1ll * (vx[x + 1] - vx[x]) * (vy[y + 1] - vy[y]);
        }
        for(int i = 0; i < 4; i++){
            int xx = ux + dx[i], yy = uy + dy[i];
            if(xx >= M || xx < 0 || yy >= M || yy < 0 || ma[xx][yy] || vis[xx][yy]) continue;
            qu.push({xx, yy});
            vis[xx][yy] = true;
        }
    }
    if(flag) printf("INF\n");
    else printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 89012
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int H,W;
    int i,j;
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0&&W==0){
            break;
        }
        for(i=1;i<=H;i++){
            if(i!=1){
                printf("\n");
            }for(j=1;j<=W;j++){
                if(i%2!=0&&j%2!=0){
                    printf("#");
                }else if(i%2==0&&j%2==0){
                    printf("#");
                }
                else{
                    printf(".");
                }
            }
        }printf("\n");
        printf("\n");
    }
    
    return 0;
}

Measured memory_bytes: 572
//Hey u r too far away to know this
//CHIRAGA196
#include <bits/stdc++.h>
using namespace std;
#define     ff                  first
#define     pb                  push_back
#define     ss                  second
#define     IOS                 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     all(v)              v.begin(), v.end()
#define     allr(v)             v.rbegin(), v.rend()
#define       int               long long
#define       endl             '\n'
const   int N = 1e6+5, Mod = 1e9 + 7;
int32_t main(){
        IOS;
 
        int a, b, c, d; cin >> a >> b >> c >> d;
        cout << max({a*c, a*d, b*c, b*d}) << endl;
        return 0;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#define INF 0x3f3f3f3f;

using namespace std;

int main() {
    int n,m,flag=1,i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&m);
        if(m%2==0){
            if(m%3==0||m%5==0)
                continue;
            else
                flag=0;
        }
    }
    if(flag){
        printf("APPROVED\n");
    }
    else
        printf("DENIED\n");
}


Measured memory_bytes: 256
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, A, B = lr()
if A + B - 1 > N:
    print(-1); exit()
if A * B < N:
    print(-1); exit()

if B == 1:
    q, r = A, 0
else:
    q, r = divmod(N-A, B-1)

if q == A:
    size = [B] * q
else:
    size = [B] * q + [r+1] + [1] * (A-q-1)

end = 1
answer = []
for s in size:
    start = end + s - 1
    answer.extend(list(range(start, end-1, -1)))
    end = start + 1

print(*answer)


Measured memory_bytes: 70536
# ABC157d


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと

    class UnionFind:
        def __init__(self, n):
            self.tree = [i for i in range(n)]
            self.member = [1]*n

        def root(self, x):
            if(self.tree[x] == x):
                return x
            self.tree[x] = self.root(self.tree[x])
            return self.tree[x]  # 経路圧縮

        def same(self, x, y):  # xとyが同じ木に属するか
            return self.root(x) == self.root(y)

        def unite(self, x, y):
            x = self.root(x)
            y = self.root(y)
            if(x == y):
                return
            new = self.member[x]+self.member[y]
            self.member[x] = new
            self.member[y] = new
            self.tree[x] = y

    n, m, k = map(int, input().split())
    tree = UnionFind(n)

    friend = [set() for i in range(n)]
    for _ in range(m):
        a, b = map(int, input().split())
        friend[a - 1].add(b - 1)
        friend[b - 1].add(a - 1)
        tree.unite(a-1, b-1)
    block = [set() for i in range(n)]
    for _ in range(k):
        c, e = map(int, input().split())
        if tree.same(c - 1, e - 1):
            block[c - 1].add(e - 1)
            block[e - 1].add(c - 1)
    ans = []
    for i in range(n):
        #print(i, tree.member[tree.root(i)], len(friend[i]), len(block[i]))
        ans.append(tree.member[tree.root(i)]-len(friend[i])-len(block[i])-1)
    print(*ans)


if __name__ == '__main__':
    main()


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

int N;
int main() {
  cin >> N;
  for (int i=0; i<N; i++) {
    int k, p;
    cin >> k >> p;
    int x = k % p;
    if (x == 0) x = p;
    cout << x << "\n";
  }
  return 0;
}

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final long D = 1000000007;
		long result = 1;

		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int M = in.nextInt();

		// 壊れ段 スタート直前とゴール直後も登録しておく
		int[] a = new int[M + 2];
		a[0] = -1;
		a[M + 1] = N + 1;

		long[] ptrns = new long[M + 2];
		for ( int i = 1; i <= M; i++ ) {
			a[i] = in.nextInt();
			ptrns[i] = getStepPatterns(a[i] - a[i - 1] - 1);
		}
		ptrns[M + 1] = getStepPatterns(a[M + 1] - a[M] - 1);

		for ( int i = 1; i <= M + 1; i++ ) {
			result = (result * (ptrns[i]) % D) % D;
		}

		System.out.println(result);
		in.close();
	}

	// n段のステップパターンを計算する（nにはスタートとゴールの段を含む）
	private static long getStepPatterns(int ｎ) {
		long D = 1000000007;
		long ptrn = 0;

		if ( ｎ <= 0 ) ptrn = 0;
		else if ( ｎ == 1 || ｎ == 2 ) ptrn = 1;
		else
		// (p+2)段目のパターン = (p+1)段目のパターン + p段目のパターン
		if ( 3 <= ｎ ) {
			long p0, p1, p2;
			p0 = p1 = p2 = 1;

			for ( int i = 2; i < ｎ; i++ ) {
				p2 = (p1 + p0) % D;
				p0 = p1;
				p1 = p2;
			}
			ptrn = p2;
		}
		return ptrn;
	}
}


Measured memory_bytes: 45848
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

vector<int> eval(vector<ii> &left, vector<int> &add) {
	vector<int> ret;
	sort(left.begin(),left.end());
	for (int i=0; i<left.size(); i++)
		ret.push_back(left[i].second);
	return ret;
}

bool ok(string &s) {
	int cur=0;
	for (char ch : s) {
		if(ch=='(') cur++;
		else cur--;
		if(cur<0) return false;
	}
	return cur==0;
}

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N; cin>>N;
	vector<string> S(N);
	for (int i=0; i<N; i++)
		cin>>S[i];
	vector<ii> left, right;
	vector<int> middle;
	vector<int> add(N,0);
	for (int i=0; i<N; i++) {
		int rt=0, lt=0;
		for (char ch : S[i])
			if(ch=='(') add[i]++;
			else add[i]--;
		int cur=0;
		for (char ch : S[i]) {
			if(ch==')') cur++;
			else cur--;
			rt=max(rt,cur);
		}
		reverse(S[i].begin(),S[i].end());
		cur=0;
		for (char ch : S[i]) {
			if(ch=='(') cur++;
			else cur--;
			lt=max(lt,cur);
		}
		reverse(S[i].begin(),S[i].end());
		if(add[i]>0) {
			left.push_back({rt,i});
		} else if(add[i]==0) {
			middle.push_back(i);
		} else {
			right.push_back({lt,i});
		}
	}
	vector<int> lidx=eval(left,add);
	vector<int> ridx=eval(right,add);
	reverse(ridx.begin(),ridx.end());
	string ret;
	for (auto x : lidx)
		ret+=S[x];
	for (auto x : middle)
		ret+=S[x];
	for (auto x : ridx)
		ret+=S[x];
	cout<<(ok(ret)?"Yes":"No")<<"\n";
	return 0;
}

Measured memory_bytes: 53060
#include<stdio.h>
int gcd(int a,int b){
    if(a<b){
        int t=b;
        b=a;
        a=t;
    }
    int c=1;
    while(c!=0){
        c=a%b;
        a=b;
        b=c;
    }
    return a;
}
int main(void){
    int x,y,z;
    scanf("%d %d",&x,&y);
    if(x==y)
        printf("%d\n",x+1);
    else if(x%2||y%2)
        printf("%d\n",x+y);
    else
        printf("%d\n",(x+y-gcd(x,y)+1));
	return 0;		
}


Measured memory_bytes: 2148
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define vsort(v) sort(v.begin(),v.end())
ll labs(ll a){return (a>0)?a:(0-a);}

int main(){
  ll i,j,X,N,mid,ans=0;
  cin>>N>>X;
  vector<ll> paty(N+1,1),level(N+1,1);
  rep1(i,N+1){
    paty[i]=paty[i-1]*2+1;
    level[i]=level[i-1]*2+3;
  }
  while(1){
    mid=(1+level[N])/2;
    if(X==mid){
      if(N==0){ans+=1;}
      else{ans+=paty[N-1]+1;}
      break;
    }
    if(X==1)break;
    if(X==level[N]){
      ans+=paty[N];
      break;
    }
    N--;
    if(level[N]+2<X){
      ans+=paty[N]+1;
      X-=(level[N]+2);
    }else{X--;}
  }
  cout<<ans<<endl;
  return 0;
}

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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	ll ans=0;
	cin>>n;
	map<ii,ll> mp;
	for(int i=1;i<=n;++i){
		int ld = i%10, aux = i, fd;
		while(aux){
			fd=aux%10;
			aux/=10;
		}
		mp[{fd,ld}]++;
	}
	for(int i=1;i<=9;++i){
		for(int j=1;j<=9;++j){
			ans+=(mp[{i,j}]*mp[{j,i}]);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<cmath>

int const MAXN = 60;

int N, K, x[MAXN], y[MAXN], c[MAXN];


bool can_do(double X, double Y, double T) {
  int count = 0;
  for(int i = 0; i < N; ++i) {
    double xx = X - x[i], yy = Y - y[i];
    if((xx*xx+yy*yy)*c[i]*c[i]/(T*T) <= 1+1e-12) ++count;
    if(count >= K) return true;
  }
  return false;
}

double calc_intersect(double x, double y, double r1, double r2,
  double& X, double& Y, double& dx, double&dy) {
  double l2 = x*x + y*y;
  double a2 = (l2 + r1*r1-r2*r2)*0.5;
  double det = l2*r1*r1 - a2*a2;
  if(det < 0) return det;
  double t2 = std::sqrt(det);
  X = a2*x/l2; Y = a2*y/l2;
  dx = y*t2/l2; dy = -x*t2/l2;
  return det;
}

bool can_do(double T) {
  for(int i = 0; i < N; ++i) {
    if(can_do(x[i], y[i], T)) return true;
  }
  for(int i = 0; i < N-1; ++i) for(int j = i+1; j < N; ++j) {
    double X, Y, dx, dy;
    if(calc_intersect(x[j]-x[i], y[j]-y[i], T/c[i], T/c[j], X, Y, dx, dy)< 0e0) continue;
    X += x[i];
    Y += y[i];
    if(can_do(X+dx, Y+dy, T)) return true;
    if(can_do(X-dx, Y-dy, T)) return true;
  }
  return false;
}

int main() {
  std::cin >> N >> K;
  for(int i = 0; i < N; ++i) std::cin >> x[i] >> y[i] >> c[i];
  double tL = 0, tH = 150*1000; // > 1000*sqrt(2)*100
  while(tH - tL > 1e-10) {
    double tM = (tL + tH)*0.5;
    if(can_do(tM)) tH = tM; else tL = tM;
  }
  std::cout << std::setprecision(10) << std::fixed << (tL+tH)*0.5 << std::endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	  public static void main(String args[]){
      	Scanner scan = new Scanner(System.in);
            
        int n = scan.nextInt();
        int cnt = 0;
        
        if( n % 2 == 0 ){
         cnt = (n / 2) - 1; 
        }
        
        else{
          cnt = (int)(n / 2);
        }
            
        System.out.println(cnt);
	  }
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

void out(){cout << "\n";}
template<class T,class... Args>
void out(const T &x,const Args &... args){
	cout << x << " ";
	out(args...);
}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

ll dig(string s){
	ll ret=0;
	for(auto&& e:s) ret+=e-'0';
	return ret;
}

int main()
{
	string s;
	vll ans;
	while(1){
		cin >> s;
		if(s=="0") break;
		ans.pb(dig(s));
	}
	for(auto&& e:ans) cout << e << endl;
	return 0;
}


Measured memory_bytes: 3168
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
using namespace std;
using ll = long long;

typedef pair <int, int> pii;

int main()
{

	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	string s, t;
	ll x, n;
	cin >> s;
	for (int i = 0; i < s.length(); i++)
	{
		if (a==0&&s[i]=='C')
		{
			a++;
		}
		if (a==1&&s[i]=='F')
		{
			cout <<"Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	//cout << ans << endl;
	//cout <<  << endl;

	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}

//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

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


int main() {

    ll x, a, b;
    cin >> x >> a >> b;
    if (a >= b) cout << "delicious" << endl;
    else if (b - a <= x) cout << "safe" << endl;
    else cout << "dangerous" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#define RI int
#define CI const int&
using namespace std;
const int N=6005;
int n,mod,f[N][N<<1],ans;
inline void inc(int& x,CI y)
{
	if ((x+=y)>=mod) x-=mod;
}
int main()
{
	RI i,j,k,t; scanf("%d%d",&n,&mod); n*=3; f[0][n]=1;
	for (i=0;i<n;++i) for (j=-i;j<=i;++j) if (f[i][n+j])
	inc(f[i+1][n+j-1],f[i][n+j]),
	inc(f[i+2][n+j+1],1LL*f[i][n+j]*(i+1)%mod),
	inc(f[i+3][n+j],1LL*f[i][n+j]*(i+2)%mod*(i+1)%mod);
	for (i=-n;i<=0;++i) inc(ans,f[n][n+i]); return printf("%d",ans),0;
}

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL MOD = 1e9+7;

int main() {
    LL a, b, c, d;
    cin >> a >> b >> c >> d;
    LL r = max({a*c, a*d, b*c, b*d});
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n, m, a;
   cin >> n >> m;
   vector<int> ctr_trans(n + 1, 0);
   vector<bool> is_hole(n + 1, false);
   for (int i = 0; i < m; i++)
   {
      cin >> a;
      is_hole[a] = true;
   }
   ctr_trans[0] = 1;
   ctr_trans[1] = (int)(!is_hole[1]);
   for (int i = 2; i <= n; i++)
   {
      if (is_hole[i])
         continue;
      ctr_trans[i] = (ctr_trans[i - 1] + ctr_trans[i - 2]) % INF;
   }
   cout << ctr_trans[n] << endl;
   return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<vector>
#include<algorithm>
#include<string.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << x << endl;
using namespace std;

int main(){
    int c1, c2, c3;
    bool deck[11];
    while(cin >> c1 >> c2 >> c3){
        int count = 0;
        rep(i,11){
            if(i + c1 + c2 <= 20)
                deck[i] = true;
            else
                deck[i] = false;
        }
        deck[0] = false;
        deck[c1] = false;
        deck[c2] = false;
        deck[c3] = false;
        rep(i,11)
            if(deck[i] == true) count++;
        if(count / 7.0 >= 0.5)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll nchoose2 ( ll a )
{
  return a*(a-1)/2;
}
int main()
{
    ll n;
    cin>>n;
    ll* a = new ll[n+1]();
    ll* b = new ll[n]();
    for(int i=0;i<n;i++)
    {
        cin>>b[i];
        a[ b[i] ]++;
    }
    ll totalans =0;
    for(int i=0;i<=n;i++)
    {
        totalans = totalans + nchoose2(a[i]);
    }
    for(int i=0;i<n;i++)
    {
         if( a[b[i] ] < 2 )
             cout<<totalans<<endl;
         else
         {
             ll temp = totalans - nchoose2(a[b[i]]) + nchoose2(a[b[i]] -1 );
             cout<<temp<<endl;
         }
    }
}

Measured memory_bytes: 6724
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    K,S = MI()
    ans = 0
    for i in range(K+1):
        for j in range(K+1):
            k = S - i - j
            if 0 <= k <= K:
                ans += 1
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>

using namespace std;


int neutral = 0;
int incr = 1;
int decr = -1;

int main() {

    int N;
    cin >> N;
    vector<long> as;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        as.push_back(a);
    }

    int state = neutral;

    int count = 1;

    int curr = as[0];

    for (int i = 1; i < N; i++) {

        if ((as[i] - curr) > 0) {

            if (state == neutral) {
                state = incr;
            } else if (state == incr) {
            } else {
                count += 1;
                state = neutral;
            }
        } else if ((as[i] - curr) == 0) {
        } else {

            if (state == neutral) {
                state = decr;
            } else if (state == incr) {
                count += 1;
                state = neutral;
            } else {
            }

        }

        curr = as[i];
    }

    cout << count << "\n";

    return 0;

}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define ms(a,b)         memset(a, b, sizeof(a))
#define pb(a)           push_back(a)
#define db              double
#define ll              long long
#define loop(i,e,n)      for(int i=e;i<=n;i++)
#define TEST_CASE(t)    for(int z=1;z<=t;z++)
ll PowFun(ll base, ll power){ll ans = 1;for(int i = 1; i <= power; i++){ans *= base;}return ans;}
double phi = acos(-1);
using namespace std;



    int main()
    {
        int n; cin>>n;
        int a = 0, b = 0, x = 0, y = 0;
        while(n--)
        {
            string str; cin>>str;
            if(str == "AC") x++;
                if(str == "WA") y++;
                if(str == "TLE") a++;
                if(str == "RE") b++;
        }

        cout<<"AC x "<<x<<endl;
        cout<<"WA x "<<y<<endl;
        cout<<"TLE x "<<a<<endl;
        cout<<"RE x "<<b<<endl;
    }



Measured memory_bytes: 3628
#include <iostream>

int main()
{
	int h, w;
	while (true)
	{
		std::cin >> h >> w;
		if (h == 0 && w == 0)break;
		for (int i = 0; i < h; ++i)
		{
			for (int j = 0; j < w; ++j)
			{
				std::cout << "#";
			}
			std::cout << std::endl;
		}
		std::cout << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<cstdio>
#include<cstring>

const int N=101000;

bool s[N];
int n,m;

int main()
{
	scanf("%d%d",&n,&m);
	for(int u,v;m--;)
		scanf("%d%d",&u,&v),s[u]^=1,s[v]^=1;
	bool ans=0;
	for(int i=1;i<=n;i++)
		ans|=s[i];
	printf("%s\n",ans?"NO":"YES");
	return 0;
}


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

using namespace std;

const int MOD = 1e9+7;

void solve()
{
	int N;
	cin >> N;
	vector<vector<int>> ok(N, vector<int>(N));
	for (int i = 0; i < N; i++)
		for (int j = 0; j < N; j++)
	{
		cin >> ok[i][j];
	}
	vector<int> dp(1<<N);
	dp[0] = 1;
	for (int i = 0; i < N; i++)
	{
		vector<int> nx(1<<N);
		for (int bit = 0; bit < 1<<N; bit++)
		{
			if (!dp[bit]) continue;
			for (int j = 0; j < N; j++)
			{
				if (bit>>j&1 || !ok[i][j]) continue;
				nx[bit|1<<j] += dp[bit];
				nx[bit|1<<j] %= MOD;
			}
		}
		swap(dp, nx);
	}
	cout << dp.back() << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 18680
#include <cstdio>
#include <algorithm>
#include <vector>
#include <iostream>
#include <cstring>
#include <string>
using namespace std;

#pragma warning(disable:4996)

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	vector<int>ans;
	ans.push_back(abs(a - b) + abs(c - b));
	ans.push_back(abs(c - a) + abs(b - c));
	ans.push_back(abs(a - b) + abs(c - a));
	ans.push_back(abs(c - b) + abs(c - a));
	ans.push_back(abs(a - c) + abs(b - a));
	ans.push_back(abs(b - c) + abs(a - b));
	sort(ans.begin(), ans.end());
	cout << ans[0];

	
	
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int N, D, X; cin >> N >> D >> X;
    vector<int> A(N);
    for(int &a:A) cin >> a;
    
    int ans = 0;
    for(int i=1; i<=D; i++){
        for(int j=0; j<N; j++){
            if(i%A[j] == 1) ans++;
            if(A[j] == 1) ans++;
        }
    }
    
    cout << ans+X << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll INM = 114514;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll a, b;
	cin >> a >> b;
	dump(max({a + b, a - b, a * b}));
	return 0;
}


Measured memory_bytes: 256
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s, t;
	cin >> s >> t;

	if(t.length() > s.length()) {
		cout << "UNRESTORABLE";
		exit(0);
	}

	string k = s;
	for(int i = 0; i < k.length(); i++) {
		if(k[i] == '?') k[i] = 'a';
	}
	
	int pos = -1;
	for(int i = k.length() - 1; i >= 0; i--) {
		if(i + t.length() - 1 >= k.length()) continue;
		bool f = true;
		for(int j = i; j < i + t.length(); j++) {
			if( k[j] != t[j - i] ) {
				f = false;
				break;
			}
		}
		if(f) {
			pos = i;
			break;
		}
	}

	if(pos != -1) {
		cout << k;
		exit(0);
	}

	for(int i = s.length() - 1; i >= 0; i--) {
		if(i + t.length() - 1 >= s.length()) continue;
		bool f = true;
		for(int j = i; j < i + t.length(); j++) {
			if(s[j] != '?' && s[j] != t[j - i]) {
				f = false;
				break;
			}
		}
		if(f) {
			pos = i;
			break;
		}
	}

	if(pos != -1) {
		for(int i = pos; i < pos + t.length(); i++) {
			s[i] = t[i - pos];
		}
		for(int i = 0; i < s.length(); i++) {
			if(s[i] == '?') s[i] = 'a';
		}
		cout << s;
		exit(0);
	}

	cout << "UNRESTORABLE"; 


	return 0;
}


Measured memory_bytes: 256
#include <iostream>

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

using namespace std;

int main(){
	long long int n, pre, next, ans, a[200005];
	
	cin >> n;
	ans = 0;
	cin >> pre;
	if (pre!=0){
		//cout << "pre!=0" << endl;
		cout << -1 << endl;
		return 0;
	}
	REP(i,n-1){
		cin >> next;
		if (next-pre>1){
			//printf("i=%d\n", i);
			cout << -1 << endl;
			return 0;
		}else if(pre>=next){
			ans += pre;
		}
		pre = next;
	}
	ans += pre;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vll vector<long long>
#define INF 1e18
 
ll modInverse(ll a, ll m);
ll gcd(ll a, ll b);
ll power(ll x, unsigned ll y, unsigned ll m);
ll logint(ll x,ll y);
 
 
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b%a, a);
}
 
ll power(ll x, unsigned ll y, unsigned ll m)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m;
 
    return (y%2 == 0)? p : (x * p) % m;
}
 
ll modInverse(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
 
    if (m == 1)
      return 0;
 
    while (a > 1)
    {
        // q is quotient
        ll q = a / m;
        ll t = m;
 
        // m is remainder now, process same as
        // Euclid's algo
        m = a % m, a = t;
        t = y;
 
        // Update y and x
        y = x - q * y;
        x = t;
    }
 
    // Make x positive
    if (x < 0)
       x += m0;
 
    return x;
}
 
void pairsort(ll a[],ll b[], ll n)
{
    pair<ll, ll> pairt[n];
 
    // Storing the respective array
    // elements in pairs.
    for (ll i = 0; i < n; i++)
    {
        pairt[i].first = a[i];
        pairt[i].second = b[i];
    }
 
    // Sorting the pair array.
    sort(pairt, pairt + n);
 
    // Modifying original arrays
    for (ll i = 0; i < n; i++)
    {
        a[i] = pairt[i].first;
        b[i] = pairt[i].second;
    }
}
 
ll logint(ll x,ll y)
{
    ll ans=0;
    ll a=1;
    for(ll i=0;i<x;i++)
    {
        if(x<=a)
        {
            return ans;
        }
        ans++;
        a*=y;
    }
    return -1;
}
/*
ll v[500001], size[500001];
vector<ll>ve(0);
ll fin(ll x){
    //using path compression optimization
    if(x == v[x]){
        return x;
    }
    return v[x] = fin(v[x]);
}
void uni(ll x, ll y){
    x = fin(x);
    y = fin(y);
    if(x == y){
        return ;
    }
    //Using Union by size method, to reduce long chains
    if(size[x] < size[y]){
	size[x]+= size[y];
    	v[y] = x;}
    else{
	size[y]+=size[x];
	v[x]=y;
	}
}
*/
ll dp[200005][2];
int main()
{
   // ios::sync_with_stdio(0);
    //cin.tie(0);
    //cout.tie(0);
 
    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */
    ll a;
    cin>>a;
    ll dp[a];
    memset(dp, 0, sizeof(dp));
    ll ar[a];
    REP(i, 0, a){
        cin>>ar[i];
    }
    dp[1] = abs(ar[1]-ar[0]);
    REP(i, 2, a){
        dp[i] = min(dp[i-1]+abs(ar[i]-ar[i-1]), dp[i-2]+abs(ar[i]-ar[i-2]));
    }
    cout<<dp[a-1];

    }

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
using namespace std;
int main(){

    int n;
    int d[7]={600,800,1000,1200,1400,1600,0};
    while(cin>>n,n){
        int ans = 0;
        while(n--){
            int x,y,h,w;
            cin>>x>>y>>h>>w;
            x+=y+h;
            int a,b;
            for(a=0;a<6&&x>60+a*20;a++);

            if(w<=2)b=0;
            else for(b=1;b<6&&w>b*5;b++);
            ans+=d[max(a,b)];
        }
        cout<<ans<<endl;

    }
    return 0;
}

Measured memory_bytes: 1160
#ifndef ___Class_RangeTree
#define ___Class_RangeTree

// ------ Includes ------ //
#include <limits>
#include <vector>
#include <algorithm>

template<typename Type> class RangeTree {
private:
	int size_;
	std::vector<std::vector<Type> > dat;
	std::vector<std::vector<int> > vl;
	inline int query_(int a, int b, Type x, int k, int l, int r, int e) {
		// Find range [a, b) : value < x : Now k-th node and the range is [l, r) and e integers below x in the range
		if (r <= a || b <= l || e == 0) return 0;
		if (a <= l && r <= b) return e;
		int lc = query_(a, b, x, k << 1, l, (l + r) >> 1, vl[k][e - 1]);
		int rc = query_(a, b, x, k << 1 | 1, (l + r) >> 1, r, e - vl[k][e - 1]);
		return lc + rc;
	}
public:
	RangeTree() : size_(0), dat(std::vector<Type>()) {};
	template<class T>
	RangeTree(T begin_, T end_) {
		int n = (end_ - begin_);
		for (size_ = 1; size_ < n; size_ <<= 1);
		dat.resize(size_ << 1);
		vl.resize(size_);
		for (int i = 0; i < n; i++) dat[i + size_].push_back(*(begin_ + i));
		for (int i = size_ - 1; i > 0; i--) {
			dat[i].resize(dat[i << 1].size() + dat[i << 1 | 1].size());
			vl[i].resize(dat[i].size());
			int cl = 0;
			for (int j = 0; j < dat[i].size(); j++) {
				if (j - cl == dat[i << 1 | 1].size() || (cl != dat[i << 1].size() && dat[i << 1][cl] < dat[i << 1 | 1][j - cl])) dat[i][j] = dat[i << 1][cl++];
				else dat[i][j] = dat[i << 1 | 1][j - cl];
				vl[i][j] = cl;
			}
		}
	}
	inline int size() { return size_; }
	inline int query(int l, int r, Type x) {
		// Find range [a, b) : value < x
		int ptr = lower_bound(dat[1].begin(), dat[1].end(), x) - dat[1].begin();
		return query_(l, r, x, 1, 0, size_, ptr);
	}
};

#endif

#include <cstdio>
#include <vector>
#pragma warning(disable : 4996)
using namespace std;
int N, Q, xl, yl, xr, yr;
int main() {
	scanf("%d%d", &N, &Q);
	vector<pair<int, int> > p(N);
	for (int i = 0; i < N; i++) scanf("%d%d", &p[i].first, &p[i].second);
	sort(p.begin(), p.end());
	vector<int> z1(N), z2(N);
	for (int i = 0; i < N; i++) {
		z1[i] = p[i].first;
		z2[i] = p[i].second;
	}
	RangeTree<int> seg(z2.begin(), z2.end());
	while (Q--) {
		scanf("%d%d%d%d", &xl, &yl, &xr, &yr);
		int ptr1 = lower_bound(z1.begin(), z1.end(), xl) - z1.begin();
		int ptr2 = lower_bound(z1.begin(), z1.end(), xr + 1) - z1.begin();
		int res1 = seg.query(ptr1, ptr2, yl);
		int res2 = seg.query(ptr1, ptr2, yr + 1);
		printf("%d\n", res2 - res1);
	}
	return 0;
}

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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;
    int K;

    public void Do()
    {
        cin = new Scanner();
        int A = cin.nextInt();
        int B = cin.nextInt();
        int C = cin.nextInt();
        K = cin.nextInt();
        Console.WriteLine(dfs(0, A, B, C));
    }

    int dfs(int cur, int A, int B, int C)
    {
        if (cur == K)
        {
            return A + B + C;
        }
        int ret = 0;
        ret = Math.Max(dfs(cur + 1, A * 2, B, C), ret);
        ret = Math.Max(dfs(cur + 1, A, B * 2, C), ret);
        ret = Math.Max(dfs(cur + 1, A, B, C * 2), ret);
        return ret;
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K;cin>>K;string A[K+1];A[0]="0";
  for(int i=1;i<=K;i++){
    string S=A[i-1];
    int N=S.size()-1;
    while(N>0&&(S.at(N)=='9'||S.at(N-1)<S.at(N)))N--;
    if(N==0&&S.at(0)=='9')A[i]=to_string(stoi(S)+1);
    else{
      S.at(N)++;
      for(N++;N<S.size();N++)S.at(N)=max((char)(S.at(N-1)-1),'0');
      A[i]=S;
    }
  }
  cout<<A[K]<<endl;
}

Measured memory_bytes: 5760
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll max(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
double max(double a, double b) {

	if (a > b)return a;
	else return b;

}
//a??¨b?????§?????????

ll min(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
//a??¨b????°??????????

ll avd_i(ll a, ll b) {

	if (a > b)return a - b;
	else return b - a;

}
double avd_d(double a, double b) {

	double re;
	if (a > b)re = a - b;
	else re = b - a;
	return re;

}
//a??¨b???????????¶??????

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//p????´???°,a???b??????p??§?????£?????????

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//p????´???°,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

	}
	ll r;
	r = b%a;
	if (r == 0)return a;
	else return gcd(r, a);

}
//?????§??¬?´???°

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//????°???¬?????°

int main() {
	
	int H, W;

	while (1) {

		cin >> H >> W;

		if (H == 0 && W == 0)break;
		else {

			for (int i = 0; i < H; i++) {

				for (int j = 0; j < W; j++) {

					if (i % 2 == 0) {

						if (j % 2 == 0) {

							cout << "#";

						}
						else {

							cout << ".";

						}

					}
					else {

						if (j % 2 == 0) {

							cout << ".";

						}
						else {

							cout << "#";

						}

					}

				}
				cout << endl;

			}
			cout << endl;

		}

	}

	return 0;
}

Measured memory_bytes: 3096