akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}

int main(){
    int n;
    cin >> n;
    vector<int> p;
    rep(i,n){
        int a,b;
        cin >> a >> b;
        if(a==b){
            p.push_back(i);
        }
    }
    for(int i=0;i<(int)p.size()-2;i++){
        if(p[i]+2==p[i+1]+1&&p[i+1]+1==p[i+2]){
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		int a[] = new int[n + 1];
		int b[] = new int[n];

		String str[] = br.readLine().split(" ");

		for (int i = 0; i < n + 1; i++) {
			a[i] = Integer.parseInt(str[i]);
		}

		str = br.readLine().split(" ");

		for (int i = 0; i < n; i++) {
			b[i] = Integer.parseInt(str[i]);
		}

		long ans = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] > 0) {
				ans += Math.min(a[i], b[i]);
				int temp = a[i];
				a[i] -= b[i];
				b[i] -= temp;
			}

			if (a[i] <= 0 && b[i] > 0) {
				ans += Math.min(a[i + 1], b[i]);
				int temp1 = a[i + 1];
				a[i + 1] -= b[i];
				b[i] -= temp1;
			}
		}

		System.out.println(ans);
	}
}

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

int main()
{
	string sa, sb, sc;
	cin >> sa >> sb >> sc;
	int pa = 0, pb = 0, pc = 0;
	char x;
	string* sx = &sa;
	int* px = &pa;
	while(*px < sx->size()){
		x = sx->at((*px)++);
		switch(x){
			case 'a':
				sx = &sa;
				px = &pa;
				break;
			case 'b':
				sx = &sb;
				px = &pb;
				break;
			case 'c':
				sx = &sc;
				px = &pc;
		}
	}
	cout << (char)(x - 'a' + 'A') << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long N;
  scanf("%lld", &N);
  if (B - 1 <= N)
  {
    cout << floor((A * (B - 1)) / B) - A * floor((B - 1) / B) << endl;
  }
  else
  {
    cout << floor((A * N) / B) - A * floor(N / B) << endl;
  }

  return 0;
}


Measured memory_bytes: 3292
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
x = y = 0
a[0][0] = "."
while True:
    if x + 1 < w and y + 1 < h:
        if a[y][x+1] == a[y+1][x]:
            print("Impossible")
            exit()
        elif a[y][x+1] == "#":
            x += 1
            a[y][x] = "."
        elif a[y+1][x] == "#":
            y += 1
            a[y][x] = "."
    elif y + 1 >= h:
        x += 1
        if a[y][x] != "#":
            print("Impossible")
            exit()
        else:
            a[y][x] = "."
    elif x + 1 >= w:
        y += 1
        if a[y][x] != "#":
            print("Impossible")
            exit()
        else:
            a[y][x] = "."
    if x == w - 1 and y == h - 1:
        for i in range(h):
            for j in range(w):
                if a[i][j] == "#":
                    print("Impossible")
                    exit()
        print("Possible")
        exit()


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

int main()
{
	int rows, columns;
	cin >> rows >> columns;
	int **HW;
	HW = new int * [rows];
	for (int i = 0; i < rows; i++) {
		HW[i] = new int[columns];
	}
	for (int i = 0; i < rows; i++) {
		for (int j = 0; j < columns; j++) {
			HW[i][j] = 0;
		}
	}
	int Num;
	cin >> Num;
	int *a;
	a = new int[Num];
	for (int i = 0; i < Num; i++) {
		cin >> a[i];
	}
	int var = 0; int x = -1, y = 0;
	for (int i = 0; i < Num; i++) {
		for (int j = 0; j < a[i]; j++) {
			if (var == 0) {
				x++;
				if (x < columns && HW[y][x] == 0) {
					HW[y][x] = i + 1;
				}
				else {
					x--; j--; var++;
				}
			}else if (var == 1) {
				y++;
				if (y < rows && HW[y][x] == 0) {
					HW[y][x] = i + 1;
				}
				else {
					y--; j--; var++;
				}
			}else if (var == 2) {
				x--;
				if (x >= 0 && HW[y][x] == 0) {
					HW[y][x] = i + 1;
				}
				else {
					x++; j--; var++;
				}
			}else if(var == 3) {
				y--;
				if (y >= 0 && HW[y][x] == 0) {
					HW[y][x] = i + 1;
				}
				else {
					y++; j--; var = 0;
				}
			}
		}
	}
	for (int i = 0; i < rows; i++) {
		cout << HW[i][0];
		for (int j = 1; j < columns; j++) {
			cout << " " << HW[i][j];
		}
		cout << endl;
	}
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
const int N = 2e5;
using namespace std;
int n,edge[N * 2 + 5],nxt[N * 2 + 5],head[N + 5],edge_cnt,sg[N + 5];
void add_edge(int u,int v)
{
    edge[++edge_cnt] = v;
    nxt[edge_cnt] = head[u];
    head[u] = edge_cnt;
}
void dfs(int u,int fa)
{
    for (int i = head[u];i;i = nxt[i])
    {
        int v = edge[i];
        if (v == fa)
            continue;
        dfs(v,u);
        sg[u] ^= sg[v] + 2;
    }
}
int main()
{
    scanf("%d",&n);
    int u,v;
    for (int i = 1;i < n;i++)
    {
        scanf("%d%d",&u,&v);
        add_edge(u,v);
        add_edge(v,u);
    }
    dfs(1,0);
    if (sg[1])
        cout<<"Alice"<<endl;
    else
        cout<<"Bob"<<endl;
    return 0;
}

Measured memory_bytes: 13768
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
#define itn int
#define all(c) c.begin(),c.end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define ll long long
#define ull unsigned long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std;
 
const ll MAX_N = 2e5 + 5, inf = 1e18, mod = 1000000007;
const double PI = 3.1415926536;
int days[13] = {0, 31, 28, 31, 30, 31,30, 31, 31, 30, 31, 30, 31};
 
template<typename T>
ostream& operator <<(ostream& out, const vector<T>& mas) {
    for (const auto& x : mas) {
        out << x << ' ';
    }
    return out;
}
 
void ok() {
    cout << "OK" << '\n';
}
 
void no() {
    cout << "NG" << '\n';
}
 
inline ll nxt() {
    ll x;
    cin >> x;
    return x;
} 
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    ll a = nxt();
    string s;
    cin >> s;
    ll sum = (s[0] - '0') * 100;
    sum += (s[2] - '0') * 10;
    sum += s[3] - '0';
    cout << a * sum / 100;
    return 0;

}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
typedef long long ll;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
using namespace std;

