akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vii;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

// ────────────────────────────────────────────────────

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

	vvi p(n, vector<int>(3));

	rep(i, n) {
		rep(j, 3) {
			cin >> p[i][j];
		}
		sort(ASC(p[i]));
	}
	sort(ASC(p));

	int check[3];
	check[0] = p[0][0];
	check[1] = p[0][1];
	check[2] = p[0][2];

	int cnt = 0;

	for (int i = 1; i < n; ++i) {
		if (check[0] == p[i][0] && check[1] == p[i][1] && check[2] == p[i][2]) {
			cnt++;
		}
		else {
			check[0] = p[i][0];
			check[1] = p[i][1];
			check[2] = p[i][2];
		}
	}
	ANS(cnt);
}



Measured memory_bytes: 3228
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int cnt[35][35];

int main() {
	unsigned long long ans = 0;
	int n; scanf("%d", &n);
	for(int i=1;i<=n;i++) {
		char str[55]; scanf("%s", str);
		int len = strlen(str), pos = len - 1;
		for(int i=0;i<len;i++) {
			if( str[i] == '.' ) {
				pos = i;
				break;
			}
		}
		
		unsigned long long p = 0;
		int pw = 10 - (len - pos - 1);
		for(int i=0;i<len;i++)
			if( str[i] != '.' ) p = p * 10 + (str[i] - '0');
		for(int i=1;i<=pw;i++) p *= 10;
		
		int c2 = 0, c5 = 0;
		while( p % 2 == 0 ) p /= 2, c2++;
		while( p % 5 == 0 ) p /= 5, c5++;
		c2 = min(c2, 30), c5 = min(c5, 30), cnt[c2][c5]++;
	}
	
	for(int i=0;i<=30;i++) for(int j=0;j<=30;j++)
	for(int p=0;p<=30;p++) for(int q=0;q<=30;q++)
		if( cnt[i][j] && cnt[p][q] )
			if( i + p >= 20 && j + q >= 20 )
				ans += 1ull * cnt[i][j] * cnt[p][q];
	
	for(int i=0;i<=30;i++) for(int j=0;j<=30;j++)
		if( i + i >= 20 && j + j >= 20 )
			ans -= cnt[i][j];
	
	printf("%llu\n", ans / 2);
}

Measured memory_bytes: 1656
import copy
h, w, k = map(int, input().split())
hw = []
mas = []
mas_su = 0

for i in range(h):
    hwi = input()
    masi = []
    for j in range(w):
        if hwi[j] == "#":
            masi.append(1)
        else:
            masi.append(0)

    mas_su += sum(masi)
    mas.append(masi)

l = 2**(h+w)
ans = 0

for i in range(l):
    test = copy.deepcopy(mas)
    num = 0
    for j in range(h+w):
        if ((i >> j) & 1):
            if j < h:
                for p in range(w):
                    if test[j][p]==1:
                        test[j][p] = 0
                        num += 1
            else:
                for p in range(h):
                    if test[p][j-h]==1:
                        test[p][j-h] = 0
                        num += 1
    if mas_su-num == k:
        ans += 1

print(ans)

Measured memory_bytes: 9252
S = list(input())
N = len(S)

a = [0] * (N + 1)
for i in range(N):
    if S[i] == '<':
        a[i + 1] = max(a[i + 1], a[i] + 1)
    # print(a)

for i in reversed(range(N)):
    if S[i] == '>':
        a[i] = max(a[i], a[i + 1] + 1)
    # print(a)

print(sum(a))
# print(a)


Measured memory_bytes: 27196
//by yjz
#include<bits/stdc++.h>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
typedef long long ll;
using namespace std;
ll n, a, b;
ll solve(ll a, ll b)
{
	if ((a-b)%2==0) return abs(a-b)/2;
	else if (min(a,b)>1)
	{
		ll t = min(a, b)-1;
		return t+solve(a-t, b-t);
	}
	else
	{
		return 1+solve(max(a-1,1ll), max(b-1,1ll));
	}
}
int main()
{
	cin>>n>>a>>b;
	cout<<min(solve(a,b), solve(n-a+1, n-b+1))<<endl;
	return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int W,H,C,c;
	cin>>W>>H>>C;
	c=min(W,H);
	while(1){
		if (W%c==0&&H%c==0) break;
		c--;
	}
	cout<<(W/c)*(H/c)*C<<endl;
	return 0;
}


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

using namespace std;

