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

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });

            var cin = GetIntArray();
            var ans = Math.Max(cin[0] * cin[1], cin[2] * cin[3]);


            Console.WriteLine(ans);


            Console.Out.Flush();
            Console.ReadKey();
        }


        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public char GetChar() { return Console.ReadLine().Trim()[0]; }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Split(' ').Select(char.Parse).ToArray(); }
        static public Double[] GetDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
        static void Multi<T, U, V,W>(out T a, out U b, out V c, out W d)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);
        }
        static void Multi<T, U, V, W,X>(out T a, out U b, out V c, out W d,out X e)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);e = cv<X>(ar[4]);
        }
    }
}

Measured memory_bytes: 13396
#include <stdio.h>
int main(void){
    int N ,a[100],b,c=0,d=0;
    scanf("%d",&N);
    for(b=0;b<N;b++){
        scanf(" %d",&a[b]);
    };
    for(b=0;b<N;b++){
        if(a[b]==1){c=c+1;}else{
            if(c>d){d=c;c=0;}else{
                c=0;
            };
        };
    };if(c>d){d=c;}
    printf("%d\n",d+1);
}



Measured memory_bytes: 2076
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
const int MaxN = 1e5;
using namespace std;
int a[MaxN + 5];
int n , k;
int main()
{
	while(~scanf("%d%d" , &n , &k)){
		int Min = 1 << 30;
		bool ok = 0 ;
		for(int i = 1;i <= n;i++){
			scanf("%d" , &a[i]);
		}
		sort(a + 1 , a + n + 1);
		for(int i = 2;i <= n;i++){
			if(a[i] - a[i - 1] != 0) Min = min(Min , abs(a[i] - a[i - 1]));
		}
		for(int i = 1;i <= n;i++){
			if(abs(a[i] - k) % Min == 0) ok = 1;
		}
		if(k > a[n]) ok = 0;
		if(ok) printf("POSSIBLE\n");
		else printf("IMPOSSIBLE\n");
	}
}

Measured memory_bytes: 512
#include <iostream>
#include <string>

using namespace std;

constexpr int Q_MAX = 131072;

template<typename T>
class MyQueue {
public:
	MyQueue() : list(new T[Q_MAX]), head(0), tail(1), size(0) {}

	~MyQueue()
	{
		delete[] list;
	}

	void inq(T val)
	{
		if (tail == head) {
			throw runtime_error("queue is full");
		}
		list[tail] = val;
		size++;
		tail = (tail + 1) % Q_MAX;
	}

	T deq()
	{
		if (size == 0) {
			throw runtime_error("queue is empty");
		}
		head = (head + 1) % Q_MAX;
		size--;
		return list[head];
	}

	int get_size()
	{
		return size;
	}
private:
	T* list;
	int head;
	int tail;
	int size;
};

int main()
{
	int n, q;
	cin >> n >> q;

	MyQueue<pair<string, int>> queue;
	for (int i = 0; i < n; i++) {
		pair<string, int> task;
		cin >> task.first >> task.second;
		queue.inq(task);
	}

	int sum_time = 0;
	while (queue.get_size() != 0) {
		pair<string, int> task = queue.deq();
		if (task.second <= q) {
			sum_time += task.second;
			cout << task.first << ' ' << sum_time << '\n';
		}
		else {
			sum_time += q;
			task.second -= q;
			queue.inq(task);
		}
	}

    return 0;
}



Measured memory_bytes: 7432
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>

std::size_t gcd(std::size_t x, std::size_t y)
{
    if (x <= y) {
        if (y % x == 0) {
            return x;
        } else {
            return gcd(x, y % x);
        }
    } else {
        if ( x % y == 0) {
            return y;
        } else {
            return gcd(x % y, y);
        }
    }
}


int main()
{
    std::size_t a, b;
    std::cin >> a >> b;

    std::cout << gcd(a, b) << std::endl;

    return 0;
}


Measured memory_bytes: 3100
//password1488
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
const ll N = 2e5+228;
vector<ll> lr, lg, lb;
ll rr, rg, rb;
signed main(){
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
    ll n;
    string s;
    cin >> n >> s;
    if(n < 3){
        cout << "0\n";
        return 0;
    }
    if(s[0] == 'R') lr.pb(0);
    if(s[0] == 'G') lg.pb(0);
    if(s[0] == 'B') lb.pb(0);
    for(ll i = 2;i<n;i++){
        if(s[i] == 'R') rr++;
        if(s[i] == 'G') rg++;
        if(s[i] == 'B') rb++;
    }
    ll res = 0;
    for(ll i = 1;i<n-1;i++){
        if(s[i] != 'R'){
            for(auto j : lr){
                ll df = i-j;
                if(s[i] == 'G') res += rb-(i+df<n&&s[i+df]=='B'?1:0);
                if(s[i] == 'B') res += rg-(i+df<n&&s[i+df]=='G'?1:0);
            }
        }
        if(s[i] != 'G'){
            for(auto j : lg){
                ll df = i-j;
                if(s[i] == 'R') res += rb-(i+df<n&&s[i+df]=='B'?1:0);
                if(s[i] == 'B') res += rr-(i+df<n&&s[i+df]=='R'?1:0);
            }
        }
        if(s[i] != 'B'){
            for(auto j : lb){
                ll df = i-j;
                if(s[i] == 'R') res += rg-(i+df<n&&s[i+df]=='G'?1:0);
                if(s[i] == 'G') res += rr-(i+df<n&&s[i+df]=='R'?1:0);
            }
        }
        if(s[i] == 'R') lr.pb(i);
        if(s[i] == 'G') lg.pb(i);
        if(s[i] == 'B') lb.pb(i);
        if(s[i+1] == 'R') rr--;
        if(s[i+1] == 'G') rg--;
        if(s[i+1] == 'B') rb--;
    }
    cout << res <<'\n';
}

