akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        System.out.println(str);
    }

    public static void main(String[] args) {

        int N;
        int Q;

        Node[] nodes;
        Operation[] ope;

        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            Q = sc.nextInt();

            nodes = new Node[N];
            ope = new Operation[Q];

            for (int i = 0; i < N; i++) {
                nodes[i] = new Node(i+1);
            }

            for(int i = 0; i < N-1; i++){
                int a = sc.nextInt();
                int b = sc.nextInt();

                nodes[a - 1].nodeList.add(nodes[b - 1]);
                nodes[b - 1].nodeList.add(nodes[a - 1]);
            }

            for(int i = 0; i < Q; i++){
                int p = sc.nextInt();
                int x = sc.nextInt();

                Operation e = new Operation(p, x);
                ope[i] = e;
            }

            for(Operation o :ope){
                int p = o.p;
                int x = o.x;
                nodes[p - 1].addNum += x;
            }

            //深さ優先探索
            Deque<Node> queue = new ArrayDeque<Node>(N);
            nodes[0].visited = true;
            queue.add(nodes[0]);
            nodes[0].realNUm += nodes[0].addNum;
            Node n = null;

            while ((n = queue.peekLast()) != null) {
                //未訪問の隣接ノードを取得
                Node m = n.getUnVisitNode();
                //隣接ノードあり。
                if(m != null){
                    m.visited = true;
                    queue.add(m);
                    m.realNUm = m.addNum +n.realNUm;
                }else{
                    //隣接ノードなし
                    queue.pollLast();
                }
            }
            StringBuilder sb = new StringBuilder();
            for(Node noo :nodes){
                sb.append(noo.realNUm + " ");
            }
            System.out.println(sb.toString());
        }
    }


    public static class Node {
        long addNum = 0;
        long realNUm = 0;
        long id;
        boolean visited = false;
        List<Node> nodeList = new LinkedList<>();
        public Node(int id){
            this.id = id;
        }

        public Node getUnVisitNode(){
            Node result = null;
            for(Node n : nodeList){
                if(!n.visited){
                    result = n;
                    break;
                }
            }
            nodeList.remove(result);
            return result;
        }

        public void print(){
            System.out.println("["+id+"]:"+addNum +":"+realNUm);
        }

    }

    public static class Operation {
        int p;
        int x;
        public Operation(int p, int x) {
            this.p = p;
            this.x = x;
        }
    }
}


Measured memory_bytes: 228332
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var s = next();
  if(s.indexOf("7") != -1){
    myout("Yes");
  }else{
    myout("No");
  }
}

Measured memory_bytes: 29688
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
using namespace std;

