akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  string a,b;
  cin >> a >>b;
  bool ans=true;
  for(int i=0;i<a.size();i++){
    for(int j=0;j<a.size();j++){
      swap(a.at(j),a.at(a.size()-1));
    }
    if(a==b){
      cout << "Yes" << endl;
      ans=false;
      break;
    }    
  }
  if(ans==true){
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
//package atcoder.beginner144;

import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
//        try {
//            FastScanner in = new FastScanner(new FileInputStream("src/input.in"));
//            PrintWriter out = new PrintWriter(new FileOutputStream("src/output.out"));
        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int N = in.nextInt();
        long K = in.nextLong();
        long sum = 0;
        Long[] A = new Long[N], F = new Long[N];
        for(int i = 0; i < N; i++) {
            A[i] = in.nextLong();
            sum += A[i];
        }
        for(int i = 0; i < N; i++) {
            F[i] = in.nextLong();
        }

        if(sum <= K) {
            out.println(0);
        }
        else {
            Arrays.sort(A);
            Arrays.sort(F);
            long l = 0, r = 0;
            for(int i = 0; i < N; i++) {
                r = Math.max(r, A[i] * F[N - 1 - i]);
            }
            while(l < r - 1) {
                long mid = l + (r - l) / 2;
                if(check(A, F, K, mid)) {
                    r = mid;
                }
                else {
                    l = mid + 1;
                }
            }
            if(check(A, F, K, l)) {
                out.println(l);
            }
            else {
                out.println(r);
            }
        }

        out.close();

//        }
//        catch (IOException e) {
//            e.printStackTrace();
//        }
    }

    private static boolean check(Long[] A, Long[] F, long K, long target) {
        long sum = 0;
        for(int i = 0; i < A.length; i++) {
            if(A[i] * F[A.length - 1 - i] > target) {
                sum += (A[i] - target / F[A.length - 1 - i]);
            }
        }
        return sum <= K;
    }
    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream stream) {
            try {
                br = new BufferedReader(new InputStreamReader(stream));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}




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

int main(){
  int n,m,p,ans1=0,ans2=0;
  string s;
  cin>> n >> m;
  vector<bool> v1(n,false);
  vector<int> v2(n,0);
  for (int i=0; i<m; i++){
    cin>> p >> s; p--;
    if (v1[p]) continue;
    if(s=="WA") v2[p]++;
    else v1[p]=true;
  }
  for (int i=0; i<n; i++){
    if(v1[i]){
      ans1++;
      ans2+=v2[i];
    }
  }
  cout<< ans1 <<" "<< ans2 <<endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;

int deg[10];

void solve() {
  string s = "YES";
  for(int i = 0; i < 3; i++) {
    int a, b;
    cin >> a >> b;
    if(++deg[a] >= 3) {
      s = "NO";
    }
    if(++deg[b] >= 3) {
      s = "NO";
    }
  }
  cout << s << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
}


Measured memory_bytes: 256
def solve(bit_state, num, mod):
    for div in range(1, num + 1):
        if num % div == mod:
            cand[i].append(bit_state | (1 << div))
        if num % div > mod:
            solve(bit_state | (1 << div), num % div, mod)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

cand = [[] for i in range(n)]
for i in range(n):
    solve(0, a[i], b[i])
    if a[i] == b[i]:
        cand[i].append(0)

ans = 0
while True:
    max_ = 0
    for j in range(n):
        min_ = 10 ** 5
        for num in cand[j]:
            min_ = min(min_, num.bit_length() - 1)
        max_ = max(max_, min_)

    if max_ == 0:
        print(ans)
        break
    if max_ == 10 ** 5:
        print(-1)
        break
    ans += 2 ** max_
    
    tmp = [[] for i in range(n)]
    for j in range(n):
        for num in cand[j]:
            if num & (1 << max_):
                tmp[j].append(num - (1 << max_))
            else:
                tmp[j].append(num)
    cand = tmp[0:]
            

Measured memory_bytes: 44636
class Node:
  def __init__(self, id):
    self.id = id
    self.parent = None
    self.left = None
    self.right = None

  def get_parent(self):
    if self.parent == None:
      return -1
    return self.parent.id

  def get_children(self):
    return list(filter(None, [self.left, self.right]))

  def get_sibling(self):
    parent = self.parent
    if parent == None:
      return -1
    children = parent.get_children()
    if len(children) == 1:
      return -1
    return list(filter(lambda x: x != self, children))[0].id

  def get_depth(self):
    count = 0
    tmp = self
    while tmp.parent:
      count += 1
      tmp = tmp.parent
    return count
    
  def get_height(self):
    l, r = 0, 0
    if self.left != None:
      l = self.left.get_height() + 1
    if self.right != None:
      r = self.right.get_height() + 1
    return max(l, r)
  
  def get_type(self):
    if self.parent == None:
      return "root"
    if len(self.get_children()) == 0:
      return "leaf"
    return "internal node"


num = int(input())
nodes = [None] * num
children = []

for i in range(num):
  id, left, right = map(int, input().split())
  n = nodes[id] if nodes[id] else Node(id)
  nodes[id] = n

  if left != -1:
    if nodes[left] == None:
      l = Node(left)
      l.parent = n
      nodes[left] = l
      n.left = l
    else:
      nodes[left].parent = n
      n.left = nodes[left]

  if right != -1:
    if nodes[right] == None:
      r = Node(right)
      r.parent = n
      nodes[right] = r
      n.right = r
    else:
      nodes[right].parent = n
      n.right = nodes[right]
    

for i in range(num):
  node = nodes[i]
  print("node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}".format(node.id, node.get_parent(), node.get_sibling(), len(node.get_children()), node.get_depth(), node.get_height(), node.get_type()))



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

signed main() {
  int N, M; cin >> N >> M;
  vector<vector<int>> A(N, vector<int>(N)), B(M, vector<int>(M));
  rep(i, N) rep(j, N) {
    char c; cin >> c;
    A[i][j] = (c == '#' ? 1 : 0);
  }
  rep(i, M) rep(j, M) {
    char c; cin >> c;
    B[i][j] = (c == '#' ? 1 : 0);
  }
  
  rep(i, N-M+1) rep(j, N-M+1) {
    bool t = true;
    rep(k, M) {
      rep(l, M) {
        if(A[k+i][l+j] != B[k][l]) t = false;
       if(!t) break;
      }
      if(!t) break;
    }
    if(t) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

}

Measured memory_bytes: 256
n, m = gets.split.map &:to_i
k = Array.new(m)
s = Array.new(m)
m.times{|i|
    arr = gets.split.map &:to_i
    k[i] = arr[0]
    s[i] = arr[1..arr.size]
}
ps = gets.split.map &:to_i

suitti = (1..n).to_a
cnt = 0

def check(ons, m,k, s, ps)
    return (0...m).all?{|i|
        ons.count{|e|s[i].include?(e)}%2 == ps[i]
    }
end
ans = 0
while cnt < (1 << n)
    bit = cnt.to_s(2).rjust(n,'0').split("").map(&:to_i)
    
    sample = []
    suitti.zip(bit).each do |test|
      item,b = test.first,test.last
      # bitが1だったら処理
      if b==1 
        sample << item
      end
    end
  
    #p sample
    #sample にswitchおんのやｔるがはいってるよ

    if check(sample, m,k,s,ps)
        ans = ans + 1
    end
    cnt = cnt + 1
end

p ans

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

int main() {
  char c;
  cin >> c;
  if (c == 'a'
    || c == 'e'
    || c == 'i'
    || c == 'o'
    || c == 'u') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
signed main(){
    int N,M; cin >> N >> M;
    constexpr int INF = 1e18;
    constexpr int mod = 3;
    vector<vector<int>>d (N,vector<int>(4,INF));
    vector<vector<int>>edge(N);
    for(int i = 0;i < M; ++i){
        int u,v; cin >> u >> v;
        edge[--u].push_back(--v);
    }
    int s,t;
    cin >> s >> t; --s;--t;
    using tp = tuple<int,int,int> ;
    priority_queue<tp,vector<tp>,greater<>>que;
    d[s][0] = 0;
    que.emplace(d[s][0],s,0LL);
    while (not que.empty()) {
        auto top = que.top(); que.pop();
        int dis = get<0>(top);
        int nv  = get<1>(top);
        int cnt = get<2>(top);
        if(dis > d[nv][cnt])continue;
        for(auto to : edge[nv]){
            int ncnt = (cnt + 1) % mod;
            if(d[to][ncnt] <= dis + 1) continue;
            d[to][ncnt] = dis + 1;
            que.emplace(d[to][ncnt],to,ncnt);
        }
        
    }
    cout << (d[t][0] == INF ? -1 : d[t][0] / 3) << endl;
}


Measured memory_bytes: 12800
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cmath>

struct Point
{
	double x, y;
};

void koch(int n, Point a, Point b)
{
	if (n == 0)
		return;

	Point s, t, u;
	double th = M_PI * 60.0 / 180.0;

	s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
	s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
	t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
	t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
	u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
	u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

	koch(n - 1, a, s);
	printf("%.8f %.8f\n", s.x, s.y);
	koch(n - 1, s, u);
	printf("%.8f %.8f\n", u.x, u.y);
	koch(n - 1, u, t);
	printf("%.8f %.8f\n", t.x, t.y);
	koch(n - 1, t, b);
}

int main()
{
	Point a, b;
	int n;

	scanf("%d", &n);

	a.x = 0;
	a.y = 0;
	b.x = 100;
	b.y = 0;

	printf("%.8f %.8f\n", a.x, a.y);
	koch(n, a, b);
	printf("%.8f %.8f\n", b.x, b.y);
}

Measured memory_bytes: 2708
#include<map>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int cnt[27];
char s[100010];

int main()
{
	scanf("%s",s+1);
	int len=strlen(s+1);
	if(len==2)
	{
		if(s[1]==s[2])
		{
			puts("1 2");
		}
		else
		{
			puts("-1 -1");
		}
		return 0;
	}
	cnt[s[1]-'a']++;
	cnt[s[2]-'a']++;
	for(int i=1;i<=len-2;i++)
	{
		cnt[s[i+2]-'a']++;
		for(int j=0;j<26;j++)
		{
			if(cnt[j]>=2)
			{
				return printf("%d %d",i,i+2),0;
			}
		}
		cnt[s[i]-'a']--;
	}
	puts("-1 -1");
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;
const int inf = 1e15;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}

const int N =2e5+10;
int dp[N][3];

void solve()
{
   int n;
    cin >> n;
    
    int a[n];
    f(i,n) cin >> a[i];
    
        f(i,n) f(j,3) dp[i][j] = -inf;
        
        dp[0][0] = a[0];
        dp[1][1] = a[1];
        dp[2][2] = a[2];
        dp[2][0] = a[0] + a[2];
    
        for(int i=3;i<n;i++)
        {
           dp[i][0] = a[i] + dp[i-2][0];
           dp[i][1] = a[i] + max(dp[i-2][1],dp[i-3][0]);
           dp[i][2] = a[i] + max(dp[i-2][2],dp[i-3][1]);
            
           if(i>3) dp[i][2] = max(dp[i][2],a[i] + dp[i-4][0]);
        }
        
  if(n%2 == 1)
  {
        int res = dp[n-1][2];
        res = max(res,dp[n-2][1]);
        res = max(res,dp[n-3][0]);
        cout << res;
  }
  else
  {
      int res = dp[n-1][1];
      res = max(res,dp[n-2][0]);
    
      cout << res;
  }
    
    
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<vector<int>> sheet(3,vector<int>(3));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>sheet.at(i).at(j);
    }
  }
  int N;
  cin>>N;
  vector<int> B(N);
  for(int i=0;i<N;i++){
    cin>>B.at(i);
  }
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      for(int l=0;l<N;l++){
        if(B.at(l)==sheet.at(i).at(j)){
          sheet.at(i).at(j)=-1;
        }
      }
    }
  }
  int a=0;
  for(int i=0;i<3;i++){
    if(sheet.at(i).at(0)==-1 &&sheet.at(i).at(1)==-1 && sheet.at(i).at(2)==-1){
      a=1;
    }
  }  
  for(int i=0;i<3;i++){
    if(sheet.at(0).at(i)==-1 &&sheet.at(1).at(i)==-1 && sheet.at(2).at(i)==-1){
      a=1;
    }    
  }
  if(sheet.at(0).at(0)==-1 && sheet.at(1).at(1)==-1 && sheet.at(2).at(2)==-1){
    a=1;
  }  
  if(sheet.at(0).at(2)==-1 && sheet.at(1).at(1)==-1 && sheet.at(2).at(0)==-1){
  a=1;
  }  
  if(a==1){
  cout<<"Yes"<<endl;
  }
  else{
  cout<<"No"<<endl;
  }  
}

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

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

  int N; cin >> N;
  string A; cin >> A;
  string B; cin >> B;
  for (int i = 0; i < 2 * N; i++) {
    if (i % 2 == 0) cout << A[i / 2];
    else cout << B[i / 2];
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while(true) {
			int dataSet = sc.nextInt();

			if(dataSet == 0) {
				break;
			}

			int sum = 0;
			for(int $ = 0; $ < dataSet; $++) {
				int big = 0;
				int weight  = 0;
				for(int i = 0; i < 4; i++) {
					if(i == 3) {
						weight = sc.nextInt();
					} else {
						big += sc.nextInt();
					}
				}

				//??§??????????????????????¨????
				if(big <= 60 && weight <= 2) {
					sum += 600;
				} else if(big <= 80 && weight <= 5) {
					sum += 800;
				} else if(big <= 100 && weight <= 10) {
					sum += 1000;
				} else if(big <= 120 && weight <= 15) {
					sum += 1200;
				} else if(big <= 140 && weight <= 20) {
					sum += 1400;
				} else if(big <= 160 && weight <= 25) {
					sum += 1600;
				}
			}

			System.out.println(sum);
		}
	}

}

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

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int K;
int A[100010];