int main() {
	int x, y;
	set<int> a, b, c;

	a.insert(1);
	a.insert(3);
	a.insert(5);
	a.insert(7);
	a.insert(8);
	a.insert(10);
	a.insert(12);

	b.insert(4);
	b.insert(6);
	b.insert(9);
	b.insert(11);

	scanf("%d %d", &x, &y);

	if (a.find(x) != a.end() && a.find(y) != a.end()) {
		puts("Yes");
	}
	else if (b.find(x) != b.end() && b.find(y) != b.end()) {
		puts("Yes");
	}
	else if (x == 2 && y == 2)
		puts("Yes");
	else
		puts("No");

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <assert.h>
#include <map>
#include <memory.h>
#include <queue>
#include <string.h>
#include <set>
#include <bitset>
using namespace std;

#define ll long long
#define N 100005

int p[N],dsu[N];
int f(int x) {
  if(x==dsu[x]) {
    return x;
  }
  return dsu[x] = f(dsu[x]);
}
void merge(int x,int y) {
  x = f(x),y = f(y);
  if(x!=y) {
    dsu[x] = y;
  }
}

set<int> s[N];
void solve() {
  int n,m;
  scanf("%d %d ",&n,&m);
  for(int i=1;i<=n;++i) {
    scanf("%d" ,&p[i]);
    dsu[i] = i;
  }
  for(int i=0;i<m;++i) {
    int x,y;scanf("%d %d ", &x,&y);
    merge(x,y);
  }
  for(int i=1;i<=n;++i) {
    int par = f(i);
    s[par].insert(p[i]);
  }
  int ret = 0;
  for(int i=1;i<=n;++i) {
    int par = f(i);
    if(s[par].count(i)) {
      ++ret;
    }
  }
  printf("%d\n", ret);
}

int main() {
  //freopen("input.txt","r",stdin);
  solve();
  return 0;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}// char to int
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}//MAX
int lcm(ll a,ll b){return a*b/gcd(a,b);}//MIN
 
int  main(){
int n;
string s;
cin >> n >> s;
int ans = 0;
for(int i=0;i<n;i++){
    if(s.at(i)=='R')ans++;
    else ans--;
}
if(ans>0)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
 


Measured memory_bytes: 256
N, W = list(map(int, input().split()))

value, weight= [0]*N, [0]*N

for i in range(N):
    v, w = list(map(int, input().split()))
    value[i], weight[i] = v, w

dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
"""
for i in range(N):
    for j in range(W+1):
        k = 0
        while k * weight[i] <= j:
            res1 = dp[i+1][j]
            res2 = dp[i][j - k*weight[i]] + k * value[i]
            dp[i+1][j] = max(res1, res2)
            k += 1
"""

for i in range(N):
    for j in range(W+1):
        if j < weight[i]:
            dp[i+1][j] = dp[i][j]
        else:
            res1 = dp[i][j]
            res2 = dp[i+1][j - weight[i]] + value[i]
            dp[i+1][j] = max(res1, res2)

print(dp[N][W])



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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
  string S, T;
  cin >> S >> T;
  int ans = 0;
  for (int i = 0; i < S.size(); i++)
    if (S[i] == T[i])
      ans++;
  cout << ans << endl;
}


Measured memory_bytes: 256
program main
    integer :: n,nn
    integer :: a = 1, ans = 0, s = 0, de = 10**8

    read *, n
    nn = n
    do while(de > 1)
        s = n / int(de)
        ans = ans + s
        if(s /= 0)  then
            n = n - s*de
        end if
        de = de / 10
    end do
    ans = ans + n
    if(mod(nn, ans) == 0) then
        print *, "Yes"
    else
        print *, "No"
    end if
end program main

Measured memory_bytes: 512
/*
   Aizu Vol-1 0170: Lunch
   2017.8.15 bal4u@uu
*/

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

typedef struct { char *f; int w, s; } T; T f[12];
char ss[12][22];
int n, sw, g[12], ans[12];

int cmp(T *a, T *b)
{
	if (a->w != b->w) return b->w - a->w;
	return b->w - a->w;
}

int combi(int j, int w)
{
	int i;
	T *p;

	if (j >= n) return 1;
	for (p = f, i = 0; i < n; i++, p++) {
		if (g[i] || (sw - w - p->w) > p->s) continue;
		g[i] = 1;
		ans[j] = i;
		if (combi(j + 1, w + p->w)) return 1;
		g[i] = 0;
	}
	return 0;
}

int main()
{
	int i;

	while (1) {
		scanf("%d", &n); if (!n) break;
		for (sw = i = 0; i < n; i++) {
			scanf("%s%d%d", ss + i, &f[i].w, &f[i].s);
			f[i].f = ss[i], sw += f[i].w;
			g[i] = 0;
		}
		qsort(f, n, sizeof(T), cmp);
		combi(0, 0);
		for (i = 0; i < n; i++) printf("%s\n", f[ans[i]].f);
	}
	return 0;
}

Measured memory_bytes: 588
#include <stdio.h>

int main(){
  int n, x;
  while(1){
    scanf("%d%d", &n, &x);
    if(n == 0 && x == 0) break;

    int num1[n];
    int num2[n];
    int num3[n];

    int i =1;
    int j =1;
    int k =1;

    int count = 0;
  
    for(i = 1; i <= n-2; i++){
      num1[i] = i;
      for(j = i + 1; j <= n-1; j++){
	num2[j] = j;
	for(k = j+1;k <= n; k++){
	  num3[k] = k;
	  if(x == num1[i] + num2[j] + num3[k]){
	    if(num1[i] != num2[j] && num1[i] != num3[k] && num2[j] != num3[k])
	      count++;
	  }
	}
      }
    }
  
    printf("%d\n", count);
  }
  return 0;
}



Measured memory_bytes: 2068
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <unordered_map>

using namespace std;

typedef long long LL;

const int MAXN = 32;
int d[MAXN] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main() {
    int k;
    cin >> k;
    cout << d[k-1] << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
       Scanner sc = new Scanner(System.in);   
      //取得
	  int N = sc.nextInt();
      int[] B = new int[N-1];
      for(int i=0;i<N-1;i++){
        B[i] = sc.nextInt();
      }
      //Aを作る
      int[] A = new int[N];
      A[0] = B[0];
      for(int i=1;i<N-1;i++){
        if(B[i-1]>B[i]){
          A[i]=B[i];
        }else{
          A[i]=B[i-1];
        }
      }
      A[N-1]=B[N-2];
      //A[]の合計
      int sum = 0;
      for(int i=0;i<N;i++){
          sum+=A[i];
      }
      System.out.println(sum);
    }
}

