akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

	public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			long n = sc.nextLong();
			long a = sc.nextLong();
			long b = sc.nextLong();
			
			long a1 = n/(a+b)*a;
			long a2;
			long c = n%(a+b);
			if(c<=a) {
				a2 =c;	
			}else {
				a2 =a;
			}
			
			if(a==0) {
				System.out.println(0);
			}else {
				System.out.println(a1+a2);
			}
			
			
		}

	}

Measured memory_bytes: 21972
#include<iostream>
#include<cstring>
using namespace std;
typedef long long ll;
const int N=2010;
int n,x,y,t[2100],a[2];
int dist[N][N],g[N][N];
int min(int a,int b,int c)
{
	return min(min(a,b),c);
}
int main()
{
	cin>>n>>x>>y;
	for(int i=1;i<n;i++)
		for(int j=i+1;j<=n;j++)
		{
		//	cout<<i<<' '<<j<<' '<<min(j-i,abs(j-y)+abs(x-i)+1,abs(i-x)+abs(j-y+)1)<<endl;
			t[min(j-i,abs(j-y)+abs(x-i)+1)]++;
		}
	for(int i=1;i<n;i++) cout<<t[i]<<endl;
	
	return 0;
}

Measured memory_bytes: 256
N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for i in range(Q)]

def calc_score(A):
  score = 0
  for a, b, c, d in abcd:
    if A[b-1] - A[a-1] == c:
      score += d
  return score

ans = 0
def dfs(A):
  global ans
  if len(A) == N:
    ans = max(ans, calc_score(A))
  else:
    last_a = A[-1]
    for a in range(last_a, M+1):
      dfs(A + [a])

dfs([1])
print(ans)

Measured memory_bytes: 9220
# -*- coding: utf-8 -*-


def main():
    """    i = a_i   """

    n = int(input())
    a = [int(input()) for _ in range(n)]

    cnt = 0
    i = 1
    while cnt <= n:
        i = a[i-1]
        cnt += 1
        if i == 2:
            print(cnt)
            exit()

    print(-1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 7084
#include<stdio.h>
int main()
{
int i,j,m;
for(i=1;i<10;i++)
{
	for(j=1;j<10;j++)
	{
		m=i*j;
		printf("%dx%d=%d\n",i,j,m);	
	}
	}
	return 0;
}

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

void heap_print(vector<int> keys){
  for(int j=0;j<keys.size();j++){
    int i = j+1;
    cout << "node " << i << ": ";
    cout << "key = " << keys[i-1] << ", ";
    if(i!=1){
      cout << "parent key = " << keys[(i/2)-1] << ", ";
    }

    if(2*i-1 < keys.size()){
      cout << "left key = " << keys[(i*2)-1] << ", ";
    }

    if(2*i+1-1 < keys.size()){
      cout << "right key = " << keys[i*2+1-1] << ", ";
    }

    cout << endl;
  }
	
}

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

  vector<int> keys;
  for(int i=0;i<n;i++){
    int tmp;
    cin >> tmp;
    keys.push_back(tmp);
  }

  heap_print(keys);

  return 0;
}

Measured memory_bytes: 1220
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 1000;
static const int VMAX = 10000;

int n, A[MAX], s,B[MAX],T[VMAX+1];

int solve(){
  int ans = 0;

  bool V[MAX];
  for(int i=0;i<n;i++){
    B[i] = A[i];
    V[i] = false;
  }
  sort(B,B+n);
  for(int i=0;i<n;i++) T[B[i]] = i;
  for(int i=0;i<n;i++){
    if(V[i]) continue;
    int cur = i;
    int S = 0;
    int m = VMAX;
    int an = 0;
    while(1){
      V[cur] = true;
      an++;
      int v = A[cur];
      m = min(m,v);
      S += v;
      cur = T[v];
      if(V[cur]) break;
    }
    ans += min(S + (an - 2)*m,m + S + (an + 1)*s);
  }

  return ans;
}

int main(){
  cin >> n;
  s = VMAX;
  for(int i=0;i<n;i++){
    cin >> A[i];
    s = min(s,A[i]);
  }
  int ans = solve();
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3164
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  string S; cin >> S;
  int l=S.size();
  int ans=l;
  rep(i,l-1){
    if(S[i]!=S[i+1]){
      if(max(i+1,l-(i+1))<ans) ans=max(i+1,l-(i+1));
    }
  }
  cout << ans << endl;
}

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

#define ll long long

using namespace std;


int main() {
    int n, w[102];
    cin >> n;
    int sol = 100 * 100;
    for (int i = 0; i < n; ++i)
        cin >> w[i];
    for (int i = 0; i < n; ++i) {
        int s1 = 0, s2 = 0;
        for (int j = 0; j <= i - 1; j++)
            s1 += w[j];
        for (int j = i; j < n; j++)
            s2 += w[j];
        sol = min(sol, abs(s2 - s1));
    }
    cout << sol;

    return 0;
}


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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const int INF = 100000000;