// Monday-Saturday Prime Factors(1154)
int main()
{
	//freopen("1154.txt", "r", stdin);

	const int MAX = 300000+1;
	bool msp[MAX];
	for (int i = 0; i < MAX; ++i)
		msp[i] = true;
	msp[1] = false;
	for (int i = 0; i < MAX; ++i) {
		if (!(i%7 == 1 || i%7 == 6))
			msp[i] = false;
	}

	for (int i = 0; i*i < MAX+1; ++i) {
		if (msp[i]) {
			for (int j = i+i; j < MAX; j += i)
				msp[j] = false;
		}
	}

	vector<int> p;
	for (int i = 0; i < MAX; ++i) {
		if (msp[i])
			p.push_back(i);
	}

	int n;
	while (cin >> n) {
		if (n == 1)
			break;

		cout << n << ":";
		for (unsigned int i = 0; i < p.size(); ++i) {
			if (n%p[i] == 0) {
				cout << " " << p[i];
			}
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1464
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cmath>
#include <cstdio>
#define int long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int n,m,ans;
int a[20][20];
bool check(int x,int y){
	int p=0;
	for(int i=1;i<=m;i++)p+=(a[x][i]-a[y][i])*(a[x][i]-a[y][i]);
	int q=sqrt(p);
	if(q*q==p)return 1;
	return 0;
}
signed main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cin>>a[i][j];
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(check(i,j))ans++;
	cout<<ans<<endl;
	return 0;
}


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

int n, cnt, ans_num;
vector<int> a;
vector<int> ans;

int main(){

    cin >> n;
    for(int i=0; i<n; i++){
        int temp;
        cin >> temp;
        a.push_back(temp);
    }

    cnt = 1;
    for (int i=0; i<n; i++){
        if (a.at(i) == cnt){
            ans.push_back(cnt);
            cnt++;
        }
    }

    ans_num = n - ans.size();
    
    if (ans_num == n){
        cout << -1 << endl;    
    }
    else{
        cout << ans_num << endl;
    }
    
    return 0;

}

Measured memory_bytes: 2548
n, m, x = map(int, input().split())
C = []
A = []
for i in range(n):
    L = list(map(int, input().split()))
    C.append(L[0])
    A.append(L[1:m+1])
# print(C, A)
ans = sum(C) + 1

for i in range(2**n):
    # print(bin(i))
    study = [0] * m
    price = 0
    for j in range(n):
        if i >> j & 1:
            for k in range(m):
                study[k] += A[j][k]
            price += C[j]
            # print(study, price)
            if min(study) >= x:
                ans = min(ans, price)

if ans == sum(C) + 1:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 68612
using System;
using System.Collections.Generic;

namespace practice_csharp
{
    class Program
    {
        private static Dictionary<string,int> Day = new Dictionary<string, int>()
        {
            {"SUN",7},
            {"SAT",1},
            {"FRI",2},
            {"THU",3},
            {"WED",4},
            {"TUE",5},
            {"MON",6}
        };
        static void Main(string[] args)
        {
            var after = Day[Console.ReadLine()];
            Console.WriteLine(after);
        }
    }
}

Measured memory_bytes: 13152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	int n;cin>>n;
	ll x[n],l[n];
	rep(i,n) cin>>x[i]>>l[i];

	pair<ll,ll> gs[n];
	rep(i,n){
		gs[i].first=x[i]+l[i];
		gs[i].second=x[i]-l[i];
	}
	sort(gs,gs+n);
	ll now=-INF,cnt=0;
	rep(i,n){
		if(now<=gs[i].second){
			cnt++;
			now=gs[i].first;
		}
	}

	cout<<cnt<<"\n";
}

Measured memory_bytes: 3328
#include <stdio.h>
int main()
{
  char S[100];
  scanf("%s",S);
  int i,len;
  i = 0;
  while (S[i])
  {
    i++;
  }
  len = i - 1;
  i = 0;
  while (i != len/2 + 1)
  {
    if (S[i] != S[len - i])
    {
      printf("No");
      return(0);
    }
    i++;
  }
  i = 0;
  while (i != (len - 1)/2)
  {
    if (S[i] != S[((len - 1) / 2) - i])
    {
      printf("No");
      return(0);
    }
    i++;
  }
  printf("Yes");
}

Measured memory_bytes: 128
/**
 *    author:  FromDihPout
 *    created: 2020-07-25
**/

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    long long pos = 0, sum = 0;
    for (int i = 0; i < n; i++) {
        sum += a[i];
        if (i % 2 == 0 && sum <= 0) {
            pos += 1 - sum;
            sum = 1;
        }
        else if (i % 2 == 1 && sum >= 0) {
            pos += sum - (-1);
            sum = -1;
        }
    }
    
    long long neg = 0;
    sum = 0;
    for (int i = 0; i < n; i++) {
        sum += a[i];
        if (i % 2 == 1 && sum <= 0) {
            neg += 1 - sum;
            sum = 1;
        }
        else if (i % 2 == 0 && sum >= 0) {
            neg += sum - (-1);
            sum = -1;
        }
    }
    
    cout << min(pos, neg) << '\n';
    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#include<algorithm>

#define MAX_V 100
#define INF 9999

int prim(void);

int cost[MAX_V][MAX_V]; //cost[u][v]は辺e=(u,v)のコスト(存在しない場合はINF)
int mincost[MAX_V]; //集合Xからの最小コスト
bool used[MAX_V]; //頂点iがxに含まれているか
int V; //頂点数

using namespace std;

int main(){
  int n,i,c,j,a,b;
  
  while(1){
    scanf("%d",&V);
    if(V==0) break;
    scanf("%d",&n);
    for(j=0;j<V;j++){
      for(i=0;i<V;++i){
	cost[j][i]=INF;
      }
    }
    for(i=0;i<n;i++){
      scanf("%d,%d,%d",&a,&b,&c);
      cost[a][b]=c/100-1;
      cost[b][a]=c/100-1;
    }
    printf("%d\n",prim());
    
  }
  return 0;
}

int prim(){
  
  //初期化
  for(int i=0;i<V;++i){
    mincost[i]=INF;
    used[i]=false;
  }
  
  mincost[0]=0;
  int res=0;
  
  while(true){
    int v=-1;
    //xに属さない頂点のうちxからの辺のコストが最小になる頂点を探す
    for(int u=0;u<V;u++){
      if(!used[u]&&(v==-1||mincost[u]<mincost[v])) v=u;
    }
    if(v==-1) break;
    
    used[v]=true; //頂点vをxに追加
    res+=mincost[v]; //辺のコストを比べる
    
    for(int u=0;u<V;u++){
      mincost[u]=min(mincost[u],cost[v][u]);
    }
  }
  return res;
}

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

using namespace std;

int main() {
    //freopen("sample-8.in", "r", stdin);
    //freopen("output8.txt", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    bool ym=true,my=true;
    int a=0,b=0;
    string l="",r="";
    l+=s[0];
    l+=s[1];
    r+=s[2];
    r+=s[3];
    stringstream ss1,ss2;
    ss1<<l;
    ss1>>a;
    ss2<<r;
    ss2>>b;
    if(a>12||a<=0){
        my=false;
    }
    if(b>12||b<=0){
        ym=false;
    }
    if(my&&ym){
        cout<<"AMBIGUOUS"<<endl;
    }
    else if(my){
        cout<<"MMYY"<<endl;
    }
    else if(ym){
        cout<<"YYMM"<<endl;
    }
    else{
        cout<<"NA"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        char[] arr = s.toCharArray();
        int max;
        int c;
        c = max = 0;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == 'R') {
                c = c + 1;
            } else {
                c = 0;
            }
            if (c > max) {
                max = c;
            }
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 35592
/*package whatever //do not write package name here */

import java.util.*;
import java.lang.*;
import java.io.*;

class Main {
	public static void main (String[] args)throws IOException{
		//code
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		
		String[]s;
		  
            int n=Integer.parseInt(br.readLine());
            
		    int [][]ar=new int[n][3];
		    
		    for(int i=0;i<n;i++){
                s=br.readLine().split("\\s+");
                ar[i][0]=Integer.parseInt(s[0]);
                ar[i][1]=Integer.parseInt(s[1]);
                ar[i][2]=Integer.parseInt(s[2]);
            }
            int dp[][]=new int[n][3];
            dp[0][0]=ar[0][0];
            dp[0][1]=ar[0][1];
            dp[0][2]=ar[0][2];
            int v=0;
            for(int i=0;i<3;i++)v=Math.max(v,dp[0][i]);
            for(int i=1;i<n;i++){
               for(int k=0;k<=2;k++){
                for(int j=0;j<=2;j++){
                    if(k!=j)
                    dp[i][k]=Math.max(dp[i-1][j]+ar[i][k],dp[i][k]);
                    
                }
                v=Math.max(dp[i][k],v);
              }
            }
                
            
          
            System.out.print(v);
		
		    
	
		
	}
}


Measured memory_bytes: 67928
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n,a,b;
    cin >> n >> a >> b;
    VI p(n);
    REP(i,0,n)cin >> p[i];
    int cnt[3] = {};
    REP(i,0,n) {
        if (p[i] <= a) cnt[0]++;
        else if (p[i] <= b) cnt[1]++;
        else cnt[2]++;
    }
    cout << min({cnt[0], cnt[1], cnt[2]}) << endl;
}

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
#define int long long
#define rep(i,a,n) for (int (i)=(a);(i)<(n);(i)++)
using namespace std;
#define hash hush
typedef long long ll;
typedef long double ld;
signed  main() {
	int n, a[100], sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	sort(a, a + n);
	reverse(a, a + n);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (sum - a[i] > ans&&(sum-a[i])%10!=0)
			ans = sum - a[i];
	}
	if (sum % 10 != 0)
		ans = sum;
	cout << ans << endl;
	getchar(); getchar();
}