Measured memory_bytes: 35956
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

struct edge { int to; int cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-12;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int dp[500010];

int main(){
	int n,k;
	cin >> n >> k;
	vi h(n);
	rep(i,n) cin >> h[i];
	rep(i,500010) dp[i] = INF;
	dp[0] = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j <= k; j++){
			if(i+j < n) chmin(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
		}
	}
	cout << dp[n-1] << endl;

	return 0;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

vector<vector<int>> edges;
int loop_start;

void detect_cycle(int cur, ll &k, vector<bool> &visited) {
    if (k == 0) {
        cout << cur + 1 << endl;
        exit(0);
    }
    if (visited[cur]) {
        loop_start = cur;
        return;
    }

    visited[cur] = true;
    k--;
    detect_cycle(edges[cur][0], k, visited);
}

void find_towns_loop(int cur, vector<int> &towns_loop, const int start) {
    if ((int) towns_loop.size() != 0 && cur == start) {
        return;
    }

    towns_loop.push_back(cur);
    find_towns_loop(edges[cur][0], towns_loop, start);
}

int main(void) {
    int N;
    ll K;
    cin >> N >> K;

    edges.resize(N);
    for (int i = 0; i < N; i++) {
        int t;
        cin >> t;
        t--;
        edges[i].push_back(t);
    }

    {
        vector<bool> visited(N, false);
        detect_cycle(0, K, visited);
    }

    vector<int> towns_loop;
    find_towns_loop(loop_start, towns_loop, loop_start);

    cout << towns_loop[K % ((ll) towns_loop.size())] + 1 << endl;

    return 0;
}


Measured memory_bytes: 20704
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)

	var tree Tree

	tree.root = nil

	for i := 0; i < n; i++ {
		order := getNextString(scanner)
		switch order {
		case "print":
			tree.i = 0
			tree.keys = make([]int, tree.n)
			tree.printInOrders(tree.root)
			fmt.Fprintln(writer, fmt.Sprintf(" %s", joinint(tree.keys, " ")))
			tree.i = 0
			tree.keys = make([]int, tree.n)
			tree.printPreOrders(tree.root)
			fmt.Fprintln(writer, fmt.Sprintf(" %s", joinint(tree.keys, " ")))
		case "insert":
			key := getNextInt(scanner)
			tree.insert(key)
		}
	}

	writer.Flush()
}

// Tree tree
type Tree struct {
	root *Node
	keys []int
	i    int
	n    int
}

func (t *Tree) insert(key int) {
	t.n++
	node := Node{
		key:    key,
		parent: nil,
		left:   nil,
		right:  nil,
	}
	if t.root == nil {
		t.root = &node
		return
	}

	n := t.root
	var p *Node
	p = nil

	for n != nil {
		p = n
		if n.key < key {
			n = n.right
			continue
		}
		n = n.left
	}
	node.parent = p
	if p.key < key {
		p.right = &node
		return
	}
	p.left = &node
}

func (t *Tree) printPreOrders(n *Node) {
	if n == nil {
		return
	}
	t.keys[t.i] = n.key
	t.i++
	t.printPreOrders(n.left)
	t.printPreOrders(n.right)
}

func (t *Tree) printInOrders(n *Node) {
	if n == nil {
		return
	}
	t.printInOrders(n.left)
	t.keys[t.i] = n.key
	t.i++
	t.printInOrders(n.right)
}

// Node node
type Node struct {
	key    int
	parent *Node
	left   *Node
	right  *Node
}

func joinint(a []int, sep string) string {
	n := len(a)
	ss := make([]string, n)
	for i := 0; i < n; i++ {
		ss[i] = fmt.Sprintf("%d", a[i])
	}
	return strings.Join(ss, sep)
}



Measured memory_bytes: 57964
n=int(input())
arr=list(map(int,input().split()))
ans=0
i=0
j=0
sumx=0
while(i<n and j<n):
    if((arr[j] & sumx)==0):
        sumx+=arr[j]
        j+=1
        ans+=j-i
        
    else:
        sumx-=arr[i]
        i+=1
print(ans)  


Measured memory_bytes: 25916
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = ("0 " + Console.ReadLine()).Split().Select(int.Parse).ToArray();
        for (int i = n / 2; i >= 1; i--)
            Heapfy(a, i, n);
        Console.WriteLine(" " + string.Join(" ", a.Skip(1)));
    }
    static void Heapfy(int[] a, int i, int n)
    {
        var l = i * 2;
        var r = i * 2 + 1;

        var largest = l <= n && a[i] < a[l] ? l : i;
        if (r <= n && a[largest] < a[r]) largest = r;

        if (largest != i)
        {
            var tmp = a[i];
            a[i] = a[largest];
            a[largest] = tmp;
            Heapfy(a, largest, n);
        }
    }
}



Measured memory_bytes: 76332
n = int(input())
s = input()
imosw = []
imose = []
imosw.append(0);
imose.append(0);
for i in range(n):
    if s[i]=='W':
        imosw.append(imosw[i]+1)
        imose.append(imose[i])
    else:
        imosw.append(imosw[i])
        imose.append(imose[i]+1)