int main(){

    cin >> K;
    for(int i = 0; i < K; i++) cin >> A[i];
    ll Y1 = 2;
    ll Y2 = 3;
    bool ok = true;
    for(int i = K - 1; i >= 0; i--){
        ll X1 = (Y1 + A[i] - 1) / A[i] * A[i];
        ll X2 = (Y2 + A[i] - 1) / A[i] * A[i];
        if(X2 <= Y1 || Y2 <= X1) {
            ok = false;
            break;
        }
        else{
            Y1 = X1;
            Y2 = X2;
        }
    }

    if(ok) {
        cout << Y1 << " " << Y2 - 1 << endl;
    }
    else {
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 640
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G();
		int N = I[0], A = I[1], B = I[2];
		var c = 0;
		for (var i = 1; i <= N; i++)
		{
			var s = i.ToString().Sum(d => d - '0');
			if (A <= s && s <= B) c += i;
		}
		Console.WriteLine(c);
	}
}


Measured memory_bytes: 13396
<?php

$n = (int)trim(fgets(STDIN));
$input = explode(' ', trim(fgets(STDIN)));

$hs = [];
foreach ($input as $v) {
	$hs[] = (int)$v;
}
$max = 0;
$cnt = 0;
foreach ($hs as $h) {
	$max = max($h, $max);
	if ($h >= $max) {
		++$cnt;
	}
}
echo $cnt .PHP_EOL;

