akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

#define NMAX 1000000
#define LMAX 1000000
#define DMAX 1000000000

using namespace std;

int Input(vector<int>&);
void CreateTree(vector<vector<int> >&, int);
void UpDate(vector<vector<int> >&, int, int);

int main(){
    vector<int> data;
    vector<vector<int> > tree(1);
    int L = Input(data);
    
    if(L == -1)
        return -1;
    
    copy(data.begin(), data.begin() + L, back_inserter(tree[0]));
    if(tree[0].size() > 1)
        CreateTree(tree, 0);
    
    cout << tree[tree.size() - 1][0];
    for(vector<int>::size_type i = 1; i <= data.size() - L; i++){
        UpDate(tree, (i - 1) % L, data[i - 1 + L]);
        cout << " " << tree[tree.size() - 1][0];
    }
    
    cout << endl;
    
    return 0;
}

int Input(vector<int> &data){
    int N, L, a;
    
    cin >> N >> L;
    if(!(1 <= N && N <= NMAX) || !(1 <= L && L <= LMAX) || L > N)
        return -1;
    
    for(int i = 0; i < N; i++){
        cin >> a;
        if(!(1 <= a && a <= DMAX))
            return -1;
        data.push_back(a);
    }
    
    return L;
}

void CreateTree(vector<vector<int> > &tree, int level){
    vector<int> new_layer;
    
    for(vector<int>::size_type i = 0; i < tree[level].size(); i += 2){
        new_layer.push_back(min(tree[level][i], tree[level][i + 1]));
        
        if(i + 2 == tree[level].size() - 1){
            new_layer.push_back(tree[level][i + 2]);
            break;
        }
    }
    
    tree.push_back(new_layer);
    
    if(tree[level + 1].size() > 1)
        CreateTree(tree, level + 1);
}

void UpDate(vector<vector<int> > &tree, int i, int v){
    int target = i;
    tree[0][target] = v;
    
    for(vector<vector<int> >::size_type level = 1; level < tree.size(); level++){
        if(target == tree[level - 1].size() - 1 && tree[level - 1].size() & 1)
            tree[level][target / 2] = tree[level - 1][target];
        else if(target & 1)
            tree[level][target / 2] = min(tree[level - 1][target], tree[level - 1][target - 1]);
        else
            tree[level][target / 2] = min(tree[level - 1][target], tree[level - 1][target + 1]);
        
        target /= 2;
    }
}




Measured memory_bytes: 8764
n,m = map(int,input().split())
li = [list(map(int,input().split())) for _ in range(m)]

li = sorted(li,key = lambda x:x[0])
start = []
for i in range(m):
  if li[i][0] != 1:
    break
  else:
    start.append(li[i][1])
li = sorted(li,key = lambda x:-x[1])
goal = []
for i in range(m):
  if li[i][1] != n:
    break
  else:
    goal.append(li[i][0])
isec = set(start+goal)
if len(isec) == len(start)+len(goal):
  print("IMPOSSIBLE")
else:
  print("POSSIBLE")
#print(start)
#print(goal)

Measured memory_bytes: 64816
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll; 

int N, A, B, C;
const int MAX_N = 8;
int l[MAX_N];
const int INF = (int)pow(10, 9);

int dfs(int i, int a, int b, int c){
    if (i == N) {
        if (min(a, min(b, c)) == 0) return INF;
        else return abs(a - A) + abs(b - B) + abs(c - C) - 30;
    }
    int ret0 = dfs(i + 1, a, b, c);
    int retA = dfs(i + 1, a + l[i], b, c) + 10;
    int retB = dfs(i + 1, a, b + l[i], c) + 10;
    int retC = dfs(i + 1, a, b, c + l[i]) + 10;
    return min(ret0, min(retA, min(retB, retC))); 
}

int main() {
    cin >> N >> A >> B >> C;
    for (int i = 0; i < N; i++) cin >> l[i];
    cout << dfs(0, 0, 0, 0) << endl;
    return 0;    
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            int R = GetInt();
            var ans = R < 1200 ? "ABC" : R < 2800 ? "ARC" : "AGC";

            Console.WriteLine(ans);
            Console.ReadKey();
        }

        static void Solve()
        {
        }


        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Split(' ').Select(char.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c, out V d)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<V>(ar[3]);
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#define NIL -1
#define MAX 500000
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
int n;
int root;
int *p = new int[MAX];       //    p---|  Unit
int *left2 = new  int[MAX]; // left2 --|--------> T
int *right2 = new int[MAX]; //right2---|
int *key = new int[MAX];     // key----|
   
void Init(){
  rep(i,MAX){
    p[i]=left2[i]=right2[i]=key[i]=NIL;
  }
}
   
bool SEARCH(int x,int k){
  if(k == key[x])return true;
  if(x == NIL)return false;
  if(k < key[x])return SEARCH(left2[x],k);
  else return SEARCH(right2[x],k);
}
  
   
void TREE_INSERT(int z){
  int y = NIL;
  int x = root;
   
  while(x != NIL){
    y = x;
    if(key[z] < key[x]){
      x = left2[x];
    }
    else x = right2[x];
  }
  p[z]=y;
  if(y == NIL){
    root = z;
  }
  else if(key[z] < key[y]){
    left2[y] = z;
  }else{
    right2[y] = z;
  }
   
}
   
void InorderTreeWalk(int x){
  if(x != NIL){
    InorderTreeWalk(left2[x]);
    printf(" %d",key[x]);
    InorderTreeWalk(right2[x]);
  }
}
   