int n, a[maxn], b[maxn], vis[20];
int fac[maxn], A[maxn], sum[maxn];

int main() {
    ios::sync_with_stdio(0);
    fac[0] = 1;
    for(int i = 1; i < maxn; i++) fac[i] = (ll)fac[i - 1] * i % mod;
    cin >> n;
    A[0] = 1;
    for(int i = 1; i <= n; i++) A[i] = (ll)A[i - 1] * (n - i + 1) % mod;
    for(int i = 1; i <= n; i++) cin >> a[i];
    sum[0] = 0;
    for(int i = 1; i <= n; i++) {
        int v = (ll)fac[i] * A[n - (i + 1)] % mod;
        sum[i] = (sum[i - 1] + v) % mod;
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        ans += (ll)a[i] * fac[n] % mod;
        ans += (ll)a[i] * sum[i - 1] % mod;
        ans += (ll)a[i] * sum[n - i] % mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int N,R,F; //N:コンテスト参加回数 R:表示レーティング F:内部レーティング
    cin >> N >> R;
    if(10 <= N)
        F = R;
    else
        F = R + (100 * (10 - N));

    cout << F << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)
        cin >> a[i];
    int ans = 0;
    while(1){
        int count = 0;
        for(int i = 0; i < n; i++){
            if(a[i] % 2 == 0){
                a[i]/=2;
                count++;
            }
            else goto loop_end;
        }
        if(count == n) ans++;
    }
    loop_end: ;
    cout << ans << endl;
    return 0;
}

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

int main(){
  int N,M;
  int dp[100001]={0};
  cin>>N>>M;
  vector<int> a(M+1,-1);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  dp[0]=1;
  int counter=0;
  if(a[0]==1){
    dp[1]=0; 
    counter++;
  }else dp[1]=1;
  for(int i=2;i<=N;i++){
    if(a[counter]==i){
      counter++;
      continue;
    }
    dp[i]=(dp[i-1]+dp[i-2])%mod;
    
  }
  cout<<dp[N]<<endl;
}



Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main
{

  public static void main
  (
    String[] args
  )
  {
    BufferedReader in_stream;
    String         in_str;
    String[]       in_str_split;

    int in_X;
    int in_A;
    int in_B;
    int ans;

    try
    {

      in_stream = new BufferedReader(new InputStreamReader(System.in));

      in_str = new String(in_stream.readLine());
      in_X   = Integer.parseInt(in_str);

      in_str = new String(in_stream.readLine());
      in_A  = Integer.parseInt(in_str);

      in_str = new String(in_stream.readLine());
      in_B  = Integer.parseInt(in_str);


      ans = in_X - in_A;
      ans = ans % in_B;


      UtilLog.ans_ln("" + ans);
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }
}

class UtilLog
{
  private static boolean is_debug_mode = false;



  public static void ans_ln
  (
    String i_message
  )
  {
    System.out.println(i_message);
  }



  public static void ans_f
  (
    String i_message
  )
  {
    System.out.printf(i_message);
  }



  public static void inf_ln
  (
    String i_message
  )
  {
    StackTraceElement[] stack;


    if(is_debug_mode)
    {
    stack = new Throwable().getStackTrace();

    System.out.println
      (
        String.format
          (
            "[inf][%s:%s():%5d]",
            stack[1].getClassName(),
            stack[1].getMethodName(),
            stack[1].getLineNumber(),
            i_message
          )
      );
    }
  }
}


Measured memory_bytes: 22484
#include <iostream> 
#include <cstdio> 
#include <cstdlib>  
#include <algorithm> 
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include<iomanip>
#include<functional>
using namespace std;
typedef long long ll;


long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}


int main() {
    int N, K;
    
    string S;
    cin >> N >>  S  >> K;
    for (int i = 0; i < N; i++) {
        if (S[i] != S[K - 1]) S[i] = '*';
    }
    cout << S << endl;
}


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

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

struct edge{
    int to,cap,cost,rev;
    edge(int to,int cap,int cost,int rev):to(to),cap(cap),cost(cost),rev(rev){}
};

const int INF=1001001001;
const int MAX_V=500;
int S=MAX_V-2,T=MAX_V-1;
vector<edge>G[MAX_V];
int dist[MAX_V];
int prevv[MAX_V],preve[MAX_V];

