akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(int, n, m);
	OUT(n * (n - 1) / 2 + m * (m - 1) / 2);
}


Measured memory_bytes: 256
/***
**   AUTHOR::ASHUTOSH MOUDGIL
***/


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

#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define int long long
//#define ll long long
#define all(x) x.begin(),x.end()
#define rsort(x) sort(all(x)); reverse(all(x));
#define endl '\n'
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define vi vector<int>
#define vlli vector<long long>
#define pii pair<int,int>
#define mod 1000000007
#define LMAX 1e18
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define PI 3.141592654
#define dbg1(x) cout << #x <<"="<< x <<endl;
#define dbg2(x,y) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<endl;
#define dbg3(x,y,z) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<", "<<#z<<"="<<z<<endl;
#define dbg4(x,y,z,a) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<", "<<#z<<"="<<z<< ", "<<#a <<"="<<a << endl;
#define dbgarr(x) cout << #x<<endl;for(int i : x){cout << i <<" ";} cout <<endl;



void mymain(){
    int a,b;
    double x = 0.08,y=0.10;
    cin >> a >> b;
    //deb(x)
    int ans = -1;
    for(int i=1;i<100000;i++){
        if((int)(x*i) == a && (int)(i*y)==b ){
            cout << i << endl;
            return;
        }

    }
    cout << -1 << endl;

}

signed main(){
IOS;
///freopen("input.txt", "r", stdin);
///freopen("output.txt", "w", stdout);
int t=1;
//cin>>t;
for(int tt=0;tt<t;tt++){
   ///cout << "Case #" << tt+1 <<": ";
   mymain();
   }
return 0;
}
/*

*/


Measured memory_bytes: 256
N = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))

import itertools
l = list(itertools.permutations(range(1,N+1)))

a = 0
b = 0

for i in range(len(l)):
    s = [i for i in l[i]]

    if s == p:
        a = i 
    if s == q:
        b = i 
        
print(abs(a-b))

Measured memory_bytes: 13988
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		int a = 1;
		int b = 0;
		while(true){
			b = sc.nextInt();
			if(b==0) break;
			System.out.println("Case "+a+": "+b);
			a++;
		}
	}
}


Measured memory_bytes: 42736
# coding: utf-8

def get_ans():
    (h, w) = [int(i) for i in input().rstrip().split(" ")]
    map = [input().rstrip() for i in range(h)]

    for i in range(h):
        for j in range(w):
            if map[i][j] != "#":
                continue

            nearBlack = False
            for k in range(i - 1, i + 2):
                if k < 0 or k >= h:
                    continue
                for l in range(j - 1, j + 2):
                    if (l < 0) or (l >= w):
                        continue
                    if k == i and l == j:
                        continue
                    if k != i and l != j:
                        continue
                    if map[k][l] == "#":
                        nearBlack = True
                        break
                if nearBlack:
                    break

            if not nearBlack:
                return False
    return True


print("Yes" if get_ans() else "No")


Measured memory_bytes: 3064
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;
typedef vector<int> Vint;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)
#define N 100510

bool era[N] = {true, true};

