akhauriyash/Code-Regression huggingface dataset:
def main():
    import sys
    input = sys.stdin.readline
    H,W = map(int,input().split())
    N = int(input())
    A = list(map(int,input().split()))
    ans = [[0]*W for i in range(H)]
    x = 0
    y = 0
    flag = 0
    for i in range(N):
        color = i+1
        num = A[i]
        for j in range(num):
            ans[y][x] = color
            if flag==0:
                x+=1
                if x==W:
                    x = W-1
                    flag = 1
                    y += 1
            else:
                x-=1
                if x==-1:
                    x = 0
                    flag=0
                    y += 1
    for i in range(H):
        print(*ans[i])
    
main()

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ar array

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

const int maxn = 2e5 + 5;

signed main(void)
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    freopen("A.INP", "r", stdin);
    freopen("A.OUT", "w", stdout);
  #endif // LOCAL
  int a, va, b, vb, t;
  cin >> a >> va >> b >> vb >> t;
  if(a == b){
    cout << "YES";
    return 0;
  }
  if(va <= vb){
    cout << "NO";
    return 0;
  }
  function<int(int, int)>Ceil = [&](int x, int y)
  {
    if(x % y == 0) return x / y;
    return x / y + 1;
  };
  int need;
  if(b > a) need = Ceil(b - a, va - vb);
  else need = Ceil(a - b, va - vb);
  if(need > t){
    cout << "NO";
  }
  else{
    cout << "YES";
  }
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
signed main()
{
int x=0,y=0,z=0,w=0,n=0,m=0,a=0,b=0;
string s="",t="";
std::cin >> s>>t;
std::cout << t<<s << '\n';

}


Measured memory_bytes: 256
import math,bisect
n,d,a = map(int,input().split())
lst1 = [list(map(int,input().split())) for i in range(n)]
lst1.sort()

#解法2 - imos法
"""
単純に座標に対してimos法を行うと、座標の制約は10**9なので間に合わない。
process1
そこで、各モンスターに対して、そのモンスターを左端で攻撃を行った際、右側の巻き込めるモンスターのインデックスを
保存するリストを作る。
process2
これにより、imosのテーブルはn+1個で答えを求めることができる。
また、imosの累積和は順次求めていく感じになる。
"""
x = []
for i in lst1:
    x.append(i[0])

#process1
index = 0
reach = []
for i in range(n):
    index = bisect.bisect_right(x,lst1[i][0]+2*d)
    reach.append(index)

#process2
ans = 0
imos = [0]*(n+1) #その座標に効いている魔法の回数(ダメージ量ではない)

for i in range(n):
    if imos[i]*a < lst1[i][1]: #ダメージが足りないなら
        need = math.ceil((lst1[i][1]-imos[i]*a)/a)
        imos[i] += need
        imos[reach[i]] -= need #届かなくなったとこでマイナス
        ans += need
    imos[i+1] += imos[i] #累積和を逐一とる

print(ans)

Measured memory_bytes: 111880
#include<bits/stdc++.h>
using namespace std;
#define int  long long 
#define speedrap ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int be(int a,int b,int mod) {if(b == 0) return 1; if(b%2 == 1) return (a*be(a,b-1,mod))%mod; else return (be(a,b/2,mod)*be(a,b/2,mod))%mod;}
const int mod = 1e9+7;
#define PI 3.14159265359
#define pf push_front
#define pb push_back
#define bitcount __builtin_popcount
#define sc(a) scanf("%d", &a);
#define sz(s) (int)s.size()
#define eb emplace_back
#define pf push_front
#define mkp(x,y) make_pair(x,y)
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
const int siz = 2*(2500 + 1);
const int logi = 21;
const double epsilon = 1e-6;
int prime[siz];
bool cmp(const int &a,const int &b)
{
  return (abs(a-b)>1);
}

signed main()
{
	
	speedrap
	int t;
	t = 1;
	//cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		double n1 = (double) n ;
		n1 *= 2.0;
		n1 *= PI;
		std::cout << std::fixed;
    std::cout << std::setprecision(2);
    std::cout << n1;
}
}

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

typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