int main() {

    ll N, M;
    cin >> N >> M;
    vector<ll> A(M);
    ll sum = 0;
    REP(i, M){
        cin >> A[i];
        sum += A[i];
    }

    if(sum > N)sum = N + 1;

    cout << N - sum << endl;
    

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 3628
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>

using namespace std;

long long n;
vector<long long> a(100001,0);
vector<bool> flag(1000000001, false);
long long ans = 0;

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

    map<int,int> mp;
    for(int i = 0; i < n; i++){
        mp[a[i]]++;
    }

    for(auto p: mp){
        int x = p.first;
        int n= p.second;
        if(n < x) ans += n;
        else ans += n-x;
    }

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 127616
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <iomanip>
using namespace std;

int n, m;
int a[100100], b[100100];
pair<int, int> p[100100];

int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    p[i] = make_pair(a[i], b[i]);
  }

  sort(p, p + n);

  unsigned long long int ans = 0LL;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int a = p[i].first;
    int b = p[i].second;
    if (m - cnt < b) {
      ans += (a + 0LL) * (m-cnt);
      break;
    }
    ans += (a + 0LL) * b;
    cnt += b;
  }

  cout << ans << endl;
}


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

using namespace std;

// AtCoderを信じる！

using int64 = long long;
const int64 INF = 1LL << 61;

int main() {
  int N;
  vector< pair< int, int > > g[100];

  cin >> N;
  for(int i = 1; i < N; i++) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    g[x].emplace_back(y, i);
    g[y].emplace_back(x, i);
  }

  pair< int64, int64 > ret = {INF, INF};
  for(int i = 0; i < N; i++) {

    for(auto &e : g[i]) {
      int dont_use = e.second;
      queue< int > q[101];
      queue< int > out;
      q[0].emplace(i);
      q[0].emplace(e.first);
      bool v[101] = {};
      v[i] = v[e.first] = true;
      vector< int > use(101);
      for(int j = 0; j < 101; j++) {
        int leaf = 0;
        while(q[j].size()) {
          int p = q[j].front();
          q[j].pop();
          out.emplace(p);
          int child = 0;
          for(auto &f : g[p]) {
            if(f.second == dont_use) continue;
            if(v[f.first]) continue;
            ++child;
          }
          leaf = max(leaf, child);
        }
        use[j] = leaf;
        while(out.size()) {
          int p = out.front();
          out.pop();
          for(auto &f : g[p]) {
            if(f.second == dont_use) continue;
            if(v[f.first]) continue;
            v[f.first] = true;
            q[j + 1].emplace(f.first);
          }
        }
      }
      int64 fact = 1, sum = 1;
      for(auto &v : use) {
        if(v) {
          fact *= v;
          ++sum;
        }
      }
      ret = min(ret, {sum, fact * 2});
    }
  }
  for(int i = 0; i < N; i++) {
    queue< int > q[101];
    queue< int > out;
    q[0].emplace(i);
    bool v[101] = {};
    v[i] = true;
    vector< int > use(101);
    for(int j = 0; j < 101; j++) {
      int leaf = 0;
      while(q[j].size()) {
        int p = q[j].front();
        q[j].pop();
        out.emplace(p);
        int child = 0;
        for(auto &f : g[p]) {
          if(v[f.first]) continue;
          ++child;
        }
        leaf = max(leaf, child);
      }
      use[j] = leaf;
      while(out.size()) {
        int p = out.front();
        out.pop();
        for(auto &f : g[p]) {
          if(v[f.first]) continue;
          v[f.first] = true;
          q[j + 1].emplace(f.first);
        }
      }
    }
    int64 fact = 1, sum = 1;
    for(auto &v : use) {
      if(v) {
        fact *= v;
        ++sum;
      }
    }
    ret = min(ret, {sum, fact});

  }
  cout << ret.first << " " << ret.second << endl;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
int MOD = 1000000007;

int main() {
    string l;
    cin >> l;
    int n = l.size();
    ll room = 1;
    ll zero = 2;
    for(int i = 1; i < n; i++){
        if(l[i] == '0'){
            room *= 3;
            zero *= 1;
        }else{
            room = 3 * room + zero * 1;
            zero = zero * 2;
        }
        room %= MOD;
        zero %= MOD;
    }
    cout << (room + zero) % MOD << endl;
}

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

int main()
{
    int n, a[100];
    cin >> n;

    for (int i = 0; i <  n; i++)
        {
            cin >> a[i];
            for (int j = 0; j < i; j++)
            {
                int c;
                c = a[i];
                a[i] = a[j];
                a[j] = c;
            }
        }
    for (int i = 0; i < n - 1; i++)
        {
            cout << a[i] << " ";
        }
    cout << a[n-1] << endl;
    return 0;
}