void PreorderTreeWalk(int x){
  if(x != NIL){
    printf(" %d",key[x]);
    PreorderTreeWalk(left2[x]);
    PreorderTreeWalk(right2[x]);
  }
}
   
   
int main(){
  int val;
  string op;
  long long zr;                   
   
   
  scanf("%d",&n);
  Init();
  root = -1;
  zr=0;
  while(n-- > 0){
    cin >> op;
    if(op == "insert"){
      scanf("%d",&val);
      key[zr]=val;       
      TREE_INSERT(zr);
      zr++;
    }else if(op == "print"){
      InorderTreeWalk(root);
      printf("\n");
      PreorderTreeWalk(root);
      printf("\n");
    }
    else if(op == "find"){
      scanf("%d",&val);
      if(SEARCH(root,val)){
    printf("yes\n");
      }else{
    printf("no\n");
      }
         
   
    }
  }
   
  delete [] p;
  delete [] left2;
  delete [] right2;
  delete [] key;
  
  return 0;
}

Measured memory_bytes: 8788
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int N;
    int i;
    N = s.nextInt();
    for(i = N; ((Math.sqrt(i) - (int)(Math.sqrt(i))) != 0.0); i--);
    System.out.printf("%d",i);
  }
}


Measured memory_bytes: 23764
'''
ika tako
事前計算で1以上N以下の数字を走査し、
「先頭桁がiで末尾桁がjの数字の個数Ci,j 」をあらかじめ求めておく。
再度、1以上N以下の数字を走査し、
その数字が先頭桁がjで末尾桁がiなら答にCi,jを加算すればよい。
'''
def solve(n):
    tbl = [0] * 100
    for i in range(1, n + 1):
        st = str(i)
        tbl[int(st[0] + st[-1])] += 1
 
    ans = 0
    for i in range(1, n + 1):
        st = str(i)
        ans += tbl[int(st[-1] + st[0])]
    return ans
 
 
n = int(input())
print(solve(n))

Measured memory_bytes: 40300
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#define llint long long
#define inf 1e18
#define mod 998244353
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)

using namespace std;
typedef pair<llint, llint> P;

llint n, x;
llint dp[2][505][530];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> x;
	dp[1][0][0] = 1;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= x; j++){
			for(int k = 0; k < 512; k++){
				dp[(i+1)%2][j][k] = 0;
			}
		}
		for(int j = 0; j <= x; j++){
			for(int k = 0; k < 512; k++){
				(dp[(i+1)%2][j][k^j] += dp[i%2][j][k]) %= mod;
				if(j+1 <= x) (dp[i%2][j+1][k] += dp[i%2][j][k]) %= mod;
			}
		}
	}
	
	llint ans = 0;
	for(int i = 0; i <= x; i++) ans += dp[(n+1)%2][i][x], ans %= mod;
	cout << ans << endl;
	
	return 0;
}


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

using namespace std;

typedef long long int ll;

int main() {
	ll n;

	cin >> n;

	ll ans = 0;
	vector <ll> divsors(n+1, 0);

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j*i <= n; j++) {
			divsors[i*j]++;
		}
	}

	for (int k = 1; k <= n; k++) {
		ans += k * divsors[k];
	}

	cout << ans << "\n";

	return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(c, a);
    cout << a << " " << b << " " << c;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

const int C_10PW9 = 1000000000;

int main()
{
	int n;
	cin >> n;
	vector<int> x;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		x.push_back(t);
	}
	long min_d = C_10PW9;
	for (int p = 1; p <= 100; p++) {
		long nowt = 0;
		for (int i = 0; i < n; i++) {
			nowt += (long)pow(x[i] - p, 2);
		}
		min_d = min(min_d, nowt);
	}
	cout << min_d;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

struct mint {
    ll v;
    ll mod = MOD;
    mint() : v(0) {}
    mint(signed v, ll mod = MOD) : v(v), mod(mod) {}
    mint(ll t, ll mod = MOD) : mod(mod) {
        v = t % mod;
        if (v < 0)
            v += mod;
    }

    mint pow(ll k) {
        mint res(1), tmp(v);
        while (k) {
            if (k & 1)
                res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }

    static mint add_identity() { return mint(0); }
    static mint mul_identity() { return mint(1); }

    mint inv() { return pow(mod - 2); }

    mint &operator+=(mint a) {
        v += a.v;
        if (v >= mod)
            v -= mod;
        return *this;
    }
    mint &operator-=(mint a) {
        v += mod - a.v;
        if (v >= mod)
            v -= mod;
        return *this;
    }
    mint &operator*=(mint a) {
        v = 1LL * v * a.v % mod;
        return *this;
    }
    mint &operator/=(mint a) { return (*this) *= a.inv(); }

    mint operator+(mint a) const { return mint(v) += a; };
    mint operator-(mint a) const { return mint(v) -= a; };
    mint operator*(mint a) const { return mint(v) *= a; };
    mint operator/(mint a) const { return mint(v) /= a; };

    mint operator-() const { return v ? mint(MOD - v) : mint(v); }

    bool operator==(const mint a) const { return v == a.v; }
    bool operator!=(const mint a) const { return v != a.v; }
    bool operator<(const mint a) const { return v < a.v; }
};
int main() {
    ll n, k;
    cin >> n >> k;
    vector<vector<mint>> mat(n, vector<mint>(n, 0));
    vector<vector<mint>> ret(n, vector<mint>(n, 0));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> mat[i][j].v;
        }
    }
    for (int i = 0; i < n; ++i) {
        ret[i][i].v = 1;
    }

    while (k) {
        if (k & 1) {
            vector<vector<mint>> retn(n, vector<mint>(n, 0));

            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < n; ++j) {
                    for (int k = 0; k < n; ++k) {
                        retn[i][j] += ret[i][k] * mat[k][j];
                    }
                }
            }
            ret = retn;
        }
        vector<vector<mint>> matn(n, vector<mint>(n, 0));
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                for (int k = 0; k < n; ++k) {
                    matn[i][j] += mat[i][k] * mat[k][j];
                }
            }
        }
        mat = matn;
        k >>= 1;
    }
    mint sum = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            sum += ret[i][j];
        }
    }
    cout << sum.v << "\n";
    return 0;
}

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

