akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
DbgTimer D_t;
  #define TSTART() D_t.start()
  #define TSTOP() D_t.stop()
#else
  #define DUMP(i) 
  #define TSTART()
  #define TSTOP()  
#endif
 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const int EPS = 1e-9;



int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  vi num(3);
  while(cin >> num[0] >> num[1] >> num[2]){
    TSTART();
    sort(ALL(num));
    string ans;
    if(num[0] == 5 && num[1] == 5 && num[2] == 7)ans = "YES";
    else ans = "NO";
    cout << ans << endl;
    TSTOP();
  }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > using vec = std::vector< T >;
template < class T = int > T in() {
  T x;
  cin >> x;
  return (x);
}
template < class T > void print(T &x) { cout << x << "\n"; }
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vec< int > a(N);
  REP(i, N) { cin >> a[i]; }
  vec< int > l(N + 1, -INF);
  vec< int > r(N + 1, -INF);
  REP(i, N) {
    l[i + 1] = max(l[i], a[i]);
    r[i + 1] = max(r[i], a[N - 1 - i]);
  }
  REP(i, N) { cout << max(l[i], r[N - 1 - i]) << "\n"; }
  // print();
}

Measured memory_bytes: 6272
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n = sc.nextInt()
  val str = sc.next()
  val sb = new StringBuilder

  val (l, r, cnt) = Range(0, str.length)
    .map(str.charAt(_))
    .foldLeft((0, 0, 0)) {
      case ((l, r, cnt), c) => {
        c match {
          case '(' =>
            (l + 1, r, cnt + 1)
          case ')' =>
            if (cnt == 0) {
              (l, r + 1, cnt)
            } else {
              (l - 1, r, cnt - 1)
            }
        }
      }
    }

  val ans = Stream.concat(Range(0, r).map(_ => '('), str.toStream, Range(0, l).map(_ => ')'))
      .foreach(sb.append(_))
  println(sb.toString())
}


Measured memory_bytes: 25532
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define FI(i, a, b) for (int i = (a); i <= (b); ++i)
#define FD(i, b, a) for (int i = (b); i >= (a); --i)
#define DEBUG(x) cerr << #x << ": " << (x) << endl;
 
int main() {
  double a, b, x;
  cin >> a >> b >> x;
  if (x >= a * a * b / 2) {
    double y = a * a * b - x;
    double h = 2 * y / a / a;
    double ang = atan(h / a);
    printf("%.10f\n", ang / acos(-1) * 180);
  } else {
    double h = 2 * x / a / b;
    double ang = atan(h / b);
    printf("%.10f\n", 90 - ang / acos(-1) * 180);
  }
}


Measured memory_bytes: 512
#include<stdio.h>
#include<iostream>
#include<string>
#include<complex>
#include<algorithm>
#include<vector>

int main()
{
	char s[6];
	scanf("%s", s);
	int n{};
	for (int i = 0; i < 4; ++i)
	{
		if (s[i] == '+') ++n;
		else --n;
	}
	printf("%d\n", n);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    long double sum=0;
    for(int i=0;i<n;i++)
    {
        long double c;
        cin>>c;
        sum=sum+(1/c);
    }
    cout<<fixed<<setprecision(10)<<1/sum<<'\n';
}


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

using namespace std;

int main(int argc, char const *argv[])
{
    string S;
    cin >> S;
    int cnta = 0;
    int cntb = 0;
    for (int i = 0; i < (int)S.length(); i++)       //101010...
    {
        if (i % 2 == 0)
        {
            if (S[i] == '0') cnta++;
        }else
        {
            if (S[i] == '1') cnta++;
        }
        
    }

    for (int i = 0; i < (int)S.length(); i++)       //010101...
    {
        if (i % 2 == 0)
        {
            if (S[i] == '1') cntb++;
        }else
        {
            if (S[i] == '0') cntb++;
        }
        
    }

    cout << min(cnta, cntb) << endl;
    
    return 0;
}

Measured memory_bytes: 512
def submit():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()

    dp = [False for _ in range(k + 1)]
    for i in range(k + 1):
        for e in a:
            if i >= e:
                dp[i] = dp[i] or not dp[i - e]
    
    if dp[k]:
        print("First")
    else:
        print("Second")

submit()
        

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

int main(){

  int n, a, b, c, x;
  int y[110];

  while(cin >> n >> a >> b >> c >> x, n|a|b|c|x){
    int ans = 0;
    for(int i = 0; i < n; i++){
      cin >> y[i];
    }
    int idx = 0;
    int i;
    for(i = 0; i <= 10000; i++){
      if(y[idx] == x){
        idx++;
      }
      if(idx == n) break;
      x = (a * x + b) % c;
    }
    if(i < 10001){
      cout << i << endl;
    }else{
      cout << -1 << endl;
    }
  }
  return 0;
}


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

int N,X;
int k = 0 ;
int count = 0;
int rem;
int swap(int c,int d){
  if( d < c){
    rem = c;
    c = d ;
    d = rem;
  }
}

int gcd(int a ,int b){
  swap(a,b);
  if(a == 0) return b;
  else return gcd(b % a,a);
}