void init(){
    rep(i,MAX_V)G[i].clear();
}
void add_edge(int from,int to,int cap,int cost){
    G[from].pb(edge(to,cap,cost,G[to].size()));
    G[to].pb(edge(from,0,-cost,G[from].size()-1));
}

int min_cost_flow(int s,int t,int f){
    int res=0;
    while(f>0){
        fill_n(dist,MAX_V,INF);
        dist[s]=0;
        bool update=true;
        while(update){
            update=false;
            rep(v,MAX_V){
                if(dist[v]==INF)continue;
                rep(i,G[v].size()){
                    edge &e=G[v][i];
                    if(e.cap>0&&dist[e.to]>dist[v]+e.cost){
                        dist[e.to]=dist[v]+e.cost;
                        prevv[e.to]=v;
                        preve[e.to]=i;
                        update=true;
                    }
                }
            }
        }

        if(dist[t]==INF)return -1;

        int d=f;
        for(int v=t;v!=s;v=prevv[v]){
            chmin(d,G[prevv[v]][preve[v]].cap);
        }

        f-=d;
        res+=d*dist[t];
        for(int v=t;v!=s;v=prevv[v]){
            edge &e=G[prevv[v]][preve[v]];
            e.cap-=d;
            G[v][e.rev].cap+=d;
        }
    }

    return res;
}

int A,B,K;
string a[200],b[200];
signed main(){
    cin>>A>>B>>K;
    rep(i,A)cin>>a[i];
    rep(i,B)cin>>b[i];

    int lb=0,ub=300;
    while(ub-lb>1){
        int mid=(ub+lb)/2;

        init();
        rep(i,A)add_edge(S,i,1,0);
        rep(i,B)add_edge(i+A,T,1,0);
        rep(i,A)rep(j,B){
            int cnt=0;
            if(a[i][j]=='1')cnt++;
            if(b[j][i]=='1')cnt++;
            add_edge(i,j+A,1,cnt);
        }

        int tmp=min_cost_flow(S,T,mid);
        if(tmp==-1||tmp>K)ub=mid;
        else lb=mid;
    }
    cout<<lb<<endl;
    return 0;
}

Measured memory_bytes: 4624
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        var KN = ReadLine().Split().Select(int.Parse).ToArray();
        var K = KN[0];
        var N = KN[1];
        var A = ReadLine().Split().Select(int.Parse).ToArray();
        var d = new long[N];
        d[0] = K - A[N - 1] + A[0];
        for (int i = 1; i < N; i++)
        {
            d[i] = A[i] - A[i - 1];
        }
        Array.Sort(d);
        WriteLine(d.Sum()-d[N-1]);
    }
}


Measured memory_bytes: 45420
#include <stdio.h>

int main(void)
{
	int a;
	int i = 0;
	
	while (1)
	{
		scanf("%d", &a);
		
		if (a == 0)
		{
			break;
		}
		
		i++;
		
		printf("Case %d: %d\n", i, a);
	}
	
	return 0;
}

Measured memory_bytes: 600
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define int long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int cnt[200005],a[200005];
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	FOR(i,1,n)cin>>a[i],cnt[a[i]]++;
	int ans=0;
	FOR(i,1,n)ans=ans+cnt[i]*(cnt[i]-1)/2;
	int t;
	FOR(i,1,n){
		t=ans;
		t=t-cnt[a[i]]*(cnt[a[i]]-1)/2;
		cnt[a[i]]--;
		t=t+cnt[a[i]]*(cnt[a[i]]-1)/2;
		cnt[a[i]]++;
		cout<<t<<'\n';
	}
	RE 0;
}




Measured memory_bytes: 4736
//confilm 0LL and 1LL
//confilm cornercases such as 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecVec = vector<Vec>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll n;
	cin >> n;
	Vec l(2*n);
	rep(i, 2*n) cin >> l[i];
	sort(all(l));

	ll ans = 0;
	rep(i, n) ans += l[i*2];
	co(ans);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<string> S(n);
    for (int i = 0; i < n; i++){
        cin >> S[i];
    }
    sort(S.begin(), S.end());
    S.erase(unique(S.begin(), S.end()), S.end());
    cout << S.size() << endl;
}

