akhauriyash/Code-Regression huggingface dataset:
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    for (auto e: v) os << e << ",";
    os << "]";
    return os;
}

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

// print floating-point number
// cout << fixed << setprecision(12) <<

// }}}

int H, N;
int a[1010], b[1010];
int dp[1010][10010];

void solve()
{
    REP (i, N+1) REP (j, H+1) dp[i][j] = INF;
    dp[0][0] = 0;
    REP (i, N) {
        REP (j, H+1) {
            dp[i+1][j] = dp[i][j];
            dp[i+1][j] = min(dp[i+1][j], (j >= a[i] ? dp[i+1][j-a[i]] : 0) + b[i]);
        }
    }
    cout << dp[N][H] << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> N;
    REP (i, N) cin >> a[i] >> b[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 39424
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int[] num_arr = { 0, 0, 0 };

            // 標準入力読み込み
            for (int i = 0; i < num_arr.length; i++) {
                num_arr[i] = sc.nextInt();
            }

            // ソート
            for (int i = 0; i < num_arr.length - 1; i++) {
                for (int j = num_arr.length -1 ; j > i; j--) {
                    if (num_arr[j] < num_arr[j - 1]) {
                        int buf = num_arr[j];
                        num_arr[j] = num_arr[j - 1];
                        num_arr[j - 1] = buf;
                    }
                }
            }

            // 結果出力
//            for (int num : num_arr) {
//            	System.out.println(num + " ");
//            }
            System.out.println(num_arr[0] + " " + num_arr[1] + " " + num_arr[2]);
        }
    }
}


Measured memory_bytes: 26204
n,k,c=map(int,input().split())
s=input()
l=[0]*k
r=[0]*k
ld=0
rd=n-1
for i in range(k):
    j=k-1-i
    while s[ld]=='x':
        ld+=1
    while s[rd]=='x':
        rd-=1
    l[i]=ld
    ld+=1+c
    r[j]=rd
    rd-=1+c
for i in range(k):
    if l[i]==r[i]:
        print(l[i]+1)

Measured memory_bytes: 20628
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll A, B, C, K;

int main() {

	cin >> A >> B >> C >> K;

	if (K <= A)
		cout << K << endl;
	else if (K <= A + B)
		cout << A << endl;
	else
		cout << A - (K - A - B) << endl;

	return 0;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int N, M;
        cin >> N >> M;
        N++;
        vector<Int> P(M);
        vector<string> S(M);
        for (int i = 0; i < M; ++i) {
            cin >> P[i] >> S[i];
        }

        vector<bool> used(N, false);
        vector<Int> wa(N);

        int ac = 0;
        for (int i = 0; i < M; ++i) {
            if (S[i] == "AC") {
                if (!used[P[i]]) {
                    used[P[i]] = true;
                    ac++;
                }
            } else {
                if (!used[P[i]]) {
                    wa[P[i]]++;
                }
            }
        }

        int swa = 0;
        for (int i = 0; i < N; ++i) {
            swa += wa[i] * used[i];
        }

        cout << ac << " " << swa << endl;


    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 4224
# -*- coding: utf-8 -*-
from collections import deque

s = list(input())

ans = deque()
for i in s:
    if i == "0":
        ans.extend("0")
    elif i == "1":
        ans.extend("1")
    else:
        if len(ans) == 0:
            pass
        else:
            ans.pop()

#print(ans)

print("".join(ans))


Measured memory_bytes: 3316
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30


def make_adj_list():
    n, E = map(int, input().strip().split()) # 頂点の数
    l = [[] for _ in range(n)] # 隣接リスト. 各要素は(コスト、to_node)
    for i in range(E):
        s, t = map(int, input().strip().split())
        l[s].append(t)
        l[t].append(s)

    return l, n, E

G = []
prenum = []
parent = []
lowest = []
order = 1
visited = []

def dfs(v, fr):
    global G, prenum, parent, lowest, order, visited
    visited[v] = True
    prenum[v] = lowest[v] = order
    order += 1
    
    for node in G[v]:
        if not visited[node]:
            parent[node] = v
            dfs(node, v)
            lowest[v] = min(lowest[v], lowest[node]) # DFS Treeの子
        elif node != fr:
            lowest[v] = min(lowest[v], prenum[node]) # back edge


def main():
    global G, prenum, parent, lowest, visited
    ans = set()
    G, n, e = make_adj_list()
    prenum = [INF] * n
    parent = [INF] * n
    lowest = [INF] * n
    visited = [False] * n
    dfs(0, -1)

    c = 0
    for i in range(1, n):
        p = parent[i]
        if p == 0:
            c += 1
        elif prenum[p] <= lowest[i]:
            ans.add(p)
    if c >= 2:
        ans.add(0)
    ans = sorted(list(ans))
    for i in ans:
        print(i)


if __name__ == '__main__':
    main()



Measured memory_bytes: 19372
using System;
using System.Linq;

namespace ConsoleApp21
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] line = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int N = line[0];
            int M = line[1];
            int[] rtn = new int[N];

            for (int i = 0; i < M; i++)
            {
                int[] Douro = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                rtn[Douro[0] - 1] += 1;
                rtn[Douro[1] - 1] += 1;
            }

            for (int i = 0; i < N; i++)
            {
                Console.WriteLine(rtn[i]);
            }
        }


    }

}