Measured memory_bytes: 3696
main :: IO ()
main = do
  ls <- getNums <$> getLine
  let a = head ls
  let b = last ls
  let msg =  if (a == 1)
                  then if (b == 1)
                       then "Draw"
                       else "Alice"
                  else if (b == 1)
                       then "Bob"
                       else if (a == b)
                            then "Draw"
                            else if (a < b)
                            then "Bob"
                            else "Alice"
  putStrLn msg
  
getNums :: String -> [Int]
getNums = map read . words


Measured memory_bytes: 508
s = input()
n = len(s)


def dfs(i, f):
    if i == n - 1:
        return sum(list(map(int, f.split("+"))))
      
    return dfs(i + 1, f + s[i + 1]) + dfs(i + 1, f + "+" + s[i + 1])
    
print(dfs(0, s[0]))

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>

#define REP(i,n) for(int i=1;i<=n;i++)
#define MAX 100
#define INT_MAX 100000
using namespace std;

int N;
int M[MAX][MAX];

void shortestPath(int src,int d[],int path[]){
	bool visited[MAX];//Sツづ可堕ョツつキツづゥツノツーツトツづ衡rue
	REP(i,N){
		d[i]=INT_MAX;
		visited[i]=false;
	}
	
	d[src]=0;
	path[src]=-1;

	while(1){
		int u;
		int mincost=INT_MAX;
		REP(i,N){
			if(!visited[i] && d[i]<mincost){
				mincost=d[i];
				u=i;
			}
		}

		if(mincost==INT_MAX)break;

		visited[u]=true;
		REP(v,N){
			if(visited[v]||M[u][v]==INT_MAX)continue;
			if(d[u]+M[u][v] <d[v]){
				d[v]=d[u]+M[u][v];
				path[v]=u;
			}
		//REP(i,N)cout<<d[i]<<endl;
		//cout<<endl;
		}
	}
}

int main(void){
	int m;
	cin>>N>>m;
	int a1,b1,c1,d1;
	REP(i,N)REP(j,N)M[i][j]=INT_MAX;
	REP(i,m){
		scanf("%d,%d,%d,%d",&a1,&b1,&c1,&d1);
		M[a1][b1]=c1;
		M[b1][a1]=d1;
	/*	
	REP(k,N){
		REP(j,N){
			cout<<M[k][j];
		}
		cout<<endl;
	}
		cout<<endl;
	*/
	}
	int start,end,syozi,hashira;
	scanf("%d,%d,%d,%d",&start,&end,&syozi,&hashira);
	int d[21],path[21];
	shortestPath(start,d,path);
	int go,back;
	go=d[end];//ツ行ツつォツつェツつッツづ個コツスツト
	shortestPath(end,d,path);
	back=d[start];//ツ帰ツづィツつェツつッツづ個コツスツト

	cout<<syozi-hashira-go-back<<endl;	
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    long N = scan.nextLong();
    long A = scan.nextLong();
    long B = scan.nextLong();
    long C = scan.nextLong();
    long D = scan.nextLong();
    long E = scan.nextLong();

    long min = A;
    if (min > B) {
      min = B;
    }
    if (min > C) {
      min = C;
    }
    if (min > D) {
      min = D;
    }
    if (min > E) {
      min = E;
    }
    long result = 0;
    if (min == 1) {
      result = N / min + 4;
    } else {
      result = N / min + 5;
    }
    System.out.println(result);
  }
}


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

using namespace std;

int n,m,p[100100],sol,penal,rjesen[100100],pokusaj[100100];

vector <string> v(100100);

int main() {
  
  scanf("%d %d", &n, &m);
  
  for (int i = 0; i < m; i++) {
    cin >> p[i] >> v[i];
    p[i]--;
    if (v[i] == "AC") rjesen[p[i]] = 1;
    if (!rjesen[p[i]] && v[i] == "WA") pokusaj[p[i]]++;
	}
	
	for (int i = 0; i < n; i++) {
		if (rjesen[i]) {
			sol++;
			penal += pokusaj[i];
		}
	}
	
	printf("%d %d\n", sol, penal);
	
	return 0;
}
	

    

Measured memory_bytes: 6784
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define f first
#define s second
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug(...) cout << " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " << endl

using ld = long double;
using ll = long long;
using pii = pair <int,int>;
using pll = pair <ll,ll>;
using vi = vector <int>;
using vll = vector <ll>;
using vpii = vector <pii>;
using vpll = vector<pll>;
using vs = vector <string>;