int main() {
  int N, K; cin >> N >> K;
  int R, S, P; cin >> R >> S >> P;
  string T; cin >> T;
  
  int win_hand[100000]; // i回目に勝つ手の配列(0: グー, 1: チョキ, 2: パー)
  for (int i = 0; i < N; i++) {
    if (T[i] == 'r') win_hand[i] = 2;
    if (T[i] == 's') win_hand[i] = 0;
    if (T[i] == 'p') win_hand[i] = 1;
  }
  
  int virtual_max_p = 0; // K回の制約がない場合の得点の最大値
  for (int i = 0; i < N; i++) {
    if (win_hand[i] == 0) virtual_max_p += R;
    if (win_hand[i] == 1) virtual_max_p += S;
    if (win_hand[i] == 2) virtual_max_p += P;
  }
  
  int real_max_p = virtual_max_p; // 実際の得点の最大値
  for (int i = K; i < N; i++) {
    if (win_hand[i] == win_hand[i-K]) {
      if (win_hand[i] == 0) real_max_p -= R;
      if (win_hand[i] == 1) real_max_p -= S;
      if (win_hand[i] == 2) real_max_p -= P;
      win_hand[i] = -1; // -1: K回前ともK回後とも被らないよう適当に決める
    }
  }
  
  cout << real_max_p << endl;
      
  return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
#include <math.h>
 
int main()
{
	double x1,y1,x2,y2,x3,y3,xp,yp;
	double s,s1,s2,s3;
	double ab,bc,ca,ap,bp,cp;
	while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)!=EOF){
	ab=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
	bc=sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
	ca=sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
	ap=sqrt((x1-xp)*(x1-xp)+(y1-yp)*(y1-yp));
	bp=sqrt((x2-xp)*(x2-xp)+(y2-yp)*(y2-yp));
	cp=sqrt((x3-xp)*(x3-xp)+(y3-yp)*(y3-yp));
	s=sqrt(((ab+bc+ca)*(-ab+bc+ca)*(ab-bc+ca)*(ab+bc-ca))/16);
	s1=sqrt(((ap+ab+bp)*(-ap+ab+bp)*(ap-ab+bp)*(ap+ab-bp))/16);
	s2=sqrt(((bp+bc+cp)*(-bp+bc+cp)*(bp-bc+cp)*(bp+bc-cp))/16);
	s3=sqrt(((cp+ca+ap)*(-cp+ca+ap)*(cp-ca+ap)*(cp+ca-ap))/16);
	if(fabs(s1+s2+s3-s)<0.1)puts("YES");
	else puts("NO");
	}
	return 0;
}

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

using namespace std;
int a[4];
char o[3]={'+','-','*'};
int gdb(int a,int b){
  int c;
  while(b){
    c=a%b;
    a=b;
    b=c;
  }
  return a;
}
int cl(int a,int b,int o){
  if(o==0) return a+b;
  else if(o==1) return a-b;
  else return a*b;
}
int solve(){
  do{
    for(int k=0;k<3;k++){
      for(int l=0;l<3;l++){
	for(int h=0;h<3;h++){
	  for(int m=0;m<5;m++){
	    int w,x,y,z;
	    char e,f,g;
	    w=a[0];x=a[1];y=a[2];z=a[3];
	    e=o[k];f=o[l];g=o[h];
	    if(m==0&&cl(cl(cl(w,x,k),y,l),z,h)==10){
	      cout<<"((("<<w<<" "<<e<<" "<<x<<") "<<f<<" "<<y<<") "<<g<<" "<<z<<")"<<endl;
	      return 0;
	    }
	    else if(m==1&&cl(cl(w,x,k),cl(y,z,h),l)==10){
	      cout<<"(("<<w<<" "<<e<<" "<<x<<") "<<f<<" ("<<y<<" "<<g<<" "<<z<<"))"<<endl;
	      return 0;
	    }
	    else if(m==2&&cl(cl(w,cl(x,y,l),k),z,h)==10){
	      cout<<"(("<<w<<" "<<e<<" ("<<x<<" "<<f<<" "<<y<<")) "<<g<<" "<<z<<")"<<endl;
	      return 0;
	    }
	    else if(m==3&&cl(w,cl(cl(x,y,l),z,h),k)==10){
	      cout<<"("<<w<<" "<<e<<" (("<<x<<" "<<f<<" "<<y<<") "<<g<<" "<<z<<"))"<<endl;
	      return 0;
	    }
	    else if(m==4&&cl(w,cl(x,cl(y,z,h),l),k)==10){
	      cout<<"("<<w<<" "<<e<<" ("<<x<<" "<<f<<" ("<<y<<" "<<g<<" "<<z<<")))"<<endl;
	      return 0;
	    }
	  }
	}
      }
    }
  }while(next_permutation(a, a+4));
  cout<<0<<endl;
}
	  
int main(){
  while(cin>>a[0]>>a[1]>>a[2]>>a[3]){
    if(a[0]==0) break;
    int c=gdb(a[0],gdb(a[1],gdb(a[2],a[3])));
    if(c!=1&&c!=2&&c!=5){
      cout<<0<<endl;
      continue;
    }
    sort(a,a+4);
    solve();
  }
  return 0;
}