Measured memory_bytes: 4728
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();

            if(H == 0 && W == 0)
                break;

            for(int i = 1;i<=H;i++){
                if(i==1||i==H){
                    for(int j = 1;j <= W;j++){
                        System.out.printf("#");
                    }
                    System.out.printf("\n");
                }else{
                    for(int j = 1;j<=W;j++){
                        if(j==1||j==W){
                            System.out.printf("#");
                        }else{
                            System.out.printf(".");
                        }
                    }
                    System.out.printf("\n");
                }
            }
            System.out.printf("\n");
        }
    }
}


Measured memory_bytes: 58640
#include <iostream>
#include <set>
#include <cassert>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <map>

using namespace std;

int calc(vector<pair<int, int>>& vec, int start, int next) {
	int dx = vec[next].first - vec[start].first;
	int dy = vec[next].second - vec[start].second;
	if (dx == 0 && dy==0) return vec.size();
	if (dx < 0) {
		dx = -dx;
		dy = -dy;
	}
	if (dx == 0 && dy < 0) {
		dy = -dy;
	}

	sort(vec.begin(),vec.end());
	int count = 0;
	vector<int> filled(vec.size(), 0);
	for (int i = 0; i < vec.size(); ++i) {
		if (filled[i] == 0) {
			count++;
			filled[i] = 1;
			int cx = vec[i].first;
			int cy = vec[i].second;
			while (true) {
				bool find = false;
				cx += dx;
				cy += dy;
				for (int j = 0; j < vec.size(); ++j) {
					if (cx == vec[j].first && cy == vec[j].second) {
						find = true;
						filled[j] = 1;
						break;
					}
				}
				if (!find) break;
			}
		}
	}
	return count;
}

