akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll h, w;
    cin >> h >> w;
    int n;
    cin >> n;
    V<P> a(n);
    rep(i, n) cin >> a[i].first >> a[i].second, a[i].first--, a[i].second--;
    map<P, int> mp;
    rep(i, n) {
        srepn(j, -1, 1) srepn(k, -1, 1) {
            int nx = a[i].first + j;
            int ny = a[i].second + k;
            if(nx >= 0 && nx < h && ny >= 0 && ny < w) mp[P(nx, ny)]++;
        }
    }

    vector<ll> ans(10);
    for(auto &p : mp) {
        if(p.first.first >= 1 && p.first.first < h-1 && p.first.second >= 1 && p.first.second < w-1) ans[p.second]++;
    }

    ll sum = accumulate(all(ans), 0);
    ans[0] = (ll)(h-2)*(w-2) - sum;
    for(auto p : ans) cout << p << endl;
}

Measured memory_bytes: 60164
#include<bits/stdc++.h>
using namespace std;
int dp[3005][3005];
string s,t;
int ret[3005][3005];
int main()
{

    string s1,t1;
    cin>>s1>>t1;
    string s="0",t="1";
    s+=s1;t+=t1;
    //cout<<s[4]<<' '<<t[5]<<'\n';
    int n=s.size()-1,m=t.size()-1;
    //cout<<n<<' '<<m<<'\n';
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            if(i==0||j==0)
                dp[i][j]=0;
            else
            {
                if(s[i]==t[j])
                {
                    ret[i][j]=0;
                    dp[i][j]=dp[i-1][j-1]+1;
                }
                else
                {
                    if(dp[i-1][j]>dp[i][j-1])
                        ret[i][j]=-1;
                    else ret[i][j]=1;
                    dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
                }
            }
        }
    }
    //cout<<dp[n][m]<<'\n';
    int nows=n,nowt=m;
    string ans;
    while(nows>0&&nowt>0)
    {
        if(ret[nows][nowt]==0)
        {
            ans.push_back(s[nows]);
            //cout<<nows<<' '<<nowt<<'\n';
            nows--;
            nowt--;
        }
        if(ret[nows][nowt]==-1)
            nows--;
        if(ret[nows][nowt]==1)
            nowt--;
    }
    for(int i=ans.size()-1;i>=0;i--)
        cout<<ans[i];
}


Measured memory_bytes: 70784
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;

