akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forn for(int i=0;i<n;i++)
int main()
{
    int n;
    cin>>n;
    string s;
  cin>>s;
  int east=0;
  int west=0;
  forn 
  {
      if(s[i]=='E') east++;
      else west++;
  }
  int ans=n;
  int w=0,e=0;
  forn
  {
     if(s[i]=='E') east--;
     if(s[i-1]=='W') east++;
     ans=min(ans,east);
  }
    cout<<ans;
    return 0;
}


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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int INF = 1e9 + 7;

int main() {
  int a;
  cin >> a;
  int sum = 0;
  int n = a;
  while (n >= 10) {
    sum += n % 10;
    n /= 10;
  }
  sum += n;
  if (a % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
def run():
	N = int(input())
	stock = 0
	ans = 0
	count = 0
	clr = [int(x) for x in input().split()]

	for i in clr:
		if stock == i:
			count += 1

		else:
			ans += count // 2
			count = 1
			stock = i

	ans += count // 2
	print(ans)



if __name__ == '__main__':
	run()

Measured memory_bytes: 3060
#include<cstdio>
#include<cmath>
typedef long long ll;
using namespace std;
int main(){
    ll n,x[1000],y[1000],two[35],sum[36],a,b,c,d;
    char s[36];
    scanf("%lld",&n);
    for(int i=0;i<n;i++){
        scanf("%lld %lld",&x[i],&y[i]);
    }
    for(int i=1;i<n;i++){
        a=abs(x[i]+y[i]);
        b=abs(x[0]+y[0]);
        if(a%2!=b%2){
            printf("-1\n");
            return 0;
        }
    }
    if((x[0]+y[0])%2){
        two[0]=1;
        for(int i=1;i<35;i++){
            two[i]=2*two[i-1];
        }
    }
    else{
        two[0]=two[1]=1;
        for(int i=2;i<35;i++){
            two[i]=2*two[i-1];
        }
    }
    sum[0]=0;
    for(int i=0;i<35;i++){
        sum[i+1]=sum[i]+two[i];
    }
    s[35]='\0';
    printf("35\n");
    for(int i=0;i<35;i++){
        printf("%lld ",two[i]);
    }
    printf("\n");
    for(int i=0;i<n;i++){
        for(int j=34;j>=0;j--){
            a=abs(x[i]+two[j])+abs(y[i]);
            b=abs(x[i]-two[j])+abs(y[i]);
            c=abs(x[i])+abs(y[i]-two[j]);
            d=abs(x[i])+abs(y[i]+two[j]);
            if(a<=sum[j]){
                s[j]='L';
                x[i]+=two[j];
            }
            else if(b<=sum[j]){
                s[j]='R';
                x[i]-=two[j];
            }
            else if(c<=sum[j]){
                s[j]='U';
                y[i]-=two[j];
            }
            else if(d<=sum[j]){
                s[j]='D';
                y[i]+=two[j];
            }
        }
        printf("%s\n",s);
    }
}

Measured memory_bytes: 256
#include <iostream>
typedef long long ll;
using namespace std;
int arr[200001];
ll tree[800001];
int lazy[800001];
ll pre[11][200'010];
ll mod=998244353;
ll merge(ll a,ll b,int c){
    return (a*pre[10][c]+b)%mod;
}
ll init(int n, int s, int e){
    if(s==e) {
        return tree[n]=1;
    }
    int mid=(s+e)>>1;
    int gn=n<<1;
    tree[n]=merge(init(gn,s,mid),init(gn|1,mid+1,e),e-mid);
    return tree[n];
}
void update_lazy(int node, int start, int end) {
    if (lazy[node] != 0) {
        tree[node] = pre[lazy[node]][end-start+1];
        if (start != end) {
            lazy[node<<1] = lazy[node];
            lazy[node<<1|1] = lazy[node];
        }
        lazy[node] = 0;
    }
}

void update(int n, int s, int e, int left, int right, long long diff){
    update_lazy(n, s, e);
    if(left>e||right<s) return;
    int gn=n<<1;
    int mid=(s+e)>>1;
    if(left<=s&&e<=right){
        lazy[n]=diff;
        update_lazy(n, s, e);
        return;
    }
    update(gn,s,mid,left,right,diff);
    update(gn|1,mid+1,e,left,right,diff);
    tree[n]=merge(tree[gn],tree[gn|1],e-mid);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n,m;
    cin>>n>>m;
    for(int i=0;i<10;i++)pre[i][1]=i;
    pre[10][0]=1;
    pre[10][1]=10;
    for(int i=2;i<200'010;i++){
        pre[10][i]=(pre[10][i-1]*10)%mod;
        for(int j=1;j<10;j++){
            pre[j][i]=(pre[j][i-1]*10+j)%mod;
        }
    }

    init(1, 1, n);

    int c,a,b;
    for(int i=0;i<m;i++){
        cin>>c>>a>>b;
        update(1,1,n,c,a,b);
        cout<<tree[1]<<'\n';
    }
}

Measured memory_bytes: 25404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
	if (b==0) return a;
    else{
    	return gcd(b,a%b);
    }
}
 
int main() {
	ll a,b;
  	cin >> a >> b;
  	cout << a*a-b << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
char t1[1510];
char t2[1510];
int main(){
	int n;
	int a=0,b=0;
	int i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s %s",&t1,&t2);
		if(strcmp(t1,t2)==0) a++,b++;
		if(strcmp(t1,t2)>0) a+=3;
		if(strcmp(t1,t2)<0) b+=3;
	}
	printf("%d %d\n",a,b);
	return 0;
}



Measured memory_bytes: 2048
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    A,B,X = (int(_) for _ in input().split())
    if X<A:
        print('NO')
    elif A+B<X:
        print('NO')
    else:
        print('YES')
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    REP(i,n) cin>>a[i];

    a.insert(a.begin(),0);
    a.push_back(0);
    int sum=0;
    REP(i,n+1) sum+=abs(a[i+1]-a[i]);

    REP2(i,1,n+1) cout<<(((a[i]-a[i-1])*(a[i+1]-a[i])<0)? sum-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i+1]-a[i-1]):sum)<<endl;

	return 0; 
}

