akhauriyash/Code-Regression huggingface dataset:
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define mp make_pair
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const long long MXN = 3e5 + 1;
const long long MNN = 1e3 + 1;
const long long MOD = 998244353;
const long long INF = 1e18;
const long long OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

llong n, a, b, k, ans, f[MXN];

llong binpow(llong a, llong b){
	if(b == 0){
		return 1;
	}if(b % 2 == 1) return (binpow(a, b - 1) * a) % MOD;
	else{
		llong x = binpow(a, b / 2);
		return (x * x) % MOD;
	}
}

llong C(llong n, llong k){
	llong x = (f[k] * f[n - k]) % MOD;
	return (f[n] * binpow(x, MOD - 2)) % MOD;
}

llong solve(llong cntA, llong cntB){
//	llong ans = 0;
//	for(int i = min(cntA, cntB); i >= 0; i--){
//		llong R = cntA - i, B = cntB - i, G = i;
//		if(R + G + B > n) break;
//		ans += (((C(n, R) * C(n - R, B)) % MOD) * C(n - R - B, G)) % MOD;
//		ans %= MOD;
//	}
//	return ans;
        if (cntB > n) return 0;
	return C(n, cntA) * C(n, cntB) % MOD;
}

int main(){
	ios;
	f[0] = 1;
	for(int i = 1; i < MXN; i++){
		f[i] = (f[i - 1] * i) % MOD;
	}
	cin >> n >> a >> b >> k;
	for(int i = 0; i <= n; i++){
		if(k >= a * i && (k - (i * a)) % b == 0){
			ans += solve(i, (k - (i * a)) / b);
			ans %= MOD;
		}
	}
	cout << ans;
	return 0;
}
// 6391049189 - 48090 * 33447


Measured memory_bytes: 2560
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    a,b,c = map(int, input().split())
    import numpy as np
    if c-a-b >=0 and (c-a-b)**2-4*a*b > 0:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Measured memory_bytes: 14528
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    if(n==m)
    {
        cout<<0<<endl;
        return 0;
    }
    if(n>0&&m>0)
    {
        if(n<m)
        {
            cout<<abs(m-n)<<endl;
            return 0;
        }
        else
        {
            cout<<abs(n-m)+2<<endl;
            return 0;
        }
    }
    if(n==0||m==0)
    {
        if(n>m)
        {
            cout<<abs(n -m)+1<<endl;
            return 0;
        }
        cout<<abs(n-m)<<endl;
        return 0;
    }
    if(n>0&&m<0||n<0&&m>0)cout<<abs(abs(n)-abs(m))+1<<endl;
    if(n<0&&m<0)
    {
        if(n>m)cout<<abs(abs(n)-abs(m))+2<<endl;
        if(n<m)cout<<abs(abs(n)-abs(m))<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}


int main()
{
  ll k,a,b,p,q,r;
  p=0;
  q=0;
  r=0;
  cin >> k >> a >> b;
  if(k>=a+1)p=b+(k-a-1)/2*(b-a)+(k-a-1)%2;
  if(k>=a+1)q=b+k-a-1;
  r=k+1;
  printf("%lld",max({p,q,r}));
}

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

int main() {
	int n;
	cin >> n;
	long long a;
	int count = 0;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a % 2 == 1) {
			count++;
		}
	}
	if (count % 2 == 1) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

    class Student implements Comparable<Student>{
        long A, X;

        Student(long A, long X){
            this.A = A;
            this.X = X;
        }

        @Override
        public int compareTo(Student o) {
            return (int)(o.A - A);
        }
    }

    public Main() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();

        Student[] A = new Student[N];
        for (int i = 0; i < N; i++) {
            A[i] =  new Student(scanner.nextLong(), i);
        }

        Arrays.sort(A);

        long dp[][] = new long[N+1][N+1];
        dp[0][0] = 0;

        for (int i = 0; i < N; i++) {

            for (int left = 0; left <= i; left++) {
                int right = i-left;

                if (dp[i+1][left+1] < dp[i][left] + (A[i].X - left) * A[i].A){
                    dp[i+1][left+1] = dp[i][left] + (A[i].X - left) * A[i].A;
                }
                if (dp[i+1][left] < dp[i][left] + ( (N-right-1) - A[i].X) * A[i].A){
                    dp[i+1][left] = dp[i][left] + ( (N-right-1) - A[i].X) * A[i].A;
                }
            }
        }

        long Ans = 0;
        for (int i = 0; i < N+1; i++) {
            Ans = Math.max(Ans, dp[N][i]);
        }

        System.out.println(Ans);
    }

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


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

public class Main {
  Scanner sc;

  int INF = 1 << 28;

  void run() {
    for ( ;; ) {
      int a = ni();
      int d = ni();
      int n = ni();

      if ( ( a | d | n ) == 0 ) {
        break;
      }

      int cnt = 0;
      for ( ;; ) {
        boolean f = a != 1;
        for ( int i = 2; i * i <= a; ++i ) {
          f &= a % i != 0;
        }
        if ( f ) {
          if ( ++cnt >= n ) {
            break;
          }
        }
        a += d;
      }

      System.out.println( a );
    }
  }

  Main() {
    sc = new Scanner( System.in );
  }

  int ni() {
    return sc.nextInt();
  }

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

  void debug(Object... os) {
    System.err.println( Arrays.deepToString( os ) );
  }
}

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

using namespace std;

#define rep(i,b) for(int i=0; i<b; i++)