Measured memory_bytes: 1180
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n){
        ll r; cin >> r;
        a[i] = r-i-1;
    }
    sort(a.begin(),a.end());
    ll b;
    if(n%2==0) b = (a[n/2]+a[n/2-1])/2;
    else b = a[(n-1)/2];
    ll ans = 0;
    rep(i,n){
        ans+=abs(a[i]-b);
    }
    cout << ans << endl;
    
}



Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;

int main(){

    ll H, W; cin >> H >> W;

    vector<vector<ll > > grid(H+2, vector<ll >(W+2, 0));

    vector<vector<ll > > row_dist(H+2, vector<ll >(W+2, 0));
    vector<vector<ll > > col_dist(H+2, vector<ll >(W+2, 0));
    vector<vector<ll > > re_row_dist(H+2, vector<ll >(W+2, 0));
    vector<vector<ll > > re_col_dist(H+2, vector<ll >(W+2, 0));

    for(ll i = 1; i <= H; i++){
        string s; cin >> s;
        for(ll j = 1; j <= W; j++){
            if(s[j-1] == '.'){
                grid[i][j] = 1;
            }
        }        
    }
    
    for(ll i = 1; i <= H; i++){
        for(ll j = 1; j <= W; j++){
            if(grid[i][j] == 1){
                row_dist[i][j] += row_dist[i][j-1] + 1;
                col_dist[i][j] += col_dist[i-1][j] + 1;
            }
        }        
    }

    //反対
    for(ll i = H; i > 0; i--){
        for(ll j = W; j > 0; j--){
            if(grid[i][j] == 1){
                re_row_dist[i][j] += re_row_dist[i][j+1] + 1;
                re_col_dist[i][j] += re_col_dist[i+1][j] + 1;
            }
        }        
    }

    ll ans = 0;

    for(ll i = 1; i <= H; i++){
        for(ll j = 1; j <= W; j++){
            if(grid[i][j] == 0) continue;
            ll t_ans = 0;
            //cout << t_ans << endl;
            t_ans = row_dist[i][j] + col_dist[i][j] + re_row_dist[i][j] + re_col_dist[i][j] - 3;
            ans = max(ans, t_ans);
        }        
    }

    cout << ans << endl;

}

Measured memory_bytes: 157312
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class A_Multiplication1_169
    {
        // https://atcoder.jp/contests/abc169/tasks/abc169_a
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            long A = inputLongArray[0];
            long B = inputLongArray[1];

            long result = 0;

            result = A * B;

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


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

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var n = inputs[0];
        var m = inputs[1];
        var x = inputs[2];

        List<Argo> argo = new List<Argo>();
        long min = -1;
        bool isOK = false;

        for(int i = 0; i < n; i++)
        {
            var tmp = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            Argo a = new Argo();
            a.c = tmp[0];
            for(int j = 0; j < m; j++)
            {
                a.a.Add(tmp[j + 1]);
            }
            argo.Add(a);
        }

        foreach(var item in BitFullSearch(n))
        {
            long[] argoOK = new long[m];
            long cost = 0;

            for (int num = 0; num < item.Length; num++)
            {
                if (item[num])
                {
                    cost += argo[num].c;
                    for(int i2 = 0; i2 < m; i2++)
                    {
                        argoOK[i2] += argo[num].a[i2];
                    }
                }
            }

            // 条件
            if(argoOK.All(e => e >= x))
            {
                if (isOK == false)
                {
                    isOK = true;
                    min = cost;
                }
                else
                {
                    if (cost < min) min = cost;
                }
            }
        }

        if(isOK == false)
        {
            Console.WriteLine("-1");
        }
        else
        {
            Console.WriteLine(min);
        }
    }

    public class Argo
    {
        public long c;
        public List<long> a = new List<long>();
    }

    public static IEnumerable<bool[]> BitFullSearch(long n)
    {
        if (n <= 0)
        {
            yield return new bool[] { };
            yield break;
        }

        for (int i = 0; i < Math.Pow(2, n); i++)
        {
            var array = new bool[n];
            for (int j = 0; j < n; j++)
            {
                var targetBit = (i >> j) & 1;
                if (targetBit == 1) array[j] = true;
            }

            yield return array;
        }
    }
}

Measured memory_bytes: 29380
import           Control.Monad
import qualified Data.ByteString.Char8 as BS
import           Data.Char
import           Data.Maybe
import qualified Data.Vector.Unboxed   as V

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

main = do
  n <- getInt
  ps <- getIntVec n
  let inf = 10^6 :: Int
  print $ solve 0 inf 0 n ps
  where
    solve ans m i len xs | i == len = ans
                         | otherwise =
                           let x = xs V.! i
                               m' = min x m
                               ans' = if x <= m' then ans + 1 else ans
                           in
                             solve ans' m' (i+1) len xs

Measured memory_bytes: 15740
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;


ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}


int main(void) {

  ll n, a, b;
  cin >> n >> a >> b;

  ll ans = (n / (a + b)) * a;
  ll k = n - (n / (a + b)) * (a + b);
  if (k <= a) ans += k;
  else ans += a;
  cout << ans << endl;
}


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

int main() {
  
  int c;
  
  cin >> c;
  
  string s = to_string(c);
  
  bool ans = false;
  
  for(int i=0;i<3;i++){
    if(s.at(i) == '7'){
      ans = true;
    }
  }
  
  if(ans){
    cout << "Yes" <<endl;
  }else{
    cout << "No" <<endl;
  }
  
  return 0;
  
}


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