Measured memory_bytes: 1656
#include <bits/stdc++.h>
using namespace std;
int main () {
  int H, N;
  cin >> H >> N;
  long sum = 0, a;
  for(int i = 0; i < N; i++){
    cin >> a;
    sum += a;
  }
  if(sum < H)cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,t;
    int sum,num;
    scanf("%d%d%d",&a,&b,&t);
    sum=0;
    num=a;
    if(num>t+0.5)
        printf("0\n");
    else
    {
        while(num<=t+0.5)
        {
            sum+=b;
            num+=a;
        }
        printf("%d\n",sum);
    }
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <cmath>
using namespace std;

#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647

int main() {
	int N, M;
	cin >> N >> M;
	vector<pair<int, int>> vec;
	/*
	vector<int> vec1
	vec.push_back();

	vector<vector<int>> vec2;
	vec[0].push_back();

	sort(vec[0].begin(), vec[0].end());

	vectorの形 
	N行0列の2次元vector
			0	1	2	3
	vec[0] 
	1 <- こいつの要素はvector<int>で宣言されている
	2
	3
	4
	.
	.
	.
	.
	.
	N-1
	*/


	vector<vector<int>> vec2(N + 1);

	for (int i = 0; i < M; ++i) {//入れる処理
		int p, y;
		cin >> p >> y;
		vec.push_back(make_pair(p, y));
		vec2[p].push_back(y);
	}

	map<pair<int, int>, int> mp;
	for (int i = 1; i <= N; ++i) {
		sort(vec2[i].begin(), vec2[i].end());//vec[i]の要素をソート
		/*
		p:県の番号
		y:その県の中にある市の誕生年
		p	y
		1	55	91	42	45	12	01	49	73	71
		2	81	84	12	47	472	374
				*/
		int number = 1;
		for (int j = 0; j < vec2[i].size(); ++j) {
			mp[make_pair(i, vec2[i][j])] = number++;
 		}
	}

	for (int i = 0; i < vec.size(); ++i) {
		printf("%06d%06d\n", vec[i].first, mp[vec[i]]);
	}
	return 0;
}

Measured memory_bytes: 15504
N = int(input())
List = list(map(int,input().split()))

S1, S2 = 0, 0
j, k = 0, 0

for i in range(N):
    if S1 <= S2:
        S1 += List[j]
        j += 1
    else:
        S2 += List[N-k-1]
        k += 1

result = abs(S1 - S2)
print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
	long long arr[n];
	long long mult=1;
	for(int i=0;i<n;i++){
		cin>>arr[i];
		if(arr[i]==0){
			cout<<0;
			return 0;
		}
	}
	long double cult=1;
	sort(arr,arr+n);
	for(int i=0;i<n;i++){
		cult=cult*arr[i];
		if(cult>1e18){
			cout<<-1;
			return 0;
		}
		mult=mult*arr[i];
	}
	cout<<mult;
	return 0;
}

Measured memory_bytes: 4380
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
int a[1000000],b[1000000];
int main()
{
	int n=read();int m=0;
	reg int i,gs,j;
	for(i=1;i<=n;++i)a[i]=read();
	for(i=n;i>=1;--i)
	{
		gs=0;
		for(j=2;j*i<=n;++j)
			gs+=b[j*i];
		gs%=2;
		if(a[i])
		{
			if(gs==0)b[i]=1;
		}
		else
		{
			if(gs)b[i]=1;
		}
	}
	for(i=1;i<=n;++i)m+=b[i];
	cout<<m<<"\n";
	for(i=1;i<=n;++i)
		if(b[i])cout<<i<<" ";cout<<"\n";
	return 0;
}


Measured memory_bytes: 5760
x = int(input())
if 400 <= x <= 599:
    rating = 8
elif 600 <= x <= 799:
    rating = 7
elif 800 <= x <= 999:
    rating = 6
elif 1000 <= x <= 1199:
    rating = 5
elif 1200 <= x <= 1399:
    rating = 4
elif 1400 <= x <= 1599:
    rating = 3
elif 1600 <= x <= 1799:
    rating = 2
elif 1800 <= x <= 1999:
    rating = 1
print(rating)


