akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
typedef long long ll;

using namespace std;

string s;
int ans=0;

int main(){
    cin>>s;
    int temp=0;
    for(int i=0;i<s.length();i++){
        if(i==0){
            if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C'){
                temp++;
            }
        }else{
            if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C'){
                if(s[i-1]=='A'||s[i-1]=='T'||s[i-1]=='G'||s[i-1]=='C'){
                    temp++;
                }else{
                    temp=1;
                }
            }else{
                if(ans<temp){
                    ans=temp;
                }
            }
        }
    }
    if(ans<temp){
        ans=temp;
    }
    cout<<ans;
}


Measured memory_bytes: 256
from collections import deque
x,y,a,b,c=map(int, input().split())
pi=list(map(int,input().split()))
qi=list(map(int,input().split()))
ri=list(map(int,input().split()))
pi.sort(reverse=True)
qi.sort(reverse=True)

apple=pi[:x]+qi[:y]+ri
apple.sort(reverse=True)

print(sum(apple[:x+y]))

Measured memory_bytes: 111852
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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(a>b){a=b;return 1;}return 0;}

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

  int n, l;
  cin >> n >> l;
  bool hasZero = false;
  vector<int> v(n);
  ll sum = 0LL;
  REP(i, n) {
    v[i] = l + i;
    sum += v[i];
    if(v[i] == 0) hasZero = true;
  }
  if(hasZero) {
    cout << sum << endl;
  }
  else {
    //positive
    if(v[0] > 0) {
      cout << sum-v[0] << endl;
    } 
    else {
      cout << sum-v[v.size()-1] << endl;
    }   
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define FALSE 0
#define TRUE 100000
int yoko[8],tate[8],A[8][8];
int x[15],y[15];
void print(){
  int i,j,k,l;
  for(i=0;i < 8;i++){
    for(j=0; j <8;j++){
      if(A[i][j] !=0){
        if(yoko[i] != j){
          return;
        }
      }
    }
  }

  for(i=0;i < 8;i++){
    for(j=0; j <8;j++){
      if(yoko[i]==j){
        printf("Q");
      }
      else{
        printf(".");
      }
      
    }
    printf("\n");
  }
}

void haiti(int a){
  int i,j,k,l;
  if(a==8){
    print();
    return;
  }

  for(i=0;i <8;i++){

    if(tate[i]==1 || x[a+i]==1 || y[a-i+8-1]==1){
      continue;
    }
    yoko[a]=i;
    tate[i]=1;
    x[a+i]=1;
    y[a-i+8-1]=1;

    haiti(a+1);
    tate[i]=-1;
    x[a+i]=-1;
    y[a-i+8-1]=-1;
  }

}

int main(){
  int i,j,k,l,a,b;
  for(i=0; i < 15 ;i++){
    x[i]=-1;
    y[i]=-1;
  }
  for(i=0; i < 8 ;i++){
    tate[i]=-1;
    yoko[i]=-1;
  }

  for(i=0;i < 8;i++){
    for(j=0; j <8;j++){
      A[i][j]=FALSE;
    }
  }

  scanf("%d",&l);

  for(i=0; i < l;i++){
    scanf("%d %d",&a,&b);
    A[a][b]=TRUE;
  }

  haiti(0);

  return 0;
}




Measured memory_bytes: 2108
#include <string>
#include <vector>
#include <iostream>
#include <queue>

struct PointAndCost {
  int x, y, cost;
};

int H, W;
std::vector<std::vector<bool>> is_black_map;
std::queue<PointAndCost> blacks;

void fillIfNotFilled(int x, int y, int cost) {
  if(x < 0 || x >= W || y < 0 || y >= H) return;
  if(is_black_map[y][x]) return;
  is_black_map[y][x] = true;
  blacks.push({x, y, cost});
}

int main(int argc, char *argv[]) {
  std::cin >> H >> W;
  is_black_map.clear();
  for(int y = 0; y < H; y++){
    std::vector<bool> row;
    row.resize(W, false);
    is_black_map.push_back(row);
  }
  for(int y = 0; y < H; y++){
    std::string s;
    std::cin >> s;
    for(int x = 0; x < W; x++){
      if(s[x] != '#') continue;
      blacks.push({x, y, 0});
      is_black_map[y][x] = true;
    }
  }
  int max = 0;
  while(blacks.size()) {
    auto &e = blacks.front();
    if(max < e.cost) max = e.cost;
    fillIfNotFilled(e.x + 1, e.y + 0, e.cost + 1);
    fillIfNotFilled(e.x - 1, e.y + 0, e.cost + 1);
    fillIfNotFilled(e.x + 0, e.y + 1, e.cost + 1);
    fillIfNotFilled(e.x + 0, e.y - 1, e.cost + 1);
    blacks.pop();
  }
  std::cout << max << std::endl;
  return 0;
}


Measured memory_bytes: 12560
package main

import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}

