akhauriyash/Code-Regression huggingface dataset:
import math
import itertools
import collections
import bisect
import heapq

def IN(): return int(input())
def sIN(): return input()
def MAP(): return map(int,input().split())
def LMAP(): return list(map(int,input().split()))
def TATE(n): return [input() for i in range(n)]
MOD = 10**9 + 7


n = IN()

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

print(str(num2alpha(n)).lower())



Measured memory_bytes: 9476
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;

int INF = 101010;

vector<int>v;
int dp[101010];

int rec(int n) {
	if (dp[n] != -1)return dp[n];
	if (n == 0)return 0;

	int res = INF;
	for (int x : v) {
		if (n - x < 0)continue;
		if (res > rec(n - x))res = rec(n - x)+1;
	}

	return dp[n] = res;
}


int main() {
	int n;
	cin >> n;
	v.push_back(1);

	int temp_6 = 6;
	while (temp_6 <= n) {
		v.push_back(temp_6);
		temp_6 *= 6;
	}
	int temp_9 = 9;
	while (temp_9 <= n) {
		v.push_back(temp_9);
		temp_9 *= 9;
	}

	rep(i, 0, n+1) {
		dp[i] = -1;
	}

	cout << rec(n) << endl;

	return 0;
}

Measured memory_bytes: 5376
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
//~ int N,move;
ll pw[22];
string to(ll x){
	string s;
	while(x>=1){
		s+=(x%10)+'0';
		x/=10;
	}reverse(all(s));
	return s;
}
int ask(ll x){
	//~ assert(1<=x and x<=1e18);
	printf("? %lld\n",x);
	fflush(stdout);
	char c;
	cin>>c;
	return (c=='Y');
	//~ move++;
	//~ return ((x<=N and to(x)<=to(N)) or (x>N and to(x)>to(N)));
}
int main(){
	//~ #ifndef ONLINE_JUDGE
    //~ freopen("file.in", "r", stdin);
	//~ #endif	
	//~ scanf("%d",&N);
	pw[0]=1;
	for(int i=1;i<15;i++)
		pw[i]=pw[i-1]*10LL;
	int len=0;
	for(int i=3;i>=0;i--)
		if(len+(1<<i)<=10 and ask(pw[len+(1<<i)-1]))
			len+=(1<<i);
	ll now=0;
	if(len==10){
		now=1;
		for(int i=9;i>=1;i--)
			if(!ask(pw[i]-1)){
				now=pw[i];
				break;
			}
	}	
	else{
		for(int i=1;i<len;i++){
			int dig=0;
			for(int i=3;i>=0;i--)
				if(dig+(1<<i)<10 and ask(now*10+dig+(1<<i)))
					dig+=(1<<i);
			now=now*10+dig;		
		}
		int last=-1;
		for(int i=3;i>=0;i--)
			if(last+(1<<i)<10 and !ask(now*100+10*(last+(1<<i))))
				last+=(1<<i);
		now=now*10+last+1;	
	}
	//~ printf("%d times asked!\n",move);
	//~ assert(move<=64);
	printf("! %lld\n",now);
	return 0;
}


Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
//#include "toollib.h"
#pragma warning (disable:4018)

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, q;
	cin >> n >> q;
	vector<int> a(n, 0);
	for (int i = 0; i < q; i++) {
		int com, x, y;
		cin >> com >> x >> y;
		if (com == 0) {
			a[x - 1] += y;
		}
		else {
			cout << accumulate(a.begin() + x - 1, a.begin() + y, 0) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3292
def gcd(a, b):
    if a < b:
        a, b = b, a
    while a % b:
        a, b = b, a % b
    return b


def main():
    n, m = map(int, raw_input().split())
    s = raw_input().strip()
    t = raw_input().strip()
    g = gcd(n, m)
    lcm = n * m / g
    a = lcm / m
    b = lcm / n
    if s[::a] == t[::b]:
        print lcm
    else:
        print -1


if __name__ == '__main__':
    main()


Measured memory_bytes: 28652
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>
int main(void) {
   int N,X;
   scanf("%d %d",&N,&X);
   int L[N+1];

   for (int i=1;i<=N;i++)
    scanf("%d",&L[i]);
   int D[N+1];
   D[1]=0;
   for (int i=2;i<=N+1;i++)
   {
       D[i]=D[i-1]+L[i-1];
   }
   int count =0;
   for (int i=1;i<=N+1;i++){
    if (D[i]<=X)count++;
   }
   printf("%d",count);

 return EXIT_SUCCESS;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int ans = 0;
  for (int i = 0; i + 1 < S.length(); i++) ans += S[i] != S[i + 1];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3752
import java.io.*;
import java.util.StringTokenizer;

class Main {
	public static void main (String args[]) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		String buf;
		int count = 1;

		try {
			while (true) {
				buf = br.readLine();
				StringTokenizer st = new StringTokenizer(buf);
				int a = Integer.parseInt(st.nextToken());
				int b = Integer.parseInt(st.nextToken());
				if (a==0 && b==0) break;
				else if (a<b) System.out.println(a+" "+b);
				else System.out.println(b+" "+a);
			}
		} catch (Exception e) {
			//Exception
		}
	}
}

Measured memory_bytes: 22472
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int N=sc.nextInt();
    int A[] = new int[N];
    int B[] = new int[N+1];
    B[0] =0;
    for(int i=0;i<N;i++){
      A[i]=sc.nextInt();
      B[i+1]=B[i]+A[i];}
    int C =10*B[N]/N;
    int D =B[N]/N;
    int x=D;int y=0;int z;
    if(C>D*10+5){z=x+1;}else{z=x;}
    for(int j=0;j<N;j++){
      y=y+(A[j]-z)*(A[j]-z);}
    System.out.println(y);
  }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h> 
    #include<ext/pb_ds/assoc_container.hpp> 
    #include<ext/pb_ds/tree_policy.hpp>
    using namespace __gnu_pbds;
    using namespace std;
    template <typename T>
    using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
    #define int long long  
    typedef long double ld;
    #define pb push_back
    #define f(i,a,b) for(int i=a;i<b;i++)
    #define fd(i,a,b) for(int i=a-1;i>=b;i--)
    #define pf push_front
    #define fi first
    #define se second
    #define INF 1e10
    const double pi=3.14159265358979323;
    const int mod=1e9+7;
    const int MAX=1e7+5;
    int gcd(int a, int b) 
    { 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
    } 
    void swap(int a,int b)
    {
      int temp=a;
      a=b;
      b=temp;
    } 
    int  binpow(int  a,int  b) 
    {
    int res = 1;
    while (b > 0) {
        if (b%2 == 1)
            res = (res * a)%mod;
        a = (a* a)% mod;
        b >>= 1;
    }
    return res;
}
    int modinv(int y)
    {
        return binpow(y,mod-2);
    }

    int fact[500000+5];
    void precal()
    {
    fact[0]=1;
    for(int i=1;i<500000+5;i++)
    {
        fact[i]=(i*fact[i-1])%mod;
    }
}   
    bool isPrime(int n) 
    { 
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
   
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
    } 
    
    signed main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    #ifndef ONLINE_JUDGE
     if(fopen("INPUT.txt","r"))
      {
      freopen ("INPUT.txt" , "r" , stdin);
      freopen ("OUTPUT.txt" , "w" , stdout); 
      }
    #endif  
    // -------------------------------------Code starts here--------------------------------------------------------------------- 
    int t=1; 
    //cin>>t;
    while(t--)
    {   
        int a;
        cin>>a;
        int x=a*a;
        int y=x*a;
        
        cout<<a+x+y<<endl;  
    }
}
  

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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{
		char[] S = nextString().toCharArray();
		char[] T = nextString().toCharArray();

		long ans =0;
		for(int i=0;i<S.length;i++){
			if(S[i]==T[i])
				ans++;

		}
		System.out.println(ans);
	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


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

int main () {
  vector<vector<int>> c(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> c.at(i).at(j);
    }
  }
  int x = c.at(0).at(0)+c.at(1).at(1)+c.at(2).at(2);
  int y = c.at(0).at(1)+c.at(1).at(2)+c.at(2).at(0);
  int z = c.at(0).at(2)+c.at(1).at(0)+c.at(2).at(1);
  if (x == y && y == z) {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

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

int main()
{
    int x, num, total;
    cin >> x;
    num = x/100;
    total = x%100;
    if(total<=(num*5)){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}


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

int main(){
	int a,b,c,k,i=0;
	cin>>a>>b>>c>>k;
	
	
	while(a>=b&&i<=k)
	{
		i++;
		b*=2;
	}
	while(b>=c&&i<=k)
	{
		i++;
		c*=2;
	}
	if(a<b<c&&i<=k)
	{
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
	return 0;
}

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

public class Main {

	public static void main(String[] args) {
        FastScanner in = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt(), m = in.nextInt() , x = in.nextInt();
        int r[] = new int[n+1];
        int c[] = new int[m+1];
        long maxr = 0, maxc = 0;int mr = 0, mc = 0;
        HashMap<Integer,HashSet<Integer>> map = new HashMap<>();
        for(int i=0;i<x;i++) {
        	int a = in.nextInt(), b = in.nextInt();
        	if(map.containsKey(a))
        		map.get(a).add(b);
        	else
        	{
        		HashSet<Integer> set = new HashSet<>();
        		set.add(b);
        		map.put(a, set);
        	}
        	r[a]++;c[b]++;
        	maxr = Math.max(maxr, r[a]);
        	maxc = Math.max(maxc, c[b]);
        }
        long pans = maxr + maxc;
        ArrayList<Integer> rr = new ArrayList<>();
        ArrayList<Integer> cc = new ArrayList<>();
        for(int i=1;i<=n;i++) {
        	if(r[i]==maxr)
        		rr.add(i);
        }
        for(int i=1;i<=m;i++) {
        	if(c[i]==maxc)
        		cc.add(i);
        }
        boolean verdict = Boolean.FALSE;
        for(int i : rr) {
        	for(int j : cc) {
        		if(map.containsKey(i)) {
    	        	if(map.get(i).contains(j)) {
    	        		continue;
    	        	}
    	        	else {
    	        		verdict = Boolean.TRUE;break;
    	        	}
    			}
        	}
        }
        if(!verdict) pans--;
        out.println(pans);
        out.flush();
	}
	
	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		
		String next() {
			while(!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				}catch(IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int[] readArray(int n) {
			int a[] = new int[n];
			for(int i=0;i<n;i++) a[i] = nextInt();
			return a;
		}
		
		long[] readArray(int n,long x) {
			long a[] = new long[n];
			for(int i=0;i<n;i++) a[i] = nextLong();
			return a;
		}
		
	}
}











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

const long long int INF = 100000000000000;

int n, m;
long long int dp[1000], nextdp[1000];

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

struct edge e[2000];

int main(){
  cin >> n >> m;
  for(int i = 0; i < m; i++){
    int s, t, u;
    cin >> s >> t >> u;
    e[i].from = s;
    e[i].to = t;
    e[i].cost = u;
  }
  dp[n] = 0;
  for(int i = 1; i < n; i++){
    dp[i] = -INF;
  }
  int count = 0;
  while(true){
    count++;
    if(count > n){
      break;
    }
    bool flag = true;
    for(int i = 1; i <= n; i++){
      for(int j = 0; j < m; j++){
	if(e[j].from == i && dp[e[j].to] != -INF){
	  if(dp[i] < dp[e[j].to] + e[j].cost){
	    dp[i] = max(dp[i], dp[e[j].to] + e[j].cost);
	    flag = false;
	  }
	  else{
	    flag = flag and true;
	  }
	}
      }
    }
    if(flag){
      break;
    }
  }
  if(count <= n){
    cout << dp[1] << endl;
  }
  else{
    cout << "inf" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
using namespace std;
int main(void)
{
    long int a,b,k;
    cin>>a>>b;
    k=(a+b)/2;

    if(abs(a-k)==abs(b-k))
        cout<<k<<endl;
    else
        cout<<"IMPOSSIBLE"<<endl;
}


Measured memory_bytes: 256
'use strict'
function main(input) {
  const tmp = Array.from(input.split('\n'));
  const N = parseInt(tmp.shift(), 10);

  let a = [];
  let b = [];
  let c = [];
  for (let abc of tmp) {
    abc = abc.split(' ').map((elem) => parseInt(elem, 10));
    a.push(abc[0]);
    b.push(abc[1]);
    c.push(abc[2]);
  }

  let dp = new Array(N + 1);
  for (let i = 0; i <= N; i++) {
    dp[i] = new Array(3).fill(0);
  }
  const happiestValDay1 = [a[0], b[0], c[0]].reduce((max, elem) => Math.max(max, elem));

  dp[1][0] = happiestValDay1;
  dp[1][1] = happiestValDay1;
  dp[1][2] = happiestValDay1;
  for (let day = 2; day <= N; day++) {
    dp[day][0] = Math.max(dp[day][0], dp[day - 1][1] + b[day - 1]);
    dp[day][0] = Math.max(dp[day][0], dp[day - 1][2] + c[day - 1]);

    dp[day][1] = Math.max(dp[day][1], dp[day - 1][0] + a[day - 1]);
    dp[day][1] = Math.max(dp[day][1], dp[day - 1][2] + c[day - 1]);

    dp[day][2] = Math.max(dp[day][2], dp[day - 1][0] + a[day - 1]);
    dp[day][2] = Math.max(dp[day][2], dp[day - 1][1] + b[day - 1]);
  }
  const answer = [dp[N][0], dp[N][1], dp[N][2]].reduce((max, elem) => Math.max(max, elem));
  console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 61388
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int A,B;
    cin>>A>>B;
    int x,y,z;
    cin>>x>>y>>z;
    vector<int >red(x); for(int i=0;i<x;i++)cin>>red[i];
    vector<int >green(y);for(int i=0;i<y;i++)cin>>green[i];
    vector<int >colorless(z);for(int i=0;i<z;i++)cin>>colorless[i];


    sort(red.rbegin(),red.rend());
    sort(green.rbegin(),green.rend());
    sort(colorless.rbegin(),colorless.rend());

    priority_queue<ll> pq;
    for(int i=0;i<A;i++)pq.push(red[i]);
    for(int j=0;j<B;j++)pq.push(green[j]);
    for(int k=0;k<z;k++)pq.push(colorless[k]);

    ll answer=0;
    for(int i=0;i<A+B;i++)
    {
        answer+=pq.top();
        pq.pop();
    }
    cout<<answer<<endl;
    return 0;
}


Measured memory_bytes: 7408
import sys
input = sys.stdin.readline

N = int(input())
A = map(int, input().split())
M = 10**6
smallest_prime = [0] * (M+1)
for i in range(2, M+1):
    if smallest_prime[i] == 0:
        smallest_prime[i] = i
        for j in range(i*i, M+1, i):
            smallest_prime[j] = i

cnt = [0] * (M+1)
for a in A:
    while a > 1:
        p = smallest_prime[a]
        cnt[p] += 1
        while a % p == 0:
            a //= p

if all(c <= 1 for c in cnt):
    print('pairwise coprime')
elif all(c < N for c in cnt):
    print('setwise coprime')
else:
    print('not coprime')

Measured memory_bytes: 150976
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;

int main() {
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>>p(m);
    rep(i,m) cin >> p[i].first >> p[i].second;
    rep(x,1000) {
        vector<int> d(1,x%10);
        int nx = x/10;
        while(nx) {
            d.push_back(nx%10);
            nx /= 10;
        }
        reverse(d.begin(),d.end());
        if(d.size() != n) continue;
        bool can = true;
        rep(i,m) {
            if(d[p[i].first-1] != p[i].second) {
                can = false;
            } 
        }
        if(can) {
            cout << x << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
//Compete against Yourself.
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N], k;
int32_t main(){_

   cin>>n>>k;

   map<int, int> M;
   M[0]++;

   vector<int> pref;
   pref.push_back(0);
   for (int i = 1; i <= n; ++i)
   {
      cin>>a[i];
      pref.push_back(pref.back() + a[i]);
   }

   if (k == 1){
      cout<<0;
      exit(0);
   }

   int sum = 0, ans = 0;
   for (int i = 1; i <= n; ++i)
   {
      sum = pref[i] % k;
      int tt = (sum - i) % k;
      tt += k;
      tt %= k;
      ans += M[tt];
      M[tt]++;
      if(i-k+1 >= 0){
         int yy = pref[i-k+1] - (i-k+1);
         yy %= k;
         yy += k; 
         yy %= k;
         M[yy]--;
      }
   }
   
   cout<<ans;

   return 0;
}


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

int main(){
    int h,w;

    while(1){
        cin>>h>>w;
        if(h==0&&w==0)break;

        for(int i=1;i<=h;i++){
            for(int j=1;j<=w;j++){
                if((i==1||i==h)||(j==1||j==w))cout<<"#";
                else cout<<".";
            }
            cout<<endl;
        }
        cout<<endl;
    }



    return 0;
}


Measured memory_bytes: 3028
/* You are being watched. */


//~ while (clock() <= 69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")

using namespace std;

//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
//~ using namespace __gnu_pbds;
//~ template <typename T>
//~ using ordered_set =
  //~ tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) (x).begin(), (x).end()
#define show(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

void solve() {
  int a, b; cin >> a >> b;
  print(a * b);
}

int main() {
  int t; t = 1;
  while(t--) solve();
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:



int main(void){
	string s;
	cin >> s;
	const int n = s.size();

	vector<int> num(3,0);
	rep(i,n) num[s[i]-'a']++;

	const int tmp = min({num[0],num[1],num[2]});

	bool ok = true;
	rep(i,3) if(num[i]-tmp>1) ok =false;
	puts(ok?"YES":"NO");

	return 0;
}

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

using namespace std;

using ll = long long;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

  vector<ll> va(n);
  for (int i = 0; i < n; ++i) {
    cin >> va[i];
  }

  multiset<ll, greater<ll>> g;
  for (auto &a : va) {
    auto it = g.upper_bound(a);
    if (it != g.end()) {
      g.erase(it);
    }

    g.insert(a);
  }

  cout << g.size() << '\n';

  return 0;
}

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

int gcd(int i, int j, int k);

int main(void)
{
    int num,i;
    long long sum = 0;
    cin>>num;

    for(i = 1; i <= num; i++)
    {
        if(i % 3 != 0 && i % 5 != 0)
            sum = sum + i;
    }

    cout<<sum<<endl;

    return 0;
}


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

using namespace std;

const int maxn = 2e5+10;

typedef long long ll;

int h[maxn], n;

ll dp[maxn], bit[maxn];

void upd(int x, ll v)
{
	for (; x <= n; x += (x&-x))
		bit[x] = max(bit[x], v);
}

ll query(int x)
{
	ll ans = 0LL;
	for (; x > 0; x -= (x&-x))
		ans = max(ans, bit[x]);
	return ans;
}

int main(void)
{
	cin >> n;

	for (int i = 1; i <= n; i++)
		cin >> h[i];

	for (int i = 1; i <= n; i++)
	{
		ll a;
		cin >> a;

		dp[i] = a+query(h[i]-1);
		upd(h[i], dp[i]);
	}

	cout << query(n) << "\n";
}

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

using namespace std;
using ll = long long;

ll chose2(ll n) {
  return n * (n - 1) / 2;
}

int main() {
  int n;
  cin >> n;
  vector<int> as(n);
  rep(i, n) cin >> as[i];
  rep(i, n) as[i]--;
  vector<int> cnt(n);
  rep(i, n) cnt[as[i]]++;
  ll tot = 0;
  rep(i, n) { tot += chose2(cnt[i]); }
  rep(i, n) {
    ll ans = tot;
    ans -= chose2(cnt[as[i]]);
    ans += chose2(cnt[as[i]] - 1);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 4988
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(x) sort(x.begin(),x.end())
#define REVE(x) reverse(x.begin(),x.end())
#define all(x) (x).begin(),(x).end()
#define fst first
#define mp make_pair
#define pb push_back
using LL = long long;
using ULL = unsigned long long;
#define FOR(i, m, n) for(int i = m;i < n;i++)
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C, D;
    cin >> A >> B >> C >> D;
  if(min(D,B)-max(A,C)>0){
  cout << min(D,B)-max(A,C);
}else{
  cout << 0;
  }
}

Measured memory_bytes: 256
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

N = ii()
S = input()

pos = 0
r_cnt = 0

while pos < N and S[pos]==')':
    r_cnt += 1
    pos += 1

l_cnt = 0

for i in range(pos, N):
    if S[i]=='(':
        l_cnt += 1
    else:
        if l_cnt==0:
            r_cnt += 1
        else:
            l_cnt -= 1

#if l_cnt > 0:
print('('*r_cnt + S + ')'*l_cnt)

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

const int maxn = 5005;

int n, k, cnt;
string s, ans[maxn];

int main()
{
	cin >> n >> k >> s;

	char minc = s[0]; 
	for (int i = 1; i < n; ++i) minc = min(minc, s[i]);

	int mxl = 0;
	for (int i = 0, len = 0; i < n; ++i)
		if (s[i] == minc) ++len;
		else mxl = max(mxl, len), len = 0;
	if (k >= 14) return cout << string(n, minc), 0;

	string tmp = s; reverse(tmp.begin(), tmp.end());
	s = s + tmp;
	for (int i = 0, len = 0; i < n; ++i) {
		if (s[i] == minc) ++len;
		else mxl = max(mxl, len), len = 0;
		if (i == n - 1) {
			if (s[i] != minc) break;
			++cnt;
			int L = len << k;
            if (L >= n) return cout << string(n, minc), 0;
			ans[cnt] = s.substr(n - len - (n - L), n - L); reverse(ans[cnt].begin(), ans[cnt].end());
			ans[cnt] = string(L, minc) + ans[cnt];
		} else if (len == mxl) {
			++cnt;
			int L = len << (k - 1);
			ans[cnt] = string(L, minc) + s.substr(i + 1, n - L);
		}
	}

	sort(ans + 1, ans + cnt + 1);
	cout << ans[1].substr(0, n) << endl;
	
	return 0;
}


Measured memory_bytes: 22144
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            int dab = b - a;
            int l = 0;
            for(int i = dab; i > 0; i--)
            {
                l += i;
            }
            
            Console.WriteLine(l - b);
        }
    }
}


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

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

typedef long long int ll;
typedef pair<int, int> P;

const long long INF = 3e18 + 12;
const int inf = 1e9;

int main() {
  double x;
  cin >> x;

  double y = x / 3;

  printf("%.12f\n", y * y * y);

  return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long int ll;
const int N = 1000000;
const int mod = 1000000007;
const int INF = 1 << 30;
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define vin(v,n) rep(i,n)cin>>v[i];
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define sz size()
#define fi first
#define se second0
#define pb push_back
#define prqueue priority_queue<ll,vector<ll>,greater<ll>>
string YN(bool b) { return(b ? "YES" : "NO"); }
string yn(bool b) { return(b ? "Yes" : "No"); }
int main() {
	ll n, v[100010], t=0, f=0,e;
	cin >> n;
	rep(i, n)cin >> v[i], (v[i] % 4 == 0 ? ++f : (v[i] % 2 == 0 ? ++t : t));
	e = n - f - t;
	if (t > 0)++e;
	e -= f + 1;
	cout << yn(e <= 0) << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define chmax(x,y) x = max(x,y)
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }
const ll MOD = 1000000007;

ll modPow(ll a, ll n) {
	ll res = 1;
	rep(i, n) {
		res *= a;
		res %= MOD;
	}
	return res;
}

int main() {
	ll n;
	cin >> n;
	cout << (modPow(10, n) + MOD - (2 * modPow(9, n)) % MOD + modPow(8, n)) % MOD << endl;
	return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

class Main{
    public static void main(String[] args){

    int match,num;
    Scanner s = new Scanner(System.in);

    while( s.hasNextInt() ){

        match=0;
        num=s.nextInt();

        for(int i=0;i<10;i++){
        	for(int j=0;j<10;j++){
        		for(int k=0;k<10;k++){
        			for(int l=0;l<10;l++){
        				if( num==i+j+k+l ){
        					match++;
        				}
        			}
        		}
        	}
        }

        System.out.println( match );

    }

    }
}

Measured memory_bytes: 26760
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=2e5+100;
ll par[N];
ll getpar(ll v){
    if (par[v]==v) return v;
    return par[v]=getpar(par[v]);
}
vector <int> g[N];
ll mark[N];
int32_t main(){
    ll n,m;
    cin >> n >> m;
    ll q;
    cin >> q;
    ll tm=n;
    ll ma=0;
    for (int i=0;i<N;i++) par[i]=i;
    ll pz=0;
    while(q--){
        ll u,v,c;
        cin >> u >> v >> c;
        u++;
        v++;
        if (c==0){
            ll u1=getpar(u),v1=getpar(v);
            if (v1!=u1){
                par[u1]=v1;
                tm--;
            }
            else continue;
            ma++;
        }
        if (c==1){
            g[u].pb(v);
            g[v].pb(u);
            if (m==n-1) pz=1;
        }
    }
    if (pz) kill("No");
    if (m==n-1) kill("Yes");
    ma+=tm*(tm-1)/2;
    ll y=0;
    for (int i=1;i<=n;i++){
        for (auto u : g[i]){
            if (getpar(i)==getpar(u)) kill("No");
        }
    }
   // cout << tm << " " << y << " " << mi << endl;
  // if (tm==2 && y==2) kill("No");
   ll mi=n;
    if (m>=mi && m<=ma) kill("Yes");
    kill("No");

}



Measured memory_bytes: 10112
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>  //setprecision(桁)
using namespace std;
#define pb push_back
#define ll long long int
#define rep(i,n) for(int i = 0;i < (n);i++)
ll INF = 1000000010; 
const ll MOD = 1000000007;


int main(){ 
    ll h, w; cin >> h >> w;
  	if(h == 1 || w == 1) cout << 1 << endl;
    else if((h * w) % 2 == 0) cout << h * w / 2 << endl;
    else cout << h * w / 2 + 1 << endl;
} 

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

int main()
{
    string S, T;
    cin >> S >> T;
    int64_t ans = 0;
    for (int i = 0; i < S.size(); i++)
    {
        if (S[i] != T[i])
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3916
#include <stdio.h>
int main()
{
    int n, cnt = 0;
    int A[110];
    int i, j, tmp, pos;
    scanf("%d", &n);
    for(i = 0; i < n; i++) scanf("%d", &A[i]);
    for(i = 0; i < n; i++)
    {
        pos = i;
        for(j = i + 1; j < n; j++)
        {
            if(A[j] < A[pos]) pos = j;
        }
        if(A[i] > A[pos])
        {
            tmp = A[i];
            A[i] = A[pos];
            A[pos] = tmp;
            cnt++;
        }
    }
    for(i = 0; i < n; i++)
    {
        if(i > 0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n%d\n", cnt);
    return 0;
}


Measured memory_bytes: 2140
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,d,t=0;
    cin>>a>>b>>c>>d;
    for(int i=0;i<=a;i++){
    	for(int j=0;j<=b;j++){
    		for(int k=0;k<=c;k++){
    			if(i*500+j*100+k*50==d)t++;
			}
		}
	}
	cout<<t<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=1e6+10;
int q[N];
#define f(i,a,b) for(int i=a;i<b;i++)
#define read(x)  scanf("%d",&x)
int main(){
int k,a,b;
scanf("%d%d%d",&k,&a,&b);
for(int i=a;i<=b;i++){
	if(i%k==0){
		printf("OK");
		return 0;
	}
	else if(i==b)printf("NG");
}
return 0;
}


Measured memory_bytes: 3724
program main
	implicit none
    character(1000) S, ans
	integer w, i
	read(*, *) S
	read(*, *) w
	do i = 1, len_trim(S)
		if(w == 1) then
			write(*, *) trim(S)
			goto 1
		else if(mod(i,w) == 1) then
			write(*, '(a)', advance = 'No') S(i:i)
		end if
	end do
	write(*, *) ''
1 continue
end program main

Measured memory_bytes: 768
/*input
60 3
5 8
1 3
10 15
*/

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

// from atcoder live
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> l(k), r(k);
  rep(i, k) cin >> l[i] >> r[i];
  vector<mint> dp(n);
  dp[0] = 1;
  for (int i = 1; i < n; ++i) {
    dp[i] = dp[i-1];
    rep(j, k) {
      if (i-l[j] < 0) continue;
      dp[i] += dp[i-l[j]];
      if (i-r[j]-1 < 0) continue;
      dp[i] -= dp[i-r[j]-1];
    }
  }
  cout << dp[n-1]-dp[n-2] << endl;
}


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

using namespace std;

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

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

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

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

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

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

bool used[2521][2521];
const int C = 1125;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
char dc[4]={'R','U','L','D'};

int bef[2521][2521];
int befy[2521][2521];
char str[12525];
void bfs(int x,int y,int tx,int ty){
  used[tx][ty]=false;
  queue<pii> Q;
  REP(i,2521)REP(j,2521)bef[i][j]=befy[i][j]=-1;
  bef[x][y] = -2;
  Q.push(pii(x,y));
  while(!Q.empty()){
    int cx = Q.front().first;
    int cy = Q.front().second;
    Q.pop();
    REP(i,4){
      int nx = cx+dx[i];
      int ny = cy+dy[i];
      if(nx<0||ny<0||nx>=2521||ny>=2521)continue;
      if(bef[nx][ny]!=-1)continue;
      if(used[nx][ny])continue;
      bef[nx][ny]=cx;
      befy[nx][ny]=cy;
      Q.push(pii(nx,ny));
    }
  }
  int m = 0;
  int cx = tx, cy = ty;
  while(bef[cx][cy]!=-2){
    used[cx][cy] = true;
    int nx = bef[cx][cy], ny = befy[cx][cy];
    REP(i,4){
      if(cx-nx==dx[i]&&cy-ny==dy[i]){
        str[m++] = dc[i];
      }
    }
    cx = nx;
    cy = ny;
  }
  FORR(i,0,m)putchar(str[i]);
}

int main(){
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  sx+=C;sy+=C;tx+=C;ty+=C;
  bfs(sx,sy,tx,ty);
  bfs(tx,ty,sx,sy);
  bfs(sx,sy,tx,ty);
  bfs(tx,ty,sx,sy);
  return 0;
}


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

int main(void) {
  int a, b, k;
  cin >> a >> b >> k;
  
  if ((b-a+1) <= 2*k) {
    for (int j=a; j<b+1; ++j) {
      cout << j << endl;
    }
  } else {
 	 for (int i=0; i<k; ++i) {
      		cout << a+i << endl;
  		}
  	  for (int i=0; i<k; ++i) {
      		cout << b-k+i+1 << endl;
  		}
  }
}

Measured memory_bytes: 256
s_dash = input()
t = input()

ans = []
for i in range(len(s_dash) - len(t) + 1):
    candidate = []
    for j in range(i):
        candidate.append('a' if s_dash[j] == '?' else s_dash[j])
    found = True
    for j in range(len(t)):
        if s_dash[i + j] == '?' or t[j] == s_dash[i + j]:
            candidate.append(t[j])
        else:
            found = False
            break
    if found:
        for j in range(len(t) + i, len(s_dash)):
            candidate.append('a' if s_dash[j] == '?' else s_dash[j])
        ans.append("".join(candidate))
if 0 == len(ans):
    print("UNRESTORABLE")
else:
    print(sorted(ans)[0])


Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<cmath>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
int Q;
int main() {
	scanf("%d", &Q);
	vector<int> l(Q), r(Q);
	rep(i, 0, Q)scanf("%d%d", &l[i], &r[i]);
	int MAX = 101010;
	vector<int> is_prime(MAX, 1);
	is_prime[0] = is_prime[1] = is_prime[2] = 0;
	for (int i = 2; i < MAX; i++) {
		for (int num = i * 2; num < MAX; num += i) {
			is_prime[num] = 0;
			if (num * 2 - 1 < MAX)is_prime[num * 2 - 1] = 0;
		}
	}
	for (int i = 2; i < MAX; i++)is_prime[i] += is_prime[i - 1];
	rep(i, 0, Q) {
		printf("%d\n", is_prime[r[i]] - is_prime[l[i] - 1]);
	}
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N,M;
    cin >> N >> M;
    ll A[N];
    ll i;
    ll sum=0;
    for(i=0;i<N;i++){
        cin >> A[i];
        sum+=A[i];
    }
    sort(A,A+N);
    if(A[N-M]*4*M>=sum)cout << "Yes";else cout << "No";
    return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.conv;
import std.datetime;
import std.numeric;
import std.math;
import std.string;

string my_readln() { return chomp(readln()); }

void main()
{
	auto tokens = split(my_readln());
	auto N = to!uint(tokens[0]);

	long[] a;
	foreach (i; 0..N)
	{
		a ~= to!long(my_readln());
	}
	a.sort();
	stderr.writeln(a);
	ulong result;
	long last_b = a[0], last_e = a[0];
	ulong begin = 1, end = a.length - 1;
	ulong mod = 0;
	if (a.length % 2 == 1)
	{
		auto mid = a.length / 2;
		auto left = a[mid] - a[mid-1];
		auto right = a[mid+1] - a[mid];
		if ((mid % 2 == 0 && left > right) || (mid % 2 == 1 && left < right))
		{
			last_b = a[$-1];
			last_e = a[$-1];
			begin = 0;
			end = a.length - 2;
			mod = 1;
		}
	}
	
	foreach (i; 1..a.length)
	{
		ulong idx;
		if ((i - 1) / 2 % 2 == mod)
			idx = end--;
		else
			idx = begin++;
		if ((i - 1) % 2 == 0)
		{
			result += abs(last_b - a[cast(uint)idx]);
			last_b = a[cast(uint)idx];
		}
		else
		{
			result += abs(last_e - a[cast(uint)idx]);
			last_e = a[cast(uint)idx];
		}
		stderr.writeln(idx);
		
	}
	writeln(result);
	stdout.flush();
}

Measured memory_bytes: 4092
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int n;
  cin >> n;
  
  vector<int> v(n-1);
  for(int i; i < n-1; i++)
    cin >> v.at(i);
  
  int s = 0;
  int j = 0;
  
  while(j < n){
    if(j == 0)
      s += v.at(0);
    if(j == n-1)
      s += v.at(n-2);
    if((0 < j) && (j < n-1))
      s += min(v.at(j-1), v.at(j));
    j++;
  }
  cout << s << endl;
}
      

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

#define MAX ((int)110)
#define endl '\n'

using namespace std;

typedef long long ll;

int n, m[ MAX ];
ll DP[ MAX ][ MAX ];

ll solve(){
	int j;
	ll cost;
	for(int len = 2 ; len <= n ; len++){
		for(int i = 1 ; i <= n - len + 1 ; i++){
			j = i + len - 1;
			DP[ i ][ j ] = LONG_LONG_MAX;
			for(int k = i ; k < j ; k++){
				cost = DP[ i ][ k ] + DP[ k + 1 ][ j ] + m[ i - 1 ] * m[ k ] * m[ j ];
				DP[ i ][ j ] = min(DP[ i ][ j ], cost);
			}
		}
	}
	return DP[ 1 ][ n ];
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	cin >> n >> m[ 0 ];
	for(int i = 1 ; i < n ; i++)
		cin >> m[ i ] >> m[ i + 1 ];
	cin >> m[ n ];
	cout << solve() << endl;
	return 0;
}


Measured memory_bytes: 3216
import java.util.*;
public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
		int N = sc.nextInt();
		if (N<=1) {
			System.out.println(0);
			return;
		}
		
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		int min = arr[0];
		int max = arr[N - 1];
		
		int ans = Integer.MAX_VALUE;
        for (int i = min; i <= max; i++) {
			int part = 0;
			for (int j = 0; j < N; j++) {
				part += (int)Math.pow(arr[j]-i, 2);
			}
			if (part < ans) {
				ans = part;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define Rep(i,a,b) for(ll i=a;i<b;i++)
#define pb emplace_back
#define allv v.begin(),v.end()
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
#define FASTio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<(#x)<<" "<<x<<endl
ll mod=1e9+7;
template<typename t>
ll Max(ll a,ll b)
{
    return (a>b)?a:b;
    
}
ll Min(ll a,ll b)
{
    return (a>b)?b:a;
}
ll power(ll a,ll b)
{
    ll p=1;
    a=a%mod;
    b=b%mod;
    while(b)
    {
        if(b&1)
        {
            p=((p%mod)*(a%mod))%mod;
        }
        a=((a%mod)*(a%mod))%mod;
        b=(b/2);
    }
    return p%mod;
}
int main()
{
    int t;
    t=1;
   // cin>>t;
    while(t--)
    {
        
        int x,y;
        cin>>x>>y;
        if(y>=2*x && ((y-2*x)%2==0) && (4*x>=y) && ((4*x-y)%2==0))
        cout<<"Yes"<<endl;
        else 
        cout<<"No"<<endl;
    }
    return 0;
}


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

typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;

#define endl '\n'
#define ff first
#define ss second
#define int long long
#define pb push_back
#define f(i,l,r) for(ll i=l;i<=r;i++)
#define rf(i,r,l) for(ll i=r;i>=l;i--)
#define Max 5000001
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define d0(a) cout<<a<<' ';
#define d1(a) cout<<a<<endl;
#define d2(a,b) cout<<a<<' '<<b<<endl;
#define d3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define d4(a,b,c,d) cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
#define d5(a,b,c,d,e) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<endl;
#define d6(a,b,c,d,e,f) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<' '<<f<<endl;

const ll N=2e5+5,mod=1e9+7,bit=61;



signed main()
{
    fast;

    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll fq[n+1]={0};
        f(i,2,n)
        {
            ll x;
            cin>>x;
            fq[x]++;
        }
        f(i,1,n)
        {
            cout<<fq[i]<<'\n';
        }
    }
    return 0;
}


















Measured memory_bytes: 5224
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000500

ll n, W, mx, w[105], v[105], dp[105][100005];

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    cin >> n >> W;
    for (int i = 1; i <= n; i++) cin >> w[i] >> v[i], mx = max(mx, v[i]);
    ll m = mx*n;
    for (int i = 0; i <= n; i++)
        for (int j = 0; j <= m; j++) dp[i][j] = 1e9;
    dp[0][0] = 0;
    for (int cnt = 0; cnt <= n; cnt++){
        for (int c = 0; c <= m; c++){
            dp[cnt + 1][c] = min(dp[cnt + 1][c], dp[cnt][c]);
            if (c + v[cnt + 1] <= m && dp[cnt][c] + w[cnt + 1] <= W) 
                dp[cnt + 1][c + v[cnt + 1]] = min(dp[cnt + 1][c + v[cnt + 1]], dp[cnt][c] + w[cnt + 1]);
        }
    }
    ll ans = 0;
    for (ll i = 1; i <= m; i++){
        if (dp[n][i] <= W) ans = max(ans, i);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 80128