Measured memory_bytes: 13268
#include <iostream>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define per(i, a, b) for(int i = a; i > b; --i)
#define ll long long

int main(){
  ll d, g;
  cin >> d >> g;

  ll p[10], c[10];
  rep(i, d) cin >> p[i] >> c[i];
  
  ll ans = 1e9;
  rep(i, 1 << d) {
    ll point = 0, cnt = 0;
    rep(j, d) {
      if ((i >> j) & 1) {
        point += p[j] * (j + 1) * 100 + c[j];
        cnt += p[j];
      }
    }
    per(j, d-1, -1) {
      if ((i >> j) & 1) continue;
      int ccnt = 0;
      while (point < g && ccnt + 1 < p[j]){
        point += (j + 1) * 100;
        ++ccnt;
        ++cnt;
      }
    }
    if (point >= g) {
      ans = min(ans, cnt);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
const int INF = 1000000000;

int main()
{
	long n;
	long a;
	long sum = 0;
	long sumb = 0;
	long h[100005] = { 0 };
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> h[i];
		sum += h[i];
		if (i % 2 == 0)sumb+=h[i];
	}
	h[0] = sum - 2 * sumb;
	cout << h[0] << endl;
	for (int i = 1; i <= n-1; i++) {
		h[i] = 2*h[i] - h[i-1];
		cout << h[i] << endl;
	}
}

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

int main()
{
	int ans;
	char s;
	for (int i = 0; i < 3; ++i) {
		cin >> s;
		if (s == 'o') {
			++ans;
		}
	}

	cout << 700 + ans * 100 << endl;
}



Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

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

	int n;
	cin >> n;
	vector<int> a(n);
	for (auto &t : a) {
		cin >> t;
	}
	int S = 0;
	for (auto t : a) {
		S += t;
	}
	int c = 0;
	int ans = S;
	for (int i = 0; i <= n; i++) {
		ans = min(ans, abs(S - 2 * c));
		if (i < n) {
			c += a[i];
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 4356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int n, l;
    cin >> n >> l;
    
    vector<string> v(n);
    for(int i = 0; i < n; i++)
        cin >> v[i];
    sort(v.begin(), v.end());
    string ans = "";
    for(auto s:v)
        ans += s;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;

int N, M;

int main() {
    cin >> N >> M;
    vector<pair<long long, int>> drink(N);
    for (int i = 0; i < N; i++) {
        cin >> drink[i].first >> drink[i].second;
    }
    sort(drink.begin(), drink.end());
    long long cost = 0;
    for (int i = 0; i < N; i++) {
        if (drink[i].second >= M) {
            cost += drink[i].first * M;
            break;
        }
        cost += drink[i].first * drink[i].second;
        M -= drink[i].second;
    }
    cout << cost << endl;
}



Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(void){

  ll n;
  cin>>n;
  vector<ll> a(n);
  vector<ll> b(n,0);

  ll sum=0;

  ll _min=INF;

  ll neg=0;

  rep(i,n){
    cin>>a[i];
    sum+=abs(a[i]);
    if(a[i]<0) neg++;
    _min=min(_min,abs(a[i]));
  }

  //cout << _min << endl;

  if(neg%2==0) cout << sum << endl;
  else cout << sum- 2*_min<< endl;

  return 0;

}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
  int n,i,flag=1;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  for(i=1;i<n;i++){
    if(a[i-1]>a[i]){
      if(a[i-1]-a[i]>1){
        flag=0;
        break;
      }
      a[i]++;
    }
  }
  if(flag)
    cout<<"Yes\n";
  else
    cout<<"No\n";
  
  return 0;
}

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

int main(){
    double N;
    cin >> N;
    double p = 0.0;
    vector<float> X(N);
    double sum = 0.0;
    for (int i=0; i<N; i++){
        cin >> X.at(i);
        sum += X.at(i);
    }
    p = sum / N;
    int p1 = (int) p;
    int p2 = (int) p + 1;

    int sum1, sum2 = 0;
    for (int i=0; i<N; i++){
        sum1 += pow(X.at(i) - p1,2);
        sum2 += pow(X.at(i) - p2,2);
    }
    cout << min(sum1, sum2) << endl;
}

Measured memory_bytes: 3696
h, w = [int(i) for i in input().split()]
s = []
for i in range(h):
    s.append(list(input()))

t = [['#']*w for _ in range(h)]
dh = (-1, -1, -1, 0, 0, 1, 1, 1)
dw = (-1, 0, 1, -1, 1, -1, 0, 1)
for i in range(h):
    for j in range(w):
        if s[i][j] != '#':
            cnt = 0
            for y, x in zip(dh, dw):
                if 0 <= i+y < h and 0 <= j+x < w:
                    if s[i+y][j+x] == '#':
                        cnt += 1
            t[i][j] = str(cnt)

for l in t:
    print(''.join(l))


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();
		int count = 0;

		for(int i = 0; i < s.length; i++) {
			count += s[i] == t[i] ? 1 : 0;
		}

		System.out.println(count);
	}
}

Measured memory_bytes: 35356
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'

const int N = 1e7 + 11;
int f[N];

int32_t main() {
	ios_base::sync_with_stdio(NULL);
	cin.tie(nullptr), cout.tie(nullptr);

	int n; cin >> n;
	int sum = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; i * j <= n; j++) {
			f[i * j]++;
		}
		sum += i * f[i];
	}
	cout << sum << endl;
}