int main(void){
  scanf("%d",&X);
if(360 % X == 0){
  printf("%d",360/X);
}else{
  gcd(X,360);
  printf("%d",360/gcd(X,360));
}


}


Measured memory_bytes: 1728
def main():
    N = int(input())  # 文字列または整数(一変数)

    mins = []
    maxs = []

    for i in range(N):
        a, b = map(int, input().split())
        mins.append(a)
        maxs.append(b)

    mins.sort()
    maxs.sort()

    if N % 2 == 1:
        # 奇数の場合
        mid = N // 2
        print(maxs[mid] - mins[mid] + 1)

    else:
        mid1 = N // 2
        mid2 = mid1 - 1
        smallest = mins[mid1] + mins[mid2]
        largest = maxs[mid1] + maxs[mid2]
        print(largest - smallest + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 25320
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const ll MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());
//set_intersection(x, x+7, y, y+6, back_inserter(v));
//set_union(x, x+7, y, y+6, back_inserter(v));
//set_difference(x, x+7, y, y+6, back_inserter(v));

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}


int main(){
  int a,b,t;
  cin >> a >> b >> t;
  cout<< t/a*b<<endl;

}


Measured memory_bytes: 256
n = gets.to_i
array = gets.split.map(&:to_i)
array_diff = []

n.times do |i|
  if i == 0
    array_diff.push(0)
  else
    diff = array[i] - array[i - 1]
    if diff < 0
      array[i] += diff.abs
      array_diff.push(diff.abs)
    else
      array_diff.push(0)
    end
  end
end

puts array_diff.sum


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

int main(){
  char y1000, y100, y10, y1;
  char s1, s2;
  char m10, m1;
  string d;
  cin >> y1000 >> y100 >> y10 >> y1;
  cin >> s1 >> m10 >> m1 >> s2;
  cin >> d;
  cout << "2018/01/" << d << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 10000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;

int main(){
    bool flag=true;
    ll H,W,A,B,a1,a2,b1,b2,temp;
    cin>>H>>W>>A>>B;
    a1=A; a2=W-A; b1=B; b2=H-B;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(j<a1 && i<b1) cout<<0;
            else if(i<b1) cout<<1;
            else if(j<a1) cout<<1;
            else cout<<0;
        }
        cout<<endl;
    }

}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <typeinfo>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    string s;

    cin >> s;
    cout << (s == "ARC" ? "ABC" : "ARC") << endl;
}

Measured memory_bytes: 3628
#include<cstdio>
using namespace std;
int main()
{
	int n,t,x,y;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d%d",&t,&x,&y);
		if(x+y>t)
		{
			printf("No\n");
			return 0;
		}
		if((x+y)%2==0&&t%2==1)
		{
			printf("No\n");
			return 0;
		}
		if((x+y)%2==1&&t%2==0)
		{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let h = input::<usize>();
    let w = input::<usize>();
    let mut a = (0..h)
        .map(|_| {
            input::<String>()
                .chars()
                .map(|c| if c == '.' { 0 } else { 1 })
                .collect()
        })
        .collect::<Vec<Vec<i64>>>();

    loop {
        let mut ok = true;

        for i in 0..h {
            let mut drop = true;
            let mut dropped = true;
            for j in 0..w {
                if a[i][j] >= 0 {
                    dropped = false;
                }
                if a[i][j] >= 0 && a[i][j] != 0 {
                    drop = false;
                    break;
                }
            }
            if !dropped && drop {
                ok = false;
                for j in 0..w {
                    a[i][j] = -1;
                }
            }
        }

        for j in 0..w {
            let mut drop = true;
            let mut dropped = true;
            for i in 0..h {
                if a[i][j] >= 0 {
                    dropped = false;
                }
                if a[i][j] >= 0 && a[i][j] != 0 {
                    drop = false;
                    break;
                }
            }
            if !dropped && drop {
                ok = false;
                for i in 0..h {
                    a[i][j] = -1;
                }
            }
        }

        if ok {
            break;
        }
    }

    let out = std::io::stdout();
    let mut buf = std::io::BufWriter::new(out.lock());
    for i in 0..h {
        let mut line = false;
        for j in 0..w {
            if a[i][j] >= 0 {
                line = true;
                write!(buf, "{}", if a[i][j] == 0 { '.' } else { '#' }).unwrap();
            }
        }
        if line {
            write!(buf, "\n").unwrap();
        }
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
typedef struct sw{
	int x,y,z,cal,n;
}SW;
SW a[1005];
int main(){
	int i,n,m,p,q,r,c,f;
	
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		f=0;
		for(i=0;i<n;i++){
			scanf("%d",&m);
			a[i].n=m;
			scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].z);
			a[i].cal=a[i].x*4+a[i].y*9+a[i].z*4;
		}
		scanf("%d%d%d%d",&p,&q,&r,&c);
		for(i=0;i<n;i++){
			if(a[i].x<=p && a[i].y<=q && a[i].z<=r && a[i].cal<=c){
				printf("%d\n",a[i].n);
				f=1;
			}
		}
		if(f==0)printf("NA\n");
	}
	
	return 0;
}

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

