akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var n = int.Parse(spl[0]);
        var m = int.Parse(spl[1]);

        var list = new Point[n];
        for(int i=0; i<n; i++) {
            spl = input.ReadLine().Split(' ');
            var a = int.Parse(spl[0]);
            var b = int.Parse(spl[1]);
            list[i] = new Point(a, b);
        }

        var cp = new Point[m];
        for (int i = 0; i < m; i++) {
            spl = input.ReadLine().Split(' ');
            var a = int.Parse(spl[0]);
            var b = int.Parse(spl[1]);
            cp[i] = new Point(a, b);
        }

        for(int i=0; i<n; i++) {
            long min = long.MaxValue;
            int minidx = 999;

            for(int j=0; j<m; j++) {
                var man = list[i];
                var po = cp[j];
                long h = Math.Abs(man.x-po.x) + Math.Abs(man.y - po.y);
                if(h < min) {
                    min = h;
                    minidx = j;
                }
            }

            Console.WriteLine(minidx+1);
        }

        return null;
    }

    class Point : IEquatable<Point>
    {
        public int x;
        public int y;

        public Point() {
        }
        public Point(int x, int y) {
            this.x = x;
            this.y = y;
        }
        public bool Equals(Point other) {
            return x == other.x && y == other.y;
        }
        public double Distance(Point other) {
            return Distance(this, other);
        }
        public static double Distance(Point a, Point b) {
            var xx = a.x - b.x;
            var yy = a.y - b.y;
            return Math.Sqrt(xx*xx + yy*yy);
        }
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n + 1);
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
        a[i] += a[i - 1];
    }
    int dif = numeric_limits<int>::max() / 10;
    for(int t = 1; t < n; ++t) {
        dif = min(dif, abs(a[n] - 2 * a[t]));
    }
    cout << dif << '\n';
}

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i)
    {
        cin >> A[i];
    }

    sort(A.begin(), A.end());

    cout << A[N - 1] - A[0] << endl;

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) cin >> vec.at(i);

  vector<int> R(N);
  for (int i = 0; i < N; i++) R.at(i) = vec.at(i);
  sort(R.begin(), R.end());

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (vec.at(i) != R.at(i)) ans++;
  }

  if (ans == 0 || ans == 2) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

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

for i in range(N + 1):
    if i == 0:
        l_list.append(2)
    elif i == 1:
        l_list.append(1)
    else:
        l_list.append(l_list[i - 1] + l_list[i - 2])
ans = l_list[-1]

print(ans)


Measured memory_bytes: 2940
fun main(args: Array<String>) {
        val input = read()
        println(countShift(input, 0))
    }

    fun read(): List<Int> {
        readLine() // Nを読み捨てる
        val input = readLine()
        return input!!.split(' ').map { Integer.parseInt(it) }
    }

    tailrec fun countShift(list: List<Int>, count: Int): Int {
        if (list.all { it % 2 == 0 })
            return countShift(list.map { it / 2 }, count + 1)
        else
            return count
    }

Measured memory_bytes: 38300
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int t = Integer.parseInt(sc.next());
		
		int []a = new int [t];
		
		int max =  0; 
		for(int i = 0 ; i < t ;i++) {
			a[i] = Integer.parseInt(sc.next());
			max = Math.max(max, a[i]);
		}
		
		if(t == 1) {
			System.out.println(n-1);
			return;
		}
		
		if(max <= (n+1)/2) {
			System.out.println(0);
		}
		else {
			System.out.println(max - (n -max) - 1);
		}
		
	}

}


Measured memory_bytes: 21972
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)

N, M = map(int, input().split())
v = [[] for _ in range(N+M)]
for i in range(N) :
    K, *L = map(int, input().split())
    for l in L :
        v[N+l-1].append(i)
        v[i].append(N+l-1)

visited = [False] * (N + M)
visited[0] = True
q = [0]

while q :
    cur = q.pop()
    for nex in v[cur] :
        if not visited[nex] :
            q.append(nex)
            visited[nex] = True

if sum(visited[:N]) == N :
    print('YES')
else :
    print('NO')