Measured memory_bytes: 256
//https://beta.atcoder.jp/contests/abc085/submissions/1964917

#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)

int main(){
    int n,money;
    cin>>n>>money;
    
    int x = 0;
    int y = 0;
    int z = int(money/1000);
    
    if(z<n){
        cout<<"-1 -1 -1"<<endl;
    }else if(z==n){
        cout<<x<<" "<<y<<" "<<z<<endl;
    }else{
        int div1000 = min(int((z-n)/4), int(z/5));
        z = z - (5*div1000);
        y += div1000;
        
        if(y+z==n){
            cout<<x<<" "<<y<<" "<<z<<endl;
        }else{
            if(int(y/2) >= y+z-n){
                x += y+z-n;
                y -= (y+z-n)*2;
                cout<<x<<" "<<y<<" "<<z<<endl;
            }else{
                cout<<"-1 -1 -1"<<endl;
            }
        }
    }
}


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

int main()
{
  	int a = 1,b = 1;

 	while(a > 0 || b > 0){
      cin >> a >> b;
      if(a > 0 || b > 0)
        cout << min(a,b) << " " << max(a,b) << endl;
    } 
}


Measured memory_bytes: 3004
#include <bits/stdc++.h>
 
#define ll long long
#define ull unsigned ll
#define vi vector<ll>
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define ld long double
#define pii pair<ll, ll>
#define mt make_tuple
#define mn(a, b) a = min(a, b)
#define mx(a, b) a = max(a, b)
 
using namespace std;
 
const ll INF = (ll)2e9;
const ll inf = (ll)2e18;
const ld eps = (ld)1e-8;
const ll mod = (ll)998244353;
const ll MAXN = (ll)1e5 + 1;
const ll MAXC = (ll)1e6 + 1;
const ll MAXE = (ll)1000;
const ll MAXLOG = 21;
const ll maxlen = (ll)1e5;
const ll asci = (ll)256;
const ll block = 480;
const ld PI = acos(-1);
const ld e = 2.7182818284;
 
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<
pii,
null_type,
less<pii>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;*/
 
template <class T>
istream& operator >>(istream &in, vector<T> &arr){
    for (T &cnt : arr) {
        in >> cnt;
    }
    return in;
};

void solve() {
    int r, c, n; cin >> r >> c >> n;
    vector<pii> pts;
    for (int i = 0; i < n; ++i) {
        int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
        if ((!x1 || x1 == r || !y1 || y1 == c) && (!x2 || x2 == r || !y2 || y2 == c)) {
            if (!x1 || y1 == c) pts.push_back(mp(x1 + y1, i));
            else pts.push_back(mp(r + c + (r - x1) + (c - y1), i));
            if (!x2 || y2 == c) pts.push_back(mp(x2 + y2, i));
            else pts.push_back(mp(r + c + (r - x2) + (c - y2), i));
        }
    }
    sort(all(pts));
    stack<int> q;
    for (int i = 0; i < pts.size(); ++i) {
        if (q.size() && q.top() == pts[i].second) {
            q.pop();
        } else {
            q.push(pts[i].second);
        }
    }
    if (!q.size()) cout << "YES\n";
    else cout << "NO\n";
}

int main() {
    srand(time(0));
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#endif
    cout.precision(30);
    solve();
 
    return 0;
}

Measured memory_bytes: 7392
#include<iostream>
using namespace std;
  