int main(){
  int i, start, end;
  string a;
  cin >> a;

  i = 0;
  while( a[i]!='A' ){
    i++;
  }
  start = i;

  while( i < a.size() ){
    if( a[i]=='Z' ){
      end = i;
    }
    i++;
  }
  cout << end-start+1 << endl; 
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define all(v) v.begin(),v.end()
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl 

void Suhaib_Sawalha (){

    int n;
    cin >> n;
    int a;
    int ans;
    cin >> ans;
    for (int i = 1 ; i < n ; ++i){
        cin >> a;
        ans = __gcd(ans,a);
    }

    cout << ans;

}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<'\n')
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}

Measured memory_bytes: 3648
while 1:
    try:
        n = input()
        if n==0: break
        l = []
        for i in range(n):
            p,d1,d2 = map(int, raw_input().split())
            l.append([p,d1+d2])
        l.sort(reverse=True, key=lambda x:x[1])
        print l[0][0],l[0][1]
    except SyntaxError:
        pass

Measured memory_bytes: 6304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MX = 0; //最大値

ll dp[MX][MX];
inline void chmax(ll& a, ll b) {
  a = max(a, b);
}

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0; i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000

int main(){
    ll n; cin >> n;
    vector<ll> v(n);
    rep(i,n) cin >> v.at(i);

    ll cnt = 0;
    for(ll i = 0; i < n; i += 2){
        if(v.at(i)%2 == 1) cnt++;
    }
    cout << cnt << endl; 
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<long long>> vvll;
typedef long double ld;
typedef std::vector<long double> vld;
typedef std::vector<std::vector<long double>> vvld;
using namespace std;
void yesno(bool state);

void Main(){
    ll N;
    cin >> N;
    ll ac = 0;
    ll wa = 0;
    ll tle = 0;
    ll re = 0;
    rep(i,N){
        string S;
        cin >> S;
        if(S=="AC")
            ac++;
        if(S=="WA")
            wa++;
        if(S=="TLE")
            tle++;
        if(S=="RE")
            re++;
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}

int main(int argc, char const *argv[])
{
    Main();
    return 0;
}

void yesno(bool state){
    if(state)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<(b)?(a=b,1):0)
#define chmin(a,b) (a>(b)?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
const int INF = 1<<29;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef pair<int,int> pii;
typedef long long ll;

const int mod = 1e9+7;
void add(ll &a, ll b) {
  a = (a+b) % mod;
}
char c[200];
ll dp[201][202][202];
// dp[i][j][k] = i番目までみて，まだ順位が決まってないのがjチームで，チームが決まってない順位がk個なときの場合の数

int main() {
  int n;
  while(cin >> n) {
    REP(i,n) cin >> c[i];
    memset(dp,0,sizeof(dp));
    dp[0][0][0] = 1;
    REP(i,n) {
      REP(j,i+1) {
        REP(k,i+1) {
          if (c[i] == 'U') {
            add(dp[i+1][j+1][k+1], dp[i][j][k]);
            add(dp[i+1][j][k], dp[i][j][k]*j%mod);
          } else if (c[i] == 'D') {
            if (k) {
              add(dp[i+1][j][k], dp[i][j][k]*k);
              if (j)
                 add(dp[i+1][j-1][k-1], dp[i][j][k]*j%mod*k%mod);
            }
          } else {
            add(dp[i+1][j][k], dp[i][j][k]);
          }
        }
      }
    }
    cout << dp[n][0][0] << endl;
  }
}

Measured memory_bytes: 65240
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		try (Scanner sc = new Scanner(System.in)){
			while (true) {
				int H = sc.nextInt();
				int W = sc.nextInt();
				if ((H == 0) && (W == 0)) break;

				for (int i=0; i<H ; i++) {
					for (int j=0; j<W ; j++) {
						System.out.print('#');
					}
					System.out.print('\n');
				}
				System.out.print('\n');
			}
		}
	}
}



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

typedef long long int ll; 
char s[200010],t[200010];


int main(void)
{
	cin >> s >> t;

	ll len = strlen(s);
	ll cnt = 0;
	for(ll i=0;i<len;i++)
		if(s[i] != t[i])
			cnt++;

	cout << cnt << endl;

	return 0;
}

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