int main(void)
{
    string s;
    cin >> s;
    ll cta = 0;
    vector<pair<char, ll>> v;
    char tmp = s[0];
    rep(i, 0, s.length() + 1)
    {
        if (tmp != s[i])
            v.push_back({s[i - 1], cta}), cta = 1, tmp = s[i];
        else
            cta++;
    }
    ll ans = 0;

    if (v[0].first == '<')
    {

        for (ll i = 0; i < v.size(); i += 2)
        {
            ll a, b = 0;
            a = v[i].second - 1;
            if (i + 1 < v.size())
                b = v[i + 1].second - 1;
            ans += max(a + 1, b + 1) + (a + 1) * a / 2 + (b + 1) * b / 2;
        }
    }
    else
    {
        ans += (v[0].second + 1) * v[0].second / 2;
        for (ll i = 1; i < v.size(); i += 2)
        {
            ll a, b = 0;
            a = v[i].second - 1;
            if (i + 1 < v.size())
                b = v[i + 1].second - 1;
            ans += max(a + 1, b + 1) + (a + 1) * a / 2 + (b + 1) * b / 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 8116
from collections import Counter
_, *lst = map(int, open(0).read().split())
c = Counter(lst).items()
stick2 = [i for i, j in c if j > 1]
stick4 = [0] + [i for i, j in c if j > 3]
max4 = max(stick4)
max4 *= max4
if len(stick2) > 1:
  stick2.sort()
  print(max(stick2[-1] * stick2[-2], max4))
else:
  print(max(0, max4))


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

int main(){
	int n;cin>>n;
	int t,a;cin>>t>>a;
	vector<int>h;
	for(int i=0;i<n;i++){
		int x;cin>>x;h.push_back(x);
	}
	double min = 100000;
	int ans;
	for(int i=0;i<h.size();i++){
		if(min>abs(a-t+(0.006 * h[i]))){
			min = abs(a-t+(0.006 * h[i]));
			ans = i+1;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.List;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] a = new int[M];
		int[] b = new int[M];
		sc.fill(a, b);

		List<List<Integer>> root = new ArrayList<>(N);
		for (int i = 0; i < N; i++) {
			root.add(new ArrayList<>());
		}
		for (int i = 0; i < M; i++) {
			root.get(a[i] - 1).add(b[i] - 1);
			root.get(b[i] - 1).add(a[i] - 1);
		}

		Deque<List<Integer>> queue = new ArrayDeque<>();
		queue.add(Arrays.asList(0));
		int count = 0;
		while (!queue.isEmpty()) {
			List<Integer> list = queue.poll();
			if (list.size() == N) {
				count++;
				continue;
			}

			int last = list.get(list.size() - 1);
			for (int next : root.get(last)) {
				if (!list.contains(next)) {
					List<Integer> copy = new ArrayList<>(list);
					copy.add(next);

					queue.add(copy);
				}
			}
		}

		System.out.println(count);
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}

Measured memory_bytes: 23380
#include<iostream>
#include<string.h>
using namespace std;

typedef struct {
    int time;
    char name[11];
} Process;

class queue{
public:
    Process array[50001];
    int head = -1;
    int tail = -1;
    
    void push(int v, char n[11]) {
        tail = (tail + 1) % 50001;
        array[tail].time = v;
        strcpy(array[tail].name, n);
        return;
    }
    
    Process pop() {
        head = (head + 1) % 50001;
        return array[head];
    }
    
    bool empty() {
        if(head == tail) return true;
        else return false;
    }
};

int main() {
    
    queue q;
    
    int n, mt;
    cin>>n>>mt;
    
    char name[11];
    int time;
    for(int i = 0; i < n; i++) {
        cin>>name>>time;
        q.push(time, name);
    }
    

    Process a;
    int num, keika = 0;
    while( !q.empty() ) {
        a = q.pop();
        num = a.time;
        num -= mt;

        if(num <= 0) {
            cout<<a.name<<' '<<keika+(mt+num)<<endl;
            keika += (mt+num);
        } else {
            q.push(num, a.name);
            keika += mt;
        }
    }
    return 0;
}



Measured memory_bytes: 3828
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_142
{
    class E
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] nm = ReadInts();
            int n = nm[0];
            int m = nm[1];
            int[][] abs = new int[m][];
            int[][] cs = new int[m][];
            for (int i = 0; i < m; i++)
            {
                abs[i] = ReadInts();
                cs[i] = ReadInts();
            }
            int[][] vals = new int[m][];
            for(int i = 0; i < m; i++)
            {
                int val = 0;
                for(int j = 0; j < abs[i][1]; j++)
                {
                    val += 1 << (cs[i][j] - 1);
                }
                vals[i] = new int[2] { abs[i][0], val };
            }
            int allPat = 1 << n;
            long[] dp = new long[allPat];
            for (int i = 0; i < allPat; i++) dp[i] = long.MaxValue / 4;
            dp[0] = 0;
            for(int i = 0; i < m; i++)
            {
                for(int j = 0; j < allPat; j++)
                {
                    int next = j | vals[i][1];
                    dp[next] = Min(dp[next], dp[j] + vals[i][0]);
                }
            }
            if (dp[allPat - 1] == long.MaxValue / 4) WriteLine(-1);
            else WriteLine(dp[allPat - 1]);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13268
// Remainder Minimization 2019 - atcoder.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{

	int L, R , minMult = 2019+1;
	cin >> L >> R;
	int to = min(L + 2019, R);
	
 	for (int i = L; i < to; i++) {
		for (int j = i + 1; j <= to; j++) {
			minMult = min(minMult, (i % 2019) * (j % 2019) % 2019) ;
		}
	}
	cout << minMult;
}

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

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var N = Console.ReadLine();
            var answer = N.Contains('7') ? "Yes" : "No";
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 25792
N = int(input()) # 宿泊数
K = int(input()) # 最初のK泊
X = int(input()) # 最初のK泊の料金
Y = int(input()) # K泊 + 1〜の料金

price = min(N, K) * X

if N > K:
    price += (N - K) * Y

print(price)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
vector<long long int> c;
vector<vector<long long int>> hoge;
vector<long long int> ans;
void saiki(long long int now,long long int bef){
  if(now!=0&&hoge.at(now).size()==1){
    ans.at(now)=c.at(now)+ans.at(bef);
    return;
  }
  ans.at(now)=c.at(now);
  if(now!=0) ans.at(now)+=ans.at(bef);
  for(long long int i=0; i<hoge.at(now).size(); i++){
    if(hoge.at(now).at(i)!=bef){
      saiki(hoge.at(now).at(i),now);
    }
  }
}
int main(void){
  long long int n,q;
  cin>>n>>q;
  hoge=vector<vector<long long int>>(n,vector<long long int>(0));
  c.resize(n);
  ans.resize(n);
  for(long long int i=0; i<n-1; i++){
    long long int a,b;
    cin>>a>>b;
    a--;
    b--;
    hoge.at(a).push_back(b);
    hoge.at(b).push_back(a);
  }
  vector<long long int> p(q);
  vector<long long int> x(q);
  for(long long int i=0; i<q; i++){
    cin>>p.at(i)>>x.at(i);
  }
  for(long long int i=0; i<q; i++){
    c.at(p.at(i)-1)+=x.at(i);
  }
  saiki(0,-1);
  for(long long int i=0; i<n; i++){
    cout<<ans.at(i);
    if(i!=n-1){
      cout<<" ";
    }else{
      cout<<endl;
    }
  }
}

Measured memory_bytes: 29840
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;
using MIte = multimap<long, long, greater<long> >::iterator;

struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		if (x >= par.size() || y >= par.size()) {
			return false;
		}
		else {
			int rx = root(x);
			int ry = root(y);
			return rx == ry;
		}
	}
};

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

	int N, M;
	cin >> N >> M;
	vector<int> vp(N, 0);
	vector<int> vx(M, 0);
	vector<int> vy(M, 0);

	rep(i, N) { cin >> vp[i]; vp[i]--; }
	rep(i, M) { cin >> vx[i] >> vy[i]; vx[i]--; vy[i]--; }

	UnionFind uf(N);
	set<int> setidx;
	set<int> setp;
	for (int i = 0; i != M; ++i) {
		uf.unite(vx[i], vy[i]);
	}

	int cnt = 0;
	for (int i = 0; i != N; ++i) {
		if (uf.same(i, vp[i])) {
			cnt++;
		}
	}

	cout << cnt << endl;


	return 0;
}