int main(){
	int w,h,i,j,k,s_b,s_w,b[51][51],wh[51][51];
	char a[51][51];
	while(1){
		s_b=0;s_w=0;
		for(i=0;i<51;i++){
			for(j=0;j<51;j++){
				a[i][j]='\0';
				b[i][j]=0;
				wh[i][j]=0;
			}
		}
		/*0範囲外　1芝生　2杭　3間接隣接*/
		cin>>w>>h;
		if(w==0&&h==0){break;}
		for(i=1;i<h+1;i++){
			for(j=1;j<w+1;j++){
				cin>>a[i][j];
				if(a[i][j]=='B'){
					b[i][j]=2;
					wh[i][j]=1;
				}else if(a[i][j]=='W'){
					wh[i][j]=2;
					b[i][j]=1;
				}else{
					b[i][j]=1;
					wh[i][j]=1;
				}
			}
		}
		for(k=0;k<w*h;k++){
			for(i=1;i<h+1;i++){
				for(j=1;j<w+1;j++){
					if(b[i][j]==1&&wh[i][j]!=2){
						if(b[i+1][j]==2||b[i-1][j]==2||b[i][j+1]==2||b[i][j-1]==2){
							b[i][j]=3;
						}							
						if(b[i+1][j]==3||b[i-1][j]==3||b[i][j+1]==3||b[i][j-1]==3){
							b[i][j]=3;
						}
					}
					if(wh[i][j]==1&&b[i][j]!=2){
						if(wh[i+1][j]==2||wh[i-1][j]==2||wh[i][j+1]==2||wh[i][j-1]==2){
							wh[i][j]=3;
						}
						if(wh[i+1][j]==3||wh[i-1][j]==3||wh[i][j+1]==3||wh[i][j-1]==3){
							wh[i][j]=3;
						}
					}
				}
			}
		}
		for(i=1;i<h+1;i++){
			for(j=1;j<w+1;j++){
				if(b[i][j]==3&&wh[i][j]!=3){
					s_b++;
				}
				if(b[i][j]!=3&&wh[i][j]==3){
					s_w++;
				}
			}
		}
		cout<<s_b<<' '<<s_w<<endl;
	}
    return 0;
}

Measured memory_bytes: 1180
#include <iostream>

const int N = 10;

bool digits(int n, const bool *arr) {
    while (n > 0) {
        int digit = n % 10;
        if (arr[digit]) {
            return false;
        }
        n /= 10;
    }
    return true;
}

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);

#if DEBUG_ON
    freopen("input", "r", stdin);
#endif

    int n, k;
    std::cin >> n >> k;
    bool arr[N] = { false };
    for (int i = 0; i < k; ++i) {
        int a;
        std::cin >> a;
        arr[a] = true;
    }
    int res = n;
    while (!digits(res, arr)) {
        ++res;
    }
    std::cout << res << '\n';
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
private static Scanner scanner;

public static void main(String args[])
{
	scanner = new Scanner(System.in);
	int a = scanner.nextInt(),b = scanner.nextInt();
	if(a < b) {
		int tmp = a;
		a = b;
		b = tmp;
	}
	while(a%b != 0) {
		int c = a%b;
		a = b;
		b = c;
	}
	System.out.println(b);
}
}




Measured memory_bytes: 26384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; n>=0; --i)
#define all(a) (begin(a)),(end(a))
#define rall(a) (rbegin(a)),(rend(a))
inline constexpr ll Inf = (1ULL << 62) -1;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define endl '\n'
template <class T> void updatemax(T& a, T b) { if (b > a) a = b; }

int main() {
    fastio;
    ll ans=0;
    ll x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector<int> p(a), q(b), r(c);
    rep(i,a) cin >> p[i];
    rep(i,b) cin >> q[i];
    rep(i,c) cin >> r[i];
    sort(rall(p));
    sort(rall(q));
    p.erase(p.begin()+x, p.end());
    p.insert(end(p), begin(q), begin(q)+y);
    p.insert(end(p), all(r));
    sort(rall(p));
    rep(i,x+y)
        ans += p[i];
    cout << ans << endl;
}


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