signed main() {
	int a, b, c;
	
	cin >> a >> b >> c;
	cout << max({10 * a + b + c, a + 10 * b + c, a + b + 10 * c}) << endl;
	return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <queue>
#include <climits>

struct Node {
	int id;
	std::vector<int> edge_to;
	std::vector<int> edge_cost;
	bool done;
	int cost;
};

bool operator>(const Node& u, const Node& v) { return u.cost > v.cost; }
bool operator<(const Node& u, const Node& v) { return u.cost < v.cost; }
bool operator>=(const Node& u, const Node& v) { return u.cost >= v.cost; }
bool operator<=(const Node& u, const Node& v) { return u.cost <= v.cost; }
bool operator==(const Node& u, const Node& v) { return u.id == v.id; }
bool operator!=(const Node& u, const Node& v) { return u.id != v.id; }

void swap(int& x, int& y)
{
	int tmp = x;
	x = y;
	y = tmp;
}

int min(int x, int y)
{
	return x>y ? y : x;
}

int main()
{
	int n; std::cin >> n;
	
	Node* nodes = new Node[n];
	
	for (int i=0; i<n; i++) {
		nodes[i].done = false;
		nodes[i].cost = INT_MAX;
	}
	
	for (int i=0; i<n; i++) {
		int id, deg;
		std::cin >> id >> deg;
		nodes[i].id = id;
		for (int j=0; j<deg; j++) {
			int t, cost;
			std::cin >> t >> cost;
			nodes[i].edge_to.push_back(t);
			nodes[i].edge_cost.push_back(cost);
		}
	}
	
	std::priority_queue<Node, std::vector<Node>, std::greater<std::vector<Node>::value_type>> que;
	que.push(nodes[0]);
	nodes[0].cost = 0;
	
	while (!que.empty()) {
		Node v = que.top(); que.pop();
		int s = v.id;
		// std::cout << s << " " << nodes[s].cost << std::endl;
		nodes[s].done = true;
		for (int k=0; k<nodes[s].edge_to.size(); k++) {
			int t = nodes[s].edge_to[k];
			int cost = nodes[s].edge_cost[k];
			if (nodes[t].done) continue;
			if ( nodes[t].cost > nodes[s].cost + cost) {
				nodes[t].cost = nodes[s].cost + cost;
				que.push(nodes[t]);
			}
		}
	}
	
	for (int i=0; i<n; i++) {
		std::cout << nodes[i].id << " " << nodes[i].cost << std::endl;
	}
	
	delete[] nodes;
	
	return 0;
}



Measured memory_bytes: 27812
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
struct edge{ll to,cost;};
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,ans=0;
    cin>>n;
    for(ll i=2;i<=sqrt(n);i++){
        ll p=i;
        while(n%p==0){
            n/=p;
            p*=i;
            ans++;
        }
        while(n%i==0) n/=i;
    }
    if(n!=1) ans++;
    cout<<ans<<"\n";
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
 
struct c{
  int a;
  int b;
  bool operator<( const c& right ) const {
        return a == right.a ? b < right.b : a < right.a;
    }
};

int main(){
  int n,m,i,k,l,wa=0,kotae=0;
  cin>>n>>m;
  int a[n];
  vector<c> d(n-1);
  for(i=0;i<n-1;i++){
    cin>>d[i].a>>d[i].b;
    a[i]=0;
  }
  a[n-1]=0;
  sort(d.begin(), d.end());
  for(i=0;i<m;i++){
    cin>>k>>l;
    a[k-1]+=l;
  }
  for(i=0;i<n-1;i++){
    a[d[i].b-1]+=a[d[i].a-1];
  }
  for(i=0;i<n;i++){
    cout<<a[i]<<" ";
  }
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define reoz(i, z, n) for(decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for(decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(all(v)))
#define MIN(v) (*min_element(all(v)))
#define INF 1000000000000 //1E+12
#define MOD 1000000007    //合同式の法

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<

using namespace std;
typedef long long ll;
typedef unsigned long long ul;
// 1s間で可能なループ回数2E+8回
// intの最大値2147483647~2E+9
// long longの最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<> push_back
// 連想配列map<key,value> insert,
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 setprecision()
// to_string<->stoi
// stoll(longlong)
// stod(double)
// 大文字65-90(-32)
// 小文字97-122(+32)
// 1E+9 +7
const ll mod = 1000000000+7;
int main(){
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int k; string s; cin >> k;
  cin >> s;

  if(SIZE(s)<=k){
    cout << s << endl;
  }else{
    rep(i,k){
      cout << s[i];
    }
    cout << "..." << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>

int main(){
	
	int N,ans=300000,i,e=0,w=0;
	char S[300010];
	
	scanf("%d",&N);
	scanf("%s",S);
	
	for(i=0;i<N;i++){
		if(S[i]=='E'){
			e++;
		}
	}
	
	for(i=0;i<N;i++){
		if(S[i]=='E'){
			e--;
		}
		
		if(ans>e+w){
			ans=e+w;
		}
		if(S[i]=='W'){
			w++;
		}
	}
	
	printf("\n%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 512
class Node:
  def __init__(self, id, lis):
    self.id = id + 1
    if id == 0:
      self.parent = None
    else:
      self.parent = lis[self.id // 2 - 1]
    if self.id * 2 + 1 <= len(lis):
      self.left = lis[self.id * 2 - 1]
      self.right = lis[self.id * 2]
    elif self.id * 2 <= len(lis) and self.id * 2 + 1> len(lis):
      self.left = lis[self.id * 2 - 1]
      self.right = None
    else:
      self.left = None
      self.right = None
    self.key = lis[id]
    self.lis = lis


  def print(self):
    if len(self.lis) == 1:
      print("node " + str(self.id) + ": key = " + str(self.key) + ", ")
    else:
      print("node " + str(self.id) + ": key = " + str(self.key) + ", ", end="")
      if self.parent == None and self.right == None:
        print("left key = " + str(self.left) + ", ")
      elif self.parent == None and self.left and self.right:
        print("left key = " + str(self.left) + ", " + "right key = " + str(self.right) + ", ")
      elif self.left and self.right:
        print("parent key = " + str(self.parent) + ", " + "left key = " + str(self.left) + ", " + "right key = " + str(self.right) + ", ")
      elif self.left and not self.right:
        print("parent key = " + str(self.parent) + ", " + "left key = " + str(self.left) + ", ")
      else:
        print("parent key = " + str(self.parent) + ", ")
    
H = int(input())

A = list(map(int, input().split()))

for i in range(H):
  node = Node(i, A)
  node.print()


Measured memory_bytes: 5644
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;while(t--)
#define pb push_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define prsp(v) loop(i,0,v.size())cout<<v[i],sp;nl;
#define prpsp(v) loop(i,0,v.size())cout<<v[i].F<<" "<<v[i].S,sp;nl;
#define prnl(v) loop(i,0,v.size())cout<<v[i],nl;nl;
#define prpnl(v) loop(i,0,v.size())cout<<v[i].F<<" "<<v[i].S,nl;nl;
#define MOD 1000000007
#define mod(n) (((n%MOD)+MOD)%MOD)
#define all(x) x.begin(),x.end()

const int N = 1e5+5;
char good[] = {'A','C','G','T'};

int main() 
{
    fastio();

    string s;
    cin>>s;
    int n = s.size();
    int mx = 0;
    loop(i,0,n)
    {
        int f = 1;
        int cnt = 0;
        while( f )
        {
            f=0;
            loop(j,0,4)
            {
                if( s[i] == good[j] )
                {
                    f=1;
                    break;
                }
            }
            if( f )
            {
                cnt++;
                i++;
            }
        }
        mx = max(mx, cnt);
    }
    cout<<mx,nl;
    

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define mod 998244353
#define SYOU(x) fixed<<setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
using pii=pair<int, int > ;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  lol n,m,k;
  string s,w;
  lol a,b,c,x,y;
  cin >>a>>b>>c;
  cout <<c<<' '<<a<<' '<<b<<'\n';
  return (0);
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
#define LL long long
using namespace std;
int n;
LL a,m,num,maxx,minn;
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
template<typename I>inline I mi(const I&a,const I&b){return a<b ? a : b;}
template<typename I>inline I mx(const I&a,const I&b){return a>b ? a : b;}
int main()
{
	//freopen("An Invisible Hand.in","r",stdin);
	//freopen(".out","w",stdout);
	read(n,m); m/=2; minn=3e18;
	for(RG int i=1;i<=n;i++)
	{
		read(a); minn=mi(minn,a);
		if((a-minn)*m>maxx) maxx=(a-minn)*m, num=1;
		else if((a-minn)*m==maxx) num++;
	}
	printf("%lld\n",num);
	//fclose(stdin); fclose(stdout);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int a,b;
        String op;
        while(true){
            a=sc.nextInt();
            op=sc.next();
            b=sc.nextInt();
            
            if(op.equals("?")){ 
                break;
            }
            else if(op.equals("+")) System.out.println(a+b);
            else if(op.equals("-")) System.out.println(a-b);
            else if(op.equals("*")) System.out.println(a*b);
            else if(op.equals("/")) System.out.println(a/b);
            
        }
    }
}


Measured memory_bytes: 26228
// D - Integer Cards
'use strict'
function main(input) {
  input = input.trim().split('\n')
  const NM = input.shift().split(' ').map(val => Number(val))
  const cards = input.shift().split(' ')
    .map(val => Number(val)).sort((a, b) => a - b)
  input = input.map(val => val.split(' ').map(val => Number(val)))
    .sort((a, b) => b[1] - a[1])
  
  let start = 0;
  for (let i = 0; i < input.length; i++) {
    let count = input[i][0]
    for (let j = start; j < cards.length; j++) {
      if (cards[j] < input[i][1]) {
        cards[j] = input[i][1]
        count--;
        start = j + 1
        if (count === 0) break;
      } else {
        break;
      }
    }
  }
  console.log(cards.reduce((p, c) => p + c))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 58524
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n; cin >> n;
    vector<ll> p(n);
    REP(i, n) cin >> p[i];
    ll ans = 0;
    RANGE(i, 1, n-2) {
        vector<ll> a = {p[i-1], p[i], p[i+1]};
        sort(ALL_OF(a));
        if (a[1] == p[i]) ans++;
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <iomanip>
#include <iostream>

using namespace std;
/** Problem0095 : Surf Fishing Contest **/
int main()
{
	map<int, vector<int> > list;
	int n, a, v, maxV=0;
	
	cin >> n;
	for (int i=0; i<n; i++) {
		cin >> a >> v;
		list[v].push_back(a);
		maxV = max(v, maxV);
	}
	
	vector<int> vec = list[maxV];
	sort(vec.begin(), vec.end());
	cout << vec[0] << " " << maxV << endl;
	return 0;
}

Measured memory_bytes: 1224
import java.util.Scanner

object Main {
  def solve(sc: => Scanner): Unit = {
    println(sc.next.zipWithIndex.filter(a => a._2 % 2 == 0).map(a => a._1).mkString)
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}


Measured memory_bytes: 36252
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;


int main(){
  int N;
  cin >> N;
  vector<int> num(N);
  vector<int> food(N);
  vector<int> more(N);
  int ans = 0;
  for(int i = 0;i<N;i++){
    cin >> num.at(i);
  }
  for(int j = 0;j<N;j++){
    cin >> food.at(j);
    ans = ans + food.at(j);
  }
  for(int k = 0;k<N;k++){
    cin >> more.at(k);
  }

  for(int l = 0;l<N-1;l++){
    if(num.at(l) + 1 == num.at(l+1)){
      ans = ans + more.at(num.at(l)-1);
    }
  }

  cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;
struct ed{int a,b,c;};
using P=pair<int,int>;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;
  cin>>n>>m;
  vector<vector<int>>com(n);
  vector<unordered_map<int, int>>num(n);
  vector<ed>es(m);
  if(m==0){cout<<-1<<endl;return 0;}

  rep(i,m)
  {
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;c--;
    es[i]={a,b,c};
    com[a].push_back(c);
    com[b].push_back(c);
  }
  int cnt=0;
  rep(i,n)
  {
    num[i][-1]=cnt++;
    sort(all(com[i]));
    com[i].erase(unique(all(com[i])),com[i].end());
    rep(j,com[i].size())
    {
      num[i][com[i][j]]=cnt++;
    }
  }
  vector<int>dist(cnt+2,-1);
  vector<vector<P>>edge(cnt+2);
  rep(i,n)rep(j,com[i].size())
  {
    int t=num[i][-1];
    int tn=num[i][com[i][j]];
    edge[t].push_back({1,tn});
    edge[tn].push_back({0,t});
  }
  rep(i,m)
  {
    int to=num[es[i].a][es[i].c],from=num[es[i].b][es[i].c];
    edge[to].push_back({0,from});
    edge[from].push_back({0,to});
  }
  int start=0,end=num[n-1][-1];
  priority_queue<P,vector<P>,greater<P>>q;
  q.push({0,start});
  while(!q.empty())
  {
    P tp=q.top();q.pop();
    if(dist[tp.second]!=-1)continue;
    dist[tp.second]=tp.first;
    for(P nn:edge[tp.second])
    {
      if(dist[nn.second]!=-1)continue;
      q.push({nn.first+tp.first,nn.second});
    }
  }
  cout<<dist[end]<<endl;
  //rep(i,dist.size())cout<<i<<" "<<dist[i]<<endl;
  //cout<<end<<endl;
  /*
  rep(i,edge.size())rep(j,edge[i].size())
  {
    cout<<i<<" "<<edge[i][j].first<<" "<<edge[i][j].second<<endl;
  }
*/


  return 0;

}


Measured memory_bytes: 70540
A, B = map(int, input().split())

def prime_factor(n):
    res = set([1])
    for i in range(2, n + 1):
        if i * i > n:
            break
            
        while n % i == 0:
            res.add(i)
            n //= i
            
    if n != 1:
        res.add(n)
        
    return res

print(len(prime_factor(A) & prime_factor(B)))


Measured memory_bytes: 62848
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  int even=0;
  for(int i=0;i<N;++i){
    cin >> A.at(i);
    if(A.at(i)%2==0) ++even;
  }

  cout << pow(3,N)-pow(2,even) << endl;;
  
  return 0;
}


Measured memory_bytes: 4220
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x, y;
  cin >> x >> y;
  rep(i, x+1) {
    int num = i*2+(x-i)*4;
    if (num == y) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3612
# 3.5.2

import re
from collections import deque
from functools import reduce
from itertools import permutations
from math import pi
from operator import itemgetter
from operator import mul
from operator import xor
from os import linesep
from queue import PriorityQueue
from sys import stdin


def rline() -> str:
    return stdin.readline().strip()


def rlines(hint: int = 1):
    ret = ['' for i in range(hint)]
    for i in range(hint):
        ret[i] = rline()
    return ret


def htokens(hint: int = 1):
    lns = rlines(hint)
    ret = list(map(lambda ln: ln.split(), lns))
    # if return value has one and only one element(list),
    if hint == 1:
        # then add an empty list.
        ret.append([])
    return ret


def vtokens(hint: int = 1):
    m, _ = htokens()
    wint = len(m)
    ret = [[None] * hint for i in range(wint)]
    for y in range(hint):
        if y != 0:
            m, _ = htokens()
        # convert horizontal to vertical
        x = 0
        for v in m:
            ret[x][y] = v
            x += 1
    # if return value has one and only one element(list),
    if wint == 1:
        # then add an empty list.
        ret.append([])
    return ret


def rint(radix: int = 10) -> int:
    return int(rline(), radix)


def hints(hint: int = 1, radix: int = 10):
    ret = htokens(hint)
    for i in range(len(ret)):
        ret[i] = list(map(lambda v: int(v, radix), ret[i]))
    return ret


def vints(hint: int = 1, radix: int = 10):
    ret = vtokens(hint)
    for i in range(len(ret)):
        ret[i] = list(map(lambda v: int(v, radix), ret[i]))
    return ret


def mat(hint: int, wint: int):
    return [[None]*wint for i in range(hint)]


def filllist(lst, value: int) -> None:
    # destructive.
    for i in range(len(lst)):
        lst[i] = value


def isprime(n: int) -> bool:
    if n <= 1:
        return False
    if n in (2, 3, 5):
        return True
    if n % 2 == 0:
        return False
    if n % 3 == 0:
        return False
    lst = int(n**0.5)
    f = 5
    while f <= lst:
        if n % f == 0:
            return False
        if n % (f + 2) == 0:
            return False
        f += 6
    return True


def strmat(matrix, lnsep: str = linesep, fieldsep: str = ' ') -> str:
    return lnsep.join(map(lambda row: fieldsep.join(map(str, row)), matrix))


def strbool(boolval: int) -> str:
    return ['No', 'Yes'][boolval]


def solve() -> None:
    # read here
    (a, b), _ = hints()

    # solve here
    ans = max([a+b, a-b, a*b])

    # print here
    print(ans)


if __name__ == '__main__':
    solve()


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

int main(){
	int n;
	cin>>n;
	vector<int> arr(n,0);
	long long sum=0;
	for(int i=0;i<n;i++){
		cin>>arr[i];
		sum+=arr[i];
	}
	unordered_map<int,int> freq;
	for(int i=0;i<n;i++){
		if(freq.find(arr[i])!=freq.end()){
			freq[arr[i]]++;
		}
		else freq[arr[i]]=1;
	}
	int q;
	cin>>q;
	while(q--){
		int b,c;
		cin>>b>>c;
		if(freq.find(b)!=freq.end()){
			sum+=(freq[b]*(c-b));
			freq[c]+=freq[b];
			freq[b]=0;
		}
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 7160
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

N, K = map(int, input().split())
Hs = []
for n in range(N):
    Hs.append(int(input()))
Hs.sort()

diff_min = 1e10
for i in range(N - (K - 1)):
    j = i + (K - 1)
    x = Hs[i]
    y = Hs[j]
    mn = min(x, y)
    mx = max(x, y)
    diff = mx - mn
    if diff < diff_min:
        diff_min = diff
print(diff_min)

    


Measured memory_bytes: 10032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;

vector<int> min_damage(30000, INF);

int main() {
    int h, n; cin >> h >> n;
    vector<int> a, b;

    for (int i = 0; i < n; i++) {
        int c, d; cin >> c >> d;
        a.push_back(c);
        b.push_back(d);
    }

    min_damage[0] = 0;
    for (int i = 0; i <= h; i++) {
        for (int j = 0; j < n; j++) {
            int pos = i + a[j];
            min_damage[pos] = min(min_damage[pos], min_damage[i] + b[j]);
        }
    }

    int ans = INF;
    for (int i = h; i < 30000; i++) {
        ans = min(ans, min_damage[i]);
    }

    cout << ans << endl;
}


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

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)

using namespace std;

typedef long long LL;

const int N = 2e5 + 10;

struct Segment_Tree{

	int Max[N << 2];

	#define lc (o << 1)
	#define rc (o << 1 | 1)
	#define M ((L + R) >> 1)

	void modify(int o, int L, int R, int l, int r, int v){
		if(l <= L && R <= r) Max[o] = max(Max[o], v);
		else{
			if(l <= M) modify(lc, L, M, l, r, v);
			if(r > M) modify(rc, M + 1, R, l, r, v);
		}
	}

	int query(int o, int L, int R, int x){
		if(L == R) return Max[o];
		else{
			if(x <= M) return max(Max[o], query(lc, L, M, x));
			else return max(Max[o], query(rc, M + 1, R, x));
		}
	}
}T;

int n, m, k, c;
int L[N], R[N], A[N];
LL dpl[N], dpr[N];
int num[N];

inline int find(int x){
	return lower_bound(num + 1, num + c + 1, x) - num;
}

void update(int l, int r, int i){
	if(l < r){
		if(l < r - 1) T.modify(1, 1, c, l + 1, r - 1, i);
	}
	else{
		if(l < c) T.modify(1, 1, c, l + 1, c, i);
		if(r > 1) T.modify(1, 1, c, 1, r - 1, i);
	}
}


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

	LL sum = 0;
	For(i, 1, m){
		int ty;
		scanf("%d%d", &A[i], &ty);
		
		if(ty == 1 && A[i] * 2 > k){
			puts("-1");
			return 0;
		}

		sum += A[i];
		
		(A[i] += A[i - 1]) %= k;
		if(ty == 1){	
			++n;
			R[n] = (2 * k - 2 * A[i - 1]) % k, L[n] = (2 * k - 2 * A[i]) % k;
			num[++c] = L[n], num[++c] = R[n];
		}
	}

	sort(num + 1, num + c + 1);
	c = int(unique(num + 1, num + c + 1) - num) - 1;

	For(i, 1, n){
		int l = find(L[i]), r = find(R[i]), x;
		
		x = T.query(1, 1, c, l);
		dpl[i] = !x ? 0 : min(dpl[x] + (L[i] - L[x] + k) % k, dpr[x] + (L[i] - R[x] + k) % k);

		x = T.query(1, 1, c, r);
		dpr[i] = !x ? 0 : min(dpl[x] + (R[i] - L[x] + k) % k, dpr[x] + (R[i] - R[x] + k) % k);

		update(l, r, i);
	}

	memset(T.Max, 0, sizeof T.Max);
	LL ans = 1e18;
	Forr(i, n, 1){
		int l = find(L[i]), r = find(R[i]);

		if(!T.query(1, 1, c, l)) ans = min(ans, dpl[i]);
		if(!T.query(1, 1, c, r)) ans = min(ans, dpr[i]);

		update(l, r, n + 1 - i);
	}
	printf("%lld\n", ans + sum * 2);

	return 0;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647

int main() {
  string s;
  cin >> s;
  char a,b,c;
  a = s[0];
  b = s[1];
  c = s[2];
  if(a == '7' || b == '7' || c == '7') cout << "Yes";
  else cout << "No";
  hinata;
}

Measured memory_bytes: 3612
#include"stdio.h"
#include"math.h"

int cls(int);

int main()
{
  int n;
  int p;
  int i;
  int num=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&p);
      num+=cls(p);
    }
  printf("%d\n",num);
    return 0;
}

int cls(int n)
{
  int num=(int)sqrt(n);
  int i;
  for(i=2;i<=num;i++)
    {
      if(n%i==0)return 0;
    }
  return 1;
}


Measured memory_bytes: 2056
/// Bismillahir Rahmanir Rahim
/* Mohammad Morsalin
   Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define int long long
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ms2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pi pair<int,int>
#define tc(t) int t;cin>>t;while(t--)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define fi first
#define se second
#define PI acos(-1)
#define sz(a) (int)a.size();
#define IOS ios::sync_with_stdio(false);
using namespace std;
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
double sq(double x) {return x*x;}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
signed main()
{
    IOS
    int n,k;
    cin>>n>>k;
    int cnt=0;
    while(n>0){
        n/=k;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}
///Alhamdulillah


Measured memory_bytes: 3592
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	static long[] s;
	static long[,] dp;
	static bool[,] visited;
	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		var sa = Input();
		var a = new long[n];
		for(int i = 0; i < n; i++)
		{
			a[i] = sa[i].ToLong();
		}
		
		s = new long[n+1];
		
		s[0] = a[0];
		for(int i = 1; i < n; i++)
		{
			s[i] = s[i - 1] + a[i];
		}
		
		dp = new long[n+1,n+1];
		visited = new bool[n+1,n+1];
		Console.WriteLine(Solve(0, n-1));
	}
	
	private static long Solve(int l, int r)
	{
		if(r == l) return 0;
		
		if(visited[l, r]) return dp[l, r];
		
		int mid = (l + r) / 2;
		long min = DpInf;
		for(int c = l; c < r; c++)
			min = Math.Min(min, Solve(l, c) + Solve(c+1, r));
		
		long res = s[r];
		if(l > 0) res -= s[l-1];
		dp[l, r] = min + res;
		visited[l, r] = true;
		return dp[l, r];
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}


Measured memory_bytes: 12628
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> prl;
typedef vector<ll> vcl;
typedef map<ll,ll> mapl;
typedef unordered_map<ll,ll> umap;
#define pb push_back
#define all(v) v.begin(), v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;
vcl g[200005];
ll ans[200005];
bool used[200005];

int main() {
    // your code goes here
    ll n,m,a,b,pr;
    cin >> n >> m;
    rep(i,1,m){
        cin >> a >> b;
        g[a].pb(b); 
        g[b].pb(a);
    }
    queue<ll> que;
    que.push(1);
    pr=0;
    used[1]=true;
    while(!que.empty()){
        ll v = que.front();
        que.pop();
        for(auto to: g[v]){
            if(used[to]) continue;
            ans[to]=v;
            que.push(to);
            used[to]=true;
        }
    }
    cout << "Yes" << endl;
    rep(i,2,n){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 15364
#include<bits/stdc++.h>
#define Fail puts("NO"),exit(0);
#define eps 1e-10
#define maxn 505
#define maxm 4010
#define inf 1000000007
#define mod 998244353
#define pi acos(-1)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int>pii;
typedef bitset<maxn> bit;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n;
int prime[100010],primesize;
bool notprime[100010];
void get_prime()
{
    for(int i=2;i<=100000;i++)
    {
        if(!notprime[i])   prime[++primesize]=i;
        for(int j=1;j<=primesize&&i*prime[j]<=100000;j++)
        {
            notprime[i*prime[j]]=true;
            if(i%prime[j]==0)  break;
        }
    }
}
ll ans[maxn][maxn];
int xx[4]={0,0,1,-1};
int yy[4]={1,-1,0,0};
bool check(int x,int y)
{
    return (x>=1&&x<=n&&y>=1&&y<=n);
}
ll gcd(ll x,ll y)
{
    if(!y)  return x;
    return gcd(y,x%y);
}
ll lcm(ll x,ll y)
{
    return x*(y/gcd(x,y));
}
int main()
{
    get_prime();
    n=read();
    int l=1,r=(n<<1)+(!(n&1));
    for(int i=2;i<=(n<<1);i+=2)
    {
        int val;
        if(i%4==0)  val=prime[l++];
        else        val=prime[r--];
        for(int x=1;x<=n;x++)
        {
            int y=(i-x);
            if(y<=0||y>n)  continue;
            ans[x][y]=val;
        }
    }
    for(int i=-(n-1)/2*2;i<=(n-1)/2*2;i+=2)
    {
        int val;
        if(i%4==0)  val=prime[l++];
        else        val=prime[r--];
        for(int x=1;x<=n;x++)
        {
            int y=(i+x);
            if(y<=0||y>n)  continue;
            ans[x][y]*=val;
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if((i+j)&1)
            {
                for(int k=0;k<4;k++)
                {
                    int tx=i+xx[k],ty=j+yy[k];
                    if(check(tx,ty))
                    {
                        if(!ans[i][j])  ans[i][j]=ans[tx][ty];
                        else          ans[i][j]=lcm(ans[i][j],ans[tx][ty]);
                    }
                }
                ans[i][j]++;
            }
        }
    }
    if(n==2)  ans[1][2]=ans[1][2]*2-1;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)  printf("%lld ",ans[i][j]);
        puts("");
    }
    return 0;
}

Measured memory_bytes: 5248
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

a = [int(item) for item in input().split()]
a.sort()
if a[0] == a[1] and a[1] != a[2]:
    print("Yes")
elif a[1] == a[2] and a[0] != a[1]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,v,z;
    cin>>n;
    bool flag = false;
    for(int i=1;i<=n;i++){
        z = i*1.08;
        if(z == n){
            flag = true;
            v = i;
            break;
        }
    }
    if(flag == true){
        cout<<v<<endl;
    }
    else{
        cout<<":("<<endl;
    }
    //cout<<(round(n/1.08))<<" "<<z<<endl;

    return 0;
}


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

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double[][] xy = new double[n][2];
        for(int i = 0;i<n;i++){
            xy[i][0] = sc.nextDouble();
            xy[i][1] = sc.nextDouble();
        }
        double result = 0;
        for(int i = 0;i<(n-1);i++){
            for(int j = (i+1);j<n;j++){
                result += Math.sqrt( (xy[i][0] - xy[j][0]) * (xy[i][0] - xy[j][0]) +
                (xy[i][1] - xy[j][1]) * (xy[i][1] - xy[j][1]) );
            }
        }
        result = result * 2 / n;
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 23508
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long v = A[0];
		long sig = 1;
		for(int i=1;i<N-1;i++){
			sig *= -1;
			v += A[i] * sig;
		}
		
		v += A[N-1];
//Console.WriteLine(v);
		long[] X2 = new long[N];
		X2[0] = v / 2;
		X2[1] = A[0] - X2[0];

		for(int i=2;i<N-1;i++){
			X2[i] = A[i-1] - X2[i-1];
		}
		X2[N-1] = A[N-1] - X2[0];
		
		for(int i=0;i<N;i++) X2[i] *= 2;
		Console.WriteLine(String.Join(" ",X2));
		
	}
	int N;
	long[] A;
	public Sol(){
		N = ri();
		A = rla();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 31196
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
using namespace std;

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

    int n, k,ans=0;
    cin >> n >> k;
    vector<int> b(10000);
    for(int i = 0; i < k; ++i) {
        int d;
        cin >> d;
        for(int j = 0; j < d; ++j) {
            vector<int> a(1000,0);
            cin >> a.at(j);
            ++b.at(a.at(j)-1);

        }
        

    }
    for(int i = 0; i < n; ++i) {
        if(b.at(i) == 0)
            ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3700
S = input()
T = input()
N = len(S)
K = len(T)

ans = []
flag = False
for i in range(N-K+1):
    for j in range(K):
        if not(S[i+j] == T[j] or S[i+j] == '?'):
            break
    else:
        flag = True
        tmp = list(S)
        for j in range(K):
            tmp[i+j] = T[j]
        for j in range(N):
            if tmp[j] == '?': tmp[j] = 'a'
        tmp = ''.join(tmp)
        ans.append(tmp)
        
if flag:
    ans.sort()
    print(ans[0])
else:
    print('UNRESTORABLE')
    
        
        

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
    int n;

    scanf("%d", &n);

    int H[n];
    int count = 0, max = 0;
    for(int i = 0; i < n; i++){
        scanf("%d", &H[i]);

        if(i != 0 && H[i-1] >= H[i]){
          count++;
        } else {
            if(max < count){
                max = count;
            }
            count = 0;
        }
    }
	if(max < count){
      max = count;
    }
    printf("%d", max);
}


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


void dump(vector<int> vec)
{
  bool flag = true;
  reverse(vec.begin(),vec.end());
  for (auto && a : vec) {
    if (flag && a <= 0)
    {
      continue;
    }
    else 
    {
      cout << char('a' + a - 1);
      flag = false;
    }
  }
  cout << endl;
}

void fix(vector<int> &vec)
{
  for (int i = 0; i < vec.size()-1; i++) {
    if (vec.at(i) <= 0)
    {
      vec.at(i)+=26;
      vec.at(i+1)--;
    }
  }
}


signed main(){
  ll n;cin>>n;
  vector<int> ans;
  do {
    ans.push_back(n%26);
  } while (n /= 26);
  fix(ans);
  dump(ans);

}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;
typedef pair<double,int> P;
double x[1010],y[1010],r[1010];
int n;
bool vis[1010];
double D(int a,int b){
	double cnt=(x[a]-x[b])*(x[a]-x[b]);
	cnt+=(y[a]-y[b])*(y[a]-y[b]);
	cnt=(double)sqrt((double)cnt);
	return max(0.0,cnt-r[a]-r[b]);
}
int main(){
priority_queue<P,vector<P>,greater<P> >Q;
	cin>>x[0]>>y[0]>>x[1]>>y[1]>>n;
	for(int i=2;i<n+2;i++)cin>>x[i]>>y[i]>>r[i];
	for(int i=0;i<=n+1;i++)vis[i]=false;
	Q.push(make_pair(0.0,0));
	while(!Q.empty()){
		double a=Q.top().first;int b=Q.top().second;
		Q.pop();
		if(!vis[b]){
			if(b==1){
				cout<<fixed<<setprecision(10)<<a<<endl;
			}
			vis[b]=true;
			for(int i=0;i<n+2;i++){
				if(vis[i]==false){
					Q.push(make_pair(a+D(i,b),i));
				}
			}
		}
	}
	return 0;
}

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

using namespace std;

int const N = 1e4 + 5;


int n, k;

int main() {
	cin >> n >> k;
	string s;
	cin >> s;
	string rev = s;
	reverse(rev.begin(), rev.end());
	s = s + rev;
	char mins = 'z';
	for (char p : s) {
		mins = min(mins, p);
	}

	int ans = 0;
	for (int i = (int)s.size() - 1; i >= n - 1;) {
		if (s[i] != mins) {
			i--;
			continue;
		}
		int pos = i;
		while (pos >= 0 && s[pos] == mins) {
			pos--;
		}
		ans = max(ans, i - pos);
		i = pos;
	}

	int maxLen = ans;
	for (int i = 1; i <= k - 1; i++) {
		maxLen = maxLen * 2;
		if (maxLen >= n) {
			maxLen = n;
			break;
		}
	}

	if (maxLen == n) {
		for (int i = 1; i <= n; i++) {
			cout << mins;
		}
		cout << endl;
		return 0;
	}

	string suffix = "";
	for (int i = (int)s.size() - 1; i >= n - 1;) {
		if (s[i] != mins) {
			i--;
			continue;
		}
		int pos = i;
		while (pos >= 0 && s[pos] == mins) {
			pos--;
		}

		if (i - pos == ans) {
			string cur = s.substr(pos - (n - maxLen) + 1, n - maxLen);
			//cout << i << " " << pos << " " << cur << endl;
			reverse(cur.begin(), cur.end());
			suffix = suffix == "" ? cur : min(cur, suffix);
		}
		i = pos;
	}

	for (int i = 1; i <= maxLen; i++) {
		cout << mins;
	}
	cout << suffix << endl;


}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cmath>

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

typedef struct PLAN
{
  int t, x, y;
  PLAN(){}
  PLAN(int a, int b, int c):t(a), x(b), y(c){}
}PLAN;
int main()
{
  int n;
  cin >> n;
  PLAN prev(0, 0, 0), now;
  bool ok = true;
  rep(i, n)
  {
    cin >> now.t >> now.x >> now.y;
    int dt = now.t - prev.t;
    int dist = abs(now.x - prev.x) + abs(now.y - prev.y);
    bool c1 = dt >= dist;
    bool odddist = dist & 1;
    bool odddt = dt & 1;
    bool c21 = odddist && odddt;
    bool c22= !odddist && !odddt;
    bool c2 = c21 || c22;
    ok = ok && c1 && c2;
    prev = now;
  }
  if(ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


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

namespace ABC112
{
    class Program
    {
        static void Main(string[] args)
        {
            b();
        }

        public static void b()
        {
            int[] nt = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int n = nt[0], t = nt[1];
            int[] c = new int[n];
            int[] ti = new int[n];
            for(int i = 0; i < n; i++)
            {
                int[] cti = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                c[i] = cti[0];
                ti[i] = cti[1];
            }
            int ans = 10000;
            for(int i = 0; i < n; i++) 
            { 
                if(ti[i] <= t && ans >= c[i])
                {
                    ans = c[i];
                }
            }
            if(ans == 10000)
            { Console.WriteLine("TLE"); }
            else
            { Console.WriteLine(ans); }
        }
    }
}


Measured memory_bytes: 28196
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  srand((unsigned)time(NULL));
  ll N;
  cin >> N;
  map<ll, ll> mp;
  for(int i = 1; i <= 100; i++){
    for(int j = 1; j <= 100; j++){
      for(int k = 1; k <= 100; k++){
        ll num = i*i + j*j + k*k + i*j + j*k + k*i;
        mp[num]++;
      }
    }
  }
  for(int i = 1; i <= N; i++){
    cout << mp[i] << endl;
  }
}

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

using namespace std;

int main(){
  
  int N;
  cin >> N;
  vector<double> v(N);
  for(int i = 0; i < N; i++) cin >> v.at(i);
  
  sort(v.begin(), v.end());
  
  double sum;
  
  if (N > 0) {
    sum = v.at(0);
    for(int i = 1; i < N; i++) sum = (sum + v.at(i)) / 2.0;
  }
  else sum = 0;
    
  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 256