Measured memory_bytes: 1792
from itertools import combinations_with_replacement
n,m,q = map(int,input().split())
a=[0]*q
b=[0]*q
c=[0]*q
d=[0]*q
for i in range(q):
  a[i],b[i],c[i],d[i] = map(int,input().split())
  
ans = 0      
def dfs(A):
  global ans
  if len(A) >= n:    
    tmp = 0
    for i in range(q):
      if A[b[i]-1] - A[a[i]-1] == c[i]:
        tmp += d[i]
    ans = max(ans,tmp)
  else:
    s = 1
    if len(A)>0:
      s = A[-1]    
    for i in range(s-1,m):
      dfs(A+[i+1])

A = []
dfs(A) 
print(ans)

Measured memory_bytes: 9248
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	vector<int> bricks(n);
	for (int i = 0; i < n; ++i) {
		cin >> bricks[i];
	}

	int curr_idx = 1;
	int broke = 0;
	for (int i = 0; i < n; ++i) {
		if (bricks[i] != curr_idx) {
			++broke;
		} else {
			++curr_idx;
		}
	}

	if (broke == n) {
		cout << "-1\n";
	} else {
		cout << broke << "\n";
	}

	return 0;

}

Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
#define Maxn 100007
#define modp 1000000007
int n;
char s[Maxn];
int cnt[27];
int main()
{
    scanf("%d",&n);
    scanf("%s",s+1);
    for (int i=1;i<=n;i++)
        ++cnt[s[i]-'a'+1];
    int ans=1;
    for (int i=1;i<=26;i++)
        ans=(1LL*ans*(cnt[i]+1))%modp;
    ans=(ans+modp-1)%modp;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3772
#include<iostream>
using namespace std;
int main() {
    int N, L, tmp = 0, ans = 0, min = 100000;
    cin >> N >> L;
    int a[N+1], b[N+1];
    for(int i = 1; i <= N; i++) { 
        a[i] = 0; b[i] = 0;
        a[i] = L + i - 1;
        tmp += a[i];
    }
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            if(i == j) {
                continue;
            }
            b[i] += a[j];
        }
        if(abs(tmp - b[i]) < min) {
            min = abs(tmp - b[i]);
            ans = i;
        }
    }

    cout << b[ans] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;
