akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define var auto
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX_ITEM = 10e5+10;
ll dp[MAX_ITEM] = {0};

int main() {
  int n;
  cin >> n;
  int h[n];
  rep(i,n) {
    cin >> h[i];
  }

  // 最小化問題なので INF で埋める
  rep(i,MAX_ITEM) dp[i] = INF;
  // 初期値はゼロ
  dp[0] = 0;

  // 足場文まわす
  rep(i,n) {
    chmin(dp[i+1], dp[i] + abs(h[i+1] - h[i]));
    chmin(dp[i+2], dp[i] + abs(h[i+2] - h[i]));
  }
  
  cout << dp[n-1] << endl;
  return 0;
}


Measured memory_bytes: 8448
N = int(input())
jobs = []
for _ in range(N):
    a, b = map(int, input().split())
    jobs.append((a, b))

jobs.sort(key=lambda x: x[1])
t = 0
for a, b in jobs:
    t += a
    if t <= b:
        continue
    else:
        print("No")
        break
else:
    print("Yes")


Measured memory_bytes: 31860
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn=2050;
int pre[maxn][maxn],heng[maxn][maxn],shu[maxn][maxn];
bool map[maxn][maxn];
int n,m,q;
int main(){
	scanf("%d%d%d",&n,&m,&q);
	for(register int i=1;i<=n;i++){
		char s[maxn];
		scanf("%s",s);
		for(register int j=1;j<=m;j++){
			map[i][j]=s[j-1]-'0';
			pre[i][j]=pre[i-1][j]+pre[i][j-1]-pre[i-1][j-1]+map[i][j];
			heng[i][j]=heng[i-1][j]+heng[i][j-1]-heng[i-1][j-1];
			shu[i][j]=shu[i-1][j]+shu[i][j-1]-shu[i-1][j-1];
			if(!map[i][j])continue;
			if(map[i][j]==map[i-1][j])heng[i][j]++;
			if(map[i][j]==map[i][j-1])shu[i][j]++;
		}
	}
	for(register int t=1,x1,y1,x2,y2;t<=q;t++){
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		int toth=heng[x2][y2]-heng[x1][y2]-heng[x2][y1-1]+heng[x1][y1-1];
		int tots=shu[x2][y2]-shu[x1-1][y2]-shu[x2][y1]+shu[x1-1][y1];
		int tot=pre[x2][y2]-pre[x1-1][y2]-pre[x2][y1-1]+pre[x1-1][y1-1];
		printf("%d\n",tot-toth-tots);
	}
}

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

using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s0, s1, s2;
	
	cin >> s0 >> s1 >> s2;
	
	cout<< s0[0] << s1[0] << s2[0] << endl;
	
	return 0;
}


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

int main() {
	string s;
	cin >> s;
	int k = (s.length() + 1) / 2;
	char c = s[k-1];
	while(k < s.length()) {
		if(s[s.length()-k-1] == c && s[k] == c) k++;
		else break;
	}
	cout << k << endl;
	return 0;
}


Measured memory_bytes: 512
line = input()
List = [int(line[x]) for x in range(4)]
A,B,C,D = List
List_ans = []

for i in range(8):
  s = A
  List_mark = []
  for j in range(3):
    if ((i>>j) & 1)== 0:
      s = s - List[-(j+1)]
      x_j = '-'
    else:
      s = s + List[-(j+1)]
      x_j = '+'
    List_mark.append(x_j)
  if s ==7:
    List_ans.append(List_mark)

x = List_ans[0]
print(str(A)+x[-1]+str(B)+x[-2]+str(C)+x[-3]+str(D)+'=7')
  

Measured memory_bytes: 3188
#include <bits/stdc++.h>
typedef long long ll;
#define inf 9223372036854775807
#define fast ios::sync_with_stdio(0);cin.tie(0);
using namespace std;
int main(){
    fast;
    int s, w;
    cin>>s>>w;
    if(w>=s){
        cout<<"unsafe";
    }
    else{
        cout<<"safe";
    }
}

Measured memory_bytes: 3644
S = input().replace('+x', '+1x').replace('-x', '-1x').replace('^', '**').replace('x', '*1*(x)')[1:]
for i in range(2000, -2001, -1):
    if i == 0: continue

    T = S.replace('x', str(i))
    #print(T, eval(T))
    if eval(T) == 0:
        print('(x{:+})'.format(-i), end='')
else:
    print()