Measured memory_bytes: 9596
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int d;
int c[27];
int s[366][27];
int calc(vector<int> t){
    int last[26]={};
    vector<int> ret(d);
    int ans=0;
    for(int i=0; i<d; i++){
        ans+=s[i][t[i]];
        last[t[i]]=i+1;
        for(int j=0; j<26; j++){
            ans-=c[j]*(i+1-last[j]);
        }
        ret[i]=ans;
    }
    return ans;
}
mt19937 mt(314159265);
void gen(){
    d=365;
    uniform_int_distribution<> rndc(0, 100), rnds(0, 20000);
    for(int i=0; i<26; i++) c[i]=rndc(mt);
    for(int i=0; i<d; i++) for(int j=0; j<26; j++) s[i][j]=rnds(mt);
}
int main()
{
    cin>>d;
    for(int i=0; i<26; i++) cin>>c[i];
    for(int i=0; i<d; i++) for(int j=0; j<26; j++) cin>>s[i][j];
    //gen();
    vector<int> t(d);
    
    int last[26]={};
    for(int i=0; i<d; i++){
        int kmx=0, mx=-1e9;
        for(int k=0; k<26; k++){
            int sum=s[i][k];
            int myon=last[k];
            last[k]=i+1;
            for(int j=0; j<26; j++){
                sum-=c[j]*(i+1-last[j]);
            }
            last[k]=myon;
            if(mx<sum) kmx=k, mx=sum;
        }
        t[i]=kmx;
        last[kmx]=i+1;
    }

    uniform_int_distribution<> rndk(0, d-1), rndq(0, 25);
    clock_t start = clock();
    int ans=calc(t);
    while((double)(clock()-start)/CLOCKS_PER_SEC<1.95){
        int k, q;
        k=rndk(mt), q=rndq(mt);
        if(t[k]==q){
            continue;
        }
        int pr=t[k], ansp=ans;
        ans-=s[k][pr];
        ans+=s[k][q];
        int l1=-1, l2=-1, r1=d, r2=d;
        for(int i=k+1; i<d; i++){
            if(t[i]==pr){
                r1=i; break;
            }
        }
        for(int i=k+1; i<d; i++){
            if(t[i]==q){
                r2=i; break;
            }
        }
        for(int i=k-1; i>=0; i--){
            if(t[i]==pr){
                l1=i; break;
            }
        }
        for(int i=k-1; i>=0; i--){
            if(t[i]==q){
                l2=i; break;
            }
        }
        ans+=c[q]*(k-l2)*(r2-k);
        ans-=c[pr]*(k-l1)*(r1-k);
        t[k]=q;
        if(ansp>ans){
            t[k]=pr;
            ans=ansp;
        }
    }
    for(int i=0; i<d; i++){
        cout<<t[i]+1<<endl;
    }
	return 0;
}


Measured memory_bytes: 3708
N = int(input())
S = []
for _ in range(N):
    S.append(input())

A = S.count('AC')
B = S.count('WA')
C = S.count('TLE')
D = S.count('RE')
print('AC x '+str(A))
print('WA x '+str(B))
print('TLE x '+str(C))
print('RE x '+str(D))

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