int main(){
    int n,a;
    cin >> n >> a;
    string ans="No";
    rep(j,n/500+2){
        rep(i,a){
            //cout << i+500*j <<endl;
            if(n==i+500*j){
                ans="Yes";
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
<?php
/*
    Problem URL : http://arc059.contest.atcoder.jp/tasks/arc059_b

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

ini_set('error_reporting', E_ALL & ~E_NOTICE);

fscanf(STDIN, "%s", $s);
$sLen = strlen($s);
$arrS = str_split($s);

for ($i = 1; $i < $sLen; $i++) {
    if ($i != 1) {
        if ($arrS[$i] == $arrS[$i-2]) {
            echo ($i - 1) . " " . ($i + 1) . "\n";
            exit;
        }
    }
    if ($arrS[$i] == $arrS[$i-1]) {
        echo $i . " " . ($i + 1) . "\n";
        exit;
    }
}
echo "-1 -1\n";


Measured memory_bytes: 21008
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1000000000;/* 1e+9a */
namespace utils{

    class Repeater{
        int st;
        int ed;
        int d;
    public:
        class rep_iterator{
            int i; int d;
        public:
            rep_iterator(int x, int pd) :i(x), d(pd) {}

            int& operator*(){ return i; }
            bool operator==(const rep_iterator& k) const { return i == k.i; }
            bool operator!=(const rep_iterator& k) const { return i != k.i; }
            rep_iterator& operator++(){ i+=d; return *this; }
        };

        Repeater(int N) :st(0), ed(N), d(1) {}
        Repeater(int b, int e) :st(b), ed(e), d(1) {if(st > ed){ st--; ed--; d = -1; } }

        rep_iterator begin() const{ return rep_iterator(st, d); }
        rep_iterator end() const{ return rep_iterator(ed, d); }

    };

    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool min_update(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool max_update(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }
#define ALL(x) begin(x), end(x)
#define rALL(x) rbegin(x), rend(x)
};
using namespace utils;

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a%b);
}


void sub_main(istream &cin) {
    ll N;
    cin >> N;
    if(!cin) return;
    vector<ll> A(N);
    for (auto &&a : A) { cin >> a; } // end a
    vector<ll> L(N+1), R(N+1);
    L[0] = 0;
    for (auto &&i : Repeater(0, N)) {
        L[i+1] = gcd(L[i], A[i]);
    } // end i
    R.back() = 0;
    for (auto &&i : Repeater(N, 0)) {
        R[i] = gcd(R[i+1], A[i]);
    } // end i

    ll ans = 1;
    for (auto &&k : Repeater(0, N)) {
        ans = max(ans, gcd(L[k], R[k+1]));
    } // end k
    cout << ans << endl;




}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    cerr << "DEBUG MODE" << endl;
    string test_cases = "test_C.txt";
    auto fs = fstream(test_cases, fstream::in);
    int lp = 0;
    while(fs) {
        lp++;
        cout << lp <<  "#------\n";
        sub_main(fs);
    }
    cout << "------#" << endl;
    if(lp <= 1) sub_main(cin);
#else
    sub_main(cin);
#endif
    return 0;
}


Measured memory_bytes: 2560
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define mp make_pair

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

inline void scani(int& x){
	scanf("%d",&x);
}

//end of macro

const ll MOD = 1e9 + 7;
inline ll addmod(ll a, ll b){
    if(a+b<MOD)return a+b;
    return a+b-MOD;
}
inline ll submod(ll a, ll b){
    return addmod(a, MOD-b);
}
inline ll mulmod(ll a, ll b){
    return (a*b)%MOD;
}
inline ll expmod(ll a, ll e){
    ll ret = 1;
    while(e){
        if(e&1)ret = mulmod(ret, a);
        a = mulmod(a, a);
        e >>= 1;
    }
    return ret;
}
inline ll divmod(ll a, ll b){
    return mulmod(a, expmod(b, MOD-2));
}

const int N = 2e5 + 5;
int fac[N];
int C(int a, int b){
    return divmod(fac[a], mulmod(fac[b], fac[a-b]));
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);
    
    fac[0] = fac[1] = 1;
    REP(i,2,N-5)fac[i] = mulmod(fac[i-1], i);
    
    int h,w,a,b;
    cin>>h>>w>>a>>b;
    
    int sx = h-a, sy = b+1;
    int ans = 0;
    while(sx >= 1 && sy <= w){
        ans = addmod(ans, mulmod(C(sx-1+sy-1, sx-1), C(h-sx+w-sy, h-sx)));
        sx--;
        sy++;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
  
class Dice{
private:
    int d[6];
public:
    Dice(int n0, int n1, int n2, int n3, int n4, int n5){ //Constructor
        d[0]=n0; d[1]=n1; d[2]=n2; d[3]=n3; d[4]=n4; d[5]=n5;
    }
    int get_top(){
        return d[0];
    }
    int get_front(){
        return d[1];
    }
    int get_right(){
        return d[2];
    }
    int get_left(){
        return d[3];
    }
    int get_back(){
        return d[4];
    }
    int get_bottom(){
        return d[5];
    }
    void Roll(string op){
        for(unsigned int i=0;i<op.length();i++){
            switch(op[i]){
                case 'N': RollN(); break;
                case 'E': RollE(); break;
                case 'W': RollW(); break;
                case 'S': RollS(); break;
            }
        }
    }
    void RollN(){
        int tmp=d[0];
        d[0]=d[1];
        d[1]=d[5];
        d[5]=d[4];
        d[4]=tmp;
    }
    void RollE(){
        int tmp=d[0];
        d[0]=d[3];
        d[3]=d[5];
        d[5]=d[2];
        d[2]=tmp;
    }
    void RollW(){
        int tmp=d[0];
        d[0]=d[2];
        d[2]=d[5];
        d[5]=d[3];
        d[3]=tmp;
    }
    void RollS(){
        int tmp=d[0];
        d[0]=d[4];
        d[4]=d[5];
        d[5]=d[1];
        d[1]=tmp;
    }
    bool operator==(const Dice& t)const{
    	return(d[0]==t.d[0] && d[1]==t.d[1] && d[2]==t.d[2] && 
    	d[3]==t.d[3] && d[4]==t.d[4] && d[5]==t.d[5]);
    }
    bool operator!=(const Dice& t)const{
    	return !(*this==t);
    }
};
  
int main(){
    int a, b, c, d, e, f, q;
    cin >> a >> b >> c >> d >> e >> f;
    Dice di(a, b, c, d, e, f);
    cin >> a >> b >> c >> d >> e >> f;
    Dice di2(a, b, c, d, e, f);
    for(int j=0;j<4;j++){
        bool flg = false;
        di.RollE();
        for(int k=0;k<4;k++){
            di.RollN();
            for(int l=0;l<4;l++){
                di.RollE();
                if(di.get_top()==di2.get_top() && di.get_front()==di2.get_front()){
                    flg=true; break;
                }
            }
            if(flg) break;
        }
        if(flg) break;
    }
    if(di==di2) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int get(int rsp[3],char t){
  switch (t) {
    case 'r':return rsp[2];
    case 's':return rsp[0];
    case 'p':return rsp[1];
  }
  std::cout <<"t:"<<t << '\n';
  exit(0);
  return 'a';
}

int main(){
  int n,k,r,s,p;
  int rsp[3];
  char temp;
  std::cin >> n>>k>>rsp[0]>>rsp[1]>>rsp[2];

  std::vector<char> t;
  for (int i = 0; i < n; i++) {
    std::cin >> temp;
    t.push_back(temp);
  }

  long long score=0;
  for (int i = 0; i < n; i++) {
    if(i-k<0){score+=get(rsp,t[i]);}
    else{
      if(t[i-k]=='q')score+=get(rsp,t[i]);
      else if(t[i]==t[i-k])t[i]='q';
      else score+=get(rsp,t[i]);
    }

  }

  std::cout << score << '\n';


  return 0;
}


Measured memory_bytes: 512
n,z,w = map(int, input().split())

al = list(map(int, input().split())) 

if n ==1:
    print(abs(al[0]-w))
    exit()

al1 = al[-2]
al2 = al[-1]

d1 = abs(al1-al2)
d2 = abs(al2-w)

print(max(d1,d2))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define N 2333
#define a(x) A[((x)%n+n)%n]
#define b(x) B[((x)%n+n)%n]
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
char A[N],B[N]; int go[N],pre[N],nxt[N];
int main()
{	scanf("%s%s",A,B); int n=strlen(A),ans=INT_MAX;
	for(rint i=0;i<n;i++)
	{	for(pre[i]=0;pre[i]<n&&b(i-pre[i])!='1';pre[i]++);
		for(nxt[i]=0;nxt[i]<n&&b(i+nxt[i])!='1';nxt[i]++);
		if(a(i)=='1'&&(pre[i]==n||nxt[i]==n)) return !printf("-1");
	}
	for(rint l=0;l<n;l++)
	{	int num=0,len=l; memset(go,0,sizeof(go));
		for(rint i=0;i<n;i++) if(a(i)!=b(i-l)) num++,go[nxt[i]]=max(go[nxt[i]],pre[i]);
		for(rint i=n-1;i>=0;i--) ans=min(ans,num+2*(len+i)-l),len=max(len,go[i]);
	}
	for(rint l=0;l<n;l++)
	{	int num=0,len=l; memset(go,0,sizeof(go));
		for(rint i=0;i<n;i++) if(a(i)!=b(i+l)) num++,go[pre[i]]=max(go[pre[i]],nxt[i]);
		for(rint i=n-1;i>=0;i--) ans=min(ans,num+2*(len+i)-l),len=max(len,go[i]);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using  namespace  std;
using ll=long long;
int main(){
  bool kazu=false;
  int n;
  cin>>n;
  char a;
  for (int i=0;i<n;i++){
    cin>>a;
    if(a=='Y') kazu=true;
}
  if(kazu) cout<<"Four"<<endl;
  else cout<<"Three"<<endl;
}

Measured memory_bytes: 256
/*
 * @Author       : nonameless
 * @Date         : 2020-09-13 19:55:56
 * @LastEditors  : nonameless
 * @LastEditTime : 2020-09-13 20:00:55
 */
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define sz(x) (int)x.size()
#define toStr(name) (#name)
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
const double eps = 1e-6;
const double PI  = acos(-1.0);
const int INF = 0x3f3f3f3f;
const ll LNF  = 0x3f3f3f3f3f3f3f3f;
inline int gcd(int a, int b) { return b ? gcd(b,a % b):a;}
inline ll  gcd(ll  a, ll  b) { return b ? gcd(b,a % b):a;}
inline int lcm(int a, int b) { return a * b / gcd(a, b); }

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

template<class T>
inline void out(string a, T x){ cout << a << " = " << x << endl; }


int main(){

    int x; read(x);
    if(x == 0) puts("1");
    if(x == 1) puts("0");

    
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;

const ll MOD = 1e9+7;
const ll MAX_N = 1e5+10;

int main(int argc, char const *argv[])
{
    ll n, m, a[MAX_N];
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        scanf("%lld", &a[i]);
    }
    ll dp[MAX_N] = {0};
    ll iter = 0;

    for (int i = 1; i <= n; ++i) {
        if (i==a[iter]) {
            iter++;
            continue;
        }
        if (i==1) {
            dp[i] = 1;
        }
        else if (i==2) {
            dp[i] = dp[i-1] + 1;
        }
        else {
            dp[i] = dp[i-1] + dp[i-2];
            dp[i] %= MOD;
        }
    }

    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 1792
//AtCoder ABC095 A - Something on It
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    string s;
    cin>>s;
    ll ans=700;
    for(const auto& t:s){
        if(t=='o'){
            ans+=100;
        }
    }  
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD


bool cmp(const pll& i, const pll& j) {
    return i.second > j.second;
}
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n,m;
    cin>>n>>m;
    vl a(n);
    REP(i,n)cin>>a[i];

    sort(ALL(a));

    vector<pll> bc(m);
    REP(i,m){
        ll b, c;
        cin>>b>>c;
        bc[i] = pll(b,c);
    }

    sort(ALL(bc),cmp);

    int pos = 0;
    REP(i,bc.size()){
        FOR(j,pos,n){
            pos = j;
            if(bc[i].first==0) break;
            if(a[j] > bc[i].second) break;

            a[j] = bc[i].second;
            bc[i].first--;
        }
    }

    ll ans = 0;
    REP(i,n) ans += a[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
import Data.List
import Data.Maybe

main = print =<< sol <$> readLn

sol x = fromJust $ find (>=x) primes 

primes :: Integral a => [a]
primes = 2 : filter ((==1) . length . primeFactors) [3,5..]

primeFactors :: Integral a => a -> [a]
primeFactors 1 = []
primeFactors n = factor n primes

factor :: Integral a => a -> [a] -> [a]
factor n (p:ps) 
  | p*p > n        = [n]
  | n `mod` p == 0 = p : factor (n `div` p) (p:ps)
  | otherwise      = factor n ps 


Measured memory_bytes: 1404
#include<stdio.h>
#include<limits.h>
int main(void)
{
    long long n,t,q,a[100000],d[100000],x[1000],b,c,i,j;
    scanf("%lld %lld %lld", &n, &t, &q);
    for(i=1; i<=n; i++)
    scanf("%lld %lld", &a[i], &d[i]);
    for(i=0; i<q; i++)
    scanf("%lld", &x[i]);
    for(i=0; i<q; i++)
    {
        if(d[x[i]]==1)
        {
            b=a[x[i]];
            c=LONG_MIN;
            for(j=x[i]+1; j<=n; j++)
            {
                if(d[j]==2)
                {
                    c=(a[j]+b)/2;
                    if(c>a[x[i]]+t)
                    c=LONG_MIN;
                    break;
                }
                b=a[j];
            }
            if(c==LONG_MIN)
            printf("%lld\n", a[x[i]]+t);
            else
            printf("%lld\n", c);
        }
        else
        {
            b=a[x[i]];
            c=LONG_MAX;
            for(j=x[i]-1; j>=1; j--)
            {
                if(d[j]==1)
                {
                    c=(a[j]+b)/2;
                    if(c<a[x[i]]-t)
                    c=LONG_MAX;
                    break;
                }
                b=a[j];
            }
            if(c==LONG_MAX)
            printf("%lld\n", a[x[i]]-t);
            else
            printf("%lld\n", c);
        }
    }
    
    return 0;
}


Measured memory_bytes: 3304
<?php

fscanf(STDIN, "%d %d", $n, $q);

$G = array_fill(1, $n, []);
for ($i = 0; $i < $n - 1; ++$i) {
    fscanf(STDIN, "%d %d", $a, $b);
    --$a;
    --$b;
    $G[$a][] = $b;
    $G[$b][] = $a;
}

$ans = array_fill(0, $n, 0);
for ($i = 0; $i < $q; ++$i) {
    fscanf(STDIN, "%d %d", $a, $b);
    --$a;
    $ans[$a] += $b;
}

function dfs($v, $p = -1) {
    global $G;
    global $ans;
    foreach ($G[$v] as $next_v) {
        if ($next_v == $p) continue;

        $ans[$next_v] += $ans[$v];

        dfs($next_v, $v);
    }
}

dfs(0);

echo implode(' ', $ans);


Measured memory_bytes: 154104
#include <bits/stdc++.h>
using namespace std;
#define data_type long long

int main()
{
    string str;
    char ch='a';
    cin>>str;
    for(auto i:str)
        {
            if((i=='A' && ch=='B' )||(i=='B' && ch=='A'))
                {
                    cout<<"Yes"<<endl;
                    return 0;
                }
ch=i;

        }

    cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
  #define FASTIO std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

  int a[10000];

  int main () {
    int n, m, count = 0,d, total = 0;
    cin >> n >> m;

    for (int i = 0; i < n; i++) {
      cin >> a[i];
      total += a[i];
    }
    d = ceil(total /(4.0 * m));
    for (int i = 0; i < n; i++) {
      if (a[i] >= d) {
        count++;
      }
    }
    if (count >= m) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }


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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;


int main(){
  int a,p; cin >> a >> p;

  cout << (a*3+p)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1 << 30;
const ll MOD = 1000000007;
int nums[4];
bool check(int bit) {
  int result = nums[0];
  for (int i = 0; i < 3; i++) {
    if ((bit & (1 << i)) == 0) {
      result += nums[i + 1];
    } else {
      result -= nums[i + 1];
    }
  }

  if (result != 7) return false;

  cout << nums[0];
  for (int i = 0; i < 3; i++) {
    if ((bit & (1 << i)) == 0) {
      cout << '+';
    } else {
      cout << '-';
    }
    cout << nums[i + 1];
  }
  cout << "=7" << endl;
  return true;
}
int main(void) {
  string tmp;
  cin >> tmp;
  for (int i = 0; i < 4; i++) {
    nums[i] = tmp[i] - '0';
  }
  for (int bit = 0; bit < (1 << 3); bit++) {
    if (check(bit)) return 0;
  }
  return 0;
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int n;
    cin >> n;
    vector<string> s(n);
    map<string, int> m;
    bool flg = true;
    for(int i = 0; i < n; i++){
        cin >> s[i];
        m[s[i]]++;
        if(m[s[i]] > 1){
            flg = false;
        }
    }
    for(int i = 1; i < n; i++){
        int l = s[i-1].size();
        if(s[i-1][l-1] != s[i][0]){
            flg = false;
        }
    }
    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
l = [0,0]
c = 0
i = 0
while(i < len(a)-1):
    if(a[i] == a[i+1]):
        del l[0]
        l.append(a[i])
        i += 1
        c += 1
    if(c >= 2 or i == len(a)-2):
        i = len(a)-1
        print(l[0] * l[1])
    i += 1

Measured memory_bytes: 14224
def solve(n, m, l, r):
    return max(0, min(r) - max(l) + 1)

n, m = map(int, input().split())
l = [0] * m
r = [0] * m
for i in range(m):
    l[i], r[i] = map(int, input().split())
print(solve(n, m, l, r))

Measured memory_bytes: 10868
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;

ll n,m;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
	ll res=n*(n-1)/2;
	res+=m*(m-1)/2;
	cout<<res;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
hoge=list(map(int,input().split()))
ans=0
for a in range(n):
  for b in range(n-a):
    b+=a
    for c in range(n-b):
      c+=+b
      if(a!=b and b!=c and c!=a):
        if(abs(hoge[a]-hoge[b])<hoge[c] and hoge[c]<hoge[a]+hoge[b] 
           and hoge[a]!=hoge[b] and hoge[b]!=hoge[c] and hoge[c]!=hoge[a]):
          ans+=1
          
print(ans)

Measured memory_bytes: 9212
#include <bits/stdc++.h>
 
using namespace std;
 
int main () {
  string S;
  int N,K;
  cin>>N>>K;
  cin>>S;
  vector<int> seq;
  if(S[0]=='0')seq.push_back(0);
  S.push_back('$');
  int l=0;
  for(int r=1;r<N+1;r++) {
    if(S[r]!=S[l]) {
      seq.push_back(r-l);
      l=r;
    }
  }
  N = seq.size();
//   for(int i=0;i<seq.size();i++)cout<<seq[i]<<" ";
   //cout<<endl;

  int win = 0,r=0;
  for(r=0;r<min(K*2,N);r+=2) {
    win+=seq[r];
    if(r+1<N)win+=seq[r+1];
  }
  if(r<N)win+=seq[r];
  //cout<<"WIN "<<win<<endl;
  int ans = win;
  for(;r<N;r+=2) {
   	win-=(seq[r-K*2]+seq[r-K*2+1]);
    if(r+1<N)win+=seq[r+1];
    if(r+2<N)win+=seq[r+2];
    ans=max(ans,win);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1020
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
char S[8];
int ans,len;

int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x*f;
}

void query(ll x)
{
    printf("? %lld\n",x);
    fflush(stdout);
    scanf("%s",S);
}

int main()
{
    int x=1000000000;
    query(x);
    if (S[0]=='Y')
	{
	    for (int i=8;~i;i--)
		{
		    query(x-1);
		    if (S[0]=='N') break;
		    x/=10;
		}
	    printf("! %d\n",x);
	    return 0;
	}
    for (int i=8;~i;i--)
    	{
	    x/=10;
	    query(x);
	    if (S[0]=='Y')
		{
		    len=i+1;
		    break;
		}
	}
    int l=x+1,r=x*10-1;
    while(l<=r)
	{
	    ll mid=(l+r)>>1;
	    query(mid*10);
	    if (S[0]=='Y') ans=mid,r=mid-1;
	    else l=mid+1;
	}
    printf("! %d\n",ans);
    return 0;
}
	    


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

int main() {
  int64_t X;
  cin >> X;
  bool flag = false;
  for (int64_t i = 0; i < 124; i++){
    for (int64_t j = -100; j < 125; j++){
      if (pow(i, 5) - pow(j, 5) == X){
        cout << i << " " << j << endl;
        flag = true;
        break;
      }
    }
    if (flag){
      break;
    }
  }
}


Measured memory_bytes: 4096
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

int main(){
    ll N,M;
    cin >> N >> M;
    ll ans = 0;
    if(N>M){
        ans = M/2;
    }
    else{
        if(M>N*2){
            ans += N;
            M = M -  N*2;
            ans += M/4;
        }
        else{
            ans = M/2;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ll long long
#define pb push_back
#define pf push_front
deque<char> deq;

int main(void){
    string S;
    char C;
    ll Q;
    ll T,F;
    bool on=false;
    cin >> S >> Q;
    for(auto tmp:S){
        deq.pb(tmp);
    }
    REP(i,Q){
        cin >> T;
        if(T==1) on^=true;
        else{
            cin >> F >> C;
            if(on ^ (F==1)) deq.pf(C);
            else deq.pb(C);
        }
    }
    string ans;
    for(auto tmp:deq) ans.pb(tmp); 
    if(on) reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1412
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

int main(void) {
  int N,K,X,Y;
  scanf("%d %d %d %d",&N,&K,&X,&Y);

  int ans;

  if (N <= K){
    ans = N * X;
  }else{
    ans = K * X + (N-K)*Y;
  }

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


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

const int64_t MOD = 1e9 + 7;

struct mint
{
    int64_t x;
    mint(int64_t x = 0) : x((x % MOD + MOD) % MOD) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= MOD)
            x -= MOD;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += MOD - a.x) >= MOD)
            x -= MOD;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(int64_t n) const
    {
        if (n == 0)
            return 1;
        mint t = pow(n >> 1);
        t *= t;
        if (n & 1)
            t *= *this;
        return t;
    }
    mint inv() const { return pow(MOD - 2); }
    mint &operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i);
    }

    vector<mint> cnt_all(N, 0);
    vector<mint> cnt_after(N, 0);
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < i; j++)
        {
            if (A.at(i) > A.at(j))
            {
                cnt_all.at(i) += 1;
            }
        }
        for (int j = i + 1; j < N; j++)
        {
            if (A.at(i) > A.at(j))
            {
                cnt_all.at(i) += 1;
                cnt_after.at(i) += 1;
            }
        }
    }

    mint res = 0;
    for (int i = 0; i < N; i++)
    {
        res += cnt_after.at(i) * K;
        res += cnt_all.at(i) * K * (K - 1) / 2;
    }
    cout << res.x << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		final int a_num = scanner.nextInt();
		final int b_num = scanner.nextInt();
		final int m = scanner.nextInt();
		int[] a = new int[a_num];
		int[] b = new int[b_num];

		int a_min = 100000;
		int b_min = 100000;
		for (int i = 0; i < a_num; i++) {
			a[i] = scanner.nextInt();
			if (a[i] < a_min)
				a_min = a[i];
		}
		for (int i = 0; i < b_num; i++) {
			b[i] = scanner.nextInt();
			if (b[i] < b_min)
				b_min = b[i];
		}

		int result = a_min + b_min;

		for (int i = 0, x, y, c, value; i < m; i++) {
			x = scanner.nextInt()-1;
			y = scanner.nextInt()-1;
			c = scanner.nextInt();
			value = a[x] + b[y] - c;
			if (value < result)
				result = value;
		}
		System.out.println(result);
	}

}


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

int P[10010];
int Rank[10010];

void init(int N){
	for(int i = 0; i < N; ++i){
		P[i] = i;
		Rank[i] = 0;
	}
}

int root(int a){
	if(P[a] == a) return a;
	return (P[a] = root(P[a]));
}

bool IsSameSet(int a, int b){
	return root(a) == root(b);
}

void unite(int a, int b){
	P[root(a)] = root(b);
}

void link(int a, int b){
	if(Rank[a] > Rank[b]){
		P[b] = a;
	} else {
		P[a] = b;
		if(Rank[a] == Rank[b]) Rank[a]++;
	}
}

int main() {
	int n, q;
	int com, x, y;
	cin >> n >> q;
	init(n);
	for(int i = 0; i < q; i++){
		cin >> com >> x >> y;
		if(com == 0) unite(x,y);
		else cout << IsSameSet(x,y) << endl;
	} 
	return 0;
}

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

namespace ConsoleApplication78
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            char[] a = new char[19];
            for (int b = 0; b < 19; b++)
                a[b] = str[b];
            string ans ="";
            for (int b = 0; b < 5; b++)
                ans += a[b];
            ans += " ";
            for (int b = 6; b < 13; b++)
                ans += a[b];
            ans += " ";
            for (int b = 14; b < 19; b++)
                ans += a[b];
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140