Measured memory_bytes: 69324
#include <stdio.h>
#define R register
#define ll long long
inline int read(){
	R int x; R bool f; R char c;
	for (f=0; (c=getchar())<'0'||c>'9'; f=c=='-');
	for (x=c^'0'; (c=getchar())>='0'&&c<='9'; x=(x<<3)+(x<<1)+(c^'0'));
	return f?-x:x;
}
#define MN 100005
int n,m,cnt[MN];
int main(){
	n=read(),m=read();
	while(m--) ++cnt[read()],++cnt[read()];
	for (R int i=1; i<=n; ++i) if (cnt[i]&1) return 0*puts("NO");
	puts("YES");return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  string col; //ひなあられの色
  int yell = 0; //黄色のひなあられがあるかないかの指標
  for(int i = 0; i < N; i++) {
    cin >> col;
    if(col == "Y") {
      yell ++;
    }
    else {
      continue;
    }
  }
  if(yell == 0) {
      cout << "Three" << endl;
    }else {
      cout << "Four" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {
    int n;
    string s;
    cin >> n >> s;

    int putFirst = 0;
    int putLast = 0;
    int nowCount = 0;

    rep(i, n) {
        if(s[i] == '(') {
            nowCount++;
        }
        else {
            nowCount--;
            if(nowCount == -1) {
                nowCount = 0;
                putFirst++;
            }
        }
    }
    putLast = nowCount;

    rep(i, putFirst) {
        cout << "(";
    }
    cout << s;
    rep(i, putLast) {
        cout << ")";
    }

    cout << 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 P = pair<int, int>;

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;
}

int main() {
  int n;
  cin >> n;
  int mem[n];
  rep(i, n) cin >> mem[i];

  ll total = 0;
  int high = 0;
  rep(i, n) {
    if (mem[i] > high) {
      high = mem[i];
    } else {
      total += high - mem[i];
    }
  }
  cout << total << endl;

  return 0;
}

Measured memory_bytes: 4436
N = int(input())
n = N
ans = []
for i in range(2,int(N**0.5)+1): # intに変換すること
    while(n%i==0):
        n //= i #  整数除算(//)を使うこと
        ans.append(i)
if n!=1:
    ans.append(n)
ans = [str(a) for a in ans]
ans = str(N)+": " + " ".join(ans)
print (ans)


Measured memory_bytes: 5640
A,B,C,K=map(int,input().split())
ans=0
if(K>0):
    if(K>A):
        K-=A
        ans+=A
    else:
        ans+=K
        K=0
#print(ans)
#print(K)
if(K>0):
    if(K>B):
        K-=B
    else:
        K=0
#print(ans)
#print(K)
if(K>0):
    if(K>C):
        K-=C
        ans-=C
    else:
        ans-=K
        K=0
print(ans)
#print(K)
#        


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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("fibsubseq.in","r",stdin)
#define write()         freopen("fibsubseq.out","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%llu",&n)
#define ull             unsigned long long int
#define endll           printf("\n")
#define pf              printf
#define pi              acos(-1.0)
#define eps             1e-10
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())

bool Check(unsigned int  N,int pos){return (bool)(N & (1LL<<pos));}
ll  Set(unsigned int N,int pos){    return N=N | (1LL<<pos);}
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MX 100005
#define mod  1000000007
#define mod1 1000000009
#define var    int ii,i,j,k,z=0,c=0,t,x,y,l,r,mid,m
//int dx[8]={0,0,1,1,-1,-1,1,-1};  //8 direction
//int dy[8]={1,-1,1,-1,1,-1,0,0};

ll n;
ll a[105],dp[105][100005];

ll fn(ll pos,ll m)
{
    if(pos==0)return m==0;
    ll &z=dp[pos][m];
    if(z!=-1)return z;
    z=0;
    for(ll i=0;i<=a[pos];i++)
    {
        if(m-i>=0)
        {
            z+=fn(pos-1,m-i);
            z%=mod;
        }
        else break;
    }
    return z;
}

int main()
{
    ll var;
    sfl(n);sfl(k);
    for(i=1;i<=n;i++)sfl(a[i]);
    //mem(dp,-1);
    //z=fn(n,k);
    dp[0][0]=1;
    for(i=1;i<=n;i++)
    {
        dp[i][0]=1;
        for(j=1;j<=k;j++)
        {
            dp[i-1][j]+=dp[i-1][j-1];
            dp[i-1][j]%=mod;
            dp[i][j]=dp[i-1][j];
            if(j-a[i]-1>=0)
            {
                dp[i][j]-=dp[i-1][j-a[i]-1];
                dp[i][j]+=mod;dp[i][j]%=mod;
            }
        }
    }
//    for(i=1;i<=n;i++)
//    {
//        for(j=0;j<=k;j++)
//        {
//            cout<<dp[i][j]<<" ";
//        }
//        endll;
//    }
    cout<<dp[n][k]<<endl;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;

int main()
{
  int n = 0;
  fscanf(stdin, "%d", &n);
  vector<int> heap(n + 5, 0);
  for (int i = 1; i <= n; ++i) {
    fscanf(stdin, "%d", &heap[i]);
  }
  for (int i = 1; i <= n; ++i) {
    fprintf(stdout, "node %i: key = %d, ", i, heap[i]);
    if (i / 2 > 0) {
      fprintf(stdout, "parent key = %d, ", heap[i / 2]);
    }
    if (2 * i <= n) {
      fprintf(stdout, "left key = %d, ", heap[2 * i]);
    }
    if (2 * i + 1 <= n) {
      fprintf(stdout, "right key = %d, ", heap[2 * i + 1]);
    }
    fprintf(stdout, "\n");
  }
  return 0;
}

Measured memory_bytes: 1200
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair





int main(){
    ll n;
    cin>>n;
    vector<vector<ll>> e(n);
    for(int i=0;i<n-1;i++){
        ll a,b;
        cin>>a>>b;
        a--; b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    vector<ll> sv(n),fv(n);
    for(int i=0;i<n;i++){
        sv[i]=E;
        fv[i]=E;
    }
    queue<ll> q;
    fv[0]=0;
    q.push(0);
    while(!q.empty()){
        ll w=q.front();
        q.pop();
        for(int t=0;t<e[w].size();t++){
            if(fv[e[w][t]]==E){
                fv[e[w][t]]=fv[w]+1;
                q.push(e[w][t]);
            }
        }
    }
    sv[n-1]=0;
    q.push(n-1);
    while(!q.empty()){
        ll w=q.front();
        q.pop();
        for(int t=0;t<e[w].size();t++){
            if(sv[e[w][t]]==E){
                sv[e[w][t]]=sv[w]+1;
                q.push(e[w][t]);
            }
        }
    }
    ll count=0;
    for(int i=0;i<n;i++){
        if(fv[i]<=sv[i]){count++;}
        else{count--;}
    }
    //cout<<count<<endl;
    if(count<=0){cout<<"Snuke"<<endl;}
    else{cout<<"Fennec"<<endl;}
    
    
    
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  
  if(S.at(5) == '1'){
    cout << "TBD" << endl;
  }
  
  else if(S.at(6) == '1' || S.at(6) == '2' || S.at(6) == '3' || S.at(6) == '4'){
    cout << "Heisei" << endl;
  }
  
  else{
  cout << "TBD" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};
int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        int H, W;
        cin >> W >> H;
        if(H == 0 && W == 0) break;
        string field[21];
        i_i start;
        for(int i = 1; i <= H; i++) {
            cin >> field[i];
            field[i] = "&" + field[i];
            for(int w = 1; w <= W; w++) {
                if(field[i][w] == '@') start = {i, w};
            }
        }
        queue<i_i> que;
        que.push(start);
        int ans = 0;
        while(!que.empty()) {
            i_i now = que.front();
            que.pop();
            int h = now.first;
            int w = now.second;
            //cerr << h << " " << w << endl;
            if(field[h][w] == '#') continue;
            ans++;
            field[h][w] = '#';
            for(int k = 0; k < 4; k++) {
                int newh = h + dh[k];
                int neww = w + dw[k];
                if(neww <= 0 || neww > W || newh > H || newh <= 0) continue;
                if(field[newh][neww] == '#') continue;
                que.push({newh, neww});
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define pb push_back
#define ppb pop_back
#define vi vector<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define ren(i,n) for(int i=n-1;i>=0;i--)
#define iter(it,v) for(auto it:v)
#define iterp(it,v) for(auto it=v.begin(),it!=v.end();it++)
#define itern(it,v) for(auto it=v.rbegin();it!=v.rend();it++)
#define w(n) while(n--)
#define forp(i,a,b) for(int i=a;i<=b;i++)
#define forn(i,a,b) for(int i=a;i>=b;i--)
#define sc(a) scanf("%d",&a)
#define pf(a) printf("%d",a)
#define init(a,r) for(auto&i:a) i=r;
#define inpt(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define inp(a) for(int&i:a) cin>>i;
#define diss(a) for(int i:a) cout<<i<<' ';
#define disn(a) for(int i:a) cout<<i<<'\n';
#define debug(a) cout<<#a<<": ";for(auto i:a)cout<<i<<" ";cout<<'\n';
#define mpii map<int,int>
#define sii set<int>
#define ub upper_bound
#define lb lower_bound
#define bs binary_search
#define all(v) v.begin(),v.end()
#define bitc __builtin_popcount
#define fst ios::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define pq priority_queue
#define pii pair<int,int>
#define cs(a) cout<<a<<' '
#define cn(a) cout<<a<<'\n'
#define deb(a,b) cout<<a<<' '<<b<<endl;
#define yy "YES"
#define nn "NO"
#define ff first
#define ss second
typedef long long ll;
const int mod=1e9+7,mod1=998244353;
const int N=105,k=1e5+6;
int w[N],v[N],dp[N][k];
int n,W;
void a_b_l(){
    rep(i,N){
        rep(j,k)    
            dp[i][j]=INT_MAX;
    }
    cin>>n>>W;
    rep(i,n){
        cin>>w[i]>>v[i];
        dp[i][v[i]]=w[i];
    }
    forp(i,1,n-1){
        rep(j,k){
            dp[i][j]=min(dp[i-1][j],dp[i][j]);
            if(j<v[i])
                continue;
            dp[i][j]=min(dp[i][j],w[i]+dp[i-1][j-v[i]]);
        }
    }
    int ans=0;
    rep(i,n){
        rep(j,k){
            if(dp[i][j]<=W)
                ans=j;
        }
    }
    cn(ans);
}
signed main(){
    fst;
    int t=1;
    //cin>>t;
    w(t)
    	a_b_l();
}

Measured memory_bytes: 82432
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>

int main() {
  size_t n;
  intmax_t a, b;
  scanf("%zu %jd %jd", &n, &a, &b);

  std::vector<intmax_t> h(n);
  for (auto& hi: h) scanf("%jd", &hi);

  auto f = [&](intmax_t k) {
    auto h0 = h;
    for (auto& hi: h0) hi -= b*k;
    intmax_t a0 = a-b;
    intmax_t res = 0;
    for (auto hi: h0) {
      if (hi > 0) res += (hi+a0-1) / a0;
    }
    return res <= k;
  };

  intmax_t lb = -1;
  intmax_t ub = 1e9;
  while (ub-lb > 1) {
    intmax_t mid = (lb+ub) / 2;
    (f(mid)? ub: lb) = mid;
  }

  printf("%jd\n", ub);
}


Measured memory_bytes: 1792
/*マージソートは安定だから、それと比べる。*/
#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000
#define INFINITY 1000000001

struct Card{
  char suit;
  int value;
};

struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(struct Card A[], int left, int mid, int right){
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for(i = 0; i < n1; i++){
    L[i] = A[left + i];
  }
  for(i = 0; i < n2; i++){
    R[i] = A[mid + i];
  }
  L[n1].value = INFINITY;
  R[n2].value = INFINITY;
  i = 0;
  j = 0;
  for(k = left; k < right; k++){
    if(L[i].value <= R[j].value){
      A[k] = L[i++];
    }
    else{
      A[k] = R[j++];
    }
  }
}
void mergeSort(struct Card A[], int left, int right){
  int mid;
  if(left + 1 != right){
    mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}
int partition(struct Card A[], int p, int r){
  int i, j;
  struct Card x, temp;
  x = A[r];
  i = p - 1;
  for(j = p; j < r; j++){
    if(A[j].value <= x.value){
      i = i + 1;
      temp = A[i];
      A[i] = A[j];
      A[j] = temp;
    }
  }
  temp = A[i + 1];
  A[i + 1] = A[j];
  A[j] = temp;
  
  return i + 1;
}
void quickSort(struct Card A[], int n, int p, int r){
  int q;
  if(p < r){
    q = partition(A, p, r);
    quickSort(A, n, p, q - 1);
    quickSort(A, n, q + 1, r);
  }
}

int main(){
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%s %d" , &S[0], &v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
}

  mergeSort(A, 0, n);
  quickSort(B, n, 0, n - 1);

  for(i = 0; i < n; i++){
    if(A[i].suit != B[i].suit) stable = 0;
  }

  if(stable == 1) printf("Stable\n");
  else printf("Not stable\n");
  for(i = 0; i < n; i++){
    printf("%c %d\n", B[i].suit, B[i].value);
  }
  
  return 0;
}



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

int n;
int m;
vector<int> ve;
int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> m;
		ve.push_back(m);
	}
	int counter = 0;
	for(int i = 1; i < n-1;i++){
		if(max(max(ve[i-1],ve[i]),ve[i+1]) != ve[i] && min(min(ve[i-1],ve[i]), ve[i+1]) != ve[i]){
			counter++;
		}
	}
	cout << counter << "\n";
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;} 
int main(void)
{
  long double a,b;
  long c;
  scanf("%llf %llf",&a,&b);
  c=a*b;
  printf("%ld",c);
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    string s; cin >> s;
    i64 L = s.length();

    i64 mind = 10000;
    REP(i, L) {
        if (i + 2 >= L) break;
        i64 v = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0') * 1;
        chmin(mind, abs(753 - v));
    }
    cout << mind << endl;

    return 0;
}

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


int main()
{
	int n, k;
	string s;
	cin >> n >> k >> s;

	if (s[k - 1] == 'A') {
		s[k - 1] = 'a';
	} else if (s[k - 1] == 'B') {
		s[k - 1] = 'b';
	} else {
		s[k - 1] = 'c';
	}

	cout << s << endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>  
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod=1e9+7;
const ll longINF=3e18;
const double eps=1e-8;
const double dinf=190.0;
const double pi=acos(-1);
const int INF=2e9+1;

ll k,a[50];
        
int main() 
{        
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        //freopen("input.txt","r",stdin);
        //freopen("output.txt","w",stdout);
        cin>>k;
        cout<<"50\n";
        ll x=k/50,y=k%50;
        for (int i=0;i<y;i++)
                a[i]=100+x-y;
        for (int i=y;i<50;i++)
                a[i]=49+x-y;
        for (int i=0;i<50;i++) 
                cout<<a[i]<<" ";
        return 0;
}

Measured memory_bytes: 256
import sys
n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
for i in range(n):
    for j in range(m):
        a[i][j]-=1
itr=[0 for i in range(n)]
opend=[True for i in range(m)]
back=[[] for i in range(m)]
for i in range(n):
    back[a[i][0]].append(i)
ret=10**9
while True:
    tmp=0
    for i in range(m):
        tmp=max(tmp,len(back[i]))
    ret=min(ret,tmp)
    for i in range(m):
        if len(back[i])>=ret:
            opend[i]=False
            for j in range(len(back[i])):
                source=back[i][j]
                while not opend[a[source][itr[source]]]:
                    itr[source]+=1
                    if itr[source]==m:
                        print(ret)
                        sys.exit()
                back[a[source][itr[source]]].append(source)
            back[i]=[]


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

using namespace std;
int main()
{
    string a,b;
    cin >> a;
    cin >> b;

    string c = b.erase(b.size()-1);
    if(a==c){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}

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

void cint(int a){
    cout <<a<<endl;
}

int main(){
    int n;
    cin >>n;
    int x,sum=0,ssum=0;
    for(int i=0;i<n;i++){
        cin >>x;
        sum += x;
        ssum += x*x;
    }
    int p=(sum+(n/2))/n;
    int ans=n*p*p-2*sum*p+ssum;
    cint(ans);
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.chomp.split(" ").map{|i|i.to_i}
b = gets.chomp.split(" ").map{|i|i.to_i}
c = gets.chomp.split(" ").map{|i|i.to_i}
manzoku = 0
memo = -1
n.times do |m|
 manzoku += b[a[m]-1]
  if memo == a[m] then
    manzoku += c[a[m-1]-1]
  end
    memo = a[m] + 1
end
  
 puts manzoku

Measured memory_bytes: 1788
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC105C
{
    static class MainClass
    {

        public static void Main(string[] args)
        {


         
            int N = int.Parse(Console.ReadLine());

            if (N == 0)
            {
                Console.WriteLine("0");
                return;
            }
            int diff = N;
            var anslist = new List<int>();
            int anstmp = 0;
            while (diff != 0)
            {
                anstmp = GetInitial(diff);
                anslist.Add(anstmp);
                diff = diff - (int)Math.Pow(-2, anstmp);
                //Console.WriteLine("diff: " + diff.ToString() + "anstmp: " + anstmp.ToString());
            }

            string ans = "";
            int tmp = anslist.First();
            foreach(int item in anslist)
            {
                for(int i=0;i<tmp - item-1; i++)
                {
                    ans += "0";
                }
                ans += "1";
                tmp = item;
            }
            if(tmp > 0)
            {
                for(int i = 0; i < tmp; i++)
                {
                    ans += "0";
                }
            }
            Console.WriteLine(ans);


        }

        public static int GetInitial(int a)
        {

            long tmp = 0;
            if (a <0) {
                for(int i = 0; i < -a; i++)
                {
                    tmp = tmp + (int)Math.Pow(-2, 2 * i + 1);
                    if (a >= tmp)
                    {
                        return 2 * i + 1;
                    }
                }
            }else{
                for (int i = 0; i < a; i++)
                {
                    tmp = tmp + (int)Math.Pow(-2, 2 * i);
                    if (a <= tmp)
                    {
                        return 2 * i;
                    }
                }
            }

            return 0;
        }


        public static long Gcd(long a, long b)
        {
            long tmp;
            // a<bにする
            if (a >= b)
            {
                tmp = a;
                a = b;
                b = tmp;
            }

            if (a == 0)
            {
                return b;
            }

            tmp = a;
            a = b % a;
            b = tmp;
            return Gcd(a, b);

        }


        public static IEnumerable<long> PF(long n)
        {
            long i = 2;
            long tmp = n;

            while (i * i <= n) //※1
            {
                if (tmp % i == 0)
                {
                    tmp /= i;
                    yield return i;
                }
                else
                {
                    i++;
                }
            }
            if (tmp != 1) yield return tmp;//最後の素数も返す
        }




    }

}






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

int n, a[105], b[105], m, op[105];
int main() {
#ifdef LOCAL
    freopen("data.txt", "r", stdin);
#endif
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", a + i);
        b[i] = a[i];
    }
    for (int k = 0; k < n; ++k) {
        int i;
        for (i = n - 1; i >= 0; --i) {
            if (a[i] == 1) {
                break;
            }
        }
        if (i == -1) {
            printf("-1\n");
            return 0;
        }
        op[m++] = b[i];
        for (; i < n; ++i) --a[i];
    }
    for (int i = 0; i < m; ++i) printf("%d\n", op[i]);
}

Measured memory_bytes: 256
program main
  implicit none

  character,allocatable :: a(:)
  character(:),allocatable :: b, bb
  integer :: nb, i
  character(100) :: c

  read( *, * )  c                                                                                          
  b=trim(adjustl(c))
  nb = len(b)
  bb=repeat('x',nb)
  print *, bb

end program main

Measured memory_bytes: 640
// #pragma GCC optimize("no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC diagnostic ignored "-W"

#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<sstream>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<vector>
#include<utility>
#include<functional>
#include<complex>
#include<climits>
#include<random>
#include<thread>

#if __cplusplus >= 201103L
#include<unordered_map>
#include<unordered_set>
#include<tuple>
#endif

// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/rope>

using namespace std;
// using namespace __gnu_pbds;

#define ll long long
#define ld long double
#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vint vector<int>
#define vpii vector<pair<int,int>>
#define SS stringstream
#define PQ priority_queue
#define MS(x,v) memset((x),(v),sizeof(x))
#define RZUNI(x) sort(x.begin(),x.end()), x.resize(unique(x.begin(),x.end())-x.begin())
#define FLH fflush(stdout)
#define CPPinput ios_base::sync_with_stdio(0); cin.tie(0)
#define FIN(fname) freopen(fname,"r",stdin)
#define FOUT(fname) freopen(fname,"w",stdout)

#define tm Ovuvuevuevue
#define y1 Enyetuenwuevue
#define left Ugbemugbem
#define ws Osas
#define dec tetteterette
#define expl explexplexpl

#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl

#ifdef WEAK
#include"/home/edison/Coding/cpp/template/debug.cpp"
#define DEB(...) printf(__VA_ARGS__),fflush(stdout)
#define WHR() printf("%s: Line %d",__PRETTY_FUNCTION__,__LINE__),fflush(stdout)
#define LOG(...) printf("%s: Line %d ",__PRETTY_FUNCTION__,__LINE__),printf(__VA_ARGS__),fflush(stdout)
#define DEBUG 1
#define exit(x) cout<<"exit code "<<x<<endl, exit(0)
#else
#define PDE(...) ;
#define DEB(...) ;
#define WHR() ;
#define LOG(...) ;
#define DEBUG 0
#endif

#define lowbit(x) ((x)&(-(x)))

void JIZZ(string output=""){cout<<output; exit(0);}

const ld PI=3.14159265358979323846264338327950288;
const ld eps=1e-10;
const ll mod=1e9+7;


int main(){
    CPPinput;
    int n,x; cin>>n>>x;
    int g=0;
    int a; while(n--){
        cin>>a; a-=x;
        a=abs(a);
        g=__gcd(g,a);
    }
    cout<<g<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<iomanip>
#include<cstring>
#include<string>
#include<set>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll = long long int;

const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(void) {
    long double a, b, h, m;
    cin >> a >> b >> h >> m;
    long double thita1 = 2.0 * M_PI * (h / 12.0 + (m / 60.0) / 12.0), thita2 = 2.0 * M_PI * m / 60.0;
    cout << fixed << setprecision(10) <<sqrt(a * a + b * b - 2 * a * b * cos(thita1 - thita2)) << endl;
}

Measured memory_bytes: 4088
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();

		int[] h = new int[N];
		long[] dp = new long[N];
		for(int i=0;i<N;i++) {
			h[i] = sc.nextInt();
			dp[i] = Long.MAX_VALUE;
		}
		dp[0] = 0;
		dp[1] = Math.abs(h[1] - h[0]);

		for(int i=2;i<N;i++) {
			for(int j = Math.max(0, i-K);j<i;j++) {
				dp[i] = Math.min(dp[i], dp[j] + Math.abs(h[j] - h[i]));
			}
		}
		System.out.println(dp[N-1]);
	}
}


Measured memory_bytes: 50928
use std::io::*;
use std::str::*;
use std::cmp::*;

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

fn usize() -> usize {
    read()
}

fn vec_usize(n: usize) -> Vec<usize> {
    let mut vec = Vec::new();
    for _ in 0..n {
        vec.push(usize())
    }
    vec
}

fn main() {
    let ks = vec_usize(2);
    let k = ks[0];
    let s = ks[1];
    let mut result = 0;
    for k1 in 0..k + 1 {
        let s2 = s - k1;
        for k2 in 0..min(s2, k) + 1 {
            let k3 = s2 - k2;
            if k1 + k2 + k3 == s && k3 <= k {
                result += 1;
            }
        }
    }
    println!("{}", result);
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;
typedef long long ll;
ll n,m;
vector<int> g[100000];
int color[100000];
int a[100000],b[100000];
ll cnt1=0,cnt2=0;
bool dfs(int v,int c){
  color[v]=c;
  if(c>0) cnt1++;
  else cnt2++;
  for(int i=0;i<g[v].size();i++){
    if(color[g[v][i]]==c) return false;
    if(color[g[v][i]]==0&&!dfs(g[v][i],-c)) return false;
  }
  return true;
}
int main(){
  cin >> n >> m;
  for(int i=0;i<m;i++) cin >> a[i] >> b[i];
  for(int i=0;i<m;i++){
    g[a[i]-1].push_back(b[i]-1);
    g[b[i]-1].push_back(a[i]-1);
  }
  memset(color,0,sizeof(color));
  if(dfs(a[0]-1,1)) cout << cnt1*cnt2-m << "\n";
  else cout << n*(n-1)/2-m << "\n";
  
  return 0;
}




Measured memory_bytes: 7296
#include <cstdio>
#include <queue>
#include <cstring>

const int N = 1005;

int h , w , ans;
char ss[N][N];
int able[N][N];
int las_ans;
struct Node {
	int x , y;
};
std :: queue < Node > qu;

int dx[4] = { 0 , 0 , 1 , -1 };
int dy[4] = { 1 , -1 , 0 , 0 };

inline int max ( int x , int y ) {
	return x > y ? x : y;
}
inline void bfs () {
	while ( !qu.empty () ) {
		Node j = qu.front ();
		qu.pop ();
		for ( int i = 0 ; i < 4 ; i++ ) {
			int xx = j.x + dx[i];
			int yy = j.y + dy[i];
			if ( xx > h || xx < 1 || yy > w || yy < 1 || able[xx][yy] != -1 ) 
				continue;
			able[xx][yy] = able[j.x][j.y] + 1;;
			Node tmp;
			tmp.x = xx;
			tmp.y = yy;
			las_ans = max ( las_ans , able[xx][yy] );
			qu.push ( tmp );		
		}
	}
	return;
}

int main ( void ) {
	memset ( able , -1 , sizeof ( able ) );
	scanf ( "%d%d" , &h , &w );
	for ( int i = 1 ; i <= h ; i++ ) 
		scanf ( "%s" , ss[i] + 1 );
	for ( int i = 1 ; i <= h ; i++ ) 
		for ( int j = 1 ; j <= w ; j++ ) 
			if ( ss[i][j] == '#' ) {
				able[i][j] = 0;
				Node tmp;
				tmp.x = i;
				tmp.y = j;
				qu.push ( tmp );
			}
	bfs ();
	printf ( "%d\n" , las_ans  );
	return 0;
}

Measured memory_bytes: 13328
using System;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApp1 {
    public class Class1 {
        static void Main(string[] args) {
            var num = Console.ReadLine().Trim().Split(' ').Select(x => long.Parse(x)).ToArray();
            long[] tower = Console.ReadLine().Trim().Split(' ').Select(x => long.Parse(x)).ToArray();
            var ans = new int[num[0]];
            for (var i = 0; i < num[1]; i++) {
                var road = Console.ReadLine().Trim().Split(' ').Select(x => long.Parse(x) - 1).ToArray();
                if(tower[road[0]] < tower[road[1]]) {
                    ans[road[0]] = -1;
                }else if(tower[road[0]] == tower[road[1]]) {
                    ans[road[0]] = -1;
                    ans[road[1]] = -1;
                } else if(tower[road[0]] > tower[road[1]]) {
                    ans[road[1]] = -1;
                }
            }
            Console.Write(ans.Where(x => x >= 0).Count());
        }
    }
}

Measured memory_bytes: 49448
#include<stdio.h>
#define NUM 10
void hist(int);
int main()
{
int ice[NUM];
int i,n;
while(1)
{
scanf("%d",&n);
if(n==0) break;
for(i=0;i<NUM;i++) ice[i]=0;
for(;n>0;n--)
{
scanf("%d",&i);
ice[i]++;
}
for(i=0;i<NUM;i++) hist(ice[i]);
}
return 0;
}
void hist(int x)
{
if(x)
{
for(;x>0;x--) printf("*");
}
else printf("-");
printf("\n");
}

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

int const N = 100000;
int a[N + 1], an[N + 1], fr[N + 1], n;
set<pair<int, int> > st;
set<int> lft;

void rm(int t){
	lft.erase(t);
	st.erase(make_pair(fr[a[t]], a[t]));
	--fr[a[t]];
	st.insert(make_pair(fr[a[t]], a[t]));
}

void ad(int t){
	lft.insert(t);
	st.erase(make_pair(fr[a[t]], a[t]));
	++fr[a[t]];
	st.insert(make_pair(fr[a[t]], a[t]));
}

bool go(int i = 1, int bad = 0){
	if (i == n){
		int t = *lft.begin();
		if (t == bad)return false;
		an[i] = t;
		return true;
	}
	int m = n - i + 1;
	int t = st.rbegin()->second;
	if (fr[t] == m - 1 && lft.find(t) != lft.end()){
		an[i] = t;
		rm(t);
		bool ok = go(i + 1, a[t]);
		ad(t);
		return ok;
	}
	vector<int> v;
	int z = 5;
	for (auto it = lft.begin(); it != lft.end() && z; ++it, --z)v.push_back(*it);
	for (int u: v)if (bad != u){
		rm(u);
		an[i] = u;
		bool ok = go(i + 1, a[u]);
		ad(u);
		if (ok)return true;
	}
	return false;
}

int main(){
	scanf("%d", &n);
	if (n == 2){
		printf("-1\n");
		return 0;
	}
	f(i, 1, n + 1)scanf("%d", a + i), ++fr[a[i]];
	f(i, 1, n + 1)st.insert(make_pair(fr[i], i));
	f(i, 1, n + 1)lft.insert(i);
	go();
	printf("%d", an[1]);
	f(i, 2, n + 1)printf(" %d", an[i]);
	printf("\n");
}

Measured memory_bytes: 22272
// D - Replacing
#include <bits/stdc++.h>
using namespace std;

const int MX = 100005;

int main(){
    long long n;
    cin >> n;
    vector<long long> cnt(MX);
    for(int i=0; i<n; i++){
        int a; cin >> a;
        cnt[a]++;
    }
    long long ans = 0;
    for(int i=0; i<MX; i++) ans += i*cnt[i];

    int q;
    cin >> q;
    for(int i=0; i<q; i++){
        int b, c;
        cin >> b >> c;
        ans -= b*cnt[b];
        ans -= c*cnt[c];
        cnt[c] += cnt[b]; cnt[b] = 0;
        ans += b*cnt[b];
        ans += c*cnt[c];
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 4056
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]
T = [0] * N
for i in range(M):
    if H[AB[i][0] - 1] == H[AB[i][1]-1]:
        T[AB[i][0] - 1] = 1
        T[AB[i][1] - 1] = 1
    else:
        if H[AB[i][0] - 1]>H[AB[i][1]-1]:
            T[AB[i][1] - 1] = 1
        else:
            T[AB[i][0] - 1] = 1
print(T.count(0))

Measured memory_bytes: 31884
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, m, i, j, k, ans, x, v;
	cin >> n >> m;
	vector<string> s(n);
	for (i = 0; i < n; i++) cin >> s[i];

	vector<vector<vector<int>>> dp(n, vector<vector<int>>(m, vector<int>(2, 10000000)));

	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			if (i + j == 0) {
				if (s[0][0] == '.') {
					dp[0][0][0] = 0;
					dp[0][0][1] = 1;
				}
				else {
					dp[0][0][0] = 1;
					dp[0][0][1] = 1;
				}
			}
			else {
				if (s[i][j] == '.') {
					x = 0;
					if (i > 0) dp[i][j][0] = min(dp[i][j][0], min(dp[i - 1][j][0], dp[i - 1][j][1]));
					if (j > 0) dp[i][j][0] = min(dp[i][j][0], min(dp[i][j - 1][0], dp[i][j - 1][1]));

					if (i > 0) dp[i][j][1] = min(dp[i][j][1], min(dp[i - 1][j][0] + 1, dp[i - 1][j][1] + 1));
					if (j > 0) dp[i][j][1] = min(dp[i][j][1], min(dp[i][j - 1][0] + 1, dp[i][j - 1][1] + 1));
				}
				else {
					x = 1;
					if (i > 0) dp[i][j][0] = min(dp[i][j][0], min(dp[i - 1][j][0] + 1, dp[i - 1][j][1]));
					if (j > 0) dp[i][j][0] = min(dp[i][j][0], min(dp[i][j - 1][0] + 1, dp[i][j - 1][1]));

					if (i > 0) dp[i][j][1] = min(dp[i][j][1], min(dp[i - 1][j][0] + 1, dp[i - 1][j][1]));
					if (j > 0) dp[i][j][1] = min(dp[i][j][1], min(dp[i][j - 1][0] + 1, dp[i][j - 1][1]));
				}
			}
		}
	}

	ans = min(dp[n - 1][m - 1][0], dp[n - 1][m - 1][1] + 1);
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N);
  VEC(ll, A, N);
  char t = '-';
  int ans = 1;
  rep(i, 0, N - 1) {
    if (t == '>') {
      if (A[i + 1] < A[i]) {
        ans++;
        t = '-';
      }
    } else if (t == '<') {
      if (A[i + 1] > A[i]) {
        ans++;
        t = '-';
      }
    } else {
      if (A[i + 1] > A[i]) {
        t = '>';
      } else if (A[i + 1] < A[i]) {
        t = '<';
      }
    }
  }
  print(ans);
}


Measured memory_bytes: 1024
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String t = sc.next();
    int a = sc.nextInt();
    int b = sc.nextInt();
    String u = sc.next();
    if(u.equals(s)){
      System.out.print(a-1);
      System.out.println(" "+b);
    }else{
      System.out.print(a+" ");
      System.out.println(b-1);
    }
  }
}


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

struct Point { double x, y; };

//koch関数を呼び出すことで頂点s,t,uを求める
void koch(int n, Point a, Point b) {
    if ( n == 0 ) return;
    
    Point s, t, u;
    double th = M_PI * 60.0 / 180.0;  //度からラジアンへ単位を変更、M_PI=円周率
    
    //三角形の頂点を求める(ベクトル演算、回転行列)
    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;
    
    koch(n - 1, a, s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch(n - 1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch(n - 1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch(n - 1, t, b);
}

int main() {
    Point a, b;
    int n;
    
    scanf("%d", &n);
    
    //端点の初期値
    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;
    
    //小数点以下の桁数を8桁以下に設定
    printf("%.8f %.8f\n", a.x, a.y);
    koch(n, a, b);
    printf("%.8f %.8f\n", b.x, b.y);
    
    return 0;
}


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;
const int M=1e9 + 7;

int32_t main()
{
	IOS;
	//memset(dp,-1,sizeof(dp));	
	int T;
	T = 1;
	while(T--)
	{
		string s;
		cin >> s;
		for(char c:s)
		{
			if(c=='?')
				cout << "D";
			else
				cout << c;
		}
	}
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define Pi 3.14159265358979323846

using llong = long long;
using namespace std;


int main(){
    double a,b,h,m;
    double ans;
    cin >> a >> b >> h >> m;
    double coh = cos((h+m/60)*Pi/6),sih = sin((h+m/60)*Pi/6),com = cos((m*Pi)/30),sim = sin((m*Pi)/30);
    double x=a*sih,y=a*coh,c=b*sim,d=b*com;
    
    ans = sqrt((c-x)*(c-x)+(d-y)*(d-y));
    
    cout << std::fixed << std::setprecision(15) << ans << endl;
}

Measured memory_bytes: 4128
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1000000007, INF = 1e9;

int main()
{
    string s;
    cin >> s;
    rep(i, s.size()){
        cout << "x";
    }
    cout << endl;
    system("pause");
}

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

bool isPrime(int n) {
    if (n < 2) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;
    else {
        for (int i = 3; i * i < n; i += 2) {
            if (n % i == 0) return false;
        }
        return true;
    }
}

int main() {
    ll N, P;
    cin >> N >> P;

    map<ll, ll> div_counts;
    if (N == 1 || isPrime(P)) {
        div_counts[P] = 1;
    } else {
        for (ll i = 1; i * i <= P; i++) {
            if (isPrime(i)) {
                div_counts[i] = 0;
                while (P % i == 0) {
                    div_counts[i]++;
                    P /= i;
                }
            }
        }
    }

    ll ans = 1;
    for (auto& it : div_counts) {
        if (it.second >= N) 
            ans *= pow(it.first, it.second / N);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
//D - Redistribution
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>

#define LL long long
#define Cl(X,Y) memset((X),(Y),sizeof(X))
#define FOR(i,A,B) for(LL i=A;i<=B;i++)
#define BOR(i,A,B) for(LL i=A;i>=B;i--)
#define INF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
using namespace std;
LL read() {
	int x = 0,f = 0;char ch = getchar();
	while(!isdigit(ch)) {if(ch=='-')f=1;ch=getchar();}
	while(isdigit(ch)) {x = x * 10 + ch - '0';ch = getchar();}
	return f?-x:x;
}

const int N = 1e6 + 10,inf = 1e9 + 7;
int n,f[N];
int main()
{
	n = read();
	f[0] = 1;
	for(int i = 1;i <= n;i++) {
		for(int j = 3;j <= i;j++) {
			(f[i]+=f[i-j])%=inf;
		}
	}
	cout << f[n] << endl;
}


Measured memory_bytes: 3596
import sys

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


def main():
    N, R = map(int, readline().split())

    if N >= 10:
        print(R)
    else:
        print(R + 100 * (10 - N))

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 61924
#include<iostream>
#include<string>
using namespace std;
int main() {
    int n = 0;
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < s.size() - t.size() + 1; i++) {
        int m = 0;
        for (int j = 0; j < t.size(); j++) {
            char a = s[j + i], b = t[j];
            if (a == b)m++;
        }
        if (n < m) n = m;
    }
    n = t.size() - n;
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 3628