int main(){
    const double pi =3.14159265358979323;
    
    double r;
    scanf("%lf", &r);
    
    printf("%f %f\n", r*r*pi, 2*r*pi);
   
  
}
    
    




Measured memory_bytes: 3152
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int mINF = 1e9;
const int MOD = 1e9+7;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main(){
    string s;cin >> s;
    string before;
    before += s[0];
    int ans = 1;
    string target;
    for(int i=1;i<s.size();i++){
        target += s[i];
        if(before!=target){
            ans++;
            before = target;
            target = "";
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int N, K;
  cin >> N >> K;
  int a, b;
  if(K > 1){
    a = N - K + 1;
    b = 1;
    cout << a - b << endl;
  }
  else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
using Int = long long;
int main() {
    Int N; cin >> N;
    Int ans = 0;
    for (Int i = 1; i <= N; i++) {
        ans += i * (N - i + 1);
    }
    for (Int i = 0; i < N - 1; i++) {
        Int u, v; cin >> u >> v;
        if (u > v) swap(u, v);
        ans -= u * (N - v + 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
package main

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

func main() {
	N := nextInt()
	M := nextInt()
	A := append(nextInts(M), N+3)
	d := 1000000007
	c := make([]int, N+2)
	posA := 0
	c[1] = 1
	for i := 2; i < N+2; i++ {
		if i == A[posA]+1 {
			posA += 1
			continue
		}
		c[i] = (c[i-1] + c[i-2]) % d
	}
	fmt.Println(c[N+1])
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}

func nextString() string {
	return nextReader()
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func Min(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func Max(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func MinA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Min(s, v)
	}
	return s
}

func MaxA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Max(s, v)
	}
	return s
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


Measured memory_bytes: 3072
n, l = map(int, input().split())
sum = 0
for i in range(l, l + n):
    sum += i
mnabs = 10000000
mn = 10000000
for i in range(l, l + n):
    if mnabs > abs(i):
        mnabs = abs(i)
        mn = i
print(sum - mn)


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

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

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */


int a,b;
int main() {
    cin >> a >> b;
    if(b%a){
        cout << b - a << endl;
    }else{
        cout << a + b << endl;

    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
ll fp(ll base, ll exp)
{
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    if (exp % 2 == 0)
        return (ans * ans);
    else
        return (((ans * ans)) * base);
}
int main()
{
    Hello
    ll x;
    cin >> x;
    vector<pair<ll, ll>> v;
    for(int i = 0; i <= 1000; i++){
        ll numb = fp(i, 5);
        v.push_back({numb, i});
        v.push_back({-numb, -i});
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < (int)v.size(); i++){
        for(int j = 0; j < (int)v.size(); j++){
            if(v[i].first - v[j].first == x)
                return cout << v[i].second << " " << v[j].second, 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3728
import java.util.Scanner;


public class Main {
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		for(;;)
		{
			int a = scanner.nextInt();
			String op = scanner.next();
			int b = scanner.nextInt();
			
			
			int c=0;
			switch(op)
			{
				case "?":
					return;
				case "+":
					c = a+b;
					break;
				case "-":
					c = a-b;
					break;
				case "*":
					c = a*b;
					break;
				case "/":
					c = a/b;
					break;
			}
			System.out.println(c);
		}
		
	}
}

Measured memory_bytes: 26164
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N, K;
  cin >> N >> K;
  long limit = (N-1) * (N-2) / 2;
  if (K > limit) {
    cout << -1 << endl;
    return;
  }
  long rest = limit - K;
  cout << rest + N - 1  << endl;
  for (long i = 1; i <= N; i++) for (long j = i + 1; j <= N; j++) {
    if (i == 1) cout << i << " " << j << endl;
    else if (rest) {
      cout << i << " " << j << endl;
      rest --;
    }
  }
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  char a[20];
  cin >> a;
  a[5]=' ';
  a[13]=' ';
  cout << a;
  return 0;
  if(a==a){
    cout << 1;
  }
  else if(a==a){
    cout << 2;
  }
  else{
    cout << 4;
  }
}


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


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





Measured memory_bytes: 1024
/**
*    author:  yuya1234
*    created: 02.08.2020 21:02:01
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SORT(x) sort(x.begin(),x.end())
#define SORTD(x) sort(x.rbegin(),x.rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define SZ(x) ll(x.size())

#define MEMSET(v, h) memset((v), h, sizeof(v))

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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

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

  ll n,d;
  cin>>n>>d;

  ll x[n],y[n];
  REP(i,n)cin>>x[i]>>y[i];

  int cnt=0;
  REP(i,n)
  {
    if(x[i]*x[i]+y[i]*y[i]<=d*d)cnt++;
  }

  cout<<cnt<<endl;

  return 0;
}

Measured memory_bytes: 6760
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 10000000000
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
typedef pair<double, double> doup;

int main(void) {
    string s, t;
    cin >> s;
    cin >> t;
    
    s=s+s;
    if(s.find(t)!= std::string::npos) {
        cout << "Yes" << endl;
    }else
        cout << "No" << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));



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

	int N;
	cin >> N;

	cout << 800 * N - N / 15 * 200 << endl;
	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  ll n;
  cin >> n;
  ll ans = 1e18;
  for (ll i = 1; i * i <= n; ++i) {
    if (n % i) continue;
    ll j = n / i;
    ans = min(ans, (i - 1) + (j - 1));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
s = input()
count = 0
for i in range(len(s)):
    if (i+1)%2 == 0:
        if s[i] == 'L' or s[i] == 'U' or s[i] == 'D':
            count += 1
    else:
        if s[i] =='R' or s[i] == 'U' or s[i] == 'D':
            count += 1
if len(s) == count:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  vll p(n);
  ll x = 0, y = 0, z = 0;
  for (ll i = 0; i < n; i++) {
    cin >> p[i];
    if (p[i] <= a) x++;
    else if (p[i] <= b) y++;
    else z++;
  }
  cout << min({x, y, z}) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

int main()
{
	std::string S, T;
	std::cin >> S;
	std::cin >> T;
	int ls = S.length();
	int lt = T.length();
	int res = lt;
	for (int i=0; i<=ls-lt; i++) {
		int diff = 0;
		for (int j=0; j<lt; j++) {
			if (S[i+j] != T[j]) diff++;
		}
		res = std::min(res, diff);
	}
	std::cout << res << std::endl;
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
#define rep(i, n) for (int i = 0; i < (n); i++)
using P=pair<int,int>;
int main() {
    ll a,b,c;cin>>a>>b>>c;
    if(c-a-b<=0){
        cout<<"No"<<endl;
    }else{
        if(c*c+a*a+b*b-2*a*b-2*a*c-2*b*c>0){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
}


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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	string S=in<string>();
	vector<vector<int>> P(26);
	int N=S.size();
	REP(i,N){
		P[S[i]-'a'].push_back(i);
	}

	int minV=1<<30;
	REP(i,26){
		if(P[i].empty()) continue;
		
		int maxU=0,left=1<<30;
		for(int j=0,ej=P[i].size();j<ej;j++){
			int right = min(left,(N-P[i][ej-1-j])-1);
			left = P[i][ej-1-j];
			if(ej-1-j>0){
				left = min(left,P[i][ej-1-j]-P[i][ej-2-j]-1);
			}
			maxU = max(maxU,max(left,right));
		}
		minV=min(minV,maxU);
	}
	out(minV);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#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 REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define pr(a) cout << (a) << endl
#define PR(a,b) cout << (a) << " " << (b) << endl
#define F first
#define S second
typedef long long ll;
typedef pair<int,int> P;
const int MAX=1000000001;
const ll MAXL=1000000000000000001LL;
const ll mod=1000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int size(int n) {
  if(n<=60) return 0;
  if(n<=80) return 1;
  if(n<=100) return 2;
  if(n<=120) return 3;
  if(n<=140) return 4;
  if(n<=160) return 5;
  return 6;
}

int weight(int n) {
  if(n<=2) return 0;
  if(n<=5) return 1;
  if(n<=10) return 2;
  if(n<=15) return 3;
  if(n<=20) return 4;
  if(n<=25) return 5;
  return 6;
}

int main() {
  int a[7]={600,800,1000,1200,1400,1600,0};
  int n;
  while(cin >> n && n) {
    int ans=0;
    rep(i,n) {
      int x,y,h,w;
      cin >> x >> y >> h >> w;
      ans+=a[max(size(x+y+h),weight(w))];
    }
    pr(ans);
  }
  return 0;
}


Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
  int n, total;
  cin >> n >> total;
  
  int min = std::numeric_limits<int>::max();
  
  for (int i=0; i<n; ++i)
  {
    int v;
    cin >> v;
    
    total -= v;
    
    if (v < min) min = v;
  }
  
  int cnt = n;
  
  cnt += total / min;
  
  cout << cnt << endl;
}

Measured memory_bytes: 256
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <bits/stdc++.h>

using namespace std;

#define POW2(X) (1<<(X))
#define CKBIT(S,X) (((S)&POW2(X))!=0)

template<class T> inline void nlmin(T &a,T b){ a=min(a,b); }
template<class T> inline void nlmax(T &a,T b){ a=max(a,b); }
template<class T> inline T sqr(T x){ return x*x; }
#define SIZE(A) ((int)A.size())
#define LENGTH(A) ((int)A.length())

#define PB(X) push_back(X)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>(b);--i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(),A.end()
template<class T> int CMP(T a[],const T b[],int n) { return memcmp(a,b,n*sizeof(T)); }
template<class T> void COPY(T a[],const T b[],int n) { memcpy(a,b,n*sizeof(T)); }
template<class T> void SET(T a[],int val,int n) { memset(a,val,n*sizeof(T)); }
//using uint=unsigned int;
typedef long long int64;
//using uint64=unsigned long long;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VII;
// using VD=vector<double>;
const int kmod = 1000000007;


int main() {
	string s, t;
	while (cin >> s >> t) {
		int n = LENGTH(s);
		int m = LENGTH(t);
		VII dp(n + 1, VI(m + 1, 0));
		FOR (i, 1, n + 1) FOR (j, 1, m + 1) {
			if (s[i - 1] == t[j - 1]) 
				dp[i][j] = dp[i-1][j-1] + 1;
			else
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
		}

		string ret = "";
		int i = n, j = m;
		while (dp[i][j] > 0) {
			if (s[i - 1] == t[j - 1]) {
				ret = s[i -1] + ret;
				i--, j--;
			}
			else {
				if (dp[i][j] == dp[i-1][j]) i--;
				else j--;
			}
		}
		cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 35584
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A_sum = [0]
B_sum = [0]
for i in range(N):
    A_sum.append(A_sum[-1] + A[i])
for i in range(M):
    B_sum.append(B_sum[-1] + B[i])

ans = 0
j_max = M
for i in range(N+1):
    for j in range(j_max, -1, -1):
        time = A_sum[i] + B_sum[j]
        if time > K:
            continue
        j_max = j
        ans = max(i + j, ans)
        break
print(ans)

Measured memory_bytes: 48680
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;

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

	int rank[128];
	for(int i = 2; i <= 9; ++i)
		rank[i + '0'] = i;

	rank['T'] = 10;
	rank['J'] = 11;
	rank['Q'] = 12;
	rank['K'] = 13;
	rank['A'] = 14;

	string cards[4][13];

	for(char trump; cin >> trump, trump != '#';) {
		for(int i = 0; i < 4; ++i)
			for(int j = 0; j < 13; ++j)
				cin >> cards[i][j];

		int win[2] = {};
		int first = 0;
		for(int i = 0; i < 13; ++i) {
			int mx = 0, winner;
			char led = cards[first][i][1];
			for(int j = 0; j < 4; ++j) {
				const int player = (first + j) % 4;
				const string& card = cards[player][i];
				int score = rank[card[0]];
				if(card[1] == trump)
					score += 100;

				else if(card[1] == led)
					score += 50;

				if(mx < score) {
					mx = score;
					winner = player;
				}

			}

			++win[winner & 1];
			first = winner;
		}

		if(win[1] > win[0])
			cout << "EW " << win[1] - 6 << endl;
		else
			cout << "NS " << win[0] - 6 << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1200
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#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 SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#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)
int dp[1050][1050];
int N,M;
int C[1050],D[1050];
int main()
{
	for(int i=0;i<1050;i++)
	{
		for(int j=0;j<1050;j++)
		{
			dp[i][j]=INF;
		}
	}
	cin >> N >> M;
	for(int i=0;i<N;i++)cin >> D[i];
	for(int i=0;i<M;i++)cin >> C[i];
	dp[0][0]=0;
	for(int i=0;i<M;i++)
	{
		for(int j=0;j<N;j++)
		{
			if(dp[i][j]==INF)continue;
			dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]+C[i]*D[j]);
			dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
		}
	}
	int ans = INF;
	for(int i=0;i<=M;i++)ans = min(ans,dp[i][N]);
	cout << ans << endl;
	return 0;
}

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

int main() {
  long long N;
  map<long long, long long> m, m2;
  cin >> N;
  for (long long i = 0; i < N; i++) {
    long long a;
    cin >> a;
    if (m.count(i+a) == 0) {
      m[i+a] = 1;
    } else {
      m[i+a]++;
    }
    if (m2.count(i-a) == 0) {
      m2[i-a] = 1;
    } else {
      m2[i-a]++;
    }
  }
  long long sum = 0;
  for (auto it = m.begin(); it != m.end(); it++) {
    if (m2.count(it->first) != 0) sum += it->second * m2[it->first];
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 26724
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,x,y,a=1,b=1,d;
	scanf("%lld",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld%lld",&x,&y);
		d=max(a/x+(a%x!=0),b/y+(b%y!=0));
		a=d*x;b=d*y;
	}
	printf("%lld",a+b);
	return 0;
}

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

int main(void)
{
	char num[1001];
	int sum,len,i;
	
	while(1) {
		gets(num);
		if(num[0] == '0') break;
		sum = 0;
		len = strlen(num);
		for (i=0; i<len; i++) {
			sum += num[i] - '0';
		}
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

Int n, ans;
vector<Int> p;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	p.resize(n);
	for(auto &i:p) cin >> i;
	for(Int i=1; i<n-1; ++i){
		vector<Int> v({p[i-1], p[i], p[i+1]});
		sort(v.begin(), v.end());
		if(p[i] == v[1]){
			++ans;
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Created by khrom on 2017/06/14.
 */
public class Main {
    public static void main(String[] args) {
        double r = new Scanner(System.in).nextDouble();
        System.out.printf("%.6f %.6f", Math.PI * r * r, 2 * Math.PI * r);
    }
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;

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

  if(x>=30)cout << "Yes";
  else cout << "No";
}


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

int main()
{
  int N;
  cin >> N;
  vector<long long> a(N);
  for (int i = 0; i < N; ++i)
    cin >> a[i];
  long long res = 0, cur_sum = 0;
  for (int i = 0; i < N;)
  {
    int j = i;
    while (j < N && a[j])
      cur_sum += a[j++];
    res += cur_sum / 2;
    cur_sum = 0;
    i = j + 1;
  }
  cout << res << endl;
}

Measured memory_bytes: 1024
#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 <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;
typedef complex<double> P;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 1000000007

//AOJ 2335
LL fact[222222];
LL invfact[222222];

LL extgcd(LL a, LL b, LL &x, LL &y){
	LL d = a;
	if(b){
		d = extgcd(b, a % b, y, x);
		y -= a/b * x;
	}
	else x = 1, y = 0;
	return d;
}

LL mod_inverse(LL a, LL m){
	LL x, y;
	extgcd(a, m, x, y);
	return (m + x%m) % m;
}

LL comb(int p, int q){
	LL ret=fact[p];
	ret *= invfact[q];
	ret %= MOD;
	ret *= invfact[p-q];
	ret %= MOD;
	return ret;
}

LL f(int a, int b){
	LL ret = fact[2*a+b]*(b+1)%MOD;
	ret*=invfact[a];
	ret%=MOD;
	ret*=invfact[a+b+1];
	ret%=MOD;
	return ret;
}

int main(){
	int n,m,k;
	invfact[0]=fact[0]=invfact[1]=fact[1]=1;
	FOR(i,2,222222){
		fact[i] = (fact[i-1]*i)%MOD;
		invfact[i] = (invfact[i-1]*mod_inverse(i,MOD))%MOD;
	}
	cin>>n>>m>>k;
	LL ret=0;
	REP(i,k+1){
		LL tmp = comb(2*k+n+m, 2*i+n);
		tmp *= f(i,n);
		tmp %= MOD;
		tmp *= f(k-i,m);
		tmp %= MOD;
		ret += tmp;
		ret %= MOD;
	}
	cout << ret << endl;
	return 0;
}

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


int main() {

    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    int ans = 0;
    for (int i = 0; i < 1000; ++i) {
         rep(k,n) {
            if (a[k] % 2 != 0) {
                cout << ans << endl;
                return 0;
            }
        }
        rep(j,n) {
            a[j] /= 2;
        }
        ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
d = list(c.values())
if (n % 2 == 1 and c[0] == 1 and d.count(2) == (n-1)//2) or (n % 2 == 0 and d.count(2) == n//2):
    print(pow(2, n//2, 10**9+7))
else:
    print(0)

Measured memory_bytes: 20712
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long N;cin>>N;
    long long ans=0;
    vector<long long>L(N);
    for(long long i=0;i<N;i++){
        cin>>L[i];
    }
    for(long long i=0;i<N;i++){
        for(long long l=i+1;l<N;l++){
            for(long long m=l+1;m<N;m++){
                if(L[i]!=L[l]&&L[i]!=L[m]&&L[l]!=L[m]){
                    vector<long long>tmp(3);
                    tmp[0]=L[i];tmp[1]=L[l];tmp[2]=L[m];
                    sort(tmp.begin(),tmp.end());
                    if(tmp[2]<tmp[0]+tmp[1]){
                        ans++;                        
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3632