Measured memory_bytes: 3092
#include <iostream>
using namespace std;
int a, b;
int main (){
    cin >> a >> b;
    if (a > 9) {
        cout << "-1" << endl;
    } else if (a < 0) {
        cout << "-1" << endl;
    } else if (b > 9) {
        cout << "-1" << endl;
    } else if (b < 0) {
        cout << "-1" << endl;
    } else {
        cout << a*b << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f;
const ll mod = 998244353LL;
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
int n;

void solve()
{
    cin >> n;
    n = n % 10;
    if(n==2||n==4||n==5||n==7||n==9)
        cout << "hon";
    else if(n==3)
        cout << "bon";
    else
        cout << "pon";
}

int main()
{
    TIME_START = clock();
    int Test = 1;
    // cin >> Test;
    while (Test--)
        solve();
    TIME_END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 3536
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define mp make_pair
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const long long MXN = 1e5 + 1;
const long long MNN = 1e3 + 1;
const long long MOD = 998244353;
const long long INF = 1e18;
const long long OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

llong n, b[MXN], ans;

int main(){
	ios;
	cin >> n;
	for(int i = 1; i <= 2 * n; i++){
		cin >> b[i];
	}sort(b + 1, b + 2 * n + 1);
	for(int i = 1; i <= 2 * n; i += 2){
		ans += b[i];
	}cout << ans;
	return 0;
}


Measured memory_bytes: 256
import * as fs from 'fs';
// main
function main(input: string[]) {
    // param
    let n: number = 0;
    let ans: number = 0;
    // init
    n = Number(input.shift());
    // solve
    let a0 = 1;
    let an = 8;
    let a9 = 1;
    let a09 = 0;
    for (let nx = 1; nx < n; nx++) {
        let bn = an * 8;
        let b0 = a0 * 9 + an * 1;
        let b9 = a9 * 9 + an * 1;
        let b09 = a09 * 10 + a0 * 1 + a9 * 1;
        an = bn % 1000000007;
        a0 = b0 % 1000000007;
        a9 = b9 % 1000000007;
        a09 = b09 % 1000000007;
    }
    ans = Number(a09);
    // answer
    console.log(ans);
}
// entrypoint
function entrypoint() {
    try {
        // linux
        let input = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        console.debug = function () { };
        main(input);
    }
    catch (ex) {
        // windows
        const lines: string[] = [];
        // @ts-ignore
        const reader = require('readline').createInterface({
            // @ts-ignore
            input: process.stdin,
            // @ts-ignore
            output: process.stdout
        });
        reader.on('line', function (line: string) {
            lines.push(line);
        });
        reader.on('close', function () {
            let input = lines;
            main(input);
        });
    }
}
entrypoint();


Measured memory_bytes: 33096
#include <stdio.h>
int main(void){
	int i,j,n,m;
	int A[30]={0};
	char str[1000];

	for( ; ; ){
		fgets(str,sizeof(str),stdin);
		sscanf(str,"%d",&m);
		if(m==0) break;
		for(j=0;j<m;j++){
			fgets(str,sizeof(str),stdin);
			sscanf(str,"%d",&n); A[n]+=1;
		}
		for(i=0;i<10;i++){
			for(j=0;j<A[i];j++){
				printf("*");
			}
			if(A[i]==0) printf("-");
			printf("\n");
			A[i]=0;
		}
	} 
	return 0;
}			

Measured memory_bytes: 588
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def FI(): return list(map(float, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): pass
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n = I()
A = LI()
memo  = [[[-1.0] * (n+1) for _ in range(n+1)] for _ in range(n+1)]
memo[0][0][0] = 0
def f(i, j, k):
    if memo[i][j][k] != -1:
        return memo[i][j][k]
    s = i + j + k
    ret = n - s
    if i:
        ret += i * (f(i - 1, j, k) + 1)
    if j:
        ret += j * (f(i + 1, j - 1, k) + 1)
    if k:
        ret += k * (f(i, j + 1, k - 1) + 1)
    memo[i][j][k] = ret / s
    return memo[i][j][k]

one, two, three = 0, 0, 0
for i in range(n):
    if A[i] == 1:
        one += 1
    elif A[i] == 2:
        two += 1
    else:
        three += 1

print(f(one, two, three))

Measured memory_bytes: 369924
#include<iostream>
using namespace std;
int main() {
  int n,k;
  cin>>n>>k;
  int j = 0;
  for(int i = 0;i < n;i++){
    int l = 0,x = 0;
    cin>>x;
    l = (k - x) * 2;
    x *= 2;
    if(x < l){
      j += x;
    }else{
      j += l;
    }
  }
  cout<<j<<endl;
  return 0;
  }

Measured memory_bytes: 3172
using namespace std;
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
int main() {
    int N,M,ans = 0;
    cin >> N >> M;
    
    for (int i = N;i>1;i--){
        ans += i-1;
    }
    for (int i = M;i>1;i--){
        ans += i-1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios_base::sync_with_stdio(0);
    int n, x, t; cin >> n >> x >> t;
    cout << t*((n+x-1)/x) << endl;
}


Measured memory_bytes: 3608
H, W = map(int, input().split())
mine = []
dx = [-1, 0, 1, 1, 1, 0, -1, -1]
dy = [-1, -1, -1, 0, 1, 1 ,1, 0]
for i in range(H):
    s_list = list(input())
    mine.append(s_list)
for i in range(H):
    for j in range(W):
        if mine[i][j] == "#":
            continue
        num = 0
        for k in range(8):
            nx = i + dx[k]
            ny = j + dy[k]
            if nx<0 or nx>=H or ny < 0 or ny >= W:
                continue
            else:
                if mine[nx][ny]=="#":
                    num += 1
        mine[i][j]=str(num)
for i in mine:
    print("".join(i))

Measured memory_bytes: 3188
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
typedef struct letarr *la;
struct letarr{
	int d;
	la next;
}*az[26]={0};
int main()
{
	char s[110];
	int l;
	scanf("%s",s);
	l = strlen(s);
	for(int t=0;t<l;t++)
	{
		la nw;
		nw = (la)malloc(sizeof(struct letarr));
		nw->d = t;
		nw->next = NULL;
		if(az[s[t]-'a'] == NULL)
		{
			az[s[t]-'a'] = nw;
		}
		else
		{
			la head=az[s[t]-'a'];
			for(;head->next!=NULL;head=head->next);
			head->next = nw;
		}
	}
	for(int t=0;t<26;t++)
	{
		if(az[t] == NULL) continue;
		int max;
		la last,now;
		last = now = az[t];
		if(now != NULL)
		{
			max = now->d;
		}
		now = now->next;
		for(;now!=NULL;now=now->next,last=last->next)
		{
			if(max < now->d-last->d-1) max = now->d-last->d-1;
		}
		if(max < l-1-last->d) max = l-1-last->d;
		az[t]->d = max;
	}
	int min=666;
	for(int t=0;t<26;t++)
	{
		if(az[t] != NULL)
		{
			if(min > az[t]->d) min = az[t]->d;
		}
	}
	printf("%d\n",min);
	return 0;
}

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

using ll = long long;
typedef unsigned long long ull;
typedef std::pair<int, int>p;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = false;
bool f = false;
bool used[210];
bool graph[100][100];
bool visited[8];
int abc[26] = { 0 };

int main() {
	int a[4][4];
	for (int i = 1;i < 4;i++) {
		for (int j = 1;j < 4;j++) {
			std::cin >> a[i][j];
		}
	}
	int b = a[1][2] - a[1][1], c = a[1][3] - a[1][2];
	int  d = a[2][2] - a[2][1], e = a[2][3] - a[2][2];
	int f = a[3][2] - a[3][1], g = a[3][3] - a[3][2];
	int o = a[2][1] - a[1][1], p = a[2][2] - a[1][2], q = a[2][3] - a[1][3];
	int r = a[3][1] - a[2][1], s = a[3][2] - a[2][2], t = a[3][3] - a[2][3];
	if (b == d&&b == f&&c == e&&c == g&&o == p&&o == q&&r == s&&r == t)std::cout << "Yes" << std::endl;
	else std::cout << "No" << std::endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    rep(i, N) cin >> p[i];
    sort(p.begin(), p.end());

    LL ans = 0;
    rep(i, K) {
        ans += p[i];
    }

    cout << ans << endl;

    return 0;
}


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

int main()
{
    int A, B, C;
    scanf("%d %d %d", &A, &B, &C);
    int ans = B + C - A >= 0 ? B + C - A : 0;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
def temp(x, t):
  return t - x * 0.006

n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

dt = abs(a - temp(h[0], t))
di = 0
for i in range(n):
  ti = temp(h[i], t)
  dti = abs(a - ti)
  if dti < dt:
    dt = dti
    di = i
print(di+1)

Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

long long int f(long long int n) {
  long long int ans = 0;
  long long int mult = 2;
  if (n % 4 == 1 || n % 4 == 2) {
    ans++;
  }

  for (int i = 0; i < 42; i++) {
    mult *= 2;
    if (n % mult >= mult / 2 && n % 2 == 0) {
      ans += mult / 2;
    }
  }

  return ans;
}

int main() {
  long long int A, B;
  cin >> A >> B;

  if (A > 0) {
    cout << (f(B) ^ f(A - 1)) << endl;
  } else {
    cout << f(B) << endl;
  }

  return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int mod = 1e9+7;
const int maxn = 2e5+5;
int a[maxn];
int main() {
	int n;
	double m;
	cin>>n>>m;
	int cnt = 0;
	ll sum = 0;
    for(int i=1;i<=n;i++){
    	cin>>a[i];
    	sum+=a[i];
	}
	for(int i=1;i<=n;i++){
		if(4*m*a[i]<sum){
			cnt++;
		}
	} 
	if((n-cnt)<m){
		cout<<"No\n";
	}
	else {
		cout<<"Yes\n";
	}
	return 0;
}


Measured memory_bytes: 256
a = input()
list1 = a.split("S")

if len(list1) == 1:
  print(3)
elif len(list1) == 2:
  if a == "RSR":
    print(1)
  else:
    print(2)
elif len(list1) == 3:
  print(1)
else:
  print(0)

Measured memory_bytes: 8944
import java.io.InputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.math.BigInteger;

public class Main{

static PrintWriter out;
static InputReader ir;

static void solve(){
 for(;;){
  int n=ir.nextInt();
  if(n==0) return;
  HashMap<String,String> map=new HashMap<String,String>();
  StringBuilder sb=new StringBuilder();
  while(n-->0) map.put(ir.next(),ir.next());
  int m=ir.nextInt();
  while(m-->0){
   String str=ir.next();
   sb.append((map.containsKey(str))?map.get(str):str);
  }
  out.println(sb.toString());
 }
}

public static void main(String[] args) throws Exception{
 ir=new InputReader(System.in);
 out=new PrintWriter(System.out);
 solve();
 out.flush();
}

static class InputReader {
 private InputStream in;
 private byte[] buffer=new byte[1024];
 private int curbuf;
 private int lenbuf;

 public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}
 
 public boolean hasNextByte() {
  if(curbuf>=lenbuf){
   curbuf= 0;
   try{
    lenbuf=in.read(buffer);
   }catch(IOException e) {
    throw new InputMismatchException();
   }
   if(lenbuf<=0) return false;
  }
  return true;
 }

 private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}
 
 private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}
 
 private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}
 
 public boolean hasNext(){skip(); return hasNextByte();}
 
 public String next(){
  if(!hasNext()) throw new NoSuchElementException();
  StringBuilder sb=new StringBuilder();
  int b=readByte();
  while(!isSpaceChar(b)){
   sb.appendCodePoint(b);
   b=readByte();
  }
  return sb.toString();
 }
 
 public int nextInt() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  int res=0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }
}
}

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

#define endl "\n"
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define watch(x) cout << (#x) << " is " << (x) << endl
#define watch_vector(x) FOR(i,0,(v).size(),1) cout<<v[i]<<" ";
#define yo cout<<"yo"

typedef long long int LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

// int maxProfit(int *p,int *w,int sum,int i){
// 	//here we use inclusion exclusion priciple on the elements
// 	//as we are using (sum,i) combinations a lot we can store them
// 	//in a table
// 	if(i == -1 || sum <= 0) return 0;
// 	if(w[i] > sum) return maxProfit(p,w,sum,i-1);
// 	else return max(maxProfit(p,w,sum,i-1),p[i]+maxProfit(p,w,sum-w[i],i-1));
// }
LL maxProfitTable(LL *price,LL *weight,LL n,LL capacity){
	//in each row i we include items from 0 to i
	//the jth column max profit that we ge
	//dp[i][j] = max profit using the first i items when the bag has size j
	// i is from 1 to (no of items)
	//(i-1) is the start index of the suffix array/start of the prefix array depending on the start of the loop
	//j is from 0 to capacity
	//dp[i][j] = max(dp[i-1][j],max(dp[]))
	LL dp[n+1][capacity+1];
	for(LL i=0;i<n+1;i++){
		for(LL j=0;j<capacity+1;j++){
			dp[i][j]=0;		
		}	
	} 

	for(LL i = 1;i <= n;i++){
		//we are including the first i elements in knapsack
		//w[0 .... i-1]
		//use w[i-1]
		for(LL j = 1;j<= capacity;j++){
			//we calculate the answers for capacity = j
			if(j >= weight[i-1]) dp[i][j]=max(dp[i - 1][j], price[i - 1] + dp[i - 1][j - weight[i-1]]);
			else dp[i][j] = dp[i-1][j];
		}
	}
	return dp[n][capacity];
}
int main()
{
   ios_base:: sync_with_stdio(false); cin.tie(0);
   
   #ifndef ONLINE_JUDGE
		//for getting input from input.txt
		freopen("input.txt","r", stdin);
		//for writing output to output.txt
		freopen("output.txt","w", stdout);
	#endif

	LL N,W;cin>>N>>W;
	LL p[N],w[N];
	for(LL i=0;i<N;i++){
		cin>>w[i]>>p[i];
	}
	cout<<maxProfitTable(p,w,N,W);

        
        
   return 0;
}

Measured memory_bytes: 82352
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define size(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define int ll
int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a,b,c; cin>>a>>b>>c;
	ll l=0,l1=1;
	cout<<(b+min(a+b,c)+max(l,min(l1,c-a-b)))<<"\n";
	return 0;
}














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

int main()
{
    int n,mm[200005],mmnn[200005];
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>mm[i];
        mmnn[i]=mm[i];
    }
    sort(mm,mm+n);
    int ans=mm[n/2];
    for(int i=0;i<n;i++)
    {
        if(ans>mmnn[i])cout<<mm[n/2]<<endl;
        else cout<<mm[n/2-1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3712
n=int(input())
A=list(map(int,input().split()))

A_sum=sum(A)
A_lis=sum([A[i] for i in range(0,n,2)])
B=[2*A_lis-A_sum]

for i in range(n-1):
    B.append(2*A[i]-B[i])

print(*B)

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

struct Dice{
  int s[6];
  void roll(char c){
    int b;
    if(c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }
    if(c=='W'){
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }
    if(c=='N'){
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }
    if(c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }
    if(c=='R'){
      b=s[1];
      s[1]=s[2];
      s[2]=s[4];
      s[4]=s[3];
      s[3]=b;
    }    
  }
  int top() {
    return s[0];
  }
  int right(){
    return s[2];
  }
  int left(){
    return s[3];
  }
  int front(){
    return s[1];
  }
};

int main(){
  Dice d1,d2;
  for(int i=0;i<6;i++) cin >> d1.s[i];
  for(int i=0;i<6;i++) cin >> d2.s[i];
  
  while(d1.s[0] != d2.s[0]){
    if (d1.s[0] == d2.s[2]) d2.roll('W');
    if (d1.s[0] == d2.s[3]) d2.roll('E');
    d2.roll('N');
  }
  
  while(d1.s[1] != d2.s[1]){
      d2.roll('R');
  }
  
  if (d1.s[2] == d2.s[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3092
n, x, y = map(int, (input().split()))

ans = [0] * (n - 1)

for i in range(1, n):
    for j in range(i + 1, n + 1):
        ans[min(j - i, abs(x - i) + 1 + abs(y - j)) - 1] += 1

[print(v) for v in ans]

Measured memory_bytes: 3444
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>
#include <list>
#include <random>

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

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

int a[301][301];

int main(int argc, char const* argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  rep(i, n){
    rep(j, m)cin >> a[i][j], a[i][j]--;
  }
  if(n == 1){
    cout << 1 << endl;
    return 0;
  }
  int res = inf;
  vector<bool> mask(m, true);
  for(int i = 0; i < m - 1; i++){
    vector<int> cnt(m, 0);
    for(int j = 0; j < n; j++){
      for(int k = 0; k < m; k++){
        if(mask[a[j][k]]){
          cnt[a[j][k]]++;
          break;
        }
      }
    }
    res = min(res, *max_element(all(cnt)));
    mask[max_element(all(cnt)) - cnt.begin()] = false;
  }
  cout << res << endl;
	return 0;
}


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

A = list(input())

B = []
t = 0
for i in A:
    if i == "(":
        B.append(i)
        t += 1
    else:
        if t == 0:
            B = ["("] + B
            B.append(")")
        else:
            B.append(i)
            t -= 1
for i in range(t):
    B.append(")")
print("".join(B))

Measured memory_bytes: 38384
#include<cstdio>
#include<cstring>
const int maxn=100005;
char str[maxn];int k;
int main(){
  scanf("%s%d",str+1,&k);
  int n=strlen(str+1);
  for(int i=1;i<=n;++i){
    if(str[i]!='a'&&'z'-str[i]+1<=k){
      k-=('z'-str[i]+1);
      str[i]='a';
    }
  }
  if(k==0)printf("%s\n",str+1);
  else{
    k%=26;
    str[n]=str[n]+k;
    if(str[n]>'z')str[n]-=26;
    printf("%s\n",str+1);
  }
  return 0;
}


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

int main(){
    int n;  cin >> n;
    vector<string>s(n);
    rep(i, n)   cin >> s[i];
    map<string, int>dic;
    ll ans = 0;
    rep(i, n){
        sort(s[i].begin(), s[i].end());
        if(dic[s[i]] == 0){
            dic[s[i]]++;
        }else{
            ans += dic[s[i]];
            dic[s[i]]++;
        }
    }
    cout << ans << endl;
}


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

int main(){
    //入力
    string O,E;
    cin >> O;
    cin >> E;

    //処理
    string ans;
    for(int i=0;i<E.size();i++){
        ans+=O.at(i);
        ans+=E.at(i);
    }
    
    if(O.size()>E.size()){
        ans+=O.at(O.size()-1);
    }

    cout << ans << endl;
}

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

int main(){
    ll r,d,x;cin>>r>>d>>x;
    for(int i=1;i<=10;i++){
        ll ans;
        ans=r*x-d;
        cout<<ans<<endl;
        x=ans;

    }
}

Measured memory_bytes: 3632
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
//////////////

void solve() {
	int N, K;
	cin >> N >> K;
	vector<int> X(N);
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		cin >> X[i];
		ans += min(X[i], K - X[i]);
	}
	cout << ans * 2 << endl;

}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 384
# babc094_b.py
N, M, X = map(int,input().split())
A = list(map(int,input().split()))
cnt_pre=0
cnt_post=0
for i in A:
    if i<X:
        cnt_pre+=1
    else:
        cnt_post+=1
print(min(cnt_post,cnt_pre))

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 998244353

int main()
{
    int n, s;
    cin >> n >> s;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    vector<vector<ll>> dp(n + 1, vector<ll>(s + 1, 0));
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j <= s; j++)
        {
            dp[i][j] += (2 * dp[i - 1][j]) % MOD;
            dp[i][j] %= MOD;
            if (j + a[i - 1] <= s)
            {
                dp[i][j + a[i - 1]] += dp[i - 1][j];
                dp[i][j + a[i-1]] %= MOD;
            }
        }
    }
    cout << dp[n][s] << endl;
    return 0;
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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 end


int main(){
   int n,p; scanf("%d%d",&n,&p);
   string s; cin>>s;
   if(p==2||p==5){
      ll res=0;
      rep(i,0,n)if((s[i]-'0')%p==0)res+=i+1;
      printf("%lld\n",res);
      return 0;
   }
   ll res=0,val=0,d=1; map<int,int> mp; mp[0]++;
   rrep(i,n-1,-1){
      val=(val+(s[i]-'0')*d)%p;
      res+=mp[val]; mp[val]++;
      d=(d*10)%p;
   }
   printf("%lld\n",res);
   return 0;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define int long long int
#define double long double
#define inf (int)(1e15)
#define all(x) (x).begin(), (x).end()
#define pair pair<int, int>
typedef vector<int> vi;   // Vector of long long
typedef vector<vi> vvi;   // Vector of vi
typedef vector<pair> vii; // Vector of pairs
typedef vector<vii> vvii; // Vector of Vector of pairs
typedef vector<bool> vb;  // Vector of bool
#define pq priority_queue // Max heap (To convert to min heap, use negative sign before every value)
#define ff first          // For pairs
#define ss second
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, -1, 0, 1};
const int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}, dy8[] = {1, -1, 1, 0, -1, 1, -0, -1};
#define testcases(t) \
    int(t);          \
    cin >> (t);      \
    while ((t)--)
signed main()
{
    int n, k, x = 0, sum = 0;
    cin >> n >> k;
    vi a(n + 1), f2(n + 1, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (a[i] > a[j])
            {
                sum++;
                if (i < j)
                    x++;
            }
        }
    }
    int ans = (k * x) % mod;
    int val = ((k * (k - 1)) / 2) % mod;
    ans += (val * sum) % mod;
    ans %= mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define F2(i,a,b) for(int i=(a);i<(b);++i)
#define dF(i,a,b) for(int i=(a);i>=(b);--i)
#define dF2(i,a,b) for(int i=(a);i>(b);--i)
#define dF3(i,a,b) for(int i=(a)-1;i>=(b);--i)
using namespace std;typedef long long ll;typedef double ld;int INF=0x3f3f3f3f;int INF2=0x7fffffff;ll LNF=0x3f3f3f3f3f3f3f3f;ll LNF2=0x7fffffffffffffff;

int n,x[101],y[101];
const double PI=acos(-1);
double k[101];

int main(){
	scanf("%d",&n);
	if(n==2){puts("0.5\n0.5");return 0;}
	F(i,1,n) scanf("%d%d",x+i,y+i);
	F(i,1,n){
		int cnt=0;
		F(j,1,n) if(j!=i){
			k[++cnt]=atan2(x[j]-x[i],y[j]-y[i]);
		}
		sort(k+1,k+cnt+1);
		double t;
		t=k[1]-k[cnt]+PI+PI;
		if(t>=PI-1e-9) {printf("%.15lf\n",(t-PI)/(PI+PI)); continue;}
		bool ok=0;
		F(j,1,cnt-1){
			t=k[j+1]-k[j];
			if(t>=PI-1e-9) {printf("%.15lf\n",(t-PI)/(PI+PI)); ok=1; break;}
		} if(!ok) printf("%.15lf\n",i,0.);
	}
	return 0;
}

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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		String[] aline = br.readLine().split(" ");

		int count = 0;
		String preslime = aline[0];
		int samecount = 1;

		for (int i = 1; i < n; i++) {
			if (preslime.equals(aline[i])) {
				samecount++;
			} else {
				count += samecount / 2;
				samecount = 1;
			}
			preslime = aline[i];
		}

		count += samecount / 2;

		System.out.println(count);

	}

}


Measured memory_bytes: 19412
while True:
    H, W = map(int,raw_input().split())
    if H == W == 0:
        break
    room = []
    for y in range(H):
        room.append(map(str,raw_input()))
    x,y = 0,0
    while True:
        tile = room[y][x]
        room[y][x] = '*'
        if tile == '>':
            x += 1
        elif tile == '<':
            x -= 1
        elif tile == 'v':
            y += 1
        elif tile == '^':
            y -= 1
        elif tile == '.':
            print "%d %d" % (x,y)
            break
        elif tile == '*':
            print 'LOOP'
            break

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

a = [b[0]] * (n)
for i in range(1,n):
    a[i] = b[i-1]
    if a[i-1] > b[i-1]:
        a[i-1] = b[i-1]

print(sum(a))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
#define PB push_back
#define MP make_pair
#define st first
#define nd second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<long long>;
using ld = long double;

#define unordered_map __fast_unordered_map
template<class Key, class Value, class Hash = std::hash<Key>>
using unordered_map = __gnu_pbds::gp_hash_table<Key, Value, Hash>;

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

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

const int MaxN = 1e5 + 100;

vi adj[MaxN];
int vis[MaxN];
vector<pii> ans;

int Dfs(int v, int p) {
  vis[v] = 1;
  vi outs;
  for (int s : adj[v]) {
    if (vis[s] == 2) { continue; }
    if (s == p) { continue; }
    if (vis[s] == 1) { outs.PB(s); continue; }
    const int a = Dfs(s, v);
    if (a != -1) {
      outs.PB(a);
    }
  }
  if (v != p) { outs.PB(p); }
  debug(v, outs);

  const int s = SZ(outs);
  for (int i = 1; i < s; i += 2) {
    ans.emplace_back(v, outs[i - 1]);
    ans.emplace_back(v, outs[i]);
  }

  vis[v] = 2;
  if (s % 2 == 0) {
    return -1;
  } else {
    return v;
  }
}


int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);

  int n, m;
  cin >> n >> m;

  if (m % 2 == 1) {
    cout << "-1\n";
    return 0;
  }

  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    adj[u].PB(v);
    adj[v].PB(u);
  }

  Dfs(1, 1);
  for (auto &edge : ans) {
    cout << edge.st << " " << edge.nd << "\n";
  }
}



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