int main(){
  fastio;
  int x;
  cin >> x;
  cout << 1-x << endl;


  return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
//typedef pair<int, int> P;

/** Problem0260 : Salary for a Plumber **/
int main()
{
	int N;
	while (cin>>N, N) {
		vector<int> P(N), J(N-1);
		rep(i, N) cin>>P[i];
		rep(i, N-1) cin>>J[i];
		
		sort(J.begin(), J.end(), greater<int>());
		
		unsigned length=0, num=N;
		rep(i, N) length+=P[i];
		
		unsigned ans=length*num;
		rep(i, N-1) {
			length += J[i];
			num--;
			
			if (ans < length*num)
				ans = length*num;
			else
				break;
		}
		
		cout << ans << endl;
	}
}

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

int main(){
    int n,m;
    cin >> n >> m;
    
    const int mod = 1e9+7;
    vector<int> broken(n+1);
    
    rep(i,m)
    {
        int a;
        cin >> a;
        broken[a] = 1;
    }
    
    vector<int> dp(n+2);
    dp[n] = 1;
    for(int i = n - 1; i >= 0; i--){
        if(broken[i]){
            dp[i] = 0;
            continue;
        }
        dp[i] = (dp[i+1] + dp[i+2]) % mod;
    }
    cout << dp[0] << endl;
    
    
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}


	int c[][]=new int[10][10];
	int d[][]=new int[10][10];
	int INF=1001001001;
	public void run() {
		Scanner sc = new Scanner(System.in);
		int h=sc.nextInt();
		int w=sc.nextInt();
		for(int i=0; i<10; i++) {
			for(int j=0; j<10; j++) {
				d[i][j]=sc.nextInt();
			}
		}
		calc();
		int sum=0;
		for(int i=0; i<h; i++) {
			for(int j=0; j<w; j++) {
				int k=sc.nextInt();
				if(k<0)continue;
				sum += d[k][1];
			}
		}
		System.out.println(sum);
		sc.close();
	}

	private void calc() {
		for(int k=0; k<10; k++) {
			for(int i=0; i<10; i++) {
				if(d[i][k]==INF) continue;
				for(int j=0; j<10; j++) {
					if(d[k][j]==INF)continue;
					d[i][j] = Math.min(d[i][j], d[i][k]+d[k][j]);
				}
			}
		}
	}
}


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

int main() {
  int n;
  cin >> n;
  vector<string> blue(n);
  rep(i, n)  cin >> blue[i];
  int m;
  cin >> m;
  vector<string> red(m);
  rep(i, m)  cin >> red[i];
  
  map<string, int> map_ans; // 言葉ともらえるお金の対応表
  
  rep(i, n) map_ans[blue[i]]++;
  rep(i, m) map_ans[red[i]]--;
  
  int ans = 0; // 高橋君がもらえるお金
  rep(i, n) {
    if (ans < map_ans[blue[i]]) ans = map_ans[blue[i]];
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Pair<E,F>{
    E first;
    F second;
    public Pair(E first, F second){
        this.first=first;
        this.second=second;
    }
    public E getFirst(){return first;}
    public F getSecond(){return second;}
    public String toString(){
        return "<"+first.toString()+","+second.toString()+">";
    }
    public int hashCode(){
        return first.hashCode()*30011+second.hashCode()+2;
    }
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Pair another = (Pair) obj;
        return this.getFirst().equals(another.getFirst())&&this.getSecond().equals(another.getSecond());
    }
}
class City implements Comparable<City>{
	int year;
	int pref;
	int totalID;
	public City(int year, int pref, int totalID){
		this.year = year;
		this.pref = pref;
		this.totalID = totalID;
	}
	public int getYear(){return year;}
	public int getPref(){return pref;}
	public int getTotalID(){return totalID;}
	public int compareTo(City another){
		if(this.getYear()==another.getYear()) return this.getPref()-another.getPref();
		else return this.getYear() - another.getYear();
	}
	
	public String toString(){
		return "<year:"+year+", pref:"+pref+">";	}
}

public class Main {
    public static String to6digit(String s){
    	while(s.length()<6) s="0"+s;
    	return s;
    }
    public static String to6digit(int n){
    	return to6digit(Integer.toString(n));
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        City[] allCity = new City[M];
        for(int m=0;m<M;m++){
        	int p = sc.nextInt();
        	int y = sc.nextInt();
        	allCity[m] = new City(y, p, m);
        }
        Arrays.sort(allCity);
        
        //System.out.println(Arrays.toString(allCity));
        
        
        int[] oldCityNum = new int[N+1];
        Arrays.fill(oldCityNum,0);
        String[] ans = new String[M];
        for(int m=0;m<M;m++){
        	City c = allCity[m];
        	int pref = c.getPref();
        	
        	ans[c.getTotalID()] = to6digit(pref) + to6digit(1+oldCityNum[pref]);
        	oldCityNum[pref]++;
        }
        for(int m=0;m<M;m++) System.out.println(ans[m]);
    }
}

Measured memory_bytes: 105452
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')

card=[list(map(int, input().split())) for i in range(3)]
N=int(input())
num=[int(input()) for i in range(N)]
for i in range(3):
    for j in range(3):
        if card[i][j] in num:
            card[i][j] = True
        else:
            card[i][j] = False

res = 'No'
for i in range(3):
    if all(card[i]):
        res = 'Yes'
    if card[0][i] == card[1][i] == card[2][i] == True:
        res = 'Yes'

if card[0][0] == card[1][1] == card[2][2] == True:
    res = 'Yes'
elif card[0][2] == card[1][1] == card[2][0] == True:
    res = 'Yes'
print(res)


Measured memory_bytes: 3064
kingaku, n = input().split()
no_num = input().split()
ok_num = []
result = []

for i in range(10):
    if not str(i) in no_num:
        ok_num.append(str(i))

set_flg = False
for i in kingaku:
    set_flg = True
    for j in ok_num:
        if i == j:
            set_flg = False
            result.append(j)
            break
        elif i < j:
            result.append(j)
            print("".join(result).ljust(len(kingaku), ok_num[0]))
            exit()
            break
    
    if set_flg:
        n = 0
        if ok_num[0] == '0':
            n = 1
        print(ok_num[n].ljust(len(kingaku)+1, ok_num[0]))
        exit()

print(''.join(result))

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

using namespace std;

using int64 = long long;
using pi = pair< int, int >;

struct UnionFind {
  vector< int > data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) {
    return (-data[find(k)]);
  }
};