Measured memory_bytes: 5584
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
typedef long long ll;
const ll MAX=510000;
const ll mod = 1e9 + 7;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,D,Q,K,R,W,H,P,L,G;
ll ans;
string S,T;
ll h[101010];
ll y[101010];
ll a[201010];
ll c[101010];
ll k[101010];
ll b[201010];
ll d[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll l[101010];
ll r[101010];
ll v[101010];
ll s[101010];
ll x[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
struct Edge{
	ll to,cost;
	 Edge(ll to, ll cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	vector<ll> size;
    UnionFind(ll N) : par(N),size(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
		for(ll i = 0; i < N; i++) size[i] = 1;
    }

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

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

    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};
bool IsOK(ll len){
        map<string,ll> m;
        rep(i,0,N){
            if(m[S.substr(i,len)]==0){
                m[S.substr(i,len)]=i+len;
            }else{
                if(i>=m[S.substr(i,len)]){
                    return true;
                }
            }
        }
        return false;
}
int main(){
    cin>>N;
    ans =N;
    rep(i,1,sqrt(N)+1){
        if(N%i ==0){
            ans = min(i+N/i-2,ans);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<string,int>num;
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		string s;
		cin>>s;
		num[s]++;
	}
	printf("AC x %d\n",num["AC"]);
	printf("WA x %d\n",num["WA"]);
	printf("TLE x %d\n",num["TLE"]);
	printf("RE x %d\n",num["RE"]);
	return 0;
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e12;
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) cin >> a.at(i);

    vector<long long> v(n+1, 0);
    for(int i = 0; i < n; ++i) v.at(i+1) = v.at(i) + a.at(i);
    vector<long long> w(n+1, 0);
    for(int i = 0; i < n; ++i) w.at(i+1) = w.at(i) + max(a.at(i), 0);

    long long ans = -INF;
    for(int i = 0; i+k <= n; ++i) {
        long long tmp = w.at(n);
        tmp += max(v.at(i+k) - v.at(i), (long long)0);
        tmp -= w.at(i+k) - w.at(i);
        ans = max(ans, tmp);
    }

    cout << ans << endl;
}

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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
#define ALL(v) (v).begin(), (v).end()

//π M_PI
//deg = rad*180/M_PI

int main() {
    ll h, a;
    cin >> h >> a;
    ll ans = 0;
    while ( h > 0 ) {
        h -= a;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
 int min=1000000,max=-1000000;

 int n,a;
 cin >> n;
 long i=0;
 for(int j=1;j<=n;++j){
  cin >> a;
  if(a<min) min=a;
  if(a>max) max=a;
 
  i+=a;
 }
cout << min <<" " << max << " " << i << endl;

return 0;
}
  

Measured memory_bytes: 3088
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    final int NMAX = 1000;
    final int MMAX = 2000;
    final long INF = Long.MAX_VALUE;
    int[] a = new int[MMAX];
    int[] b = new int[MMAX];
    long[] c = new long[MMAX];

    for (int i = 0; i < M; i++) {
      a[i] = sc.nextInt();
      b[i] = sc.nextInt();
      c[i] = sc.nextLong();
      c[i] = -c[i]; //スコア逆
    }
    long ans = bellmanFord(a,b,c,N,M);

    if(ans == -INF) System.out.println("inf");
    else System.out.println(-ans);
  }

  public static long bellmanFord(int[] a, int[] b, long[]c, int N, int M){
    final long INF = Long.MAX_VALUE;

    long[] dist = new long[N];


    for (int i = 0; i < N; i++) {
      dist[i] = INF; //初期化
    }

    dist[0] = 0L;

    for(int loop = 0; loop < N - 1; loop++) {
      for (int i = 0; i < M; i++) {
        if(dist[a[i] - 1] == INF) continue;

        if(dist[b[i] - 1] > dist[a[i] - 1] + c[i]) {
          dist[b[i] - 1] = dist[a[i] - 1] + c[i];
        }
      }
    }

    long ans = dist[N - 1];

    boolean[] negative = new boolean[N];

    for(int i = 0; i < N; i++) {
      negative[i] = false;
    }

    for (int loop = 0; loop < N; loop++) {
      for (int i = 0; i < M; i++) {
        if (dist[a[i] - 1] == INF) continue;

        if (dist[b[i] - 1] > dist[a[i] - 1] + c[i]) {
          dist[b[i] - 1] = dist[a[i] - 1] + c[i];
          negative[b[i] - 1] = true;
        }

        if (negative[a[i] - 1] == true) {
          negative[b[i] - 1] = true;
        }
      }
    }
    if (negative[N - 1]) return -INF;
    else return ans;
  }
}


Measured memory_bytes: 27896
#!/usr/bin/env python3

N, X, Y = map(int, input().split())
ans = [0]*N
 
for i in range(1, N):
    for j in range(i+1, N+1):
        ans[min(abs(i-j), abs(X-i)+1+abs(Y-j), abs(Y-i)+1+abs(j-X))] += 1
 
for i in range(1, N):
    print(ans[i])

Measured memory_bytes: 47708
#include <bits/stdc++.h>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1000000007;
const int mod998 = 998244353;

struct E {
	int to, cap, rev;
};

int H, W, sx, sy, tx, ty, res, f;
char a;
vector<E>v[200];
bool u[200];

int dfs(int x, int k) {
	if (x == tx)return k;
	u[x] = true;
	for (int i = 0; i < v[x].size(); ++i) {
		auto &e = v[x][i];
		if (u[e.to] || !e.cap) continue;
		int d = dfs(e.to, min(k, e.cap));
		if (d) {
			e.cap -= d;
			v[e.to][e.rev].cap += d;
			return d;
		}
	}
	return 0;
}

int main() {
	cin >> H >> W;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> a;
			if (a == '.')continue;
			else if (a == 'o') {
				v[i].push_back({ j + 100,1,(int)v[j + 100].size() });
				v[j + 100].push_back({ i, 1, (int)v[i].size() - 1 });
			}
			else if (a == 'S') {
				sx = i;
				sy = j;
				v[i].push_back({ j + 100,0xE869120,(int)v[j + 100].size() });
				v[j + 100].push_back({ i, 0xE869120, (int)v[i].size() - 1 });
			}
			else {
				tx = i;
				ty = j;
				v[i].push_back({ j + 100,0xE869120,(int)v[j + 100].size() });
				v[j + 100].push_back({ i, 0xE869120, (int)v[i].size() - 1 });
			}
		}
	}
	if (sx == tx || sy == ty) {
		cout << -1 << endl;
		return 0;
	}
	do {
		memset(u, false, sizeof u);
		f = dfs(sx, 0xE869120);
		res += f;
	} while (f);
	cout << res << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define rep(i,n) FOR(i,0,n)

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

//cout << ans?"Yes":"No" << endl;

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
int max(int a , int  b){
  if(a > b) return a;
  else return b;

}
int min(int a , int b){
  if(a < b) return a;
  else return b;
}
bool cmp(pair < int , string >   a , pair < int , string >   b){
  if(a.first < b.first ) return true;
  else return false;
}
long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
int32_t main(){  
  fast;
  int n;
  cin >> n;
  vector < int > h(n);
  for(int i = 0 ; i < n ; i++) cin >> h[i];
  vector < int > dp(n,0);
  dp[1] = abs(h[1]-h[0]);
  for(int i = 2; i < n; i++ ){
    dp[i] = min(dp[i-2]+abs(h[i-2] - h[i]) , dp[i-1]+abs(h[i-1]-h[i])); 
  }
  //for(int i = 0 ; i < n ; i++) cout << dp[i] << "**\n";
  cout << dp[n-1] << "\n";
  return 0;
} 

Measured memory_bytes: 1792
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
#include <set>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n , k , c = 0;
    cin >> n >> k;
    int a[n];
    for( int i = 0 ; i < n ; i++ ) {
        cin >> a[i];
        if( abs( k - a[i] ) < a[i] ) c += abs( k - a[i] );
        else c += a[i];
    }
    cout << c * 2;
}