int main() {
	int n,m,x;
	cin >> n >> m >> x;
	vector<int> c(n,0);
	vector<vector<int>> a(n,vector<int> (m,0));
	for(int i=0;i<n;i++)
	{
		cin >> c.at(i);
		for(int j=0;j<m;j++)
		{
			cin >> a.at(i).at(j);
		}
	}
	int s = 10000000;
	for(int i=0;i<=pow(2,n);i++)
	{
		vector<int> d(m,0);
		int cc=0;
		for(int j=0;j<n;j++)
		{
			int jj = pow(2,j+1);
			int jjj = pow(2,j);
			if(i % jj >= jjj )
			{
				cc+=c.at(j);
				for(int l=0;l<m;l++)
				{
					d.at(l)+=a.at(j).at(l);
				}
			}
		}
		int h=0;
		for(int j=0;j<m;j++)
		{
			if(d.at(j)<x)
			{
				h=1;
			}
		}
		if(h==0)
		{
			s = min(s,cc);
		}
	}
	if(s == 10000000)
	{
		s = -1;
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 4036
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define N 200005
const int mod=1e9+7;
struct Combin{
	int fac[N],rv[N],facrv[N];
	Combin(){
		fac[0]=rv[1]=facrv[0]=1;
		for(int i=2;i<N;i++) rv[i]=((-(LL)(mod/i)*rv[mod%i]%mod)+mod)%mod;
		for(int i=1;i<N;i++) fac[i]=(LL)fac[i-1]*i%mod;
		for(int i=1;i<N;i++) facrv[i]=(LL)facrv[i-1]*rv[i]%mod;
	}
	int C(int r1,int n1){
		if(r1>n1) return 0;
		return fac[n1]*(LL)facrv[r1]%mod*facrv[n1-r1]%mod;
	}
}C; 

int n,x,y;
int c[N],w[N],bcj[N];
int ff(int x){
    return bcj[x]==x? x:bcj[x]=ff(bcj[x]);
}
void connect(int f,int t){
    if(ff(f)==ff(t)) return ;
    bcj[ff(f)]=ff(t);
}
vector<int> col[N],group[N];
int mnw[N],mfr,mse;
int main(){
    scanf("%d%d%d",&n,&x,&y);
    for(int i=1;i<=n;i++) scanf("%d%d",&c[i],&w[i]),bcj[i]=i;
    for(int i=1;i<=n;i++)
        col[c[i]].push_back(i);
    w[0]=1e9;
    for(int i=1;i<=n;i++)
        for(int j:col[i])
            if(w[j]<w[mnw[i]]) mnw[i]=j;
    for(int i=1;i<=n;i++)
        if(w[mnw[i]]<w[mfr]) mse=mfr,mfr=mnw[i];
        else if(w[mnw[i]]<w[mse]) mse=mnw[i];
    for(int i=1;i<=n;i++)
        for(int j:col[i]){
            if(w[j]+w[mnw[i]]<=x) connect(j,mnw[i]);
            int mnn=mnw[i]==mfr? mse:mfr;
            if(w[j]+w[mnn]<=y) connect(j,mnn);
        }
    for(int i=1;i<=n;i++) group[ff(i)].push_back(c[i]);
    int ans=1;
    for(int i=1;i<=n;i++){
        group[i].push_back(1e9);
        sort(group[i].begin(),group[i].end());
        int cnt=0,last=1e9,temp=C.fac[group[i].size()-1];
        for(int j:group[i]){
            if(j==last) cnt++;
            else temp=temp*1LL*C.facrv[cnt]%mod,cnt=1,last=j;
        }
        ans=ans*1LL*temp%mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 26356
#include <iostream>
#include<list>
#include<map>
using namespace std;

int printIndex(){
    int number=0;
    string word;
    map<string,list<int> > index;
    
    while(!(cin>>word>>number).eof()){
        index[word].push_back(number);
        
    }
    
    map<string, list<int> >::iterator it = index.begin();
    while(it != index.end()){
        it->second.sort();
        list<int>::iterator ite = it->second.begin();
        cout << it->first << endl;
        while(ite!=it->second.end()){
            cout << *ite;
            ite++;
            if(ite!=it->second.end()) cout<<" ";
        }
        cout << endl;
        it++;
    }
}

int main(){
    printIndex();
    return 0;
}

Measured memory_bytes: 1228
#include<stdio.h>
int main()
{
    char str[12];

    scanf("%s",str);




if(str[5]=='0' && str[6]<='4' && ((str[8]<'3') || (str[8]=='3' && str[9]=='0')))
{

     printf("Heisei");
}

    else
        printf("TBD");
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            String S = in.next();
            long K = in.nextLong();

            int index = 1;
            for (int i = 0; i < S.length(); i++) {
                char n = S.charAt(i);
                if (n == '1') {
                    if (K >= index && K < index + 1) {
                        System.out.println(n);
                        return;
                    } else {
                        index++;
                    }
                } else {
                    System.out.println(n);
                    return;
                }
            }
        }
    }

}


Measured memory_bytes: 23764
#include <stdio.h>

int main(){

	int sx,sy,tx,ty;

	scanf("%d %d %d %d",&sx,&sy,&tx,&ty);

	int i;

	for(i=0;i<tx-sx;i++){
	printf("R");
	}
	for(i=0;i<ty-sy;i++){
	printf("U");
	}
	for(i=0;i<tx-sx;i++){
	printf("L");
	}
	for(i=0;i<ty-sy;i++){
	printf("D");
	}
	printf("D");
	for(i=0;i<tx-sx+1;i++){
	printf("R");
	}
	for(i=0;i<ty-sy+1;i++){
	printf("U");
	}
	printf("L");
	printf("U");
	for(i=0;i<tx-sx+1;i++){
	printf("L");
	}
	for(i=0;i<ty-sy+1;i++){
	printf("D");
	}
	printf("R\n");
	return 0;
}

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

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

  int MAX = -1;
  for(int i = 0 ; i < N; i++){
      int count = 0;
      for(int j = 0; j <= i; j++){
        count += A[0][j];
      }

      for(int j = i; j < N; j++){
        count += A[1][j];
      }
      MAX = max(count, MAX);
  }

  cout << MAX << endl;

  return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = 1e9;
const LL LLINF = 1e18;

void solve()
{
    int N;
    cin >> N;
    int K;
    cin >> K;

    vector<int> A(N);
    REP0(i, N)
    {
        cin >> A[i];
    }

    map<int, int> histo;

    int n_kind = 0;
    REP0(i, N)
    {
        n_kind += (histo.find(A[i]) == histo.end());
        histo[A[i]]++;
    }

    vector<int> num;
    num.reserve(N);

    for (auto p : histo)
    {
        num.push_back(p.second);
    }

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

    int ans = 0;

    REP0(i, n_kind - K)
    {
        ans += num[i];
    }
    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 11264
import math

A, B, K = map(int, input().split())

minAB = min(A, B)
kcount = 1

if minAB == 1:
	print(1)
else:
	for i in range (0, minAB):
		if A%(minAB-i) == 0 and B%(minAB-i) == 0 and kcount <K:
			kcount+=1
		elif A%(minAB-i) == 0 and B%(minAB-i) == 0:
			print(minAB-i)
			exit()
		else:
			continue

Measured memory_bytes: 3064
program test
implicit none
integer :: n,a(10**5),b(2),c(10**5),i,min_c = 10**9

read(*,*) n
read(*,*) (a(i),i=1,n)

b(1) = maxval(a(1:n))

a(maxloc(a(1:n))) = 0

do i = 1, n
 if (abs(a(i)-b(1)) >= a(i)) then
   c(i) = abs(a(i)-b(1))
 else
   c(i) = a(i)
 endif
   if(min_c >= c(i)) then 
     min_c = c(i)
	 b(2) = a(i)
   endif
enddo
 

write(*,*) b(1),b(2)
 
end program

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);
}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N, M;
    cin >> N >> M;
    vl S(N), T(M);
    rep(i, N) cin >> S[i];
    rep(i, M) cin >> T[i];
    vvc<ll> dp(N + 1, vc<ll>(M + 1, 0));
    
    fill(all(dp[0]), 1);
    rep(i, N+1) dp[i][0] = 1;

    rep(i,N)rep(j,M){
        if (S[i] == T[j])
            dp[i + 1][j + 1] = (dp[i + 1][j] + dp[i][j + 1])%MOD;
        else
            dp[i + 1][j + 1] = (dp[i + 1][j] + dp[i][j + 1] - dp[i][j] + MOD)%MOD;
    }
    // rep(i,N+1){
    //     rep(j, M + 1) cout << dp[i][j] << " ";
    //     cout << endl;
    // }
    cout << dp[N][M] << endl;
}

Measured memory_bytes: 31616
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;