int main() {
  int N, P[200000], V[200000];
  cin >> N;
  for(int i = 1; i < N; i++) {
    cin >> P[i];
    --P[i];
  }
  int64 latte[200000] = {}, malta[200000] = {};
  int64 sum[200000] = {};
  for(int i = 0; i < N; i++) {
    cin >> V[i];
    if(V[i] == 0) latte[i] = 1;
    else malta[i] = 1;
  }
  UnionFind uf(N);
  auto comp = [&](const int &a, const int &b) {
    if(latte[a] * malta[b] == latte[b] * malta[a]) return a > b;
    return latte[a] * malta[b] > latte[b] * malta[a];
  };
  set< int, function< bool(const int &, const int &) > > st(comp);
  for(int i = 1; i < N; i++) st.emplace(i);
  while(st.size()) {
    int p = *st.begin();
    st.erase(p);
    int q = uf.find(P[p]);
    if(q) st.erase(q);
    sum[q] += malta[q] * latte[p];
    sum[q] += sum[p];
    latte[q] += latte[p];
    malta[q] += malta[p];
    uf.unite(q, p);
    if(q) st.emplace(q);
  }
  cout << sum[0] << endl;
}


Measured memory_bytes: 16640
#include <cstdio>
#include <set>
#include <cstdlib>
#include <string>
#include <queue>
#include <algorithm>
#include <vector>

using namespace std;

int n;
set<long long> used;
char buf[22];
vector<long long> c;
const long long MAX = 3234566667;

bool chk(long long x) {
  int l = sprintf(buf, "%lld", x);
  if (x > MAX) return false;
  for (int i = 0; i + 1 < l; i++) {
    if (abs(buf[i] - buf[i + 1]) > 1) return false;
  }
  return true;
}

int main(void) {
  scanf("%d", &n);
  
  queue<long long> q;
  c.push_back(1);
  q.push(1);
  while (!q.empty()) {
    long long p = q.front(); q.pop();
    // printf("%lld\n", p);
    if (chk(p + 1) && used.count(p + 1) == 0) {
      used.insert(p + 1);
      q.push(p + 1);
      c.push_back(p + 1);
    }
    if (p%10 != 0 && p*10+p%10-1<=MAX && used.count(p*10 + p%10-1) == 0) {
      used.insert(p*10 + p%10-1);
      q.push(p*10 + p%10-1);
      c.push_back(p*10 + p%10-1);
    }
    if (p*10+p%10<=MAX && used.count(p*10 + p%10) == 0) {
      used.insert(p*10 + p%10);
      q.push(p*10 + p%10);
      c.push_back(p*10 + p%10);
    }
    if (p%10 != 9 && p*10+p%10+1<=MAX && used.count(p*10 + p%10+1) == 0) {
      used.insert(p*10 + p%10+1);
      q.push(p*10 + p%10+1);
      c.push_back(p*10 + p%10 + 1);
    }
  }
  sort(c.begin(), c.end());
 
  printf("%lld\n", c[n - 1]);
  
  return 0;
}


Measured memory_bytes: 5748
x,y=map(int,input().split())
count=0
l=[1,3,5,7,8,10,12]
r=[4,6,9,11]
result='No'
for i in l:
    if i==x or i==y:
        count+=1
if count==2:
    result='Yes'
count=0
for c in r:
    if c==x or c==y:
        count+=1
if count==2:
    result='Yes'
print(result)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<cassert>
 
struct Meirei{
    std::string mei;
    std::string str;
};

struct Node{
	Node(){
		umu=false;
		a=NULL;
		c=NULL;
		g=NULL;
		t=NULL;
	}
	bool umu;
	Node* a;
	Node* c;
	Node* g;
	Node* t;
};

class Tree
{
public:
	Tree(){
		m_root=new Node();
	}
	void insert(std::string moji);
	bool find(std::string moji);
	
private:
	Node* m_root;
};

void Tree::insert(std::string moji)
{
	Node* node = m_root;
	for(int i =0; i < moji.size(); i++){
		if(moji[i]=='A'){
			if(node->a == NULL){
				node->a = new Node();
			}
			node = node->a;
		}else if(moji[i]=='C'){
			if(node->c == NULL){
				node->c =  new Node();
			}
			node = node->c;
		}else if(moji[i]=='G'){
			if(node->g == NULL){
				node->g = new Node();
			}
			node = node->g;
		}else if(moji[i]=='T'){
			if(node->t == NULL){
				node->t = new Node();
			}
			node = node->t;
		}else {
			assert(true);
		}
	}
	node->umu=true;
}
//---------------------------------
bool Tree::find(std::string moji)
{
	Node* node = m_root;
	for(int i =0; i < moji.size(); i++){
		if(moji[i]=='A'){
			if(node->a == NULL){
				return false;
			}
			node = node->a;
		}else if(moji[i]=='C'){
			if(node->c == NULL){
				return false;
			}
			node = node->c;
		}else if(moji[i]=='G'){
			if(node->g == NULL){
				return false;
			}
			node = node->g;
		}else if(moji[i]=='T'){
			if(node->t == NULL){
				return false;
			}
			node = node->t;
		}else {
			assert(true);
		}
	}
	if(node->umu){
		return true;
	}
	return false;
}



