akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<time.h>
#include<stdlib.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pll pair<ll,ll>
#define vll vector<ll,ll>
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define sz(x) (ll)x.size()
#define hell 1000000007
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>b;i--)
#define lbnd lower_bound
#define ubnd upper_bound
#define bs binary_search
#define gcd(a,b) __gcd((a),(b))
#define EPS 1e-12
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define sqrt sqrtl
#define cbrt cbrtl
using namespace std;
char a[200][200];
ll row[200],col[200];
int main()
{
  IOS
  
  ll i,j;
  ll n,m;
  cin>>n>>m;
  for(i=1;i<=n;i++)
  {
    string s;
    cin>>s;
    for(j=1;j<=m;j++)
      a[i][j]=s[j-1];
  }
  for(i=1;i<=n;i++)
  {
    for(j=1;j<=m;j++)
      if(a[i][j]=='#')
        break;
    if(j>m)
      row[i]=1;
  }
  for(j=1;j<=m;j++)
  {
     for(i=1;i<=n;i++)
      if(a[i][j]=='#')
        break;
      if(i>n)
        col[j]=1;
  }
  for(i=1;i<=n;i++)
    if(!row[i])
    {
      for(j=1;j<=m;j++)
        if(!col[j])
          cout<<a[i][j];
      cout<<"\n";
    }
 
  return 0;
}


Measured memory_bytes: 256
N = int(input())

X = [[0 for _ in range(10)] for _ in range(10)]

for i in range(1, N+1):
    s = str(i)
    a, b = int(s[0]), int(s[-1])
    X[a][b] += 1

ans = 0
for a in range(10):
    for b in range(10):
        ans += X[a][b] * X[b][a]

print(ans)


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

class Main{
  public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int N = Integer.parseInt(sc.next());
      int[] t = new int[N+1];
      int[] x = new int[N+1];
      int[] y = new int[N+1];
      for(int i = 1; i<N+1; i++){
        t[i] = Integer.parseInt(sc.next());
        x[i] = Integer.parseInt(sc.next());
        y[i] = Integer.parseInt(sc.next());
      }
      for(int i = 1; i<N+1; i++){
        int tdiff = t[i] - t[i-1];
        int xd = Math.abs(x[i]-x[i-1]);
        int yd = Math.abs(y[i]-y[i-1]);
        int dd = xd+yd;
        if(tdiff >= dd && (tdiff%2 == dd%2)) continue;
        else{
          System.out.println("No");
          return;
        }
      }
      System.out.println("Yes");
  }
}

Measured memory_bytes: 60076
#include<cstdio>
#include<algorithm>

using namespace std;

bool field[100][100];

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

int N,M;

int rec(int x,int y)
{
	int res=0;
	field[x][y]=false;
	for(int d=0;d<4;d++)
	{
		int nx=x+dx[d],ny=y+dy[d];
		if(nx<0||ny<0||nx>=N||ny>=M) continue;
		if(field[nx][ny]==false) continue;
		res=max(res,rec(nx,ny));
	}
	field[x][y]=true;
	return res+1;
}

int main()
{
	while(true)
	{
		scanf("%d%d",&M,&N);
		if(M==0&&N==0) break;
		for(int i=0;i<N;i++)
		{
			for(int j=0;j<M;j++)
			{
				int in;
				scanf("%d",&in);
				field[i][j]=(in==1);
			}
		}
		int ans=0;
		for(int i=0;i<N;i++) for(int j=0;j<M;j++) if(field[i][j]==true) ans=max(ans,rec(i,j));
		printf("%d\n",ans);
	}
	return 0;
}

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

int main()
{
  int N, M;
  cin >> N >> M;
  vector<vector<bool>> g(N, vector<bool>(N, false));
  rep(i, 0, M)
  {
    int a, b;
    cin >> a >> b;
    g.at(--a).at(--b) = true;
    g.at(b).at(a) = true;
  }
  vector<int> A(N - 1);
  rep(i, 1, N)
  {
    A.at(i - 1) = i;
  }
  int ans = 0;
  do
  {
    bool flag = true;
    if (!g.at(0).at(A.at(0)))
    {
      continue;
    }
    rep(i, 0, N - 2)
    {
      if (!g.at(A.at(i)).at(A.at(i + 1)))
      {
        flag = false;
        break;
      }
    }
    if (flag)
    {
      ans++;
    }
  } while (next_permutation(A.begin(), A.end()));
  cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

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

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    bool valid = true;
    for(int i=0; i<n; i++){
        int a; cin>>a;
        if(a % 2 == 0){
            if(a % 3 == 0 || a % 5 == 0);
            else valid = false;
        }
    }

    cout << (valid ? "APPROVED" : "DENIED") << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a);  a = (a * a);  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 4;