Measured memory_bytes: 81728
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define ll long long
const ll mod=998244353;
const int maxn=3005;
ll pre[maxn],now[maxn];
int main()
{
    ll a,b,c,d;
    scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
    ll row=c-a,col=d-b;
    now[0]=1;
    for(ll i=0;i<=row;i++)
    {
        for(ll j=0;j<=col;j++)
        {
            if(i&&j)
                now[j]=(pre[j]*(j+b)%mod+now[j-1]*(i+a)%mod-(a+i-1)*(b+j-1)%mod*pre[j-1]%mod+mod)%mod;
            else if(i)
                now[j]=pre[j]*(j+b)%mod;
            else if(j)
                now[j]=now[j-1]*(i+a)%mod;
        }
        for(ll j=0;j<=col;j++)
            pre[j]=now[j];
    }
    printf("%lld\n",pre[col]);
    return 0;
}


Measured memory_bytes: 3840
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<string>
#include<cstring>
#include<map>
#include<tuple>
#include<algorithm>

using namespace std;

#define REP(i, n) for(int i=0;i<(int)n;i++)
#define REPS(i, n) for(int i=1;i<=(int)n;i++)
#define RREP(i, n) for(int i=n-1;i>=0;i--)
#define RREPS(i, n) for(int i=n;i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define pb push_back
#define eb emplace_back
#define endl '\n'
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
enum DIR { LEFT, RIGHT, FRONT, BACK, BOTTOM, TOP };
int rotm[4][6]={
	{5,4,2,3,0,1},
	{0,1,5,4,2,3},
	{0,1,4,5,3,2},
	{4,5,2,3,1,0}
};

struct Dice{
	vi d, x;
	Dice(vi d):d(d), x(6){
		
	}
	
	inline int &operator[](int i){
		return d[i];
	}
	
	inline void rot(int k){
		REP(i, 6) x[rotm[k][i]] = d[i];
		swap(d, x);
	}
	
	
	inline int check(){
		if(d[BOTTOM] == -1) return 0;
		if(d[BOTTOM] + d[TOP] > d[LEFT] + d[RIGHT] + d[FRONT] + d[BACK]) return 0;
		if(d[LEFT] + d[RIGHT] > d[BOTTOM] + d[TOP] + d[FRONT] + d[BACK]+1) return 0;
		if(d[FRONT] + d[BACK] > d[BOTTOM] + d[TOP] + d[LEFT] + d[RIGHT]+1) return 0;
		return 1;
	}
	
};
int n;
string db = "ENSW";
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	while(1){
		vi t(6);
		REP(i, 6) cin >> t[i];
		sort(ALL(t));
		if(t[5] == 0) break;
		int n = accumulate(ALL(t), 0);
		string ans(n, 'Z');
		do{
			Dice dice(t);
			string tmp;
			int f = 0;
			REP(itr, n){
				REP(i, 4){
					dice.rot(i);
					dice[BOTTOM] --;
					if(dice.check()){
						tmp.pb(db[i]);
						break;
					}
					dice[BOTTOM] ++;
					dice.rot(3-i);
				}
				if(tmp.size() != itr+1) break;
				if(!f && ans[itr] < tmp[itr]) continue;
				f |= ans[itr] > tmp[itr];
			}
			if(tmp.size() == n) ans = min(ans, tmp);
		}while(next_permutation(ALL(t)));
		int p, q;
		cin >> p >> q; p--;
		if(ans[0] == 'Z') cout << "impossible" << endl;
		else cout << ans.substr(p, q-p) << endl;
	}
}

Measured memory_bytes: 1360
#include<bits/stdc++.h>
using namespace std;
char a[55],b[55];
int l;
int main()
{
    scanf("%s%s",a,b);
    l=strlen(b); 
    for(int i=0;i<l;i++) printf("%c%c",a[i],b[i]);
    if(strlen(a)>strlen(b)) printf("%c",a[l]); 
    printf("\n"); 
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int d, a ;
		double x = 0, y = 0;
		double theta = 0;
		Scanner scn = new Scanner(System.in);
		while (true) {
			scn.useDelimiter(",|" + System.lineSeparator());
			d = scn.nextInt();
			a = scn.nextInt();
			if (a == 0 && d == 0)
				break;
			x += Math.sin(theta / 180 * Math.PI) * d;
			y += Math.cos(theta / 180 * Math.PI) * d;
			theta += a;
		}
		System.out.println( (int)x);
		System.out.println((int)y);
	}
}

Measured memory_bytes: 25968
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 500005;

char c;

int main() {
scanf("%c", &c);
printf("%c", char(c + 1));
}