int main() {
  int N;
  cin >> N;
  int sum = 0;

  for (int i=0; i<N; i++){
    int l, r;
    cin >> l >> r;
    sum = sum + r - l + 1;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
import math
from decimal import Decimal, ROUND_DOWN


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (n, ) = [int(e) for e in lines[0].split(' ')]

    return (n, )


def solve(n):

    def s(n):
        return (int(26 ** n) - 1) * 26 // 25

    d = 0
    for i in range(1, 100): 
        if s(i-1) + 1 <= n and n <= s(i):
            d = i
            break

    # 26 + 26**2 + 1   26 + 26**2 * 26**3    s(3)
    # aaa              zzz
    # 1から26**3まで
    # 1ずらして
    # 0から26**3 - 1までとすると
    # 26進数で
    # aが0でzが25に対応するようになる

    m = n - s(d- 1) - 1
    ks = []
    while True:
        k = m // 26
        r = m % 26
        ks.append(r)
        if k == 0:
            break
        m = k

    ks.reverse()

    names = 'abcdefghijklmnopqrstuvwxyz'
    result = []
    for k in ks:
        result.append(names[k])

    pad_size = d - len(result)
    result = ["a"] * pad_size + result

    return ''.join(result)
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

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

const int N = 100 * 1000 + 10;

int n;
int q[N], L, R; // <- queue
set <int> adj[N];

void input() {
    cin.tie(0);
    cin >> n;

    int u, v;
    for (int i = 0; i < n - 1; i++) {
        cin >> u >> v;
        u--, v--;

        adj[v].insert(u);
        adj[u].insert(v);
    }
    return;
}

void solve() {
    if (n % 2 == 1) {
        cout << "First";
        return;
    }

    for (int i = 0; i < n; i++)
        if (adj[i].size() == 1)
            q[R++] = i;

    while (L < R) {
        int v = q[L++], par = *(adj[v].begin());
        if (adj[v].empty())
            continue;

        for (auto u : adj[par]) {
            adj[u].erase(par);

            if (adj[u].size() == 1)
                q[R++] = u;
            else if (u != v && adj[u].size() == 0) {
                cout << "First";
                return;
            }
        }
        adj[par].clear();
    }

    cout << "Second";
    return;
}

int main() {
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}


Measured memory_bytes: 14592
//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
// using namespace __gnu_pbds;
// template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;



#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define in insert
#define ld long double


#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define int ll
const ll mod =1e9+7;
const ll MAX_NODES =200001;
const ll MAX_LOG =50;
const ll maxn = 400000+10;


int32_t main()
{

  int k,n;
  cin>>k>>n;
  int a[n],maxi = 0,sum = 0;
  for(int i = 0;i<n;i++)
  {
    cin>>a[i];
    if(i)
    {
      sum+=a[i]-a[i-1];
      maxi = max(maxi,a[i]-a[i-1]);
    }
  }
  sum+=(a[0]-a[n-1]+k)%k;
  maxi = max(maxi,(a[0]-a[n-1]+k)%k);
  cout<<sum-maxi<<endl;
  
  








}


Measured memory_bytes: 1792
import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from itertools import combinations as comb
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)
def y(f):
    if f:
        print('Yes')
    else:
        print('No')
def Y(f):
    if f:
        print('YES')
    else:
        print('NO')
def qw(f):
    if f:
        print('Yay!')
    else:
        print(':(')

n,k = map(int,input().split())
l = [0] * k
for i in range(min(n, k)):
    l[i] += 1
    n -= 1
l[0] += n
print(max(l) - min(l))


Measured memory_bytes: 5588
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);

  cout << a[0] + a[1] << endl;
  return 0;
}


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

int main()
{
    long long n;
    cin>>n;
    if(n==1||n==2){cout<<n;return 0;}
    int z;
    while(z=1)
    {
        z=0;
        for(int i=2;i<=n/2;i++)
        {
            if(n%i==0){z=1;}
            
        }
        if(z==0){break;}
            else{n++;}
        
    }
   cout<<n;return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){

  int i;
  char input[1000];

  scanf("%s",input);

  for(i = 0; input[i] != '\0'; i++){

    if('D' <= input[i] && input[i] <= 'Z') input[i] -= 3;
    else input[i] += 23;

  }

  printf("%s\n",input);

  return 0;

}
  

Measured memory_bytes: 524
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
 
const int MAXN = 2e5+2;
const int MOD = 998244353; //1e9+7;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define FAIL0 {cout << "0\n"; return 0;}
#define FAIL1 {cout << "-1\n"; return 0;}
#define FAILNO {cout << "No\n"; return 0;}
#define YES {cout << "Yes\n"; return 0;}

int N;
LL K;
int A[MAXN];
int nxt[MAXN];
int lst[MAXN];
int T = 0;
vector<int> ans;

int main() {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> N >> K;
    for (int i = 1; i <= 2e5; i++) lst[i] = -1;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (lst[A[i]] == -1) lst[A[i]] = i;
    }

    for (int i = N-1; i >= 0; i--) {
        int a = A[i];
        nxt[i] = lst[a];
        lst[a] = i;
    }

    int c = 0;
    T = 1;
    while(1) {
        int n = nxt[c];
        if (n <= c) T++;
        //debug(c);
        //debug(A[c]);
        //debug(n);
        //debug(T);
        //cout << '\n';
        if (n == N-1) {break;}
        c = n+1;
    }

    //debug(T);
    LL r = K%T;
    //debug(r);

    c = 0;
    while(r) {
        int n = nxt[c];
        if (n == N-1 || n <= c) {
            if (r == 1) break;
            r--;
        }
        c = (n+1)%N;
    }

    for (;c < N;) {
        int n = nxt[c];
        if (n <= c) {
            ans.pb(A[c]);
            c++;
        } else if (n == N-1) {
            break;
        } else {
            c = n+1;
        }
    }

    for (auto a: ans) cout << a << ' ';
    cout << '\n';
    return 0;
}


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