ll k,a,b,g,x = 1,ans;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>k>>a>>b;
    ans = k + 1;
    g = min(k,a - 1);
    x += g;
    k -= g;
    x += (k / 2) * (b - a);
    k %= 2;
    x += k;
    cout<<max(ans,x);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ass 1e18
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define debug(x) cout << #x << ": " << x << endl;
#define debug2(x,y) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<< endl;
#define debug3(x,y,z) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<<" "<<#z<<" : "<<z<< endl;
using namespace std;
typedef long long int ll;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
ll arr[1000005],height[1000005],beauti[1000005],n,dp[1000005];

ll update(ll l,ll h,ll s,ll q)
{
	if(l>h)
		return 0;
	if(s<l||s>h)
		return arr[q];
	if(l==s&&h==s)
	{
		arr[q]=dp[s];
		return arr[q];
	}
	arr[q]=max(update(l,(l+h)/2,s,2*q+1),update((l+h)/2+1,h,s,2*q+2));
	return arr[q];
} 

ll query(ll s,ll e,ll l,ll h,ll q)
{
	if(l>h)
		return 0;
	if(e<l||s>h)
		return 0;
	if(l>=s&&e>=h)
		return arr[q];
	ll a=max(query(s,e,l,(l+h)/2,2*q+1),query(s,e,(l+h)/2+1,h,2*q+2));
	return a;	
}

int main()
{
	boost
	ll i,maxi=0;
	cin>>n;
	for(i=1;i<=n;i++)
		cin>>height[i];
	for(i=1;i<=n;i++)
		cin>>beauti[i];
	dp[height[1]]=beauti[1];
	update(1,n,height[1],0);
	for(i=2;i<=n;i++)
	{
		dp[height[i]]=beauti[i]+query(1,height[i]-1,1,n,0);
		update(1,n,height[i],0);
	}
	for(i=1;i<=n;i++)
		maxi=max(maxi,dp[i]);
	cout<<maxi;
	return 0;
}

Measured memory_bytes: 16128
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> bou(N);
    for (int i = 0; i < N; i++) {
      cin >> bou.at(i);
    }
  std::sort(bou.begin(), bou.end(), std::greater<int>() );
  int M = 0;
  for (int i=0; i<K; i++){
    M = M + bou.at(i);
  }
  cout << M << endl;
}

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

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();

        if (s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
#include <stdio.h>

int main(void) {
    int a,b,c,d;
    signed long long x1, x2, x3, x4;
    long long ans;

    scanf("%d %d %d %d", &a, &b, &c, &d);
    // printf("%d %d %d %d\n", a, b, c, d);
    x1 = (long long)a * c;
    x2 = (long long)a * d;
    x3 = (long long)b * c;
    x4 = (long long)b * d;

    // printf("%lld %lld %lld %lld\n", x1,x2,x3,x4);
    ans = x1;
    if ( ans < x2 ) {
        ans = x2;
    } 
    if ( ans < x3 ) {
        ans = x3;
    } 
    if ( ans < x4 ) {
        ans = x4;
    } 
    printf("%lld\n", ans);
}

Measured memory_bytes: 1732
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = getInt(sc);
		String s = getString(sc);
		if (a < 3200) {
			s = "red";
		}

		System.out.println(s);
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}
}


Measured memory_bytes: 21844
def prime(n): #n以下の素数の入ったリストを返す
    lst = [2]
    for i in range(3, n+1):
        flag = True
        for j in lst:
            if i % j == 0:
                flag = False
                break
        if flag:
            lst.append(i)
    return lst
N = int(input())
primes = prime(55555)
ans = []
cnt = 0
for p in primes:
    if p % 5 == 1:
        ans.append(p)
        cnt += 1
        if cnt == N:
            break
print(*ans)

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;

public class Program
{
	public static void Main(String[] args) {
        	var a = new List<int>();
			foreach(var item in Console.ReadLine().Split(' ')) {
				a.Add(Convert.ToInt32(item));
			}
          	var mylst = new List<int>();
			foreach(var item in Console.ReadLine().Split(' ')) {
				mylst.Add(Convert.ToInt32(item));
			}
            mylst.Sort();
            int ctr = 0, sum = 0;
            foreach(var item in mylst) {
            	if(ctr < a[1])
                	sum += item;
                else
                	break;
                ctr++;
            }
            Console.WriteLine(sum);
        }
}

Measured memory_bytes: 28164
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