Measured memory_bytes: 3604
/*
*	User: Isanchez_Aguilar
*	Problem: AtCoder ABC134B - Golden Apple
*/
#include <bits/stdc++.h>

using namespace std;
using Long = long long;

int dp[3002][3002];
short prevDp[3002][3002];

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


	memset(dp, -3001, sizeof dp);
	memset(prevDp, -1, sizeof prevDp);
	
	for (int i = 0; i <= t.size(); ++i)
	{
		dp[0][i] = 0;
		prevDp[0][i] = -1;
	}

	for (int i = 0; i <= s.size(); ++i)
	{
		dp[i][0] = 0;
		prevDp[i][0] = -1;
	}

	for (int i = 1; i <= s.size(); ++i)
	{
		for (int j = 1; j <= t.size(); ++j)
		{
			if (s[i - 1] == t[j - 1])
			{
				dp[i][j] = 1 + dp[i - 1][j - 1];
				prevDp[i][j] = 0;
			}
			else
			{
				if (dp[i - 1][j] < dp[i][j - 1])
				{
					dp[i][j] = dp[i][j - 1];
					prevDp[i][j] = 1;
				}
				else
				{
					dp[i][j] = dp[i - 1][j];
					prevDp[i][j] = 2;
				}
			}
		}
	}

	int i = s.size();
	int j = t.size();
	string ans = "";

	while (i > 0 && j > 0)
	{
		if (prevDp[i][j] == 0)
			ans += s[i - 1], --i, --j;
		else if (prevDp[i][j] == 1)
			--j;
		else
			--i;
	}

	reverse(begin(ans), end(ans));

	cout << ans;

	return 0;
}

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

using i64 = long long int;

i64 gcd(i64 m, i64 n) {
    return (n == 0 ? m : gcd(n, m % n));
}

i64 lcm(i64 m, i64 n) {
    return m / gcd(m, n) * n;
}