int v[30];
int w[30];

int dp[1000]={};

int main(){
    int d;
    while(cin>>d){
        int n=0;
        int x; cin>>x;
        rep(i,x){
            char c; int p;
            cin>>c>>p;
            if(c!='D') continue;
            v[n++] = p;
            w[n-1]=1;
        }

        int y; cin>>y;
        rep(i,y){
            char c[3]; int p;
            cin>>c>>p;
            if(c[0]!='D'||c[1]!='D') continue;
            v[n++]=p;
            w[n-1]=2;
        }

        rep(i,d+1) dp[i]=0;
        rep(i,n){
            for(int j=d; j>=0; j--){
                if(j-w[i]>=0) dp[j] = max(dp[j-w[i]]+v[i], dp[j]);
            }
        }

        cout << dp[d] << endl;
    }
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a) for(int i = 0; i < a; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    V v(3);
    rep(i,3) cin>>v[i];
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    cout<<v[0]*10+v[1]+v[2]<<endl;
}

Measured memory_bytes: 256
wotax :: Int -> Maybe Int
wotax n = let x = div ((n + 1) * 100) 108 in
          if div (x * 108) 100 == n then Just x
          else Nothing

myShow Nothing = ":("
myShow (Just x) = show x

main = do
  n <- readLn :: IO Int
  putStrLn $ myShow $ wotax n


Measured memory_bytes: 508
#include<iostream>
#include<map>
#include<vector>
#include<sstream>
using namespace std;
#define DIR 1
#define FILE 2
#define ARB 3
#define REP(i,b,e) for(int i=b;i<e;i++)
#define rep(i,n) REP(i,0,n)
class Tree{
public:
  int type;
  string myname;
  map<string,Tree* > M;
  Tree(){type=DIR;M.clear();myname="";}
};

void get_path(string a,vector<string>&b){
  rep(i,a.size())if (a[i]=='/')a[i]=' ';
  stringstream sin(a);
  while(sin>>a)b.push_back(a);
}

void get_query(string a,vector<pair<string,int> > & b){
  REP(i,1,a.size()){
    string t;
    while(i<a.size() && a[i] != '/')t+=a[i++];
    b.push_back(make_pair(t,DIR) );
  }
  if ( b.size() == 0)return;
  if ( a[a.size()-1]=='/')b.push_back(make_pair("index.html",FILE) );
  else b[b.size()-1].second =ARB;
}

void make_tree(Tree *a,vector<string>&b,int &p){
  if (b.size()==p){return;}
  Tree *next=a->M[b[p]];
  if ( next == 0){
    next = new Tree;
    next->myname=b[p];
    a->M[b[p]]=next;
    if ( p+1 ==b.size())next->type=FILE;
    else next->type=DIR;
    make_tree(next,b,++p);
  }else make_tree(next,b,++p);  
}

Tree* Find_Page(Tree *a,vector<pair<string,int> >&b,int &p,Tree *prev){
  Tree *ret=a;
  while(p < b.size()){
    if (b[p].first == "."){p++;continue;}
    else if ( b[p].first ==".."){p++;return prev;}
    //exceptional case "index.html"
    Tree *next = a->M[b[p].first];
    if ( next == 0 || (next->type&b[p].second )==0  )return NULL;
    ret = Find_Page(next,b,++p,a);
    if ( ret == NULL)return NULL;
  }

  if (ret->type == FILE)return ret;
  ret = ret->M["index.html"];
  if ( ret == 0 || ret->type !=FILE)return NULL;
  return ret;
}

void solve(string *q,Tree *root){
  Tree *data[2];
  rep(i,2){
    vector<pair<string,int> > a;
    int p=0;
    data[i]=NULL;
    get_query(q[i],a);
    data[i]=Find_Page(root,a,p,NULL);
    if (  data[i] == NULL){puts("not found");return;}
  }
  if (data[0] == data[1] )puts("yes");
  else puts("no");
}