int main(void) {
    string a,b;cin>>a>>b;
    int c = stoi(a + b);
    int i = 1;
    bool hit = false;
    while (i * i <= c) {
        if (i * i == c) hit = true;
        i++;
    }
    if (hit) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 888
N=int(input())
AC=0
WA=0
TLE=0
RE=0
 
for k in range(N):
  K=input()
  if K=="AC":
    AC=AC+1
  if K=="WA":
    WA=WA+1
  if K=="TLE":
    TLE=TLE+1
  if K=="RE":
    RE=RE+1
 
print("AC x " + str(AC))
print("WA x " + str(WA))
print("TLE x " + str(TLE))
print("RE x " + str(RE))

Measured memory_bytes: 9184
#include<bits/stdc++.h>
#include<queue>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
using namespace std;


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int S;

  cin>>S;
  int yymm=0,mmyy=0;
  int dS =(int)S%100;
  int uS = (S-dS)/100; 

  if(1<=uS&&uS<=12){
    mmyy = 1;
  }

  if(1<=dS&&dS<=12){
    yymm = 1;
  }

  if(yymm == 1 && mmyy == 1){
    cout<<"AMBIGUOUS";
  }else if(mmyy == 1){
    cout<<"MMYY";
  }else if(yymm == 1){
    cout<<"YYMM";
  }else{
    cout<<"NA";
  }
  

  
  return 0;
}

Measured memory_bytes: 256
from collections import deque


def solve():

    K = int(input())

    dq = deque()
    # 一桁のケース
    for i in range(9):
        dq.append(i+1)

    for i in range(K):
        num = dq.popleft()
        if num % 10 != 0:
            dq.append(num*10+num % 10-1)
        dq.append(num*10+num % 10)
        if num % 10 != 9:
            dq.append(num*10+num % 10+1)

    print(num)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 40688
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#define rep(i,N) for(int i=0;i<N;i++)

long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;

int main(){

int K,T;
cin>>K>>T;
vector<long long >a(T);
rep(i,T){
cin>>a[i];
}
sort(a.begin(),a.end());

long long Max=a[T-1];
long long other=0;
rep(i,T-1){
other+=a[i];
}
long long t=0;
long long ans=max(t,Max-other-1);
cout<<ans<<endl;



 return 0;
}
/*
7 3
3 2 2

0

6 3
1 4 1

1

100 1
100

99

*/

Measured memory_bytes: 256
/********************************************
 *Author*        :ZZZZone
 *Created Time*  : 六 11/ 4 23:07:32 2017
 * Ended  Time*  : 六 11/ 4 23:39:35 2017
*********************************************/

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

inline void OPEN(string s){
	freopen((s + ".in").c_str(), "r", stdin);
	freopen((s + ".out").c_str(), "w", stdout);
}

const int MaxN = 1e5;
int a[MaxN + 5], b[MaxN + 5], c[MaxN + 5];
int n;