int main() {
	int n, k;
	cin >> n;
	vector<pair<int, int>> vec;
	for (int i = 0; i < n; ++i) {
		int xi, yi;
		cin >> xi >> yi;
		vec.push_back(make_pair(xi, yi));
	}
	if (n == 1) {
		cout << 1 << endl;
		return 0;
	}
	int min_cost = 51;
	for (int start = 0; start < n; ++start) {
		for (int next = 0; next < n; ++next) {
			if (start == next) continue;
			int cost = calc(vec, start, next);
			min_cost = min(cost, min_cost);
		}
	}
	cout << min_cost << endl;
	return 0;
}

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

#define mp       make_pair
#define mt	  make_tuple
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF=1<<29;
const double EPS=1e-9;
const ll MOD = 1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
const int MAX_N = 100010;
int N;
vector<int> A;
int likes[MAX_N];
int main(){
  cin >> N;
  A.resize(N);
  for (auto &val : A){
    cin >> val;
    val--;
  }
  int res = 0;
  memset(likes, -1, sizeof(likes));
  for (int i = 0; i < A.size(); i++){
    int x = i;
    int y = A[i];
    if (A[y] == x){
      res++;
    }
  }
  cout << res / 2 << endl;
  return 0;
}


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

int n,d,a;
long long tt;
int main(){
	cin>>d>>n;
	for (int i=0;i<n;i++) {
		cin>>a;
		tt+=a;
	}
	if (d-tt>=0) cout<<d-tt<<"\n";
	else cout<<-1<<"\n";
	return 0 ; 
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    double r;
    cin >> r;
  cout << fixed << setprecision(10);
    cout << 2 * 3.14 * r << endl;
    return 0;
}


Measured memory_bytes: 3776
import java.util.*

fun gcd (a: Int, b: Int) : Int {
    if (b == 0) return a
    else return gcd(b, a % b)
}

fun main(args: Array<String>) {
    val cin = Scanner(System.`in`)
    val N: Int = cin.nextInt()
    val X: Int = cin.nextInt()
    var xs = ArrayList<Int>()
    for (i in 1..N) {
        xs.add(Math.abs(cin.nextInt() - X))
    }
    var ans = xs[0]
    for (i in 1..N-1) {
        ans = gcd(ans, xs[i])
    }
    println(ans)
}

Measured memory_bytes: 59312
#include <bits/stdc++.h>
#include <cstring>
#include <ctype.h>
#include<stdlib.h>