Measured memory_bytes: 256
/*
我的心脏怦怦跳，监管者就在附近
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
int a[10005];
int main()
{
	int x;
	cin>>x;
	string st;
	cin>>st;
	int i;
	for(i=0;i<st.size();++i)
	{
		a[i]=st[i]-65;
		a[i]+=x;
		a[i]%=26;
		a[i]+=65;
	}
	for(i=0;i<st.size();++i){
		cout<<char(a[i]); 
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,q;cin>>n>>k>>q;
  vector<int>p(n);
  for(int i=0;i<q;i++){
    int a;cin>>a;a--;
    p.at(a)++;
  }
  for(int i=0;i<n;i++){
    if(p.at(i)>q-k)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define V vector
#define L long long
#define W V<L>
#define R(n)for(L i=0;i<n;i++)
L E=70;W S(V<W>p){if(!E){return{1,0};}V<V<W>>T(2);for(W x:p){T[x[1]&1].push_back({x[0]/2,x[1]/2});if(x[0]&1){T[(x[1]+1)&1].push_back({x[0]/2,(x[1]+1)/2});}}R(2){L c=0;for(W x:T[!i]){L Q=(2*x[0]+x[1])%3;c^=Q+1;}if(!c){E--;W A=S(T[i]);A[0]*=2;A[1]*=2;A[1]+=i;return A;}}for(W&v:p){v[0]++;}W A=S(p);A[0]--;return A;}int main(){L M=2e17,n;cin>>n;V<W>p(n);R(n){L a,b;cin>>a>>b;p[i]={a+M,b+M};}W x=S(p);cout<<x[0]-M<<" "<<x[1]-M;}

Measured memory_bytes: 62908
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
struct C { int num; int cards[9]; };

int buf[9];
C rgb[3];
bool taken[10];

bool try_to_take(const int& t, int* cards, int pos) {
  while (true) {
    while (taken[pos]) pos++;
    int& v = cards[pos];
    if (v == t) {
      taken[pos] = true;
      return true;
    } else if (v > t){
      return false;
    }
    pos++;
  }
}

bool validity_of(int* cards, const int& num) {
  memset(taken, false, sizeof(taken));
  sort(cards, cards + num);
  int i = 0;
  while (i < num) {
    if (cards[i] == cards[i + 1] && cards[i] == cards[i + 2]) {
      taken[i + 2] = taken[i + 1] = taken[i] = true;
    } else {
      taken[i] = true;
      if (!try_to_take(cards[i] + 1, cards, i) || !try_to_take(cards[i] + 2, cards, i)) return false;
    }
    while (taken[i]) i++;
  }
  return true;
}

int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    for (auto&& x : rgb) x.num = 0;
    for (int j = 0; j < 9; j++) cin >> buf[j];
    for (int j = 0; j < 9; j++) {
      char c;
      cin >> c;
      C &x = rgb[c == 'R' ? 0 : c == 'G' ? 1 : 2];
      x.cards[x.num++] = buf[j];
    }
    cout << (int)(all_of(rgb, rgb + 3, [](C& x){ return x.num % 3 == 0; }) &&
                  all_of(rgb, rgb + 3, [](C& x){ return validity_of(x.cards, x.num); })) << endl;
  }
  return 0;
}

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

using namespace std;
const int MAXN = 5 * 1e5 + 5;
int n,q,x,y,arr[MAXN],ans[MAXN],t[MAXN],last[MAXN];

struct Q{
	int x,y,i;
};

void update(int i, int v){
	for(;i<=n;i += i&-i)
		t[i] += v;
}

int query(int r){
	int sum = 0;
	for(;r>0;r-=r&-r)
		sum += t[r];
	return sum;
}

bool cmp(Q q1,Q q2){return q1.y < q2.y;}


int main(){
	memset(last,-1,sizeof last);
	scanf("%d %d",&n,&q);
	for(int i=0;i<n;i++) scanf("%d",&arr[i]);
	Q qs[q];
	for(int i=0;i<q;i++){
		scanf("%d %d",&x,&y);
		x-- , y--;
		qs[i] = {x,y,i};
	}
	
	sort(qs,qs+q,cmp);
	int qn = 0;
	for(int i=0;i<n;i++){
		if(last[arr[i]] != -1)
			update(last[arr[i]] + 1,-1);
		last[arr[i]] = i;
		update(i+1,1);
		while(qn < q && qs[qn].y == i){
			ans[qs[qn].i] = query(qs[qn].y+1) - query(qs[qn].x);
			qn++;
		}
	}
	
	for(int i=0;i<q;i++) printf("%d\n",ans[i]);
	
	return 0;
}


Measured memory_bytes: 17440
#include <stdio.h>

int main()
{
	int i, N, M, A[101], sum = 0, count = 0;
	scanf("%d %d", &N, &M);
	for (i = 1; i <= N; i++) scanf("%d", &(A[i]));
	for (i = 1; i <= N; i++) sum += A[i];
	for (i = 1; i <= N; i++) if (A[i] * M * 4 >= sum) count++;
	if (count >= M) printf("Yes\n");
	else printf("No\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1644
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
int main()
{
	ll k;
	cin>>k;
	ll p=0,v=1;
	while(1){
		p=((p%k)*(10%k))%k;
		p=(p+7)%k;
		if(p%k==0){
			cout<<v<<endl;
			return 0;
		}
		v++;
		if(v>1e6) break; 
	}
	cout<<-1<<endl;
}

Measured memory_bytes: 3636
def insertionSort(A, N):
    for i in range(1, N):
        print(*A)
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = v
    print(*A)


def resolve():
    N = int(input())
    A = [int(i) for i in input().split()]
    insertionSort(A, N)


resolve()



Measured memory_bytes: 5984
# Aizu Problem CGL_2_B: Intersection
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def on_segment(p, q, r):
    # Given three colinear points p, q, r, the function checks if
    # point q lies on line segment 'pr'
    return q[0] <= max(p[0], r[0]) and q[0] >= min(p[0], r[0]) and \
           q[1] <= max(p[1], r[1]) and q[1] >= min(p[1], r[1])

def orientation(p, q, r):
    # To find orientation of ordered triplet (p, q, r).
    # The function returns following values
    #   0 --> p, q and r are colinear
    #   1 --> Clockwise
    #   2 --> Counterclockwise
    val = (q[1] - p[1]) * (r[0] - q[0]) - (q[0] - p[0]) * (r[1] - q[1])
    if val == 0:
        return 0
    return 1 if val > 0 else 2

def do_intersect(p1, q1, p2, q2):
    # The main function that returns true if line segment 'p1q1'
    # and 'p2q2' intersect.
    o1 = orientation(p1, q1, p2)
    o2 = orientation(p1, q1, q2)
    o3 = orientation(p2, q2, p1)
    o4 = orientation(p2, q2, q1)
    #
    # General case:
    if o1 != o2 and o3 != o4:
        return True
    #
    # Special Cases:
    # 
    # p1, q1 and p2 are colinear and p2 lies on segment p1q1
    if o1 == 0 and on_segment(p1, p2, q1):
        return True
    # p1, q1 and p2 are colinear and q2 lies on segment p1q1
    if o2 == 0 and on_segment(p1, q2, q1):
        return True
    # p2, q2 and p1 are colinear and p1 lies on segment p2q2
    if o3 == 0 and on_segment(p2, p1, q2):
        return True
    #  p2, q2 and q1 are colinear and q1 lies on segment p2q2
    if o4 == 0 and on_segment(p2, q1, q2):
        return True
    # Doesn't fall in any of the above cases:
    return False


n = int(input())
for k in range(n):
    x1, y1, x2, y2, x3, y3, x4, y4 = [int(_) for _ in input().split()]
    print(1 if do_intersect([x1, y1], [x2, y2], [x3, y3], [x4, y4]) else 0)

Measured memory_bytes: 7880
using System;

namespace AtCoder.ABC098
{
    class c
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Trim();
            var N = int.Parse(line);
            var S = Console.ReadLine().Trim();
            var max = 0;
            var cnt = 0;
            var pointer = 0;
            for (var i = 0; i < N; ++i)
            {
                if (S[i] == 'E') ++cnt;
                else --cnt;
                if (cnt > max)
                {
                    max = cnt;
                    pointer = i + 1;
                }
            }
            cnt = 0;
            for (var i = 0; i < N; ++i)
            {
                if (i == pointer) continue;
                else if (i < pointer)
                {
                    if (S[i] == 'W') ++cnt;
                }
                else
                {
                    if (S[i] == 'E') ++cnt;
                }
            }
            Console.WriteLine(cnt);
        }
    }
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<int,int> P;
P orExpr(string &str, int &pla);

P term(string &str, int &pla){
    //cout << "in term " << pla << endl;
    if(str[pla] == '?'){
        pla++;
        return MP(1, 1);
    }
    else {
        pla++;
        auto ret = orExpr(str, pla);
        pla++;
        return ret;
    }
}

P andExpr(string &str, int &pla){
    //cout << "in andExpr " << pla << endl;
    int a = 0, b = INF;
    int tmp = 0;

    while(1){
        auto v = term(str, pla);
        b = min(b, tmp + v.SE);
        a += v.FI;
        tmp += v.FI;

        if(str[pla] != '&'){
            break;
        }
        pla++;
    }

    //cout << "out andExpr" << endl;
    return MP(a, b);
}

P orExpr(string &str, int &pla) {
    //cout << "in orExpr " << pla << endl;
    int a = INF, b = 0;
    int tmp = 0;

    while(1){
        auto v = andExpr(str, pla);
        a = min(a, tmp + v.FI);
        tmp += v.SE;
        b += v.SE;

        if(str[pla] != '|'){
            break;
        }
        pla++;
    }

    //cout << "out orExpr" << endl;
    return MP(a, b);
}

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

    string str;cin >> str;
    str = "(" + str + ")";
    int pla = 1;
    auto ans = orExpr(str, pla);
    cout << ans.SE << " " << ans.FI << endl;

	return 0;
}



Measured memory_bytes: 3516
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<long long>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  sort(A.begin(),A.end());
  vector<pair<long long,long long>>B;
  long long mark=0;
  for(int i=0;i<N;i++){
    if(A[i]!=mark){
      mark=A[i];
      B.push_back(make_pair(A[i],1));
    }
    else{
      B.at(B.size()-1).second++;
    }
  }
  long long count=0;
  for(int i=0;i<B.size();i++){
    if(B[i].first<B[i].second){
      count=count+B[i].second-B[i].first;
    }
    else if(B[i].first>B[i].second){
      count=count+B[i].second;
    }
  }
  cout<<count<<endl;
}
    


Measured memory_bytes: 3188
Module Module1

    Sub Main()

        Dim arr As String() = Split(Console.ReadLine())
        Dim A As Integer = arr(0)
        Dim B As Integer = arr(1)
        Dim x As Integer = 0

        x = ((B - 1) \ (A - 1)) + IIf(((B - 1) Mod (A - 1)) > 0, 1, 0)

        Console.WriteLine(x)

        'console.ReadLine()

    End Sub

End Module


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


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    vector<int> p(n),q(n);
    rep(i,n)cin>>p[i];
    rep(i,n)cin>>q[i];
    vector<int> r(n);
    rep(i,n)r[i]=i+1;
    int a,b,i;
    do{
        if(r==p)a=i;
        if(r==q)b=i;
        i++;
    }while(next_permutation(r.begin(),r.end()));
    cout<<abs(a-b);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string b;
int a[5];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>b;
		if(b=="AC") a[0]++;
		if(b=="WA") a[1]++;
		if(b=="TLE") a[2]++;
		if(b=="RE") a[3]++;
	}
	cout<<"AC x "<<a[0]<<endl;
	cout<<"WA x "<<a[1]<<endl;
	cout<<"TLE x "<<a[2]<<endl;
	cout<<"RE x "<<a[3]<<endl;
	
} 

Measured memory_bytes: 3632
local function str2tbl(s)
    -- limit of #s is approximately 999959
    local t = {string.byte(s, 1, #s)}
    local char = string.char
    for i=1, #t do
        t[i] = char(t[i])
    end
    return t
end

local function nC2(n)
    if n < 2 then
        return 0
    end
    return n * (n-1) // 2
end
---
local N, _ = io.read("n", "l")
local sorted_dic = {}
for i=1,N do
    local s = io.read("l")
    local s_tbl = str2tbl(s)
    table.sort(s_tbl)
    local s_sorted = table.concat(s_tbl, "")
    --print(s_sorted)
    sorted_dic[s_sorted] = (sorted_dic[s_sorted] or 0) + 1
end
local ans = 0
for k,v in pairs(sorted_dic) do
    ans = ans + nC2(v)
end
print(ans)

Measured memory_bytes: 21860
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long int lint;
typedef long long int llint;

#define INF 2147483647
#define LINF 92233720370000000000

int n;
int h[110000], dp[110000];

int main() {
    cin >> n;

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

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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 100100100100;


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


int main(){
    int N, K;
    cin >> N >> K;
    map<int, int> mp;
    rep(i, N){
        int a;
        cin >> a;
        mp[a]++;
    }
    ll kindCount = 0;
    priority_queue<int, vector<int>, greater<int>> que;
    for(auto itr = begin(mp); itr != end(mp); itr++){
        kindCount++;
        que.push(itr->second);
    }
    kindCount -= K;
    int ans = 0;
    rep(i, kindCount){
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;

}

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

using namespace std;

#define el				'\n'
#define sz(v)			((int)((v).size()))
#define all(v)          ((v).begin()),((v).end())
#define clr(v, d)		memset(v, d, sizeof(v))

double const EPS = 1e-8, PI = acos(-1);
const int N = 3000 + 9, M = 50 + 9, OO = (int) 1e9 + 1;
const long long MOD = 1e9 + 7;

typedef long long ll;

void OUTPUT() {
	cout << fixed << setprecision(12);
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
}

void INPUT() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(12);
//	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
}

int n;
double prob[N], headProb[N][N];
int main() {
//	INPUT();
	OUTPUT();
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> prob[i];
	}
	clr(headProb, 0);
	headProb[0][0] = 1;

	for (int i = 1; i <= n; i++) {
		double h = prob[i], t = 1 - prob[i];
		headProb[0][i] = t * headProb[0][i - 1];
		
		for (int j = 1; j <= i; j++) {
			headProb[j][i] = h * headProb[j - 1][i - 1]
					+ t * headProb[j][i - 1];
		}
		
	}
	long double ans = 0;
	for (int i = (n / 2 + 1); i <= n; i++)
		ans += headProb[i][n];
	cout << ans;

	return 0;

}


Measured memory_bytes: 71040
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

bool d[51][51][51][51];
int dh[4] = { 1,0,-1,0 };
int dw[4] = { 0,1,0,-1 };
int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	int kkt = 89;
	while (kkt) {
		int W, H; scanf("%d %d", &W, &H);
		if (W == 0 && H == 0) break;
		vector<vector<string>> vs(2, vector<string>(H)); for (int i = 0; i < H; i++) cin >> vs[0][i] >> vs[1][i];
		for (int i = 0; i < H; i++) reverse(vs[1][i].begin(), vs[1][i].end());
		for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) for (int k = 0; k < H; k++) for (int l = 0; l < W; l++) d[i][j][k][l] = false;
		vector<queue<pair<int, int>>> vq(2);
		int gh[2], gw[2];
		for (int k = 0; k < 2; k++) {
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					if (vs[k][i][j] == 'L' || vs[k][i][j] == 'R') {
						vq[k].emplace(i, j);
					}
					if (vs[k][i][j] == '%') gh[k] = i, gw[k] = j;
				}
			}
		}
		d[vq[0].front().first][vq[0].front().second][vq[1].front().first][vq[1].front().second] = true;
		while (!vq[0].empty() && !vq[1].empty()) {
			pair<int, int> cur[2] = { vq[0].front(),vq[1].front() };
			vq[0].pop(); vq[1].pop();
			for (int i = 0; i < 4; i++) {
				int nh[2] = { cur[0].first, cur[1].first };
				int nw[2] = { cur[0].second,cur[1].second };
				for (int k = 0; k < 2; k++) {
					int th = nh[k], tw = nw[k];
					if (nh[k] + dh[i] >= 0 && nh[k] + dh[i] < H) th += dh[i];
					if (nw[k] + dw[i] >= 0 && nw[k] + dw[i] < W) tw += dw[i];
					if (vs[k][th][tw] == '#') continue;
					nh[k] = th;
					nw[k] = tw;
				}
				if (d[nh[0]][nw[0]][nh[1]][nw[1]]) continue;
				if (nh[0] == gh[0] && nw[0] == gw[0]) {
					if (nh[1] != gh[1] || nw[1] != gw[1]) continue;
				}
				if (nh[1] == gh[1] && nw[1] == gw[1]) {
					if (nh[0] != gh[0] || nw[0] != gw[0]) continue;
				}
				d[nh[0]][nw[0]][nh[1]][nw[1]] = true;
				vq[0].emplace(nh[0], nw[0]);
				vq[1].emplace(nh[1], nw[1]);
			}
		}
		if (d[gh[0]][gw[0]][gh[1]][gw[1]]) puts("Yes");
		else puts("No");
	}
	return 0;

}


Measured memory_bytes: 10428
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int a=0;
	int f=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
          a++;
        }
		else{ 
          a=0;
        }
		f=max(a,f);
	}
	cout<<f<<endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(int i = 0; i < (int)n; i++)
using namespace std;

int main(){
  string s;
  int k;
  cin >> s >> k;
  std::vector<string> v;
  for(int i = 1; i <= k; i++){
    for(int j = 0; j < s.length()-(i-1); j++){
      v.push_back(s.substr(j,i));
    }
  }
  sort(v.begin(),v.end());
  if(k==1){
    cout << v[0] << endl;
    return 0;
  }
  int cnt = 1;
  for(int i = 0; i < v.size(); i++){
    if(v[i]!=v[i+1]){
      cnt++;
      if(cnt==k){
        cout << v[i+1] << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 1660
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;
bool my_compare(pair<ll, ll> a, pair<ll , ll> b) {
    // 基本はfirstで比較
    if(a.first != b.first){
         return a.first < b.first; // 昇順
        //return a.first > b.first; // 降順
    }

    // それ以外はsecondで比較
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        // どちらも同じ
        return true;
    }
}

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

    ll a,b,c,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>n>>m;
    f=2;
    vector<vector<ll>> v(n,vector<ll> (f));
    vector<vector<ll>> w(m,vector<ll> (f));

    rep(j,n)rep(i,2)  cin>>v[j][i]; 
    rep(j,m)rep(i,2)  cin>>w[j][i]; 
    

    rep(i,n){
        mini=INF;
        ll uhi;
            rep(j,m){
                ll x=mini;
                mini=min(mini,abs(v[i][0]-w[j][0])+abs(v[i][1]-w[j][1]));
                if(x!=mini) uhi=j+1;
            }
            cout <<uhi<<endl;

    }
    


    return 0;
}


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


int main() {

	int count = 0, count_max = 0;
	int tmp;
	int i;

	string N;
	int N_num[200000];
	long int sum, sum_dig = 0;

	cin >> N;

	int N_len = (int)(N.length());

	for ( i = 0; i < N_len; i++)
	{
		sum_dig += (int)(N[i] - '0');
	}
	
	if (sum_dig % 9 == 0)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
		
	
	
}

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FORr(i, j, 0)
#define INF (1<<30)
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

int X;

int main() {
        scanf("%d", &X);
        int cnt = 0;
        rep(i, X + 1) {
                cnt += i;
                if(cnt >= X) {
                        printf("%d\n", i);
                        break;
                }
        }
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long 
#define pb push_back
#define MAX 10000005
#define mod 1000000007
#define sp fixed<<setprecision(12)
using namespace std;
/*
vector<int> primes;
ll sumprime[MAX];
bool is_prime[MAX];
void sieve(){
    is_prime[0]=is_prime[1]=true;
    for(int i=4;i<MAX;i+=2){
        is_prime[i]=true;
    }
    for(int i=3;i*i<MAX;i+=2){
        if(!is_prime[i]){
            for(int j=i*i;j<MAX;j+=i){
                is_prime[j]=true;
            }
        }
    }
    for(int i=0;i<MAX;i++){
        if(!is_prime[i]){
            sumprime[i]=sumprime[i-1]+i;
        }else{
            sumprime[i]=sumprime[i-1];
        }
    }
}
*/