res = 100000000000
for i in range(n):
    res = min(imosw[i]+imose[n]-imose[i+1],res)
print(res)

Measured memory_bytes: 17880
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repeq(i,a,b) for(int i=a;i<=(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    int n=sz(s);
    vi perm(n);
    rep(i,0,n) perm[i]=s[i]-'a';
    if(n<26) {
        rep(i,0,26) {
            bool ok=true;
            rep(j,0,n) if(perm[j]==i) ok=false;
            if(ok) {
                perm.push_back(i);
                break;
            }
        }
    }
    else {
        vi copy=perm;
        next_permutation(all(perm));
        int i=0;
        while(copy[i]==perm[i])++i;
        while(sz(perm)>i+1)perm.pop_back();
    }
    bool bad=false;
    if(sz(perm)==1 && perm[0]==0) {
        bad=true;
    }
    if(bad) cout<<-1<<endl;
    else {
        string result;
        for(int x:perm) result+=x+'a';
        cout<<result<<endl;
    }
}


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

int main() {
  string N;
  int a;
  a=0;
  cin >> N ;
 for(int i=0;i<N.size();i++){
  if(N.at(i)=='+') {
    a++;
  }
  else {
  a--;
  }
   }
  cout << a <<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}

int c[8][8]={{1,2,1,2,1,4,1,4},{1,2,1,4,1,4,1,2},{1,4,1,2,1,2,1,4},{1,4,1,4,1,2,1,2},
	{2,1,2,1,4,1,4,1},{2,1,4,1,4,1,2,1},{4,1,2,1,2,1,4,1},{4,1,4,1,2,1,2,1}};

int main(void){
	int p[8],i,j,min,now,id;
	while(scanf("%d %d %d %d %d %d %d %d",p,p+1,p+2,p+3,p+4,p+5,p+6,p+7)!=EOF){
		min=inf;
		rep(i,8){
			now=0;
			rep(j,8){
				if(p[j]-c[i][j]>0)
					now+=p[j]-c[i][j];
			}
			if(min>now){
				id=i;
				min=now;
			}
		}
		rep(i,8)
			printf("%d%c",c[id][i],i==7?'\n':' ');
	}
	return 0;
}


Measured memory_bytes: 2036
#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 <cmath>
#include <climits>
#include <bitset>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  vector<ll> a = vector<ll>(n, 0);
  for(int i = 0; i < n; i++){
    ll x;
    cin >> x;
    a[i] = x;
  }
  deque<ll> q;
  ll res = 0;
  ll curr = 0;
  for(int i = 0; i < n; i++){
    if(a[i] == 0 || i == n - 1){
      if(a[i] > 0)curr += a[i];
      res += curr / 2;
      curr = 0;
    }else{
      curr += a[i];
    }
  }
  cout << res << endl;
	return 0;
}


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

int h1, m1, h2, m2, k;

int main(){
	scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
	h1 = h1 * 60 + m1;
	h2 = h2 * 60 + m2 - k;
	printf("%d\n", max(0, h2 - h1));
	return 0;
}

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

int main(){
  int N;
  string s;
  cin>>N>>s;
    for(int i=0;i<s.length();i++){
      if(s[i]+N<='Z'){
      s[i]+=N;
      }else{
        s[i]=64+(s[i]-90+N);
      }
    }
 cout<<s<<endl;
   
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

int main() 
{
    int a, b, c;
    
    cin >> a >> b >> c;
    if (a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
    else if(a <= c && c <= b)
        cout << a << " " << c << " " << b << endl;
    else if(b <= a && a <= c)
        cout << b << " " << a << " " << c << endl;
    else if(b <= c && c <= a)
        cout << b << " " << c << " " << a << endl;
    else if (c <= a && a <= b)
        cout << c << " " << a << " " << b << endl;
    else
        cout << c << " " << b << " " << a << endl;
    
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int N, temp;
	cin >> N;
	int A[N] = {0};
	for(int i = 0; i < N - 1; i++)
	{
		cin >> temp;
		A[temp - 1] += 1;
	}
	for(int i = 0; i < N; i++)
	{
		cout << A[i] << endl;
	}
	return 0;
}

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

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;

int H,W, co[5], CO[5], num[26];
char a[100][100];

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> H >> W;
	F0R(i,H) F0R(j,W) {
	    cin >> a[i][j];
	    num[a[i][j]-'a'] ++;
	    int t = 4;
	    if (i == H-1-i) t /= 2;
	    if (j == W-1-j) t /= 2;
	    co[t] ++;
	}
	co[2] /= 2, co[4] /= 4;
	F0R(i,26) {
	    while (num[i] >= 4) CO[4] ++, num[i] -= 4;
	    while (num[i] >= 2) CO[2] ++, num[i] -= 2;
	    while (num[i] >= 1) CO[1] ++, num[i] -= 1;
	}
	if (CO[4] < co[4]) {
	    cout << "No";
	    return 0;
	}
	CO[4] -= co[4];
	CO[2] += 2*CO[4];
	if (CO[2] < co[2]) {
	    cout << "No";
	    return 0;
	}
	cout << "Yes";
}

// read!
// ll vs. int!

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > using vec = std::vector< T >;
template < class T > void print(T &x) { cout << x << "\n"; }
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  vec<int>a(3);
  vec<int>b(3);
  cin >> a[0]>>a[1]>>a[2];
  REP(i,3){
   b[i]=abs(a[i]-a[(i+1)%3]);
  }
  int bmax = max({b[0],b[1],b[2]});
  cout <<b[0]+b[1]+b[2]-bmax<<"\n";
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
 
static const double EPS = 1e-8;
 
int tx[] = {1,0};
int ty[] = {0,1};
 
ll dp[101][101][2][2];

ll dfs(int x,int y,int isturn,int dir,int w,int h,bool isf){
    if(x==w-1 && y==h-1) return 1;
 
    ll res=0;
    for(int i=0;i<2;i++){
        int nextT;
        if(isturn && i != dir) continue;
        if(!isf && i!=dir) nextT = 1;
        else nextT = 0;
        int dx = x + tx[i];
        int dy = y + ty[i];
        if(dy < 0 || dx < 0 || dy >= h || dx >= w) continue;
        //printf("x:%d y:%dn",dx,dy);
		if(dp[dy][dx][dir][i]==-1) res += (dp[dy][dx][dir][i] = dfs(dx,dy,nextT,i,w,h,false) % 100000);
        else res += dp[dy][dx][dir][i];
    }
 
    return res;
}
int main(){
    int w,h;
    while(~scanf("%d %d",&w,&h)){
        if(w==h && h==0) break;
		memset(dp,-1,sizeof(dp));
        printf("%lld\n",dfs(0,0,0,0,w,h,true) % 100000);
    }
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String str="";
		int start=0; int end=0;
		String moji="";
		String[] nenn;
		int nns=0;
		int counter=0;
		while(sc.hasNext()) {
			nns=0;
			start =sc.nextInt();
			end =sc.nextInt();
			if(start==0 && end==0) {
				System.exit(0);
			}
			if(counter!=0) {
				System.out.println("");
			}
			for(int i=start; i<=end; i++) {
				if(i%4==0) {
					if(i%400==0) {
						System.out.println(i);
						nns++;
					}
					else if(i%100==0 && i%400 != 0) {

					}
					else {
						System.out.println(i);
						nns++;
					}
				}
				else {}
			}
			if(nns==0) {
				System.out.println("NA");
			}
			counter++;
		}
	}
}