Measured memory_bytes: 9180
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int n;cin >> n;
    vi a(n);rep(i, n)cin >> a[i];
    sort(all(a));
    int count = 0;
    // rep(i, n)cout << a[i] << ' ';
    // cout << endl;
    // rep(i, n)cin >> a[i];
    for(int i = 0;i<n-2;i++) {
        for(int j = i+1;j<n-1;j++) {
            for(int k = j+1;k<n;k++) {
                if(a[k]<a[i]+a[j]){
                    if(a[i]==a[j]||a[j]==a[k])continue;
                    count++;
                    // cout << i+1 << ' ' << j+1 << ' ' << k+1 << endl;
                }
                
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3624
from sys import stdin
N = int(input())
L =[stdin.readline().split() for _ in range(N)]
for n in range(N):
  L[n][1] = int(L[n][1])
for n in range(N):
  L[n][1] = -L[n][1]
for n in range(N):
  L[n].append(n)
L1 = sorted(L, reverse=False, key=lambda x: x[1])
L2 = sorted(L1, reverse=False, key=lambda x: x[0])
for n in range(N):
  print(L2[n][2]+1)


Measured memory_bytes: 9084
let () = Scanf.scanf "%d" @@ fun n ->
  let pow = Array.make 12 0 in
  pow.(0) <- 1;
  for i = 0 to 10 do
    pow.(i + 1) <- 26 * pow.(i)
  done;
  let rec aux n d (p :: ps) k =
    if n < p
    then k n d
    else aux (n - p) (d + 1) ps k in
  let rec solve acc n = function
    | 0 -> acc
    | d -> solve (Char.chr (Char.code 'a' + n mod 26) :: acc) (n / 26) (d - 1) in
  List.iter print_char @@ aux n 0 (Array.to_list pow) @@ solve ['\n']



Measured memory_bytes: 3764
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
#define MAX 330
#define MOD 1000000007
inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch>'9'||ch<'0') {if(ch=='-')f=-1;ch=getchar();}
	while(ch<='9'&&ch>='0') x=x*10+ch-'0',ch=getchar();
	return x*f;
}

void add(int &x,int y)
{
	x+=y;
	if(x>=MOD)
	x-=MOD;
}
int n,m,f[MAX][MAX][MAX],ans;
struct Node{int l,x;};
vector<Node> e[MAX];
bool check(int a,int b,int c)
{
    int r=max(a,max(b,c));
    for(int i=0,t=e[r].size();i<t;++i)
    {
        int l=e[r][i].l,x=e[r][i].x,s=0;
        s=(a>=l)+(b>=l)+(c>=l);
        if(s!=x)return false;
    }
    return true;
}
int main()
{
    n=read();m=read();
    for(int i=1;i<=m;++i)
    {
        int l=read(),r=read(),x=read();
        e[r].push_back((Node){l,x});
    }
    f[0][0][0]=1;
    for(int i=0;i<=n;++i)
        for(int j=0;j<=n;++j)
            for(int k=0;k<=n;++k)
            {
                if(!f[i][j][k])continue;
                if((i&&k&&i==k)||(i&&j&&i==j)||(j&&k&&j==k))continue;
                if(!check(i,j,k))
				{
					f[i][j][k]=0;
					continue;
				}
                int r=max(i,max(j,k));
                add(f[r+1][j][k],f[i][j][k]);
                add(f[i][r+1][k],f[i][j][k]);
                add(f[i][j][r+1],f[i][j][k]);
                if(r==n)add(ans,f[i][j][k]);
            }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 129152
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define MAX 3004
#define B 100
#define dpb push_back
#define fi first
#define se second
typedef pair<int, int> P;
typedef long long ll;
const int inf = 1e9;
const ll INF = 1e18;
//__gcd(a,b), __builtin_popcount(a);

int sum = 0, ans = 0, ky, kx, a[12][12], f[12][12];
int dy[4] = {0, 0, -1, 1}, dx[4] = {-1, 1, 0, 0};

void dfs(int y, int x, int cnt){
	for(int i = 0;i < 4;i++){
		int yy = y;
		int xx = x;
		while(1){
			yy += dy[i];
			xx += dx[i];
			if(a[yy][xx] == -1)break;
			if(a[yy][xx] == 1 && f[yy][xx] == 0){
				f[yy][xx] = 1;
				dfs(yy, xx, cnt+1);
				f[yy][xx] = 0;
				break;
			}
			if(a[yy][xx] == 2 && cnt == sum){
				ans++;
				return ;
			}
		}
	}
}

int main(){
	int w, h;
	while(1){
		scanf("%d%d",&w, &h);
		if(w == 0)break;
		fill((int*)a, (int*)(a+12), -1);
		fill((int*)f, (int*)(f+12), 0);
		sum = ans = 0;
		rrep(i,h)rrep(j,w){
			scanf("%d", &a[i][j]);
			if(a[i][j] == 2){ky = i;kx = j;}
			if(a[i][j] == 1)sum++;
		}
		
		dfs(ky, kx, 0);
		printf("%d\n", ans);
	}
	return 0;
}



Measured memory_bytes: 3140
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

P = [p-1 for p in P]
#print(P)

visited = set()
ans = 0
for i in range(N):
  if i in visited:
    continue
  tmp = []
  j = i
  while j not in visited:
    tmp.append(C[j])
    visited.add(j)
    j = P[j]
  #print(tmp,visited)  
  M = len(tmp)
  L = max(0,sum(tmp))
  now = L * (K // M)
  k = K % M
  tmp2 = 0
  tmp4 = 0
  for l in range(1,min(M,K)+1):
    tmp2 += tmp[l-1]
    tmp3 = tmp2
    for j in range(M):
      tmp4 = max(tmp4, tmp3) 
      tmp3 += tmp[(j+l)%M] - tmp[j%M]
      #print(tmp4, l, j)
      ans = max(ans, now+tmp4 if l <= k else now+tmp4-L)
  #ans = max(ans, now+tmp4 if l <= k else now+tmp4-L) 
  #print(i, L, now, l, k, tmp4, M, visited, now+tmp4)
  del tmp

flag = True
for c in C:
  if c > 0:
    flag = False
    
print(max(C) if flag else ans)

    
  
    


Measured memory_bytes: 71260
n, x = map(int, input().split())
a = max(n-x, x); b = min(n-x, x)
res = n
while b!=0:
    p=a; q=int(a/b); r=a%b
    res+=q*(2*b)
    if r==0:
        res-=b
    a=b; b=r

print(res)

Measured memory_bytes: 61884
#include <iostream>
#include <algorithm>

using namespace std;

int n,m;
int x,s;
int a[100000];

int main(void){

  while( cin >> n >> m , n || m ){

    for( int i = 0 ; i < n ; i++ ){
      cin >> a[i];
    }
    x = 0;
    for( int i = 0 ; i < m ; i++ ){
      x += a[i];
    }
    s = x;
    for( int i = 0 ; i < n - m ; i++ ){
      x -= a[i];
      x += a[i + m];
      if( s < x ) s = x;
    }

    cout << s << endl;

  }
  return 0;
}

Measured memory_bytes: 1548
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

int main() {
  int A, B, T; cin >> A >> B >> T;
  int x = T / A;
  cout << B * x << endl;
                 
}


Measured memory_bytes: 256
// Two Color Card Game

#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int N;
	cin >> N;
	string s[N];
	for (int i = 0; i < N; ++i)
		cin >> s[i];
	int M;
	cin >> M;
	string t[M];
	for (int i = 0; i < M; ++i)
		cin >> t[i];

	int maxv = 0;

	for (int i = 0; i < N; ++i){
		int cnt = 0;
		for (int j = 0; j < N; ++j){
			if (s[i] == s[j])
				cnt++;
		}
		for (int j = 0; j < M; ++j){
			if (s[i] == t[j])
				cnt--;
		}
		maxv = max(maxv, cnt);
	}
	cout << maxv << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<functional>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X <<":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e14;
typedef std::pair<ll,ll> P;
struct edge{ int to,cost; };
#define VMAX 100000

ll N,M,X;
ll A,B,C;
string S;
ll ans;
int main(){

    cin>>A>>B;

    cout<<(A*B%2==0?"Even":"Odd")<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
string str[10], in;
 
void init(){
    str[0] = "* = ****";
    str[1] = "* =* ***";
    str[2] = "* =** **";
    str[3] = "* =*** *";
    str[4] = "* =**** ";
    str[5] = " *= ****";
    str[6] = " *=* ***";
    str[7] = " *=** **";
    str[8] = " *=*** *";
    str[9] = " *=**** ";
}
 
void solve(string s, int count)
{
    if (count) cout << endl;
 
    int len = (int)s.size();
    string ans[5];  
 
    if (len == 5) {
	for (int i = 0; i < len; i++) {
	    ans[i] = str[s[i]-'0'];
        }
    } else {
	for (int i = 0; i < 5-len; i++) {
	    ans[i] = str[0];
	}
   
	int t = 0;
	for (int i = 5-len; i < 5; i++) {
	    ans[i] = str[s[t++]-'0'];
        }
    }
 
    for (int i = 0; i < 8; i++) {
	for (int j = 0; j < 5; j++) {
	    cout << ans[j][i];
	}
	cout << endl;
    }
}
 
int main()
{
    init();
    int count = 0;
    while (cin >> in) {
	solve(in, count);
	count++;
    }
    return 0;
}

Measured memory_bytes: 3168
#include<iostream>
#include<cstdio>

using namespace std;

int main() {
  int N, X, m;
  long long cnt = 0;
  int minm = 2000;

  cin >> N >> X;

  for (int i = 0; i < N; i++) {
    scanf("%d", &m);
    X -= m;
    cnt += 1;
    if (minm > m) minm = m;
  }

  while (X >= minm) {
    X -= minm;
    cnt += 1;
  }

  cout << cnt << endl;

  return 0;
}


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

typedef struct _Point {
  double x, y;
} Point;

typedef Point Vector;

Vector add(Vector a, Vector b) {
  a.x += b.x;
  a.y += b.y;
  return a;
}

Vector subtract(Vector a, Vector b) {
  a.x -= b.x;
  a.y -= b.y;
  return a;
}

Vector multiply(Vector a, double b) {
  a.x *= b;
  a.y *= b;
  return a;
}

Vector divide(Vector a, double b) {
  a.x /= b;
  a.y /= b;
  return a;
}

Vector rotate(Vector v, double angle) {
  Vector nv;
  nv.x = v.x * cos(angle) - v.y * sin(angle);
  nv.y = v.x * sin(angle) + v.y * cos(angle);
  return nv;
}

Point rec(int n, Point a, Point b) {
  Vector v,u;
  Point c,d,e;
  if(n == 0) {
    printf("%.8f %.8f\n", a.x, a.y);
    return;
  }
  v = subtract(b,a);
  u = divide(v,3.0);
  c = add(a,u);
  d = add(c,u);
  e = add(c,rotate(u,M_PI/3.0));
  rec(n-1, a, c);
  rec(n-1, c, e);
  rec(n-1, e, d);
  rec(n-1, d, b);
}

int main() {
  int n;
  scanf("%d", &n);
  rec(n, (Point){0.0, 0.0}, (Point){100.0, 0.0});
  printf("%.8f %.8f\n", 100.0, 0.0);
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <unordered_map>
 
using namespace std;
typedef long long ll;
 
int main()
{
    ll N, T;
    cin >> N >> T;
    ll* c = new ll[N];
    ll* t = new ll[N];

    ll minCost = -1;
    for(ll i = 0; i < N; i ++){
        cin >> c[i] >> t[i];
        if(t[i] > T){
            continue;
        }
        if(minCost == -1 || minCost > c[i]){
            minCost = c[i];
        }
    }

    if(minCost == -1){
        cout << "TLE";
    }
    else{
        cout << minCost;
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            {for(ll i=0;i<size;i++) cout<<w[i]<<" ";cout<<"\n";}
#define print(a)                cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,val)               lower_bound(all(v),val)-v.begin()
#define ub(v,val)               upper_bound(all(v),val)-v.begin()
#define SS                      stringstream
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

ll poww(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a,ll m=MOD){if(m==1)return 0;ll m0=m,y=0,x=1;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0) x+=m0;return x;}

int main()
{
	fastIO
	ll p,n;
	cin>>p>>n;
	vll a(n);
	input(a,n);
	ll total=0;
	rep(i,0,n-1,1)
		total+=a[i];
	if(total>=p)
		cout<<"Yes";
	else cout<<"No";	
	return 0;
}




Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<iomanip>
using namespace std;
int main() {
  int n,k,a;
  cin >> n >> k;
  double c;
  for(int i=1; i<=n; i++) {
    a=i;
    double b=1;
    while(a<k) {
      b/=2;
      a*=2;
    }
    c+=b;
  }
  cout << fixed << setprecision(20) << c/n << endl;
}

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

from itertools import combinations


def main():
    N, D = map(int, input().split())
    X = [list(map(int, input().split()))for _ in range(N)]
    count = 0
    for a, b in combinations(X, 2):
        tmp = 0
        for d in range(D):
            tmp += abs(a[d] - b[d])**2
        if (tmp**0.5).is_integer():
            count += 1
    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
    #define REP(i, n) for(int i = 0;i < n;i++)
    #define REPR(i, n) for(int i = n;i >= 0;i--)
    #define FOR(i, m, n) for(int i = m;i < n;i++)
    #define FORR(i, m, n) for(int i = m;i >= n;i--)
    #define SORT(v, n) sort(v, v+n);
    #define VSORT(v) sort(v.begin(), v.end());
    #define llong long long
    #define pb(a) push_back(a)
    #define INF 1000000000000000000LL
    #define MOD 1000000007
    using namespace std;
    typedef pair<int, int> P;
    typedef pair<llong, llong> LP;
    typedef pair<int, P> PP;
    typedef pair<llong, LP> LPP;
    //vector<tuple<long long, long long, long long>>vec;

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

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


    int main()
    {
        int n;
        cin>>n;
        vector<llong> a(n,0);
        llong sum=0;
        REP(i,n)
        {
            cin>>a[i];
            sum+=a[i];
        }
        llong ans=INF;
        llong cnt=0;
        for (int i=0; i<n; i++)
        {
            cnt+=a[i];
            if(i+1<n) ans=min(ans,abs(sum-2*cnt));
        }
        cout<<ans<<endl;
    }

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 100010;

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	string s;
	cin >> s ;
	for(int i = 0;i<s.size() - 1;++i){
		if(s[i] == s[i+1]){
			cout << i + 1 << ' ' << i+2 << endl;
			return 0;
		}
		if(i < s.size() - 2 && s[i] == s[i+2]){
			cout << i + 1 << ' ' << i+3 << endl;
			return 0;
		}
	}
	cout << "-1 -1" << endl;
	return 0;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define pall(x) for(auto iter : x) p(iter)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define yn(x) cout << (x ? "Yes" : "No") << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int N;
    cin >> N;
    REP(i,N+1) {
        if (i % 3 != 0 && i % 5 != 0) ans += i;
    }

    pa;
    
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc162/abc162_b && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc162/abc162_b && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc162/abc162_b && sh shellscripts/submit_cpp.sh
*/


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

using namespace std;

int main()
{
    string S, T, s;
    int N;
    cin >> S;
    N = S.length();
    T = S;
    reverse(T.begin(), T.end());
    bool ans = false;
    if(S == T){
        s = S.substr(0, (N-1)/2);
        T = s;
        reverse(T.begin(), T.end());
        if(s == T){
            s = S.substr((N+1)/2);
            T = s;
            reverse(T.begin(), T.end());
            if(s == T){
                ans = true;
            }
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n;
	cin >> n;
	
	vector<int> a(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	
	int S = a[0];
	for(int i = 1; i < n; ++i) {
		S ^= a[i];
	}
	
	vector<int> res(n);
	for(int i = 0; i < n; ++i) {
		res[i] = S ^ a[i];
	}
	
	for(auto& ans : res) {
		cout << ans << " ";
	}		
	
	cout << endl;
	
	return 0;
}


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

const int MAX_N = 1010;
const int MAX_M = 10010;
const int MAX_TIME = 730;
int T[MAX_M][MAX_TIME];
int main()
{
    int N, M, r, q;
    while (cin >> N >> M, N || M)
    {
        // T配列の初期化
        for (int i = 0; i < M; ++i)
        {
            memset(T[i], 0, sizeof(T[i]));
        }
        // T[i][j] := i番目(0-indexed)の学生が何台のPCにログインしているか
        //            時刻[j, j+1)に
        cin >> r;
        while (r--)
        {
            int t, n, m, s;
            cin >> t >> n >> m >> s;
            --m;
            t -= 540; // 540 <= t <= 1260 を調整
            if (s == 1)
            {
                ++T[m][t];
            }
            else
            {
                --T[m][t];
            }
        }
        // 累積和にする
        for (int i = 0; i < M; ++i)
        {
            for (int j = 1; j < MAX_TIME; ++j)
            {
                T[i][j] += T[i][j - 1];
            }
        }
        int q;
        cin >> q;
        while (q--)
        {
            int ts, te, m;
            cin >> ts >> te >> m;
            --m;
            ts -= 540, te -= 540;
            int res = 0;
            for (int t = ts; t < te; ++t)
            {
                if (T[m][t] >= 1)
                    ++res;
            }
            cout << res << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 30604
N = int(input())
ARR = list(map(int,input().split()))



def calculate(n, arr):
    currentHeight = arr[0]
    result = 0
    for i in range(1,n):
        if arr[i] < currentHeight:
            result += (currentHeight - arr[i])
        else:
            currentHeight = arr[i]

    return result

res = calculate(N, ARR)

print(res)



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

int main(){
  int h,w,k;
  cin >> h >> w >> k;
  int c[h][w];
  rep(i,0,h){
    string s;
    cin >> s;
    rep(j,0,w){
      if(s[j]=='.') c[i][j] = 0;
      else c[i][j] = 1;
    }
  }

  int ans = 0;

  for(int bit_i=0;bit_i<(1<<h);bit_i++){
    vector<int> S_i;
    for (int i = 0; i < h;i++){
      if (bit_i & (1<<i)) S_i.push_back(i);
    }
    for(int bit_j=0;bit_j<(1<<w);bit_j++){
      vector<int> S_j;
      for (int j = 0; j < w; j++){
        if (bit_j & (1<<j)) S_j.push_back(j);
      }
      int tmp[h][w];
      rep(i,0,h)rep(j,0,w) tmp[i][j] = c[i][j];
      rep(k,0,(int)S_i.size()){
        rep(l,0,w) tmp[S_i[k]][l] = 0;
      }
      rep(k,0,(int)S_j.size()){
        rep(l,0,h) tmp[l][S_j[k]] = 0;
      }
      int sum = 0;
      rep(i,0,h)rep(j,0,w){
        sum += tmp[i][j];
      }
      if(sum==k) ans++;
    }    
  }

  cout << ans << endl;

  return 0;
}

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

int main() {
  long n;
  cin >> n;
  if (n % 2 == 1) {
    cout << 0 << endl;
  } else {
    n /= 2;
    long ans = 0;
    while (n) {
      ans += n / 5;
      n /= 5;
    }
    cout << ans << endl;
  }
}


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

namespace AtCoder.ABC094.D
{
    class Program
    {
        static void Main ()
        {
            var sc = new Scanner ();
            int n = sc.NextInt ();
            var a = sc.ArrayLong (n);
            var ai = a.Max ();
            var aj2 = ai / 2;
            var a2 = a.OrderByDescending (val => val).Skip (1);
            var min = a2.Min (val => Math.Abs (val - aj2));
            var aj = a2.First (val => Math.Abs (val - aj2) == min);
            Console.WriteLine ($"{ai} {aj}");
        }
        static long Factorial (int n)
        {
            long fact = n;
            for (int i = n - 1; i >= 1; i--)
            {
                fact *= i;
            }
            return fact;
        }

        static long Comb (int n, int r)
        {
            long child = 1;
            for (int i = 0; i < r; i++) child *= n - i;
            long mother = Factorial (r);
            return child / mother;
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner ()
        {
            s = new string[0];
            i = 0;
        }

        public string Next ()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine ();
            while (st == "") st = Console.ReadLine ();
            s = st.Split (cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next ();
            i = 0;
            return s[i++];
        }

        public int NextInt ()
        {
            return int.Parse (Next ());
        }
        public int[] ArrayInt (int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextInt () + add;
            }
            return Array;
        }

        public long NextLong ()
        {
            return long.Parse (Next ());
        }

        public long[] ArrayLong (int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextLong () + add;
            }
            return Array;
        }

        public double NextDouble ()
        {
            return double.Parse (Next ());
        }

        public double[] ArrayDouble (int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDouble () + add;
            }
            return Array;
        }

        public decimal NextDecimal ()
        {
            return decimal.Parse (Next ());
        }

        public decimal[] ArrayDecimal (int N, decimal add = 0)
        {
            decimal[] Array = new decimal[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDecimal ();
            }
            return Array;
        }
    }
}

Measured memory_bytes: 25952
program c176
 
implicit none
integer(16) :: n, i, m, x
integer(16), allocatable :: a(:)
 
read *, n
 
if(n == 1) then
 print *, 0
 stop
end if
 
allocate(a(1:n))
 
x = 0
 
read *, a(:)
 
do i = 1, n-1
 m = a(i) - a(i+1) 
 if(m < 0) then
  x = x
 !Print *, m ,x
 else
  x = x + m
  a(i+1) = a(i+1) + m
! Print *, m ,x
 end if
end do
 
 
!print *, a(:)
print *, x
 
end program c176


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

using namespace std;
inline void
prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
//printf("%.12lf\n",mid);
// __builtin_popcount(int) count 1's in binary
int mod;

int mymod(int num){
  if (num< 0){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}

double eps = .0000000001;

int main ()
{
  prep ();
  string s;
  cin >> s;
  int ones = 0;
  for (int i=0; i<s.size(); i++){
      if (s[i] == 'o'){
          ones++;
      }
  }
  int left = 15-s.size();
  if (ones+left >= 8){
      cout << "YES";
  }else{
      cout << "NO";
  }
  return 0;
}
// in dp problems think: up until here, intervals, or "what if there's 1, 2, 3..."
// in math problems write out equations
// also in math problems to change multiplication/division to addition/subtraction use logs, add/subtract something to make the multiplication easier (like if it's 3*f(x)+2, change it to 3*(f(x)+1)-1)
// if printint pow function, put an (int) or (long long) next to it
// if checked everything check for bugs (like sorting wrong way or not putting a break in a loop)
// if n is 10^7 try brute force if the operations are simple
// if can't do dp do brute force/greedy
// to save time don't copy maps/vectors into variables if it already exists
// only use long long if need to
// if wrong on decimal problem, check if program rounds or if you can round to a certain amt of decimals
// if decimals too, if can subtract instead of divide
// in grid traversal problems check if doing sideways or not
// if TLE try to take away loop
// in recursion looking math problems look at things from the point of view of both sides (the start and the end sections of the recursion)
// think about how many possible answers there are to the problem
// try to set the answer to the problem and see if it's possible (like w/ binary search)
// if it makes it easier use +1 indexing
// think twice when writing things down that you're going to use later
// for conversions think if you can compute them w/ only one conversion
// if the problem involves two things moving at the same time, see if you can generalise it to just one thing moving
// if nt think primes

Measured memory_bytes: 256
N=int(input())
MOD=1000000007
A=list(map(int,input().split()))
cnt=[0 for i in range(N)]
for i in range(N):
    cnt[A[i]]+=1
if N%2==0:
    for i in range(1,N,2):
        if cnt[i]!=2:
            print(0)
            break
    else:
        print(2**(N//2)%MOD)
else:
    if cnt[0]!=1:
        print(0)
    else:
        for i in range(2,(N+1)//2,2):
            if cnt[i]!=2:
                print(0)
                break
        else:
            print(2**((N-1)//2)%MOD)


Measured memory_bytes: 20384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, sum=0, i;
    cin>>n;
    int x=n;
    for(i=0; i<10; i++) {
        sum+=x%10;
        x=x/10;
    }
    if(n%sum) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
typedef long long int ll;
using namespace std;


ll N;
static ll a[200000];
static ll maxi[200000];
static ll cumsum[200002];
static ll diff[200001];
static ll maxi0[200001], maxi1[200001];

int main(){
  cin >> N;
  for(ll i=0;i<N;i++) cin >> a[i];

  for(ll i=2;i<=N+1;i++){
    cumsum[i] = cumsum[i-2] + a[i-2];
  }
  for(ll i=0;i<=N;i++){
    diff[i] = cumsum[i] - cumsum[i+1];
    // cerr << diff[i] << endl;
  }
  // cerr << endl;
  maxi0[0] = diff[0];
  for(ll i=2;i<=N;i+=2){
    maxi0[i] = max(maxi0[i-2], diff[i]);
    // cerr << maxi0[i] << endl;
  }
  // cerr << endl;
  maxi1[N] = diff[N];
  for(ll i=N-2;i>=1;i-=2){
    maxi1[i] = max(maxi1[i+2], diff[i]);
    // cerr << maxi1[i] << endl;
  }

  ll ans;
  if (N%2){
    ans = LLONG_MIN;
    for(ll i=0;i<N;i+=2){
      ll cand = cumsum[N+1] + maxi0[i] + maxi1[i+1];
      ans = max(ans, cand);
    }
  }else{
    ans = cumsum[N+1] + maxi0[N];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 11432
#include <stdio.h>
#include <math.h>
int main(void){
    // Your code here!
    int n;
    scanf("%d",&n);
    
    int c[501];
    int f[500];
    int s[500];
    for(int i=0;i<n-1;i++){
        scanf("%d%d%d",&c[i],&s[i],&f[i]);
    }
    
    for(int i=0;i<n-1;i++){
        int tim=0;
        for(int j=i;j<n-1;j++){
            if(tim<=s[j]){
                tim=s[j]+c[j];
            }else{
                //printf("%d %d %d :%f\n",i,j,tim,( (double)tim-(double)s[j] )/(double)f[j] );
                tim=s[j]+(int)ceil( ((double)tim-(double)s[j])/(double)f[j] )*f[j]+c[j];
                
            }
            //printf("%d %d %d\n",i,j,tim);
        }
        printf("%d\n",tim);
    }
    printf("0\n");
}

Measured memory_bytes: 1672
import java.util.*;

public class Main {
	private int[] p1, p2;

	public static void main(String[] args) {
		new Main().run();
	}
	
	private void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			int n = scan.nextInt();
			if (n == 0) break;
			
			p1 = new int[n];
			p2 = new int[n];
			for (int i = 0; i < n; i++) {
				p1[i] = scan.nextInt();
			}
			
			Arrays.sort(p1);
			
			int j = 0;
			int p = 0;
			for (int i = 0; i < 2 * n && p < n; i++) {
				
				if (j >= n || p1[j] != i+1) {
					p2[p] = i+1;
					p++;
				}else {
					j++;
				}
			}
			
			//debug();
			
			int card = 0, cnt1 = 0, cnt2 = 0;
			while (true) {
				boolean flag = false;
				for (int i = 0; i < n; i++) {
					if (p1[i] > card) {
						card = p1[i];
						p1[i] = -1;
						flag = true;
						//debug();
						break;
					}
				}
				if (!flag) {
					card = 0;
				}
				for (int i = 0; i < n; i++) {
					if (p1[i] != -1) cnt1++;
					if (p2[i] != -1) cnt2++;
				}
				
				if (cnt1 == 0) break;
				else cnt1 = cnt2 = 0;
				
				flag = false;
				for (int i = 0; i < n; i++) {
					if (p2[i] > card) {
						card = p2[i];
						p2[i] = -1;
						flag = true;
						//debug();
						break;
					}
				}
				if (!flag) {
					card = 0;
				}
				
				for (int i = 0; i < n; i++) {
					if (p1[i] != -1) cnt1++;
					if (p2[i] != -1) cnt2++;
				}
				
				if (cnt2 == 0) break;
				else cnt1 = cnt2 = 0;
			}
			
			System.out.println(cnt2);
			System.out.println(cnt1);
		}
	}
	
	private void debug() {
		System.out.println(Arrays.toString(p1));
		System.out.println(Arrays.toString(p2));
	}
}

Measured memory_bytes: 20516
from collections import deque

H,W=map(int,input().split())
H+=2
W+=2
s="#"*W
for _ in range(H-2):
    s+="#"+input()+"#"
s+="#"*W

answer=[]

for i in range(W*H):
    if s[i]=="#":
        continue
    dist=[-1]*(W*H)
    q=deque([i])
    dist[i]=0
    while len(q)>0:
        x=q.popleft()
        for j in [-1,1,W,-W]:
            if s[x+j]=="." and dist[x+j]==-1:
                q.append(x+j)
                dist[x+j]=1+dist[x]
    answer.append(max(dist))
print(max(answer))
            




Measured memory_bytes: 3316
#include <iostream>
#include <limits>

int main() {
  int n, max = std::numeric_limits<int>::min(),
         min = std::numeric_limits<int>::max();
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    if (i > 0) {
      int mayMax = x - min;
      if (mayMax > max) max = mayMax;
    }
    if (x < min) min = x;
  }
  printf("%d\n", max);
  return 0;
}



Measured memory_bytes: 3224
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>

int calch(int cx, int cy, int x, int y) { return (abs(x - cx) + abs(y - cy)); }

int main() {
  int n;
  std::cin >> n;
  std::vector<int> x(n);
  std::vector<int> y(n);
  std::vector<int> h(n);
  int xx, yy, hh;
  for (int i = 0; i < n; i++) {
    std::cin >> x[i] >> y[i] >> h[i];
    if (h[i] >= 1) {
      xx = x[i];
      yy = y[i];
      hh = h[i];
    }
  }
  int flag = true;
  for (int cx = 0; cx < 101 && flag; cx++) {
    for (int cy = 0; cy < 101; cy++) {
      int hcand = hh + calch(cx, cy, xx, yy);
      bool label = false;
      for (int k = 0; k < n; k++) {
        int hcand_ = std::max (hcand - calch(cx, cy, x[k], y[k]), 0);
        if (hcand_ != h[k]) {
          label = true;
          break;
        }
      }
      if (!label) {
        xx = cx;
        yy = cy;
        hh = hcand;
        flag = false;
        break;
      }
    }
  }
  std::cout << xx << " " << yy << " " << hh << std::endl;
}


Measured memory_bytes: 256