akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>  // std::accumulate(m.begin(), m.end(), 0LL);
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;
std::vector<ll> dp(90, -1);
ll get(ll i){
  if ( i == 0 ) return 2;
  if ( i == 1 ) return 1;
  if ( dp[i] != -1 ) return dp[i];
  return dp[i] = get(i-1)+get(i-2);
}

int main (void) {
  ll N; std::cin >> N;
  std::cout << get(N) << std::endl;
  return 0;
}


Measured memory_bytes: 256
s = input()
if (1 <= int(s[0:2]) and int(s[0:2]) <= 12) and (1 <= int(s[2:4]) and int(s[2:4]) <= 12):
    ans = "AMBIGUOUS"
elif (1 <= int(s[0:2]) and int(s[0:2]) <= 12) and (1 > int(s[2:4]) or int(s[2:4]) > 12):
    ans = "MMYY"
elif (1 > int(s[0:2]) or int(s[0:2]) > 12) and (1 <= int(s[2:4]) and int(s[2:4]) <= 12):
    ans = "YYMM"
else:
    ans = "NA"
print (ans)


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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define whole(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

const int N = int(1e6) + 2;
const int LG = 20;
const ll mod = (int)1e9 + 7;
const int INF = (int)1e9 + 7;
const ll linf = 1e16;
const ld pi = acos(-1);
const int base = 10;
const ld EPS = 1e-9;

int n;
string s;

int main ()
{
    cin >> n >> s;
    string t;
    for (int i = 0; i < sz(s); ++i)
    {
        t += s[i];
        string tt = t + t;
        if (tt == s)
        {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC153_c solver = new ABC153_c();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC153_c {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int K = in.nextInt();
            long H[] = new long[N];
            for (int i = 0; i < N; i++) {
                H[i] = in.nextInt();

            }
            Arrays.sort(H);
            long att = 0;
            for (int i = N - K - 1; i >= 0; i--) {
                att += H[i];
            }
            out.println(att);
        }

    }
}



Measured memory_bytes: 87224
///   ***   ---   |||         In the name of ALLAH        |||   ---   ***   ///



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


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }

int main()
{
    optimize();

    int n;
    cin >> n;

    int d = n / 1000;

    if ( n % 1000 != 0 ) d++;

    cout << ( d * 1000 ) - n << endl;


    return 0;
}


















Measured memory_bytes: 3652
import java.util.*;

class Main {

    static Double areaTriangle (double x1, double y1, double x2, double y2, double x3, double y3) {
        double a = Math.sqrt( (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) );
        double b = Math.sqrt( (x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3) );
        double c = Math.sqrt( (x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1) );
        double z = (a + b + c) / 2.0;

        return Math.sqrt( z * (z - a) * (z - b) * (z - c) );
    }

    static void solve (ArrayList<Double> X, ArrayList<Double> Y) {
        int n = X.size();
        double area = 0;
        
        for(int i = 1; i <= n-2; i++) {
            area += areaTriangle(X.get(0), Y.get(0), X.get(i), Y.get(i), X.get(i+1), Y.get(i+1));
        }

        System.out.printf("%.7f\n", area);

    }

    public static void main (String [] args) {

        Scanner sc = new Scanner(System.in);
        ArrayList<Double> pointsX = new ArrayList<Double>();
        ArrayList<Double> pointsY = new ArrayList<Double>();

        while(sc.hasNext()) {
            String[] line = sc.nextLine().split(",");
            pointsX.add(Double.parseDouble(line[0]));
            pointsY.add(Double.parseDouble(line[1]));
        }

        solve(pointsX, pointsY);

    }
}

Measured memory_bytes: 12000
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <deque>
using namespace std;

int main(){
	long long N;
	cin >> N;
	while (cin){
		int stamina = 0;
		double avg = 0;
		vector<int> v(N);
		for (int i = 0; i < N; ++i){
			cin >> v[i];
			avg += v[i];
		}
		avg = round(avg / N);
		for (int i = 0; i < N; ++i){
			stamina = stamina + pow(abs(avg - v[i]),2);
		}
		cout << stamina << "\n";
		cin >> N;
	}
	return 0;
}

Measured memory_bytes: 256
function main(input) {
  var n = input[0]-0;
  var list = input[1].split(" ").map(v=>v-0);

  var ans = 0,t_ans=0;
  for(var i=n-2;i>=0;i--){
    if(list[i] >= list[i+1]){
      t_ans++;
    }else{
      t_ans=0;
    }
    ans = Math.max(ans,t_ans);
  }
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').split("\n"))


Measured memory_bytes: 17932
package main

import(
    "fmt"
)



func main() {
    var a,b,c int
    fmt.Scan(&a,&b,&c)
    ans := min32(min32(a+b,a+c),b+c)
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}


Measured memory_bytes: 512
// In The Name Of Allah
// Mehrkish Makuei

#include <bits/stdc++.h>

#define pb push_back
#define debug1(x) cerr << #x << " : " << x << endl;
#define debug2(x, y ) cerr << #x << " : " << x << "  " << #y << " : " << y << endl;

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef vector <ll> vll;
typedef set <char> sch;
typedef set <ll> sll;

const ll MOD = 1e9 + 7;
const ll MAXN = 1e3 + 19;

char c1, c2;

int main(){
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> c1 >> c2;
	if ( c1 == c2 )
		cout << "H" << endl;
	else
		cout << "D" << endl;
	return 0;
}


Measured memory_bytes: 256
a = int(input())
b = list(map(int, input().split()))
c = {}

for i in range(a):
    if b[i] not in c:
        c.setdefault(b[i], 1)
    else:
        c[b[i]] += 1

if len(c) == 3:
    f = list(c.values())
    for i in range(1, len(f)):
        if f[i] != f[i-1]:
            print("No")
            exit()
    g = list(c.keys())
    if g[0] ^ g[1] == g[2]:
        print("Yes")
    else:
        print("No")
elif len(c) == 2:
    f = list(c.values())
    if f[0] != f[1]*2 and f[0]*2 != f[1]:
        print("No")
        exit()
    g = list(c.keys())
    if g[0] == 0 or g[1] == 0:
        print("Yes")
    else:
        print("No")
elif len(c) == 1:
    g = list(c.keys())
    if g[0] == 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")
    exit()


Measured memory_bytes: 14228
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

W,H,N = map(int,input().split())
xya = [[] for i in range(N)]
for i in range(N):
    xya[i] = [int(i) for i in input().split()]

square = [[0 for i in range(W)] for i in range(H)]


for i in range(N):
    x,y,a = xya[i]
    if a == 1:
        for i in range(H):
            for j in range(x):
                square[i][j] = 1
    elif a == 2:
        for i in range(x,W):
            for j in range(H):
                square[j][i] = 1
    elif a == 3:
        for i in range(W):
            for j in range(y):
                square[j][i] = 1
    elif a == 4:
        for i in range(W):
            for j in range(y,H):
                square[j][i] = 1

black = 0
for i in range(H):
    black += sum(square[i])

print(H*W-black)


Measured memory_bytes: 6476
# input
n = int(input())
polls = {}

# main
for i in range(n):
  tmp = input()
  if tmp in polls:
    polls[tmp] += 1
  else:
    polls[tmp] = 1

ans = max(polls.values())
result = list(polls.items())
result.sort(key=lambda x: x[0])

# output
for d in result:
  if d[1] == ans:
    print(d[0])


Measured memory_bytes: 46556
#include <iostream>
using namespace std;
int main() {
    char b;
    cin >> b;
    if(b=='A'){
        b = 'T';
    }else if (b=='T'){
        b = 'A';
    }else if (b=='C'){
        b = 'G';
    }else if (b=='G'){
        b = 'C';
    }
    cout << b << endl;
}

Measured memory_bytes: 256
from collections import Counter
N = int(raw_input())
A = sorted(map(int, raw_input().split()))
mod = 10**9+7

if N%2 == 1:
    if A[0] != 0:
        print 0
        exit()
    x = 2
    for i in xrange(1, N, 2):
        if A[i] != x or A[i+1] != x:
            print 0
            exit()
        x += 2
    print pow(2, N/2, mod)
else:
    x = 1
    for i in xrange(0, 2, N):
        if A[i] != x or A[i+1] != x:
            print 0
            exit()
        x += 2
    print pow(2, N/2, mod)


Measured memory_bytes: 11508
#include<stdio.h>
int calculation(int,char,int);
int main(void)
{
  int a,b;
  char c;
  for(;;)
    {
      scanf("%d %c %d",&a,&c,&b);
      if(c=='?') break;
      printf("%d\n",calculation(a,c,b));
    }
  return 0;
}
int calculation(int a,char c,int b)
{
  switch(c)
    {
    case '+':
      return a+b;
    case '-':
      return a-b;
    case '*':
      return a*b;
    case '/':
      return a/b;
    }
}



Measured memory_bytes: 2140
#include <iostream>
#include <bitset>
using namespace std;
bitset<4000005> dp;
int main()
{
	int n,sum=0;
	scanf("%d",&n);
	dp[0]=1;
	while (n--)
	{
		int a;
		scanf("%d",&a);
		dp|=(dp<<a);
		sum+=a;
	}
	int ans=(sum+1)/2;
	while (!dp[ans])
	ans++;
	printf("%d",ans);
}

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

int main() {
  int n,b=0,w;
  string s;
  cin >> n >> s;
  w=count(s.begin(),s.end(),'.');
  int ans=w;
  r(i,n){
    if(s[i]=='#')b++;
    else w--;
    ans=min(ans,b+w);
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,m = na()
a = na()

bc = [na() for i in range(m)]
bc.sort(key=lambda x:x[1])

for b,c in bc[::-1]:
  a.extend([c]*b)
  if len(a)>2*n:
    break

a.sort(reverse=True)
print(sum(a[:n]))

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

int main(void) {
	double x = 0.0, y = 0.0;
	double direction = M_PI_2;
	int a, b;
	int i=0;

	scanf("%d,%d", &a, &b);
	while( !(a==0 && b==0) ) {
		x += (double)a*cos(direction);
		y += (double)a*sin(direction);
		direction -= (double)b*M_PI/180.0;
		scanf("%d,%d", &a, &b);
	}
	printf("%d\n%d\n", (int)x, (int)y);

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int main(){
    IOS();
    bool x;
    cin >> x;
    cout << !x << endl;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,ans,n;
    scanf("%d",&n);
    scanf("%d",&ans);
    for(int i=2;i<=n;i++){
        scanf("%d",&a);
        ans^=a;
    }
    if(ans==0) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int a,b,c,d;
  cin >> a >> b >> c >> d;
  while(true){
    
    c=c-b;
    if(c<=0){
      cout << "Yes" << endl;
      break;
    }
    a=a-d;
    if(a<=0){
      cout << "No" << endl;
      break;
    }
  }
}


Measured memory_bytes: 3636
a, b, c = gets.chomp.split(" ")

if a == b 
    if b != c
        puts "Yes"
    else
        puts "No"
    end

elsif b == c
    if c != a
        puts "Yes"
    else
        puts "No"
    end
elsif c == a
    if a != b
        puts "Yes"
    else
        puts "No"
    end

else puts "No"

end

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

const int N = 2005;
int ans[N];

int dist(int i, int j, const int &x, const int &y)
{
	if(j <= x || i >= y) return j-i;
	if(i >= x && j <= y) {
		int resp = j-i;
		resp = min(resp, i-x + y-j + 1);
		return resp;
	}
	if(i <= x && j >= y) return x-i + j-y + 1;
	if(i >= x) {
		int resp = j-y;
		resp += min(y-i, i-x + 1);
		return resp;
	}
	if(j <= y){
		int resp = x-i;
		resp += min(j-x, y-j + 1);
		return resp;
	}
}

int main()
{
	int n, x, y;
	scanf("%d %d %d", &n, &x, &y);
	for (int i=1; i<=n-1; i++){
		for (int j=i+1; j<=n; j++){
			ans[dist(i, j, x, y)]++;
		}
	}
	for (int i=1; i<n; i++){
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>

int check(int x, int y) {
  if (x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) {
	if (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12) {
	  return 1;
	}
	else {
	  return 0;
	}
  }
  if (x == 4 || x == 6 || x == 9 || x == 11) {
	if (y == 4 || y == 6 || y == 9 || y == 11) {
	  return 1;
	}
	else {
	  return 0;
	}
  }
  if (x == 2) {
	if (y == 2) {
	  return 1;
	}
	else {
	  return 0;
	}
  }
}

int main() {
  int a, b,flag;
  scanf("%d %d", &a, &b);

  flag = check(a,b);
  if (flag == 0) {
	printf("No");
  }
  else if(flag == 1){
	printf("Yes");
  }

  return 0;
}

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

int main(){
  int n,m,ans;
  ans=0;
  long long a,b,k;
  cin >> n >> m >> k;
  vector<long long> v,w;
  b=0;
  v={0};
  rep(i,n){
    cin >> a;
    b+=a;
    v.push_back(b);
  }
  b=0;
  rep(i,m){
    cin >> a;
    b+=a;
    w.push_back(b);
  }
  rep(i,n+1){
    long long mkr=k-v[i];
    int l=0;
    int r=m-1;
    if(mkr>=0){
      if(w[l]>mkr){
        l=-1;
      }
      else if(w[r]<=mkr){
        l=m-1;
      }
      else{
        while(true){
          if(r-l<2){
            break;
          }
          if(w[(l+r)/2]>mkr){
            r=(l+r)/2;
          }
          else{
            l=(l+r)/2;
          }
        }
      }
      if(ans<l+i+1){
        ans = l+i+1;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 7976
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
cout<<fixed<<setprecision(10);

int N,X,Y;
  cin >>N>>X>>Y;
  vector<int> d(N+1,0);
  
  //例外処理　円形
  if (X==1 && Y==N){
    for (int i=0; i<=(N-3)/2; i++){
      d.at(i+1)=N;
    }
    if (N%2==0){
      d.at(N/2-1+1)=N/2;
    }
    
  } else {
  //メインの処理
    for (int i=1;i<N;i++){
    	d.at(i)=N-i;
    }
    for (int i=0; i<N-1;i++){
      for (int j=i+1; j<N; j++){
        if (i<=X-1 && Y-1<=j){
          d.at(j-i)--;
          d.at(min(j-i,X-i+j-Y+1))++;
        } else if (X-1<i && i<Y-1 && Y-1<=j){
          d.at(j-i)--;
          d.at(min(j-i,i+j+3-X-Y))++;
        } else if (i<=X-1 && j< Y-1 && X-1<j){
          d.at(j-i)--;
          d.at(min(j-i,X+Y-i-j-1))++;
        } else if (X-1<i && j<Y-1){
          d.at(j-i)--;
          d.at(min(j-i,i-j+Y-X+1))++;
        }
      }
    }
    
 
  }
  
  //出力
  for (int i=1;i<N;i++){
    cout << d.at(i)<< endl;
  }
  
  
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	writefln("%.6f", readln.split.map!(to!int).reduce!((a,b)=>a*b)/3.305785);
}

Measured memory_bytes: 1132
N = int(input())
L = ["AC", "WA", "TLE", "RE"]
p = [0] * 4

for i in range(N):
    s = input()
    if s == "AC":
        p[0] += 1
    if s == "WA":
        p[1] += 1
    if s == "TLE":
        p[2] += 1
    if s == "RE":
        p[3] += 1

for i in range(len(L)):
    print(L[i], "x", p[i])

Measured memory_bytes: 9212
n, m, k = map(int,input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
sa = [0]
for i in range(n):
    sa.append(sa[-1] + a[i])
inf = 1001001001
sb = [-inf, 0]
for i in range(m):
    sb.append(sb[-1] + b[i])
sb.append(inf)
ans = 0
for i in range(n+1):
    s = sa[i]
    l = 0
    r = len(sb) - 1
    while l+1 < r:
        m = (l+r) //2
        if s + sb[m] <= k:
            l = m
        else:
            r = m
    if l == 0:
        continue
    else:
        ans = max(ans, i+l-1)
print(ans)

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

#define     bip(a)         __builtin_popcount(a)
#define     ull            unsigned long long
#define     ll             long long
#define     u              unsigned
#define     pb             push_back
#define     pf             push_front ///for list
#define     mpr            make_pair
#define     ins            insert
#define     ff             first
#define     ss             second
#define     vi             vector<int>
#define     vl             vector<ll>
#define     si             set<int>
#define     sl             set<ll>
#define     li             list<int>
#define     pii            pair<int,int>
#define     pll            pair<ll,ll>
#define     mii            map<int,int>
#define     mll            map<ll,ll>
#define     ma             INT_MAX
#define     mi             INT_MIN
#define     mod            1000000007
#define     pi             3.14159265359
#define     e              2.71828182846
#define     inf            1000000000000000LL
#define     all(x)         x.begin(), x.end()
#define     lb(a,b,c)      lower_bound(a,a+b,c)-a
#define     ub(a,b,c)      upper_bound(a,a+b,c)-a
#define     lbv(a,c)       lower_bound(all(a),c)-a.begin()
#define     ubv(a,c)       upper_bound(all(a),c)-a.begin()
#define     srt1(a,b)      sort(a,a+b)
#define     srt2(a,b)      sort(a,a+b,greater<int>())
#define     gcd(a,b)       __gcd(a,b)
#define     lcm(a,b)       (a*(b/gcd(a,b)))
#define     harmonic(n)    0.57721566490153286l+log(n)
#define     mem(a, b)      memset(a, b, sizeof(a))

///s.lower_bound(a),s.upper_bound(a), for set
///nCr(x, y) = nCr(x-1, y-1) + nCr(x-1, y)
///factorial digit   ((n * log10(n / e) +log10(2 * pi * n) /2.0));

int cnt[10000005];

void divisor()
{
    for(int i=1;i<=10000005;i++)cnt[i]=1;
    for(int i=2;i<=10000000;i++){
        for(int j=i;j<=10000000;j+=i)
            cnt[j]++;
    }
}

int main()
{
    /*divisor();
    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=1;i<=n;i++)
        ans+=(i*cnt[i]);
    cout<<ans<<endl;*/
    /*ll a,ans;
    cin>>a;
    ans=a+(a*a)+(a*a*a);
    cout<<ans<<endl;*/
    string str1,str2;
    int mov=0;
    cin>>str1>>str2;
    for(int i=0;i<str1.size();i++){
        if(str1[i]!=str2[i])mov++;
    }
    cout<<mov<<endl;
}



Measured memory_bytes: 3888
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=200005;
int n,q;
string s;
int c[M],d[M];
int box[M];
bool chk(int pos)
{
    int rong=box[pos];
    int cur=pos;
    f(i,1,q)
    {
        if(c[i]==box[cur])
        {
            if(d[i]==0)
            {
                cur--;
                if(cur==0)return true;
            }
            else
            {
                cur++;
                if(cur>n)return false;
            }
        }
    }
    return false;
}
bool chk2(int pos)
{
    int rong=box[pos];
    int cur=pos;
    f(i,1,q)
    {
        if(c[i]==box[cur])
        {
            if(d[i]==0)
            {
                cur--;
                if(cur==0)return false;
            }
            else
            {
                cur++;
                if(cur>n)return true;
            }
        }
    }
    return false;
}
 main()

{
    fast
    cin>>n>>q;
    cin>>s;
    f(i,1,n)
    {
        box[i]=s[i-1]-'a';
    }
    f(i,1,q)
    {
        char ch,ch2;
        cin>>ch>>ch2;
        c[i]=ch-'a';
        if(ch2=='R')d[i]=1;
    }
    int lo=1,hi=n;
    while(hi>lo)
    {
        int mid=(lo+hi+1)>>1;
        if(chk(mid))
        {
            lo=mid;
        }
        else hi=mid-1;
    }
    int lft=0,rgt=n+1;
    if(chk(lo))lft=lo;
    lo=1,hi=n;
    while(hi>lo)
    {
        int mid=(lo+hi)>>1;
        if(chk2(mid))
        {
            hi=mid;
        }
        else
        {
            lo=mid+1;
        }
    }
    if(chk2(lo))rgt=lo;
    int ses=lft+(n+1-rgt);
    ses=n-ses;
    cout<<ses<<endl;
    return 0;

}





































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

using namespace std;

//Shortcut
#define long long long
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define sz size
#define ft(i , a , b) for (long i = (long)a ; i <= (long)b ; i++)
#define fd(i , a , b) for (long i = (long)a ; i >= (long)b ; i--)
#define lt(i , a , b , c) for (long i = (long)a ; i <= (long)b ; i += (long)c)
#define ld(i , a , b , c) for (long i = (long)a ; i >= (long)b ; i -= (long)c)
#define pll pair <long , long>
#define pls pair <long , string>
#define vtl vector <long>
#define vts vector <string>
#define mll map <long , long>

//Variable
const long mxN = 1e5 + 5;
const long base = 311;
const long oo = 1e15;
const long MOD = 1e9 + 7;
const long d4i[4] = {-1 , 0 , 1 , 0} , d4j[4] = {0 , 1 , 0 , -1};
const long d8i[8] = {-1 , -1 , 0 , 1 , 1 , 1 , 0 , -1} , d8j[8] = {0 , 1 , 1 , 1 , 0 , -1 , -1 , -1};

long TestCase;
long l , r , d;

void Solve() {
    cin >> l >> r >> d;
    cout << (r / d) - ((l - 1) / d);
}

int main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen(".inp", "r", stdin);
    //freopen(".out", "w", stdout);
    //cin >> TestCase;
    TestCase = 1;
    while(TestCase--)
        Solve();
    return 0;
}

Measured memory_bytes: 3552
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

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

typedef long long ll;

#include <set>
using namespace std;

ll dp[102][10][1001];

int main(){
  dp[0][0][0] = 1;
  REP(i,101) REP(j,10) REP(k,1001){
    dp[i + 1][j][k] += dp[i][j][k];
    if(j + 1 < 10 && k + i <= 1000) dp[i + 1][j + 1][k + i] += dp[i][j][k];
  }

  while(true){
    const int n = getInt();
    const int s = getInt();
    if(n + s == 0) break;
    printf("%lld\n", dp[101][n][s]);
  }

  return 0;
}

Measured memory_bytes: 8928
import Control.Monad
import Data.List
import Data.List.Split

main = do
    getLine
    ss <- lines <$> getContents
    mapM_ putStrLn . map (unwords . (map show)). numbering 1 $ cut ss

cut ss = map (\xs -> (map length (cut2 (head xs)), length xs)) $ cut1 ss

cut1 ss = f $ split (keepDelimsL $ whenElt (any (=='#'))) ss
    where f (xs:xss) | null xs = xss 
                     | otherwise = let (ys:yss) = xss in (ys ++ xs) : yss

cut2 s = f $ split (keepDelimsL $ whenElt (== '#')) s
    where f (x:xs) | null x = xs
                   | otherwise = let (y:ys) = xs in (y ++ x) : ys

numbering _ [] = []
numbering k ((xs,l):xss) = replicate l (g k xs) ++ numbering (k + length xs) xss
    where g k xs = concat $ zipWith replicate xs [k..] 

Measured memory_bytes: 2940
#include <stdio.h>

int main(void){

	int a[10000], min, max, n, i;
	long long sum = 0;

	scanf("%d", &n);	/* ???????????´??°?????°n?????\??? */
		for(i = 0; i < n; i++){
		scanf("%d", &a[i]);	/* ?????????n????????´??°a?????\??? */
			sum += a[i];
	}
	max = min = a[0];
	for(i = 1; i < n; i++){
		if(a[i] > max)max = a[i];	/* ?????§???max */
		if(a[i] < min)min = a[i];	/* ????°????min */
	}

	printf("%d %d %lld\n", min, max, sum);

	return 0;
}

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

int main()
{
	int a, b, c;
	int start;
	bool can_choose = false;

	cin >> a >> b >> c;

	start = a%b;

	int a_sum = a;

	while(a_sum%b != start || a_sum == a) {
	    if (a_sum%b == c)
	    {
	    	can_choose = true;
	    	break;	
	    }
	    a_sum += a;
	}

	if (can_choose == true)
	{
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}

	return 0;
}

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

constexpr int mod=1e9+7;

int v[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main(){
    int k;
    cin>>k;
    cout<<v[k-1];
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($( { splits.next().unwrap().parse::<$t>().unwrap() },)*)
    }}
}

#[allow(unused_macros)]
macro_rules! invec {
    ( $ t : ty ) => {{
        let mut s = String::new();
        match std::io::stdin().read_line(&mut s) {
            Ok(0) => Vec::<$t>::new(),
            Ok(n) => s
                .trim()
                .split_whitespace()
                .map(|s| s.parse::<$t>().unwrap())
                .collect::<Vec<$t>>(),
            Err(_) => Vec::<$t>::new(),
        }
    }};
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (n,) = input!(usize);
    let a = invec!(u128);

    for k in &a {
        if *k == 0 {
            println!("0");
            std::process::exit(0);
        }
    }

    let mut p = 1;

    for k in a {
        p *= k;
        if p > 1_000_000_000_000_000_000 {
            println!("-1");
            std::process::exit(0);
        }
    }

    println!("{}", p);
}

fn main() {
    solve();
}


Measured memory_bytes: 5660
#include <iostream>
using namespace std;
int x[]={8,5,2,10,7,4,1,9,6,3,0};
int y[]={7,5,3,1,10};
int main(){
    int n,k,ans=0;
    cin>>n>>k;
    n-=2;
    for(int i=0;i<11;i++){
        for(int j=0;j<5;j++){
            if((x[i]+y[j])%11==k){
                ans++;
            }
        }
    }
    ans*=n/11;
    n%=11;
    for(int i=0;i<n;i++){
        for(int j=0;j<5;j++){
            if((x[i]+y[j])%11==k){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
return 0;
}


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

const int MAXN = 100005;

int N, K;
int x[MAXN], y[MAXN], ch[MAXN];
char co[MAXN];

int c[1005][1005];

void paint(int x0, int x1, int y0, int y1)
{
	if (x0 <= x1 && y0 <= y1) {
		c[x0][y0]++, c[x0][y1+1]--, c[x1+1][y0]--, c[x1+1][y1+1]++;
		// cerr << x0 << " " << x1 << " " << y0 << " " << y1 << endl;
	}
}

int main()
{
	scanf("%d%d", &N, &K);
	for (int i = 1; i <= N; i++) {
		scanf("%d%d %c", &x[i], &y[i], &co[i]), ch[i] = (co[i] == 'B');
	}
	for (int i = 1; i <= N; i++) {
		int cur = (x[i]/K+y[i]/K)%2;
		int X = x[i]%K, Y = y[i]%K;
		if (cur == ch[i]) {
			paint(0, K-1-X, 0, K-1-Y);
			paint(K-X, K-1, K-Y, K-1);
		} else {
			paint(K-X, K-1, 0, K-1-Y);
			paint(0, K-1-X, K-Y, K-1);
		}
	}
	int ans = 0;
	for (int i = 0; i < K; i++)
		for (int j = 0; j < K; j++) {
			c[i][j] += (i>0)*c[i-1][j]+(j>0)*c[i][j-1]-(i>0&&j>0)*c[i-1][j-1];
			ans = max(ans, c[i][j]);
		}
        memset(c, 0, sizeof c);
	for (int i = 1; i <= N; i++) {
		int cur = (x[i]/K+y[i]/K)%2;
		int X = x[i]%K, Y = y[i]%K;
		if (cur != ch[i]) {
			paint(0, K-1-X, 0, K-1-Y);
			paint(K-X, K-1, K-Y, K-1);
		} else {
			paint(K-X, K-1, 0, K-1-Y);
			paint(0, K-1-X, K-Y, K-1);
		}
	}
	for (int i = 0; i < K; i++)
		for (int j = 0; j < K; j++) {
			c[i][j] += (i>0)*c[i-1][j]+(j>0)*c[i][j-1]-(i>0&&j>0)*c[i-1][j-1];
			ans = max(ans, c[i][j]);
		}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5504
#include<iostream>
using namespace std;
int main() {

	string s;
	cin >> s;
	int i, j, k;
	int ab[26];
	for (i = 0; i < 26; i++) {
		ab[i] = 0;
	}
	for (j = 0; j < s.length() - 1; j++) {
		if (s[j] == s[j + 1]) {
			cout << j + 1 << ' ' << j + 2 << endl;
			return 0;
		}
		else if (j < s.length() - 2) {
			if (s[j] == s[j + 2]) {
				cout << j + 1 << ' ' << j + 3 << endl;
				return 0;
			}
		}
	}
	cout << -1 << ' ' << -1 << endl;
	return 0;
}

Measured memory_bytes: 3772
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		StringBuilder sb = new StringBuilder();
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		int ans = Integer.MAX_VALUE;
		for (int l = 0; l <= n - k; l++) {
			int r = l + k - 1;
			int x = Math.abs(a[l]) + Math.abs(a[r] - a[l]);
			int y = Math.abs(a[r]) + Math.abs(a[r] - a[l]);
			ans = Math.min(ans, x);
			ans = Math.min(ans, y);
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 50416
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;


int main(){
	int a,b,c,d,e,f;
	while(cin>>a>>b>>c>>d>>e>>f){
		double det = a*e - b * d;
		double x = 1 / det * (c * e - b * f);
		double y = 1 / det * (f * a - c * d);
		if(x == -0.0) x = 0.0;
		if(y == -0.0) y = 0.0;
		printf("%.3lf %.3lf\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>


using namespace std;

int main(){
    int N;
    cin>>N;
    while (N!=0)
    {
            int ans=0;
        bool l=false,r=false,up=false;

        for (int i = 0; i < N; i++)
        {
            string S;
            cin>>S;
            if(S=="ru")r=true;
            else if(S=="lu")l=true;
            else if(S=="rd")r=false;
            else if(S=="ld")l=false;

            if(r && l && !up){
                ans++;
                up=true;
            }

            if (!r&&!l&&up)
            {
                ans++;
                up=false;
            }
            
        }
        
        cout<<ans<<endl;
        cin>>N;
    }
    
}


Measured memory_bytes: 3132
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		boolean col=true;
		int[] preAns=new int[n];
		preAns[0]=1;				
		boolean[] PAalre=new boolean[n];

		int s;
		int c;
		for(int i=0;i<m;i++){
			s= sc.nextInt()-1;
			c= sc.nextInt();
				if(PAalre[s]){
					if(c!=preAns[s]){
						col=false;
					}
				}else{
					PAalre[s]=true;
					preAns[s]=c;
				}	
		}
		if(preAns[0]==0&&n!=1){
			col=false;
		}
      	if(m==0&&n==1){
          preAns[0]=0;
        }
		if(col){
			String ans="";
			for(int i=0;i<n;i++){
				ans=ans+preAns[i];
			}
			System.out.println(ans);
		}else{
			System.out.println(-1);
		}
	}
}

Measured memory_bytes: 23124
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#define md double
#define LL long long
using namespace std;
const int N=6e5,M=N<<2;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
struct P{ int x,y; }p[N],st1[N],st2[N];
inline bool cmpx(const P &a,const P &b) { return a.x<b.x; }
int x[N],ans;
int mx[M],tag[M];
#define lc (i<<1)
#define rc (lc|1)
inline void build(int i,int l,int r) {
	mx[i]=-1<<30,tag[i]=0;
	if (l!=r) {
		int mid=(l+r)>>1;
		build(lc,l,mid);build(rc,mid+1,r);
	}
}
inline void modify(int i,int l,int r,int L,int R,int d) {
	if (L<=l&&r<=R) tag[i]+=d,mx[i]+=d;
	else {
		int mid=(l+r)>>1;
		if (tag[i]) {
			mx[lc]+=tag[i],tag[lc]+=tag[i];
			mx[rc]+=tag[i],tag[rc]+=tag[i];
			tag[i]=0;
		}
		if (L<=mid) modify(lc,l,mid,L,R,d);
		if (mid<R) modify(rc,mid+1,r,L,R,d);
		mx[i]=max(mx[lc],mx[rc]);
	}
}
inline void init(int i,int l,int r,int k,int d) {
	if (l==r) mx[i]=d;
	else {
		int mid=(l+r)>>1;
		k<=mid?init(lc,l,mid,k,d):init(rc,mid+1,r,k,d);
		mx[i]=max(mx[lc],mx[rc]);
	}
}
inline void solve(int n,int m,int T) {
	int i,len=T,l1,l2,a,b,e,l,r,mid;P *st;sort(p+1,p+1+T,cmpx);
	for (i=1;i<=T;i++) x[i]=p[i].x;p[++T]=(P){n,m>>1};
	x[++len]=0,x[++len]=n;
	sort(x+1,x+1+len);len=unique(x+1,x+1+len)-x-1;
	build(1,1,len);
	init(1,1,len,1,m);
	st1[l1=1]=st2[l2=1]=(P){1,m>>1};
	for (i=1;i<=T;i++) {
		int &top=p[i].y<=m>>1?(st=st1,l1):(st=st2,l2);
		a=p[i].x,b=abs(p[i].y-(m>>1));
		for (l=1,r=len;l!=r;a<=x[mid=(l+r)>>1]?r=mid:l=mid+1);a=l;e=a;
		ans=max(ans,x[a]+mx[1]);
		init(1,1,len,a,m-x[a]);
		while (top&&b<st[top].y) {
			if (st[top].x!=e) modify(1,1,len,st[top].x,e-1,b-st[top].y);
			e=st[top--].x;
		}
		if (e!=a) st[++top]=(P){e,b};
		st[++top]=(P){a,m>>1};
		if (p[i].y>m>>1) st1[++l1]=(P){a,m>>1};
		else st2[++l2]=(P){a,m>>1};
	}
}
int main()
{
	int n=gi()<<1,m=gi()<<1,T=gi(),i;
	for (i=1;i<=T;i++) p[i].x=gi()<<1,p[i].y=gi()<<1;
	solve(n,m,T);
	for (i=1;i<=T;i++) swap(p[i].x,p[i].y);
	solve(m,n,T);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 26880
#include"bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n,k; cin >> n >> k;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  sort(h.begin(),h.end());
  long long sum=0;
  rep(i,n-k){
    sum+=h[i];}
  cout << sum << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
// atoi : atoi(str.c_str())
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  fix10;
  double PI = acos(-1);
  int n;
  cin >> n;
  vector<tuple<double,long,long>> engine(n);
  rep(i,n){
    long x,y;
    cin >> x >> y;
    engine.at(i) = make_tuple(atan2(y,x),x,y);
  }
  sort(engine.begin(),engine.end());
  
  double maxi = 0;
  rep(i,n){
    double shita = get<0>(engine.at(i));
    long X = 0;
    long Y = 0;
    int count = 0;
    for(int j = i; count < n ; j = (j+1)%n){
      if(get<0>(engine.at(j)) >= shita + PI) break;
      X += get<1>(engine.at(j));
      Y += get<2>(engine.at(j));
      count++;
      double dis0 = sqrt(X*X+Y*Y);
      maxi = max(maxi,dis0);
    }
    double dis = sqrt(X*X+Y*Y);
    maxi = max(maxi,dis);
    get<0>(engine.at(i)) = shita + 2*PI;
  }
  cout << maxi << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h> 
#define ll long long
#define ld long double
using namespace std; 

ll power(ll x, ll y, ll p)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
int main()
{
	ll N;
	cin >> N;
	map <string, ll> mp;
	for(ll i=0;i<N;i++)
	{
		string s;
		cin >> s;
		mp[s]+=1;
	}
	cout << mp.size() << "\n";

}

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

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    map<int,int> index;
    rep(i,n) cin >> a[i];
    vector<int> b = a;
    sort(all(b));
    map<int, bool> odd;
    rep(i,n) odd[b[i]] = (i % 2 == 1);
    int cnt = 0;
    rep(i,n) if ((i % 2 == 0) && odd[a[i]]) cnt++;
    cout << cnt << endl;
    return 0;
}


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

using namespace std;

int main()
{
  int N,num;
  cin >> N;
  vector<int> vec;
  int cont = 0;
  for(int i = 0; i < N;i++)
  {
    cin >> num;
    vec.push_back(num);
  }
  for(int i =1; i< N-1;i++)
  {
    if(((vec[i-1] < vec[i]) && (vec[i] < vec[i+1])) || ((vec[i-1] > vec[i]) && (vec[i] > vec[i+1])))
    {
      cont++;
    }
  }
  cout << cont;
}

Measured memory_bytes: 256
#include <iostream>

#include <vector>
using namespace std;
using ll = long long;

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

template <class T = long long>
class Union_Find {
  using size_type = std::size_t;
  using _Tp = T;
public:

  vector<_Tp> par;

  const _Tp & operator[] (size_type child) {
    return -par[root(child)];
  }

  Union_Find(size_type n) : par(n, -1) {}
  void init(int n) {
    par.assign(n, -1);
  }

  _Tp root(size_type x) {
    if (par[x] < 0) return x;
    else return par[x] = root(par[x]);
  }

  bool issame(size_type x, size_type y) {
    return root(x) == root(y);
  }

  bool merge(size_type x, size_type y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (par[x] > par[y]) swap(x,y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }

  _Tp size(int x) {
    return -par[root(x)];
  }
};
 
int main() {
  ll n, m, ans = 0;
  cin >> n >> m;
  Union_Find<long long> uf(n);
 
  vector<int> a(m), b(m);
  rep(i, m) {
    cin >> a[i] >> b[i];
    a[i] -= 1; b[i] -= 1;
  }
  ll con = (n * (n-1)) / 2;
  vector<ll> comf;
  // comf.push_back(con);
 
  for (int i = m - 1; i >= 0; --i) {
    comf.push_back(con);
    if (uf.issame(a[i], b[i])) {
      continue;
    }
    ll ta = uf.size(a[i]), tb = uf.size(b[i]);
    con -= ta * tb;
    uf.merge(a[i], b[i]);
  }
 
  for (int i = m - 1; i >= 0; --i) {
    cout << comf[i] << endl;
  }
}


Measured memory_bytes: 3828
n, x, y = map(int,input().split())
cnt = [0]*n

x -= 1
y -= 1

for i in range(n):
    for j in range(i+1, n):
        a = j - i
        b = abs(x - i) + 1 + abs(j - y)
        c = min(a, b)
        cnt[c] += 1
for i in range(1,n):
    print(cnt[i])


Measured memory_bytes: 74236
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n,tt=INFINITY,ans;
  cin>>n;
  rep(i,5){
    ll t;
    cin>>t;
    tt=min(tt,t);
  }
  if(n%tt==0) ans=n/tt+4;
  else ans=n/tt+5;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#define watch5(a,b,c,d,e) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d << " | "<<#e<<": "<<e<<endl;
#define watch4(a,b,c,d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define watch3(a,b,c) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<endl;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define sharingan cerr << "\n-------------------------------------------\n\n";
#define watch2(a,b) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<< endl;
#define Yup ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define watch(a) cerr <<#a<<": "<<a<<endl;
#define __gcd(a, b) __algo_gcd(a, b)
#define PI 3.14159265358979323846
#define mod 1000000007
#include<set>
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<array>
#include<cstdio>
#include<bitset>
#include<vector>
#include<utility>
#include<sstream>
#include<cstring>
#include <climits>
#include <fstream>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include <unordered_map>
using namespace std;

#define endl "\n"
#define int long long

int k, n;
int dp[100001][3];
int ar[100001][3];

int go( int i, int pre ){
    if( i == n )return 0;
    if( dp[i][pre] != -1 )return dp[i][pre];
    int ans = INT_MIN;
    for( int j = 0; j < 3; j++ ){
        if( j != pre ){
            ans = max(ans, go(i+1, j) + ar[i][j]);
        }
    }
    return dp[i][pre] = ans;
}

int32_t main(){
    Yup;
    cin >> n;
    for( int i = 0; i < n; i++ ){
        for( int j = 0; j < 3; j++ ){
            cin >> ar[i][j];
        }
    }
    memset(dp, -1, sizeof(dp));
    cout << max(go(0, 0), max(go(0, 1), go(0, 2)));
}

Measured memory_bytes: 11264
import queue
from collections import namedtuple
U = namedtuple("U", "id parent sib degree dep height type")

dic, link = (dict() for _ in range(2))

n = int(input())
se = set(int(x) for x in range(n))

for _ in range(n):
    a, b, c = map(int, input().split())
    link[a] = list()
    for bc in [b, c]:
        if bc != -1: link[a].append(bc)
        se.discard(bc)


def bfs(s):
    q = queue.Queue()
    q.put(U(s, -1, -1, len(link[s]), 0, 0, "root"))

    while q.qsize() != 0:
        u0 = q.get()
        dic[u0.id] = u0

        if link[u0.id] == []:
            h = 0
            p = u0.parent
            while p != -1:
                dic[p] = dic[p]._replace(height=h + 1)
                p = dic[p].parent
                h += 1

        for u1 in link[u0.id]:
            sib = -1
            if len(link[u0.id]) == 2:
                sib = (set(link[u0.id]) - {u1}).pop()
            n_type = "internal node" if link[u1] != [] else "leaf"
            q.put(U(u1, u0.id, sib, len(link[u1]), u0.dep + 1, 0, n_type))


bfs(se.pop())
for i in range(n):
    print("node", i, end="")
    print(": parent =", dic[i].parent, end="")
    print(", sibling =", dic[i].sib, end="")
    print(", degree =", dic[i].degree, end="")
    print(", depth =", dic[i].dep, end="")
    print(", height =", dic[i].height, end="")
    print(",", dic[i].type)



Measured memory_bytes: 7144
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))


inline unsigned int next_subset(unsigned int S, unsigned int U) {
  return (S - U) & U;
}
int n, m, w;
int pos[16];
int weight[16];
int memo[1 << 16];

int sum[1 << 16];
int upper[1 << 16];
int lower[1 << 16];

int calc(int s, int f, int t, int rest) {
  if (rest == 0) { return 0; }
  if (memo[rest] != -1) { return memo[rest]; }
  int ret = 1 << 30;
  for (int use = rest & -rest; use; use = next_subset(use, rest)) {
    if (sum[use] > w) { continue; }
    int nrest = rest ^ use;
    int cost = abs(s - f) + abs(f - t);
    ret = min(ret, calc(t, f, t, nrest) + cost);
  }
  return memo[rest] = ret;
}

int main() {
  while (scanf("%d %d %d", &n, &m, &w) > 0) {
    m--;
    int cnt = 0;
    vector<int> fs;
    fs.push_back(0);
    REP(i, n) {
      int k;
      scanf("%d", &k);
      if (i != 0 && k > 0) {
        fs.push_back(i);
      }
      REP(j, k) {
        if (i == 0) { scanf("%*d"); continue; }
        pos[cnt] = i;
        scanf("%d", &weight[cnt++]);
      }
    }
    reverse(fs.begin(), fs.end());
    MEMSET(sum, 0);
    MEMSET(upper, 0);
    MEMSET(lower, 0x0f);
    n = cnt;
    REP(i, 1 << n) {
      REP(j, n) {
        if (i & (1 << j)) {
          sum[i] += weight[j];
          upper[i] = max(upper[i], pos[j]);
          lower[i] = min(lower[i], pos[j]);
        }
      }
    }
    int ans = 0;
    int prev = m;
    REP(i, fs.size() - 1) {
      MEMSET(memo, -1);
      int target = 0;
      REP(j, n) {
        if (pos[j] >= fs[i]) { target |= 1 << j; }
      }
      ans += calc(prev, fs[i], fs[i + 1], target);
      prev = fs[i + 1];
    }
    cout << ans << endl;
  }
}

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

int main(){
  int N, A, B, C, X, y, ans;
  bool f, g;
  while (cin >> N >> A >> B >> C >> X, N) {
    ans = -1;
    int Y[N];
    g = true;
    for (int i = 0; i < N; ++i) cin >> Y[i];
    for (int i = 0; i < N; ++i) {
      y = Y[i];
      f = true;
      for (int j = ans+1; j < 10001; ++j) {
	if (X == y) {
	  f = false;
	  ans = j;
	  X = (A*X + B)%C;
	  break;
	} else {
	  X = (A*X + B)%C;
	}
      }
      if (f) {
	cout << -1 << endl;
	g = false;
	break;
      }
    }
    if (g) cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 2984