//typedef std::vector<MEIREI> VecMeirei;
//typedef std::vector<std::string> WORDS;
//typedef std::vector<bool> ARINASHI;
//void input();
//bool find(WORDS jisho, std::string str);
void output(bool result);
//-------------------------------------------------------------------
int main()
{
    long n;
    std::cin >> n;
//    Tree* tree = new Tree();
    Tree tree;
	for(int i=0; i<n; i++){
		std::string meirei;
	    std::cin >> meirei;
		std::string moji;
		std::cin >> moji;
		if(meirei=="insert"){
		    tree.insert(moji);
	    }else if(meirei=="find"){
	     	output(tree.find(moji));
	    }
	}
//	delete tree;
    return 0;
}
//-------------------------------------------------------------------
void output(bool result)
{
    if(result){
        std::cout << "yes" << std::endl;
    }else{
        std::cout << "no" << std::endl;
    }
    return;
}
//-------------------------------------------------------------------

Measured memory_bytes: 19292
import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
# do magic here
n = int(input())
heights = [int(x) for x in input().split()]

dp = [0 for x in range(n+1)]

dp[1] = abs(heights[1]-heights[0])

for x in range(2, n):
    a = abs(heights[x]-heights[x-1]) + dp[x-1]
    b = abs(heights[x]-heights[x-2]) + dp[x-2]
    dp[x] = min(a, b)

print(dp[n-1])


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

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

    long long k = (long long)n * m / __gcd(n, m);

    map<long long, char> mp;

    for(long long i = 0; i < n; ++i)
        mp[i * (k / n)] = s[i];

    for(long long i = 0; i < m; ++i)
        if(mp[i * (k / m)] != 0 && mp[i * (k / m)] != t[i]){
            cout << -1 << endl;
            return 0;
        }


    cout << k << endl;
    return 0;
}

Measured memory_bytes: 10880
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s1,s2;
    cin>>s1;
    cin>>s2;
    int l1 = s1.length();
    int l2 = s2.length();
    int T[l1+1][l2+1]={0};
    vector<char> lcs;
    for(int i=0;i<=l1;i++)
    T[i][0]=0;
    for(int i=0;i<=l2;i++)
    T[0][i]=0;

    for(int i = 1;i<=l1;i++){
        for(int j = 1; j<=l2;j++){
            if(s1[i-1]==s2[j-1])
            T[i][j]=T[i-1][j-1] + 1;
            else
            T[i][j] = max(T[i-1][j],T[i][j-1]);
           // cout<<T[i][j]<<" ";
        }
       // cout<<endl;
    }
    
    while(1){
        if(l1==0||l2==0)
        break;
        if(s1[l1-1]==s2[l2-1]){
            lcs.push_back(s1[l1-1]);
            l1=l1-1;l2=l2-1;
        }
        else{
            if(T[l1-1][l2]>T[l1][l2-1])
            l1=l1-1;
            else
            l2=l2-1;
        }

    }
    reverse(lcs.begin(),lcs.end());
    for(int i=0;i<lcs.size();i++)
    cout<<lcs[i];
    

}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mod 1000000007

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<bool> visited(1000001, false);
    vector<int> a(n);
    bool flag = true;
    for(int i=0; i < n; i++){
        cin >> a[i];
        int x = a[i];
        for(int j=2; j*j <= x; j++){
            if(x%j == 0){
                if(visited[j]) flag = false;
                visited[j] = true;
                while(x%j == 0) x /= j;
            }
        }
        if(x != 1) {
            if (visited[x]) flag = false;
            visited[x] = true;
        }
    }
    if(flag){
        cout << "pairwise coprime"; return 0;
    }
    int g = a[0];
    for(int i=1; i<n; i++){
        g = __gcd(a[i], g);
    }
    if(g == 1) cout << "setwise coprime";
    else cout << "not coprime";
}


Measured memory_bytes: 7088
#include<cstdio>
const int MOD=1e9+7;
const int NMAX=2e5+7;
int n=0,t=0,preTot[NMAX]={0},dp[NMAX]={0},pre=0;
int main(){
    scanf("%d",&n);
    dp[0]=1;
    for(int i=1;i<=n;i++){
        scanf("%d",&t);
        if(!preTot[t]){
            dp[i]=dp[i-1];
            preTot[t]=dp[i-1];
            pre=t;
        }else{
            if(t==pre){
                dp[i]=dp[i-1];
                continue;
            }
            dp[i]=(preTot[t]+dp[i-1])%MOD;
            preTot[t]=(preTot[t]+dp[i-1])%MOD;
            pre=t;
        }
    }
    printf("%lld",dp[n]);
    return 0;
}

Measured memory_bytes: 3236
#define _AOJ_
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long long lint;
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,a,b) for(int i=a;i<b;++i)
#define all(c) c.begin(),c.end()

map<lint,lint>zip;
lint unzip[310];
void compress(vector<lint>&v,map<lint,lint>&z,lint u[]){
	sort(all(v));
	v.erase(unique(all(v)),v.end());
	rep(i,v.size()){
		z[v[i]]=i;
		u[i]=v[i];
	}
}

int main(){
	lint n;cin>>n;
	vector<vector<lint>> a(n);//6
	vector<lint>v;
	lint in1,in2;
	rep(i,n){
		a[i].resize(6);
		rep(j,6){
			cin>>in1>>in2;
			lint c=in1*60+in2;
			a[i][j]=c;
			v.push_back(c);
		}
	}
	compress(v,zip,unzip);
	lint ans=0;
	{
		lint i,j,k,tmp;
		rep(ix,300){
			REP(jx,ix+1,300){
				REP(kx,jx+1,300){
					i=unzip[ix],j=unzip[jx],k=unzip[kx],tmp=0;
					rep(l,n){
						if(  a[l][0]<=i&&i<=a[l][1]
						   &&a[l][2]<=j&&j<=a[l][3]
						   &&a[l][4]<=k&&k<=a[l][5])++tmp;
					}
					ans=max(ans,tmp);
				}
			}
		}
	}
	cout<<ans<<endl;
}
//sub-EOF