Measured memory_bytes: 27448
def resolve():
    A = int(input())
    B = int(input())
    C = int(input())
    X = int(input())
    ans = 0
    for a in range(A+1):
        for b in range(B+1):
            for c in range(C+1):
                if 500*a + 100*b + 50*c == X:
                    ans += 1
    print(ans)
resolve()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>

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

using namespace std;
using ll = long long int;
using ull = unsigned long long;

constexpr ull mod = 1e9+7;
constexpr int N = 13;
ull dp[100010][N];

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int main() {
	int n, k, x, y;
	cin >> n >> k >> x >> y;
	if (n <= k) {
		cout << (n * x) << endl;
	} else {
		cout << ((k * x) + (n - k) * y) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
const int MAXN = 101010;
typedef long long int LL;
int n, k;
int q[MAXN], p[MAXN];
long long int ans;
int main(){
    scanf("%d%d", &n, &k);
    for(int i = 1; i <= n; i ++){
        p[i] = n / i;
        q[i] = n % i;
    }

    if(k == 0){
        printf("%lld", (LL)n * (LL)n);
        return 0;
    }

    for(int i = 1; i <= n; i ++){
        if(i <= k)
            continue;
        ans += (LL)(i - k) *  p[i];
        ans += q[i] >= k ? q[i] - k + 1 : 0;
    }
    printf("%lld", ans);

}

Measured memory_bytes: 896
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
#from decimal import *

N, M = MAP()
 
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
 
for i in range(N-M+1):
	for j in range(N-M+1):
		for k in range(M):
			if A[i+k][j:j+M] != B[k]:
				break
		else:
			print("Yes")
			exit()
else:
	print("No")

Measured memory_bytes: 5200
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	//数値の入力
		int n = sc.nextInt();
      	int k = sc.nextInt();
      	int result =1;
      	for (int i = 0; i < n-1; i++) {
            result *= k-1;
        }
        System.out.println(result*k);
     }
}

Measured memory_bytes: 35760
import java.sql.SQLOutput;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String O = sc.next();
        String E = sc.next();
        String result = "";
        for (int i = 0; i < O.length() + E.length(); i++) {
            if (i % 2 == 0) {
                result = result + String.valueOf(O.charAt(i / 2));
            } else {
                result = result + String.valueOf(E.charAt(i / 2));
            }
        }
        System.out.println(result);
    }

}


Measured memory_bytes: 21716
//   //  /////       ///      
//  //   //  //     // //     
// //    //   //   //   //    
////     //   //  //     //   
// //    //   //  /////////    
//  //   //  //   //     //    
//   //  /////    //     //    