void foreach_permutation(int n, std::function<void(int *)> f) {
    int indexes[n];
    for (int i = 0; i < n; i++) indexes[i] = i+1;
    do {
        f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
}

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


typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
    /* Credits: Thomas Draper */
    if ((first == last) || (first == k) || (last == k))
        return false;
    Iterator itr1 = first;
    Iterator itr2 = last;
    ++itr1;
    if (last == itr1)
        return false;
    itr1 = last;
    --itr1;
    itr1 = k;
    --itr2;
    while (first != itr1)
    {
        if (*--itr1 < *itr2)
        {
            Iterator j = k;
            while (!(*itr1 < *j)) ++j;
            iter_swap(itr1,j);
            ++itr1;
            ++j;
            itr2 = k;
            rotate(itr1,j,last);
            while (last != j)
            {
                ++j;
                ++itr2;
            }
            rotate(k,itr2,last);
            return true;
        }
    }
    rotate(first,k,last);
    return false;
}

int main() {
  int N,K;
  cin >> N >> K;
  int d[K];
  int A[K][N];
  int snuke[N];
    for(int i=0;i<N;i++){
        snuke[i] = 0;
    }
  for(int i=0;i<K;i++){
      cin >> d[i];
      for(int j=0;j<d[i];j++){
          cin >> A[i][j];
          snuke[A[i][j]-1]++;
      }
  }
  int ans = 0;
  for(int i=0;i<N;i++){
      if(snuke[i]==0){
          ans++;
      }
  }
  cout << ans << endl;

}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
	lli dp[3000][3000][2];
		lli arr[3000];
lli solve(lli low,lli high,lli mov){
	if(low>high)
	return 0;
	if(dp[low][high][mov]!=0)
	return dp[low][high][mov];
	if(low==high){
		if(mov==0)
	return dp[low][high][mov]=arr[low];
	else
	return dp[low][high][mov]=-arr[low];
	}
	if(mov==0)
	dp[low][high][mov]=max(arr[low]+solve(low+1,high,1-mov),arr[high]+solve(low,high-1,1-mov));
	else
	dp[low][high][mov]=min(-arr[low]+solve(low+1,high,1-mov),-arr[high]+solve(low,high-1,1-mov));
	return dp[low][high][mov];
}
int main(){
	lli n;
	cin>>n;
	for(lli i=0;i<n;i++)
	cin>>arr[i];
	for(lli i=0;i<n;i++){
		for(lli j=0;j<n;j++){
			dp[i][j][0]=0;
			dp[i][j][1]=0;
		}
	}
	solve(0,n-1,0);
//	for(lli i=0;i<n;i++){
//		for(lli j=0;j<n;j++){
//			cout<<dp[i][j][0]<<" "<<dp[i][j][1]<<"     ";
//		}
//		cout<<"\n";
//	}
	cout<<dp[0][n-1][0];
	return 0;
}


Measured memory_bytes: 141056
#if defined(__GNUC__)
#include <bits/stdc++.h>
#define __int32 __int32_t
// __GNUC__
#else
#include "bits/stdc++.h"
#endif
using namespace std;

#define int long long

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); ++(i))
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); ++(i))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) std::sort(ALL(x))
#define RSORT(x, T) std::sort(ALL(x), greater<T>())
#define REVERCE(x) std::reverce(ALL(x))
#define ACM(x, y) std::accumulate(ALL(x), y)

#define INT_POW(x, y) [](int a, int b) -> int {int c = a; REP(i, b - 1){c *= a;} return c;}(x, y)
#define INT_POWM(x, y, m) [](int a, int b, int m) -> int {int c = a; REP(i, b - 1){c *= a; c %= m;} return c;}(x, y, m)

itn main() {
	std::ios::sync_with_stdio(false);

	int n;

	cin >> n;

	vector<int> a(n);

	REP(i, n) {
		cin >> a[i];
	}

	SORT(a);

	a.erase(unique(ALL(a)), a.end());

	if (n == a.size()) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}

	return 0;
}


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