Measured memory_bytes: 3172
#include<cstdio>
#include<cmath>
using namespace std;
double x1,Y1,x2,y2,x3,y3;
double px, py,r;
int main()
{
    int n;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%lf%lf%lf%lf%lf%lf",&x1,&Y1,&x2,&y2,&x3,&y3);
        double A1 =(x2*x2+y2*y2-x1*x1-Y1*Y1)*(y3-Y1);
        double B1 =(x3*x3+y3*y3-x1*x1-Y1*Y1)*(y2-Y1);
        double A2 =(x3*x3+y3*y3-x1*x1-Y1*Y1)*(x2-x1);
        double B2 =(x2*x2+y2*y2-x1*x1-Y1*Y1)*(x3-x1);
        double D = (x2-x1)*(y3-Y1)-(y2-Y1)*(x3-x1);
         px=(A1-B1)/D/2;
         py=(A2-B2)/D/2;
         r = sqrt((px-x1)*(px-x1)+(py-Y1)*(py-Y1));
        printf("%.3f %.3f %.3f\n",px,py,r);
    }
    return 0;
}

Measured memory_bytes: 1092
h,w=map(int,input().split())

list1=[[0 for i in range(w)] for i in range(h)]
list2=[[0 for i in range(w+2)] for i in range(h+2)]
for i in range(h):
    a=input()
    for j in range(w):
        list1[i][j]=a[j]

for i in range(h+2):
    for j in range(w+2):
        if i == 0 or i == h+1:
            list2[i][j] = '#'
        if j == 0 or j == w+1:
            list2[i][j] = '#'
        
        if list2[i][j] == 0:
            list2[i][j]=list1[i-1][j-1]
    
for i in list2:
    a=''.join(i)
    print(a)

Measured memory_bytes: 3188
n, m = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
b = [int(input()) for i in range(m)]

c = [0] * n
for i in range(n):
    for j in range(m):
        c[i] += a[i][j] * b[j]
    print(c[i])


Measured memory_bytes: 6020
#include<iostream>
using namespace std;
#define mod 1000000007
#define inf 1e9
int n,k;
long long int a[100005];
long long int dp[105][100005];
long long int b[105][100005];
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>a[i];
		dp[0][0]=1;
	b[0][0]=1;
	for(int i=1;i<=a[0];i++){dp[0][i]=1;}
	for(int i=1;i<=k;i++)b[0][i]=dp[0][i]+b[0][i-1];
	for(int i=0;i<=n;i++){dp[i][0]=b[i][0]=1;}
	for(int i=1;i<n;i++){
		for(int j=1;j<=k;j++){
			if(j<=a[i]){
				dp[i][j]=b[i-1][j];
				b[i][j]=(dp[i][j]+b[i][j-1])%mod;
			}
			else{
				dp[i][j]=(b[i-1][j]-b[i-1][j-a[i]-1]+mod)%mod;
				b[i][j]=(dp[i][j]+b[i][j-1])%mod;
			}
		}
	}
	cout<<dp[n-1][k];
}

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

int main() {
	int n,m;cin>>n>>m;
  	vector<long long int> x(m);
  	vector<long long int> s(m-1);
  	for(int i=0;i<m;i++){
    	cin>>x[i];
    }
  	sort(x.begin(),x.end());
  	for(int i=0;i<m-1;i++){
    	s[i]=x[i+1]-x[i];
    }
    sort(s.begin(),s.end());
  	long long int ans=0;
  	for(int i=0;i<m-n;i++){
    	ans+=s[i];
    }
      cout<<ans<<endl;
}


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

int D,G;
vector<int> p; vector<int> c; vector<int> num;

int ans = 1e9;

int main(){
 cin >> D >> G;
  p.resize(D); c.resize(D); num.resize(D);
  
  for(int i = 0; i < D; i++){ num[i] = i;}

   for(int i = 0; i < D; i++){ cin >> p[i] >> c[i];}
  
  do{
 //num[0]→num[1]→num[2]→...num[D-1]のパッケージ順に解いた時に必要な問題数の最小値を求める
    int sum = 0; // sum >= Gになるまで
    int cnt = 0; //何問とく必要があるか
    int itr = 0; //今どのパッケージに注目しているのか
    while(sum < G){
      if(sum + 100*(num[itr]+1)*p[num[itr]] >= G){ //このパッケージで終わり
        while( sum < G){ sum += 100*(num[itr]+1); cnt++;}
        ans = min(ans, cnt); break;} //次のpermutationへ
      
      else{ //このパッケージだけで終わらない
        sum += 100*(num[itr]+1)*p[num[itr]]; cnt += p[num[itr]];
        if( sum + c[num[itr]] >= G){ ans = min(ans, cnt); break;}
        else{ sum += c[num[itr]]; itr++;}}
    }
    
    
  }while(next_permutation(num.begin(),num.end()));
         
         cout << ans << endl; return 0;}
  

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>

using namespace std;



int main() {

	int n;
	int ans = 0;
	cin >> n;
	set<int>p;
	for (int i = 0; i < n; i++) {
		int r;
		cin >> r;
		if (p.erase(r) ){
			ans--;
		}
		else {
			p.insert(r);
			ans++;
		}
	}
	cout << p.size() << endl;

	return 0;
	
}


Measured memory_bytes: 4864
import java.io.PrintWriter
import kotlin.math.abs