using namespace std;
int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    //double    pi=3.14159265358979323846;
    //sieve();
    int t=1;
    //cin>>t;
    while(t--){
        int n;
        cin>>n;
        int a[n];
        int dp[n];
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        dp[0]=0;
        dp[1]=abs(a[1]-a[0]);
        for(int i=2;i<n;i++){
            dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
        }
        cout<<dp[n-1]<<'\n';

    }
    
    
    
    
    
    return 0;
    
}

Measured memory_bytes: 4376
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int mod = 1e9+7;
inline int Mod(int x){
	return x>=mod?x-mod:x;
}
inline int power(int a,int b){
	int ret=1;
	for (;b;b>>=1,a=1ll*a*a%mod) if (b&1) ret=1ll*ret*a%mod;
	return ret;
}

const int N = 6e5;
int fac[N+10],ifac[N+10];
inline void init(){
	fac[0]=1;
	For(i,1,N) fac[i]=1ll*fac[i-1]*i%mod;
	ifac[N]=power(fac[N],mod-2);
	Dow(i,N-1,0) ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
}
inline int C(int n,int m){
	if (n<m||m<0) return 0;
	return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}

int n,m,l,r;
inline int calc2(int s,int lim){
	if (s<0) return 0;
	int ret=0;
	For(i,0,n-m){
		if (C(s-(lim+1)*i+n,n)==0) break;
		int tmp=1ll*C(n-m,i)*C(s-(lim+1)*i+n,n)%mod;
		if (i&1) ret=Mod(ret+mod-tmp);
			else ret=Mod(ret+tmp);
	}
	return ret;
}
inline int calc(int n,int m,int s){
	int ret=0;
	for (int i=0;(i+1)*m<=s;i++) ret=Mod(ret+Mod(calc2(s-(i+1)*m,i)+mod-calc2(s-(i+2)*m,i)));
	return Mod(C(n+s,n)+mod-1ll*ret*C(n,m)%mod);
}