#define flin            freopen("input.txt", "r", stdin); 
#define flout           freopen("output.txt", "w", stdout);
#define ll              long long
#define ull             unsigned long long
#define fastio          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl              '\n'
#define nll             '\0'
#define pb              push_back
#define bdyptb          return 0;
#define sorted(x)       sort(x.begin(), x.end())
#define reversed(x)     reverse(x.begin(), x.end())
#define all(x)          x.begin(), x.end()
#define mset(a, b)      memset(a, b, sizeof(a));
#define testcase        ll t,tt; cin>>tt; for(t=1;t<=tt;t++)

#define pi acos(-1.00)   
#define mx 1000007

using namespace std;
int gcd(int x,int y)
{        
    return x ? gcd(y%x,x) : y;   
}  

int main()
{
    fastio;
    int n;
    cin>>n;
    int p[n+1];
    for(int i=1; i<=n; i++)
    cin>>p[i];
    int x=30000;
    int a[n+1],b[n+1];
    for(int i=1; i<=n; i++)
    {
        a[i]=(i*x);
        b[i]=((n-i)*x);
    }

    for(int i=1; i<=n; i++)
    b[p[i]]+=i;


    for(int i=1; i<=n; i++)
    cout<<a[i]<<' ';
    cout<<nl;
    
    for(int i=1; i<=n; i++)
    cout<<b[i]<<' ';
    cout<<nl;

    bdyptb;
}

Measured memory_bytes: 3872
#include <string>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,h[100005];
ll dp[100005];

int main(){
	int N,M,K;
	//stack<int> s;   
    queue<int> que;
    //std::cin >> N;
    std::cin >> N >> M;
    //std::cin >> N >> M >> K;
    string s;
    cin>>s;
    
    std::vector<long long> v(N);
    std::vector<long long> ans(M);
    // 入力
    long long max,cnt;
    max=0;
    cnt=0;
    //printf("%d",(int)s.size());
    //int cnt;
    cnt=0;
    int flag;
    flag=0;
    long long memo;
  	
  	
  	
    for(long long i=0;i<N;i++){
			if(s[i]=='A'){
				flag=1;
				
			}
			else if(flag==1 && s[i]=='C'){
				cnt++;
				flag=0;
				
			}
			else{
				flag=0;
				if(flag==1){
					flag=0;
				}
			}
			v[i]=cnt;
		
		
	}
    
    for(long long i=0;i<M;i++){
		long long a,b;
		std::cin >> a >> b;
		ans[i]=v[b-1]-v[a-1];
	}
    for(long long i=0;i<M;i++){
    printf("%d\n",ans[i]);
    }
    
	
	return 0;
}

Measured memory_bytes: 2560
#include<cstdio>
#include<map>
using namespace std;
int a[200005],b[200005];
map<int,int> mp;
int main(){
	int n,i;
	long long ans=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		b[i]=a[i]+i;
	}
	for(i=1;i<=n;i++){
		ans+=mp[i-a[i]];
		mp[b[i]]++;
	}
	printf("%lld\n",ans); 
	return 0;
}

Measured memory_bytes: 21912
x, n = gets.split.map(&:to_i)
pi = gets.split.map(&:to_i)
ai = (0..999).to_a
delta_min = 999
ans = 999

pi.each do |p|
  ai[p] = 999
end

ai = ai.reverse

ai.each do |a|
  if delta_min >= (a-x).abs
    delta_min = (a-x).abs
    ans = a
  end
end

#p ai
puts ans


Measured memory_bytes: 14324
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>

#define MOD (1000000007)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> tup;
const int MAX = 510000;

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


ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    int all = (60*H2 + M2) - (60*H1 + M1);

    if(all <= 0) {
        all = (60 * (H2 + 24) + M2) - (60*H1 + M1);
    }

    cout << all - K << endl;


    return 0;
}


// int main() {
//     string T;
//     cin >> T;

//     for(int i = 0; i < T.size(); i++) {
//         if(T[i] == '?') T[i] = 'D';
//     }

//     cout << T << endl;
//     return 0;
// }

Measured memory_bytes: 3636
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	//	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	N, K := getInt(), getInt()
	p := make([]int, N)
	for i := 0; i < N; i++ {
		p[i] = getInt()
	}
	q := p[0:K]

	ans := float64(0.0)
	for i := 0; i < K; i++ {
		ans += (1.0 + float64(p[i])) / 2
		out(ans)
	}
	max := ans
	for i := K; i < N; i++ {
		ans = ans + (1.0+float64(p[i]))/2 - (1.0+float64(p[i-K]))/2
		if ans > max {
			max = ans
		}
	}
	out(N, K, p, q, max)
	fmt.Printf("%f\n", max)
}


Measured memory_bytes: 3072
s = input()
ns = len(s)
x = {}
for i in range(len(s)):
    if s[i] in x:
        x[s[i]] += [i]
    else:
        x[s[i]] = [i]
t = input()
i = len(s)-1
count = 0
import bisect
for j in range(len(t)):
    if t[j] in x:
        ni = bisect.bisect_right(x[t[j]],i)
        if ni == len(x[t[j]]):
            i = x[t[j]][0]
            count += 1
        else:
            i = x[t[j]][ni]
    else:
        print(-1)
        exit()
    
