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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> vec(H + 2);
  string padding = "..";
  for (int j = 0; j < W; j++) {
    padding += ".";
  }
  vec.at(0) = padding;
  for (int i = 0; i < H; i++) {
    cin >> vec.at(i + 1);
    vec.at(i + 1) = "." + vec.at(i + 1) + ".";
  }
  vec.at(H + 1) = padding;
  for (int i = 1; i < H + 1; i++) {
    for (int j = 1; j < W + 1; j++) {
      if (vec.at(i).at(j) == '#') {
        cout << '#';
      } else {
        int counter = 0;
        counter += (vec.at(i - 1).at(j - 1) == '#')
          + (vec.at(i - 1).at(j) == '#')
          + (vec.at(i - 1).at(j + 1) == '#')
          + (vec.at(i).at(j - 1) == '#')
          + (vec.at(i).at(j + 1) == '#')
          + (vec.at(i + 1).at(j - 1) == '#')
          + (vec.at(i + 1).at(j) == '#')
          + (vec.at(i + 1).at(j + 1) == '#');
        cout << counter;
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

W,H = LI()
p = LIR(W,1)
q = LIR(H,1)

p.sort()
cusum = [p[0]]
for i in range(1,W):
    cusum.append(cusum[-1]+p[i])
ans = cusum[-1]

for i in range(H):
    place = bisect_left(p,q[i])
    temp = cusum[place-1] if place >= 1 else 0
    ans += temp + q[i]*(W+1-place)

print(ans)

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

using namespace std;

using ll = long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    vector<int> v ={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout << v[k-1] << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

//dがxの約数かどうか判定する関数
bool isDivisor(int d, int x);

int main(){
	const int x = 600;
	int d;
	
	while(std::cin >> d){
		//dがxの約数でなければエラー
		if(!isDivisor(d, x)){
			std::cout << "error" << std::endl;
			return 1;
		}
		
		int sum = 0; //面積の合計値
		for(int i = d; i < x; i += d){
			sum += i*i*d;
		}
		
		std::cout << sum << std::endl;
	}
	
	return 0;
}

bool isDivisor(int d, int x){
	for(int i = 1; i*i < x; ++i){
		if(x%i == 0){
			if(d == i) return true;
			else if(d == x/i) return true;
		}
	}
	return false;
}

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

inline void read(int &T) {
	int x=0;bool f=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=!f;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	T=f?-x:x;
}

int x,y;

int main() {
	read(x),read(y);
	for(int i=0;i<=x;++i) {
		int j=x-i;
		if(i*2+j*4==y) {
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
int main ()
{
	
	int n,k, hsl ;
	scanf("%d %d", &n, &k);
	if(n<10)
		n=100*(10-n);
	else if(n>=10)
		n=0;
	hsl=n+k;
	printf("%d\n", hsl);
	return 0;
}

Measured memory_bytes: 1732
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int tree[500005],n;

int left(int i){return 2*i;}
int right(int i){return 2*i+1;}
void buildMaxHeap();
void maxHeapify(int);

void buildMaxHeap(){
    for(int i=n/2;i>0;i--)
        maxHeapify(i);
}

void maxHeapify(int i){
    int l = left(i),r = right(i);
    int largest;
    if(l<=n && tree[l]>tree[i])
        largest=l;
    else
        largest=i;
    if(r<=n && tree[r]>tree[largest])
        largest=r;
    if(largest != i){
        swap(tree[i],tree[largest]);
        maxHeapify(largest);
    }

}

int main(){
    while(cin>>n){
        for(int i=1;i<=n;i++)
            cin>>tree[i];
        buildMaxHeap();
        for(int i=1;i<=n;i++)
            cout<<" "<<tree[i];
        cout<<endl;
    }
}


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

using namespace std;

void solve()
{
    int n, k;
    cin >> n >> k;
    vector<int> xs(n);
    for (int i = 0; i < n; i++)
    {
        cin >> xs[i];
    }
    int ans = 0;
    for (int take = 1; take <= min(k, n); take++)
    {
        for (int l = 0; l <= take; l++)
        {
            int r = take - l;
            vector<int> zs(take);
            for (int i = 0; i < l; i++)
            {
                zs.push_back(xs[i]);
            }
            for (int i = n - r; i < n; i++)
            {
                zs.push_back(xs[i]);
            }
            sort(zs.rbegin(), zs.rend());
            for (int i = 0; i < k - take; i++)
            {
                if (zs.back() >= 0)
                    break;
                zs.pop_back();
            }
            ans = max(ans, accumulate(zs.begin(), zs.end(), 0));
        }
    }
    cout << ans << endl;
}

int main()
{
    solve();
    cerr << "\"努力不足ですね！\"" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n; string s,t;
    cin>>n>>s>>t;
    for(int i=n; i>=0; --i){
        if(s.substr(n-i,i)==t.substr(0,i)){
            cout<<2*n-i<<endl;
            return 0;
        }
    }
}


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

namespace CompetitiveProgramming
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }

        static void MainStream()
        {
            var array = new List<int>();
            string[] a_b_k = Console.ReadLine().Split(' ');
            int a = int.Parse(a_b_k[0]);
            int b = int.Parse(a_b_k[1]);
            int k = int.Parse(a_b_k[2]);

            for(var i=1;i<=a;i++)
            {
                if(a%i==0 && b%i==0)
                {
                    array.Add(i);
                }
            }

            Console.WriteLine(array[array.Count - k]);
        }



    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=b-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 1005;
int dp[N][N];

int main(){
	int h,w;
	scanf(" %d %d", &h,&w);
	dp[0][1] = 1;
	fu(i,1,h){
		fu(j,1,w){
			char c;
			scanf(" %c", &c);
			if(c == '.'){
				dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD;	
			}
		}
	}
	printf("%d\n",dp[h][w]);
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
 
using namespace std;
 
#define ld long double
#define ll long long
#define ull unsigned long long
#define dd double
#define lbits 64
#define ibits 32

const double pi = acos(-1);
const ll mod = (ll)(1e9 + 9);

bool isPrime(ll x){for(int i=2;i*i<=x;i++)if(x%i==0)return false;return true;}
double dist(dd a,dd b,dd c,dd d){return sqrt((c-a)*(c-a)+(d-b)*(d-b));}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;
    srand(time(0));

    int n;cin>>n;
    vector<ll> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    vector<ll> pre(n);
    pre[0] = v[0];
    for(int i=1;i<n;i++){
        pre[i] = pre[i - 1] + v[i];
    }
    ll ans = 1e18;
    for(int i=0;i<n;i++){
        ans = min(ans, abs(pre[i] - (pre[n - 1] - pre[i])));
    }
    cout<<ans;

    // CHECK THE OVERFLOW
    // CHECK THE BOUNDS

    return 0;
}

Measured memory_bytes: 3328
n,m,*x=map(int,open(0).read().split())
a,b=[0]*m,[0]*m
s=set()
for i in x:
  j=i%m
  if i in s:
    s-={i}
    b[j]+=1
  else:
    s|={i}
  a[j]+=1
c=a[0]//2+(m%2<1and a[m//2]//2)
for i in range(1,m//2+m%2):
  (i,_),(j,k)=sorted((a[j],b[j])for j in(i,m-i))
  c+=i+min(j-i>>1,k)
print(c)

Measured memory_bytes: 60196
'use strict'

function main(input) {
    const k = Number(input.split('\n')[0].split(' ')[0]);
    const a = Number(input.split('\n')[1].split(' ')[0]);
    const b = Number(input.split('\n')[1].split(' ')[1]);
    for (let index = a; index <= b; index++) {
        if (index % k === 0) {
            console.log('OK');
            return;
        }
    }
    console.log('NG');
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main(){
string S;
  cin>>S;
  
  for(int i=0; i<26; i++){
   char key='a'+ i ;
    bool flag=false;
    for(int j=0; j<S.size(); j++){
     if(S[j]==key){flag=true;}
    }
    if(!flag){cout<<key<<endl;
    return 0;}   //return0;をつけることで、このプログラムはそこで処理を終了する。
  }
cout<<"None"<<endl;
  return 0;  //したがって、上記のreturn 0;が成立する場合は、この"None"は出力されない。
}

Measured memory_bytes: 512
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String S = in.readLine();
		int[] a = new int[S.length()+1];
		a[0]=0;
		int i=0;
		int cnt=0;

		long sum=0;
		while(i<S.length()){
			a[i]=0;
			while(i<S.length()&&S.charAt(i)=='<'){
				a[i+1]=a[i]+1;
				i++;
			}
			while(i<S.length()&&S.charAt(i)=='>'){
				a[i+1]=a[i]-1;
				cnt++;
				i++;
			}
			if(cnt>0){
				int dif=a[i]*-1;
				for(int k=i-cnt+1;k<=i;k++){
					a[k]+=dif;
				}
				a[i-cnt]=Math.max(a[i-cnt],a[i-cnt+1]+1);
			}
			cnt=0;

		}

		for(i=0;i<a.length;i++){
			sum+=a[i];
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 28448
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


import collections
import math


LIMIT = 1e-10


class Vector2(collections.namedtuple("Vector2", "x y")):

    __slots__ = ()

    def __add__(self, other):
        return Vector2(self.x + other.x, self.y + other.y)

    def __sub__(self, other):
        return Vector2(self.x - other.x, self.y - other.y)

    def __mul__(self, other):
        return self.x * other.y - self.y * other.x

    def __neg__(self):
        return Vector2(-self.x, -self.y)

    def __pos__(self):
        return Vector2(+self.x, +self.y)

    def __abs__(self):
        return math.sqrt(float(self.x * self.x + self.y * self.y))

    def dotproduct(self, other):
        return self.x * other.x + self.y * other.y


def main():
    n = int(input())
    for i in range(n):
        [x1, y1, x2, y2, x3, y3, x4, y4] = [float(z) for z in input().split()]
        vector_ab = Vector2(x2 - x1, y2 - y1)
        vector_cd = Vector2(x4 - x3, y4 - y3)
        if abs(vector_ab * vector_cd) < LIMIT:
            print("YES")
        else:
            print("NO")


if __name__ == "__main__":
    main()

Measured memory_bytes: 8096
#include <iostream>

int main() {
  int N, A, B;
  std::cin >> N >> A >> B;

  int plan1 = A * N;
  int plan2 = B;
  if ( plan1 <= plan2 ) std::cout << plan1 << std::endl;
  else std::cout << plan2 << std::endl;

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
from decimal import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

def func(n):
    cnt2 = 0
    cnt5 = 0
    while n % 2 == 0:
        n //= 2
        cnt2 += 1
    while n % 5 == 0:
        n //= 5
        cnt5 += 1
    return cnt2, cnt5


arr = [[0 for _ in range(20)] for _ in range(20)]

cnt = Counter()
N = int(input())
for n in range(N):
    s = input()
    d = Decimal(s)
    d = int(d * 1000000000)
    cnt2, cnt5 = func(d)
    # print(d)
    # print(cnt2, cnt5)
    cnt[(cnt2, cnt5)] += 1

    cnt2 = min(cnt2, 18)
    cnt5 = min(cnt5, 18)
    arr[cnt2][cnt5] += 1

# from pprint import *
# import copy

# sumarr = copy.deepcopy(arr)
# for i in range(18, -1, -1):
#     for j in range(18, -1, -1):
#         sumarr[i][j] += sumarr[i][j + 1] + sumarr[i + 1][j] - sumarr[i + 1][j + 1]

ans = 0
for ij in range(19 * 19 - 1):
    i = ij // 19
    j = ij % 19
    for ij2 in range(ij, 19 * 19):
        i2 = ij2 // 19
        j2 = ij2 % 19

        if arr[i][j] * arr[i2][j2] == 0: continue

        if ij == ij2 and i + i2 >= 18 and j + j2 >= 18:
            ans += arr[i][j] * (arr[i][j] - 1) // 2
        else:
            if (arr[i][j] * arr[i2][j2] != 0 and i + i2 >= 18 and j + j2 >= 18):
                ans += arr[i][j] * arr[i2][j2]
print(ans)


Measured memory_bytes: 10832
#include <stdio.h>

int main() {
	int r;

	scanf("%d", &r);

	if (r < 1200) {
		printf("ABC\n");
	}
	else if (r < 2800) {
		printf("ARC\n");
	}
	else {
		printf("AGC\n");
	}

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    int num[n];
    for (int j=0; j<n; j++) {
        cin >> num[j];
    }
    
    for (int i = n-1; i>=0; i--) {
        if (i ) {
            cout << num[i];
            cout << " ";
        }else{
            cout << num[i];
        }
        
    }
    cout << endl;
     return 0;
}

Measured memory_bytes: 1164
s = str(input())
t = str(input())
ss = []
for i in range(len(s)-len(t)+1):
    for j in range(len(t)):
        if s[i+j] not in ("?",t[j]):
            break
    else:
        u = s[:i]+t+s[i+len(t):]
        ss.append(u.replace("?","a"))
if ss:
    print(min(ss))
else:
    print("UNRESTORABLE")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define pb push_back 
using namespace std;

const int maxn=1;
typedef long long ll;

int n,m,p,x;
int T,ans;

int main()
{
	int i,j,k;
	scanf("%d%d",&n,&T);
	
	scanf("%d",&p);
	for(i=2;i<=n;++i)
	{
		scanf("%d",&x);
		if(x>p+T)
		{
			ans+=T;
		}
		else ans+=x-p;
		p=x;
	}
	ans+=T;
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef unsigned long long int ll;
#define MAX_N 50
char maze[MAX_N][MAX_N];

bool isIsolate(int i,int j,int h,int w){
	bool ans = true;
	if( i >= 1){
		if( maze[i-1][j] == '#') return false;
	}
	if( i+1 < h){
		if( maze[i+1][j] == '#') return false;
	}
	if( j-1 >= 0){
		if( maze[i][j-1] == '#') return false;
	}
	if( j+1 < w){
		if( maze[i][j+1] == '#') return false;
	}
	return true;
}

int main()
{
	int H,W;
	cin>>H>>W;
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			cin>>maze[i][j];
		}
	}
	bool canDraw = true;
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			if(maze[i][j] == '#' && isIsolate(i,j,H,W) == true){
				canDraw = false;
				break;
			}
		}
	}
	if(canDraw == true){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<functional>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int main() {
	string str;
	while (1) {
		getline(cin, str);
		if (str == ".") break;

		stack<char> stk;
		bool flag = true;
		REP(i, 0, str.size()) {
			if (str[i] == '(' || str[i] == '[') stk.push(str[i]);
			else if (str[i] == ')') {
				if (stk.empty()) {
					flag = false;
					break;
				}
				
				char c = stk.top();
				stk.pop();
				if (c != '(') {
					flag = false;
					break;
				}
			}
			else if (str[i] == ']') {
				if (stk.empty()) {
					flag = false;
					break;
				}

				char c = stk.top();
				stk.pop();
				if (c != '[') {
					flag = false;
					break;
				}
			}
		}

		if (flag && stk.empty()) cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}

Measured memory_bytes: 3104
/*
ID: thanhvq1
LANG: C++14
PROB: namenum
*/

#pragma GCC optimize ("O2")
#include<bits/stdc++.h>
#include<unistd.h>
using namespace std;
#define int long long
#define double long double
#define vec vector
#define vi vector<int>
#define FZ(n) memset((n),0,sizeof(n))
#define FMO(n) memset((n),-1,sizeof(n))
#define unset unordered_set
#define ii pair<int, int>
#define vii vector<ii>
#define F first
#define S second
#define PB push_back
#define ALL(x) begin(x),end(x)
#define SZ(x) ((int)(x).size())
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define bitcount(n) __builtin_popcountll(n)
template <typename T,typename U>
std::pair<T,U> operator+(const std::pair<T,U> & l,const std::pair<T,U> & r) {
  return {l.first+r.first, l.second+r.second};
}
typedef void (*callback_function)(void); // type for conciseness
const long long ZERO = 0LL;
const long long INF64 = 1e18;
const int INF32 = 1e9;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0L);
const double EPS = static_cast<double>(1e-9);
typedef long long ll;

void FILEIO() {  freopen("in.txt", "r", stdin);  freopen("out.txt", "w", stdout); }
//void FILEIO() {  freopen("namenum.in", "r", stdin);  freopen("namenum.out", "w", stdout); }

int w, h, x, y;

void solve() {
	cin >> w >> h >> x >> y;
	double s = (double)w * (double)h;
	s =s/2.0;
	if(w%2==0 and h%2==0) {
		if(x==w/2 and y==h/2) {
			cout << setprecision(9) << fixed << s << " 1" << endl;
			return;
		}
	}
	cout << setprecision(9) << fixed << s << " 0" << endl;
}

//#undef int
signed main() {
//#define int long long
  ios_base::sync_with_stdio(false); cin.tie();
//  FILEIO();
//auto beginProgram = chrono::steady_clock::now();

// int t; cin >> t;
//  while (t--)
  {
		solve();
  }

  //auto endProgram = chrono::steady_clock::now();

  return 0;
}


Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int n; cin >> n;
    unordered_set<string> se;
    string w; cin >> w;
    se.insert(w);
    rep(i, n - 1) {
        string u; cin >> u;
        if(se.find(u) != se.end()) {
            cout << "No" << endl;
            return;
        }
        if(w[(int)w.size() - 1] != u[0]) {
            cout << "No" << endl;
            return;
        }
        w = u;
        se.insert(w);
    }
    cout << "Yes" << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3672
N, A = map(int, input().split())
x = [int(i) for i in input().split()]
 
lim = sum(x)
dp = [[0]*(lim + 1) for i in range(N + 1)]
 
dp[0][0] = 1
 
for i in range(N):
    for k in range(i + 1, 0, -1):
        for v in range(lim, x[i] - 1, -1):
            dp[k][v] += dp[k - 1][v - x[i]]
 
ans = 0

for k in range(1, N + 1):
    if k*A > lim:
        break
    ans += dp[k][k*A]

print(ans)

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

const int MOD = 1000000007;
const int INF = 999999999;

int main(){
    ll Q, H, S, D, N;
    cin >> Q >> H >> S >> D >> N;
    if(Q * 2 <= H){
        H = 2 * Q;
    }
    if(H * 2 <= S){
        S = 2 * H;
    }
    if(S * 2 <= D){
        D = 2 * S;
    }
    cout << (N/2)*D + (N%2)*S << endl;
return 0;}
/**
 * g++ code.cpp
 * ./a.out
 * shift + ctrl + i
**/ 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define array_input int n;cin>>n;int a[n+1],i;for(i=1;i<=n;i++){cin>>a[i];}
#define array_output for(i=1;i<=n;i++){cout<<a[i]<<" ";}cout<<endl;
#define INF 2147483647
#define long_INF 18446744073709551615
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
const double pi=acos(-1);
const double eps=1e-6;

int main()
{
	ios::sync_with_stdio(false);
	int a,b;
	cin>>a>>b;
	int i,t,ans,s;
	s=0;
	for (i=a;i<=b;i++)
	{
		t=i;
		ans=0;
		while (t!=0)
		{
			ans=ans*10+t%10;
			t/=10;
		}
		if (ans==i)
		{
			s++;
		}
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <math.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    vector<int> a(4);
    for(int i=0;i<4;i++){
        int m=n%10;
        a[i]=m;
        n/=10;
    }
    reverse(a.begin(),a.end());
    for(int i=0;i<2;i++){
        //int ans=a[0];
        //if(i==0)ans+=a[1];
        //else ans-=a[1];
        for(int j=0;j<2;j++){
            //if(j==0)ans+=a[2];
            //else ans-=a[2];
            for(int k=0;k<2;k++){
                int ans=a[0];
                if(i==0)ans+=a[1];
                else ans-=a[1];   
                if(j==0)ans+=a[2];
                else ans-=a[2];                
                if(k==0)ans+=a[3];
                else ans-=a[3];
            if(ans==7){
                cout<<a[0];
                if(i==0)cout<<"+"<<a[1];
                else cout<<"-"<<a[1];
                if(j==0)cout<<"+"<<a[2];
                else cout<<"-"<<a[2];
                if(k==0)cout<<"+"<<a[3];
                else cout<<"-"<<a[3];
                cout<<"=7"<<endl;
                return 0;
            }
            }
        }
    }
    return 0;
}


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

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int n;

int main() {
  cin >> n;
  vector<int> b(n);
  range(i, 0, n) {
    cin >> b[i];
    b[i]--;
    if(b[i] > i) {
      cout << -1;
      return 0;
    }
  }
  vector<int> res;
  while(n) {
    husk(i, n - 1, -1) {
      if(b[i] == i) {
        res.push_back(i + 1);
        b.erase(b.begin() + i);
        n--;
        break;
      }
    }
  }
  reverse(res.begin(), res.end());
  for(int i : res) cout << i << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int max(int a,int b){return a>b?a:b;}
int main(void)
{
    int a,b,k,i,d[200],j=0;
    scanf("%d%d%d",&a,&b,&k);

    for(i=max(a,b);i>0;i--)
    {
        if(a%i == 0 && b%i == 0)
            {
                d[j] = i;
                j++;
            }
    }
        printf("%d",d[k-1]);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
int a[100][100],i,j;
char z[100][100];
void sim(void){
	int f=0;
	i=j=0;
	while(1){
		if(a[i][j]){
			puts("LOOP");
			break;
		}
		a[i][j]++;
		switch(z[i][j]){
			case '>':j++;break;
			case '<':j--;break;
			case '^':i--;break;
			case 'v':i++;break;
			default :printf("%d %d\n",j,i);f=1;
		}
		if(f)break;
	}
}
int main(void){
	int w,h;
	char gomi;
	while(scanf("%d %d",&h,&w),w+h){
		memset(a,0,sizeof(a));
		for(i=0;i<h;i++){
			scanf("%s",z[i]);
		}
		sim();
	}
	return 0;
}

Measured memory_bytes: 668
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using System.Text;

namespace Atcoder
{
    class Program
    {
        private const long COMDIV = 1000000007;
        static void Main(string[] args)
        {
            var NK = Console.ReadLine().Split().Select(int.Parse).ToArray();
            HashSet<int> own = new HashSet<int>();
            for (int i = 0; i < NK[1]; i++)
            {
                var len = int.Parse(Console.ReadLine());
                var As = Console.ReadLine().Split().Select(int.Parse).ToArray();
                for (int j = 0; j < len; j++)
                {
                    own.Add(As[j]);
                }
            }

            Console.WriteLine(NK[0] - own.Count);
        }
        
    }
}

Measured memory_bytes: 28416
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

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

Measured memory_bytes: 3640
from collections import Counter
a = input()
c = Counter(a)
n = len(a)

ans = n * (n-1) // 2 + 1
for i in range(26):
    w = chr(ord('a') + i)
    count = c[w]
    if count >= 2:
        ans -= count * (count - 1) // 2

print(ans)

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

using namespace std;
typedef long long ll;

const ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

int main(void){
    ll n,k;
    cin >> n >> k;

    //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<300000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }
   ll i;
   ll red;
   ll blue;
   blue=k;
   red=n-k;
   ll r,b;
   int flag=0;
   for(i=1 ;i<=k;i++){
     r=red-(i-1);
     b=blue-i;
     if(r<0||blue<0){flag=-1;std::cout << 0 << std::endl;}
     else{long long ans=comb(r+i,r)*comb(b+i-1,b);ans=ans%M;
         std::cout << ans<< std::endl;}
    }
}


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

using namespace std;

int main() {
	string s;
	int k;
	cin >> k  >> s ;
	int n;
	n=s.size();
	if(n<=k){
		cout << s << endl;
		return 0;
	}
	else {
		for(int i=0;i<k;i++){
			cout << s[i];
		}
	cout << "..." << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3612
A,B,C,D,E,F = map(int,input().split())

maxE = 0
maxWS = [100*A,0]
for a in range(0,F//(100*A)+1):
	for b in range(0,(F-100*A*a)//(100*B)+1):
		if a +b == 0:
			continue
		for c in range(0,(F-100*A*a-100*B*b)//C+1):
			for d in range(0,(F-100*A*a-100*B*b-C*c)//D+1):
				
				s = C*c+D*d
				ws = 100*A*a+100*B*b+C*c+D*d
				e = s/ws*100
				
				if not e <= E/(100+E)*100:
					continue
				
				if maxE < e:
					maxE = e
					maxWS = [ws,s]
				
print(maxWS[0],maxWS[1])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define err(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

using namespace std;

typedef long long ll;

int cnt[31];

int main() {
	string s;
	cin >> s;
	
	for (char c : s) cnt[c - 'a']++;
	
	ll ans = 1;
	for (int i = 0; i < 31; i++) {
		int cur = 0;
		for (int j = i + 1; j < 31; j++) cur += cnt[j];
		ans += 1ll * cnt[i] * cur;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 644
import sys
def input():
    return sys.stdin.readline()[:-1]
d = {}
ans = 0
n = int(input())
s = [''.join(sorted(input())) for i in range(n)]
for string in s:
    if string in d:
        ans += d[string]
        d[string] += 1
    else:
        d[string] = 1
print(ans)


Measured memory_bytes: 19460
#include<stdio.h>
int main (void)
{
    int w,n,a,b,i,tate[31]={0},box;
    scanf("%d%d",&w,&n);
    for(i=0;i<=w;i++){
        tate[i]=i;
    }
    for(i=0;i<n;i++){
        scanf("%d,%d",&a,&b);
        box=tate[a];
        tate[a]=tate[b];
        tate[b]=box;
    }
    for(i=1;i<=w;i++){
        printf("%d\n",tate[i]);
    }
    return 0;
}

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

#define _GLIBCXX_DEBUG

//vector<int> A(M), B(M);
//vector<vector<char>> answer(N, vector<char>(N, '-'));

int main() {
  char c;
  string ans;
  
  cin >> c;
  
  cout << ++c << endl;
  return 0;
}

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

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

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

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

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int win[100];

void brute() {
    win[1] = 1;
    FOR(i,2,11) {
        set<int> cur;
        FOR(j,1,i+1) {
            int z = 0; FOR(k,j,i) z ^= win[k];
            cur.insert(z);
        }
        for (int j = 0;;++j) if (!cur.count(j)) {
            win[i] = j;
            break;
        }
        cout << i << " " << win[i] << "\n";
    }
}

ll N,L,ans; 

void simp(ll x) {
    ll t = 1;
    while (x % 2 == 0) {
        t *= 2;
        x /= 2;
    }
    ans ^= t;
}

struct {
    int nex[MX][2], z = 0;
    void ins(string s) {
        int cur = 0;
        for (char c: s) {
            if (!nex[cur][c-'0']) nex[cur][c-'0'] = ++z;
            cur = nex[cur][c-'0'];
        }
    }
    void dfs(int cur, int len) {
        if (len == L) return;
        F0R(i,2) {
            if (nex[cur][i]) dfs(nex[cur][i],len+1);
            else simp(L-len);
        }
    }
} tri;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N >> L;
    F0R(i,N) {
        string s; cin >> s;
        tri.ins(s);
    }
    tri.dfs(0,0);
    if (ans) cout << "Alice";
    else cout << "Bob";
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 4844
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a<=b){
            System.out.println(a);
        }else{
            System.out.println(a-1);
        }
    }

}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M,m;
  cin >> N >> M;
  m = M;
  
  for (int i = 1; i < N; i++) {
    int x;
    cin >> x;
    M = max(M,x);
    m = min(m,x);
  }
  
  cout << M - m << endl;
}

Measured memory_bytes: 256
dist_lake, num_home = map(int, input().split())
dist_start_to_home = tuple(map(int, input().split()))

max_length = 0

for index, dist in enumerate(dist_start_to_home):
  	
    if index == len(dist_start_to_home) - 1:
      	length = dist_lake - (dist_start_to_home[index] - dist_start_to_home[0])
    else:
      	length = dist_start_to_home[index + 1] - dist_start_to_home[index]
    if max_length < length:
    	max_length = length
print('{}'.format(dist_lake - max_length))

Measured memory_bytes: 26692
#include <bits/stdc++.h>
#include <iomanip>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}


int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int n;
  string s;
  cin >> n >> s;
  int sum=0;
  for(int i=0;i<n;){
    int j=i;
    while(j<n && s[i]==s[j]) j++;
    sum++;
    i=j;
  }
  
  cout<<sum<<endl;
  
}

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

int main(){
    int64_t N; cin >> N;
    int64_t ans = 0;
    if(N & 1) ans = 0;
    else{
        N >>= 1; 
        while(N) { ans += N/5; N /= 5;}
    }

    cout << ans << endl;
}

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

int main(){
    int n;
    scanf("%d\n",&n);
    int p[n];
    int ans=0;
    for(int i=0;i<n;i++){
        scanf("%d",&p[i]);
    }
    int min=p[0];
    for(int i=1;i<n;i++){
        if(p[i]<min) ans++;
        if(min>p[i]) min=p[i];
    }

    printf("%d\n",ans+1);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define iii tuple<int, int, int>
#define ii pair<int, int>
#define fi first
#define se second

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve() {
    int a, b;
    cin >> a >> b;
    cout << 1LL * a * b / __gcd(a, b) << '\n';
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    // freopen("in", "r", stdin);

    int t = 1;
    // cin >> t;
    while (t--) solve();

    return 0;
}

Measured memory_bytes: 256
#include<functional>
#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define int long long
using namespace std;
const int INF=1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

signed main(){
  int n;
  string s;
  cin>>n>>s;
  int ans=0;
  rep(i,n){
    if((s[i]=='x'&&s[i+1]=='x')){
      ans++;
      break;
    }
    else ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3340
#include<bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
const int INF = 1e9;
const int MOD = 1e9+7;

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int A, B, C; cin >> A >> B >> C;
    if((A == B && A != C) || (B==C && B != A) || (C==A && C != B))  cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[]args) {
		Scanner input=new Scanner(System.in);
		int a;
		int b;
		int c;
		do {
			a=input.nextInt();
			b=input.nextInt();
			c=input.nextInt();
		}while(a<1&&a>100&&b<1&&b>100&&c<1&&c>100);
		if((a+b==c)||(a+c==b)||(b+c==a)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 26916
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll z, w;
    cin >> n >> z >> w;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<vector<ll>> dp(n + 10, vector<ll>(2));
    for(int i = n - 1; i >= 0; i--) {
        dp[i][0] = -LLINF;
        chmax(dp[i][0], llabs((i == 0 ? w : a[i - 1]) - a[n - 1]));
        for(int j = i + 1; j < n; j++) {
            chmax(dp[i][0], dp[j][1]);
        }
        dp[i][1] = LLINF;
        chmin(dp[i][1], llabs((i == 0 ? z : a[i - 1]) - a[n - 1]));
        for(int j = i + 1; j < n; j++) {
            chmin(dp[i][1], dp[j][0]);
        }
    }
    cout << dp[0][0] << endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <queue>
#include <set>
#include <stack>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const ll MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

const int N = 1005;

string s;
int h,w;
char c[N][N];
ll dp[N][N];

ll cal(int i, int j) {
  if(dp[i][j] != -1) return dp[i][j];
  else if(c[i][j] == '#') dp[i][j] = 0;
  else {
    if(i==1 && j==1) dp[i][j] = 1;
    else if(i==1) dp[i][j] = cal(i,j-1);
    else if(j==1) dp[i][j] = cal(i-1, j);
    else dp[i][j] = (cal(i-1,j) + cal(i,j-1)) % MOD;
  }
  return dp[i][j];
}

int main () {
  cin >> h >> w;
  rep(i,N) rep(j,N) dp[i][j] = -1;
  rep(i,h) {
    cin >> s;
    rep(j,w) {
      c[i+1][j+1] = s[j];
    }
  }
  cout << cal(h,w) << endl;
}


Measured memory_bytes: 9216
a, b = map(int, input().split())

if a > 0 and b > 0:
    print("Positive")

elif a < 0 and b < 0:
    if (abs(a) - abs(b)) % 2 == 0:
        print("Negative")
    else:
        print("Positive")

else:
    print("Zero")


Measured memory_bytes: 2940
import java.io.*;
class Main{
	public static void main(String[]args)throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb=new StringBuilder();
		
		String str=br.readLine();
		int n=Integer.parseInt(str);
		
		String[] a=br.readLine().split(" ");
		for(int i=n-1;i>=0;i--){
			sb.append(a[i]);
			if(i!=0){
				sb.append(" ");
			}
		}
		System.out.println(sb);
	}
}

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

int main() { 
    int N, M;
    cin >> N >> M;
    int maxL = 0;
    int minR = N;
    for (int i=0; i<M; i++) {
        int l, r;
        cin >> l >> r;
        l--;
        r--;
        if (l > maxL) maxL = l;
        if (r < minR) minR = r;
    }

    int res = max(0, minR - maxL + 1);

    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

  public static void main(String[] arg){
  		Scanner sc=new Scanner(System.in);
    
    	int n=sc.nextInt();
    	int m=sc.nextInt();
    
    	if(m>=n%500){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }
  }
  
}

Measured memory_bytes: 21844
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

vector <int> edges[100000];
int color[100000];
int order[100000];
bool used[100000];
vector <pair <int, pair<int, int> > >ord_v_c[11];
int main(){ 
    int N;
    int M;
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int a;
        int b;
        cin >> a >> b;
        edges[a - 1].push_back(b - 1);
        edges[b - 1].push_back(a - 1);
    }

    int Q;
    cin >> Q;
    for(int i = 0; i < Q; i++){
        int v;
        int d;
        int c;
        cin >> v >> d >> c;
        ord_v_c[d].push_back(make_pair(i, make_pair(v - 1, c)));
    }

    for(int i = 0; i < N; i++){
        color[i] = 0;
        order[i] = -1;
    }

    for(int i = 10; i >= 0; i--){
        sort(ord_v_c[i].begin(), ord_v_c[i].end());
        for(int j = 0; j < N; j++){
            used[j] = false;
        }
        for(int j = ord_v_c[i].size() - 1; j >= 0; j--){
            auto tmp = ord_v_c[i][j];
            int cur_ord = tmp.first;
            int cur_v = tmp.second.first;
            int cur_c = tmp.second.second;
            if(used[cur_v]){
                continue;
            }
            if(cur_ord > order[cur_v]){
                order[cur_v] = cur_ord;
                color[cur_v] = cur_c;
            }
            used[cur_v] = true;
            if(i > 0){
                for(int k = 0; k < edges[cur_v].size(); k++){
                    int next_v = edges[cur_v][k];
                    if(!used[next_v]){
                        ord_v_c[i - 1].push_back(make_pair(cur_ord, make_pair(next_v, cur_c)));
                    }
                }
            }
        }
    }

    for(int i = 0; i < N; i++){
        cout << color[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 20680
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
sum_ab = [(i, v[0]+v[1]) for i, v in enumerate(ab)]
sum_ab.sort(key=lambda x: x[1], reverse=True)
t_res = 0
a_res = 0
for i,v in enumerate(sum_ab):
    if i % 2 == 0:
        t_res += ab[v[0]][0]
    else:
        a_res += ab[v[0]][1]
print(t_res-a_res)

Measured memory_bytes: 42592
#include<iostream>
#include<stdio.h>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
	int A1,A2,A3;
	cin >> A1 >> A2 >> A3;
	int a[] ={A1,A2,A3};
	sort(a,a+3);
	cout << abs(a[0]-a[1])+ abs(a[1] - a[2]) << endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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 main() {
	int A,B;
	cin >> A >> B;
	int H,M;
	cin >> H >> M;
	double ap,bp;
	double pi = acos(-1);
	ap = 2 * pi * (1-((H*1.0 + M*1.0 / 60) / 12)) + pi/2;
	bp = 2 * pi * (1-(M*1.0 / 60)) + pi/2;
	if(ap < 0) ap += 2*pi;
	if(bp < 0) bp += 2*pi;
	if(ap > 2*pi) ap -= 2*pi;
	if(bp > 2*pi) bp -= 2*pi;
	double ans = 0;
	double ax,ay,bx,by;
	ax = A*cos(ap);
	ay = A*sin(ap);
	bx = B*cos(bp);
	by = B*sin(bp);
	ans = sqrt((ax-bx)*(ax-bx) + (ay-by)*(ay-by));
	/*if(ap > bp) {

	}
	else if (ap == bp) {
		ans = abs(A-B);
	}
	else {

	}*/

	cout << setprecision(20) << ans << endl;
  return 0;
}


Measured memory_bytes: 4088
#!/usr/bin/env python
# coding: utf-8

# In[5]:


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


# In[6]:


if A >= B-2:
    bisc = K+1
else:
    n = (K-A+1)//2
    bisc = 1+K-2*n+(B-A)*n
print(bisc)


# In[ ]:






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

ll inf=1e18;

int main() {
  ll n,a,b,c;
  cin >> n >> a >> b >> c;
  vector<ll> l(n);
  for(ll i=0;i<n;i++) {
    cin >> l[i];
  }
  ll ans=inf;
  for(ll m=0;m<(1<<2*n);m++) {
    ll tans=0;
    ll count=0;
    ll temp=m;
    ll t1=0,t2=0,t3=0;
    while(temp) {
      if(temp%4==1) {
        if(t1!=0) {
          tans+=10;
        }
        t1+=l[count];
      }
      if(temp%4==2) {
        if(t2!=0) {
          tans+=10;
        }
        t2+=l[count];
      }
      if(temp%4==3) {
        if(t3!=0) {
          tans+=10;
        }
        t3+=l[count];
      }
      count++;
      temp/=4;
    }
    if(t1==0||t2==0||t3==0) {
      continue;
    }
    tans+=abs(a-t1)+abs(b-t2)+abs(c-t3);
    ans=min(ans,tans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

int main() {
    int n;
    while ( cin >> n && n ) {
        int res = 0;
        for ( int i = 0; i < 54; ++ i ) {
            for ( int j = 0; j < 100; ++ j ) {
                int sum = i * i * i + j * ( j + 1 ) * ( j + 2 ) / 6;
                if ( sum <= n ) res = max( res, sum );
            }
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  double t,a;
  cin >> t >> a;
  double h;
  cin >> h;
  double min_t = abs(t - 0.006 * h - a);
  int min_i = 1;
  for(int i = 1;i < n;i++) {
    cin >> h;
    if(min_t > abs(t - 0.006 * h - a)) {
      min_t = abs(t - 0.006 * h - a);
      min_i = i + 1;
    }
  }
  cout << min_i << endl;
}

Measured memory_bytes: 256