int main() {
	int a,b,c,d,aa,bb;
	cin >>a>>b>>c>>d;
	aa = a * b;
	bb = c * d;
	int ans;
	if (aa < bb) {
		ans = bb;
	}
	else {
		ans = aa;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextLong()
    val b = sc.nextLong()
    val c = sc.nextLong()

    println(pana2020c(a, b, c))
}

private fun pana2020c(a: Long, b: Long, c: Long): String {
  val cab = c - (a + b)
  val ab = a * b

  if (cab > 0 && cab * cab > 4 * ab) return "Yes"

  return "No"
}

Measured memory_bytes: 31264
#include <bits/stdc++.h>
    using namespace std;
	typedef long long int ll; 
     
    int main() {
        int N;
        cin >> N;
        //vector<ll> A(N);
        ll counter =0;
        ll sum =0; 
        ll A, M;
        M = 1000*1000*1000+7;
      
        for (int i = 0; i < N; i++) { 
       		 cin >> A; 
       		 if(A<0){
       		     counter++;
       		     A = -A; 
       		 }
       		 sum+=A;
       		 M=min(M,A);
        }   
        if(counter%2==0){
            cout<< sum << endl;
        }else{
            cout<< sum - 2*M << endl;
        }
   }


Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>

using namespace std;
typedef long long int LL;
const int Max_N(100050);

int N, Head[Max_N], Total, To[Max_N << 1], Next[Max_N << 1], Weight[Max_N << 1], Size[Max_N], SonMax[Max_N], root;
LL Ans;

inline void Add_Edge(int s, int t, int w)
{
	++Total, To[Total] = t, Next[Total] = Head[s], Weight[Total] = w, Head[s] = Total;
}

void dfsSize(int u, int fa)
{
	Size[u] = 1, SonMax[u] = 0;
	for (int i = Head[u], v;i;i = Next[i])
		if ((v = To[i]) != fa)
			dfsSize(v, u), Size[u] += Size[v], SonMax[u] = max(SonMax[u], Size[v]);
	SonMax[u] = max(SonMax[u], N - Size[u]);
}

void dfsDist(int u, int fa, LL Dis)
{
	Ans += Dis * 2LL;
	for (int i = Head[u], v;i;i = Next[i])
		if ((v = To[i]) != fa)
			dfsDist(v, u, Dis + Weight[i]);
}

/*
考虑提出任意重心root，可以证明：存在一个最优解，使得哈密顿路上相邻两个点的路径均经过root
可以先构造出哈密顿回路：把在不同子树中的点两两匹配起来（可能存在孤立点），以root为起点，再考虑root走到的点和走到root的点，显然哈密顿回路 = Sum{2 * Dist(root, i)   |   1 <= i <= N}
然后考虑去掉哈密顿回路上边权最小的边就可以得到答案，显然一定是去掉和root相邻的一个点x到root的路径（是root走到的点或走到root的点）
当最大子树匹配过程中有孤立点时，x必须在可能存在孤立点的子树中（root走到的点或走到root的点都在该子树中）：(1)最大子树 或 (2)去掉该子树中1个点，剩下的点可以两两匹配 
*/

int main()
{
	scanf("%d", &N);
	for (int i = 1, u, v, w;i != N;++i)
		scanf("%d%d%d", &u, &v, &w), Add_Edge(u, v, w), Add_Edge(v, u, w);
	dfsSize(1, -1), root = 1;
	for (int i = 2;i <= N;++i)
		if (SonMax[i] < SonMax[root])
			root = i;
	dfsDist(root, -1, 0LL);
	dfsSize(root, -1);
	int Min(0X3F3F3F3F);
	if (N & 1)//SonMax[root] <= N / 2，N是奇数故SonMax[root] <= (N - 1) / 2，所以可以两两匹配，不存在孤立点
		for (int i = Head[root];i;i = Next[i])
			Min = min(Min, Weight[i]);
	else//找可能存在孤立点的子树 
		for (int i = Head[root], v;i;i = Next[i])
			if (Size[v = To[i]] == SonMax[root] || (N - 2 >= 2 * SonMax[root]))
				Min = min(Min, Weight[i]);
	printf("%lld", Ans - Min);
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int b,f,r,v;
    vector<vector<vector<int>>> vvv(4,vector<vector<int>>(3,vector<int>(10,0)));
    for(int i=0; i<n; i++){
        cin >> b >> f >> r >> v;
        vvv[b-1][f-1][r-1]+=v;
    }
    for(int i=0; i<4; i++){
        for(int j=0; j<3; j++){
            for(int k=0; k<10; k++){
                cout << " " << vvv[i][j][k]; 
            }
            cout << endl;
        }
        if(i!=3)
        cout << "####################" << endl;
    }
}


Measured memory_bytes: 3156
N = int(input())
A = list(map(int,input().split()))
ans = 0
B = [0]*N
for i in range(N-1,-1,-1):
    k = sum(B[i::i+1])
    if k%2!=A[i]:
        B[i]=1
        ans+=1
print(ans)
print(*[i+1 for i in range(N) if B[i]==1])

Measured memory_bytes: 13112
import sys

import numba as nb

input = sys.stdin.readline


@nb.njit("i8(i8)")
def g(n):
    return n * (n + 1) // 2


@nb.njit("i8(i8)")
def solve(n):
    ans = 0
    for i in range(1, n + 1):
        ans += i * g(n // i)
    return ans


def main():
    N = int(input())

    ans = solve(N)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 109404
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	int a, b; cin >> a >> b;
	if (a <= 9 && b <= 9) cout << a*b << endl;
	else cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
using ll = long long;

int main(){
  int s;
  cin >> s;
  set<int> a;
  a.insert(s);

  int next=s;
  int i=1;
  while(1){
    if(next%2==0){
      next=next/2;
    }
    else{
      next=3*next+1;
    }
    ++i;
    if(a.count(next)) break;
    else a.insert(next);
  }

  cout << i << endl;
  
  return 0;
}


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

using namespace std;

void solve()
{
	string s;
	while(getline(cin, s))
	{
		for(int i = 0; i < 26; ++i)
		{
			for(int j = 0; j < s.size(); ++j)
			{
				if('a' <= s[j] && s[j] <= 'z')
				{
					if(s[j] == 'z')
					{
						s[j] = 'a';
					}
					else
					{
						++s[j];
					}
				}
			}
			if(s.find("this") != string::npos || s.find("that") != string::npos || s.find("the") != string::npos)
			{
				cout << s << endl;
				break;
			}
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1172
/* 
	بسم الله الرحمن الرحیم
	
	(; طلا یک جهانی
*/

#include <bits/stdc++.h>
using namespace std;

const int MAX_N = 100 + 5;
int n, a[MAX_N];

void read_input() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i], a[i]--;
}

void solve() {
	vector<int> ans;
	for (int i = n - 1; ~i; i--) {
		bool ok = false;
		for (int j = i; ~j; j--)
			if (a[j] == j) {
				ok = true;
				ans.push_back(j + 1);
				copy(a + j + 1, a + n, a + j);
				break;
			}
		if (!ok) {
			cout << -1;
			exit(0);
		}
	}
	reverse(ans.begin(), ans.end());
	for (int i: ans)
		cout << i << endl;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	read_input();
	solve();
}


Measured memory_bytes: 256
//g++  7.4.0

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAXX 1e12
#define MAXN 1005
#define MOD 1000000007
ll dp[MAXN][MAXN];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll N,M; cin>>N>>M;
    string s[N];
    
    for(ll i=0;i<N;++i)
    {
        cin>>s[i];
        for(ll j=0;j<M;++j)
        {
            if(s[i][j] == '#')
                continue;
            
            if(i == 0 && j == 0)
            {
                dp[0][0] = 1;
                continue;
            }
            
            dp[i][j] = (((i > 0) ? dp[i - 1][j] : 0) + ((j > 0) ? dp[i][j - 1] : 0)) % MOD;
        }
    }
    
    //cout<<dp[1][1]<<endl;
    
    cout<<dp[N - 1][M - 1]<<endl;
}

Measured memory_bytes: 12456
#include<stdio.h>
int main(void)
{
    int n,x,y,b,p,i,m1,m2,m3,m4;
	scanf("%d",&n);
    for (i=0;i<n;i++){
	    scanf("%d %d",&x,&y);
		scanf("%d %d",&b,&p);
		m1=x*b+y*p;
		m2=x*b+y*2-(x*2/10)*b-(y*2/10)*2;
		m3=x*5+y*p-(x*2/10)*5-(y*2/10)*p;
		if (b>=5&&p>=2){
			m4=x*b+y*p-(x*2/10)*b-(y*2/10)*p;
			printf("%d\n",m4);
		}
		else if(p>=2&&m3<m1){
			printf("%d\n",m3);
		}
		else if(b>=5&&m2<m1){
			printf("%d\n",m2);
		}
		else {
			printf("%d\n",m1);
		}
	}
	return 0;
}

Measured memory_bytes: 1028
import java.util.Scanner;
import java.io.IOException;

class Main 
{
	private static int[][] field;
	public static void main(String[] args) throws IOException
	{
		Scanner sc = new Scanner(System.in);	
		int N, W, H, S, T, x, y;

		while(true)
		{
			N = sc.nextInt();	

			if(N == 0)
			{
				break;
			}

			W = sc.nextInt();
			H = sc.nextInt();

			field = new int[H][W];

			for(int i = 0; i < field.length; i++)
			{
				for(int j = 0; j < field[i].length; j++)
				{
					field[i][j] = 0;
				}
			}

			for(int i = 0; i < N; i++)
			{
				x = sc.nextInt();
				y = sc.nextInt();

				field[y - 1][x - 1] = 1;
			}

			S = sc.nextInt();
			T = sc.nextInt();

			System.out.println(search(S, T));
		}
	}

	private static int search(int S, int T)
	{
		int max = 0, cnt = 0;

		for(int si = 0; si < field.length - T + 1; si++)
		{
			for(int sj = 0; sj < field[si].length - S + 1; sj++)
			{
				cnt = 0;

				for(int i = 0; i < T; i++)
				{
					for(int j = 0; j < S; j++)
					{
						if(field[si + i][sj + j] == 1)
						{
							cnt++;
						}
					}
				}

				max = max < cnt ? cnt : max;
			}
		}

		return max;
	}
}

Measured memory_bytes: 34252
from collections import Counter,defaultdict,deque
from heapq import heapify,heappop,heappush
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    #根を返す
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

n,m = inpl()
p = inpl()
uf = UnionFind(n)
for i in range(m):
    a,b = inpl()
    uf.union(a-1,b-1)
res = 0
for i in range(n):
    if uf.find(p[i]-1) == uf.find(i):
        res += 1
print(res)    


Measured memory_bytes: 90344
#include <bits/stdc++.h>
using namespace std;
int main(){
    int k;
    string s;
    
    cin >> k >> s;
    
    if (s.size()>k) {
        string sub = s.substr(0, k);
        cout << sub << "..." <<endl;
    }
    else{
        cout << s <<endl;
    }
    
}


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

int num(char c) {
	switch (c) {
		case 'I': return 1;
		case 'V': return 5;
		case 'X': return 10;
		case 'L': return 50;
		case 'C': return 100;
		case 'D': return 500;
		case 'M': return 1000;
	}
	return 0;
}

int main() {
	string s;
	while (cin >> s) {
		int n = 0;
		for (int i = 0; i < s.size(); i++) {
			int a = num(s[i]);
			int b = i+1 < s.size() ? num(s[i+1]) : 0;
			if (a >= b)
				n += a;
			else
				n += b-a, i++;
		}
		cout << n << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#pragma comment(linker, "/stack:200000000")
        #pragma GCC optimize ("Ofast")
        #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
         
         
        #include <iostream>
        #include <iomanip>
        #include <sstream>
        #include <cstring>
        #include <vector>
        #include <deque>
        #include <queue>
        #include <set>
        #include <map>
        #include <valarray>
        #include <iterator>
        #include <functional>
        #include <limits>
        #include <algorithm>
        #include <numeric>
        #include <cmath>
        #include <cassert>
        #include <unordered_map>
        #include <unordered_set>
        #include <stack>
        using namespace std;
        #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
         #define trace(x) cerr << #x << ": " << x << " " << endl;
     
        typedef int64_t ll;
     
        #define endl '\n'
        #define int ll
        ll mod=1e9+7;
        ll mod1=1e9+5;
        ll power(ll a,ll b)
        {
            if(b==0) return 1;
            else if(b%2==0)
                return power((((a%mod)*(a%mod))%mod),b/2)%mod;
            else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
        }
        int n,m,t;
        vector<pair<int,int>> mat[5001];
        vector<pair<int,int>> ulta[5001];
        int32_t main()
        {
            IOS
           
          
        int n,y;
        cin>>n>>y;
        y/=1000;
        for(int i=0;i<=n;++i)
        {
            for(int j=0;j<=n;++j)
            {
                if((y-i*10-j*5)==n-i-j and n-i-j>=0)
                {
                    cout<<i<<" "<<j<<" "<<n-i-j;
                    return 0;
                }
            }
        }
        cout<<"-1 -1 -1";



    }



Measured memory_bytes: 640
n = gets.to_i
x = gets.split.map(&:to_i)
p = Array.new(101) { 0 }
p[0] = Float::INFINITY
for i in 1..100
  for j in 0..n-1
    p[i] += (x[j] - i) ** 2
  end
end
puts p.min


Measured memory_bytes: 1788
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
using namespace std;



int main(int argc, char *args[]) {
	int A, B;
	int s, d, t;
	int max = -10000;
	cin >> A >> B;
	s = A + B;
	d = A - B;
	t = A * B;
	if (max < s)max = s;
	if (max < t)max = t;
	if (max < d)max = d;
	cout << max << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
typedef long long ll;
 
int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<ll> acc(N + 1);
  for(int i = 0; i < N; i++) {
    acc[i + 1] = acc[i] + A[i];
  }
  ll ans = 1LL << 62;
  for(int j = 1; j < N - 2; j++) {
    int i1 = lower_bound(acc.begin(), acc.begin() + j + 1, acc[j + 1] / 2) - acc.begin() - 1;
    int i2 = i1 - 1;
    int k1 = lower_bound(acc.begin() + j + 1, acc.end(), (acc[N] - acc[j + 1]) / 2 + acc[j + 1]) - acc.begin() - 1;
    int k2 = k1 - 1;
    //cout << i2 << "," << i1 << "," << j << "," << k2 << "," << k1 << endl;
    vector<ll> I = {i1};
    vector<ll> K = {k1};
    if (i2 >= 0) I.push_back(i2);
    if (k2 > j) K.push_back(k2);
    for(int ii = 0; ii < I.size(); ii++) {
      for(int kk = 0; kk < K.size(); kk++) {
        int i = I[ii], k = K[kk];
        vector<ll> area;
        area.push_back(acc[i + 1]);
        area.push_back(acc[j + 1] - acc[i + 1]);
        area.push_back(acc[k + 1] - acc[j + 1]);
        area.push_back(acc[N] - acc[k + 1]);
        sort(area.begin(), area.end());
        ans = min(ans, area.back() - area[0]);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3328
#include<stdio.h>

int main(void){

int s;
int m;
int h;
scanf("%d",&s);

while(s>3599){
s = s - 3600;
h ++;
}
while(s>59){
s = s - 60;
m++;
}

printf("%d:%d:%d\n",h,m,s);
return 0;
}

Measured memory_bytes: 592
import sys
h,w=map(int,input().split())
l=[]

for i in range(h):
  s=[x for x in input()]
  l.append(s)

for i in range(w):
  im=max(i-1,0)
  ip=min(i+1,w-1)
  for j in range(h):
    jm=max(j-1,0)
    jp=min(j+1,h-1)
    
    if l[j][i]=="#":
      if l[jm][i]=="#" or l[jp][i]=="#" or l[j][ip]=="#" or l[j][im]=="#":
        continue
      else:
        print("No")
        sys.exit()
    else:
      continue
  
print("Yes")

Measured memory_bytes: 9156
using System;

namespace abc137A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            int C = A + B;
            int D = A - B;
            int E = A * B;
            if (C > D)
            {
                C = C + 0;
            }
            else
            {
                C = D;
            }
            if (C > E)
            {
                C = C + 0;
            }
            else
            {
                C = E;
            }
            Console.WriteLine(C);
        }
    }
}

Measured memory_bytes: 13140
#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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;
const long long MOD =1000000000+7;

int main()
{
	int H,W;
	cin >>H>>W;
	int h,w;
	cin >>h>>w;


	cout <<(H-h)*(W-w)<<endl;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    n = int(input())
    h = list(map(int, input().split()))
    for i in range(0, n):
        if i == 0:
            h[i] = h[i] - 1
        else:
            if h[i] < h[i - 1]:
                if h[i] - 1 == h[i - 1]:
                    h[i] = h[i] - 1
                else:
                    print('No')
                    exit()
            if h[i] > h[i - 1]:
                h[i] = h[i] - 1
    print('Yes')


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	int N, M, X;
	cin >> N >> M >> X;

	vector<bool> v(N + 1);
	int L, R;
	L = 0;
	R = 0;

	for (int i = 0; i < M; i++) {
		int n;
		cin >> n;
		if (n < X) L++;
		else R++;
	}

	cout << min(L, R) << endl;
}

Measured memory_bytes: 3616
#include<stdio.h>
int main(){
  int n;
  int c=0;
  scanf("%d",&n);
  int i,j;
  for(i=1;i<10;i++){
    for(j=1;j<10;j++){
      if(n==i*j)
	c++;
    }
  }

  if(c>0)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
// int c=0;

 int main()
 {
 	int n,k,low=INT_MAX;
 	cin>>n>>k;
 	int a[n];
 	for(int i=0;i<n;i++)
 	{
 	    cin>>a[i];
 	}
 	int ans[k+1],j=0;
 	ans[0]=0;
 	memset(ans,0,sizeof(ans));
 	for(int i=1;i<=k;i++)
 	{
 	    
 	    for(j=0;j<n;j++)
 	    {
 	        //cout<<i-a[j];
 	        if((i-a[j]>=0) && (ans[i-a[j]]==0))
 	        {
 	            ans[i]=1;
 	            break;
 	        }
 	    }
 	    j=0;
 	    //cout<<ans[i]<<endl;
 	}
//  	for(int i=0;i<=k;i++)cout<<ans[i];
 	if(ans[k]==1)
 	    cout<<"First"<<endl;
 	 else
 	    cout<<"Second"<<endl;
 	 return 0;
 }


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    int C[N], A[N][M];
    for(int i = 0; i < N; i++) {
        cin >> C[i];
        for(int j = 0; j < M; j++) cin >> A[i][j];
    }
    int n = N;
    int ans = inf;
    for(int bit = 0; bit < (1 << n); ++bit) {
        vector<int> S;
        for(int i = 0; i < n; ++i) {
            if(bit & (1 << i)) {
                S.push_back(i);
            }
        }
        int a[M], cost = 0;
        for(int i = 0; i < M; i++) a[i] = 0;
        for(int i = 0; i < (int)S.size(); ++i) {
            cost += C[S[i]];
            for(int j = 0; j < M; j++) a[j] += A[S[i]][j];
        }
        bool ok = true;
        for(int i = 0; i < M; i++)
            if(a[i] < X) {
                ok = false;
                break;
            }
        if(ok) ans = min(ans, cost);
    }
    if(ans == inf)
        cout << -1;
    else
        cout << ans;
    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<cstdint>
using namespace std;

const int64_t kD = 1000000;

int main()
{
  int64_t K, X;

  cin >> K >> X;

  for (int64_t i = max(X - K + 1, -1 * kD); i <= min(X + K - 1, kD); ++i) {
    cout << i << " ";
  }

  return 0;
}



Measured memory_bytes: 256
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX_STRING 50
#define MAX_LOOP 2304
#define WALL  -2
#define SPACE -1

int subCheck(char* psTarget, char* psKeyword, int len){
	int ret=1;
	int nLen=len;
	int i=0;

	for (i=0;i<nLen;i++){
		if (*(psTarget+i)==*(psKeyword+i) || *(psTarget+i) == '?'){
			// ok
		} else {
			ret= 0;
			break;
		}
	}

	return ret;
}

int main() {

	char sInput[MAX_STRING+1]="";
	char sKeyword[MAX_STRING+1]="";
	char* psInput;
	char* psInputTemp;
	char* psKeyword;
	int nMaxKeywordHead=-1;
	int nInputLen=0;
	int nKeywordLen=0;
	int i=0;

	// read line 1
	gets(sInput);
	psInput = sInput;
	psInputTemp = sInput;
	nInputLen=strlen(sInput);
	// read line 2
	gets(sKeyword);
	psKeyword = sKeyword;
	nKeywordLen=strlen(sKeyword);

	if ( nInputLen < nKeywordLen ){
		// skip process
	} else {
		for (i=0; (nInputLen-i)>=nKeywordLen; i++){
			if(subCheck(psInputTemp,psKeyword,nKeywordLen)){
				nMaxKeywordHead=i;
			}
			psInputTemp++;
		}
		
	}

	if ( nMaxKeywordHead < 0 ){
		printf("UNRESTORABLE\n");
	} else {
		psInputTemp = sInput+nMaxKeywordHead;
		memcpy(psInputTemp,sKeyword,nKeywordLen);
		for (i=0;i<nInputLen;i++){
			if (*(psInput+i)=='?'){
				printf("a");
			} else {
				printf("%c",*(psInput+i));
			}
		}
		printf("\n");
	}
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 505;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<vector<int> > a(MAX, vector<int>(MAX));
    int l, r;
    for (int i = 0; i < M; i++) {
        cin >> l >> r;
        a[l][r]++;
    }
    // [l, r)内に含まれる個数の累積和
    vector<vector<int> > sum(MAX + 1, vector<int>(MAX + 1));
    for (int i = 0; i < MAX; i++) {
        for (int j = 0; j < MAX; j++) {
            sum[i+1][j+1] = sum[i][j+1] + sum[i+1][j] - sum[i][j] + a[i][j];
        }
    }
    for (int i = 0; i < Q; i++) {
        cin >> l >> r;
        // [l, r)より r = r+1に変更している
        cout << sum[r+1][r+1] - sum[r+1][l] - sum[l][r+1] + sum[l][l] << '\n';
    }

}

Measured memory_bytes: 2944