print(len(s)*(count-1)+i+1)


Measured memory_bytes: 7668
s = gets.chomp
t = gets.chomp
min = t.length
0.upto(s.length-t.length) do |i|
  count = 0
  t.length.times do |j|
    count += 1 if s[i+j] != t[j]
  end
  min = count if count < min 
end
puts min

Measured memory_bytes: 14368
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	h, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	w, _ := strconv.Atoi(sc.Text())
	a := make([]string, h+2)
	var bytes bytes.Buffer
	for i := 0; i < w+2; i++ {
		bytes.WriteString("#")
	}
	a[0] = bytes.String()
	a[len(a)-1] = bytes.String()
	for i := 1; i < h+1; i++ {
		bytes.Reset()
		bytes.WriteString("#")
		sc.Scan()
		bytes.WriteString(sc.Text())
		bytes.WriteString("#")
		a[i] = bytes.String()
	}
	for i := 0; i < h+2; i++ {
		fmt.Println(a[i])
	}
}


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

using namespace std;

int n;
long long a[110], ans;

int main()
{
    scanf ("%d",&n);
    for (int i=1;i<=n;i++)
        scanf ("%lld",&a[i]);
    if (n==1) { printf ("%lld",a[1]); return 0; }
    long long g=__gcd(a[1],a[2]);
    ans=g;
    ans*=(a[1]/g);
    ans*=(a[2]/g);

    for (int i=3;i<=n;i++)
    {
        long long m=ans;
        g=__gcd(m,a[i]);
        //printf ("%lld ",g);
        ans*=(a[i]/g);
    }
    printf ("%lld",ans);
}


Measured memory_bytes: 256
n = int(input())
chk = 0
i=0
while(i<26 and chk==0):
    j=0
    while(j<15 and chk==0):
        if(n==4*i+7*j):
            chk=1
        elif(n<4*i+7*j):
            break
        j+=1
    i+=1
if(chk==1):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<stdio.h>