fun main() {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val (x, n) = readIntegerList()
    if (n == 0) {
        println(x)
        return
    }

    val pSet = readIntegerList()
    var abs = abs(x - 0)
    var ans = 0
    for (i in 1..101) {
        if (pSet.contains(i)) {
            continue
        }

        val tmp = abs(x - i)
        if (tmp < abs) {
            ans = i
            abs = tmp
        }
    }
    println(ans)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 36624
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
 

int main(){

  int n,sum;
  int val[1000];
  double a;
  
  while(1){
    cin >> n;
    if(n==0) break;
    
    sum=0; a=0;
    
    for(int i=0; i<n; i++){
      cin >> val[i];
      sum += val[i];
    }
    for(int i=0; i<n; i++){
      a += (val[i]-(double)sum/n)*(val[i]-(double)sum/n);
    }
    
    a /= (double)n;

  
    printf("%.8lf\n",sqrt(a));
    
  }
  
  return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#include <stdio.h>
typedef long long int LL;
#define fr(i,p,n) for(LL i=p;i<n;i++)
#define fr1(i,p,n) for(LL i=p;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define precise cout << std::setprecision(10) << std::fixed;
using namespace std;
int main()
{       LL h,w;
        cin>>h>>w;
        char a[h+1][w+1];
        fr(i,0,h){ 
          fr(j,0,w){
            cin>>a[i][j];
          }
      }
      LL dp[h+1][w+1];
      for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    dp[i][j]=0;
                    if(a[i][j]=='#')
                    continue;
                     if (i == 0 && j == 0)
                     dp[i][j] = 1;
                    if(i>0)
                    dp[i][j]+=dp[i-1][j]%MOD;
                    if(j>0)
                    dp[i][j]+=dp[i][j-1]%MOD;
                }
            }
    cout<<dp[h-1][w-1]%MOD<<endl;

    return 0;
}

Measured memory_bytes: 12400
N, M = map(int, input().split())

L = [0 for i in range(M)]
R = [0 for i in range(M)]
for i in range(M):
    L[i], R[i] = map(int, input().split())

if min(R) >= max(L):
    print(min(R) - max(L) + 1)
else:
    print('0')

Measured memory_bytes: 11048
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;

void testcase() {
 	int n; cin >> n;
 	string s; cin >> s;

 	if (n & 1) cout << "No";
 	else {
 		if (s.substr(0, n/2)==s.substr(n/2, n/2))
 			cout << "Yes";
 		else
 			cout << "No";
 	}
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    map<string,ll> m;
    rep(i,N){
        string S;
        cin>>S;
        m[S]++;
    }

    
    cout << "AC x " << m["AC"]<<endl;
    cout << "WA x " << m["WA"]<<endl;
    cout << "TLE x " << m["TLE"]<<endl;
    cout << "RE x " << m["RE"]<<endl;


    return 0;
    

}

Measured memory_bytes: 3612
s = input()

tc = ['dreamer', 'dream', 'eraser', 'erase']
start = 0
out = True

while out:
  if start >= len(s):
    break
  laststart = start
  for i in tc:
    if s[start:start+len(i)] == i:
      if i == 'dreamer' and s[start+7:start+8] == 'a':
        start += 5
      else:
        start += len(i)
      break
  #print('{} {}'.format(laststart, start))
  if start == laststart:
    out = False

if out:
  print('YES')
else:
  print('NO')

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