#include <bits/stdc++.h>
using namespace std;
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define iter(it,a,b) for(a::iterator it=b.begin(); it!=b.end();++it)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (binary me 1 kitne hai) (if longlong popcount ll)
#define ln "\n"
#define dbg(x) cerr<<#x<<" = "<<x<<endl
#define dbg2(x,y) cerr<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;
#define dbgstl32(v) cerr<<#v<<" = \n"; { int c=0; forstl(it,v) \
cerr<<"    Term "<< ++c <<" = "<<it<<ln;} cerr<<endl
#define dbgstlp32(v) cerr<<#v<<" = \n"; { int c=0; forstl(it,v) \
cerr<<"    Term "<< ++c <<" = "<<it.fi<<" , "<<it.se<<ln;} cerr<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(n) n.begin() , n.end() 
#define tfi first.first
#define tse first.second
#define tth second
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
typedef pair< pair<int,int> , int> tri;
typedef vector<bool> vbool;
typedef priority_queue<p32> pq32;
typedef priority_queue<p32, vector<p32>, greater<p32> > pq32l;

#pragma GCC optimize ("-O2")
const ll LIM = 2e5+5;
const ll MOD = 1e9+7;
const ll inf = 1e10;



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

	int N, W;
	cin >> N >> W;

	ll w[N], v[N];
	forn(i,N) cin >> w[i] >> v[i];

	ll dp[N+1][100000+1];

	forn(i,N+1) forn(j,100000+1) dp[i][j] = inf;

	forn(i,N+1) dp[i][0] = 0;

	int maxval = 0;

	forn(i,N){
		forn(j,100000+1){
			if(j+1 >= v[i]){
				if(dp[i][j+1 - v[i]] + w[i] <= W){
					maxval = max(maxval, j+1);
					dp[i+1][j+1] = min(min(dp[i+1][j+1], dp[i][j+1-v[i]] + w[i]), dp[i][j+1]);
				}
				else dp[i+1][j+1] = dp[i][j+1];
			}
			else dp[i+1][j+1] = dp[i][j+1];
		}
	}


	cout << maxval;			
}


Measured memory_bytes: 79232
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
#define RAP(i, n) for(ll i=0;i<(n);i++)
#define FOR(i, a, b) for(ll i=(a);i<(b);i++)

int main(){
    ll n, a, count2=0;
    cin >> n;
    map<ll,ll> A;
    RAP(i, n){
        cin >> a;
        A[a]++;
    }
    for(auto itr=A.begin();itr!=A.end();itr++){
        if(itr->second==2){
            count2++;
        }else if(itr->second>1){
            while(1){
                n -= 2;
                itr->second -= 2;
                if(itr->second==1){
                    break;
                }else if(itr->second==2){
                    count2++;
                  	break;
                }
            }
        }
    }
    for(ll i=count2;i>0;i-=2){
        n -= 2;
    }
   
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 6528
//Pranet Verma
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
typedef struct Node* pnode;
#define plus lfsfsfd
#define minus fdsgfsdf
#define prev sdfsd
struct Node {
	long long val;
	pnode l, r;
};
pnode plus, minus;
int n;
long long offset = 0;
long long rmq(pnode u, int x, int y, int l = 1, int r = n) {
	if (x > r or y < l) {
		return INF;
	}
	if (x <= l and r <= y) {
		return u->val;
	}
	int m = (l + r) / 2;
	return min(rmq(u->l, x, y, l, m), rmq(u->r, x, y, m + 1, r));
}
void update(pnode u, int x, int y, long long v, int l = 1, int r = n) {
	if (x > r or y < l) {
		return;
	}
	if (x <= l and r <= y) {
		assert(l == r);
		u->val = v;
		return;
	}
	int m = (l + r) / 2;
	update(u->l, x, y, v, l, m);
	update(u->r, x, y, v, m + 1, r);
	u->val = min(u->l->val, u->r->val);
}
long long rmq(int u) {
	long long o1 = rmq(plus, u, n) - u;
	long long o2 = rmq(minus, 1, u - 1) + u;
	return min(o1, o2);
}
void makeTree(pnode &u, int l, int r) {
	u = new Node{INF, NULL, NULL};
	if (l == r) {
		return;
	}
	int m = (l + r) / 2;
	makeTree(u->l, l, m);
	makeTree(u->r, m + 1, r);
	u->val = min(u->l->val, u->r->val);
}
void init(int a) {
	makeTree(plus, 1, n);
	update(plus, a, a, 0 + a);
	makeTree(minus, 1, n);
	update(minus, a, a, 0 - a);
}
void setValue(int u, long long v) {
	update(plus, u, u, v + u);
	update(minus, u, u, v - u);
}
long long getValue(int u) {
	return rmq(plus, u, u) - u + offset;
}	
long long getMinimum() {
	long long ans = INF;
	for (int i = 1; i <= n; ++i) {
		ans = min(ans, getValue(i));
	}
	return ans;
}
void increaseAll(long long v) {
	offset += v;
}
int main() {
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	int q, a, prev;
	cin >> n >> q >> a >> prev;
	init(a);
	for (int i = 1; i <= q; ++i) {
		int curr;
		cin >> curr;
		long long o1 = rmq(curr);
		long long o2 = getValue(prev) + abs(curr - prev);
		setValue(prev, min(o1, o2) - abs(curr - prev));
		increaseAll(abs(curr - prev));
		prev = curr;
	}	
	cout << getMinimum();
}

Measured memory_bytes: 25216
#include <stdio.h>

int main(void){
    
    int a,b,c;
    int count=0;
    
    scanf("%d%d%d",&a,&b,&c);
    
    for(int i=a;i<=b;i++){
        if(c%i==0){
            count++;
        }
    }
    printf("%d\n",count);
    
    return 0;
}


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

using namespace std;
int main(){
    int d;
    string answer ;
    cin >> d;
    if(d == 25){
        answer = "Christmas";
    }
    else if(d == 24){
        answer = "Christmas Eve";
    }
    else if(d == 23){
        answer = "Christmas Eve Eve";
    }
    else answer = "Christmas Eve Eve Eve";
    
    cout << answer << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}
    void init(int n) { par.assign(n, -1);}
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
main(){
    int N,K;
    cin >> N >> K;
    vector<int> V(N);
    rep(i,0,N)cin >> V[i];
    UnionFind uf(N+1);
    set<int> st;
    rep(i,0,K){
        st.insert(V[i]);
    }
    rep(i,0,N-K){
        st.insert(V[i+K]);
        int mini = *st.begin();
        int maxi = *--st.end();
        if(V[i] == mini && V[i+K] == maxi){
            uf.merge(i, i+1);
        }
        st.erase(V[i]);
    }
    vector<int> accum(N+1), invcnt(N+1);
    rep(i,0,N-1){
        invcnt[i] = V[i] > V[i+1];
    }
    rep(i,0,N-1){
        accum[i+1] = accum[i] + invcnt[i];
    }
    rep(i,0,N-K+1){
        if(accum[i] == accum[i+K-1]){
            uf.merge(i, N);
        }
    }
    //rep(i,0,N-K+1)cout << uf.root(i) << endl;
    set<int> st2;
    rep(i,0,N-K+1)st2.insert(uf.root(i));
    cout << st2.size() << endl;

}

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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main() {
    int n, r;
    cin >> n >> r;
    if(n >= 10) {
        cout << r << endl;
    } else {
        cout << r + (100 * (10 - n)) << endl;
    }
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  while(1){
    int w,h;
    scanf("%d%d", &h, &w);

    if(w==0) break;

    char map[h][w];
    int done[h][w];

    int i,j;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
       done[i][j] = 0;
       scanf(" %c", &map[i][j]);
       //printf("%c", map[i][j]);
      }
      //puts("");
    }

    int x,y;
    x = y = 0;
    
    while(map[x][y] != '.' && !done[x][y]){
      done[x][y] = 1;
      if(map[x][y] == '>') y++;
      else if(map[x][y] == 'v') x++;
      else if(map[x][y] == '^') x--;
      else if(map[x][y] == '<') y--;
    }

    if(done[x][y]) printf("LOOP\n");
    else printf("%d %d\n", y, x);
  }
  return 0;
}