main(){
  int n,q;
  while(cin>>n>>q &&n){
    Tree root;
    string t;
    vector<string> a;
    int p=0;
    rep(i,n)cin>>t,get_path(t,a),make_tree(&root,a,p=0),a.clear();
    rep(i,q){
      string in[2];
      cin>>in[0]>>in[1];
      solve(in,&root);
    }
  }
  return false;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
long long to(long long a,long long b) {
	long long s=a/b*b;
	if (s<a) s+=b;
	return s;
}
int main() {
	long long n,x,y,u,v;
	cin >> n;
	cin >> u >> v;
	for  (long long i=2;i<=n;i++) {
		cin >> x >> y;
		if (to(u,x)/x*y>v) {
			u=to(u,x);
			v=u/x*y;
		}
		else {
			v=to(v,y);
			u=v/y*x;
		}
	}
	cout << u+v << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
//#define scanf scanf_s
typedef long long int lli;

// ITP1_5_A
// H * Wの四角形を'#'で出力
// H=0,W=0で終了
int main()
{
	int iInputH, iInputW;
	int iCnt1, iCnt2;

	scanf("%d %d", &iInputH, &iInputW);

	while (iInputH != 0 || iInputW != 0)
	{
		for (iCnt1 = 0; iCnt1 < iInputH; iCnt1++)
		{
			for (iCnt2 = 0; iCnt2 < iInputW; iCnt2++)
			{
				printf("#");
			}
			printf("\n");
		}

		printf("\n");
		scanf("%d %d", &iInputH, &iInputW);
	}

	return 0;
}


Measured memory_bytes: 2044
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";var n=r(1);r(2)(n.readFileSync("/dev/stdin","utf8"))},function(t,e){t.exports=require("fs")},function(t,e,r){"use strict";var n=r(3),i=r(5);t.exports=function(t){var e=new n(t);i(e)}},function(t,e,r){"use strict";var n=r(4);t.exports=class{constructor(t){var e=t.trim().split(/\s+/g);this.inp=new n(e)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,r){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,r){"use strict";var n=998244353;function i(){for(var t=arguments,e=t[0],r=t.length;--r;)e=((e>>16)*t[r]%n*65536+(65535&e)*t[r])%n;return e}function o(t,e){for(var r=1;e;t=i(t,t),e>>=1)1&e&&(r=i(t,r));return r}t.exports=function(t){for(var e=t.in(),r=new Array(e),s=0;s<e;s++)r[s]=t.in();if(0==r[0]){for(var u=new Map,c=0,f=0;f<e;f++)u[r[f]]||(u[r[f]]=0),u[r[f]]++,c=Math.max(c,r[f]);if(1==u[0]){for(var l=1,a=1;a<=c;a++){if(!u[a])return void console.log(0);l=i(l,o(u[a-1],u[a]))%n}console.log(l)}else console.log(0)}else console.log(0)}}]);

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

int main() {
  int a,b,c,d;
  cin >>a>>b>>c;
  d=0;
  if (a==7 & b==5 & c==5) {
    d=1;
  }
  else if (a==5 & b==7 & c==5) {
    d=1;
  }
  else if (a==5 & b==5 & c==7) {
    d=1;
  }
  if (d==1) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}
    
    
    


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

#define int long long
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()

#define fast ios::sync_with_stdio(0); cin.tie(0)
#define print(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1> void __f(const char* name, Arg1&& arg1){
    cout << name << ": " << arg1 << '\n';
}

template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

int32_t main(){
    
    fast;
    int n; cin >> n;
    int ar[n];

    for(int i=0;i<n;i++){
        cin >> ar[i];
    }

    int prefix[n] = {0};
    prefix[0] = 0;


    for(int i=1;i<n;i++){
        if(ar[i]<=ar[i-1]){
            prefix[i] = prefix[i-1] + 1;
        }else{
            prefix[i] = 0;
        }
    }

    int ans = *max_element(prefix,prefix+n);
    cout << ans << '\n';
    
 
    return 0;
} 

Measured memory_bytes: 1792
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    a,b,x = LI()
    ans = 0

    if x >= a**2 * b/2:
        ans = math.degrees(math.atan((a**2*b-x)*2/a**3))
    else:
        ans = math.degrees(math.atan(a*b**2/(2*x)))
    
    print(ans)
main()


Measured memory_bytes: 74896
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    if(s < t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
#define all(v) v.begin(), v.end()
#define rall(x) (x).rbegin(), (x).rend()
#define pll pair<long long, long long>
#define pb emplace_back
#define mp make_pair
#define mt make_tuple
#define vc vector<char>
#define vvc vector<vc>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
template <class T>bool chmax(T &a, const T &b){if (a < b){a = b;return 1;}return 0;}
template <class T>bool chmin(T &a, const T &b){if (b < a){a = b;return 1;}return 0;}
//snippets:tmp,cl,cvl,cs,co,coy,con,cov,setp

ll modPow(long long a, long long n, long long p) {
  if (n == 0) return 1; // 0乗にも対応する場合
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  long long t = modPow(a, n / 2, p);
  return (t * t) % p;
}

ll mod=1000000007;

std::vector<std::vector<long long>> comb(int n, int r) {
  std::vector<std::vector<long long>> v(n + 1,std::vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k])%mod;
    }
  }
  return v;
}

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

  ll i=1;
  ll ans=0;
  vvll com=comb(s+1,s+1);
  while(true){
    if(i*3>s) break;
    ans+=com[s-i*3+i-1][s-i*3]%mod;
    ans%=mod;
    i++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 34424
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF 1e17
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,k; cin>>n>>k;
	vector<int> v(n);
	for(auto &i:v) cin>>i;
	int now=0;
	For(i,0,k-1) now+=v[i];
	int tot=0;
	For(i,k,n-1) tot+=max(0ll,v[i]);
	int ans=tot+max(0ll,now);
	//cout<<tot<<" "<<now<<"\n";
	For(i,k,n-1){
		//cout<<tot<<" "<<now<<"\n";
		now+=v[i]-v[i-k];
		tot+=max(0ll,v[i-k])-max(0ll,v[i]);
		ans=max(ans,tot+max(0ll,now));
	}
	cout<<ans<<"\n";
	return 0;
}





























Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <algorithm>
using namespace std;

int calc(vector<int> v) {
	v.push_back(0);
	int ret = 0;
	int k = 0, p1, p2, p3;
	for (int i=0; i<10; ++i) {
		p1 = 0, p2 = 0, p3 = 0;
		p1 = v[k++];
		if (i == 9) {
			p2 = v[k++];
			if (p1 == 10 || p1 + p2 == 10) p3 = v[k++];
		} else {
			if (p1 == 10) {
				ret += v[k] + v[k+1];
			} else {
				p2 = v[k++];
				if (p1 + p2 == 10) {
					ret += v[k];
				}
			}
		}
		ret += p1 + p2 + p3;
	}
	return ret;
}