int main()
{
	while(~scanf("%d", &n)){
		for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
		for(int i = 1; i <= n; i++) scanf("%d", &b[i]);
		for(int i = 1; i <= n; i++) scanf("%d", &c[i]);
		sort(a + 1, a + 1 + n);
		sort(b + 1, b + 1 + n);
		sort(c + 1, c + 1 + n);
		LL ans = 0;
		int pa = 0, pc = 0;
		//a[n+1] = 1<<30, c[n+1] = 1<<30;
		for(int i = 1; i <= n; i++){
			while(a[pa+1] < b[i] && pa < n) pa++;
			while(c[pc+1] <= b[i] && pc < n) pc++;
			//printf("%d %d\n", pa, pc);
			ans += 1LL * pa * (n - pc);
		}
		printf("%lld\n", ans);
	}
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;

using namespace std;

int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    int ans = 0;
    int tmp=0;
    rep(i,n){
        if (s[i]=='D') tmp -= 1;
        else {
            tmp += 1;
            if (tmp > ans) ans =tmp;
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
/*
    ##############################
    #  Author: Pratyush Gaurav   #
    #  College: NIT ROURKELA     #
    ##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

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

void solve() {
    lli n, k;
    cin >> n >> k;
    
    vlli positive, negative;

    for (int i = 0; i < n; ++i) {
        lli x;
        cin >> x;
        if (x < 0) negative.push_back(x);
        else positive.push_back(x);
    }

    lli ans = INF;
    
    for (int i = 0; i <= k; ++i) {
        lli neg = i, pos = k - i, res = 0;
        if (i > negative.size() or (k - i) > positive.size()) continue;

        if (neg == k) {
            res = abs(negative[negative.size() - k]);
        } else if (pos == k) {
            res = positive[k - 1];
        } else {
            res = positive[pos - 1] + abs(negative[negative.size() - neg]);
            res += min(positive[pos - 1], abs(negative[negative.size() - neg]));
        }
        //cout << pos << " " << neg << " " << res << endl;
        ans = min(ans, res);
    }

    cout << ans << endl;
}

int main()
{
    IOS;
    lli t = 1;
    //cin >> t;

    while(t--)
        solve();
    return 0;
}

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

int main(){
  int A, B, S = 0;
  cin >> A >> B;
  
  int i = A;
  while (i <= B){
    int a=i/10000, b=i%10000/1000, c=i%100/10, d=i%10;
    if (a == d && b == c){
        S += 1;
    }
    i++;
  }
  cout << S << endl;
}
    

Measured memory_bytes: 256
#include"iostream"
using namespace std;

int main()
{
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << x2 - y2 + y1 <<" "<< y2 + x2 - x1 <<" "<< x1 - y2 + y1 <<" "<< y1 + x2 - x1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    int K,S;
    cin >> K >> S;
    int cnt = 0;
    for(int i = 0;i <= K;i++){
        if(i < S - K * 2 || S - i < 0)continue;
        for(int j = 0;j <= K;j++){
            if(S - i - j <= K && S - i - j >= 0)cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int main()
{
  int N;
  cin >> N;
  vint A(N+1);
  vint B(N);
  cin >> A;
  cin >> B;
  
  ll ans = 0;
  REP(i,N){
    REP(j,2){
      if(A[i+j] >= B[i]){
        ans += B[i];
        A[i+j] -= B[i];
        B[i] = 0;
      }else{
        ans += A[i+j];
        B[i] -= A[i+j];
        A[i+j] = 0;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
n=int(input())
T=0; X=0; Y=0;
ans="Yes"
for i in range(n):
    t,x,y=map(int,input().split())
    s=t-T
    if s >= abs(X-x)+abs(Y-y) and (s-abs(X-x)+abs(Y-y))%2==0:
        T,X,Y = t,x,y
    else:
        ans="No"
        break
print(ans)

Measured memory_bytes: 9196
#include <iostream>
#include <vector>
#include <set>

int f(int n,int a,int b){
	int t = a-b;
	if(t<0)t+=n;
	if(t > n/2){
		return n-t;
	}else{
		return t;
	}
}

int main(){
	int n;
	while(true){
		std::cin >> n;
		if(n==0)break;
		std::set<int> nums;
		for(int i=1;i<n;i++){
			nums.insert((i*i)%n);
		}
		std::vector<int> buf(n/2,0);
		for(int a : nums){
			for(int b : nums){
				if(a!=b)buf[f(n,a,b)-1]++;
			}
		}
		for(int x : buf){
			std::cout << x << std::endl;
		}
	}
}

Measured memory_bytes: 1452
from itertools import combinations, product


def gcd(a, b):
    if a < b:
        a, b = b, a
    while b != 0:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)


def get(fmt):
    ps = input().split()
    r = []
    for p, t in zip(ps, fmt):
        if t == "i":
            r.append(int(p))
        if t == "f":
            r.append(float(p))
        if t == "s":
            r.append(p)
    if len(r) == 1:
        r = r[0]
    return r

def put(*args, **kwargs):
    print(*args, **kwargs)


def rep(n, f, *args, **kwargs):
    return [f(*args, **kwargs) for _ in range(n)]
    
def rep_im(n, v):
    return rep(n, lambda: v)
    
YES_NO = ["NO", "YES"]


N = get("i")

put(N * (N + 1) // 2)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl;
#define rep(i,n) for(ll i = 0;i < n;++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0);

const ll INF = 1e9+7;

// 各桁の和
template<typename T>
T digit(T num){
  T sum = 0;
  while(num){
    sum += num % 10;
    num /= 10;
  }
  return sum;
}

int main(){
  ll N,A,B;
  cin>>N>>A>>B;
  vector<ll> X(N);
  rep(i,N)cin>>X[i];
  sort(all(X));
  vector<ll> dif(N);
  
  rep(i,N){
    if(i == 0)continue;
    dif[i] = X[i] - X[i - 1];
    dif[i] *= A;
  }
  
  sort(all(dif));
  
  ll ans = 0;
  rep(i,N){
    if(dif[i] > B){
      ans += B; 
    }else{
      ans+= dif[i];
    }
  }
  print(ans)
  return 0;
}


Measured memory_bytes: 1792
readints()=parse.(Int,split(readline()))
X,N=readints()
p=readints()

ans0=50
for i in 0:100
    s=X-i
    if sum(p.==s)==0
        global ans0=s
        break
    end
    s=X+i
    if sum(p.==s)==0
        ans0=s
        break
    end
end
print(ans0)

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

int n, a, b, p, t1, t2, t3;

int main() {
    cin >> n >> a >> b;
    rep(i, n) {
        cin >> p;
        if (p <= a) t1++;
        else if (p <= b) t2++;
        else t3++;
    }
    cout << min({t1, t2, t3}) << endl;
    return 0;
}

Measured memory_bytes: 256
N, M, C = [int(_) for _ in input().split()]
B = [int(_) for _ in input().split()]

ans = 0
for _ in range(N):
    A = [int(_) for _ in input().split()]
    if sum([a * b for a, b in zip(A, B)]) + C > 0:
        ans += 1
print(ans)


Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main (String[] args) {
        Scanner scanner = new Scanner(System.in);
        double x = 0;
        double y = 0;
        double step = 0;
        double deg = 0;
        
        
        while (true) {
            String input = scanner.nextLine();
            String[] str = new String[2];
            str = input.split(",");
            
            if (str[0].equals("0") && str[1].equals("0")) {
                break;
            }
            step = Double.valueOf(str[0]);

            x += step * Math.sin(Math.toRadians(deg));
            y += step * Math.cos(Math.toRadians(deg));
            
            deg += Double.valueOf(str[1]);

        }
        System.out.println((int)x);
        System.out.println((int)y);
   }
        
}

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

#define i64 long long int

int n, m;
priority_queue<int> q;

int main() {
	scanf("%d%d", &n, &m);
	while(!q.empty()) q.pop();
	for(int i=0;i<n;i++) {
		int x;
		scanf("%d", &x);
		q.push(x);
	}
	for(int i=0;i<m;i++) {
		int x = q.top(); q.pop();
		q.push(x/2);
	}
	
	i64 ans = 0;
	while(!q.empty()) {
		int x = q.top(); q.pop();
		ans += x;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 892
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3,tune=native")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define all(a) a.begin(),a.end()
#define ull unsigned long long
#define y1 asjdlfaskavslbcjasndscf
#define endl '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define iter vector< int >::iterator
#define iter1 multiset<int>::iterator
#define int long long
using namespace std;
using namespace __gnu_pbds;

template<class T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

template<class T>
using ordered_multiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rnd1(chrono::steady_clock::now().time_since_epoch().count());

//find_by_order
//order_of_key

const int N=3e5+7;
const int inf=1e18+1e9;
const int mod=998244353;
const ld eps=1e-9;

//const int MAX_MEM=1e8;
//int mpos=0;
//char mem[MAX_MEM];
//
//inline void * operator new(size_t n){
//    char *res=mem+mpos;
//    mpos+=n;
//    assert(mpos<=MAX_MEM);
//    return (void*)res;
//}
//
//inline void operator delete(void *) {}

int solve(int n,int a,int b)
{
    if (a>b)swap(a,b);
    int ans=inf;
    if ((b-a)%2==0){
        ans=min(ans,(b-a)/2);
    }
    int a1=a;
    int b1=b;
    int f=a1-1;
    a1-=f;
    b1-=f;
    ans=min(ans,f+(b1-a1+1)/2);
    a1=a;
    b1=b;
    f=n-b;
    a1+=f;
    b1+=f;
    ans=min(ans,f+(b1-a1+1)/2);
    return ans;
}

main ()
{
    ios;
    int n,a,b;
    cin>>n>>a>>b;
    cout<<solve(n,a,b)<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
//#include<Hatsune_Miku>
using namespace std;
long long a,b;
char op;
int main(){
    cin>>a>>op>>b;
    if(op=='+')cout<<a+b<<endl;
    if(op=='-')cout<<a-b<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
 
using namespace std;
 
typedef pair<int,int> ii;
const int IINF = INT_MAX;
 
vector<ii> G[100010];
int mincost[100010];
int V,E,r;
 
struct Data{
  int cur,cost;
  bool operator < (const Data& data) const{ return cost > data.cost; }
};
 
int main(){
  scanf("%d %d %d",&V,&E,&r);
 
  int s,t,d;
  rep(i,E){
    scanf("%d %d %d",&s,&t,&d);
    G[s].push_back(ii(t,d));
  }
 
  // Shortest Path Faster Algorithm 
  // O(kE)
 
  rep(i,V) mincost[i] = IINF;
  mincost[r] = 0;
  deque<int> deq; deq.push_back(r);
  vector<int> in_queue(V,0); in_queue[r] = 1;
  vector<int> time_stamp(V,0); time_stamp[r] = 1;
 
  bool found = false;
  while(!deq.empty()){
    int u = deq.front(); deq.pop_front(); in_queue[u] = 0;
    rep(i,(int)G[u].size()){
      int v = G[u][i].first, c = G[u][i].second;
      if( mincost[v] > mincost[u] + c ) {
        mincost[v] = mincost[u] + c;
        if( !in_queue[v] ) {
          deq.push_back(v);
          in_queue[v] = 1;
          time_stamp[v]++;
          if( time_stamp[v] >= V-2 ) {
            found = true;
            goto Skip;
          }
        }
      }
    }
  }
 Skip:;
  if( found ){
    puts("NEGATIVE CYCLE");
    return 0;
  }
  rep(i,V) {
    if( mincost[i] == IINF ) puts("INF");
    else printf("%d\n",mincost[i]);
  }
 
  return 0;
}

Measured memory_bytes: 5644
from copy import copy
Ss = input() + "T"
X, Y = map(int, input().split())

d = [len(s) for s in Ss.split("T")]
x = d[0]
# x,y方向に分解
d_x = d[2::2]
d_y = d[1::2]

xs = set([x])
ys = set([0])
blx = [X in xs]
for d in d_x:
    # 各移動後に、X座標にいるかcheck
    xs_ = set()
    for x in xs:
        xs_.add(x+d)
        xs_.add(x-d)
    blx.append(X in xs_)
    xs = copy(xs_)

bly = []
for d in d_y:
    ys_ = set()
    for y in ys:
        ys_.add(y+d)
        ys_.add(y-d)
    bly.append(Y in ys_)
    ys = copy(ys_)

if blx[-1] and bly[-1]: print("Yes")
else: print("No")

Measured memory_bytes: 10396
#include <iostream>
#include <cstring>
#include <sstream>
#include <cctype>
using namespace std;

string str[101];
int s = 0;

int main(){
	while (true){
		int m;
		cin >> str[s];
		if (str[s] == "-")break;
		cin >> m;
		for (int i = 0; i < m; i++){
			int h=0;
			cin >> h;
			string strh;
			strh = str[s].substr(0,h);
			str[s].erase(0,h);
			str[s] += strh;
		}
		s++;
	}
	for (int i = 0; i < s; i++){
		cout << str[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3124
#include<iostream>
#include<algorithm>
#include<climits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
const int NMAX=1<<17;
char c[6];
int main(){
  rep(i,6){
    scan(c[i]);
  }
  if(c[0]==c[5]&&c[1]==c[4]&&c[2]==c[3]){
    prin("YES");
  }
  else{
    prin("NO");
  }

  return 0;
}


Measured memory_bytes: 256