Measured memory_bytes: 0
#include<math.h>
#include<stdio.h>
int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	int y = m;
	while (y)
	{
		y /= 10;
		n *= 10;
	}
	int k = sqrt(n + m);
	if (k*k== (n + m))printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
w, h, n = [int(i) for i in input().split()]
xmin, xmax = 0, w
ymin, ymax = 0, h
for _ in range(n):
  x, y, a = [int(i) for i in input().split()]
  if a == 1:
    xmin = max(x, xmin)
  elif a == 2:
    xmax = min(x, xmax)
  elif a == 3:
    ymin = max(y, ymin)
  elif a == 4:
    ymax = min(y, ymax)
print(max(xmax - xmin, 0) * max(ymax - ymin, 0))

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
using namespace std;

int yaku(int n,int m){
    if(n%m==0){
        return m;
    }
    return yaku(m,n%m);
}


int main(){
    int n,m;
    cin>>n>>m;
    m/=yaku(n,m);
    int ans=1;
    for(int i=2;i*i<=m;i++){
        if(m%i==0){
            ans*=i;
            while(m%i==0){
                m/=i;
            }
        }
    }
    ans*=m;
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N,M;
int A[305][305];
int idx[305];
bool del[305];
int cnt[305];
bool check(int k){
	memset(idx,0,sizeof(idx));
	memset(del,false,sizeof(del));
	while(1){
		memset(cnt,0,sizeof(cnt));
		for(int i=0;i<N;i++){
			cnt[A[i][idx[i]]]++;
		}
		int mx = -1;
		for(int i=0;i<M;i++){
			if(!del[i]&&(mx==-1||cnt[mx]<cnt[i]))mx = i;
		}
		assert(mx!=-1);
		if(cnt[mx]<=k)return true;
		del[mx]=true;
		for(int i=0;i<N;i++){
			while(idx[i]<M&&del[A[i][idx[i]]])idx[i]++;
			if(idx[i]==M)return false;
			assert(!del[A[i][idx[i]]]);
		}
	}
}
int main(){
	cin >> N >> M;
	for(int i=0;i<N;i++){
		for(int j=0;j<M;j++){
			cin >> A[i][j];
			A[i][j]--;
		}
	}
	int l = 0,r = N;
	while(r-l>1){
		int mid = (l+r)/2;
		if(check(mid))r=mid;
		else l=mid;
	}
	cout << r << endl;
	return 0;
}

Measured memory_bytes: 640
// Why am I so dumb? :c
#include<bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

const int MAXN = (int)1e5 + 5;

ll arr[MAXN];

int n;

void solve() {
	scanf("%d", &n);
	ll sum = 0, k = n * (n + 1ll) / 2;

	for (int i = 1; i <= n; ++i) {
		scanf("%lld", &arr[i]);
		sum += arr[i];
	}

	if (sum % k) {
		printf("NO\n");
		return;
	}

	sum /= k;

	{
		vector<ll> tmp(n + 1);
		arr[n + 1] = arr[1];

		for (int i = 1; i <= n; ++i) {
			tmp[i] = arr[i + 1] - arr[i];
		}

		for (int i = 1; i <= n; ++i) {
			arr[i] = tmp[i];
		}         
	}

	for (int i = 1; i <= n; ++i) {
		arr[i] -= sum;
	}

	ll cur = 0;

	for (int i = 1; i <= n; ++i) {
		if (arr[i] > 0) {
			printf("NO\n");
			return;
		}

		ll x = -arr[i];

		if (x % n) {
			printf("NO\n");
			return;
		}

		cur += x / n;
	}

	if (cur != sum) {
		printf("NO\n");
		return;
	}         

	printf("YES\n");
}

int main() {
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

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

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

    string s;
    cin >> s;
    bool L = false, R = false;
    rep(i, s.size())
    {
        if (i % 2 == 0 && s[i] == 'L')
        {
            cout << "No" << endl;
            return 0;
        }
        if (i % 2 == 1 && s[i] == 'R')
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

void solve(){
    int n;
    cin>>n;
    
    map<pair<int,int>,int> mp;
    
    for(int i=0;i<n;i++){
        double d;
        cin>>d;
        long x=llround(d * 1e9);
        
        int c5=0;
        while(x%5==0) {c5++;x=x/5;}
        
        int c2=0;
        while(x%2==0) {c2++;x=x/2;}
        
        mp[{c2,c5}]++;
    }
    
    ll ans=0;
    
    for(auto m1:mp){
        for(auto m2:mp){
            if(m2.first.first+m1.first.first>=18 && m2.first.second+m1.first.second>=18){
                if(m1.first<m2.first){
                    ans+=(ll) m2.second*m1.second;
                }
                else if(m1.first==m2.first){
                    ans+=(ll) (((ll) m2.second-1)*m2.second)/2;
                }
            }
        }
    }
    cout<<ans;
}

int main() {
	// your code goes here
	//freopen("inptmp0.txt","r",stdin);
	int T;
	
	//cin>>T;
	T=1;
	while(T--){
	    solve();
	}
	return 0;
}


Measured memory_bytes: 3816
//{{{
#include <bits/stdc++.h>
using namespace std;
//types
typedef long long ll;
typedef pair<int,int> pii;
//input
bool SR(int &_x){return scanf("%d",&_x)==1;}bool SR(ll &_x){return scanf("%lld",&_x)==1;}
bool SR(double &_x){return scanf("%lf",&_x)==1;}bool SR(char *_s){return scanf("%s",_s)==1;}
bool RI(){return true;}
template<typename I,typename... T>bool RI(I &_x,T&... _tail){return SR(_x) && RI(_tail...);}
//output
void SP(const int _x){printf("%d",_x);}void SP(const ll _x){printf("%lld",_x);}
void SP(const double _x){printf("%.16lf",_x);}void SP(const char *s){printf("%s",s);}
void PL(){puts("");}
template<typename I,typename... T>void PL(const I _x,const T... _tail)
{SP(_x);if(sizeof...(_tail)) putchar(' ');PL(_tail...);}
//macro
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<int(n);i++)
#define REP1(i,a,b) for(int i=(a);i<=int(b);i++)
#define PER1(i,a,b) for(int i=(a);i>=int(b);i--)
#define pb push_back
#define mkp make_pair
#define F first
#define S second
//debug
#ifdef darry140
template<typename A,typename B>
ostream& operator <<(ostream&_s, const pair<A,B> &_p){return _s<<"("<<_p.F<<","<<_p.S<<")";}
template<typename It>
ostream& _OUTC(ostream &_s,It _b,It _e)//container
{
    _s<<"{";
    for(auto _it=_b;_it!=_e;_it++) _s<<(_it==_b?"":" ")<<*_it;
    _s<<"}";
    return _s;
}
template<typename A,typename B>
ostream& operator <<(ostream&_s, const map<A,B> &_c){return _OUTC(_s,ALL(_c));}
template<typename T>
ostream& operator <<(ostream&_s, const set<T> &_c){return _OUTC(_s,ALL(_c));}
template<typename T>
ostream& operator <<(ostream&_s, const vector<T> &_c){return _OUTC(_s,ALL(_c));}
template<typename I>
void _DOING(const char *_s,I&& _x){cerr<<_s<<"="<<_x<<endl;}//without ','
template<typename I,typename... T>
void _DOING(const char *_s,I&& _x,T&&... _tail)//with ','
{
    int _c=0;
    static const char _bra[]="({[";
    static const char _ket[]=")}]";
    while(*_s!=',' || _c!=0)//eg. mkp(a,b)
    {
        if(strchr(_bra,*_s)) _c++;
        if(strchr(_ket,*_s)) _c--;
        cerr<<*_s++;
    }
    cerr<<"="<<_x<<", ";
    _DOING(_s+1,_tail...);
}
#define debug(...) do{\
    fprintf(stderr,"%s:%d - ",__PRETTY_FUNCTION__,__LINE__);\
    _DOING(#__VA_ARGS__,__VA_ARGS__);\
}while(0)
#else
#define debug(...)
#endif
//}}}

int main()
{
    int n;RI(n);
    ll sum=0;
    while(n--)
    {
        int x;RI(x);
        sum+=x;
    }
    PL(sum%2==0?"YES":"NO");
    return 0;
}




































/*End Of File*/




Measured memory_bytes: 764