int main() {
	int m;
	while (cin >> m, m) {
		cin.ignore();
		vector<pair<int,int> > res;
		string s;
		int idx, t;
		for (int i=0; i<m; ++i) {
			getline(cin, s);
			stringstream ss(s);
			ss >> idx;
			vector<int> score;
			while (ss >> t) {
				score.push_back(t);
			}
			res.push_back(make_pair(-calc(score), idx));
		}
		sort(res.begin(), res.end());
		for (int i=0; i<(int)res.size(); ++i) {
			cout << res[i].second << " " << -res[i].first << endl;
		}
	}
	return 0;
}

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

int main() {
    string ans = "No";
    int X, Y;
    cin >> X >> Y;
    if(Y % 2 == 0) {
        if(Y <= 4 * X && 2 * X <= Y)
            ans = "Yes";
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define DEBUG 0
#define nl          '\n'
#if     DEBUG
#define trace(var)  {cerr << "Line " << __LINE__ << ": " << #var << "=" << var << nl;}
#else
#define trace(var)	{}
#endif
#define fori(n)			for(int i = 0; i < n; ++i) 
#define forj(n)			for(int j = 0; j < n; ++j)
#define fork(n)			for(int k = 0; k < n; ++k)
#define forl(n)			for(int l = 0; l < n; ++l)

typedef long long ll;typedef pair<int,int> pii;typedef vector<bool> vbool;typedef vector<int> vint;typedef vector<ll> vll;typedef long double ld;typedef vector<vector<int>> vvi;

const ll N = 100010;
const ll INF = 0x3f3f3f3f;
const ll MOD = 1e9 + 7;

int n,a[N],ans[N];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	fori(n) cin >> a[i];
	ll x = a[0];
	for(int i = 1; i+1 < n; i+=2) {x-=a[i]; x+=a[i+1];}
	x /= 2;
	ans[0] = x;
	for(int i = 1; i < n; ++i) ans[i] = a[i-1]-ans[i-1];
	
	fori(n) cout << ans[i]*2 << " ";
	cout << nl;

	#if DEBUG
	cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << " s" << nl;
	#endif
	return 0;
}


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

using namespace std;

int main() {
	string S;
	cin >> S;

	int num[26];
	for (int i = 0; i < 26; i++) num[i] = 1;

	int n = (int)S.size();
	for (int i = 0; i < n; i++) {
		num[S[i] - 'a']++;
	}

	for (int i = 1; i < 26; i++) {
		num[0] = num[0] * num[i];
	}

	if (num[0] % 2 != 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;
  if(N == M){
    cout << "Yes";
  } else {
    cout << "No";
  }
  cout << endl;
  return 0;
}


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

int main() {
  int n, flag1, flag2, cnt, ans = 0;
  vector<char> s(101);

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> s.at(i);
  }
  for (int i = 0; i < n; i++) {
    cnt = 0;
    for (int j = 97; j < 123; j++) {
      flag1 = flag2 = 0;
      for (int k = 0; k < i + 1; k++) {
        if (s.at(k) == j) {
          flag1 = 1;
          break;
        }
      }
      for (int k = i + 1; k < n && flag1 == 1; k++) {
        if (s.at(k) == j) {
          flag2 = 1;
          break;
        }
      }
      if (flag1 && flag2) cnt++;
    }
    if (cnt > ans) ans = cnt;
  }

  cout << ans;
  return 0;
}

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

int main(){
  int n, m;
  cin >> n >> m;
  int A[n][m];
  for (int i=0; i<n; ++i){
    for (int j=0; j<m; ++j){
	cin >> A[i][j];
    }
  }
  int b[m];
  for (int i; i<m; ++i){
    cin >> b[i];
  }
  int c[n] = {};
  for (int i=0; i<n; ++i){
    for (int j=0; j<m; ++j){
      c[i] += A[i][j] * b[j];
    }
    cout << c[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3140
import sys
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def prime_numbers(n):
    if n < 2:
        return []

    m = (n + 1) // 2
    p = [1] * m
    for i in range(1, int((n ** 0.5 - 1) / 2) + 1):
        if p[i]:
            p[2 * i * (i + 1) :: 2 * i + 1] = [0] * (((m - 1) - 2 * i * (i + 1)) // (2 * i + 1) + 1)

    a = [2 * i + 1 for i in range(m) if p[i]]
    a[0] = 2
    return a


def main():
    primes = set(prime_numbers(10 ** 5))
    A = [n % 2 and n in primes and (n + 1) // 2 in primes for n in range(10 ** 5 + 1)]
    B = [0]
    B.extend(accumulate(A))

    Q, *LR = map(int, read().split())
    ans = [0] * Q
    for i, (l, r) in enumerate(zip(LR[::2], LR[1::2])):
        ans[i] = B[r + 1] - B[l]

    print(*ans, sep='\n')
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 29256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;

ll num_10e9 = pow(10, 9) + 7;

int main() {
    ll N, K, ans = 0, tmp;
    numeric_limits<ll> inf;
    vector<ll> a, b, sorted_a;
    cin >> N >> K;

    for (ll i = 0; i < N; i++) {
        cin >> tmp;
        a.push_back(tmp);
        sorted_a.push_back(tmp);
    }
//    sort(sorted_a.begin(), sorted_a.end());
//
//    for (ll i = 0; i < N; i++) {
//        ll target = a[i];
//        // calc base part
//        ll n_larger_than_target_after_target = 0;
//        for (ll j = i + 1; j < N; j++) {
//            if (a[j] > target) {
//                n_larger_than_target_after_target++;
//            }
//        }
//        ans += n_larger_than_target_after_target;
//
//        // calc loop part
//        ll n_larger_than_target = 0;
//        for (ll j = 0; j < N; j++) {
//            if (a[j] > target) {
//                n_larger_than_target++;
//            }
//        }
//        ans += n_larger_than_target * (K - 1);
//    }

    for (ll i = 0; i < N; i++) {
        ll target = a[i];
        // calc base part
        ll n_smaller_than_target_after_target = 0;
        for (ll j = i + 1; j < N; j++) {
            if (a[j] < target) {
                n_smaller_than_target_after_target++;
            }
        }
        ans += n_smaller_than_target_after_target * K % num_10e9;
//        cout << n_smaller_than_target_after_target << endl;

        // calc loop part
        ll n_smaller_than_target = 0;
        for (ll j = 0; j < N; j++) {
            if (a[j] > target) {
                n_smaller_than_target++;
            }
        }
//        ans += n_smaller_than_target * (K - 1);
        ans += n_smaller_than_target * (K * (K - 1) / 2 % num_10e9) % num_10e9;
//        cout << n_smaller_than_target << endl;
    }


    cout << ans % num_10e9 << endl;
}

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

typedef struct {
	int k;
	int s[11];
	int p;
}pair_t;

int main(void) {
	int n, m;
	pair_t pair[11] = { 0 };
	int temp;
	int switches[11] = { 0 };
	int judge;
	int ans = 0;

	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d", &pair[i].k);
			for (int j = 0; j < pair[i].k; j++) scanf("%d", &pair[i].s[j]);
	}
	for (int i = 0; i < m; i++) scanf("%d", &pair[i].p);
	int max = 1;
	for (int i = 0; i < n; i++) max *= 2;
	//printf("max=%d\n", max);
	for (int i = 0; i < max; i++) {
		temp = i;
		//printf("temp=%d  ", temp);
		for (int j = 0; temp > 0; j++) {
			switches[j] = temp % 2;
			temp /= 2;
		}
		for (int a = 0; a < m; a++) {
			judge = 0;
			for (int b = 0; b < pair[a].k; b++) {
				judge += switches[pair[a].s[b] - 1];				
			}
			//printf("a:%d  judge=%d  ", a, judge);
			if (judge % 2 != pair[a].p)break;
			else if (a == m - 1) ans++;
		}
		/*
		printf("switches=");
		for (int x = n - 1; x >= 0; x--) printf("%d", switches[x]);
			printf("\n");
			*/
	}
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 128
n = int(input())
a = [int(i) for i in input().split()]
lst1 = {}
lst2 = {}
ans = 0
for i in range(len(a)):
  val1 = str(i + a[i])
  val2 = str(i - a[i])
  if val2 in lst1.keys():
    ans += lst1[val2]
  if val1 in lst1.keys():
    lst1[val1] += 1
  else:
    lst1[val1] = 1
print(ans)
  
  

Measured memory_bytes: 130852
import sys
input=sys.stdin.readline

def main():
    S = input().strip()
    T = input().strip()
    a = [set() for i in range(26)]
    for i,c1 in enumerate(S):
        s = a[ord(c1)-ord("a")]
        s |= set(T[i])
        if len(s) >= 2:
            print("No")
            return
    a = [set() for i in range(26)]
    for i,c1 in enumerate(T):
        s = a[ord(c1)-ord("a")]
        s |= set(S[i])
        if len(s) >= 2:
            print("No")
            return
        
    print("Yes")

if __name__ == '__main__':
    main()


Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
# 整数の入力
N, M, C = map(int, raw_input().split())
B = map(int, raw_input().split())

count = 0
for n in range(N):
    A = map(int, raw_input().split())
    sum = 0
    for m in range(M):
        sum += A[m] * B[m]

    if sum > -C:
        count += 1

print count


Measured memory_bytes: 2568
// /usr/local/bin/g++ Main.cpp -std=c++14
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int H, W, K, C[30*30], _c[30*30];
set<int> d;

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

	cin >> H >> W >> K;
	for (int i = 0; i < H; i++) {
		string s;
		cin >> s;
		int j = 0;
		for (char& c : s) {
			C[i*W+(j++)] = (int)(c - '0');
		}
	}

	ll res = 0;
	for (int i = 1; i < H; i++) {
		for (int j = 0; j < W; j++) {
			for (int k = 0; k < 30*30; k++) {
				_c[k] = C[k];
			}
			d.clear();
			d.insert(i*W+j);
			int cnt = 0;
			int __res = 0;
			while (d.size()) {
				for (int l : d) {
					for (int _i = l/W; _i > 0; _i--) {
						_c[_i*W+l%W] = _c[(_i-1)*W+l%W];
					}
					_c[l%W] = 0;
				}
				d.clear();
				int _res = 0;
				for (int _i = 1; _i < H; _i++) {
					int pre = 0;
					bool loop = false;
					int kuri = K - 1;
					for (int _j = 0; _j <= W; _j++) {
						if (_j != W && pre != 0 && _c[_i*W+_j] == pre) {
							if (--kuri <= 0) {
								for (int _t = 0; _t < K - 1; _t++) {
									if (d.count(_i*W+_j-(_t+1)) == 0) {
										d.insert(_i*W+_j-(_t+1));
										_res += pre;
									}
								}
								loop = true;
							}
						} else {
							if (loop) {
								_res += pre;
								d.insert(_i*W+_j-1);
							}
							kuri = K - 1;
							loop = false;
						}
						if (_j < W) pre = _c[_i*W+_j];
					}
				}
				if (_res > 0) {
					int tmp = 1;
					for (int _k = 0; _k < cnt; _k++) {
						tmp *= 2;
					}
					__res += tmp*_res;
				}
				cnt++;
			}
			if (res < __res) res = __res;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
i=3;main(n,j){for(scanf("%d",&n);j=n-i+1&~1,j+=j&1,n>3&5000<j;i+=3);for(i=n-j;i;printf(n<4?i=0,"2 3 25":"%d ",2*i--))for(;j;printf("%d ",6*j---3));}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> vec(n);
    for(int i = 0; i < m;i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        vec.at(a).push_back(b);
        vec.at(b).push_back(a);
    }
    queue<int> q;
    vector<int> dist(n,INF);
    vector<int> pre(n,-1);
    dist[0] = 0;
    q.push(0);
    while(!q.empty()){
        int v = q.front();q.pop();
        for(auto u : vec.at(v)){
            if(dist.at(u) != INF) continue;
            dist.at(u) = dist.at(v) + 1;
            pre.at(u) = v;
            q.push(u);
        }
    }
    cout << "Yes" << endl;
    for(int i = 0; i < n;i++){
        if(i == 0) continue;
        cout << ++pre.at(i) << endl;
    }
    return 0;
}

Measured memory_bytes: 10688
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int MOD = 1e9+7;
const ll LINF = 1e18;
const int INF = 1e9;
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

int main()
{
    cin >> A >> B;
    cout << A*B;
    
    return 0;
}

Measured memory_bytes: 3612
# AOJ 0611: Silk Road
# Python3 2018.7.4 bal4u

import sys
from sys import stdin
input = stdin.readline

INF = 0x7fffffff
n, m = map(int, input().split())
d = [int(input()) for i in range(n)]
c = [0] + [int(input()) for i in range(m)]
dp = [[INF for j in range(n+1)] for i in range(2)]
dp[0][0] = 0
for i in range(1, m+1):
	for j in range(n+1): dp[i&1][j] = INF
	for j in range(n+1): dp[i&1][j] = dp[1-(i&1)][j]
	for j in range(n):
		if dp[1-(i&1)][j] != INF:
			dp[i&1][j+1] = min(dp[i&1][j+1], dp[1-(i&1)][j]+c[i]*d[j])
print(dp[i&1][n])


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

#define HEAP priority_queue
#define rep(i, n) for(int i = 0, _end_ = (n); i < _end_; ++i)
#define per(i, n) for(int i = (n) - 1; i >= 0 ; --i)
#define forn(i, l, r) for(int i = (l), _end_ = (r); i <= _end_; ++i)
#define nrof(i, r, l) for(int i = (r), _end_ = (l); i >= _end_; --i)
#define FOR(a, b) for(auto (a): (b))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define X first
#define Y second
#define eps 1e-6
#define pi 3.1415926535897932384626433832795
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(), x.end()

using namespace std;

typedef long long LL;
typedef double flt;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<int,LL> pil;
typedef pair<LL,int> pli;
typedef pair<LL,LL> pll;
typedef vector<pil> vil;
typedef vector<pii> vii;
typedef vector<pli> vli;
typedef vector<pll> vll;

const int iinf = 1e9 + 7;
const int oo = 0x3f3f3f3f;
const LL linf = 1ll << 60;
const flt dinf = 1e60;

template <typename T> inline void scf(T &x)
{
	bool f = 0;
	x = 0;
	char c = getchar();
	while(c != '-' && (c < '0' || c > '9')) c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	if(f) x = -x;
	return;
}

template <typename T1, typename T2> void scf(T1 &x, T2 &y)
{
	scf(x);
	return scf(y);
}

template <typename T1, typename T2, typename T3> void scf(T1 &x, T2 &y, T3 &z)
{
	scf(x);
	scf(y);
	return scf(z);
}

template <typename T1, typename T2, typename T3, typename T4> void scf(T1 &x, T2 &y, T3 &z, T4 &w)
{
	scf(x);
	scf(y);
	scf(z);
	return scf(w);
}

inline char mygetchar()
{
	char c = getchar();
	while(c == ' ' || c == '\n') c = getchar();
	return c;
}

template <typename T> inline bool chkmax(T &x, const T &y)
{
	return y > x ? x = y, 1 : 0;
}

template <typename T> inline bool chkmin(T &x, const T &y)
{
	return y < x ? x = y, 1 : 0;
}

#ifdef King_George
#define DEBUG
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

//---------------------------------------------------------head----------------------------------------------------

LL K, n = 50;
LL a[55];

int main()
{
	scf(K);
	LL bnd = n - 1 - K, z = n + 1;
	LL k = K, m = n;
	printf("%lld\n", n);
	forn(i, 1, n)
	{
		LL kk = k / m;
		a[i] = z * kk + bnd;
		k -= kk;
		--m;
		printf("%lld ", a[i]);
	}
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::*;

fn read<T: FromStr>(s: &mut StdinLock) -> Option<T> {
    let s = s.by_ref()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let s = stdin();
    let mut s = s.lock();
    let S: String = read(&mut s).unwrap();

    if S.find('a') != None && S.find('b') != None && S.find('c') != None {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<stdio.h>

int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    a=(a-2+13)%13;
    b=(b-2+13)%13;
    if(a==b)printf("Draw\n");
    if(a>b)printf("Alice\n");
    if(a<b)printf("Bob\n");
    return 0;
}

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

static const int N = 100 + 1;

void trace(int* a, int n);
void swapInt(int& t1, int& t2);
int selectionSort(int* a, int n);

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

  int c = selectionSort(a, n);
  trace(a, n);
  printf("%d\n", c);

  return 0;
}

int selectionSort(int* a, int n) {
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    int minj = i;
    int flag = 0;
    int j;
    for (j = i + 1; j < n; ++j) {
      if (a[j] < a[minj]) { minj = j; flag = 1; }
    }
    if (flag) {
      swapInt(a[i], a[minj]);
      cnt++;
    }
  }
  return cnt;
}

void trace(int* a, int n) {
  for (int i = 0; i < n; ++i) {
    if (i) { printf(" "); }
    printf("%d", a[i]);
  }
  printf("\n");
}

void swapInt(int& t1, int& t2) {
  int temp = t1;
  t1 = t2;
  t2 = temp;
}

Measured memory_bytes: 1152
#include<iostream>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int a[100][100],w,h,ans;
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
void dfs(int y,int x,int d){
  ans=max(ans,d);
  r(i,4){
    int xx=x+dx[i],yy=y+dy[i];
    if(xx<0||xx>=w||yy<0||yy>=h)continue;
    if(!a[yy][xx])continue;
    a[yy][xx]=0;
    dfs(yy,xx,d+1);
    a[yy][xx]=1;
  }
}
int main(){
  while(cin>>w>>h,w){
    r(i,h)r(j,w)cin>>a[i][j];
    ans=0;
    r(i,h)r(j,w)if(a[i][j])dfs(i,j,0);
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
const int dx[4]={-1,1,0,0};
const int dy[4]={0,0,-1,1};
int a[4];
signed main()
{
	int n;
	cin>>n;
	while (n--){
		string s;
		cin>>s;
		if (s=="AC")  a[0]++;
		if (s=="WA")  a[1]++;
		if (s=="TLE")  a[2]++;
		if (s=="RE")  a[3]++;
	}
	cout<<"AC x "<<a[0];
	cout<<"\nWA x "<<a[1];
	cout<<"\nTLE x "<<a[2];
	cout<<"\nRE x "<<a[3]; 
	re 0;
}


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

int main()
{
    std::string s1, s2;
    std::cin >> s1 >> s2;
    int size1 = s1.size();
    int size2 = s2.size();
    int d[size1 + 1][size2 + 1];
    for (int i = 0; i <= size1; ++i)
    {
        d[i][0] = i;
    }

    for (int i = 0; i <= size2; ++i)
    {
        d[0][i] = i;
    }

    for (int i = 1; i <= size1; ++i)
    {
        for (int j = 1; j <= size2; ++j)
        {
            int cost = s1[i - 1] == s2[j - 1] ? 0 : 1;
            d[i][j] = std::min(std::min(d[i - 1][j] + 1, d[i][j - 1] + 1), d[i - 1][j - 1] + cost);
        }
    }

    std::cout << d[size1][size2] << "\n";
}


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

bool isPalindrome(string s) {
    string rev_s = s;
    reverse(rev_s.begin(), rev_s.end());
    return s == rev_s;
}

int main(){
    string S;
    cin >> S;
    int len = S.size() / 2;
    if (isPalindrome(S) && isPalindrome(S.substr(0, len))) cout << "Yes" << endl;
    else cout << "No" << endl;
} 

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

#define REP(i, n) for (int i = 0; i < (n); ++i)

#define INF (1 << 30)

int main(void) {
    int n, a, min_a = INF, max_a = 0;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    REP(i, n) {
        cin >> a;
        min_a = min(min_a, a);
        max_a = max(max_a, a);
    }

    cout << max_a - min_a << "\n";
    return 0;
}

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

namespace edamat {
template <typename T>
struct SegTree {
    using F = ::std::function<T(T, T)>;
    int n;
    F f;
    T ti;
    ::std::vector<T> dat;
    SegTree(){};
    SegTree(F f, T ti) : f(f), ti(ti) {}
    void init(int n_) {
        n = 1;
        while(n < n_) n <<= 1;
        dat.assign(n << 1, ti);
    }
    void build(const ::std::vector<T> &v) {
        int n_ = v.size();
        init(n_);
        for(int i = 0; i < n_; i++) dat[n + i] = v[i];
        for(int i = n - 1; i; i--)
            dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]);
    }
    void update(int k, T x) {
        dat[k += n] = x;
        while(k >>= 1) dat[k] = f(dat[(k << 1) | 0], dat[(k << 1) | 1]);
    }
    T query(int a, int b) {
        assert(0 <= a and b <= n);
        T vl = ti, vr = ti;
        for(int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) {
            if(l & 1) vl = f(vl, dat[l++]);
            if(r & 1) vr = f(dat[--r], vr);
        }
        return f(vl, vr);
    }
    template <typename C>
    int find(int st, C &check, T &acc, int k, int l, int r) {
        if(l + 1 == r) {
            acc = f(acc, dat[k]);
            return check(acc) ? k - n : -1;
        }
        int m = (l + r) >> 1;
        if(m <= st) return find(st, check, acc, (k << 1) | 1, m, r);
        if(st <= l && !check(f(acc, dat[k]))) {
            acc = f(acc, dat[k]);
            return -1;
        }
        int vl = find(st, check, acc, (k << 1) | 0, l, m);
        if(~vl) return vl;
        return find(st, check, acc, (k << 1) | 1, m, r);
    }

    template <typename C>
    int find(int st, C &check) {
        T acc = ti;
        return find(st, check, acc, 1, 0, n);
    }
    T operator[](const int &k) const { return dat[k + n]; }
};
}  // namespace edamat

void solve() {
    int N;
    scanf("%d", &N);
    std::vector<int> h(N);
    rep(i, N) scanf("%d", &h[i]);
    std::vector<int> a(N);
    rep(i, N) scanf("%d", &a[i]);
    // segがdp配列代わり
    edamat::SegTree<i64> seg([](i64 a, i64 b) { return std::max<i64>(a, b); },
                             0LL);
    seg.init(220000);
    rep(i, N) {
        auto t = seg.query(0, h[i] + 1) + a[i];
        seg.update(h[i], t);
    }
    printf("%ld\n", seg.query(0, 220000));
}

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

Measured memory_bytes: 5888
#include <stdio.h>

#define INT_MIN ((int) 1)
#define INT_MAX ((int) 1000000000)

typedef enum
{
	kSuccess = 0,
	kError = -1
}Result;

Result checkNumRange( int num, int min, int max );
int calctateGcd( int x, int y );

int main( void )
{
	int x, y;

	scanf( "%d %d", &x, &y );

	if( (checkNumRange( x, INT_MIN, INT_MAX ) || checkNumRange( y, INT_MIN, INT_MAX )) == kError )
	{
		return kError;
	}

	printf( "%d\n", calctateGcd( x, y ) );

	return kSuccess;
}

Result checkNumRange( int num, int min, int max )
{
	return ((num >= min) && (num <= max)) ? kSuccess : kError;
}

int calctateGcd( int x, int y )
{
	int work;

	if( x < y )
	{
		work = x;
		x = y;
		y = work;
	}

	while( y > 0 )
	{
		work = x % y;
		x = y;
		y = work;
	}

	return x;
}



Measured memory_bytes: 2044
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    x, y, z, k = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))

    AB = []
    for a in A:
        for b in B:
            AB.append(a + b)
    AB = sorted(AB, reverse=True)[:k]

    res = []
    for ab in AB:
        for c in C:
            res.append(ab + c)
    res = sorted(res, reverse=True)[:k]
    print(*res, sep="\n")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 242492
using System;

namespace ConsoleApp1
{
    class ABC179B
    {
        // https://atcoder.jp/contests/abc179/tasks/abc179_b
        static void Main(string[] args)
        {
            int N = Int32.Parse(Console.ReadLine());

            int x = 0;
            bool result = false;

            for (int i = 0; i < N; i++)
            {
                var ab = Console.ReadLine().Split();
                int a = Int32.Parse(ab[0]);
                int b = Int32.Parse(ab[1]);

                if (a == b)
                {
                    x++;
                    if (x >= 3)
                    {
                        result = true;
                    }
                }
                else
                {
                    x = 0;
                }
            }
            Console.WriteLine(result ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 27528
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

n = int(arr_data[0][0])
k = int(arr_data[1][0])
x = int(arr_data[2][0])
y = int(arr_data[3][0])


if k>=n:
    
    print(n*x)

else:
    
    print(x*k + y*(n-k) )

Measured memory_bytes: 3064
inp = input()
inplist1 = inp.split()
people = int(inplist1[0])
kinds = int(inplist1[1])

inplist2 = [input() for i in range(kinds * 2)]

foodlist = []
roop = 0
for i in inplist2:
  if roop % 2 == 0 :
    roop += 1
    continue
  boys = i.split()
  for boy in boys:
    foodlist.append(boy)
  roop += 1

setlist = set(foodlist)
print(people -len(setlist))



Measured memory_bytes: 9628
#include <algorithm>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

int main(void) {
    int x, a, b;
    cin >> x >> a >> b;

    if(b - a > x){
        cout << "dangerous" << endl;
    }else if(b - a > 0){
        cout << "safe" << endl;
    }else{
        cout << "delicious" << endl;
    }

    return 0;
}


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

const int MOD = 1000000007;

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int N;
    cin >> N;

    int digits = 1;
    while (true) {
        if (N >= pow(10, digits - 1) && N < pow(10, digits)) {
            break;
        }
        digits++;
    }

    if (digits == 1) {
        cout << N << endl;
    } else if (digits == 2) {
        cout << 9 << endl;
    } else if (digits == 3) {
        cout << 9 + N - 100 + 1 << endl;
    } else if (digits == 4) {
        cout << 9 + 900 << endl;
    } else if (digits == 5) {
        cout << 9 + 900 + N - 10000 + 1 << endl;
    } else { // N=100000
        cout << 9 + 900 + 90000 << endl;
    }
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-

import sys


def main():
    s, w = [int(x) for x in sys.stdin.readline().rstrip().split(" ")]
    data = []
    for line in sys.stdin:
        data.append(list(line.rstrip()))

    for i in range(s):
        for j in range(w):
            if data[i][j] == "#":
                continue
            count = 0
            for k in range(max(i - 1, 0), min(i + 2, s)):
                for l in range(max(j - 1, 0), min(j + 2, w)):
                    if data[k][l] == "#":
                        count += 1
            data[i][j] = str(count)

    for line_arr in data:
        print("".join(line_arr))

if __name__ == "__main__":
    main()


Measured memory_bytes: 3188