akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void)
{
    static char planet[1024][1024];
    static int num[3][1024][1024];
    int x, y, sy, sx, ey, ex;
    int k;
    int i, j;
    int jungle, ocean, ice;
    
    scanf("%d%d", &y, &x);
    getchar();
    scanf("%d", &k);
    getchar();
    for (i = 1; i <= y; i++){
        for (j = 1; j <= x; j++){
            scanf("%c", &planet[i][j]);
            if (planet[i][j] == 'J'){
                num[0][i][j] = num[0][i - 1][j] + num[0][i][j - 1] - num[0][i - 1][j - 1] + 1;
                num[1][i][j] = num[1][i - 1][j] + num[1][i][j - 1] - num[1][i - 1][j - 1];
                num[2][i][j] = num[2][i - 1][j] + num[2][i][j - 1] - num[2][i - 1][j - 1];
            }
            else if (planet[i][j] == 'O'){
                num[0][i][j] = num[0][i - 1][j] + num[0][i][j - 1] - num[0][i - 1][j - 1];
                num[1][i][j] = num[1][i - 1][j] + num[1][i][j - 1] - num[1][i - 1][j - 1] + 1;
                num[2][i][j] = num[2][i - 1][j] + num[2][i][j - 1] - num[2][i - 1][j - 1];
            }
            else {
                num[0][i][j] = num[0][i - 1][j] + num[0][i][j - 1] - num[0][i - 1][j - 1];
                num[1][i][j] = num[1][i - 1][j] + num[1][i][j - 1] - num[1][i - 1][j - 1];
                num[2][i][j] = num[2][i - 1][j] + num[2][i][j - 1] - num[2][i - 1][j - 1] + 1;
            }
        }
        getchar();
    }
    
    for (i = 0; i < k; i++){
        scanf("%d%d%d%d", &sy, &sx, &ey, &ex);
        jungle = num[0][ey][ex] - num[0][ey][sx - 1] - num[0][sy - 1][ex] + num[0][sy - 1][sx - 1];
        ocean = num[1][ey][ex] - num[1][ey][sx - 1] - num[1][sy - 1][ex] + num[1][sy - 1][sx - 1];
        ice = num[2][ey][ex] - num[2][ey][sx - 1] - num[2][sy - 1][ex] + num[2][sy - 1][sx - 1];
        
        printf("%d %d %d\n", jungle, ocean, ice);
    }
    
    return (0);
}

Measured memory_bytes: 13000
<?php

$s = str_split(trim(fgets(STDIN)));

$ans = "Yes";
for ($i = 1; $i <= count($s); $i++) {
    if($i % 2 == 1) {
        if($s[$i-1] === "L") {
            $ans = "No";
        }
    } else {
        if($s[$i-1] === "R") {
            $ans = "No";
        }
    }
}

echo $ans;

Measured memory_bytes: 4728
import scala.math._
import scala.collection.mutable.ListBuffer

object Main {
  //rt.gc()??§??¬??????????????¬?????????????????????
  //val rt = Runtime.getRuntime()
  val sc = new java.util.Scanner(System.in)
  def main(args: Array[String]) {
    while(true) {
      val n,k = sc.nextInt()
      if((n,k) == (0,0)) {
        return
      }

      val a = (1 to n).map(_ => sc.nextInt())
      var max = a.take(k).sum
      var tmp = max
      for(i <- 0 until n-k) {
        tmp = tmp + a(i+k) - a(i)
        if(max < tmp) {
          max = tmp
        }
      }
      println(max)
    }
  }
}

Measured memory_bytes: 130556
N, H = map(int, input().split())
weapon = [list(map(int, input().split())) for _ in range(N)]

count = 0

max_atack = -1
for i in range(N):
    max_atack = max(max_atack, weapon[i][0]) 


flag = True
weapon = sorted(weapon, key=lambda x: x[1], reverse=True)
for i in range(N):
    if weapon[i][1] >= max_atack:
        count += 1
        H -= weapon[i][1]
        
        if H <= 0:
            flag = False
            break

if flag:
    if H % max_atack == 0:
        count += H // max_atack
    else:
        count += H // max_atack + 1


print(count)

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  ll A,B,C,K;
  cin>>A>>B>>C>>K;
  // A -> B+C -> 2A+B+C -> 2A+3B+3C -> 6A+5B+5C
  // B -> A+C -> 2B+A+C -> 3A+2B+3C -> 5A+6B+5C
  // C -> A+B -> 2C+A+B -> 3A+3B+2C -> 5A+5B+6C
  // A-B -> B-A -> A-B -> B-A -> A-B
  ll ansA,ansB,ansC;
  if(K%2)cout<<B-A<<endl;
  else cout<<A-B<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
	long long N;
	cin >> N;
	vector<long long> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	long long money = 1000;
	long long stock = 0;

	for (int i = 0; i < N - 1; i++) {
		if (A[i] < A[i + 1]) {
			stock += money / A[i];
			money -= money / A[i] * A[i];
		}
		else if (A[i] > A[i + 1]) {
			money += stock * A[i];
			stock = 0;
		}
	}
	if (stock > 0) {
		money += stock * A[N - 1];
		stock = 0;
	}
	cout << money << endl;

	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main()
{ 
    int m,i;
cin>>m;
int flag=1,a[m];
 for(i=0;i<m;i++)
{
    cin>>a[i];
   
}
for(i=0;i<m;i++)
{
    //cout << a[i];
}
for(i=0;i<m-1;i++)
{
    //cout < a[i]-a[i+1] << endl;
    if(a[i+1]>a[i])
    {
        a[i+1]--;
    }
    else
    if(a[i+1]<a[i])
    {
    //cout<<"no";
    flag=0;
    break;
    }
    
     
}
if(flag==0)
{
    cout<<"No";
}
else
cout<<"Yes";
    return 0;
}


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