int main() {
	
	int N, x, d=0;
	cin >> N >> x;
	vector<int>l(N);
	for(auto &i:l) cin >> i;
	for(int i=0; i<N; i++){
		d += l.at(i);
		if(d>x){
			cout << i+1 << endl;
			break;
		}
		if(i==N-1) cout << N+1 << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from operator import itemgetter
# gcd
from fractions import gcd
# 切り上げ，切り捨て
from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
from collections import Counter
import math
from functools import reduce
# input関係の定義
input = sys.stdin.readline


def ii(): return int(input())


def mi(): return map(int, input().rstrip().split())


def lmi(): return list(map(int, input().rstrip().split()))


def li(): return list(input().rstrip())


# template



def solve(s: list):
    print(*s)


def main():

    # def iterate_tokens():
    #     for line in sys.stdin:
    #         for word in line.split(','):
    #             yield word
    # tokens = iterate_tokens()
    # s = next(tokens)  # type: str
    # solve(s)
    word = list(input().rstrip().split(','))
    solve(word)


if __name__ == '__main__':
    main()


Measured memory_bytes: 63852
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 998244353;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
int t[26];
int main() {
	string s;
	cin >> s;
	if (s == "zyxwvutsrqponmlkjihgfedcba") {
		printf("-1");
      return 0;
	}
	bool f = 1;
	rep(i, 0, s.size())t[s[i] - 'a']++;
	rep(i, 0, 26) {
		if (t[i] == 0) {
			f = 0;
			s.push_back(i + 'a');
			printf(s.c_str());
			break;
		}
	}
	if (f) {
		string p = s;
		next_permutation(all(s));
		int i = 0;
		for (; i < s.size();i++) {
			printf("%c", s[i]);
			if (s[i] != p[i])break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
n = int(input())
xyh = [list(map(int, input().split())) for _ in range(n)]

for i in range(101):
    for j in range(101):
        s = -1
        flag = True
        limit = float('inf')
        for x, y, h in xyh:
            if h != 0:
                H = h + abs(x-i) + abs(y-j)
                if s != -1:
                    if s != H:
                        flag = False
                        break
                s = H
            else:
                limit = min(limit, abs(x-i) + abs(y-j))
        if flag:
            if s != -1 and s <= limit:
                print(i, j, s)
                exit()
            elif s <= limit and limit == 1:
                print(i, j, 1)
                exit()

Measured memory_bytes: 9192
#include <stdio.h>
int main(void) {
	int n, i, j, count = 0;
	int a[200000];

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (i = 0; i < n; i++) {
		count++;
		if (a[i] == 1)
			break;
	}

	if (i == n) {
		printf("-1");
		return 0;
	}

	j = i;
	while (j != n) {
		if (a[i] + 1 != a[j + 1]) {
			count++;
			j++;
		}
		else {
			j++;
			i = j;
		}
	}
	printf("%d", count-2);
	return 0;
}

Measured memory_bytes: 896
import numpy as np
A, B, H, M = map(np.float32, input().split())

R = H/12 + M*0.5/360

r = M/60

Rad_c = np.cos((R-r)*2*np.pi)

C = np.sqrt(A*A + B*B -2*A*B*Rad_c)
print(C)

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

class Program
{

    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ');
        var N = int.Parse(inputs[0]);
        var M = int.Parse(inputs[1]);
        var A = new int[M];
        inputs = Console.ReadLine().Split(' ');
        for (int i = 0; i < M; i++)
        {
            A[i] = int.Parse(inputs[i]);
        }

        A = A.OrderByDescending((a) => a).ToArray();

        var countMap = new Dictionary<int, int>();
        int n = 1;
        countMap.Add(n++, 2);
        countMap.Add(n++, 5);
        countMap.Add(n++, 5);
        countMap.Add(n++, 4);
        countMap.Add(n++, 5);
        countMap.Add(n++, 6);
        countMap.Add(n++, 3);
        countMap.Add(n++, 7);
        countMap.Add(n++, 6);

        // dp[i]: i本のマッチを使用して作成できる最大桁数
        var dp = new int[N + 1];
        for (int i = 1; i < dp.Length; i++)
        {
            // 初期値を0にすると桁数0という扱いになり無限ループが発生する
            int max = -1000000000;
            // dp[i] = max_j { dp[i - num(Aj)] + 1 } 
            for (int j = 0; j < M; j++)
            {
                var numj = countMap[A[j]];
                if (i < numj)
                {
                    continue;
                }
                max = Math.Max(dp[i - numj] + 1, max);
            }
            dp[i] = max;
        }

        string ans = string.Empty;
        int match = N;
        int remain = dp[N];
        while (match > 0)
        {
            for (int i = 0; i < M; i++)
            {
                int next = match - countMap[A[i]];
                // 端数処理。next != 0なのでdp[next] = 0となるのは対象が無いのと同じ
                if (next < 0)
                {
                    continue;
                }

                // dp[N - num(Ai)] = dp[N] - 1
                // 最大桁から見るとちょうど一桁ずつ減っていく
                // 尚、使いきる場合、next = 0となる
                if (dp[next] == remain - 1)
                {
                    ans += A[i];
                    match -= countMap[A[i]];
                    remain--;
                    break;
                }
            }
        }

        Console.WriteLine(ans);
    }

}



Measured memory_bytes: 27220
#include <algorithm>
#include <set>
#include <iostream>
using namespace std;
int main() {
    int n, q; cin >> n >> q;
    int a[2*n], b[2*n];
    long long asum = 0;
    for (int i = 0; i < 2*n; i++) cin >> a[i], asum += a[i];
    multiset<int> ds;
    for (int i = 0; i < 2*n; i++) {
        cin >> b[i];
        if (0 < i && i < 2*n-1) ds.insert(b[i] - a[i]);
    }
    long long dsum = 0;
    auto it = ds.lower_bound(1);
    int c = 0;
    for (auto it2 = it; it2 != ds.end(); it2++) {
        c++;
        dsum += *it2;
    }
    while (q--) {
        int i, x, y; cin >> i >> x >> y;
        i--;
        if (0 < i && i < 2*n-1) {
            ds.erase(ds.find(b[i] - a[i]));
            if (b[i] - a[i] > 0) { dsum -= b[i] - a[i]; c--; }
        }
        asum += x - a[i];
        a[i] = x; b[i] = y;
        if (0 < i && i < 2*n-1) {
            ds.insert(b[i] - a[i]);
            if (b[i] - a[i] > 0) { dsum += b[i] - a[i]; c++; }
        }
        long long ans = asum + dsum;
        if (c % 2) {
            it = ds.lower_bound(1);
            if (it != ds.begin() && *it + *prev(it) > 0)
                ans += *prev(it);
            else
                ans -= *it;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 12672
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);


class UnionFind {
private:
    vector<ll> par; // 親
    vector<ll> rank; // 木の深さ

    // 木の根を求める
    ll find(ll x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }

public:
    explicit UnionFind(unsigned int n) {
        par.resize(n);
        rank.resize(n);
        rep(i, n) {
            par[i] = i;
            rank[i] = 0;
        }
    }


    // xとyの属する集合を併合
    void unite(ll x, ll y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (rank[x] < rank[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
        }
    }

    // xとyが同じ集合に属するか否か
    bool is_same(ll x, ll y) {
        return find(x) == find(y);
    }
};


vector<ll> p;
int N, E;

int main() {
    cin >> N >> E;
    p.resize(N);

    UnionFind tree = UnionFind(N);
    rep(i, N) {
        cin >> p[i];
        p[i]--;
    }
    for (int i = 0; i < E; ++i) {
        int s, t;
        cin >> s >> t;
        tree.unite(s - 1, t - 1);
    }

    ll ans = 0;
    rep(i, N) {
        if (tree.is_same(i, p[i])) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
  int L, R, d;
  cin >> L >> R >> d;

  int ans = 0;
  for (int i = d; i <= R; i += d)
  {
    if (L <= i && i <= R) {
      ans++;
    }
  }
  cout << ans;
}

Measured memory_bytes: 3632