int main(){
	n=read(),m=read(),l=read(),r=read(),init();
	printf("%d\n",Mod(calc(n,m,r)+mod-calc(n,m,l-1)));
}

Measured memory_bytes: 8468
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
x, y = map(int, input().split())
if x == 2 or y == 2:
    print("No")
elif x in a and y in a:
    print('Yes')
elif x in b and y in b:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
long long int knapsack(vector<long long int> val,vector<long long int> wt,long long int n,long long int w){
    long long int dp[n+1][w+1];
    for(int i=0;i<n+1;i++){
        for(int j=0;j<w+1;j++){
            if(i==0){
            dp[i][j]=0;continue;}
            if(j==0){
            dp[i][j]=1;continue;}
            if(wt[i-1]<=j)
            dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    return dp[n][w];
}
int main() {
   long long int n,w;
   cin>>n>>w;
   vector<long long int> wt(n),val(n);
   int i=0;
   while(i<n){
       cin>>wt[i]>>val[i];
       i++;
   }
   cout<<knapsack(val,wt,n,w)<<endl;
   return 0;
}

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

#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>

using ll = long long;
const ll INF = LLONG_MAX/4 - 100;
ll mod = 1e9 + 7;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;

class fact {
public:
    int fmod = 1e9+7;
    vector<int> fac, inv;
    fact (int n, int Mod = 1e9+7) {
        fmod = Mod;
        fac = vector<int>(n,0);
        inv = vector<int>(n,0);
        fac[0] = 1; for (int i = 1; i < n; i++) fac[i] = fac[i-1] * i % fmod;
        for (int i = 0;i < n;i++) inv[i] = fact::POW(fac[i],fmod-2);
    }
    ll nCr(ll n, ll r) {return (fac[n] * inv[r] % fmod) * inv[n-r] % fmod;}
    ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%fmod;}a = a * a%fmod; b >>= 1;}return c;}
};

template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%mod;}a = a * a%mod; b >>= 1;}return c;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}
bool isSqrt(ll a) {return pow(sqrt(a),2) == a ? 1 : 0;}
void YesNo(bool a) {if (a) cout << "Yes"; else cout << "No"; cout << endl;}
void yesno(bool a) {if (a) cout << "yes"; else cout << "no"; cout << endl;}
void YESNO(bool a) {if (a) cout << "YES"; else cout << "NO"; cout << endl;}

int now[5050];
int dp[5050];

void solve() {
    int n,a; cin >> n >> a;
    int pf = 2525;
    int x[n];
    REP (i,n) {
        int X; cin >> X; X -= a;
        x[i] = X;
    }
    now[pf] = 1;
    dp[pf] = 1;
    REP (i,n) {
        REP (j,5050) {
            if (x[i]+j < 0 || x[i]+j >= 5050) continue;
            now[x[i]+j] += dp[j];
        }
        REP (j,5050) {
            dp[j] = now[j];
        }
    }
    cout << dp[pf]-1 << endl;
}

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


Measured memory_bytes: 384