int main(){
    int A,B;
  	cin >> A >> B;
  	if(A%(B+B+1)==0){
      cout << A/(B+B+1) << endl;
    }
  	else {
      cout << (A/(B+B+1))+1 << endl;
    }
}

 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        String s = sc.next();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < s.length(); i += 2) {
			sb.append(s.substring(i, i + 1));
		}
        System.out.println(sb);
    }
}

Measured memory_bytes: 27820
i[100012],d[100012],s,n,a,x,y;main(w){for(w=scanf("%d",&n);a++<n;d[y]++)scanf("%d%d",&x,&y),i[x]++;for(a=2;a<=n+1;w-=d[a++])w+=i[a],w>=a?s=a-1:0;printf("%d\n",s);exit(0);}

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

int main(){
    int n, k;
    cin >> n >> k;
    ll a[n];
    ll sum[n+1] = {};
    rep(i,n) {
        cin >> a[i];
        sum[i+1] = sum[i] + a[i];
    }
    vector<ll> v;
    for(int i = 1; i <= n; i++){
        for(int j = i; j <= n; j++){
            v.push_back(sum[j]-sum[i-1]);
        }
    }
    ll m = sum[n];
    int c = 0;
    while(m != 0){
        c++;
        m /= 2;
    }
    ll ans = 0;
    vector<bool> use(v.size(), true);
    for(int i = c; i >= 0; i--){
        int t = 0;
        rep(j,v.size()){
            if((((ll)1 << i) & v[j]) && use[j]) t++;
        }
        if(t >= k){
            ans += ((ll)1 << i);
            rep(j,v.size()){
                if(!(((ll)1 << i) & v[j])) use[j] = false;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n; i++)
#define all(v) (v).begin(), (v).end()
#define decimal fixed << setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
const int INF = 1e9;
const LL LLINF = 1e16;


template< int mod >
struct ModInt
{
  int x;

  ModInt() : x(0) {}

  ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p)
  {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p)
  {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p)
  {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p)
  {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const
  {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      a -= t * b;
      swap(a, b);
      u -= t * v;
      swap(u, v);
    }
    return ModInt(u);
  }

  friend ostream &operator<<(ostream &os, const ModInt< mod > &p)
  {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt< mod > &a)
  {
    long long x;
    is >> x;
    a = ModInt< mod >(x);
    return (is);
  }

};

const int mod = 998244353;
using modint = ModInt< mod >;


modint dp[334][101010], dp2[334][101010];
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    // R+G <= B となる 塗り方
    dp[0][0] = dp2[0][0] = 1;
    rep(i, n)rep(j, 90909){
        // B
        dp[i+1][j+a[i]] += dp[i][j];
        // R or G
        dp[i+1][j] += dp[i][j]*2;

        dp2[i+1][j+a[i]] += dp2[i][j];
        // RかGだけ選び続ける
        dp2[i+1][j] += dp2[i][j];
    }
    modint ans = 1;
    rep(i, n) ans *= 3;
    int sum = accumulate(all(a), 0);
    for(int i=(sum+1)/2; i<=sum; i++) ans -= dp[n][i]*3;
    if(sum % 2 == 0) ans += dp2[n][sum/2]*3;
    cout << ans << endl;


}


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

vector<long> memo(87,0);
int main() {
  long n;
  memo.at(0) = 2;
  memo.at(1) = 1;
  
  cin >> n;
  
  for(int i=2; i<=n; i++){
    if(memo.at(i)){
      break;
    }
    memo.at(i) = memo.at(i-1) + memo.at(i-2);
    //cout << memo.at(i) << endl;
  }
  
  cout << memo.at(n) << endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define out(a) cout << a << endl
using namespace std;
typedef long long ll;

int main() {
    int N, M;
    cin >> N >> M;
    int A;
    ll sum=0;
    rep(i, M) {
        cin >> A;
        sum += A;
    }
    out(max((ll)-1, N-sum));
}




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

int N, M;
vector<vector<int>> As;

void initAs(vector<int> A)
{
    if (A.size() == N)
    {
        As.push_back(A);
        return;
    }

    int mn;
    if (A.size() == 0)
    {
        mn = 1;
    }
    else
    {
        mn = A.back();
    }
    for (int ai = mn; ai <= M; ai++)
    {
        vector<int> newA = A;
        newA.push_back(ai);
        initAs(newA);
    }
}

int main()
{
    int Q;
    cin >> N >> M >> Q;
    vector<int> a(Q), b(Q), c(Q), d(Q);
    for (int i = 0; i < Q; i++)
    {
        cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
    }

    initAs(vector<int>());

    int res = 0;
    for (auto &&A : As)
    {
        int score = 0;
        for (int i = 0; i < Q; i++)
        {
            int ai = a.at(i) - 1, bi = b.at(i) - 1, ci = c.at(i), di = d.at(i);
            if (A.at(bi) - A.at(ai) == ci)
            {
                score += di;
            }
        }
        res = max(res, score);
    }
    cout << res << endl;
}

Measured memory_bytes: 9872
use std::cmp::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve(n: usize, k: usize, h: Vec<i64>) {
    let mut dp = vec![std::i64::MAX; n];
    dp[0] = 0;
    for i in 0..n {
        for j in 1..(k+1) {
            if i + j >= n {
                continue;
            }
            let t = (h[i] - h[i+j]).abs() + dp[i];
            dp[i+j] = min(dp[i+j], t);
        }
    }
    println!("{}", dp[n - 1]);
}

fn main() {
    input! {
        n: usize,
        k: usize,
        h: [i64; n],
    }

    solve(n, k, h);
}


Measured memory_bytes: 6396
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    vector<ll> a(n),s(n+1);
    int i;
    for(i=0; i<n; i++) {
        scanf("%lld", &a[i]);
        a[i]*=2;
        s[i+1]=s[i]+a[i];
    }
    ll M=s[n]/2;

    int k=lower_bound(s.begin(), s.end(), M)-s.begin();
    ll tmp0=M-s[k-1];
    ll tmp1=s[k]-M;
    ll tmp=MIN(tmp0,tmp1);
    printf("%lld\n", tmp);


    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>//本当は必要なヘッダファイルだけインクルードするべきです
using namespace std;//本当は個別にusingするか変数や関数ごとにstd::をつけるべきです
//本当は関数内に宣言し明示的に初期化するべきです
double a,b;
int C;
int main(void){
  cin>>a>>b>>C;
  printf("%f\n",a*b*sin(C*M_PI/180)/2);
  printf("%f\n",a+b+sqrt(a*a+b*b-2*a*b*cos(C*M_PI/180)));
  printf("%f\n",b*sin(C*M_PI/180));
  return 0;
}



Measured memory_bytes: 3340
#include <bits/stdc++.h>
using namespace std;
int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int>> c(10, vector<int>(10));
    for(int i = 0; i < 10; i++) {
        for(int j = 0; j < 10; j++) {
            cin >> c.at(i).at(j);
        }
    }
    vector<vector<int>> A(H,vector<int>(W));
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> A.at(i).at(j);
        }
    }
    
    vector<int> cost(10);
    for(int i = 0; i <= 9; i++) {
        if (i==1) continue;
        int ans = 2000000000;
        vector<int> perm;
        for(int j = 0; j <= 9; j++) {
            if(j!=i) perm.push_back(j);
        }
        do {
            int tmp = 0;
            int s, g;
            for(int j = 0; j < 9; j++) {
                s = (j==0 ? i : perm.at(j-1));
                g = perm.at(j);
                tmp += c.at(s).at(g);
                if(g==1) break;
            }
            ans = min(ans, tmp);
        } while(next_permutation(perm.begin(), perm.end()));
        cost.at(i) = ans;
    }
    
    int ans = 0;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            int a = A.at(i).at(j);
            if(a==-1) continue;
            ans += cost.at(a);
        }
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define endl '\n'
#define inf (ll)(1e18+5)
#define maxn 3000001
#define mod (ll)(1e9+7)
#define int ll
 