int main(){
    int n;
    cin >> n;
    i64 ans = 1;
    for(int i=0;i<n;++i){
        i64 a;
        cin >> a;
        ans = lcm(ans, a);
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3092
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

typedef struct slobj_{
    struct slobj_ *next;
    int v; //uから枝が伸びている節点v
    long d; //枝(u,v)の重み
}* slobj;

//slobj型のリストの定義
typedef struct{
    slobj head;
    slobj tail;
}* slist;

//グラフの構造体の定義
typedef struct{
    int n; //節点数
    slist* E; //枝リストの配列E[0]~E[n-1],未ソート単方向
}* graph;

//vにn,dにxを持つslobj型のリスト要素のメモリ確保+作成する関数
slobj slobj_new(int n,long x){
    slobj p;
    NEW(p,1);
    p->v=n;
    p->d=x;
    p->next=NULL;
    return p;
}

//slist型のメモリを1個確保し、空リスト1つを作る関数
slist slist_new(void){
    slist L;
    NEW(L,1);
    L->head=NULL;
    L->tail=NULL;
    return L;
}

//各slistを空リストにした,節点nのgraph型のメモリを確保する関数(Eは0カウント)
graph graph_new(int n){
    graph G;
    NEW(G,1);
    
    G->n=n;
    
    NEW(G->E,G->n);
    int i;
    for(i=0;i<G->n;i++){
        G->E[i]=slist_new();
    }
    
    return G;
}

//リストLの末尾に要素rを追加する関数
void slist_append_tail(slist L,slobj r){
    if(L->head==NULL){
        L->head=r;
        L->tail=r;
    }
    else{
        L->tail->next=r;
        L->tail=r;
    }
    
    return;
}

//節点i(0~n-1)から節点j(0~n-1)に、重さxの枝を追加する関数
void add_edge(graph G, int i, int j, int x){
    //枝データを追加
    slobj p=slobj_new(j,x);
    slist_append_tail(G->E[i],p);

    return;
}

void delete_edge(graph G, int i, int j){
    slobj p=G->E[i]->head;
    slobj q=NULL;
    while(p!=NULL){
        if(p->v==j) break;
        q=p;
        p=p->next;
    }
    //削除するpがhead
    if(q==NULL){
        G->E[i]->head=p->next;
    }
    else{
        q->next=p->next;
    }
    //削除するpがtail
    if(p->next==NULL){
        G->E[i]->tail=q;
    }
    return;
}

//根(節点i)からの長さをdfs
void dfs(graph G, int i, int* d){
	slobj p=G->E[i]->head;
	while(p!=NULL){
		if(d[p->v]==-1){ //未探索なら
			d[p->v]=d[i]+p->d;
			dfs(G,p->v,d);
		}
		p=p->next;
	}
	return;
}

typedef struct{
    int a;
    int b;
}edge;

int main(void){
    int N,M;
    scanf("%d%d",&N,&M);

    graph G=graph_new(N);
    edge* A;
    NEW(A,M);

    for(int i=0;i<M;i++){
        scanf("%d%d",&A[i].a,&A[i].b);
        A[i].a--;
        A[i].b--;
        add_edge(G,A[i].a,A[i].b,1);
        add_edge(G,A[i].b,A[i].a,1);
    }

    int ans=0;
    for(int i=0;i<M;i++){
        delete_edge(G,A[i].a,A[i].b);
        delete_edge(G,A[i].b,A[i].a);

        int d[N];
        for(int j=0;j<N;j++) d[j]=-1;

        d[0]=0;
        dfs(G,0,d);

        for(int j=0;j<N;j++){
            if(d[j]==-1){
                ans++;
                break;
            }
        }

        add_edge(G,A[i].a,A[i].b,1);
        add_edge(G,A[i].b,A[i].a,1);
    }
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 128
using System;
class aoj
{
    static void Main()
    {
        string a = Console.ReadLine();
        char b = ' ';
        string[] c = a.Split(b);
        int d = int.Parse(c[0]);
        int e = int.Parse(c[1]);
        Console.WriteLine("{0} {1}", d * e, 2 * (d + e));

    }
}

Measured memory_bytes: 9176
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

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

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

struct Info { int cnt, last_index; };

int main() {
    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;

    vector<Info> l(n + 1), r(n + 1);

    const int INF = 100000000;
    auto make_table = [&](){
        vector<Info> res(n + 1);
        res[0] = Info{0, -INF};
        rep(i, n) {
            res[i + 1] = res[i];
            if (s[i] == 'o' && res[i + 1].cnt < res[max(0, i - c)].cnt + 1) res[i + 1] = Info{res[max(0, i - c)].cnt + 1, i};
        }
        return res;
    };

    l = make_table();
    reverse(s.begin(), s.end());
    r = make_table();
    reverse(s.begin(), s.end());
    reverse(r.begin(), r.end());
    rep(i, n + 1) r[i].last_index = n - r[i].last_index - 1;

    //rep(i, n + 1) cout << l[i].cnt << " " << l[i].last_index << endl;
    //cout << endl;
    //rep(i, n + 1) cout << r[i].cnt << " " << r[i].last_index << endl;

    rep(i, n) {
        int cnt = l[i].cnt + r[i + 1].cnt;
        if (l[i].last_index + c >= r[i + 1].last_index) cnt--;
        //cout << "cnt: " << cnt << endl;
        if (cnt < k) cout << i + 1 << endl;
    }
}

Measured memory_bytes: 5252
'''     ░░█ ▄▀█ █   █▀ █░█ █▀█ █▀▀ █▀▀   █▀█ ▄▀█ █▀▄▀█  
        █▄█ █▀█ █   ▄█ █▀█ █▀▄ ██▄ ██▄   █▀▄ █▀█ █░▀░█     '''


# [temp1.py] => [29-07-2020 @ 10:25:10] 
# Author & Template by : Udit "luctivud" Gupta
# https://www.linkedin.com/in/udit-gupta-1b7863135/


import math;   from collections import *
import sys;    from functools import reduce
import time;   from itertools import groupby

# sys.setrecursionlimit(10**6)

def input()         : return sys.stdin.readline()
def get_ints()      : return map(int, input().strip().split())
def get_list()      : return list(get_ints())
def get_string()    : return list(input().strip().split())
def printxsp(*args) : return print(*args, end="")
def printsp(*args)  : return print(*args, end=" ")


DIRECTIONS = [(+0, +1), (+0, -1), (+1, +0), (+1, -1)] 
NEIGHBOURS = [(-1, -1), (-1, +0), (-1, +1), (+0, -1),\
              (+1, +1), (+1, +0), (+1, -1), (+0, +1)]


CAPS_ALPHABETS = {chr(i+ord('A')) : i for i in range(26)}
SMOL_ALPHABETS = {chr(i+ord('a')) : i for i in range(26)}
INF = float('inf')


# Custom input output is now piped through terminal commands.
# for _test_ in range(int(input())): 

n = int(input())
mod = int(1e9) + 7
if (n % 2 == 0):
	print(-1)
else:
	ans = -1
	num = 7
	for i in range(1, n+1):
		if num % n == 0:
			ans = i
			break
		num = (num % n * 10) % n + 7
	print(ans)




# print("Time Elapsed: {}".format(float(S34p-S34t)))


Measured memory_bytes: 9464
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

int arr[10];

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int r, D, x;

    cin >> r >> D >> x;
    arr[0] = x;

    F0R (i, 10)
    {
        cout << r * arr[i] - D << endl;
        
        if (i < 10)    
            arr[i + 1] = r * arr[i] - D;
    }

    return 0;
}


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

template<typename T>
struct Sieve{
    vector<bool> is_prime;
    vector<T> prime;
    T prime_count;
    Sieve(T n):is_prime(n+1,true),prime_count(0){
        is_prime[0] = false;
        is_prime[1] = false;
        for (T i=2;i<=n;i++){
            if (is_prime[i]){
                prime.push_back(i);
                prime_count++;
                for (T j=2*i; j<=n ;j+=i) is_prime[j]=false;
            }
        }
    };
};

int main(){
    ll max_n = 1000000;
    ll n;
    Sieve<ll> a(max_n);
    vector<ll> prime_count(max_n,0);
    ll count = 0;
    for (ll i=0;i<max_n;i++){
        if (a.is_prime[i]) count++;
        prime_count[i] = count;
    }
    while(scanf("%lld",&n)==1){
        ll c= prime_count[n];
        printf("%lld\n", c);
    }
}


Measured memory_bytes: 11500
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
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 H, W, Q;
  const int MAX_L = 50000;
  while(cin >> H >> W >> Q && H){
    int A[MAX_L], B[MAX_L], O[MAX_L];
    REP(i, Q){
      cin >> A[i] >> B[i] >> O[i];
    }
    bool usedY[MAX_L] = {};
    bool usedX[MAX_L] = {};
    int CY = H;
    int CX = W;
    int ans = 0;
    for(int i = Q - 1; i >= 0; i--){
      if(A[i] == 0){
        int y = B[i];
        if(usedY[y]) continue;
        usedY[y] = true;
        CY--;
        if(O[i] == 1) ans += CX;
      }else{
        int x = B[i];
        if(usedX[x]) continue;
        usedX[x] = true;
        CX--;
        if(O[i] == 1) ans += CY;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1852
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
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;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
  string S; cin >> S;
  if(S[2]==S[3] && S[4]==S[5]){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

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

#define ll long long int
#define li int64_t

int main()
{
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}	
	sort(a,a+n);
	int sum = 0;
	for(int i=0;i<k;i++)
	{
		sum+=a[i];
	}
	cout<<sum;
}


Measured memory_bytes: 3628
object Main extends App {
  val n = scala.io.StdIn.readInt()
  val readB =  scala.io.StdIn.readLine()
  val bArray = readB.split(" ").map(_.toInt).toVector

  var resultVec = Vector.empty[Int]
  val size = bArray.size
  (0 to (n - 1)).foreach { i =>
    if (i == 0) {
      resultVec :+= bArray(0)
    } else if (i == (n - 1)) {
      resultVec :+= bArray(n - 2)
    } else {
      val value = bArray(i)
      val before = bArray(i - 1)
      resultVec :+= (if (value > before) before else value)
    }
  }
  println(resultVec.sum)
}


Measured memory_bytes: 27200
from queue import Queue
H, W = map(int, input().split())
s = [input() for _ in range(H)]
d = [[float('inf')]*W for _ in range(H)]
d[0][0] = 1
cs = 0
for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            cs += 1
            d[i][j] = 0


def check(t):
    if 0 <= t[0] < H and 0 <= t[1] < W and d[t[0]][t[1]] == float('inf'):
        return True
    return False


q = Queue()
q.put((0, 0))
while not q.empty():
    h, w = q.get()
    for v in [(h-1, w), (h+1, w), (h, w-1), (h, w+1)]:
        if check(v):
            d[v[0]][v[1]] = d[h][w]+1
            q.put(v)

print(H*W-cs-d[-1][-1] if not (d[-1][-1] == float('inf')) else -1)


Measured memory_bytes: 47336
#include <bits/stdc++.h> 
using namespace std;
///////////////////////////////////////////
const long long int INF = 100000000000;
const long long int Mod = 1000000007;
using ll = long long int; //long long int は64bit
using vi = vector<int>; using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(long long int i=0;i<N;i++)
#define np nullptr
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
typedef pair<ll,ll> Pair;
bool p_compare(const Pair& firstP, const Pair& secondP){ 
    return firstP.second < secondP.second; 
}//sort(all(v),p_compare)で昇順ソート
//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////
//Snipet -> Caps Lock

ll n,m;

vector<Pair> v;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n>>m;ll aa,bb;
    rep(i,m){
        cin>>aa>>bb;
        v.pb(mp(aa,bb));
    }//input
    sort(all(v),p_compare);
    ll big = 0,ans = 0;
    rep(i,m){
        if(big<=v[i].first){
            big=v[i].second;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2420
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

def print_l(l):
    print(' '.join(map(str, l)))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

n,k,c = l_in()
S = s_in()


i = 0
left = set()

while i < n:
    if S[i] == 'o':
        left.add(i)
        i += 1+c
    else:
        i += 1

i = n-1
right = set()

while i >= 0:
    if S[i] == 'o':
        right.add(i)
        i -= 1+c
    else:
        i -= 1

if len(left) == k and len(right) == k:
    for i in sorted(list(left.intersection(right))):
        print(i+1)



Measured memory_bytes: 90840
#include<iostream>
#include<string>
#include<cctype>
#include<algorithm>

using namespace std;

void UpperCamelCase(string&);
void LowerCamelCase(string&);
void UnderScoreCase(string&);
bool IsUpperCase(char);

int main(){
  char c;
  string str;

  while(1){
    cin >> str >> c;

    if(c == 'X') break;
    else if(c == 'U') UpperCamelCase(str);
    else if(c == 'L') LowerCamelCase(str);
    else if(c == 'D') UnderScoreCase(str);

    cout << str << endl;
  }

  return 0;
}

void UpperCamelCase(string& s){
  string::iterator i;

  if(s[0] >= 'a' && s[0] <= 'z')
    s[0] = toupper(s[0]);

  i = s.begin();
  while(1){
    i = find(i, s.end(), '_');
    if(i == s.end()) break;
    i = s.erase(i);
    *i = toupper(*i);
  }
}

void LowerCamelCase(string& s){
  string::iterator i;

  if(s[0] >= 'A' && s[0] <= 'Z')
    s[0] = tolower(s[0]);

  i = s.begin();
  while(1){
    i = find(i, s.end(), '_');
    if(i == s.end()) break;
    i = s.erase(i);
    *i = toupper(*i);
  }
}

void UnderScoreCase(string& s){
  string::iterator i;

  if(s[0] >= 'A' && s[0] <= 'Z')
    s[0] = tolower(s[0]);

  i = s.begin();
  while(1){
    i = find_if(i, s.end(), IsUpperCase);
    if(i == s.end()) break;
    *i = tolower(*i);
    i = s.insert(i, '_');
    ++i;
  }
}

bool IsUpperCase(char c){
  if(c >= 'A' && c <= 'Z')
    return true;
  else
    return false;
}

Measured memory_bytes: 0
#include <cstdio>
#include <iostream>
#include <utility>

using namespace std;

int main() {

	int DIAGONAL = 0;
	int TOP = 1;

	int N, W;
	scanf("%d %d", &N, &W);

	int C[N + 1][W + 1];
	int G[N + 1][W + 1];

	for (int i = 0; i <= W; ++i) {
		C[0][i] = 0;
		G[0][i] = DIAGONAL;
	}
	for (int i = 0; i <= N; ++i) {
		C[i][0] = 0;
	}

	pair<int, int> items[N + 1];

	for (int i = 1; i <= N; ++i) {
		int v, w;
		scanf("%d %d", &v, &w);
		items[i] = make_pair(v, w);
	}

	for (int i = 1; i <= N; ++i) {
		for (int w = 01; w <= W; ++w) {
			if (items[i].second <= w) {
				if (items[i].first + C[i - 1][w - items[i].second] > C[i - 1][w]) {
					C[i][w] = items[i].first + C[i - 1][w - items[i].second];
					G[i][w] = DIAGONAL;
				} else {
					C[i][w] = C[i - 1][w];
					G[i][w] = TOP;
				}
			} else {
				C[i][w] = C[i - 1][w];
				G[i][w] = TOP;
			}
		}
	}

	cout << C[N][W] << endl;

	return 0;
}

Measured memory_bytes: 11044
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef bitset<16> BS;

const ll MOD = 1E+09 + 7;
const int INF = 1E09;
const int MAX_N = 1E+05;

int N;

int C[MAX_N + 1], S[MAX_N + 1], F[MAX_N + 1];

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

    cin >> N;

    for (int i = 1; i < N; i++) {
        cin >> C[i] >> S[i] >> F[i];
    }

    for (int i = 1; i < N; i++) {
        int t = S[i] + C[i];
        for (int j = i + 1; j < N; j++) {
            if (t < S[j]) {
                t = S[j] + C[j];
            } else {
                t = ceil(double(t) / F[j]) * F[j] + C[j];
            }
        }
        cout << t << "\n";
    }
    cout << 0 << "\n";
    /*
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cout << "i = " << i << ", j = " << j << ", dp = " << dp[i][j] << "\n";
        }
    }
    */

    return 0;
}

Measured memory_bytes: 3676
lst = [int(s) for s in input()]
lst2 = []
search = 7
for i, num in enumerate(lst):
    lst2.append([])
    if i == 0:
        lst2[i].append(num)
    else:
        for num_ in lst2[i-1]:
            lst2[i].append(num_ + num)
            lst2[i].append(num_ - num)
idx = lst2[len(lst2)-1].index(search)
s= str(lst[0])
lst_ = list(lst2[len(lst)-1])
for i in range(1, len(lst)):
    if len(lst_)/2>idx:
        s += '+'
        lst_ = lst_[0:len(lst_)//2]
    else:
        s += '-'
        lst_ = lst_[(len(lst_)//2):len(lst_)]
        idx -= len(lst_)
    s += str(lst[i])
s += '=' + str(search)
print(s)

Measured memory_bytes: 3064
#include <stdio.h>

using namespace std;

void outPut(int Array[],char mark) {
	for (int i = 1; i <= 13; i++)
	{
		if (Array[i]==0)
		{
			printf("%c %d\n", mark, i);
		}
	}
}

int main() {
	char mark[2];
	int n, S[14], H[14], C[14], D[14], tmp;
	for (int i = 0; i < 14; i++)
	{
		S[i] = H[i] = C[i] = D[i] = 0;
	}
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%s %d", mark, &tmp);
		switch (mark[0])
		{
		case 'S':
			S[tmp] = 1;
			break;
		case 'H':
			H[tmp] = 1;
			break;
		case 'C':
			C[tmp] = 1;
			break;
		case 'D':
			D[tmp] = 1;
			break;
		}
	}
	outPut(S, 'S');
	outPut(H, 'H');
	outPut(C, 'C');
	outPut(D, 'D');
}


Measured memory_bytes: 2616
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.14159265358979323846264338327950288;

int main(){
    ll A;
    cin>>A;
    string B;
    cin>>B;
    ll dec=B[0]-'0';
    ll p1=B[2]-'0';
    ll p2=B[3]-'0';
    ll ans=A*(dec*100+p1*10+p2);
    ans/=100;
    cout<<ans<<endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int H,W;
string S[401];
int num[401][401];

int main(){
    cin >> H >> W;
    rep(i,H) cin >> S[i];

    int number=1;
    rep(i,H) rep(j,W){
        if(num[i][j]!=0) continue;

        num[i][j] = number;

        queue<pii> que;
        que.push(pii(i,j));

        while(!que.empty()){
            int x = que.front().first;
            int y = que.front().second;
            que.pop();

            for(int k=0;k<4;k++){
                int nx = x + dx[k];
                int ny = y + dy[k];

                if(nx<0 or nx>=H or ny<0 or ny>=W) continue;
                if(num[nx][ny] != 0) continue;

                if(S[x][y]!=S[nx][ny]){
                    que.push(pii(nx,ny));
                    num[nx][ny] = number;
                }
            }
        }
        number++;
    }
/*
    rep(i,H){
        rep(j,W){
            cout << num[i][j];
        }
        cout << endl;
    }
*/

    map<int,pii> mp;
    rep(i,H) rep(j,W){
        if(S[i][j]=='.') mp[num[i][j]].first++;
        else mp[num[i][j]].second++;
    }

    ll ans = 0;
    for(auto p : mp){

        ans += p.second.first * p.second.second;
    }
    cout << ans << endl;
}


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

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

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
int main(void)
{
    double a[1000];
    double b , c ;
    int n, i;
 
    while (1)
    {
        scanf("%d", &n);
        if (n == 0)
        {
            break;
        }
        for (i = 0,b=0;i < n;i++)
        {
            scanf("%lf", &a[i]);
            b += a[i];
        }
        scanf("\n");
 
        b /= n;
        for (i = 0,c=0;i < n;i++)
        {
            c += ((a[i] - b)*(a[i] - b));
        }
        c /= n;
        printf("%.8f\n", sqrt(c));
    }
    return 0;
}


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

int main(void){
    int k, x;
    std::cin >> k >> x;

    int left = x - k + 1;
    int right = x + k -1;
    for(int i = left; i <= right; i++){
        std::cout << i << " ";
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			Map<Integer, Integer> memo = new HashMap<Integer, Integer>();
			memo.put(0, 1);
			for (int i = 0; i < n; i++) {
				int a = scanner.nextInt();
				int b = scanner.nextInt();
				Map<Integer, Integer> tmp = new HashMap<Integer, Integer>();
				tmp.putAll(memo);
				for (Entry<Integer, Integer> entry : memo.entrySet()) {
					for (int j = 1; j <= b; j++) {
						int c = entry.getKey() + a * j;
						if (c > 1000) {
							continue;
						}
						int d = entry.getValue();
						if (tmp.containsKey(c)) {
							tmp.put(c, d + tmp.get(c));
						} else {
							tmp.put(c, d);
						}

					}
				}
				memo = tmp;

			}
			int s = scanner.nextInt();
			while (s-- > 0) {
				int m = scanner.nextInt();
				if (!memo.containsKey(m)) {
					System.out.println(0);
				} else {
					System.out.println(memo.get(m));
				}
			}
		}
	}
}

Measured memory_bytes: 26776
#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=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SORTR(x) sort(ALLR(x))
#define SORT(x) sort(ALL(x))
#define SUM(x) accumulate(ALL(A), 0)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
typedef vector<ll> VI;
typedef vector<VI> VVI;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef vector<string> VS;
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; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}


void Main()
{
	ll N,M;
	ll result=0;
	cin>>N>>M;
	VI A(M);
	REP(i, M) cin >> A[i];
	result=N-SUM(A);
	if(result<0) result=-1;
	cout << result << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 3688
#!/usr/bin/env python
n, m = list(map(int, input().split()))
c = list(map(int, input().split()))
DP = {}
for i in range(n + 1):
	DP[i] = n
DP[0] = 0
for cost in c:
	for i in range(cost, n + 1):
		DP[i] = min(DP[i], DP[i - cost] + 1)
print(DP[n])



Measured memory_bytes: 11220
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;

int main() {
    int a, b,ans=0;
    cin >> a >> b;
    for (int i = a;i <= b; i++) {
        if (i % 10 == i / 10000 && i % 100 / 10 == i / 1000 % 10) ans++;
    }
    printf("%d", ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[200004];
int main(){
	ll k,n;
	ll maxx=0;
	scanf("%lld%lld",&k,&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		if(i!=1){
			maxx=max(a[i]-a[i-1],maxx);
		}
	}
	maxx=max(k-a[n]+a[1],maxx);
	printf("%lld\n",k-maxx);
	return 0;
} 

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define sz(a) int(a.size())

int main(){
	int a, b; cin>>a>>b;
	for(int c = 1; c <= 3; c++){
		if((a * b * c) % 2 != 0){
			cout<<"Yes"<<endl;
			return 0;
		}
	}	
	cout<<"No"<<endl;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = int(1e9) + 7; constexpr ll LINF = 1ll << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    vll X(N);
    rep(i, N) cin >> X[i];

    vll dist(N, LINF);
    dist[0] = 0;
    rep(i, 1, N) {
        dist[i] = min(dist[i - 1] + (X[i] - X[i - 1]) * A, dist[i - 1] + B);
    }

    write(dist[N - 1]);
}

Measured memory_bytes: 1792
Q = 998244353
def main():
    N, M, K = map( int, input().split())
    ans = 0
    cmb = 1
    for k in range(K+1):
        ans += M*pow(M-1,N-1-k,Q)%Q*cmb%Q
        ans %= Q
        cmb *= (N-k-1)*pow(k+1,Q-2,Q)%Q
        cmb %= Q
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 9192
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx")
#include <bits/stdc++.h>

constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(x1y2-x2y1) = S
//x1y2 = S + x2y1
//

vector<ll> ed(ll n) { // 約数列挙
	vector<ll> ans;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ans.push_back(i);
			if (i != 1 && i * i != n)ans.push_back(n / i);
		}
	}
	return ans;
}


int main() {
	ll S;
	cin >> S;
	ll x1, x2, y1, y2;
	x1 = ceil(sqrt(S));
	if (x1 % 2 != 0)x1++;
	y2 = x1;
	if (x1 * y2 == S) {
		y1 = x2 = 0;
	}
	else {
		auto v = ed((x1 * y2 - S));
		x2 = v.back();
		y1 = (x1 * y2 - S) / x2;
	}
	cout << 0 << " " << 0 << " " << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
}

Measured memory_bytes: 256
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end
def bs(ar,eq,n) en=(eq==1 ? :>= : :>); ar.bsearch_index{|x|x.send(en,n)} end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n, k = gsmi

if k%2==0
  even_cnt = n/k
  odd_cnt = n/(k/2) - even_cnt
  cnt = even_cnt**3 + odd_cnt**3
else
  cnt = (n/k)**3
end
puts cnt

Measured memory_bytes: 1788