int main() {
    int n, mx, mn;
    long s = 0;
    int* ns;
    cin >> n;
    ns = new int[ n ];
    for( int i = 0; i < n; ++i ) {
        cin >> ns[ i ];
        s += ns[ i ];
        if( i == 0 ) {
            mx = mn = ns[ 0 ];
            continue;
        }
        mx = mx < ns[ i ] ? ns[ i ] : mx;
        mn = mn > ns[ i ] ? ns[ i ] : mn;
    }
    cout << mn << " " << mx << " " << s << endl;
    
}

Measured memory_bytes: 1228
/**
 *  author:   TakeruOkuyama
 *  created:  
**/
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD = 1000000007;

int main(){
    string A, B;
    cin >> A >> B;
    if(A.size() < B.size()){
        cout << "LESS" << endl;
    }else if(A.size() > B.size()){
        cout <<"GREATER" << endl;
    }else{
        if(A == B){
            cout << "EQUAL" << endl;
            return 0;
        }else if(A > B){
            cout << "GREATER" << endl;
            return 0;
        }else if(A < B){
            cout << "LESS" << endl;
            return 0;
        }    
    }
return 0;}

/**
 * g++ code.cpp
 * ./a.out
 * shift + ctrl + i
**/ 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int A, B;
    cin >> A >> B;
    if(B == 1){
        cout << 0 << endl;
        return 0;
    }
    int ans = 1;
    int cnt = 0;
    while(ans < B){
        ans += -1 + A;
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3636
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;
typedef pair< lo,PII > PIII;

#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define pb push_back
#define int long long
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t,vis[li],kok;
int cev;
PIII p[li];
string s;
vector<int> v;

bool psort(PIII x,PIII y){
	if(x.fi/kok<y.fi/kok)return 1;
	if(x.fi/kok>y.fi/kok)return 0;
	if(x.se.fi<y.se.fi)return 1;
	return 0;
}

main(void){
	scanf("%lld %lld",&n,&t);
	kok=1000;
	FOR scanf("%lld",&a[i]);
	for(int i=1;i<=t;i++){
		scanf("%lld %lld",&p[i].fi,&p[i].se.fi);
		p[i].se.se=i;
	}
	sort(p+1,p+t+1,psort);
	int bas=0;
	int son=0;
	for(int i=1;i<=t;i++){
		//~ cout<<i<<"[][][]"<<a[bas]<<"[][]"<<bas<<endl;
		while(bas<p[i].fi){
			//~ cout<<i<<"[][][]"<<a[bas]<<"[][]"<<bas<<endl;
			if(vis[a[bas]]==1)cev--;
			//~ cout<<i<<"[][][]"<<a[bas]<<"[][]"<<bas<<endl;
			vis[a[bas]]--;
			bas++;
		}
		while(bas>p[i].fi){
			bas--;
			if(vis[a[bas]]==0)cev++;
			vis[a[bas]]++;
			
		}
		while(son<p[i].se.fi){
			son++;
			if(vis[a[son]]==0)cev++;
			vis[a[son]]++;
		}
		while(son>p[i].se.fi){
			if(vis[a[son]]==1)cev--;
			vis[a[son]]--;
			son--;
		}
		//~ printf("%lld %lld %lld\n",p[i].fi,p[i].se.fi,p[i].se.se);
		//~ cout<<vis[1]<<" : : "<<vis[2]<<" : ; "<<vis[3]<<endl;
		//~ cout<<bas<<" () "<<son<<" () "<<a[bas]<<endl;
		b[p[i].se.se]=cev;
	}
	//~ printf("")
	for(int i=1;i<=t;i++)printf("%lld\n",b[i]);
	return 0;
}



Measured memory_bytes: 27232
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int pro = A*B;

    if(pro%2 == 0) {
      System.out.println("Even");
    }else {
      System.out.println("Odd");
    }
  }
}


Measured memory_bytes: 21076