int main(){
	int n, m, c[20];
	//input
	scanf(" %d %d", &n, &m);
	for(int i=0; i<m; ++i) scanf(" %d", &c[i]);	
	
	//solve
	
	//dp[i]:=i?????????????????????????????????????????????????°??????°
	int dp[50001] = {0};
	//???????????§????????°??§?????????
	for(int i=1; i<=50000; ++i) dp[i] = 100000;
	
	for(int i=0; i<=50000; ++i){
		for(int j=0; j<m; ++j){
			if(i+c[j]<=n){
				dp[i+c[j]] = min(dp[i+c[j]],dp[i]+1);	
			}
		}	
	}
	
	printf("%d\n", dp[n]);
}

Measured memory_bytes: 1392
a, b, c, x, y = map(int, input().split())
ans = a*x + b*y
if x > y :
    ans = min(ans, 2*y*c+(x-y)*a)
    ans = min(ans, 2*x*c)
else :
    ans = min(ans, 2*x*c+(y-x)*b)
    ans = min(ans, 2*y*c)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <assert.h>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,a) for(ll i=ll(a-1);i>=0;--i)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
using ull = unsigned long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll MOD3 = 1e6;
const ll EPS = 1e-10;
int sgn(const double a){
    return (a < -EPS ? -1 : (a > EPS ? +1 : 0));
}
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<long double,long double> point;
typedef complex<long double> Point;
const ll MAX = 3000;
constexpr ll nx[4] = {-1,0,1,0};
constexpr ll ny[4] = {0,1,0,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n+1,0),b(n+1,0),s,t;
    rep(i,n){
        ll c;
        cin >> c;
        s.push_back(c);
        a[c]++;
    }
    rep(i,n){
        ll c;
        cin >> c;
        t.push_back(c);
        b[c]++;
    }
    rep(i,1,n+1){
        if (a[i]+b[i] > n){
            PRINT("No");
            return 0;
        }
    }
    vector<ll> ans(n);
    ll i = 0;
    while (i < n && s[n-i-1] != t[i]){
        ans[n-i-1] = t[i];
        i++;
    }
    ll j = 0;
    while (i < n){
        ans[j] = t[i];
        j++;
        i++;
    }
    bool ok = 1;
    rep(i,n){
        if (s[i] == ans[i]) ok = 0;
    }
    if (ok){
        PRINT("Yes");
        array_output(all(ans));
        return 0;
    }
    i = 0;
    while (i < n && s[i] != t[n-i-1]){
        ans[i] = t[n-i-1];
        i++;
    }
    j = 0;
    while (i < n){
        ans[i] = t[j];
        j++;
        i++;
    }
    ok = 1;
    rep(i,n){
        if (s[i] == ans[i]) ok = 0;
    }
    if (ok){
        PRINT("Yes");
        array_output(all(ans));
        return 0;
    }
    ll ma = 0;
    rep(i,1,n+1){
        chmax(ma,a[i]);
    }
    rep(i,n){
        ans[(i+ma)%n] = t[i];
    }
    PRINT("Yes");
    array_output(all(ans));
}


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

int main(){
  string S;
  cin >> S;
  int day=0;
  if(S=="SUN"){
    day=7;
  }else if(S=="MON"){
    day=6;
  }else if(S=="TUE"){
    day=5;
  }else if(S=="WED"){
    day=4;
  }else if(S=="THU"){
    day=3;
  }else if(S=="FRI"){
    day=2;
  }else if(S=="SAT"){
    day=1;
  }
  cout << day << endl;
}


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