using namespace std;
 
void io(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}

int n,m,l,r,x,y,z,a,h,w,b,c,mn=inf,mx=-inf,sum=0;
char mat[1005][1005];
int dp[1005][1005];

int32_t main(){
io();
IOS;    
		cin>>h>>w;
		for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++){
				cin>>mat[i][j];
			}
		}

		dp[1][1]=1;

		for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++){
				if(i==1 && j==1)continue;
				if(mat[i][j]=='#')dp[i][j]=0;
				else {
					dp[i][j]=dp[i-1][j]+dp[i][j-1];
					dp[i][j]%=mod;
				}
			}
		}

		cout<<dp[h][w]<<endl;




        

        


        
    
        
        
                


 
        
 
 
 
        
 
 
 
 
        
        
 
        
        
 
    
    
    
    
 
 
       
 
 
 
 
      
   
 
 
 
 
}

Measured memory_bytes: 12324
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();
        int C = sc.nextInt();
        int[] B = new int[M];
        int[][] A = new int[N][M];
        int sum = C;
        int ans = 0;

        for(int i=0; i<M; i++){
            B[i] = sc.nextInt();
        }
        for(int i=0; i<N; i++){
            for(int j=0; j<M; j++){
                A[i][j] = sc.nextInt();
                sum += A[i][j]*B[j];
            }
            if(sum>0){
                ans += 1;
            }
            sum = C;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 24404
#include<cstdio>
#include<cstring>

const int MAX = 1e5;
char s[MAX];
int main() {
    scanf("%s", s);
    int l = strlen(s);
    int cnt = 0;
    for (int i = 0; i < l; i++) {
        if (s[i] == 'p') cnt++;
    }

    printf("%d\n", l / 2 - cnt);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int ans = 700;
	if (s[0] == 'o') ans+=100;
	if (s[1]=='o') ans+=100;
	if (s[2]=='o') ans+=100;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int Mod = 1e9 + 7;
int n, m;
ll cnt;

int main() {
	ll ans = 1ll, res = 1ll;
	cin >> n >> m;
	if(abs(n - m) >= 2) puts("0");
	else {
		for(int i = 1; i <= n; i++) ans = ans * i % Mod;
		for(int i = 1; i <= m; i++) res = res * i % Mod;
		cnt = ans * res % Mod;
		if(n == m) {
			cnt *= 2;
			cnt %= Mod;
		}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
const int N=200005;
using namespace std;
int n;
int main(){
	cin>>n;
	if(n%10==3) cout<<"b";
	else if(n%10==0||n%10==1||n%10==6||n%10==8) cout<<"p";
	else cout<<"h";
	cout<<"on";
    return 0;
}

Measured memory_bytes: 3600
n,k = map(int,input().split())
p = list(map(int,input().split()))

wrk = sum(p[:k])
ans = wrk
for i in range(1,n-k+1):
    wrk-=p[i-1]
    wrk+=p[i+k-1]
    ans = max(ans,wrk)

print(0.5+(0.5*ans)+(k-1)*0.5)

Measured memory_bytes: 25060
N, C, K = map(int, input().split())
p = 0
bus = 0
time = 0
b = sorted([int(input()) for i in range(N)])
for i in range(N):
    a = b[i]
    if a - time > K or p == C:
        p = 0
    if p == 0:
        time = a
        bus += 1
    p += 1
print(bus)

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

using namespace std;

int main()
{
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	int num;
	for(int i = 0; ; i++){
		c = c - b;
		if(c <= 0){
			cout << "Yes" << endl;
			break;
		}
		a = a - d;
		if(a <= 0){
			cout << "No" << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3596
using System;

namespace tst
{
    class Program
    {
        public static void Main()
        {
            string[] In = Console.ReadLine().Split(' ');
            int[] N = new int[3];
            for(int i=0; i<3; i++)
            {
                N[i] = int.Parse(In[i]);
            }
            //全事象から「全部同じ」と「全部違う」を抜く
            bool flag = false;
            // 全部違う
            for (int i = 0; i < 2; i++)
            {
                for (int j = i + 1; j <= 2; j++)
                {
                    if (N[i] == N[j])
                    {
                        flag = true;
                    }
                }
            }
            //全部同じ
            if (N[0]==N[1] && N[1] == N[2])
            {
                flag = false;
            }
            if (flag)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

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

#define int long long
#define vi vector<int>
#define pb push_back
#define forn(i,n) for(int i=0;i<n;i++)
#define all (v.begin(),v.end())

void solve(){
  int m=(int)1e18;
  int ans=1;
  int n;cin>>n;
  int a[n];
  forn(i,n)cin>>a[i];
  forn(i,n){
  	if(a[i]==0){
  		cout<<"0"<<endl;
  		return;
	  }
  }
  forn(i,n){
  	if(ans>m/a[i] && a[i]>0 ){
  		cout<<"-1";
  		return;	
	  }
	  ans*=a[i];
  }
  cout<<ans<<endl;
}

int32_t  main(){
	
	solve();


   
    return 0;	
}

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

string j(string s){
	string ret;
	ret += s[s.size()-1];
	for(int unsigned i = 0;i<s.size()-1;i++){
		ret += s[i];
	}
	return ret;
}
string c(string s){
	string ret;
	for(int unsigned i = 1;i<s.size();i++){
		ret += s[i];
	}
	ret += s[0];
	return ret;
}
string e(string s){
	string ret;
	int size = s.size()/2;
	for(int unsigned i = s.size()-size;i<s.size();i++){
		ret += s[i];
	}
	if(s.size()%2){
		ret += s[s.size()/2];
	}
	for(int unsigned i = 0;i<s.size()/2;i++){
		ret += s[i];
	}
	return ret;
}
string a(string s){
	//reverse
	return string(s.rbegin(),s.rend());
}
string p(string s){
	//increments
	string ret;
	for(int unsigned i = 0;i<s.size();i++){
		if(isdigit(s[i])) {
			ret += (char)((s[i] - '0' + 9)%10 + '0');
		} else {
			ret += s[i];
		}
	}
	return ret;
}
string m(string s){
	//decrements
	string ret;
	for(int unsigned i = 0;i<s.size();i++){
		if(isdigit(s[i])) {
			ret += (char)((s[i] - '0' + 1)%10 + '0');
		} else {
			ret += s[i];
		}
	}
	return ret;
}

int main(){
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		string messengers;
		cin >> messengers;
		string message;
		cin >> message;
		for(int i = (signed)messengers.size()-1;i>=0;i--){
			if(messengers[i] == 'J') message=j(message);
			if(messengers[i] == 'C') message=c(message);
			if(messengers[i] == 'E') message=e(message);
			if(messengers[i] == 'A') message=a(message);
			if(messengers[i] == 'P') message=p(message);
			if(messengers[i] == 'M') message=m(message);
		}
		cout << message << endl;
	}
	return 0;
}

Measured memory_bytes: 3160
#include<stdio.h>
#include<algorithm>
using namespace std;
int a[109],b[109];
int Abs(int a)
{
    if(a>0) return a;
    else return -a;
}
int cmp(int a,int b)
{
    return a>b;
}
int main()
{
    int n,i,j,sum=0;
    scanf("%d",&n);
    for(i=1; i<=n; i++)
    {
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    for(i=1; i<=n; i++)
    {
        for(j=0; j<=i; j++)
        {
            b[i]+=a[j];
        }

    }
    int Min=1000000;
    for(i=1; i<=n; i++)
    {
        if(Min>Abs(2*b[i]-sum))
        {
            Min=Abs(2*b[i]-sum);
        }
    }
    printf("%d\n",Min);
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

using ll = long long;
const ll MOD = 998244353;

int main() {
    int N;
    cin >> N;
    vector<pair<double, double>> xy(N);
    rep(i, N) cin >> xy[i].first >> xy[i].second;
    sort(xy.begin(), xy.end());
    double s = 0, c = 0;
    do {
        rep(i, N - 1) {
            s += sqrt((xy[i].first - xy[i + 1].first) * (xy[i].first - xy[i + 1].first) + (xy[i].second - xy[i + 1].second) * (xy[i].second - xy[i + 1].second));
        }
        c++;
    } while (next_permutation(xy.begin(), xy.end()));
    cout << setprecision(12) << s / c << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#define ff first
#define ss second
#define M 1000000007
typedef long long int ll;
using namespace std;
ll power(ll a,ll b){
    ll ans = 1;
    while(b>0){
        if(b%2!=0){
            ans = ((ans)*(a));
        }
        a = ((a)*(a));
        b=b/2;
    }
    return ans;
}
vector <ll> dp;
ll solve(const vector <ll> &a,ll n,ll k){
    if(n<=0){
        return 100000;
    }
    if(n==1){
        return 0;
    }
    if(dp[n]!=-1){
        return dp[n];
    }
    ll ans = INT_MAX;
    for(ll i=1;i<=k;i++){
        if(n-i-1>=0)
            ans=min(ans,abs(a[n-1]-a[n-i-1])+solve(a,n-i,k));
    }
    return dp[n]=ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    dp.assign(n+1,-1);
    vector <ll> a(n);
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    cout<<solve(a,n,k)<<endl;
    return 0;
}


Measured memory_bytes: 9600
## coding: UTF-8
from decimal import *
from itertools import permutations, combinations,combinations_with_replacement,product
s = input().split()
t = [int(p) for p in s]

sA = input().split()
p = [int(w) for w in sA]



N = t[0]
M = t[1]
p.sort(reverse=True)
#print('N:{}, M:{}, p:{}'.format(N,M,p))

all_vote = sum(p)
#print(all_vote)
boder = all_vote / ( 4.0 * M ) #これ以下の商品を切り捨てる
#print(boder)

list_clear = []
for i in range(N):
    if(p[i] >= boder):
        list_clear.append(p[i])
#print(list_clear)

if(len(list_clear) >= M):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 5204
#include<stdio.h>
int a[4]={0};
int b[4]={0};
int hit=0,blow=0;

int main()
{
    while(scanf("%d",&a[0])!=-1)
    {
        for(int i=1;i<4;i++)
        {
            scanf("%d",&a[i]);
        }
        for(int i=0;i<4;i++)
        {
            scanf("%d",&b[i]);
        }
        for(int i=0;i<4;i++)
        {
            if(a[i]==b[i])
            {
                hit++;
                a[i]=0;
                b[i]=0;
            }
        }
        for(int i=0;i<4;i++)
        {
            if(b[i]!=0)
            {
                for(int j=0;j<4;j++)
                {
                    if(b[i]==a[j])
                    {
                        blow++;
                    }
                }
            }
        }
        printf("%d %d\n",hit,blow);
        for(int i=0;i<4;i++)
        {
            a[i]=0;
            b[i]=0;
        }
        hit=0;
        blow=0;
    }
    return 0;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#define lp(i,n) for(int i=0;i<n;i++)
#include<bits/stdc++.h>

using namespace std;
int main() {
	vector<int> a(3);
	lp(i, 3)
		cin >> a[i];
	sort(a.begin(), a.end());
	cout << (a[0] * a[1]) / 2 << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
#define M 150
int u[M][M],s[M],t;
int tim,where[M];
int ans[M][2];
int visit[M];


int end(int n){
  int a=1,i;

  for(i=1;i<=n;i++){
    if(visit[i]==0)return i;
  }

  return 0;
} 



void push(int a){
  tim++;
  s[t++]=a;
  visit[a]=1;
}
int pop(){
  tim++;
  return s[t--];
}



int main(){
  int a,b,c,d,i,j,k,n;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d%d",&a,&b);
    for(j=0;j<b;j++){
      scanf("%d",&c);
      u[a][c]=1;
    }
  }
  i=1;
  j=1;
  push(i);
  ans[i][0]=tim;
  while(t>0){

    if(u[s[t-1]][j]==1&&visit[j]==0){
      push(j);
      where[s[t-2]]=j;
      if(ans[s[t-1]][0]==0)ans[s[t-1]][0]=tim;
      j=1;
    }
    j++;
    if(j>n){ 
      pop();
      ans[s[t]][1]=tim;
      j=where[s[t-1]];
 if(  t==0 && (end(n)>0) ){  
       push(end(n));
       ans[s[t-1]][0]=tim; 
     } 
    
    }

    
  }

  for(i=1;i<=n;i++){
    printf("%d %d %d\n",i,ans[i][0],ans[i][1]);

  }













  return 0;
}

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

// definitions
#define __Imperial_Lord__ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define _cps CLOCKS_PER_SEC
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i, l, r) for (long long i = (l); i < (long long)(r); i++)
#define repb(i, r, l) for (long long i = (r); i > (long long)(l); i--)
#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define high(x) __builtin_popcountll(x)
#define pb push_back
#define pf push_front
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c <<endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d <<endl
#define exec cerr<<"Time taken : "<<(ld)(clock())/_cps<<"s"<<endl
#define mod1 998244353
#define mod 1000000007
#define pi 3.1415926535897932384

using namespace std;

// alias name for common data types
typedef vector<long long> vl;
typedef vector<long double> vld;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector< pair<long long, long long> > vp;
typedef vector<tuple<long long , long long , long long> > vtup;
typedef deque <long long> dql;
typedef deque <char> dqc;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const ll INF=1e18;

template <class ...Args>
istream &read_args(Args &...args) {return (cin >> ... >> args);}
#define read(...)   __VA_ARGS__; read_args(__VA_ARGS__)

// cin and cout overloaded for vectors
template<typename T>    istream& operator>>(istream& is,  vector<T>& v)
{
    for (auto& i : v) 
        is >> i;        
    return is;
}
template<typename T>    ostream& operator<<(ostream& os,  vector<T>& v)
{
    for (auto& i : v) 
        os << i << ' '; 
        return os;
}


// code beigns in main
int main()
{
    __Imperial_Lord__
    ll t=1;
    // cin >> t;
    ll lo;// lol
    
    while(t--)
    {
        ll a[(ll)1e5]; clr(a);
        rep(i,1,100)
        {
            rep(j,1,100)
            {
                rep(k,1,100)
                {
                    ll val=i*i+j*j+k*k+i*j+j*k+k*i;
                    a[val]++;
                }
            }
        }

        ll read(n);
        rep(i,1,n+1)
            p1(a[i]);
    }   
    exec;
}

Measured memory_bytes: 4584
n=int(input())
ln=input()
r=set()
g=set()
b=set()
for i,alp in enumerate(ln):
    if alp=="R":
        r.add(i)
    elif alp=="G":
        g.add(i)
    elif alp=="B":
        b.add(i)
max=len(r)*len(g)*len(b)
cnt=0

for i in range(n):
    for j in range(i+1,n):
        k=j+j-i
        if k<n:
            if ln[i]==ln[j] or ln[j]==ln[k] or ln[i]==ln[k]:
                continue
            else:
                cnt+=1

max-=cnt
print(max)

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

int main(){
  int n,k;
  cin>>n>>k;
  int a[n];
  rep(i,0,n) cin>>a[i];
  bool p[k+1];
  p[0]=false;
  rep(i,1,k+1){
    bool q=false;
    rep(j,0,n){
      if(i-a[j]>=0 && !p[i-a[j]]){
        q=true;
      }
    }
    p[i]=q;
  }
  if(p[k]) cout<<"First"<<endl;
  else cout<<"Second"<<endl;
}

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

using namespace std;

int g1[81][81];
int g2[81][81];
bool dp[81][81][6500];


int main() {
	int H, W;
	cin>>H>>W;
	for (int i = 0;i < H;++i) {
		for (int j = 0;j < W;++j) {
			cin>>g1[i][j];
		}
	}
	
	for (int i = 0;i < H;++i) {
		for (int j = 0;j < W;++j) {
			cin>>g2[i][j];
		}
	}
	
	dp[0][0][abs(g1[0][0] - g2[0][0])] = true;

	for (int i = 0;i < H;++i) {
		for (int j = 0;j < W;++j) {
			for (int k = 0;k <= 6400;++k) {
				if (dp[i][j][k]) {
					dp[i][j+1][abs(k - abs(g1[i][j+1] - g2[i][j+1]))] = true;
					dp[i][j+1][abs(k + abs(g1[i][j+1] - g2[i][j+1]))] = true;
					dp[i+1][j][abs(k - abs(g1[i+1][j] - g2[i+1][j]))] = true;
					dp[i+1][j][abs(k + abs(g1[i+1][j] - g2[i+1][j]))] = true;
				}
			}
		}
	}
	
	for (int i = 0;i <= 6400;++i) {
		if (dp[H-1][W-1][i]) {
			cout<<i<<endl;
			break;
		}
	}
	
	return 0;
}


Measured memory_bytes: 41856
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000010;
constexpr ll INF= 1000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

ll RS(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P < 0) {
        return 0;
    }
    if(P%2==0){
        ll t = RS(N, P/2, M);
        return t*t % M;
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    int A;
    cin >> A;
    cout << A + A * A + A * A * A << endl;
}

Measured memory_bytes: 3624
h_arr = []
w_arr = []
while true
  h, w = gets.split.map(&:to_i)
  break if h == 0 && w == 0
  h_arr.push(h)
  w_arr.push(w)
end

h_arr.zip(w_arr) do |h, w|
  h_num = 0
  h.times do
    w_num = 0
    w.times do
      if w_num == 0 || w_num == (w-1) || h_num == 0 || h_num == (h-1)
        print "#"
      else
        print "."
      end
      w_num = w_num + 1
    end
    h_num = h_num + 1
    puts ""
  end
  puts ""
end



Measured memory_bytes: 6876
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  cin >> str;
  while(str[0]!='0'){
    int i,o=0;
    for(i=0;i<str.size();i++){
      o+=str[i]-'0';
    }
    cout << o << endl;
    cin >> str;
  }
  return 0;
}


Measured memory_bytes: 3176
//Mitesh Agrawal
#include <bits/stdc++.h>
using namespace std;
 
#define next _next
 
int next[200005][26], mini[26], l;
int dp[200005];
int ans[200005];

bool cmp(string a, string b){
	if(a == "")
		return false;
	if(b == "")
		return true;
	if(a.size() != b.size())
		return a.size() < b.size();
	return a < b;
}

int find(int idx){
	if(idx == l + 1)
		return dp[idx] = 0;
	if(dp[idx] != 0)
		return dp[idx];
	dp[idx] = 1 + find(next[idx][0]);
	ans[idx] = 0;
	for(int i = 1; i < 26; i++){
		if(find(next[idx][i]) + 1 < dp[idx]){
			dp[idx] = 1 + find(next[idx][i]);
			ans[idx] = i;
		}
	}
	return dp[idx];
}
 
int main(){
	int i, j, k, m;
	string s, t;
	cin >> s;
	l = s.size();
	for(i = 0; i < 26; i++)
		mini[i] = l + 1;
	for(i = l - 1; i >= -1; i--){
		for(j = 0; j < 26; j++)
			next[i + 1][j] = mini[j];
		if(i >= 0)
			mini[s[i] - 'a'] = i + 1;
	} 
    int it = 0;
    while(1){
    	if(!find(it))
    		break;
    	printf("%c", ans[it] + 'a');
    	it = next[it][ans[it]];
    }
    return 0;
}

Measured memory_bytes: 22660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll N=1e6+5,inf=1e18,mod=1e9+7;
#define test ll testcases;cin>>testcases; while(testcases--)
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define sz(x) ((ll)((x).size()))
const ld pi=3.141592653589793238;

bool check_prime(ll n)
{
	ll flag=0,i;
	for(i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			flag=1;
			break;
		}
	}
	if(n==1)
	{
		return false;
	}
	else if(flag==0 || n==2 || n==3)
	{
		return true;
	}
	else
	{
		return false;
	}
}

ll fastexpo(ll a,ll b,ll MOD) 
{
	ll result=1;
	while(b>0)
	{
		if(b%2==1)
		{
			result=(result*a)%MOD;
		}
		a=(a*a)%MOD;
		b=b/2;
	}
	return result;
}

ld dp[305][305][305];

ld fxn(ll n1,ll n2,ll n3,ll n)
{
	if(dp[n1][n2][n3]!=-1.0)
	{
		return dp[n1][n2][n3];
	}
	ld p,pro1,pro2,pro3,d1,d2,d3;
	pro1=(ld)n1/n;
	pro2=(ld)n2/n;
	pro3=(ld)n3/n;
	p=pro1+pro2+pro3;
	if(p==0.0)
	{
		return 0;
	}
	if(n1==0)
	{
		d1=0;
	}
	else
	{
		d1=fxn(n1-1,n2,n3,n);
	}
	if(n2==0)
	{
		d2=0;
	}
	else
	{
		d2=fxn(n1+1,n2-1,n3,n);
	}
	if(n3==0)
	{
		d3=0;
	}
	else
	{
		d3=fxn(n1,n2+1,n3-1,n);
	}
	dp[n1][n2][n3]=((1/p)+((pro1*d1+pro2*d2+pro3*d3)/p));
	return dp[n1][n2][n3];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n1,n2,n3,n,i,j,k,x;
    ld ans;
    cin>>n;
    n1=0;
    n2=0;
    n3=0;
    for(i=0;i<n;i++)
    {
    	cin>>x;
    	if(x==1)
    	{
    		n1++;
    	}
    	else if(x==2)
    	{
    		n2++;
    	}
    	else
    	{
    		n3++;
    	}
    }
    for(i=0;i<305;i++)
    {
    	for(j=0;j<305;j++)
    	{
    		for(k=0;k<305;k++)
    		{
    			dp[i][j][k]=-1.0;
    		}
    	}
    }
    ans=fxn(n1,n2,n3,n);
    printf("%0.15Lf\n",ans);
	return 0;
}

Measured memory_bytes: 447112
A = list(map(int, input().split(' ')))
S = input()

if S[0:A[0]].isdigit() == False or S[A[0]+1:].isdigit() == False or S[A[0]] != '-' or len(S[0:A[0]]) != A[0] or len(S[A[0]+1:]) != A[1] :
	print('No')
else:
	print('Yes')

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if (b - a == c - b) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 21076
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

struct sparse_table
{
	int lg[100111],v[20][100111];
	void construct(int n,int *a)
	{
		for(int i=2;i<=n;i++)lg[i]=lg[i>>1]+1;
		for(int i=1;i<=n;i++)v[0][i]=a[i];
		for(int i=1;i<20;i++)for(int j=1;j<=n;j++)
		{
			int nxt=j+(1<<i-1);
			if(nxt>n)v[i][j]=v[i-1][j];
			else v[i][j]=max(v[i-1][j],v[i-1][nxt]);
		}
	}
	int query(int l,int r)
	{
		if(l>r)return 0;
		int len=lg[r-l+1];
		return max(v[len][l],v[len][r-(1<<len)+1]);
	}
}thor;

int n,m,a[233][5111];
LL sum[5111][5111],pre[5111];
void add(int*a)
{
	thor.construct(n,a);
	for(int i=1;i<=n;i++)
	{
		int l=0,r=i,mid,tl,tr;
		while(l<r-1)
		{
			mid=(l+r+1)>>1;
			if(thor.query(mid,i)==a[i])r=mid;
			else l=mid;
		}
		tl=r;
		l=i;r=n+1;
		while(l<r-1)
		{
			mid=(l+r)>>1;
			if(thor.query(i,mid)==a[i]&&thor.query(i+1,mid)!=a[i])l=mid;
			else r=mid;
		}
		tr=l;
		sum[tl][i]+=a[i];
		sum[i+1][tr+1]+=a[i];
		sum[tl][tr+1]-=a[i];
		sum[i+1][i]-=a[i];
	}
}
int main()
{
	get2(n,m);
	for(int i=2;i<=n;i++)
	{
		get1(pre[i]);
		pre[i]+=pre[i-1];
	}
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)get1(a[j][i]);
	for(int i=1;i<=m;i++)add(a[i]);
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)sum[i][j]+=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
	LL ans=0;
	for(int i=1;i<=n;i++)for(int j=i;j<=n;j++)
		ans=max(ans,sum[i][j]-pre[j]+pre[i]);
	printendl(ans);
	return 0;
}

Measured memory_bytes: 213248
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <utility>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B; cin >> A >> B;
  if (A * B % 2 == 0)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}


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

int main() {
  const int MOD = 1000000007;
  int n; cin >> n;
  vector<int> alphabet(26);
  
  for (int i = 0; i < n; i++) {
    char c; cin >> c;
    alphabet.at(c - 'a')++;
  }
  
  long long answer = 1;
  
  for (int i = 0; i < 26; i++) {
    answer *= alphabet.at(i) + 1;
    answer %= MOD;
  }
  
  cout << answer - 1 << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
ODD = defaultdict(int)
EVEN = defaultdict(int)
ALL = set([])
N = int(input())

A = list(map(int,input().split()))
for i in range(N):
  ALL.add(A[i])
  if i%2 == 0:
    EVEN[A[i]] += 1
  else:
    ODD[A[i]] += 1
if len(ALL) == 1:
  ans = N//2
  print(ans)
  exit()
modd = max(ODD.values())
meven = max(EVEN.values())
mlodd = [];mleven = []
dicodd = sorted(ODD.items(), key=lambda x:x[1], reverse = True)
diceven = sorted(EVEN.items(), key=lambda x:x[1], reverse = True)
ans = N
if len(dicodd) > 1:
  X = [dicodd[0],dicodd[1]]
else:
  X = [dicodd[0]]
if len(diceven) > 1:
  Y = [diceven[0],diceven[1]]
else:
  Y = [diceven[0]]
#print(X)
#print(Y)
for x,v in X:
  for y,w in Y:
    if x == y:
      continue
    temp = N-(v+w)
    ans = min(ans,temp)

print(ans)




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

int main() {
    int N;
    char S[101];
    int x = 0;
    int ans = 0;

    scanf("%d", &N);
    scanf("%s", S);
    for (int i = 0; i < N; i++) {
        if (S[i] == 'I') x++;
        else if (S[i] == 'D') x--;
        ans = max(ans, x);
    }

    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll x,y,aa,bb,cc;
vector<ll> a,b,c;
int main(){
	//freopen("input.txt","r",stdin);
	cin>>x>>y>>aa>>bb>>cc;
	ll temp;
	for(ll i=0;i<aa;i++) {
		cin>>temp;
		a.push_back(temp);
	}
	for(ll i=0;i<bb;i++) {
		cin>>temp;
		b.push_back(temp);
	}
	sort(a.rbegin(),a.rend());
	sort(b.rbegin(),b.rend());
	for(ll i=0;i<x;i++) c.push_back(a[i]);
	for(ll i=0;i<y;i++) c.push_back(b[i]);
	for(ll i=0;i<cc;i++) {
		cin>>temp;
		c.push_back(temp);
	}
	sort(c.rbegin(),c.rend());
	ll sum=0;
	for(ll i=0;i<x+y;i++) sum+=c[i];
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 7408
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int nn = n;
		int s = 0;
		while(nn != 0){
			s += nn % 10;
			nn /= 10;
		}
		if(n % s == 0) ou.println("Yes");
		else ou.println("No");
		ou.flush();
	}
}

Measured memory_bytes: 35760
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, start, end) for(int i = start; i < (int)(end); ++i)
int a[200010], b[200010];
int main(){
    long long n, k;
    cin >> n >> k;
    rep(i,1,n+1){
        cin >> a[i];
    }
    int cnt = 1, now = 1;
    while(b[now] == 0){
        b[now] = cnt;
        cnt++;
        now = a[now];
    }
    long long interval = cnt - b[now];
    if(b[now] < k){
        k -= b[now] - 1;
        k %= interval;
    }else{
        now = 1;
    }
    while(0 < k){
        now = a[now];
        k--;
    }
    cout << now << endl;
    return 0;
}

Measured memory_bytes: 5116
#include<iostream>
#include<set>
#include<map>
#include<cmath>
#include<complex>
using namespace std;
typedef pair<int,int> pi;
typedef pair<pi,char> mirror;
const int dx[] = {25,-25,-25,25};
const int dy[] = {25,25,-25,-25};
mirror examine(int x, int y){
  if(x%100==0){
    return mirror( pi(x,y-(y%100)), 'y');
  }else
    return mirror( pi(x-(x%100),y), 'x');
}
int main(){
  while(true){
    int n;
    int x=75, y=25;
    int prev_d = 0;
    int d=0;
    set< mirror > mirrors;
    cin >> n;
    if(n==-1)break;
    for(int i = 0; i < n; ++i){
      char tc;
      int tx,ty;
      cin >> tc >> tx >> ty;
      mirrors.insert( mirror( pi(100*tx,100*ty), tc ) );
    }
    while(true){

      if((x==0||x==800||y==0||y==800)&&
	 mirrors.find( examine(x,y) )==mirrors.end())
	break;
      if(x%100==0||y%100==0){
	pair<pi,char> search = examine(x,y);
	//cout << "NOW : " << x << " " << y << " EXAMINE A MIRROR AT " << search.first.first << " " << search.first.second << endl;
	set< mirror >::iterator itm = mirrors.find( examine(x,y) );
	if( itm != mirrors.end() && itm->second == search.second){
	  if(search.second=='x'){
	    switch(d){
	    case 0:d=3;break;
	    case 1:d=2;break;
	    case 2:d=1;break;
	    case 3:d=0;break;
	    }
	  }
	  if(search.second=='y'){
	    switch(d){
	    case 0:d=1;break;
	    case 1:d=0;break;
	    case 2:d=3;break;
	    case 3:d=2;break;
	    }
	  }
	  // cout << "REFRECTED AT : " << x << " " << y << endl;
	}
      }
      x+=dx[d];
      y+=dy[d];
      if(x==75&&y==25)break;
    }
    cout << x << " " << y << endl;
  }
  
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i,l,r) for (int i=l;i<=r;i++)
#define down(i,l,r) for (int i=l;i>=r;i--)
#define clr(x,y) memset(x,y,sizeof(x))
#define maxn 605000
#define inf (int)1e9
#define ll long long
#define eps 1e-9
#define mm 1000000007
#define low(x) x&(-x)
#define pb push_back
#define mp make_pair
#define PII pair<int,int>
using namespace std;
ll read(){
    ll x=0,f=1; char ch=getchar();
    while (!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
    while (isdigit(ch)){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
ll a[maxn],s[maxn],mx,mx2,amx;
int n,m;
bool cmp(ll a,ll b){
	return a>b;
}
int main(){
//	freopen("in.txt","r",stdin);
//	freopen("1.txt","w",stdout);
	n=read();
	rep(i,1,n) a[i]=read();
	sort(a+1,a+1+n,cmp);	
	m=1; s[m]=1;
	rep(i,2,n) {
		if (a[i]!=a[i-1]) ++m;
		s[m]++;
		if (s[m]>=4){
			if (!amx) amx=a[i];
		}
		if (s[m]>=2) {
			if (!mx) mx=a[i];
			else if (a[i]!=mx&&!mx2) mx2=a[i];
		} 
	}
	printf("%lld\n",max(amx*amx,mx*mx2));
	return 0;
}

Measured memory_bytes: 3072
#include<algorithm>
#include<chrono>
#include<climits>
#include<numeric>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
using namespace std;
 
struct Debug{
    int cnt = 0;
    bool on = false;
    char debug[10] = "debug";
    template<class T>
    Debug & operator<<(const T & v) {
        if(on && cnt++ == 0) cerr << "debug: ";
        if(on) cerr << v << ' ';
        return *this;
    }
    Debug & operator<<(ostream&(*pManip)(ostream&)) {
        if(on) cerr << (*pManip);
        cnt = 0;
        return *this;
    }
} debug;
#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define print(v) {if(debug.on){for(auto x : v) debug << x; debug << endl;}}
#define printn(v, n) {if(debug.on){for(int _i = 0; _i < n; _i++) debug << *(v + _i); debug << endl;}}
 

typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;


const int MAXN = 2e3 + 20;



int main(int argc, char * argv[]) {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(argc > 1 && !strcmp(argv[1], debug.debug)) debug.on = true;

    string s;
    cin >> s;
    if(s == "Sunny")
    	cout << "Cloudy" << endl;
    if(s == "Cloudy")
    	cout << "Rainy" << endl;
    if(s == "Rainy")
    	cout << "Sunny" << endl;

    return 0;
}






















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

typedef long long ll;

int main() {
	int n = 0, a = 0, b = 0;
	int ans = 0;
	std::cin >> n;
	for (int i = 0; i < n; i++) {
		std::cin >> a >> b;
		ans += b - a + 1;
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.nextLine().toCharArray();
		char[] t = sc.nextLine().toCharArray();
        Arrays.sort(s);
        Arrays.sort(t);

        StringBuilder revercseT = new StringBuilder();
		revercseT.append(t);
        revercseT.reverse();

        System.out.println(String.valueOf(s).compareTo(revercseT.toString()) < 0 ? "Yes" : "No");
    }
}

Measured memory_bytes: 23508