int main(){
	int N,i;
	double a,b,c,d,obliqueline,baseline,height;
	scanf("%d",&N);
	for(i=1;i<=N;i++){
		scanf("%lf %lf %lf",&baseline,&height,&obliqueline);
		a=pow(baseline,2);
		b=pow(height,2);
		d=pow(obliqueline,2);
		c=sqrt(a+b);
		if(c==obliqueline){
			printf("YES\n");
		}
		else if((c=sqrt(a+d))==height){
			printf("YES\n");
		}
		else if((c=sqrt(b+d))==baseline){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 616
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int n, d[300][300], x[300][300], noneed[300][300];

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	cin >> n;
	rep(i, n) rep(j, n){
		cin >> d[i][j];
		x[i][j] = d[i][j];
	}
	rep(k, n) rep(i, n) rep(j, n){
		x[i][j] = min(x[i][j], x[i][k] + x[k][j]);
		if(i != j && j != k && k != i && x[i][j] == x[i][k] + x[k][j]) noneed[i][j] = 1;
	}
	rep(i, n) rep(j, n) if(x[i][j] != d[i][j]){
		cout << -1 << endl;
		return 0;
	}
	long long ans = 0;
	rep(i, n) rep(j, i) if(!noneed[i][j]) ans += d[i][j];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1280
#include <stdio.h>
#include <stdlib.h>

struct ab{
	long a;
	long b;
};
int cmp(const void *a,const void *b){
	long long x = ((struct ab*)a)->a - ((struct ab*)b)->a;
	if( x>0){
		return 1;
	}else if (x == 0 ){
		return 0;
	}else if (x<0){
		return -1;
	}
}
int main(void){
	long long N,M;
	int i,j;
	
	scanf("%lld%lld",&N,&M);
	struct ab ab[N];
	for(i=0;i<N;i++){
		scanf("%lld%lld",&ab[i].a,&ab[i].b);
	}
	qsort(ab,N,sizeof(struct ab),cmp);
	//安いヤツから買っていく
	int count = 0;
	long long ans = 0;
	
		for(i=0;i<N;i++){
			if( (M-count) > ab[i].b){
				count += ab[i].b;
				ans   += ab[i].b * ab[i].a;
			}else{
				ans += (M-count)*ab[i].a;
				break;
			}
		}
	
	printf("%lld",ans);
	return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define int long long
typedef vector<int> vi;
#define all(x) x.begin(),x.end()
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define OO 1e9
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
typedef long long ll;
#define in_range(x, y, r, c) ((x >= 0 && x < r && y >= 0 && y < c))

const double eps=1e-9;
const  int MOD=1e10;
const int N=1e5+9;
const int inf = 1<<30;


template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template <typename T> T exp(T b, T p){T x = 1;while(p){if(p&1)x=(x*b);b=(b*b);p=p>>1;}return x;}
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }


int32_t main() {
    IOS;
int n;
cin>>n;
int ans=1,mx;
cin>>mx;
    for (int i = 1; i <n     ; ++i) {
        int a;
        cin>>a;
        if(a>=mx)mx=max(a,mx),ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
	int n;
	scanf("%d", &n);

	if (n < 1000) {
		printf("ABC\n");
	}
	else {
		printf("ABD\n");
	}
}

Measured memory_bytes: 256
<?php
while (true) {
    $rep_words = [];
    $string = [];
    $rep_count = trim(fgets(STDIN));
    if (0 == $rep_count) break;
    for ($i = 0; $i < $rep_count; $i++) {
        list($before, $after) = explode(' ', trim(fgets(STDIN)));
        $rep_words[] = array('before' => $before, 'after' => $after);
    }

    $string_count = trim(fgets(STDIN));
    for ($i = 0; $i < $string_count; $i++) {
        $string[] = trim(fgets(STDIN));
    }

    $done = array_fill(0, count($string), false);
    foreach ($rep_words as $rep) {
        for ($i = 0; $i < count($done); $i++) {
            if ($done[$i] == true) continue;
            if ($string[$i] == $rep['before']) {
                $string[$i] = $rep['after'];
                $done[$i] = true;
            }
        }
    }

    echo implode($string) . PHP_EOL;
}


Measured memory_bytes: 46312
#include<iostream>
#include<vector>
#define _USE_MATH_DEFINES
#include<math.h>
#include<algorithm>
#include<memory>
#include<string>
typedef long long ll;
#define Rep(i,n) for(int i = 0;i < (n);i++)	

int gcd(int a, int b) { if (b == 0)  return a;  else  return gcd(b, a % b);  }
int lcm(int a, int b) { return a * b / gcd(a, b); }
void swap(int& a, int& b) { int temp = a; a = b; b = temp; return; }
int ncr(int n, int r) { int a = 1; Rep(i, r) a = (a * (n - i)) / (i + 1); return a; }
int npr(int n, int r) { int a = 1; Rep(i, r) a *= n - i; return a; }
int mod(int a, int b) { return a % b; }

int main() {
	double a;
	std::cin >> a;
	printf("%10.10f", 2 * a * M_PI);
	return 0;
}

Measured memory_bytes: 3776
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll n;
    cin >> n;
    ll a[n];
    for (ll i=0;i<n;i++){
        cin >> a[i];
    }
    ll ans=a[0];
    for (ll i=1;i<n;i++){
        ans=gcd(ans,a[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
  long long n;
  cin >> n;

  //  / if (n < 6) {
  //   cout << "1" << endl;
  //   return 0;
  // }

  long long  m;
  int r;
  m = n / 11;
  r = n % 11;
  if (r == 0) {
    cout << 2 * m;
  } else if (r <= 6) {
    cout << 2*m + 1;
  } else {
    cout << 2*m + 2;
  }
  return 0;
  
}
  


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

const int DIM = 1e5 + 5;

int arr[DIM];

int main(void)
{
    int n, l, t;
    cin >> n >> l >> t;
    
    long long pos = 0;
    for (int i = 0; i < n; ++i) {
        int p, d;
        cin >> p >> d;
        
        if (d == 1) p += t;
        else        p -= t;
        
        pos += p / l; p %= l;
        if (p < 0) pos--, p += l;
        
        arr[i] = p;
    }
    
    sort(arr, arr + n);
    for (int i = 0; i < n; ++i)
        cout << arr[(pos % n + n + i) % n] << "\n";
    
    return 0;
}



Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;



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

	string s;
	cin >> s;

    int len = s.size();
	rep(i,len/2){
        if(s[i] != s[len-i-1]){
            cout << "No" << endl;
            return 0;
        }
    }
    rep(i,len/4){
        if(((len/2)-i-1))
        if(s[i] != s[(len/2)-i-1]){
            cout << "No" << endl;
            return 0;
        }
    }
    repk(i,len/2+1,len){
        if(s[i] != s[len - (i-(len/2))] ){
            cout << "No" << endl;
            return 0;
        }
    }
     


    cout << "Yes" << endl;


	return 0;
}


Measured memory_bytes: 256
require 'pp'

# 入力値を文字の配列で返却する
def gets_nsp_list()
  gets.chomp.split("")
end

# 入力値を数値で返却する
def gets_i()
  gets.chomp.to_i
end

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end
# N, M = gets_i_list
# list = gets_i_list

# 空白区切の入力を文字列の配列で返す
def get_s_list()
  gets.chomp.split(" ")
end

s_list = gets_nsp_list
Q = gets_i

i = s_list.size - 1
is_reversed = false

Q.times do
  i += 1
  t, f, c = get_s_list
  if t == "1"
    is_reversed = !is_reversed
  elsif f == "1"
    if is_reversed
      s_list.push(c)
    else
      s_list.unshift(c)
    end
  elsif f == "2"
    if is_reversed
      s_list.unshift(c)
    else
      s_list.push(c)
    end
  end
end
s_list.reverse! if is_reversed
puts s_list.join

Measured memory_bytes: 29308
n, k = map(int, input().split())
d = list(map(int, input().split()))

def isAvailable(x):
    for c in str(x):
        if int(c) in d:
            return False
    return True

while True:
    if isAvailable(n):
        print(n)
        break
    else:
        n += 1





Measured memory_bytes: 41308
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define MOD 1000000007
typedef long long ll;

ll min(ll n, ll vec[n]){
	ll t = vec[0];
	if(n == 0) return vec[0];
	for(int i = 1; i < n; i++){
		if(t > vec[i]) t = vec[i];
	}
	return t;
}

int main(){
	ll A, B, M;
	scanf("%lld%lld%lld", &A, &B, &M);
	ll a[A], b[B], x, y, c, d[M];
	rep(i, A) scanf("%lld", &a[i]);
	rep(i, B) scanf("%lld", &b[i]);
	rep(i, M){
		scanf("%lld%lld%lld", &x, &y, &c);
		d[i] = a[x-1] + b[y-1] - c;
	}	
	ll min_d, min_nd;
	min_nd = min(A, a) + min(B, b);
  	min_d = min(M, d);	
	if(min_nd <= min_d) printf("%lld", min_nd);
	else printf("%lld", min_d);	
	return 0;
}



Measured memory_bytes: 2560
def m(L,R):
 global c;c+=len(L)+len(R)
 T=[]
 for l in L[::-1]:
  while R and R[-1]>l:T+=[R.pop()]
  T+=[l]
 return R+T[::-1]
def d(A):s=len(A)//2;return m(d(A[:s]),d(A[s:]))if len(A)>1 else A
c=0
input()
print(*d(list(map(int,input().split()))))
print(c)


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    string s; cin >> s;
    for(int i=0;i<s.size();i+=2)cout << s[i];
    cout << endl;
}


Measured memory_bytes: 592
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int a, b;
  int ans = 0;
  string s;

  cin >> a >> b;

  cout << max(max((a+b), (a-b)), a*b) << endl;

}


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

int main()
{
    string s;
    cin >> s;
    if (s[0] != 'A') {
        cout << "WA" << endl;
        return 0;
    }
    int c = 0;
    for (int i = 1; i < s.size(); ++i) {
        if (s[i] == 'C') {
            if (2 <= i && i < s.size() - 1) {
                ++c;
            }
        } else if (!islower(s[i])) {
            cout << "WA" << endl;
            return 0;
        }
    }
    if (c != 1) {
        cout << "WA" << endl;
        return 0;
    }
    cout << "AC" << endl;
    return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Data.IntMap as M
import Data.List as L

primes :: [Int]
primes = takeWhile (<31623) $ 2:3:p
    where 
        p = 5:q 1 7 p
        q m s (p:ps) = [n|n<-[x+y|x<-[s,s+6..p*p-2],y<-[0,4]],gcd m (toInteger n)<2]++q (m*toInteger p) (p*p) ps

fac :: [Int]->M.IntMap Int->Int->M.IntMap Int
fac _ m 1 = m
fac [] m n = M.insert n 1 m
fac pa@(p:pr) m n
    |mod n p==0=fac pa (M.insertWith(+) p 1 m) (div n p)
    |otherwise =fac pr m n

main=do
    k <- readLn::IO Int
    let ps = M.elems $ L.foldl' (\m n -> fac primes m n) M.empty [1..k]
    let us = length $ L.filter (>=74) ps
    let vs = length $ L.filter (>=24) ps
    let ws = length $ L.filter (>=14) ps
    let fs = length $ L.filter (>=4) ps
    let ss = length $ L.filter (>=2) ps
    print $ us + (vs*(ss-1)) + (ws*(fs-1)) + (fs*(fs-1)*(ss-2)`div`2)


Measured memory_bytes: 508
main :: IO ()
main = do
  n <- readLn
  if n == 0
    then return ()
    else do
      putStrLn $ solve n
      main

solve :: Int -> String
solve n = format (findTwin n (reverse primeT))
  where
    format :: (Int,Int) -> String
    format (a,b) = (show a) ++ " " ++ (show b)

    findTwin :: Int -> [(Int,Int)] -> (Int,Int)
    findTwin n ((a,b):rt)
      | b <= n = (a,b)
      |otherwise = findTwin n rt
prime :: Int -> [Int]
prime n = loop [2..n]
  where
    loop :: [Int] -> [Int]
    loop [] = []
    loop (x:xs) = x:(loop (filter (\y -> y `mod` x /= 0) xs))
primeL = prime 10000
primeT = makeT primeL
  where
    makeT :: [Int] -> [(Int,Int)]
    makeT [x] = []
    makeT (x:y:r)
      | y - x == 2 = (x,y):(makeT (y:r))
      | otherwise = makeT (y:r)

Measured memory_bytes: 4308
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<map>
using namespace std;

int main(void)
{
	int N;
	cin >> N;

	map<int, int> table;
	for(int i=0; i<N; i++)
	{
		int A;
		cin >> A;

		table[A]++;
	}

	int ret = 0;
	for(auto it=table.begin(); it!=table.end(); it++)
	{
		if(it->second%2 == 1)
			ret++;
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 4864