using namespace std;
typedef long long ll;
const int MAXN = 300 + 3;
int n, m, l;
ll d[MAXN][MAXN];
ll ans[MAXN][MAXN];
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n >> m >> l;
	for( int i = 0; i < n; i ++){
		for( int j = 0; j < n; j ++){
			d[i][j] = (ll)1e17;
			ans[i][j] = (ll)1e17;
		}
		d[i][i] = (ll)0;
		ans[i][i] = (ll)0;
	}
	for( int i = 0; i < m ; i ++){
		int a, b, c;
		cin >> a >> b >> c;
		a --, b --;
		d[a][b] = min(d[a][b],(ll)c);
		d[b][a] = min(d[b][a],(ll)c);
	}
	
	for( int i = 0; i < n;i ++){
		for( int j = 0; j < n; j ++){
			for( int h = 0; h < n; h ++){
				d[j][h] = min(d[j][h], d[j][i] + d[i][h]);
			}
		}
	}
	
	for( int i = 0; i < n; i ++){
		for( int j = 0; j < n; j ++){
			if( d[i][j] <= (ll)l)
				ans[i][j] = (ll)1;
			if( i == j)
				ans[i][j] = (ll)0;
		}
	}
	for( int i = 0; i < n; i++){
		for( int j = 0; j < n; j ++){
			for( int h = 0; h < n; h ++){
				ans[j][h] = min(ans[j][h], ans[j][i] + ans[i][h]);
			}
		}
	}
	
	int q;
	cin >> q;
	for( int i = 0; i < q; i ++){
		int a, b;
		cin >> a >> b;
		a --, b --;
		if( ans[a][b] >= 1e17){
			cout << -1 << endl;
		}
		else{
			cout << ans[a][b] - 1 << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 1920
# -*- coding: utf-8 -*-
s = list(input())

#if len(set(s)) == 4 or (len(set(s)) == 2 and ('N' in s and 'S' in s) or ('W' in s and 'E' in s)):
#    print("Yes")
if len(set(s)) == 4:
    print("Yes")
elif len(set(s)) == 2 and 'N' in s and 'S' in s:
    print("Yes")
elif len(set(s)) == 2 and 'E' in s and 'W' in s:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38384
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int n,d,x,y;
    cin>>n>>d;
    int ans=0;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        if(pow(d,2)>=pow(x,2)+pow(y,2))
            ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
class SegmentTreeDual():
    def __init__(self,arr,op=lambda x,y:y if y != -1 else x,ie=-1):
        self.h = (len(arr)-1).bit_length()
        self.n = 2**self.h
        self.ie = ie
        self.op = op
        self.val = [ie for _ in range(len(arr))]
        self.laz = [ie for _ in range(2*self.n)]
        for i in range(len(arr)):
            self.val[i] = arr[i]
    def propagate(self,k):
        if self.laz[k] == self.ie:
            return
        if self.n <= k:
            self.val[k-self.n] = self.op(self.val[k-self.n],self.laz[k])
            self.laz[k] = self.ie
        else:
            self.laz[(k<<1)] = self.op(self.laz[(k<<1)],self.laz[k])
            self.laz[(k<<1)+1] = self.op(self.laz[(k<<1)+1],self.laz[k])
            self.laz[k] = self.ie
    def update(self,left,right,f):
        left += self.n
        right += self.n
        for i in reversed(range(self.h+1)):
            self.propagate(left>>i)
        for i in reversed(range(self.h+1)):
            self.propagate((right-1)>>i)
        while right - left > 0:
            if right & 1:
                right -= 1
                self.laz[right] = self.op(self.laz[right],f)
            if left & 1:
                self.laz[left] = self.op(self.laz[left],f)
                left += 1
            left >>= 1
            right >>= 1
    def get(self,index):
        res = self.val[index]
        index += self.n
        while index:
            res = self.op(res,self.laz[index])
            index //= 2
        return res

INF = 2**31-1
N,Q = map(int,input().split())
A = [INF for _ in range(N)]
sg = SegmentTreeDual(A)
ans = []

for _ in range(Q):
    q = list(map(int,input().split()))
    if q[0] == 0:
        s,t,x = q[1:]
        sg.update(s,t+1,x)
    else:
        i = q[1]
        ans.append(sg.get(i))

print('\n'.join(map(str,ans)))



Measured memory_bytes: 16992
def resolve():
    N = int(input())
    p = input().split()
    num = 0
    mini = int(p[0])
    for i in range(N):
        if int(p[i])<=mini:
            num+=1
            mini=int(p[i])
    print(num)
 
 
if __name__ == "__main__":
    resolve()

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

using namespace std;

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

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

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

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

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

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

int n,m;
ll x[1252], y[1252], z[1252];
ll sum[1252];

int main(){
  scanf("%d%d",&n,&m);
  REP(i,n){
    scanf("%lld%lld%lld",x+i,y+i,z+i);
  }
  ll ans = 0;
  REP(d,16){
    REP(i,n)sum[i] = (ll)x[i]+y[i]+z[i];
    sort(sum,sum+n);
    reverse(sum,sum+n);
    ll tmp = accumulate(sum,sum+m,0ll);
    CHMAX(ans, tmp);
    if(d%1==0)REP(i,n)x[i]*=-1;
    if(d%2==0)REP(i,n)y[i]*=-1;
    if(d%4==0)REP(i,n)z[i]*=-1;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    x, n= map(int,input().split())
    inlis = list(map(int, input().split()))
    inlis.sort()

    if x in inlis:
        for i in range(1, 100):
            if x - i in inlis:
                if x + i in inlis:
                    pass
                else:
                    print(x+i)
                    exit()
            else:
                print(x-i)
                exit()
    else:
        print(x)
    
if __name__ == "__main__":
    main()


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define REV(x) reverse(ALL((x)))
#define pb push_back

int main()
{
    string S;
    cin >> S;
    ll K;
    cin >> K;

    ll N = SZ(S);
    ll M = MAX(K,N);
    ll dp[N+1][2][M+1]; // dp[桁][未満フラグ][0でない個数]
    REP(i,0,N+1) {
        REP(smaller,0,2) {
            REP(k,0,M+1) {
                dp[i][smaller][k] = 0;
            }
        }
    }
    dp[0][0][0] = 1;

    REP(i,0,N) {
        REP(smaller,0,2) {
            REP(k,0,M) {
                REP(n,0,smaller?10:(S[i]-'0')+1) {
                    dp[i + 1][smaller || n < (S[i]-'0')][k + (n > 0)] += dp[i][smaller][k];
                }
            }
        }
    }

    PR(dp[N][0][K]+dp[N][1][K]);

    return 0;
}

/*



*/

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

MOD = 1000000007
N = int(input())
U = input() + ' '
D = input()

s = ''
c = 0
while c < len(U)-1:
    if U[c] == U[c+1]:
        s += 'L'
        c += 2
    else:
        s += 'S'
        c += 1


l = s[0]
a = 3 if l == 'S' else 6
for i in s[1:]:
    if l == i == 'S':
        a = (a * 2) % MOD
    elif l == i == 'L':
        a = (a * 3) % MOD
    elif l == 'S' and i == 'L':
        a = (a * 2) % MOD
    l = i
print(a)


Measured memory_bytes: 3064
n=int(input())
d=[list(map(int,input().split())) for i in range(n)]
for i in range(n-2):
  if d[i][0]==d[i][1]:
    if d[i+1][0]==d[i+1][1]:
      if d[i+2][0]==d[i+2][1]:
        print('Yes')
        exit()
print('No')

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

int main(){
    string s;   cin >> s;
    vector<int> a(3);
    string ans="YES";
    for(int i=0; i<s.size(); i++) a.at(s[i]-'a') += 1;
    
    sort(a.begin(), a.end());
    
    if(1<a[2]-a[0])    ans = "NO";

    cout << ans << endl;

}

Measured memory_bytes: 512
KN = input().split(' ')
K = int(KN[0])
N = int(KN[1])
M = K/2
Al = input().split(' ')
A = []

for home in Al:
  A.append(int(home))

m = A[0]+(K-A[-1])
 
for i in range(N-1):
  m = max(m,abs(A[i]-A[i+1]))

print(K-m)

Measured memory_bytes: 26444
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <string.h>
#include <bitset>
#include <map>

using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;
    map<int, int> m;
    for (int i = 0; i < N; ++i)
    {
        int j;
        cin >> j;
        if (m.count(j))
        {
            m[j] += 1;
        }
        else
        {
            m.insert(make_pair(j, 1));
        }
    }

    vector<decltype(m)::value_type::second_type> v;
    for (auto &p : m)
    {
        v.push_back(p.second);
    }
    sort(v.begin(), v.end());
    int sum = 0;
    int l = max(int(v.size() - K), 0);
    for (int i = 0; i < l; ++i)
    {
        sum += v[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 10748
#include <stdio.h>
void solve(void)
{
	char c;
	scanf("%c",&c);
	switch(c){
		case 'a':
		case 'e':
		case 'i':
		case 'o':
		case 'u':
			printf("vowel\n");
			break;
		default:
			printf("consonant\n");
			break;
	}
}
int main(int argc, char **argv)
{
	solve();
	return 0;
}


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll n; cin >> n;
  cout << 180*(n-2) << endl;
  
  
}

Measured memory_bytes: 3564
#include<stdio.h>
#define N 100
#define M 2000000

int main(void) {

  int n,p[N],m[N][N];
  int i,j,k,l,q;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d%d",&p[i],&j);

  p[n] = j;;
  for(i=1;i<=n;i++)
    m[i][i] = 0;
  
  for(l=2;l<=n;l++) {
    for(i=1;i<=n-l+1;i++) {
      j = i + l - 1;
      m[i][j] = M;
      for(k=i;k<=j-1;k++) {
	q = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];
	
	if(m[i][j] > q)
	  m[i][j] = q;
      }
    }
  }
  printf("%d\n",m[1][n]);

 return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

char c[6][6];
char mark[6][6];

int h,w;
int k;
int bn;

int count3(set<int>hs, set<int>ws) {
//printf("count3(");
//printf("{"); for (auto ih=hs.begin(); ih!=hs.end(); ih++) printf("%d ", *ih); printf("},");
//printf("{"); for (auto ih=ws.begin(); ih!=ws.end(); ih++) printf("%d ", *ih); printf("}");
//printf(")=");
  int cx=0;
  for(int i=0; i<h; i++) {
    auto ith=hs.find(i);
    if (ith!=hs.end()) continue;
    for (int j=0; j<w; j++) {
      auto itw=ws.find(j);
      if (itw!=ws.end()) continue;
//printf("(c:%d/%d)", i, j);
      if (c[i][j] == '#') cx++;
      if (cx>k) {
//printf("0\n");
        return 0;
      }
    }
  }
  if (cx == k) {
//printf("1\n");
    return 1;
  }
//printf("0\n");
  return 0;
}
int count2(set<int> hs, set<int> ws, int ny, int y) {
  if (ny>w) return 0;
//printf("count2(_, _, %d, %d)\n", ny, y);
  int ret=0;
  if ((int)ws.size() == y) {
    return count3(hs, ws);
  }
//  set<int> ws2 = ws;
  // nyを入れる場合
  ws.insert(ny);
  ret += count2(hs, ws, ny+1, y);
  // nyを入れない場合
  ws.erase(ny);
  ret += count2(hs, ws, ny+1, y);
  return ret;
}
int count1(set<int> hs, int nx, int x, int y) {
  if (nx>h) return 0;
//printf("count1(_, %d, %d, %d)\n", nx, x, y);
  int ret=0;
  if ((int)hs.size() == x) {
    set<int> ws;
    return count2(hs, ws, 0, y);
  }
//  set<int> hs2=hs;
  // nxを入れる場合
  hs.insert(nx);
  ret += count1(hs, nx+1, x, y);
  // nxを入れない場合
  hs.erase(nx);
  ret += count1(hs, nx+1, x, y);
  return ret;
}
int count(int x, int y) {
  int ret;
  set<int> hs;
//printf("count(%d, %d)\n", x, y);

  ret = count1(hs, 0, x, y);
  return ret;
}
int main()
{
  ll ans=0;
  int i, j;

  cin >> h >> w >> k;

  bn = 0;
  for (i=0; i<h; i++) {
    for (j=0; j<w; j++) {
      cin >> c[i][j];
      if (c[i][j] == '#') bn++;
    }
  }
  if (bn < k) {
    printf("0\n");
    return 0;
  }

  for (i=0; i<=h; i++) {
    for (j=0; j<=w; j++) {
      ans += count(i, j);
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3644