func main() {
    a := nextInt()
    b := nextInt()
    h := nextInt()

    fmt.Println((a+b)*h/2)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Int int32_t
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair< int , int >
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(auto x : c )cout << x << " ";
#define ol(c , s , e ) for(int pos=s; pos<e ; pos++) cout << c[pos] << " ";
#define PI acos(-1l)
const int M = 1000000007;
const int N=3e5+5;
const long long INF = 1e18+5;

//#define rohit
#ifdef rohit
template<typename... T >
void bug(T... __VA_ARGS__) {
    ((cerr << __VA_ARGS__ << " ") , ...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", bug(__VA_ARGS__) , cerr << endl;
#endif


void solve(){
    string s;
    cin >> s;
//    char last = '#';
//    for(auto &x : s ){
//        if(last == 'P'){
//            x = 'D';
//        }
//        last = x;
//    }
    for(int i=0; i<s.length() ; i++){
        if(i == s.length()-1){
            if(s[i] == '?'){
                s[i] = 'D';
            }
            break;
        }
        if(s[i]=='?' ){
            if(i>0 && s[i-1] == 'P'){
                s[i] = 'D';
            }
            else if(s[i+1]=='D')
            {
                s[i] = 'P';
            }
            else if(s[i+1]=='?'){
                s[i] = 'P';
                s[i+1] = 'D';
            }
            else{
                s[i] = 'D';
            }
        }
    }
    cout <<s << endl;

}

signed main(){
    FAST;
    //TODO:  check test cases.
    int tc=1;
//    cin >> tc;
    for(int t = 1 ; t <= tc ; t++){
        solve();
    }
}

/*Extra Cares
 * 1)In graphs or dp problems sometimes long long creates MLE.
 * 2)Check whether int to long long typecasting is commented or not?
 * 3)Check overflows.
*/

Measured memory_bytes: 3784
#include<stdio.h>
int binarySearch();
int n,S[100000],key,mid;

int main(){
  int i,q,T[100000],C=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  for(i=0;i<q;i++){
    key=T[i];
    if(binarySearch()==-1){
      continue;
    }
    else{
      C++;
    }
  }

  printf("%d\n",C);
}

  int binarySearch(){
    int left=0;
    int right=n;
    while(left<right){
      mid=(left+right)/2;
      if(S[mid]==key){
	return mid;
      }
      else if(key<S[mid]){
	right=mid;
      }
      else
	left=mid+1; 
    }
    return -1;
  }



Measured memory_bytes: 2272
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
	cin>>s;
	string s1,s2;
	cin>>s1;
	if(s1.size()-s.size()==1)
	{
		for (int i = 0; i < s.size(); ++i)
		{
			s2.push_back(s1[i]);
		}
		if(s==s2)
			cout<<"Yes";
		else
		cout<<"No";
	}
	else
		cout<<"No";
}

Measured memory_bytes: 3644
n = int(input())
p = [int(v) for v in input().split()]
q = [int(v) for v in input().split()]

def index_of(array, v):
    for i in range(len(array)):
        if v == array[i]:
            return i
    return -1

def perm(v):
    p = 1
    for i in range(2, v+1):
        p *= i
    return p

memo = [1] * (n+1)
for i in range(1, n+1):
    memo[i] = perm(i)
    #print("P!: ", i, memo[i])

def to_n(array):

    m = 0
    sa = sorted(array)
    while len(array) > 0:
        v = array.pop(0)
        index = index_of(sa, v)
        k = len(array)
        #print("v: ",v, ", index: ", index, ", memo: ", memo[k], index * memo[k])
        m += index * memo[k]

        if k == 0:
            break
        sa = sorted(array)

    return m

a = to_n(p)
#print("a", a)

b = to_n(q)
#print("b", b)
print(abs(a - b))

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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    ll a, b, c; cin >> a >> b >> c;
    ll ans = 0;
    ans += min(a, c);
    c -= min(a, c);
    ll t = min(b, c);
    ans += 2*t;
    b -= t;
    ans += b;
    c -= t;
    if(c) ans++;

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
int N, a[100001], X;
long long S;
int main()
{
	scanf("%d%d", &N, &X);
	for (int i = 1; i <= N; i++)
		scanf("%d", a + i);
	for (int i = 1; i <= N; i++)
	{
		int d = std::max(a[i - 1] + a[i] - X, 0);
		S += d;
		a[i] -= d;
	}
	printf("%lld\n", S);
	return 0;
}


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

using namespace std;

int main() {

    char s[101], t[101];
    scanf("%s", s);
    scanf("%s", t);

    sort(s, s + strlen(s));
    sort(t, t + strlen(t));

    int sl = strlen(s);
    int tl = strlen(t);
    int l = min(sl, tl);
    bool f = false;
    for (int i = 0; i < l; ++i) {
        // printf("s = %c\n", s[i]);
        // printf("t = %c\n", t[tl - 1 - i]);
        if (s[i] > t[tl - 1 - i]) {
            f = false;
            break;
        } else if (s[i] < t[tl - 1 - i]) {
            f = true;
            break;
        } else {
            if (i + 1 == l) {
                if (sl < tl)
                    f = true;
                else
                    f = false;
            }
        }
    }

    if (f) printf("Yes\n");
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

int a, b, c;
int dp[105][105][105];
int ans = 1e9;

int calc(int aa, int bb, int cc) {
  if (aa < 0 || bb < 0 || cc < 0 || aa < a || bb < b || cc < c) {
    return 1e9;
  }
  int& res = dp[aa][bb][cc];
  if (res != -1) {
    return res;
  }
  res = 1e9;
  res = min(res, 1 + calc(aa, bb, cc - 2));
  res = min(res, 1 + calc(aa - 2, bb, cc));
  res = min(res, 1 + calc(aa, bb - 2, cc));
  res = min(res, 1 + calc(aa - 1, bb - 1, cc));
  res = min(res, 1 + calc(aa - 1, bb, cc - 1));
  res = min(res, 1 + calc(aa, bb - 1, cc - 1));
  return res;
}

int main() {

  cin >> a >> b >> c;

  memset(dp, -1, sizeof(dp));
  dp[a][b][c] = 0;

  for (int i = 0; i <= 100; i++) {
    ans = min(ans, calc(i, i, i));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;


int main() {
  int n;
  cin >> n;
  int h[n];
  rep(i,n) cin >> h[i];
  int dp[n];
  dp[0] = 0; dp[1] = abs(h[1] - h[0]);
  for(int i = 2; i < n; i++){
    dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
  }
  cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
import java.util.*;
import java.util.stream.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = in.nextInt();
		}
		int[] copy = Arrays.copyOf(arr, arr.length);
		Arrays.sort(copy);

		int left = 0, right = n;
		long x = (long)n * (long)(n + 1) / 4;
		while(left + 1 < right) {
			int mid = (left + right) / 2;
			int am = copy[mid];
			int[] s = new int[n + 1];
			for (int i = 0; i < n; i++) {
				s[i + 1] = am <= arr[i] ? 1 : -1;
			}
			for (int i = 1; i < n + 1; i++) {
				s[i] += s[i - 1];
			}
			BIT bit = new BIT(2 * n + 1);
			long sum = 0;
			for (int i = 0; i < n + 1; i++) {
				sum += bit.sum(s[i] + n);
				bit.add(s[i] + n, 1);
			}
			if(x <= sum) {
				left = mid;
			} else {
				right = mid;
			}
		}
		System.out.println(copy[left]);
	}
}

class BIT {
	private long[] bit;
 
    public BIT(int size){
        bit = new long[size];
    }
 
    public long sum(int i){
        long s = 0;
        while(0 < i){
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }
 
    public void add(int i, long x){
        while(i < bit.length){
            bit[i] += x;
            i += i & -i;
        }
    }
}



Measured memory_bytes: 64140
from collections import Counter

n, p = map(int, input().split())
s = input()

ans = 0

if p in {2, 5}:
    lst = set(i for i in range(0, 10, p))
    for i, num in enumerate(s):
        if int(num) in lst:
            ans += i + 1
else:
    num = [int(s[-1]) % p]
    for i in range(1, len(s)):
        tmp = num[-1] + pow(10, i, p) * int(s[-i - 1])
        num.append(tmp % p)
    mod = [1] + [0] * (p - 1)
    for i in num:
        ans += mod[i]
        mod[i] += 1
print(ans)


Measured memory_bytes: 87368
from collections import deque

N,M=map(int,input().split())
p=list(map(int,input().split()))

out=[set() for i in range(N+1)]

for k in range(M):
    x,y=map(int,input().split())
    out[x].add(y)
    out[y].add(x)

rch=[False for i in range(N+1)]
ans=0
q=deque()
for i in range(1,N+1):
    if not rch[i]:
        si=set()            
        q.append(i)
        rch[i]=True
        si.add(i)
        while q:
            u=q.popleft()
            for v in out[u]:
                if not rch[v]:
                    q.append(v)
                    rch[v]=True
                    si.add(v)
        sv={p[i-1] for i in si}
        ans+=len(si&sv)
              
print(ans)

Measured memory_bytes: 100588
#include <iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<array>
#include<functional>
#include<iomanip>
#include<ios>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)

typedef int value_type; /* ソートするキーの型 */

value_type med3(value_type x, value_type y, value_type z)
/* x, y, z の中間値を返す */
{
    if (x < y)
        if (y < z) return y; else if (z < x) return x; else return z; else
        if (z < y) return y; else if (x < z) return x; else return z;
}

void quicksort(value_type a[], int left, int right,value_type index[])
/* クイックソート
 * a     : ソートする配列 
 * left  : ソートするデータの開始位置
 * right : ソートするデータの終了位置
 * index: index配列
 */
{
    if (left < right) {
        int i = left, j = right;
        value_type tmp, pivot = med3(a[i], a[i + (j - i) / 2], a[j]); /* (i+j)/2ではオーバーフローしてしまう */
        while (1) { /* a[] を pivot 以上と以下の集まりに分割する */
            while (a[i] < pivot) i++; /* a[i] >= pivot となる位置を検索 */
            while (pivot < a[j]) j--; /* a[j] <= pivot となる位置を検索 */
            if (i >= j) break;
            tmp = a[i]; a[i] = a[j]; a[j] = tmp; /* a[i],a[j] を交換 */
            tmp = index[i]; index[i] = index[j]; index[j] = tmp;
            i++; j--;
        }
        quicksort(a, left, i - 1,index);  /* 分割した左を再帰的にソート */
        quicksort(a, j + 1, right,index); /* 分割した右を再帰的にソート */
    }
}


int dfs(int n,int N){
    if (n>N){
        return 0;
    }
    

    int ret;
    
    return ret;
}
int main(){
    string S;
    cin >>S;
    

    int ans;
    int c0=0;
    int c1=0;
    FOR(i,S.size()){
        if(i%2==0){
            if(S[i]=='0'){
                c1++;
            }else{
                c0++;
            }
        }else{
            if(S[i]!='0'){
                c1++;
            }else{
                c0++;
            } 
        }
    }
    ans=min(c0,c1);
    std::cout << ans<< endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define l first
#define r second

using namespace std;

const int maxn = 3e5 + 1;

int a[maxn];

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    for (int i = 0; i < 3 * n; i++)
        cin >> a[i];
    sort(a, a + 3 * n);
    int ans = 0;
    for (int i = n; i < 3 * n; i += 2)
        ans += a[i];
    cout << ans;
    return 0;
}


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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    bool ok = true;
    //sが回文
    string s2 = s;
    reverse(all(s));
    if(s2!=s) ok = false;
    string s3;
    s3 = s2.substr(0,(n-1)/2);
    reverse(all(s3));
    if(s3!=s2.substr(0,(n-1)/2)) ok = false;
    string s4;
    s4 = s2.substr((n+3)/2 -1, n-1);
    reverse(all(s4));
    if(s4!=s2.substr((n+3)/2 -1, n-1)) ok = false;
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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 ld = long double;
long double const pi = std::acos(-1.0L);
typedef pair<int,int> P;
const int INF = 1001001001;


int main() {
  string s;
  cin >> s;
  int cnt = 0;
  rep(i,s.size()-1){
    if(s[i]==s[i+1]){
      cnt++;
      if(s[i+1] == '0') s[i+1] = '1';
      else s[i+1] = '0';
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3728
# https://atcoder.jp/contests/abc084/tasks/abc084_c
# C - Special Trains
import math

N = int(input().split()[0])
csf_list = []

for _ in range(N-1):
    c, f, s = list(map(int, input().split()))
    csf_list.append((c, f, s))

x_list = []
total_c_list = []

for start_i in range(N-1):  # N <= 500
    total_c = csf_list[start_i][0] + csf_list[start_i][1]

    for csf in csf_list[start_i+1:]:  # N <= 500
        c, s, f = csf
        total_c = s if total_c < s else total_c
        i = math.ceil((total_c - s) / f)
        total_c = s + f * i + c
    total_c_list.append(str(total_c))

ans = '\n'.join(total_c_list + ['0'])
print(ans)


Measured memory_bytes: 3064
#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 DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

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

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  cout<<(a+b+c==2*max({a,b,c}) ? "Yes" : "No")<<endl;
  return 0;
}


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> primes = Prime.primeList(100000);
		while(true) { 
			long m = sc.nextInt();
			if (m == 0) {
				break;
			}
			long a = sc.nextInt();
			long b = sc.nextInt();
			long sqrtM = (long) Math.sqrt(m);
			long ans = 0;
			long ansP = -1;
			long ansQ = -1;
			for(long p:primes) {
				if (p > sqrtM) {
					break;
				}
				long qMax = Math.min(m/p, b*p/a);
				int qInd = Collections.binarySearch(primes, (int) qMax);
				if (qInd < 0) {
					qInd = (~qInd) - 1;
				}
				if (qInd < 0) {
					continue;
				}
				long q = primes.get(qInd);
				if (q >= p && p*q > ans) {
					ans = p*q;
					ansP = p;
					ansQ = q;
				}
			}
			System.out.println(ansP + " " + ansQ);
		}
	}

}
class Prime {
	public static boolean[] isPrimeArray(int max) {
		boolean[] isPrime = new boolean[max+1];
		Arrays.fill(isPrime, true);
		isPrime[0] = isPrime[1] = false;
		for(int i=2;i*i<=max;i++) {
			if (isPrime[i]) {
				int j = i * 2;
				while(j<=max) {
					isPrime[j] = false;
					j += i;
				}
			}
		}
		return isPrime;
	}
	public static ArrayList<Integer> primeList(int max) {
		boolean[] isPrime = isPrimeArray(max);
		ArrayList<Integer> primeList = new ArrayList<Integer>();
		for(int i=2;i<=max;i++) {
			if (isPrime[i]) {
				primeList.add(i);
			}
		}
		return primeList;
	}
}

Measured memory_bytes: 29468
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i <= b; i++)
#define per(i, a, b) for(int i = a; i >= b; i--)
typedef long long LL;
const int maxn = 105;
const LL mod = 1e9 + 7;

int n, m, x, y;
int f[maxn][maxn][maxn][maxn], r[maxn][maxn], c[maxn][maxn];
char ch;

int main() {
	cin>>n>>m;
	rep(i, 1, n)
	    rep(j, 1, m) {
	    	cin>>ch;
	    	if(ch == 'E') x = i, y = j;
	    	r[i][j] = r[i][j - 1];
	    	c[i][j] = c[i - 1][j];
	    	if(ch == 'o') r[i][j]++, c[i][j]++;
	    }
	int A, B, C, D;
	A = x - 1, B = n - x;
	C = y - 1, D = m - y;
	rep(i, 0, A)
	    rep(j, 0, B)
	        rep(k, 0, C)
	            rep(l, 0, D) {
	            	int val = f[i][j][k][l];
	            	int L = max(y - k, l + 1), R = min(y + l, m - k);
	            	f[i + 1][j][k][l] = max(f[i + 1][j][k][l], val + (r[x - i - 1][R] - r[x - i - 1][L - 1])*(x - i - 1 > j));
	                f[i][j + 1][k][l] = max(f[i][j + 1][k][l], val + (r[x + j + 1][R] - r[x + j + 1][L - 1])*(x + j + 1 + i <= n));
	            	L = max(x - i, j + 1), R = min(x + j, n - i);
	                f[i][j][k + 1][l] = max(f[i][j][k + 1][l], val + (c[R][y - k - 1] - c[L - 1][y - k - 1])*(y - k - 1 > l));
	            	f[i][j][k][l + 1] = max(f[i][j][k][l + 1], val + (c[R][y + l + 1] - c[L - 1][y + l + 1])*(y + l + 1 + k <= m));
	            }
	cout<<f[A][B][C][D]<<endl;
}

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

public class Main {

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

	    int N = Integer.parseInt(scanner.next());
	    long[] H  = new long[N];
	    
	    for (int i=0; i<N; i++) {
	        H[i]= Long.parseLong(scanner.next());
	    }

	    int m= 0;
	    int tmp=0;
        for (int i=0; i<N-1; i++) {
	        if (H[i] >= H[i+1]) {
	        	tmp++;
	        	if (m < tmp) {
	        		m=tmp;
	        	}
	        }else {
	        	tmp=0;
	        }
	    }

        System.out.print(m);
	}

}

Measured memory_bytes: 59780
#include<bits/stdc++.h>
#define ll long long int
#define li long int
#define ull unsigned long long int
#define mci map<char,int>
#define db double
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define msi map<string,int>
#define pii pair<int,int>
#define mii map<int,int>
#define vs vector<string>
#define nl "\n"
using namespace std;
int main()
{
   string s,t;
   cin>>s>>t;
   int l1=s.length();
   int l2=t.length();
   if(t.substr(0,l1)==s)
    cout<<"Yes"<<nl;
   else
    cout<<"No"<<nl;
}

Measured memory_bytes: 3616
s=list(input())
n=len(s)
s1=s[:n//2]
s2=s[n//2:]
for i in range(n//2):
  s2=[s1[-1]]+s2[:-2]
  s1=s1[:-1]
  if s2==s1:
    break
print(len(s1+s2))

Measured memory_bytes: 38256
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//const int MAX=;



int main(){
	int N,M;
	cin>>N>>M;
	multimap<int,int> m;
	rep(i,N){
		int a,b;
		cin>>a>>b;
		m.insert(make_pair(a,b));
	}
	map<int,int>::iterator ite=m.begin();
	ll ans=0;
	int rm=M;
	while(1){
		int a=ite->first;
		int b=ite->second;
		if(rm<=b){
			ans+=(ll)a*rm;
			break;
		}
		else{
			ans+=(ll)a*b;
			rm-=b;
			ite++;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define N 200005
using namespace std;
const int p = 1000000007;
int n,m;
int jie[N],ni[N];
int main()
{
	scanf("%d%d",&n,&m);
	jie[0]=ni[0]=ni[1]=1;
	for(int i=1;i<=200000;i++)jie[i]=1LL*jie[i-1]*i%p;
//	for(int j=1;j<=200000;j++)ni[j]=1LL*(p-p/i)*ni[p%i]%p;
//	for(int i=1;i<=200000;i++)ni[i]=1LL*ni[i-1]*ni[i]%p;
	int ans=1LL*jie[n]*jie[m]%p;
	if(n>m)swap(n,m);
	if(n<m-1)
	{
		puts("0");
	}
	else
	{
		if(n==m)printf("%d\n",2*ans%p);
		else printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
const long long int INF=10000000000;
int main(){
    int N,W;
    cin >> N >> W;
    int w[111];
    int v[111];
    long long int sum=0;
    for(int i=0;i<N;i++){
        cin >> v[i] >> w[i];
        sum+=v[i];
    }

    long long int dp[111][11111];
    for(int j=0;j<=11111;j++){
        dp[0][j]=INF;
    }
    dp[0][0]=0;

    for(int i=1;i<=N;i++){
        for(int j=0;j<=11111;j++){
            if(j<v[i-1]){
                dp[i][j]=dp[i-1][j];
            }else{
                dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i-1]]+w[i-1]);
            }
        }
    }

    for(long long int j=sum;j>=0;j--){
        if(dp[N][j]<=W){
            cout << j <<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 11880
#include <iostream>
#include <string>
#define llint long long

using namespace std;

string s;
llint n;

int main(void)
{
  cin >> s;

  llint ans = 0, cnt = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'W') ans += cnt;
    else cnt++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];puts("");}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};//RDLU
#define yes puts("YES")
#define no puts("NO")

struct UnionFind{
    vector<int> data;
    UnionFind(int size) : data(size, -1) {}
    bool unionSet(int x,int y){
        x=root(x);y=root(y);
        if(x==y)return 0;
        if(data[y]<data[x])swap(x,y);
        data[x]+=data[y],data[y]=x;
        return 1;
    }
    bool findSet(int x,int y){
        return root(x)==root(y);
    }
    int root(int x){
        return data[x]<0 ? x : data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<(c-a)*(d-b)<<endl;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int p[1000*100+1];
const int M=1000*100;
int main() {
	int n,m;
	cin >> n >> m;
	for(int i=1;i<n;i++){
		cin >> p[i];
		p[i]+=p[i-1];
	}
	int j=0;
	int ret=0;
	for(int i=0;i<m;i++){
		int a;
		cin >> a;
		ret+=abs(p[j]-p[j+a])%M;
		ret%=M;
		j+=a;
	}
	cout << ret << endl;
}

Measured memory_bytes: 1548
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include<math.h>

using namespace std;

int P[100];
int cnt1, cnt2, cnt3;

int main(){
	int N, A, B;
	cin >> N >> A >> B;
	for (int i = 0; i < N; i++){
		cin >> P[i];

		if (P[i] <= A){
			cnt1++;
		}
		if (P[i] >= A + 1 && P[i] <= B){
			cnt2++;
		}
		if (P[i] >= B + 1){
			cnt3++;
		}
	}
	cout << min({ cnt1, cnt2, cnt3 }) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=100000+10;
int n,a[N];
LL chk(LL x){
	for(int i=1;i<=n;i++){
		x=1LL*a[i]*(x/a[i]);
	}
	return x;
}
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	if(a[n]!=2)return !printf("-1\n");
	vector<LL> ans;

	{
		LL l=0,r=1e18;
		while(r-l>1){
			LL mid=(l+r)/2;
			if(chk(mid)<2) l=mid;
			else r=mid;
		}
		if(chk(r)==2) ans.push_back(r);
	}

	{
		LL l=0,r=1e18;
		while(r-l>1){
			LL mid=(l+r)/2;
			if(chk(mid)>2) r=mid;
			else l=mid;
		}
		if(chk(l)==2) ans.push_back(l);
	}
	if(ans.size()==0) return !printf("-1\n");
	printf("%lld %lld\n", ans[0],ans[1]);
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;



int main() {
  int n;
  int w;
  cin >> n >> w;

  vector<vector<long long>> nums(n, vector<long long>(2));
  for (int i=0; i<n; ++i) {
    cin >> nums[i][0] >> nums[i][1];
  }

  vector<vector<long long>> dp(n+1, vector<long long>(w+100));

  for (int i=0; i<=n; ++i) {
    for(int j=0; j<=w; ++j) {
      if (i==0) dp[i][j] = 0;
      else {
        if (j >= nums[i-1][0]) {
          if (i==2 && j == 3) {
            // cout << j << " " << nums[i-1][0] << " " << (dp[i-1][j-nums[i-1][0]] + nums[i-1][1]) << endl;
          }
          
          dp[i][j] = max(
            (dp[i-1][j-nums[i-1][0]] + nums[i-1][1]),
            (dp[i-1][j])
          );
        } else { // 
          // cout << i << " " << j << " " <<  " yay"  << endl;
          dp[i][j] = dp[i-1][j];
        }
      }
      // cout << "dp" <<  i << " " << j << " " << dp[i][j] << endl;
    }
  }
  // cout << "dp size" << dp.size() << endl;
  cout << dp[n][w] << endl;
  return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char s[200];
    int n, i, count = 0;
    scanf("%s", s);
    n = strlen(s);
    for(i=0; i<n/2; i++){
        if(s[i] != s[n-i-1]){
            count++;
        }
    }
    printf("%d", count);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;

int main()
{
  int n, max_num = -1000001, min_num = 1000001, tmp;
  long long int sum = 0;
  scanf("%d\n", &n);
  for (int i = 0; i < n; i++)
  {
    scanf("%d", &tmp);
    sum += tmp;
    max_num = max(max_num, tmp);
    min_num = min(min_num, tmp);
  }
  printf("%d %d %lld\n", min_num, max_num, sum);
  return 0;
}


Measured memory_bytes: 2748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
    string S, T;
    cin>>S>>T;
    ll Sz=S.size();
  	bool U=true;
    rep(i, Sz){
      	if(S.at(i)!=T.at(i))U=false;
    }
  	Yes(U);
}

Measured memory_bytes: 3628
n = int(input())
h = [int(x) for x in input().split()]

inf = 10 ** 10
dp = [inf] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    if i > 1:
        dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]))
        
print(dp[n-1])

Measured memory_bytes: 13924
#include<iostream>
#include<string>
#include<stack>
using namespace std;
int main(){
  string str;
  bool ok;

  while(true){
    stack<char>stk;
    ok = true;
    getline(cin,str);
    if(str==".") break;
    for(int i=0,l=str.size();i<l;i++){
      if(str[i]=='(') stk.push('(');
      else if(str[i]=='[') stk.push('[');
      else if(str[i]==')'){
	if(stk.empty() || stk.top()!='('){
	  ok = false;
	  break;
	}else stk.pop();
      }else if(str[i]==']'){
	if(stk.empty() || stk.top()!='['){
	  ok = false;
	  break;
	}else stk.pop();
      }
    }
    cout << (ok&&stk.empty() ? "yes" : "no") << endl;
  }
}

Measured memory_bytes: 1176
# https://atcoder.jp/contests/abc095/tasks/arc096

# 値段,枚数
A, B, C, X, Y = map(int, input().split())

ans = float("inf")
for i in range(10 ** 5 * 2):
    ans = min(ans, max(X - i, 0) * A + max(Y - i, 0) * B + 2 * i * C)

print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define vi vector<int>
#define fi first
#define sec second
#define pb push_back
#define ll long long int
#define mp make_pair
#define endl '\n'
#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,a,b)     for(int i=b;i>=a;i--)
void fast(){ ios::sync_with_stdio(false); cin.tie(NULL);}
void file(){ freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);}

int main()
{
    fast();
    
    int a,b,flag=-1;
    cin>>a>>b;
    for(int i=0;i<1500;i++)
    {
        if(floor(i*0.08)==a and floor(i*0.1)==b)
            {flag = i;break;}
    }
    cout<<flag<<endl;
}


Measured memory_bytes: 3592
#include<iostream>
using namespace std;
int main (){
	int a,b;
	cin>>a>>b;
	if(a<b){
	cout<<"a < b"<<endl;
	}else if(a>b){
	cout<<"a > b"<<endl;
	}else{
	cout<<"a == b"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#include<bits/stdc++.h>
using namespace std;
#define Jewel ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define M 10005
int main()
{
    Jewel;
    string s;
    int n;
    cin>>s;
    n = s.size();
    while(n--)
    {
        cout<<"x";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    
    if(a+b+c>=22)
    {
        cout<<"bust"<<endl;
    }
    else
    {
        cout<<"win"<<endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int A,B,ans;
  //入力
  scanf("%d",&A);
  scanf("%d",&B);
  
  //処理
  if(A<B)//ＡよりＢのほうが大きいとき
    ans=B+(B-1);
  else if(A>B)//ＢよりＡのほうが大きいとき
    ans=A+(A-1);
  else//ＡとＢが等しいとき
    ans=A+B;
  
  //出力
  printf("%d",ans);
  return 0;
}
  

Measured memory_bytes: 128
/*******************
  Ankit Sahu
  SRMIST Chennai
 ***********************/

#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define mp make_pair
#define mt make_tuple
#define gcd(a,b) (_gcd((a),(b)))
#define lcm(a,b) ((a*b)/gcd(a,b))
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forr(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define pr pair<ll,ll>
#define vp vector<pr>
using namespace std;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    cout << fixed;
    
    int a,b,c,k,ans=0;
    cin>>a>>b>>c>>k;
    
    while(k--){
    	if(a>0){
    	ans++;
    	a--;}
    	else if(b>0){
    		b--;
		}
		else{
			ans--;
			c--;
		}
	}
	cout<<ans;


	return 0;
}






Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////
ll p = 998244353;
const int NMAX = 510000;
ll fac[NMAX],finv[NMAX],inv[NMAX];
void combinit(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	
	FORq(i,2,NMAX-1){
		fac[i] = fac[i-1] * i % p;
		inv[i] = p - inv[p%i] * (p / i) % p;
		finv[i] = finv[i-1] * inv[i] % p;
	}
}
long long comb(int n,int r){
	if (n<r) return 0;
	if (n < 0 || r < 0) return 0;
	return fac[n] * (finv[r] * finv[n-r] % p) % p;
}

int main(){
    combinit();
    ll ans = 0;
    ll N,A,B,K;
    cin >> N >> A >> B >> K;
    vector<PLL> S;

    FORq(x,0,N){
        if ((K-(A*x)) % B == 0){
            ll y = (K-A*x) / B;
            if (y < 0) continue;
            S.PB(MP(x,y));
        }
    }
    
    REP(i,S.size()){
        ll a = S[i].fst;
        ll b = S[i].snd;
        ans = (ans + ((comb(N,a) % p) * (comb(N,b) % p))%p)%p;
    }

    cout << ans << endl;
}


Measured memory_bytes: 22380
#include <bits/stdc++.h>
#define debug //printf
using namespace std;

const int maxn = 1e5+10;

int n;

struct edge{ int a, b, c; };
struct query{ int i, v, x, y; };
vector<edge> g[maxn];
vector<query> q[maxn];
void add2(int a, int b, int c, int d) {
	g[a].push_back((edge){b, c, d});
	g[b].push_back((edge){a, c, d});
}

int f[maxn], v[maxn];
int find(int x) { return f[x]>0?f[x]=find(f[x]):x; }
void merge(int x, int y) {
	int fx = find(x), fy = find(y);
	if (fx == fy) return;
	v[fy] = v[fx];
	if (f[fx] > f[fy]) swap(fx, fy);
	f[fx] -= f[fx]==f[fy];
	f[fy] = fx;
}

int dis[maxn], col[maxn], cdis[maxn];
int ans[maxn], lca[maxn];
void dfs(int u, int fa) {
	for (int i = 0; i < g[u].size(); ++i) {
		int v = g[u][i].a;
		if (v == fa) continue;
		dis[v] = dis[u] + g[u][i].c;
		col[g[u][i].b]++;
		cdis[g[u][i].b] += g[u][i].c;
		dfs(v, u);
		merge(u, v);
		col[g[u][i].b]--;
		cdis[g[u][i].b] -= g[u][i].c;
	}
	for (int i = 0; i < q[u].size(); ++i) {
		query &qq = q[u][i];
		debug(" %d %d %d %d: %d\n", qq.i, qq.v, qq.x, qq.y, ans[qq.i]);
		debug("%d: %d %d %d %d\n", qq.i, u, dis[u], cdis[qq.x], col[qq.x]*qq.y);
		if (qq.v) {
			ans[qq.i] += dis[u]-cdis[qq.x]+col[qq.x]*qq.y;
			if (!lca[qq.i] && dis[qq.v]) {
				lca[qq.i] = v[find(qq.v)];
				debug("lca: %d %d: %d\n", u, qq.v, lca);
				q[lca[qq.i]].push_back((query){qq.i, 0, qq.x, qq.y});
			}
		}
		else {
			ans[qq.i] -= 2*(dis[u]-cdis[qq.x]+col[qq.x]*qq.y);
		}
	}
}

int main() {
	int qq;
	scanf("%d%d", &n, &qq);
	int a, b, c, d;
	for (int i = 0; i < n-1; ++i) {
		scanf("%d%d%d%d", &a, &b, &c, &d);
		add2(a, b, c, d);
	}
	for (int i = 0; i < qq; ++i) {
		scanf("%d%d%d%d", &a, &b, &c, &d);
		q[c].push_back((query){i, d, a, b});
		q[d].push_back((query){i, c, a, b});
	}
	memset(f, -1, sizeof(f));
	for (int i = 1; i <= n; ++i) v[i] = i;
	dis[1] = 1;
	dfs(1, 0);
	for (int i = 0; i < qq; ++i) {
		printf("%d\n", ans[i]);
	}
}


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

int n, a;
unordered_map<int, int> m;
int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a;
		m[a-1]++;
		m[a]++;
		m[a+1]++;
	}
	a = 0;
	for(auto it : m) a = max(a, it.second);
	cout << a;
}

Measured memory_bytes: 4260
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}



int main(){
  ll h, w;
  vector<string> v;
  ll INF = 10000000000;
  cin>>h>>w;
  for(ll i=0; i<h; i++) {
    string s;
    cin>>s;
    v.push_back(s);
  }
  queue<pair<ll, ll>> q;
  ll ans = 0;
  ll d[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
  for(ll i=0; i<h; i++) {
    for(ll j=0; j<w; j++) {
      if(v[i][j]=='.') {
	vector<vector<ll>> dist(h, vector<ll>(w, INF));
	dist[i][j] = 0;
	q.push(make_pair(j, i));
	while(!q.empty()) {
	  ll x = q.front().first;
	  ll y = q.front().second;
	  q.pop();
	  for(ll k=0; k<4; k++) {
	    ll nx = x+d[k][0];
	    ll ny = y+d[k][1];
	    if(0<=nx and nx<w and 0<=ny and ny<h and v[ny][nx]=='.' and dist[ny][nx]==INF) {
	      q.push(make_pair(nx, ny));
	      dist[ny][nx] = dist[y][x]+1;
	    }
	  }
	}
	for(ll si=0; si<h; si++) {
	  for(ll sj=0; sj<w; sj++) {
	    if(dist[si][sj]!=INF)
	      ans = max(ans, dist[si][sj]);
	  }
	}
      }
    }
  }
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			int n = sc.nextInt();
			int x = sc.nextInt();
			int t = sc.nextInt();
			
			int rep = n / x + (n % x == 0 ? 0 : 1);
			
			System.out.println(rep * t);
		}
	}

}

Measured memory_bytes: 35728
using System;

namespace AtCoderProject
{
    class Program
    {
        static void Main(string[] args)
        {
            var n_m_k = Console.ReadLine().ToString().Split(" ");
            var listA = new long[long.Parse(n_m_k[0])+1];
            var listB = new long[long.Parse(n_m_k[1])+1];
            long minutes = long.Parse(n_m_k[2]);

            var a = Console.ReadLine().Split(" ");
            for (long i = 0; i < a.Length; i++)
            {
                listA[i+1] = listA[i] + long.Parse(a[i]);
            }

            var b = Console.ReadLine().Split(" ");
            for (long i = 0; i < b.Length; i++)
            {
                listB[i+1] = listB[i] + long.Parse(b[i]);
            }

            long ans = 0;
            long j = b.Length;
            for (int i = 0; i <= a.Length; i++)
            {
                if (listA[i] > minutes) break;
                
                while (listB[j] > minutes - listA[i])
                {
                    j--;
                }

               ans = Math.Max(ans, i + j);
            }

            Console.WriteLine(ans);
        }
    }
}


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

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

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

        if x == y:
            return

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

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

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

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

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

def main():
  n, m = map(int, input().split())
  uf = UnionFind(n)

  for i in range(m):
    a, b = map(int, input().split())
    a -= 1; b-= 1;
    uf.union(a, b)
  
  ans = 0
  for i in range(n):
    ans = max(ans, uf.size(i))
      
  print(ans)
  
main()

Measured memory_bytes: 14552
#include<bits/stdc++.h>
using namespace std;
typedef signed long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
//vvi(n, vector<int>(m, -1))
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(a) (a).begin(), (a).end()
#define out(x) cout << (x) << endl;

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> n >> s;
	int white[200005]={0};int black[200005]={0};
	rep(i, n){
		black[i+1] += black[i];
		white[n-1-i] += white[n-i];
		if(s[i] == '#'){
			++black[i+1];
		}
		if(s[n-1-i] == '.'){
			++white[n-1-i];
		}
	}
	int ans=100000000;
	rep(i, n+1){
		ans = min(ans, white[i] + black[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 2180