signed main(void){
  int i, j, k;

  for(i = 2;i * i <= N;i++){
    if(!era[i])for(j = i * i;j < N;j+=i)era[j] = true;
  }

  for(int testcase = 0;testcase < 1234567;testcase++){

    for(;;){
      int2(n, p);
      if((n & p) == -1)break;
      int pri[p], h = 0;
      for(i = n + 1;h < p;++i)if(!era[i])pri[h++] = i;

      Vint lis;
      rep(i, p)rep(j, i + 1)lis.pb(pri[i] + pri[j]);
      sort(all(lis));

      pri(lis[p - 1]);
    }

/*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 1376
#include "bits/stdc++.h"

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;
using ll = long long;
using P = pair<int, int>;

void Main() {
  int L;
  cin >> L;
  double x, y, z;
  x = y = z = L/3.0;
  cout << x*y*z << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 256
import math

array = []
for i in range(5):
    array.append(int(input()))
res = 0
round_array = []
for j in array:
    round_array.append(math.ceil(j /10) * 10)
tmp = 0
for k, l in zip(array, round_array):
    if abs(tmp) < abs(k - l):
        tmp = k - l
res = sum(round_array)
print(res + tmp)


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  vector<bool> dist(N, false);
  vector<int> ans(N);
  queue<int> Q;
  dist[0] = true;
  Q.push(0);

  while (!Q.empty()) {
    int v = Q.front();
    Q.pop();
    for (int nv : G[v]) {
      if (dist[nv]) continue;
      dist[nv] = true;
      ans[nv] = v;
      Q.push(nv);
      
    }
  }
  
  for (int i = 0 ; i < N; i++) {
    if (dist[i] == -1) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  for (int i = 1; i < N; i++) {
    cout << ans[i]+1 << endl;
  }
}

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

int main() {
int a,b;
cin>>a>>b;
if(a==b){
  cout  <<  "Draw"  <<  endl;
}
else if(a==1){
cout << "Alice" <<endl;
}
else if(b==1){
cout << "Bob"<<endl;
}
else if(a>=b){
cout << "Alice"<<endl;
}
else cout <<"Bob"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
#define task "test"
using namespace std;
const ll N = 100 + 9;
const ll inf = 1e9 + 7;
typedef pair<ll,ll> LL;

string s;
ll n,i;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        //freopen(task".out", "w", stdout);
    }
    cin>>s; n = s.size();
    for (i = 0;i < n;i++){
        if (s[i] == '?') cout<<'D';
        else cout<<s[i];
    }
}


Measured memory_bytes: 3740
#include <iostream>
#include <string.h>
#include <vector>
using namespace std;

int main () {
  string h;
  cin >> h;
  vector<int> l, r;
  char f = 'R';
  for (int i = 0; i < h.size(); i++) {
    if (h[i] != f) {
      if (f == 'R') {
        r.push_back(i - 1);  
        l.push_back(i);
      }  
      else {
        l.push_back(i - 1);
        r.push_back(i);  
      }
      f = h[i];
    }    
  }
  int before = 0;
  int ans[h.size()];
  for (int i = 0; i < h.size(); i++) ans[i] = 0;
  for (int i = 0; i < r.size(); i++) {
    int R = r[i] - before + 1;
    if (i != r.size() - 1) {
      before = r[i + 1];  
    }
    int L;
    if (i == r.size() - 1) {
      L = h.size() - l[i];  
    }  
    else {
      L = l[i + 1] - l[i] + 1;  
    }
    ans[r[i]] = R / 2 + (R % 2);
    ans[r[i] + 1] = R / 2;
    ans[l[i]] += L / 2 + (L % 2);
    ans[l[i] - 1] += L / 2;
    i++;
  }
  for (int i = 0; i < h.size(); i++) {
    cout << ans[i] << " ";  
  }
  cout << endl;
}

Measured memory_bytes: 1908
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

ll gcd(ll a, ll b)
{
    return (a%b == 0 ? b : gcd(b, a%b));
}

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) cin >> A[i];
    
    ll ans = A[0];
    for (ll i = 0; i < N-1; i++) ans = gcd(ans, A[i+1]);

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <stack> 
#include <map>
#include <queue>
#include <unordered_map>
#include <cassert>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;

#define pb 					push_back

template<typename T,typename S>
ostream& operator <<(ostream& os, pair<T, S> input) {
	os<<"("<<input.first<<", "<<input.second<<")";
	return os;
}

template<typename T>
ostream& operator <<(ostream& os, vector<T> input) {
	for(auto t: input)
		os << t <<" ";

	return os;
}


long long a[21][21];
long long  sum[65540];
int allones;
long long  dp[65540];

long long solve(int mask){
	if(dp[mask]!=-1)
		return dp[mask];

	long long fans = 0;
	for(int submask  = mask; submask >0 ; submask = (submask -1 )&mask) {
		fans  = max(fans, sum[submask ]  + solve( mask^submask) );
	}
	return dp[mask]=fans;
}
void init(int n){
	memset(dp, -1, sizeof dp);
	for(int i= 0; i<(1<<n); i++){
		vector<int> v;
		for(int j = 0; j<n;j++){
			if(i>>j & 1)
				v.push_back(j);
		}
		for(int x: v)
			for(int y: v)
				sum[i]+=a[x][y];
		sum[i]/=2;
	}
}
int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	int n;
	cin >> n;
	allones  = (1<<n) - 1;
	for(int i = 0;i<n;i++) {
		for(int j = 0; j<n; j++)
			cin >> a[i][j];
	}	
	init(n);
	cout << solve(allones) << "\n";

	return 0;
}

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

int rec(int depth, int prv, int sum){
  if(depth == 4)return (sum==0);

  int res = 0;
  for(int i=prv;i*i<=sum;i++){
    res += rec(depth+1, i, sum - i*i);
  }
  return res;
}

int main(){
  int n;
  while(cin >> n,n)cout << rec(0,0,n) << endl;
}

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

long long a[300000], sum[300000];
int main()
{
    long long n, m, j=0, mx=0, i; double d;
    cin>>n>>m;
    for(i=1; i<=n; i++) { cin>>a[i]; sum[i]=sum[i-1]+a[i]; }
    for(i=m; i<=n; i++)
        mx=max(mx,sum[i]-sum[i-m]);
    d=mx+m;
    cout<<setprecision(12)<<d/2<<endl;
    return 0;
}



Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    long long x;
    cin >> x;
    ll m=100;
    ll cnt=0;
    while(m<x){
        m=m*1.01;
        cnt++;
    }
    cout<< cnt<<endl;

  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv){
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {
	string s; cin >> s;
	vector<pair<int,int>> v; //<RorLのコンボ数,LRが変わった時の左側の要素番号>
	int cnt=1;
	rep2(i,1,s.size()){
		if(s[i-1]!=s[i]){
			v.emplace_back(cnt,i-1);
			cnt = 1;
		}else cnt++;
	}
	v.emplace_back(cnt,s.size()-1);
//	rep(j,v.size()) cout << v[j].first << " " << v[j].second << endl;
	int r = 1;
	vi ans(s.size(),0);
	rep(j,v.size()){
		if(r){
			ans[v[j].second] += (v[j].first+1)/2;
			ans[v[j].second+1] += v[j].first/2;
		}else{
			ans[v[j-1].second] += v[j].first/2;
			ans[v[j-1].second+1] += (v[j].first+1)/2;			
		}
			r = !r;
	}
	rep(j,s.size()) cout << ans[j] << " ";
	cout << endl;
}




Measured memory_bytes: 1780
#include <bits/stdc++.h>
#define ull unsigned long long int
#define sull static unsigned long long int
using namespace std;
int main(){
	int N, T;
	int i;
	int cost=114514;
	bool f;
	int a[1000];
	int b[1000];
	int c[1000];
	int d[1000];
	cin >> N>>T;
	for(i=0;i<N;i++){
		cin >> a[i];
		cin >> b[i];
	}
	for(i = 0; i < N; i++) {
		if (b[i] > T);
		else cost = min(cost, a[i]);
	}
	if (cost == 114514)cout << "TLE" << endl;
	else cout << cost << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int ans = 1;

        String base = s.substring(0, 1);

        for (int i = 1; i < n; i++) {
            if (!base.equals(s.substring(i, i+1))) {
                ans++;
                base = s.substring(i, i+1);
            }
        }

        System.out.println(ans);

        sc.close();
    }    
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define DISP1(as)		for(auto it : as) cout<<it.f<<" "<<it.s<<") ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cout<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	2e+5 + 99;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

// <------------- Declare Variables Here ------------> //

ll T = 1;

// <---------------------- > //


 
// <------------- Start of main() -------------------> //

void MAIN() {
	ll  n;
	cin  >> n;
	vll a(n);
	
	unordered_map<ll,ll> val;
	set<ll> digi;

	for (ll i = 0; i < n; i++) {
		cin >> a[i];
		if(val[a[i]]) {
			val[a[i]] = 2;
			continue;
		}

		for(ll j=a[i];j <= 2000000 ; j+=a[i]) {
			val[j]++;
		}

		digi.insert(a[i]);
	}

	ll cou = 0;
	for(auto it : digi) {
		if(val[it] != 1) {
			continue;
		}
		 cou++;
	}

	cout<<cou;newl;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 85596
#include<stdio.h>

int main(){
    int arr[10];
    int p,q,r;

    if(scanf("%d%d%d",&p,&q,&r)>=0){
        int ab=p+q;
        int bc=q+r;
        int ca=r+p;

        if(ab<=bc && ab<=ca){
            printf("%d\n",ab);
        }
        else if(bc<=ab && bc<=ca){
            printf("%d\n",bc);
        }
        else{
            printf("%d\n",ca);
        }

    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
using namespace std;


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



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

  rep(i, 2)
    rep(j, n) cin >> a[i][j];

  vector<int> s1(n + 1, 0), s2(n + 1, 0);

  for(int i = 0; i < n; ++i){
    s1[i + 1] = s1[i] + a[0][i];
    s2[i + 1] = s2[i] + a[1][i];
  }

  int ans = 0;

  for(int i = 1; i <= n; ++i){
    ans = max(ans, s1[i] + s2[n] - s2[i - 1]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int x, i = 0;
	while(1)
	{
		scanf("%d", &x);
		if (x != 0)
		{
			i++;
			printf("Case %d: %d\n", i, x);
			continue;
		}
		break;
	}
	return 0;
}

Measured memory_bytes: 600
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
//const int mod=(int)998244353;
const llint big=(llint)(2.19e16)+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
using pli=pair<llint,int>;
using daic=priority_queue<pli,vector<pli>,greater<pli>>;
int main(void){
	llint n,k,ans=0;cin>>n>>k;
	if(k==0){cout<<n*n<<endl;RE;}
	for(llint b=k+1;b<=n;b++){
		ans+=n+1 - (k*((n+1)/b) + min(k,(n+1)%b));
	}
	cout<<ans<<endl;
	RE;
}

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

using namespace std;

const int MX = 200000;

char s[MX + 1];

int main() {
	ignore = scanf("%s", s);
	int n = strlen(s);
	
	long long ans = 0;
	for (int i = n - 1, len = 0; i >= 0; i--) {
		if (s[i] == 'A') {
			if (len % 2 == 0) ans += len / 2;
			else len = 0;
		}
		else {
			if (s[i] == 'C' - len % 2) len++;
			else len = s[i] == 'C' ? 1 : 0;
		}
	}
	
	printf("%lld\n", ans);
	
	return 0;
}


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


int main() {
    int a, b;
    cin >> a >> b;
    if((a*b)%2 == 0){
        cout << "Even";
    }   
    else
    {
        cout << "Odd";
    }
    cout << endl;
}


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

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

  ll kane = 1000;
  ll kabu = 0;
  ll sell = 0;  // 売るときの値段
  ll last = -1;
  bool buy_turn = true;
  for (int day = 0; day < n; day++) {
    ll now = a[day];
    if (day == n - 1 && kabu != 0) {
      // 最終日は株が残っていれば全部売る
      kane += kabu * now;
      kabu = 0;
      // printf("sell   kane = [%lld]  kabu = [%lld]\n", kane, kabu);
      break;
    }

    if (buy_turn) {               // 買い待ち
      if (now == last) continue;  // 同じ金額が続いたらスルー

      // 翌日以降に今より高いタイミングがあるか確認する
      ll mx_kane = now;
      ll mx_day = day;
      for (int i = day + 1; i < n; i++) {
        if (mx_kane > a[i]) {
          break;
        } else {
          mx_kane = a[i];
          mx_day = i;
        }
      }

      if (now < mx_kane) {
        // あるなら得するので今買っておく
        kabu = kane / now;
        kane -= kabu * now;
        sell = a[mx_day];
        buy_turn = false;
        // printf("buy    kane = [%lld]  kabu = [%lld]\n", kane, kabu);
        // printf("buy    sell = [%lld]\n", sell);
      } else {
        // 損することがわかるので買わない
      }
    } else {  // 売り待ち
      if (now == sell) {
        kane += kabu * now;
        kabu = 0;
        buy_turn = true;
        // printf("sell   kane = [%lld]  kabu = [%lld]\n", kane, kabu);
      }
    }

    last = now;
  }

  cout << kane << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	int n, a, b;
	cin >> n >> a >> b;
	
	int cnt = (n / (a+b));
	
	cout << min((n - cnt*(a+b)),a) + cnt * a;

	return 0;
}



Measured memory_bytes: 256
n = int(input())
P = list(map(int, input().split()))
table = [0] * n

for i in range(n):
    if i+1 == P[i]:
        table[i] = 1

cnt = 0
for i in range(n):
    if table[i] == 1:
        cnt += 1
        if i+1<n:
            if table[i+1]==1:
                table[i+1] = 0
print(cnt)

Measured memory_bytes: 14008
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

#define rep(i, a, b) for(auto (i)=a;i<b;i++)
#define list(i, N) for(auto (i)=0;i<N;i++)

typedef long long ll;
typedef vector <ll> vi;
typedef pair <ll, ll> pi;
#define mp make_pair
#define pb push_back
#define eb emplace_back

#define int ll
#define INF 1e18+5
#define mod 1000000007

template<class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;

    //first check if option C is cheaper than options A and B combined
    double halfA = (double)A/2; double halfB = (double)B/2;
    bool isCBetter = (halfA + halfB) >= C;
    //Casework lol
    if(isCBetter){
        int option1 = 2*max(X,Y)*C; //its okay to have more pizzas than needed
        //For option 2, casework on the minimum value
        int option2 = 0;
        if(min(X,Y)==X){
            //get 2*X pizzas of type C
            option2 += 2*X*C;
            Y -= X;
            option2 += B*Y;
        }else {
            option2 += 2*Y*C;
            X -= Y;
            option2 += A*X;
        }
        cout << min(option1,option2) << "\n";
    }else {
        //C is pricey to get
        cout << X*A + Y*B << "\n"; //better to buy individually
    }

    return 0;
}

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


#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
// User defined sizeof macro
# define my_sizeof(type) ((char *)(&type+1)-(char*)(&type))


int main()

{
    optimize();
    int d,t,s;
    cin>>d>>t>>s;
    if((s*t)>=d)cout<<"Yes";
    else cout<<"No";












    return 0;
}





Measured memory_bytes: 3608
#include <stdio.h>

int main(void){
	int x,y;
	scanf("%d%d",&x,&y);
	while(x||y){
		if(x<y) printf("%d %d\n",x,y);
		else printf("%d %d\n",y,x);
		scanf("%d%d",&x,&y);
	}
	return 0;
}


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

long long int N, M, ans;

int main ()
{
	cin >> N >> M;
	swap (N, M);
	if (N < 2 * M) {
		cout << N / 2 << endl;
		return 0;
	}
	if (N >= 2 * M) {
		ans = M;
		N -= 2 * M;
		M = 0;
	}
	ans += N/4;
	cout << ans << endl;
	return 0;
}

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

    int main (){
        int n;
        cin >> n;
        vector<int> a(n);
        rep(i,n){
            cin >> a[i];
        }
        sort(a.begin(),a.end(),greater<int>());
        int ali=0;
        int bob=0;
        rep(i,n){
            if(i%2==0){
                ali+=a[i];
            }
            else{
                bob+=a[i];
            }
        }

        cout << ali-bob << endl;

        return 0;

    }


Measured memory_bytes: 3600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.lang.Math;

class Main{
    public static void main(String[] args){
        InputStreamReader inputStreamReader = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(inputStreamReader);
        
        String str;
        
        try {
            while(reader.ready()){
                str = reader.readLine();

                int n = str.length();
                for (int i = n; i > 0; i--){
                    System.out.print(str.substring(i-1, i));
                }
                System.out.println();
                
            }
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}


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

using ll = long long; using ld = long double; using ull = unsigned long long; using uint = unsigned int;
using vi  = vector<int>; using vb  = vector<bool>; using vd  = vector<double>; using vl  = vector<ll>;
using vvi = vector<vi>;  using vvb = vector<vb>;   using vvd = vector<vd>;     using vvl = vector<vl>;

#define REP(i,n) for(ll i=0; i<(n); ++i)
#define FOR(i,b,n) for(ll i=(b); i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define TEN(x) ((ll)1e##x)

template<typename T> inline string join(const vector<T>& vec, string sep = " ") { stringstream ss; REP(i, vec.size()) ss << vec[i] << ( i+1 == vec.size() ? "" : sep ); return ss.str(); }


///////////////

#define EPS (1e-10)
#define NEXT(x, i) (x[(i + 1) % x.size()])

template<class T> using CR = const T &;
using P = complex<ld>;
using G = vector<P>;

ld dot(P a, P b) { return real(conj(a)*b); }
ld cross(P a, P b) { return imag(conj(a)*b); }

ld area2(CR<G> g) {
	ld s = 0;
	REP(i, g.size()) s += cross(g[i], NEXT(g, i));
	return s;
}

//////////////

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);


	G g;
	ld x, y;
	char c;
	while (cin >> x >> c >> y) g.push_back({ x, y });
	
	cout << abs(area2(g)) / 2 << endl;

	return 0;
}

Measured memory_bytes: 3252
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i< (n);i++)
#define SORT(a) sort((a).begin(),(a).end());
#define che(a,string) cout<<string<<":"<<(a)<<endl;
#define ch(a,string) cout<<string<<":"<<(a)<<" ";
using namespace std;
typedef pair<int,int> p;
int main(){
   string S;cin>>S;
   bool a =true;
   int n = S.size();
   rep(i,n){
	   if(i%2==0){
		   //kottiga kisuu
		   if(S[i]=='L'){
			 a = false;
			 }
		 }
		 else {
			 if(S[i]=='R'){
				 a =false;
			   }
		   }
	 }
	 if(a){
		 cout<<"Yes"<<endl;
	   }
	   else{
		   cout<<"No"<<endl;
		 }
 }	


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    //int t;cin>>t;while(t--)
    {
        ll i,j,k,l,m,n,a,b,c,d,cnt=0,sum=0;
        cin>>a>>b;
        if(b>=(2*a) && (b<=4*a) && (b%2==0))
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }


}


Measured memory_bytes: 3624
Module Module1

    Sub Main()
        Dim a, b, c, x, count As Integer
        a = Console.ReadLine
        b = Console.ReadLine
        c = Console.ReadLine
        x = Console.ReadLine
        For i As Integer = x \ 500 To 0 Step -1
            For j As Integer = x \ 100 To 0 Step -1
                For k As Integer = x \ 50 To 0 Step -1
                    If i <= a And j <= b And k <= c Then
                        If 500 * i + 100 * j + 50 * k = x Then
                            count = count + 1
                        End If
                    End If
                Next
            Next
        Next
        Console.WriteLine(count)
        Console.ReadLine()

    End Sub

End Module


Measured memory_bytes: 13268
import math
from collections import deque
from collections import defaultdict
import itertools as it

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	#data = [2]
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	#ans = [x for x in data if x!=0]
	ans = data[:]
	return ans

x,n = readInts()
p = input()
if n==0:
	print(x)
	exit()
p = list(map(int, p.split()))

if x not in p:
	print(x)
	exit()

for i in range(1,101):
	l = x-i
	r = x+i
	if l not in p:
		print(x-i)
		exit()
	if r not in p:
		print(x+i)
		exit()


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

int main(){
	int N; cin >> N;
    int K; cin >> K;
  	int arr[N], dp[N];
  	
  	for(int i=0; i<N; i++){
      cin >> arr[i];
    }
  	
  	dp[N-1] = 0;
  
  	for (int i=N-2; i>=0; i--){
        int curr_min = INT_MAX, curr_val = 0;
        
        for (int j=1; j<=K; j++){
            if (i+j >= N) break;
            curr_val = abs(arr[i] - arr[i+j]) + dp[i+j];
            if (curr_val < curr_min) curr_min = curr_val;
        }      

        dp[i] = curr_min;
       
    }
  	
  	cout << dp[0] << endl;
	return 0;
}


Measured memory_bytes: 1024
// luogu-judger-enable-o2
#include<iostream>
using namespace std;
char a[10]{'a','e','i','o','u'};
int z=0;
int main(){
char b;
cin>>b;
for(int i=0;i<5;i++){
	if(b==a[i])z++;
}
	if(z!=0)cout<<"vowel";
	else cout<<"consonant";
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
string S;
ll cnt[2019];

int main(){
  cin >> S; N = S.length();
  cnt[0]++;

  int now = 0, ten = 1;
  for (int i = N - 1; i >= 0; i--){
    now += (S[i] - '0') * ten;
    now %= 2019;
    cnt[now]++;
    ten *= 10; ten %= 2019;
  }

  ll ans = 0;
  for (int i = 0; i < 2019; i++){
    ans += cnt[i] * (cnt[i] - 1) / 2;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3756
class PQueue
  def initialize(data = [], &cmp)
    @data = [nil] + data.sort(&cmp)
    @cmp = cmp
  end
  def size; @data.size - 1; end
  def empty?; @data.size == 1; end
  def peek; empty? ? nil : @data[1]; end

  def push(el)
    j = @data.size
    @data << el
    while j > 1
      break if @cmp.call(@data[j / 2], @data[j]) < 0
      
      @data[j] = @data[j / 2]
      @data[j / 2] = el
      j /= 2
    end
    self
  end
  alias_method :<<, :push
  
  def shift
    return nil if empty?
    return @data.pop if size == 1
    
    el = @data[1]
    tail = @data.pop
    
    @data[1] = tail
    j = 1
    while 2 * j < @data.size
      i = 2 * j
      i += 1 if i + 1 < @data.size && @cmp.call(@data[i + 1], @data[i]) < 0

      break if @cmp.call(@data[j], @data[i]) < 0
      
      @data[j] = @data[i]
      @data[i] = tail
      j = i
    end
    return el
  end
end
# dp[s][c] : 駅sをコインc枚以上もって、出発するときの最小時間
# dp[v][j] = min{ dp[u][j + a] + b } (j >= 0)
def min(a,b); a < b ? a : b; end
def max(a,b); a > b ? a : b; end
INF = Float::INFINITY

N,M,S = gets.split.map(&:to_i)
dp = Array.new(N + 1){ Array.new(2520, INF) }

E = Array.new(M)
V = Array.new(N + 1)

M.times do |i|
  E[i] = gets.split.map(&:to_i)
end
(1 .. N).each do |i|
  V[i] = gets.split.map(&:to_i)
end

G = Array.new(N + 1){ [] }
max_a = 0

E.each do |(u, v, a, b)|
  max_a = max(max_a, a)
  G[u] << [v, a, b]
  G[v] << [u, a, b]
end
A_MAX = max_a * N

q = PQueue.new{|a,b| [a[0],-a[1]] <=> [b[0],-b[1]] }
q << [0, min(S, A_MAX), 1]

until q.empty?
  t,w,v = q.shift
  c,d = V[v]

  next if t >= dp[v][w]
  w.downto(0) do |w_|
    if dp[v][w_] > t
      dp[v][w_] = t 
    else
      break
    end
  end
  
  G[v].each do |u,a,b|
    q << [t + b, w - a, u] if w >= a && dp[u][w - a] > t + b
  end
  q << [t + d, min(w + c, A_MAX), v] if dp[v][min(w + c, A_MAX)] > t + d
end
puts (2 .. N).map{|i| dp[i][0] }


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

int main(){
  int n;
  cin >> n;
  
  int odd_cnt = 0;
  for (int i = 0; i < n; i++){
    int a;
    cin >> a;
    if (a % 2) odd_cnt++;
  }
  if (odd_cnt % 2) cout << "NO" << endl;
  else cout << "YES" << endl;
}

Measured memory_bytes: 256
def cmb(a,b,c):
    b = min(b,a-b)
    num = 1
    for i in range(b):
        num = num*(a-i) % c
    den = 1
    for i in range(b):
        den = den*(i+1) % c
    return num * pow(den,c-2,c) % c
n,m,k = map(int,input().split())
mod = 10**9+7
ans = 0
C = cmb(n*m-2,k-2,mod)
for i in range(1,n):
    ans += i*(n-i)*m**2*C
    ans %= mod
for i in range(1,m):
    ans += i*(m-i)*n**2*C
    ans %= mod
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>

#define MAX 1000001
#define SIZE 2000

using namespace std;

int m, n;
int table[SIZE][SIZE]={{0,0}};
int dp[SIZE][SIZE];
bool prime[MAX]; 
pair<int, int>coord[MAX];//座標
pair<int, int> ans;// <素数の数, 出口の番号>


void dfs(int count, int y, int x){
	int num = table[y][x];
	if(num <= 0 || m < num) return;
	if(count < dp[y][x] || (count == dp[y][x] && prime[num] == false && dp[y][x] !=0)) return;
	dp[y][x] = count;

	if(prime[num] == true){
		count++;
		dp[y][x] = count;
		if(ans.first < count || (ans.first == count && ans.second < num)){
			ans.first = count;
			ans.second = num;
		}
	}

	for(int dx=-1; dx<=1; dx++){
		dfs(count, y+1, x+dx);
	}
}


int main(void){
	fill(prime, prime+MAX, true);
	prime[0] = prime[1] = false;
	for(int i=2; i<MAX; i++){
		if(prime[i]){
			for(int j=i+i; j<MAX; j+=i){
				prime[j] = false;
			}
		}
	}

	int d=0, x=1000, y=1000;
	int dx[4]={0, 1, 0, -1};
	int dy[4]={1, 0, -1, 0};
	for(int i=1; i<MAX; i++){
		table[y][x] = i;
		coord[i] = make_pair(y, x);
		if(table[y+dy[(d+1)%4]][x+dx[(d+1)%4]] == 0) d++;
		x += dx[d%4];
		y += dy[d%4];
	}

	while(1){
		cin >> m >> n;
		if(!m && !n) break;

		int y = coord[n].first;
		int x = coord[n].second;
		fill(dp[0], dp[2000], 0);
		ans = make_pair(0, 0);
		dfs(0, y, x);
		cout << ans.first << " " << ans.second << endl;
	}
	return 0;
}


Measured memory_bytes: 35356
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<cmath>
using namespace std;
#define N 100005
typedef long long ll;



int main(){
	string s;
	cin>>s;
	if(s[0]=='7'||s[1]=='7'||s[2]=='7'){
		cout<<"Yes";
	} 
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>

void show_ans(int x,int y){
    for(int i = 0;i < y;i++){
        printf("%d",x);
    }
    printf("\n");
}

int main(void){

    int a,b;
    scanf("%d %d",&a,&b);
    if(a < b){
        show_ans(a,b);
    }else{
        show_ans(b,a);
    }
    return 0;
}

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define dbg(var) {std::cout << #var << "  = " << var << nl;}
#define vi vector<int>
typedef long long ll;

using namespace std;

constexpr int MOD = 1e9 + 7;

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

	int n;
	cin >> n;
	
	vector<vi> can(n , vi(n));
	rep(i , n)
		rep(j , n)
			cin >> can[i][j];
			
	
	vector<vi> dp(n , vi(1 << 22 , -1));
	function<int(int,int)> rec = [&](int man , int mask) -> int
	{
		if(dp[man][mask] != -1)
			return dp[man][mask];
		
		int ans = 0;
		
		if(man == n - 1)
		{
			rep(i , n)
				if((1 << i) & mask)
					ans += can[man][i];
		}
		else
		{
			rep(i , n)
			{
				if((1 << i) & mask)
				{
					if(can[man][i])
						ans = (ans + rec(man + 1 , mask ^ (1 << i))) % MOD;
				}
			}
		}
		
		return dp[man][mask] = ans;
	};
			
	cout << rec(0 , (1 << 22) - 1);

	return 0;
}

Measured memory_bytes: 360832
k, n = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
# print(a)

dist = []
for i in range(n):
    if i!=n-1:
        dist.append(min(a[i+1]-a[i], a[i]+(k-a[i+1])))
    else:
        dist.append(min(a[i]-a[0], a[0]+(k-a[i])))
# print(dist)
print(k-max(dist))


Measured memory_bytes: 33248
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;
#define mod 1000000007
ll dp[2001][2001];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll i,j,k,l,n,m;
    cin >> n;
    for (i = 3; i <= n;i++){
        dp[1][i] = 1;
    }
    for (i = 2; i <= n; i++)
    {
        dp[i][3] = 1;
        for (j = 4; j <= n; j++)
        {
            dp[i][j] = (dp[i][j - 1] + dp[i - 1][j - 3]) % mod;
        }
    }
    /*for (i = 1; i <= n;i++){
        for (j = 1; j <= n;j++)
            cout << dp[i][j] << " ";
        cout << "\n";
    }*/
    cout << dp[n][n] << "\n";
    return 0;
}

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

int main(){
    int e;

    while(cin>>e,e){
        int res=10000000;
        for(int z=100;z>=0;z--){
                for(int y=1000;y>=0;y--){
                    int x=e-z*z*z-y*y;

                    if(x>=0){
                        res=min(res,x+y+z);
                    }
                }
        }

        cout << res << endl;
    }
}

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

int gcd(int a, int b) {
    if(b==0) return a;
    return gcd(b,a%b);
}
int main(void){
    int a, b;
    cin>>a>>b;
    cout<<gcd(a,b)<<endl;
    // Your code here!
    
}



Measured memory_bytes: 3088
using System;
//using System.Collections.Generic;

public class ProCon
{
    public static void Main(){     
        string num =　Console.ReadLine();
        bool check = false;

        foreach(char number in num)
        {
            if (number == '7') check = true;
        }

        if(check) Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }
}

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

int cnt;

void insertionSort(int* a, int n, int g){

    int i, j, v;

    for(i = g; i < n; i++){
        v = a[i];
        j = i - g;
        while((j >= 0) && (a[j] > v)){
            a[j + g] = a[j];
            j = j - g;
            cnt++;
        };
        a[j + g] = v;
    }
}

void shellsort(int* a, int n)
{
    cnt = 0;
    int i, p;
    int m;
    int* G;

    p = 1;
    for(i = 1; i < 20; i++){
        p = p * 3;
        if(p - 1 > 2 * n) break;
    }
    if(i > 1) i = i - 1;
    m = i;

    G = new int [m];
    if(G == NULL) return;

    p = 1;
    for(i = 0; i < m; i++){
        p = p * 3;
        G[m - 1 - i] = (p - 1) / 2;
    }
    cout << m << endl;
    for(i = 0; i < m - 1; i++) cout << G[i] << " ";
    cout << G[m - 1] << endl;

    for(int i = 0; i < m; i++){
        insertionSort(a, n, G[i]);
    }
    delete [] G;
}

int main()
{
    int* A;
    int i, n;
    cin >> n;

    A = new int [n];
    if(A == NULL) return 0;

    for(i = 0; i < n; i++) cin >> A[i];

    shellsort(A, n);
    cout << cnt << endl;
    for(i = 0; i < n; i++) cout << A[i] << endl;

    delete [] A;

    return 0;
}

Measured memory_bytes: 4896
#include<iostream>
#include<vector>
#include<algorithm>

int main(){
	int n;
	long long int sum=0;
	std::cin>>n;

	std::vector<long long int> b(n-1);
	for (long long int& x : b) {
		std::cin >> x;
	}

	sum += b[0];

	for (int i = 0; i < n; i++) {

		if (b.size() - 1 == i) {
			sum += b[b.size() - 1];
			break;
		}

		sum += std::min(b[i], b[i + 1]);

	}


	std::cout<<sum<<std::endl;
	return 0;
}

Measured memory_bytes: 256