int main() {
	int N,n[3];
	cin >> N;
	for (int i = 0; i < N; i++) {
		for (int m = 0; m < 3; m++) {
			cin >> n[m];
		}
		sort(n, n + 3);
		if (n[2] * n[2] == n[1] * n[1] + n[0] * n[0]) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

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

#define int long long
#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
int powmod(int a,int l, int md){a%=md; int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
int invmod(int a, int md){return powmod(a,md-2,md);}
typedef long long ll; typedef unsigned long long ull; typedef long double ld;
typedef vector<int> vi; typedef pair<int, int> ii; typedef vector< ii > vii;
#define pb push_back
int __set(int b, int i) {return b|(1LL<<i);} //set ith bit
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1LL<<i);} //returns 0 if ith bit is 0
int mulmod(int a, int b, int md) {return (((a%md)*(b%md))%md+md)%md;}
int addmod(int a, int b, int md) {return ((a%md+b%md)%md+md)%md;}
int submod(int a, int b, int md) {return (((a%md-b%md)%md)+md)%md;}
int divmod(int a, int b, int md) {return mulmod(a, powmod(b, md-2, md), md);} //if md is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int MOD = 998244353; 

int n,m;
vector<vi> g(100010);
int seen[100010];

void dfs(int u) {
	seen[u]=1;
	for(int v: g[u]) {
		if(!seen[v])
			dfs(v);
	}
}
signed main(void)
{
	IOS;
	cin>>n>>m;
	for(int i = 0; i < m; i++) {
		int u,v; cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
	int ans=0;
	for(int i = 0; i < n; i++) {
		if(!seen[i]) {
			dfs(i);
			ans++;
		}
	}
	ans--;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10576
/*input

*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int main()
{
	IOS;
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<(a-c)*(b-d);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int sa1=abs(a-b),sa2=abs(b-c);
    if(sa1<=d&&sa2<=d||abs(a-c)<=d)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

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

typedef long long int ll;

int main(){

  int n;
  string s;
  cin >> n >> s;
  for (int i = 0; i < s.size(); ++i) {
    cout << char('A'+(s[i]-'A'+n)%26);
  }
  cout << endl;

}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n, k, q;
  cin >> n >> k >> q;
  vi32 ans(n, k - q);
  rep(i, q) {
    int a;
    cin >> a;
    a--;
    ans[a]++;
  }
  rep(i, n) {
    if (ans[i] > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


Measured memory_bytes: 1024
#include<iostream>
#include<queue>

using namespace std;

int main(){
  
  int K;
  cin >> K;
  queue<long> Q;
  for(int i=1 ; i != 10;i++){ Q.push(i);};
  
  long curr = 0;
  int cnt = 0;
  
  while(cnt < K){
    curr = Q.front();
    if( curr % 10 != 0 ){
      Q.push(10 * curr + (curr % 10 ) -1 ); 
    }
    
    Q.push(10* curr + ( curr % 10));
    
    
    if( curr % 10 != 9){
      Q.push(10*curr +( curr % 10) + 1);
    }
    
    
    
    Q.pop();
    cnt++;
  }
  
  
  cout << curr;
  

  
  
}
  
  
  
  
  
  
  



Measured memory_bytes: 1792
from math import ceil
N = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
li = [a, b, c, d, e]
#exist = [N, 0, 0, 0, 0, 0]
cnt = []
for i in range(5):
    cnt.append(ceil(N / li[i]))
print(max(cnt)+4)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
 
int main() {

    int a,b,c;
    cin>>a>>b>>c;
    
    int ans=c-(a-b);
    if(ans<0)   ans=0;
    cout<<ans<<endl;

 return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

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

    int cnt10k = -1, cnt5k = -1, cnt1k = -1;

    for (int i = 0; i <= N; i++) {
        for(int j = 0; i + j <= N; j++) {
            int k = N - i - j;
            int sum = 10000 * i + 5000 * j + 1000 * k;

            if (sum == Y) {
                cnt10k = i;
                cnt5k = j;
                cnt1k = k;
            }
        }
    }

    printf("%d %d %d\n", cnt10k, cnt5k, cnt1k);
    return 0;
}

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

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

const int INF = 1e9 + 7;

using namespace std;

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

  string s;
  cin >> s;

  if (s[0] == 'S')
    cout << "Cloudy" << endl;
  else if (s[0] == 'C')
    cout << "Rainy" << endl;
  else
    cout << "Sunny" << endl;

	return 0;
}


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

int main () {
  int x,y;
  int n;
  vector<vector<int> > v;

  for(n = 0; n < 3000; n++){
    cin >> x >> y;

    if(x > y)
      v.push_back({y,x});
    else
      v.push_back({x,y});

    if((x||y) == 0)
      break;
  }

  for(int m = 0; m < n; m++){
    cout << v[m][0] << " " << v[m][1] << endl;
  }

  return 0;
}



Measured memory_bytes: 3216
#include <iostream>
using namespace std;
const int MAX = 100;

void Print(int* A, int N) {
  for (int i = 0; i < N - 1; i++)
    cout << A[i] << " ";
  cout << A[N - 1] << endl;
}

int SelectionSort(int* A, int N) {
  int num_swap = 0;
  for (int i = 0; i < N; i++) {
    int minj = i;
    for (int j = i; j < N; j++) {
      if (A[j] < A[minj])
        minj = j;
    }
    if (i != minj) {
      swap(A[i], A[minj]);
      num_swap++;
    }
  }
  return num_swap;
}

int main() {
  int N, A[MAX];
  cin >> N;
  for (int i = 0; i < N; i++)
    cin >> A[i];

  int num_swap = SelectionSort(A, N);
  Print(A, N);
  cout << num_swap << endl;

  return 0;
}

Measured memory_bytes: 3080
include Math
x,y=0,0
th=90
while true
    
    r,angle=gets.chomp.split(",").map(&:to_i)
    break if (r==0) && (angle==0)
    x+=r*cos(th/180.0*PI)
    y+=r*sin(th/180.0*PI)
    th-=angle
end
puts x.to_i,y.to_i

Measured memory_bytes: 6172
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a + b + 1 >= c) {
            System.out.println(b + c);
        } else {
            System.out.println(b + (a + b + 1));
        }
    }
}

Measured memory_bytes: 21844
PRIME = 10 ** 9 + 7

n = int(input())
bp1 = [0 for i in range(n + 1)]
bp0 = [0 for i in range(n + 1)]

bp1[1] = 2
bp0[1] = 8

for i in range(2, n + 1):
  bp0[i] = (bp0[i - 1] * 8) % PRIME
  bp1[i] = (bp1[i - 1] * 9 + bp0[i - 1] * 2) % PRIME

ans = pow(10, n, PRIME) + (PRIME - bp0[n]) + (PRIME - bp1[n])
print(ans % PRIME)

Measured memory_bytes: 88020
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL << 60;

int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

uintmax_t combination(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int modPow(long long a, long long n, long long p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  long long t = modPow(a, n / 2, p);
  return (t * t) % p;
}
int main(){
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    ll ans;
    if(a+b < k){
        ans = 2*a - k + b;
    }
    else if(a < k && k <= a+b){
        ans = a;
    }
    else ans = k;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    int A,B,C;cin >> A >> B >> C;
    int ans = 0;
    while(B >= A && ans < C){
        ans++;
        B -= A;
    }
    cout << ans << endl;
}

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

#define int long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (int)(1000000007)
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 9999999999999999
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 10005
#define mxnn 2000005
string s;
int n,d;
int dp[mxn][105][2];
int func(int ind,int sum,int tight){
if(ind ==n) return (sum%d == 0 );
if(dp[ind][sum][tight] != -1) return dp[ind][sum][tight];
int start = 0;
int en = (tight ? s[ind]-'0': 9);
int res = 0;
int new_tight = 0;
for(int i = start;i<=en;i++){
    int x = (sum+i)%d;
    if(tight && i==en) new_tight = 1;
    res = (res+func(ind+1,x,new_tight))%mod;
}
return dp[ind][sum][tight] = res;
}
int32_t main(){
sp;
cin >>s;
n = s.size();
cin >>d;
memset(dp,-1,sizeof dp);
cout<<(func(0,0,1)-1+mod)%mod;
return 0;
}


Measured memory_bytes: 17664
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            c = 0
            for x in range(-1, 2):
                for y in range(-1, 2):
                    if x == 0 and y == 0:
                        continue
                    else:
                        if 0 <= i+y and 0 <= j+x and i+y < h and j+x < w:
                            if s[i+y][j+x] == "#":
                                c += 1
            s[i][j] = str(c)
for a in range(h):
    print("".join(s[a]))

Measured memory_bytes: 9228
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;




namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int l = s.Length;
            long N = long.Parse(s);

            int d = (int)Math.Log10(N);
            d = (int)Math.Pow(2, d);

            long ans = N;
            for (int i = 1; i < d; i++)
            {
                ans += calc(N, i, d);
            }

            Console.WriteLine(ans);
        }

        static long calc(long N, int div, int maxDigit)
        {
            long[] tmp = new long[10];

            int divInd = 0;
            long v = 10;

            while(div != 0)
            {
                if (1 == (div & 1))
                {
                    tmp[divInd] = N % v;
                    divInd++;
                    N /= v;
                    v = 10;
                }
                else
                {
                    v *= 10;
                }

                div >>= 1;
            }

            long ans = N;
            for (int i = 0; i < tmp.Length; i++)
            {
                ans += tmp[i];
            }

            return ans;
        }
    }
}


Measured memory_bytes: 13140
N,X = map(int,input().split())
list_x = list(map(int,input().split()))

'''考え方
都市の位置をソートする
距離を全て計算
距離の最大公約数を計算
'''

if len(list_x) == 1:
  ans = abs(X-list_x[0])
  print(ans)
  exit()

list_x.sort()
list_dist = []
for i,city in enumerate(list_x):
  if (i == len(list_x) - 1):
    continue
  
  list_dist.append(list_x[i+1] - list_x[i])

## 初期位置と年の間の距離も追加する
## 一番小さい都市、大きい都市のいずれか
_ = min(abs(X-list_x[0]),abs(X-list_x[-1]))
list_dist.append(_)

## 上記で求めたリストから最大公約数を求める
import fractions
ans = list_dist[0]
len_list_dist = len(list_dist)

for i in range(1, len_list_dist):
    ans = fractions.gcd(ans, list_dist[i])

print(ans)

Measured memory_bytes: 14124
#include <stdio.h>
int main(void) {
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a<=b && b<=c){
		printf("%d %d %d\n",a,b,c);
	}else if(b<=a && a<=c){
		printf("%d %d %d\n",b,a,c);
	}else if(a<=c && c<=b){
		printf("%d %d %d\n",a,c,b);
	}else if(b<=c && c<=a){
		printf("%d %d %d\n",b,c,a);
	}else if(c<=a && a<=b){
		printf("%d %d %d\n",c,a,b);
	}else if(c<=b && b<=a){
		printf("%d %d %d\n",c,b,a);
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  ll n; cin >> n;
  map<pair<int, int>, int> mp;
  vector<pair<int, int>> edges;
  vector<vector<int>> g(n, vector<int>());
  rep(i, n-1) {
    int a, b;
    cin >> a >> b; a--, b--;
    edges.emplace_back(a, b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int k = 0;
  for (auto& v : g) {
    chmax(k, int(v.size()));
  }

  queue<pair<int, int>> que;  // ノードの番号と親と繋がる辺の色
  que.push(make_pair(0, 0));

  while (!que.empty()) {
    auto p = que.front(); que.pop();
    auto children = g[p.first];
    int color = p.second;
    for (int nv : g[p.first]) {
      int a = min(nv, p.first);
      int b = max(nv, p.first);

      if (mp.count({a, b}) != 0) continue;
      color++;
      color %= k;

      mp[{a, b}] = color;
      que.push(make_pair(nv, color));
    }
  }

  cout << k << endl;
  for (auto& p : edges) {
    cout << mp[{p.first, p.second}] + 1 << endl;
  }

  return 0;
}


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

int main() {
    int32_t n, k;
    cin >> n >> k;

    if ((n - 1) % (k - 1)) {
        cout << (n - 1) / (k - 1) + 1 << endl;
    } else {
        cout << (n - 1) / (k - 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>A(N);
  for (int i=0; i<N; i++)cin>>A[i];
  int cnt=0;
  for(int i=0; i<N; i+=2){
    if(A[i]%2==1)cnt++;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<vector<int>> vec(9, vector<int>(9));
  for (int i = 0; i < 9; i++){
    for (int j = 0; j < 9; j++){
      vec.at(i).at(j) = (i + 1) * (j + 1);
    }
  }
  
  bool ans = false;
  for (int i = 0; i < 9; i++){
    for (int j = 0; j < 9; j++){
      if(vec.at(i).at(j) == N){
        ans = true;
        break;
      }
      if(ans){
        break;
      }
    }
  }
  
  if(ans == true){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}

int main()
{
    string S,T;
    cin>>S>>T;
    T.pop_back();
    if(S==T)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int F[102][102];

void
DFS (int Y, int X, int A)
{
  if (F[Y][X] != A)
    return;

  F[Y][X] = 7;

  DFS (Y - 1, X, A);
  DFS (Y, X + 1, A);
  DFS (Y + 1, X, A);
  DFS (Y, X - 1, A);
}

int
main ()
{
  int w, h;
  int xs, ys;
  int xg, yg;
  int n;
  int c, d, x, y;

  while (true)
    {
      cin >> w >> h;
      if (w == 0 && h == 0)
	break;
      cin >> xs >> ys;
      cin >> xg >> yg;
      cin >> n;

      for (int i = 0; i < n; i++)
	{
	  cin >> c >> d >> x >> y;
	  if (d == 0)
	    {
	      for (int a = 0; a < 4; a++)
		{
		  for (int b = 0; b < 2; b++)
		    {
		      F[y + b][x + a] = c;
		    }
		}

	    }
	  else
	    {
	      for (int a = 0; a < 2; a++)
		{
		  for (int b = 0; b < 4; b++)
		    {
		      F[y + b][x + a] = c;
		    }
		}
	    }

	}


      if (F[ys][xs] == 1 || F[ys][xs] == 2 || F[ys][xs] == 3
	  || F[ys][xs] == 4 || F[ys][xs] == 5)
	{
	  DFS (ys, xs, F[ys][xs]);
	}

      if (F[yg][xg] == F[ys][xs])
	{
	  cout << "OK" << endl;
	}
      else
	{
	  cout << "NG" << endl;
	}

    /*for (int y = 0; y < h; y++)
	{
	  for (int x = 0; x < w; x++)
	    {
	      cout << F[y][x];
	    }
         cout << endl;
	}*/

    }

  return 0;
}

Measured memory_bytes: 3084
#include<stdio.h>
int main(){
  int n,i,j,cnt,ans=0;
  scanf("%d",&n);
  for(i=1;i<=n;i+=2){
    cnt=0;
    for(j=1;j<=i;j++){
      if(!(i%j))cnt++;
    }
    if(cnt==8)ans++;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
string ans;
int x,y,z;
void dfs(int a,int b,int c,string x,string y,string z)
{
	if (a==0) dfs(b,c,0,y,z,"");
	else if (c==0&&b==0)
	{
		for (int i=1;i<=a;i++)
			ans+=x;
	} else
	{
		string ra=x,rb,rc;
		for (int i=0;i<c/a;i++) ra+=z;
		rc=ra+z;
		int rrc=c%a;
		a-=(c%a);
		for (int i=0;i<b/a;i++) ra+=y;
		rb=ra+y;
		int rrb=b%a;
		a-=rrb;
		dfs(a,rrb,rrc,ra,rb,rc);
	}
}
int main()
{
	scanf("%d%d%d",&x,&y,&z);
	ans.clear();
	dfs(x,y,z,"a","b","c");
	cout << ans << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;

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

int main()
{
    int h, w;
    cin >> h >> w;
    vector<vector<char>> s(h, vector<char>(w));
    rep(i, h) rep(j, w) cin >> s[i][j];
    int memo[h][w];
    rep(i, h)
    {
        rep(j, w)
        {
            int ans = 0;
            REP(a, -1, 2)
            {
                REP(b, -1, 2)
                {
                    if (i + b >= 0 && i + b < h && j + a >= 0 && j + a < w)
                    {
                        if (s[i + b][j + a] == '#')
                            ans++;
                    }
                    else
                        continue;
                }
            }
            memo[i][j] = ans;
        }
    }
    rep(i, h)
    {
        rep(j, w)
        {
            if (s[i][j] == '#')
            {
                cout << '#';
            }
            else
                cout << memo[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int i, j, h, w;
	char matrix1[110][110]={0}, matrix2[110][110]={0};;

	scanf("%d %d", &h, &w );
	
	for(i=0; i<h; i++){
	    for(j=0; j<w; j++){
	        scanf(" %c", &matrix1[i][j] );
	        
	        
	        
	    }
	    
	    
	}
	
	for(i=0; i<w+2; i++) printf("#");
	printf("\n");
	for(i=0; i<h; i++){
	    printf("#");
	    for(j=0; j<w; j++){
	        printf("%c", matrix1[i][j]);
	       
	    }
	    printf("#");
	    printf("\n");
	    
	}
	for(i=0; i<w+2; i++) printf("#");
	
	return 0;
}

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

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

HHtoIND = [[H[i], i] for i in range(n)]
HHtoIND.sort()

INDtoHH = [0] * n
for i in range(n):
    INDtoHH[HHtoIND[i][1]] = i

class segtree:  # 最大値を求める用
    def __init__(self, n):  # sizeは最初に定めたサイズ、size2は2の累乗の値をとるサイズ(>=size)
        self.size = n
        i = 1
        while i < n:
            i *= 2
        self.tree = [0] * (2*i-1)
        self.size2 = i
        
    def update(self, i, x):  # i番目の値をxに更新(xは更新前の値より大きくなければならない)
        j = self.size2 + i - 1
        self.tree[j] = x
        while j > 0:
            j = (j-1) // 2
            self.tree[j] = max(self.tree[2*j+1], self.tree[2*j+2])
            # print(self.tree)
    
    def get(self, a, b, k=0, l=0, r=None):  # 区間[a, b)の最大値を返す
        if r == None:
            r = self.size2
        if r <= a or b <= l:
            return 0
        elif a <= l and r <= b:
            return self.tree[k]
        else:
            # print(2*k+1, 2*k+2,l, (l+r)//2,r)
            vl = self.get(a, b, 2*k+1, l, (l+r)//2)
            vr = self.get(a, b, 2*k+2, (l+r)//2, r)
            return max(vl, vr)

T = segtree(n)

for i in range(n):
    hh = INDtoHH[i]
    T.update(hh, T.get(0, hh) + A[i])

print(T.get(0, n))



Measured memory_bytes: 131644
n = int(input())
fs = list(map(int, input().split(' ')))
# 221
ans = 0
while sum(fs):
    min_val = 99999999999
    min_index = 0
    for i in range(n):
        if fs[i] and fs[i] < min_val:
            min_index = i
            min_val = fs[i]
    ans += min_val
    for l in range(min_index-1, -1, -1):
        if not fs[l]:
            break
        fs[l] -= min_val
    for r in range(min_index, n):
        if not fs[r]:
            break
        fs[r] -= min_val
print(ans)

Measured memory_bytes: 3064
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(dead_code)]
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self
            .cin
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn input<T: FromStr>(&mut self) -> T {
        self.read().unwrap()
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.input()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: usize = sc.input();
    let k: usize = sc.input();
    let arr: Vec<usize> = (0..n).map(|_| sc.input::<usize>() - 1usize).collect();

    let mut to = vec![vec![0; n]; 62];
    for i in 0..n {
        to[0][i] = arr[i];
    }
    for i in 0..60 {
        for j in 0..n {
            to[i + 1][j] = to[i][to[i][j]];
        }
    }

    let mut cur = 0;
    for j in 0..60 {
        if k >> j & 1 == 1 {
            cur = to[j][cur];
        }
    }
    println!("{}", cur + 1);
}


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

int main(){
  string x;
  stack<string>S;
  string O = "+-*/";
  while(cin >> x){
    if(S.empty()){
      S.push(x);
      continue;
    }
    if(O.find(x[0]) != string::npos){
      int b = stoi(S.top());
      S.pop();
      int a = stoi(S.top());
      S.pop();
      int c;
      switch (x[0])
      {
      case '+':
        c = a + b;
        break;
      
      case '-':
        c = a - b;
        break;
      
      case '*':
        c = a * b;
        break;
      
      case '/':
        c = a / b;
        break;
      
      default:
        break;
      }
      S.push(to_string(c));
    }else{
      S.push(x);
    }
  }
  cout << S.top() << endl;
}


Measured memory_bytes: 3272
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, k, mn = 1e+9;
  cin >> n >> k;
  int h[n];
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  sort(h, h+n, greater<int>());
  for(int i=0;i<=n-k;i++){
    mn = min(mn,h[i]-h[i+k-1]);
  }
  cout << mn << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

void pair_queue_print(priority_queue<pair<int, int>> q) {
  while (!q.empty()) {
    pair<int, int> p = q.top();
    q.pop();
    DEBUG(p.first);
    DEBUG(p.second);
  }
}

int main() {
  int n, m;
  priority_queue<int, vector<int>, greater<int>> data;
  priority_queue<pair<int, int>> queue;
  cin >> n >> m;
  REP(i, n) {
    int x;
    cin >> x;
    data.push(x);
  }

  REP(i, m) {
    int x, y;
    cin >> x >> y;
    queue.push(make_pair(y, x));
  }
  // pair_queue_print(queue);
  ll ans = 0;
  pair<int, int> p = queue.top();
  queue.pop();
  int idx = p.second;
  while (!data.empty()) {
    if (idx == 0) {
      if (queue.empty()) {
        break;
      } else {
        p = queue.top();
        queue.pop();
        idx = p.second;
      }
    }

    if (p.first > data.top()) {
      ans += p.first;
      data.pop();
      idx -= 1;
    } else {
      break;
    }
  }
  while (!data.empty()) {
    int x = data.top();
    ans += x;
    data.pop();
  }
  cout << ans << endl;
}

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

namespace _1_10_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] _readLine = Console.ReadLine().Split(' ');
            double x1 = double.Parse(_readLine[0]);
            double y1 = double.Parse(_readLine[1]);
            double x2 = double.Parse(_readLine[2]);
            double y2 = double.Parse(_readLine[3]);
            double answer = Math.Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
            Console.WriteLine(answer);
        }

    }
}



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

using namespace std;

using ll = long long;


int main() {
  int n;
  cin >> n;
  int arr[2][100];
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < n; j++) {
      cin >> arr[i][j];
    }
  }
  int dp[2][101]{};
  dp[0][0] = arr[0][0];
  for (int i = 1; i < n; i++) {
    dp[0][i] += dp[0][i - 1] + arr[0][i];
  }
  dp[1][0] += dp[0][0] + arr[1][0];
  for (int i = 1; i < 2; i++) {
    for (int j = 1; j < n; j++) {
        dp[i][j] = max({arr[i][j] + dp[i - 1][j], arr[i][j] + dp[i][j - 1], arr[i][j] + dp[i - 1][j - 1]});
    }
  }
  cout << dp[1][n - 1] << '\n';
  return 0;
}


Measured memory_bytes: 256