akhauriyash/Code-Regression huggingface dataset:
x, y = map(int,input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
 
if x in a and y in a:
  print("Yes")
elif x in b and y in b:
  print("Yes")
else:
  print("No")

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

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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

int main() {
	int s,w;
	cin >> s >> w;
	if(s>w) cout << "safe" << endl;
	else cout << "unsafe" << endl;

  return 0;
}


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

using namespace std;

int ans;
string s, pre;

int main()
{
	cin >> s;
	pre = s.substr(0, 1);
	ans = 1;
	for (int i = 1; i < s.length(); i++)
	{
		if (s.substr(i, 1) == pre)
		{
			if (i == s.length() - 1) break;
			pre = s.substr(i, 2);
			i++;
		}
		else pre = s.substr(i, 1);
		ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 644
#include <iostream>
using namespace std;
int main(){
    int N,th,h,te,i;
    cin >> N;
    th=N/1000;
    h=(N/100)%10;
    te=(N/10)%10;
    i=N%10;
    if(th==h && h==te || h==te && te==i){
        cout << "Yes";
        }
    else{
        cout << "No";
        }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<x<<endl
#define all(v) v.begin(), v.end()
using namespace std;
//型エイリアス
using vi = vector<int>;
using ll = long long;
using P = pair<int,int>;
using Mat = vector<vector<int>>;
const ll inf = 1e18;
const int N = 2e5+10;

int main(){
    string s;
    cin >> s;

    cout<<s[0]<<s.size()-2<<s[(int)s.size()-1]<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(true){
            int w=sc.nextInt();
            int h=sc.nextInt();
            if(h==0&&w==0) break;
            //int[][] s=new int[h][w];
            int n=h*w;
            ArrayList<ArrayList<Integer>> g=new ArrayList<ArrayList<Integer>>();
            for(int i=0;i<n;i++){
                g.add(new ArrayList<Integer>());
            }
            //int[] ok=new int[n];
            for(int i=0;i<2*h-1;i++){
                int m;
                if(i%2==0){
                    m=w-1;
                }else{
                    m=w;
                }
                for(int j=0;j<m;j++){
                    int aa=sc.nextInt();
                    if(aa==0){
                        int z=i/2;
                        if(i%2==0){
                            if(z*w+j>=0&&z*w+j<n&&z*w+j+1>=0&&z*w+j+1<n){
                                g.get(z*w+j).add(z*w+j+1);
                                g.get(z*w+j+1).add(z*w+j);
                            } 
                            
                        }else{
                            if(z*w+j>=0&&z*w+j<n&&(z+1)*w+j>=0&&(z+1)*w+j<n){
                                g.get(z*w+j).add((z+1)*w+j);
                                g.get((z+1)*w+j).add(z*w+j);
                            }
                        }
                    }
                }
            }
            /*for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    int now=i*w+j;
                    //G[now]=new ArrayList();
                    
                    if(s[i][j]==1){
                        ok[now]=1;
                        for(int x=-1;x<=1;x++){
                            for(int y=-1;y<=1;y++){
                                if(x==0&&y==0) continue;
                                if(i+x>=0&&i+x<h&&j+y>=0&&j+y<w){
                                    if(s[i+x][j+y]==1)g.get(now).add(w*(i+x)+j+y);
                                }
                            }
                        }
                    }
                }
            }*/
            //int ans=0;
            //System.out.println(-10000);
            int[] dist=new int[n];
            for(int i=0;i<n;i++) dist[i]=-1;
            Queue<Integer> que=new LinkedList<Integer>();
            dist[0]=0;
            que.add(0);
            while(!que.isEmpty()){
                int v=que.poll();
                for(int nv:g.get(v)){
                    if(nv>=0&&nv<n&&dist[nv]==-1){
                        dist[nv]=dist[v]+1;
                        que.add(nv);
                    }
                }
            }
            //if(dist[n-1]==-1) dist[n-1]=0;
            System.out.println(dist[n-1]+1);
        }
    }
}


Measured memory_bytes: 71832
#include <stdio.h>
#define N 200000
int parent(int);
int left(int);
int right(int);

int main(){
  int n,i,pk,lk,rk,k[N];


  for(i=1;i<=N;i++){
    k[i]=0;
  }
  
  scanf("%d",&n);

 
  for(i=1;i<=n;i++){
    scanf("%d",&k[i]);
  }

  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,k[i]);
    pk=parent(i);
    lk=left(i);
    rk=right(i);
    if(i!=1){
      printf("parent key = %d, ",k[pk]);
    }
    if(lk<=n){
      printf("left key = %d, ",k[lk]);
    }
    if(rk<=n){
      printf("right key = %d, ",k[rk]);
    }
    printf("\n");
  }
    
    
  return 0;
}

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

Measured memory_bytes: 1380
#include<cstdio>
#include<algorithm>
using namespace std;

int a[3];

int main()
{
	for(int i=0;i<3;i++)
		scanf("%d",&a[i]);
	sort(a,a+3);
	printf("%d\n",a[2]*10+a[1]+a[0]);
	return 0;
}

Measured memory_bytes: 128
/**
DufauX-XuafuD
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define reset(x) memset(x,-1,sizeof(x))
#define CheckBit(a,b) (a&(1ll<<b))
#define SetBit(a,b) a=(a|(1ll<<b))
#define UnSetBit(a,b) a=(a&(~(1ll<<b)))
#define maxx 10000006
#define PI 2*acos(0.0)
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;
//bitset<maxx/2>vis;
//bitset<maxx>pr;
//int mobi[maxx+10];
//vector<ll>prime;
//void sieve(){
//    ll x=maxx/2, y=sqrt(maxx)/2;
//    for(ll i=1;i<=y;i++){
//        if(vis[i]==0){
//            for(ll j=(i*(i+1)*2);j<x;j+=(2*i)+1)
//                vis[j]=1;
//        }
//    }
//    prime.push_back(2);
//    for(ll i=3;i<maxx;i+=2)
//        if(vis[i/2]==0)
//        prime.push_back(i);
//}
//void generate_mobius()
//{
//    for(int i=0;i<maxx;i++)mobi[i]=1;
//    for(int i=2;i<maxx;i++){
//        if(!pr[i]){
//            mobi[i]*=-1;
//            for(int j=i+i;j<maxx;j+=i){
//                pr[j]=1;
//                mobi[j]*=(j%(i*i)?-1:0);
//            }
//        }
//    }
//}
//bool isprime(ll a)
//{
//    if(a==1)return false;
//    if(a==2)return true;
//    if(a%2==0)return false;
//    for(ll i=0;i<prime.size() && prime[i]*prime[i]<=a;i++)
//        if(a%prime[i]==0)return false;
//    return true;
//}
/* Calculate ( a*b ) %c */
inline ll mulmod(ll a, ll b, ll c) {
    ll ret = 0 , cur = a % c ;
    while(b) { if(b%2) ret=(ret+cur)%c; cur=(cur<<1)%c; b=b>>1; }
    return ret%c;
}
//Calculate (b^p)%m || modular inverse: b^-1 = bigmod(b, m-2, m)
inline ll bigmod(ll b, ll p, ll m){
    ll ret = 1, cur = b % m;
    while(p) { if(p&1) ret=(ret*cur)%m; cur=(cur*cur)%m; p=p>>1; }
    return ret;
}
inline ll modulo(ll a,ll b,ll c) { //Same as big mod, use for numbers over 1e10
    ll ret = 1 , cur = a%c ;
    while(b) { if(b%2) ret=mulmod(ret,cur,c); cur=mulmod(cur,cur,c); b=b>>1; }
    return ret%c ;
}
inline ll power(ll b, ll p){
    ll ret = 1, cur = b;
    while(p) { if(p&1) ret=(ret*cur); cur=(cur*cur); p=p>>1; }
    return ret;
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
ll gcd(ll a,ll b)
{
    return __gcd(a,b);
}
ll counting(ll x,ll k)
{
    ll count1=0;
    for(int i=0;i<=k;i++){
        if(x-i<=k && x-i>=0){
            count1++;
        }
    }
    return count1;
}
void Dufaux()
{
    ll k,s,ans=0;
    cin>>k>>s;
    for(int i=0;i<=k;i++){
        if(s-i>=0)
            ans+=counting(s-i,k);
    }
    cout<<ans<<endl;
}
int main()
{
    FastIO;
	///sieve();
	///generate_mobius();
	int test=1;
	while(test--){
        Dufaux();
	}
	return 0;
}






Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

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

int main(){
    ll a, b, c, d, ans = 0;
    cin >> a >> b >> c >> d;
    ll x = b / c - (a - 1) / c;
    ll y = b / d - (a - 1) / d;
    ll l = c * d / gcd(c, d);
    ll z = b / (l) - (a - 1) / (l);
    ans = (b - a + 1) - (x + y - z);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import math
a, b, h, m = list(map(int, input().split()))

needle = [h * 30 + m * 0.5, m * 6]
angle = max(needle) - min(needle) 
if angle > 180.0:
  angle = 360 - angle 
c2 = math.pow(a, 2) + math.pow(b, 2) - 2 * a * b * math.cos(math.radians(angle))
print('{:.11f}'.format(math.sqrt(c2)))


Measured memory_bytes: 9444
#ifdef OJ_MISC_OFFLINE

#include "prolog.h"

#else
#define LOG
#define PRINT
#define LCERR
#include <iostream>
auto optimize_cpp_stdio = []() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::setvbuf(stdout, nullptr, _IOFBF, BUFSIZ);
    return 0;
}();
#endif

#include <algorithm>
#include <array>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>

namespace {

using namespace std;

const int MOD = 1000000007;

class Solution {
public:
    int digits_parade(const string& s) {
        vector<int> d(13);
        vector<int> dnext(13);
        d[0] = 1;
        int pow_mod_13 = 1;
        for (int p = s.size() - 1; p >= 0; --p) {
            for (int m = 0; m < 13; ++m) {
                dnext[m] = 0;
                for (int digit = 0; digit <= 9; ++digit) {
                    if (s[p] != '?' && s[p] - '0' != digit) {
                        continue;
                    }
//                    for (int l = 0; l < 13; ++l) {
//                        int cur_mod = ((digit * pow_mod_13) % 13 + l) % 13;
//                        if (cur_mod == m) {
//                            dnext[m] += d[l];
//                            dnext[m] %= MOD;
//                        }
//                    }
                    int digit_mod = (digit * pow_mod_13) % 13;
                    int target_mod = m < digit_mod ? m + 13 : m;
                    dnext[m] += d[target_mod - digit_mod];
                    dnext[m] %= MOD;
                }
            }
            pow_mod_13 *= 10;
            pow_mod_13 %= 13;
            swap(d, dnext);
        }
        return d[5];
    }

private:

};

int solve() {
    Solution solution;
    // handle IO here
    string S;
    cin >> S;
    cout << solution.digits_parade(S) << '\n';
    return 0;
}

} // anonymous namespace

#ifdef OJ_MISC_OFFLINE

#include "epilog.h"

#else

int main() {
    return solve();
}

#endif


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

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

  			long long int n,sum=0;
  		cin >> n;
  		long long int x = n * (n+1)/2;
  		long long int a =1,t=3;
  		while(t<=n){
  			
  			sum = sum + t;

  			a++;
  			if(a%5==0){
  				a++;
  			}
  			t = 3*a;
  		}
  		t =5;
  		a = 1;
  		while(t<=n){
  			sum = sum + t;
  			a++;
  			t = 5*a;
  		}

  		cout << x-sum;
  		}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double R;
    cin >> R;
    printf("%.12lf\n", 2 * R * PI);
}


Measured memory_bytes: 3804
def resolve():
    MOD = 1000000007
    N = int(input())
    A = list(map(int, input().split()))

    C = [0]*(N+1)
    C[0] = 3
    ans = 1
    for i in range(N):
        a = A[i]
        ans *= C[a]
        ans %= MOD
        C[a] -= 1
        C[a+1] += 1

    print(ans)
    
if __name__ == "__main__":
    resolve()

Measured memory_bytes: 14056
from math import sqrt, radians, sin, cos

class Triangle (object):
    def __init__(self, a, b, C):
        self.a = a
        self.b = b
        self.C = radians(C)

    def getArea(self):
        return self.a * self.getHeight() / 2

    def getPerimeter(self):
        return self.a + self.b + sqrt(self.a ** 2 - 2 * self.a * self.b * cos(self.C) + self.b ** 2)

    def getHeight(self):
        return self.b * sin(self.C)

tri = Triangle(*[int(e) for e in input().split()])
print(tri.getArea())
print(tri.getPerimeter())
print(tri.getHeight())

    


Measured memory_bytes: 5716
object Main {
  def main(args: Array[String]) {
    val sc = new java.util.Scanner(System.in)
    val x, a, b = sc.nextInt

    val text =
      if (a + x < b) "dangerous"
      else if (a >= b) "delicious"
      else "safe"

      println(text)
  }
}



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

int main() {
    int a, b, c;
    cin >> a >> b;
    cout << a * b / 2 << endl;
}


Measured memory_bytes: 256
def main():
    pass
    nxt = [int(_x) for _x in input().split()]
    n = nxt[0]
    x = nxt[1]
    t = nxt[2]
    if n % x == 0:
        kai = int(n/x)
    else:
        kai = int(n/x) + 1
    print(kai*t)

    # N = int(input())


main()


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

vector<int> a[205], b[205];
int n, ans;
multiset<int> hv;

int main()
{
	scanf("%d", &n);
	for (int i = 0;i < n;i++)
	{
		int x, y; scanf("%d%d", &x, &y);
		a[x].push_back(y);
	}
	for (int i = 0;i < n;i++)
	{
		int x, y; scanf("%d%d", &x, &y);
		b[x].push_back(y);
	}
	for (int i = 0;i < 205;i++)
	{
		for (int u: b[i])
		{
			auto it = hv.lower_bound(u);
			if (it != hv.begin())
			{
				it--;
				hv.erase(it);
				ans++;
			}
		}
		for (int u: a[i]) hv.insert(u);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
s = []
ans = []
for i in range(h):
    s.append(list(input()))
    ans.append([0]*w)

for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            ans[i][j] = "#"
            continue
        for k in range(i-1, i+2):
            for l in range(j-1, j+2):
                if k >= 0 and l >= 0 and k < h and l < w:
                    if s[k][l] == "#":
                        ans[i][j] += 1
for i in range(h):
    for j in range(w):
        print(str(ans[i][j]), end = "")
    print("")


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
 
using namespace std;
using ll = long long;
using pii = pair<int, int>;
 
const int oo = 1e9 + 7;
const int mod = 1e9 + 7;
const double PI = acos(-1);
bitset<500> vis;
vector<vector<char>> mat(20, vector<char> (20));
int w,h, adj[440][440] = {}, v;

void init(){
    for (int i=0; i<=v; i++){
        for (int j=0; j<=v; j++){
            adj[i][j] = oo;
            if (i == j) adj[i][j] = 0;
        }
    }
}

int floyd(){
    for (int k=0; k<v; k++){
        for (int i=0; i<v; i++){
            for (int j=0; j<v; j++){
                adj[i][j] = min(adj[i][k] + adj[k][j], adj[i][j]);
            }
        }
    }
    int ans = 0;

    for (int i=0; i<v; i++){
        for (int j=0; j<v; j++){
            if (adj[i][j] == oo) continue;
            if (j > i) break;
            ans = max(ans, adj[i][j]);
        }
    }
    return ans;
}
 
int main (){
    char mat[20][20];
    cin >> h >> w;
    v = h*w;
    init();

    for (int i=0; i<h; i++){
        for (int j=0; j<w; j++){
            cin >> mat[i][j];
            if (i>0 and mat[i][j] == mat[i-1][j] and mat[i][j] == '.'){
                int a = (i*w)+j, b = ((i-1)*w) + j;
                adj[a][b] = 1;
                adj[b][a] = 1;
            }
            if (j>0 and mat[i][j] == mat[i][j-1] and mat[i][j] == '.'){
                int a = (i*w)+j, b = (i*w) + (j - 1);
                adj[a][b] = 1;
                adj[b][a] = 1;
            }
        }
    }

    cout << floyd() << endl;
    return 0;
}

Measured memory_bytes: 896
n, k = map(int, input().split())
h = list(map(int, input().split()))

INF = float('inf')
dp = [INF] * n
dp[0] = 0

for i in range(n - 1):
    for j in range(1, k + 1):
        if i + j >= n:
            break
        else:
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]))

print(dp[-1])

Measured memory_bytes: 55008
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
const int mod=1e9+7;
const int INF=1<<30;
const int MAX_N=100000;

int main(){
  string A,B,ans="EQUAL";
  cin >> A >> B ;
  int a=A.length();
  int b=B.length();
  if(a>b) ans="GREATER";
  else if(a<b) ans="LESS";
  else{
    rep(i,a){
      if(A[i]>B[i]){
        ans="GREATER";
        break;
      }
      else if(A[i]<B[i]){
        ans="LESS";
        break;
      }
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int mapNum=sc.nextInt();
		int point[]=new int[mapNum+2];
		point[0]=0;
		point[mapNum+1]=0;
		for(int i=1;i<mapNum+1;i++) {
			point[i]=sc.nextInt();
		}
		int distance=0;
		for(int i=0;i<mapNum+1;i++) {
			distance+=Math.abs(point[i]-point[i+1]);
	}
		for(int i=1;i<mapNum+1;i++) {
			System.out.println(distance+Math.abs(point[i-1]-point[i+1])
			-Math.abs(point[i-1]-point[i])-Math.abs(point[i]-point[i+1]));
		}
}
	}

Measured memory_bytes: 62560
n = input()
k = int(input())

dp = [[0] * (k + 2) for _ in range(2)]
dp[0][0] = 1

for d in n:
    ndp = [[0] * (k + 2) for _ in range(2)]
    for i in range(k + 1):
        ndp[1][i] += dp[1][i]
        ndp[1][i + 1] += dp[1][i] * 9
        if d == '0':
            ndp[0][i] += dp[0][i]
        else:
            ndp[1][i] += dp[0][i]
            ndp[1][i + 1] += dp[0][i] * (int(d) - 1)
            ndp[0][i + 1] += dp[0][i]
    dp = ndp
print(dp[0][k] + dp[1][k])


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

int main(void){
  int N,A;

  cin >> N;

  int odd=0;

  for ( int i = 0; i < N; i++ ){
    cin >> A;
    if ( A % 2 != 0){
      odd++;
    }
  }
  
  if ( odd % 2 == 0 ){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
from copy import deepcopy

h,w,K=map(int,input().split())
lst=[]
for i in range(h):
    c=list(input())
    lst.append(c)
ans=0
for i in range(2**(h+w)):
    nuri=[[],[]]
    count_h=0
    count_w=0
    for j in range(h+w):
        if ((i>>j)&1):
            if j<h:
                nuri[0].append(j)
                count_h+=1
            else:
                nuri[1].append(j-h)
                count_w+=1
    c_lst=deepcopy(lst)
    for j in range(count_h):
        for k in range(w):
            if c_lst[nuri[0][j]][k]=="#":
                c_lst[nuri[0][j]][k]="."
    for j in range(count_w):
        for k in range(h):
            if c_lst[k][nuri[1][j]]=="#":
                c_lst[k][nuri[1][j]]="."
    num_shapu=0
    for j in c_lst:
        for k in j:
            if k=="#":
                num_shapu+=1
    if num_shapu==K:
        ans+=1
print(ans)

Measured memory_bytes: 71932
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
signed main(){
	int n;
	cin>>n;
	cout<<(n-2)*180<<endl;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        m: usize,
        q: usize,
        abcd: [(usize,usize,i32,i32);q],
    }
    let mut val = vec![1i32; n + 1];

    println!("{:?}", dfs(&mut val, 1, m, &abcd));
}

fn dfs(buf: &mut Vec<i32>, d: usize, ub: usize, abcd: &Vec<(usize, usize, i32, i32)>) -> i32 {
    let mut sum = 0;
    if d == buf.len() {
        // println!("{:?}", buf);
        for &(a, b, c, d) in abcd {
            if buf[b] - buf[a] == c {
                sum += d;
            }
        }
    } else {
        for i in buf[d - 1] as usize..ub + 1 {
            buf[d] = i as i32;
            sum = std::cmp::max(sum, dfs(buf, d + 1, ub, abcd));
        }
    }
    sum
}


Measured memory_bytes: 2128
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <string>
#include <sstream>
#include <cstring>
#include <cmath>

using namespace std;

#ifdef DEBUG
#define LOG(args) cout << args << "\n"
#define debug(x) x
#else
#define LOG(args)
#define debug(x)
#endif

#define vi vector<int>
#define ii pair<int, int>
#define vii vector< ii >
#define vvi vector< vi >
#define mp make_pair
#define pb push_back
#define ms(x, v) memset(x, v, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define REP(x, n) for(int x = 0; x < n; x++)
#define REPV(x, v, n) for(int x = v; x < n; x++)
#define REVE(x, n) for(int x = n; x >= 0; x--)

typedef long long ll;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;
	cin >> N;
	vi vals(N + 1);
	REPV(i, 1, N + 1)
		cin >> vals[i];
	sort(vals.begin() + 1, vals.end() + 1, greater<int>());
	ll ans = vals[1];
	REPV(i, 3, N + 1)
		ans += vals[(i + 1) >> 1];
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 4004
#include <iostream>

using namespace std;

int main(){
 
  int n; 
  int p[20];
  int ans = 0;

  cin >> n;

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

  for(int i = 0; i < n - 2; i++){
    if((p[i] < p[i + 1] && p[i + 1] < p[i + 2]) || (p[i] > p[i + 1] && p[i + 1] > p[i + 2])){
      ans++;
    }
  }

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


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

using namespace std;
typedef long long ll;


const int N=1e5+100;

map<ll,ll>mp;

int main()
{
    int n;cin>>n;
    int x;
    ll ans=0;
    for(int i=1;i<=n;i++){
        cin>>x;
        ans+=mp[i-x];
        mp[i+x]++;
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int main() {

    string s, t;
    cin >> s >> t;

    if(s+t.at(t.size()-1) == t) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


    return 0;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int grid[3][3];
  REP(i, 3) REP(j, 3) { grid[i][j] = read(); }
  FOR(i, 0, 101) {
    int a[3], b[3];
    REP(j, 3) { b[j] = grid[0][j] - i; }
    a[0] = i;
    a[1] = grid[1][0] - b[0];
    a[2] = grid[2][0] - b[0];
    int cnt = 0;
    REP(j, 3) REP(k, 3) {
      if (grid[j][k] == a[j] + b[k])
        cnt++;
    }
    if (cnt == 9) {
      std::cout << "Yes" << std::endl;
      return 0;
    }
  }
  std::cout << "No" << std::endl;
}


Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
	public static void main(String arg[])
	{
		Scanner sc = new Scanner(System.in);

		while(sc.hasNext())
		{
			int n = sc.nextInt();
			if(n==0)
				return;
			int a[][] = new int[n+1][n+1];
			int sum2=0;
			int total =0;
			for(int i=0; i<n; i++)
			{
				int j=0;
				int sum1=0;

				for(j=0; j<n; j++)
				{
					a[i][j] = sc.nextInt();
					sum1+=a[i][j];		
				}
				a[i][j]=sum1;
				total+=sum1;

			}
			a[n][n]=total;
			int i=0;
			int j=0;
			while(i<n)
			{
				sum2=0;
				for(j=0; j<n; j++)
				{
					sum2+=a[j][i];
				}
				a[j][i]=sum2;
				i++;
			}
			for(i=0; i<=n; i++)
			{
				for(j=0; j<=n; j++)
				{
					System.out.printf("%5d",a[i][j]);

				}
				System.out.println();
			}
		}

	}

}

Measured memory_bytes: 12000
#include<iostream>
#include<string>
#include<cmath>
#include<map>
using namespace std;
typedef pair< int , int > Pi;
string mas[] = {"ABC","DEF","GHI"},s;
map< char , Pi > mp;
const int dy[] = { 1, 0, -1, 0}, dx[] = { 0, 1, 0 , -1};

bool rec(int now){
  if( now == s.size()) return true;
  for(int i = 0 ; i < 4 ; i++ ){
    int ny = mp[s[now-1]].first + dy[i], nx = mp[s[now-1]].second + dx[i];
    if(nx >= 0 && nx < 3 && ny >= 0 && ny < 3 && mas[ny][nx] == s[now]){
      return rec(now+1);
    }
  }
  return false;
}

int main(){
  for(int i = 0 ; i < 3 ; i++ ){
    for(int j = 0 ; j < 3 ; j++ ) mp[mas[i][j]] = Pi(i,j);
  }

  for(int i = 0 ; i < 1000 ; i++ ){
    bool FLG = true;
    cin >> s;

    //同じ文字は連続しない(いましめ
    for(int j = 1 ; j < s.size() ; j++ ){
      if(s[j-1] == s[j]){
        FLG = false;
        break;
      }
    }
    if(!FLG) continue;

    //一筆書きができる(いましめ
    if(!rec(1)) continue;

    cout << s << endl;
  }
}

Measured memory_bytes: 1188
import java.util.*;
public class Main
{
	public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		int d, n;
		n = input.nextInt();
		for (int i = 1; i <= n; i++) {
			if (i % 3 == 0)
				System.out.print(" " + i);
			else {
				d = i;
				while(d > 0) {
					if (d % 10 == 3) {
						System.out.print(" " + i);
						break;
					}
					else d /= 10;
				}
			}
		}
		System.out.println();
	}
}

Measured memory_bytes: 28740
n = int(input())
t = list(map(int, input().split()))
m = int(input())

i = 0
while i < m:
    p = list(map(int, input().split()))
    tn = t[:]
    tn[p[0] - 1] = p[1]
    total = sum(tn)
    print(str(total))
    i += 1


Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int N,x,ans;
string S;

int main(){
    cin>>N>>S;
    rep(i,S.length()){
        if(S[i]=='I')x++;
        else x--;
        ans=max(ans,x);
    }
    out(ans);
}


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

struct Node{
  int num;

  vector<int> edge_to;
  vector<int> edge_cost;

  bool done;
  int cost;
};

vector<string> splitAll(string s, string t) {
  vector<string> v;
  for (int p = 0; (p = s.find(t)) != s.npos; ) {
    v.push_back(s.substr(0, p));
    s = s.substr(p + t.size());
  }
  v.push_back(s);
  return v;
}

int dijkstra (vector<Node> g,int start,int goal){
  int d;
  g[start].cost=0;

  while(1){
    d=-1;

    for(int i=1;i<=g.size();i++){
      if( g[i].done || g[i].cost < 0 ) continue;
      if( d==-1 || g[i].cost < g[d].cost ) d=i;
    }

    if(d==-1) break;
    g[d].done=true;

    for(int i=0; i< g[d].edge_to.size(); i++){
      int to = g[d].edge_to[i];
      int cost = g[d].cost + g[d].edge_cost[i];
      if(g[to].cost < 0 || cost < g[to].cost)
	g[to].cost = cost;
    }
  }

  return g[goal].cost;
}


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

  vector<Node> graph;
  graph.reserve(n+1);
  graph.resize(n+1);

  for(int i=1; i<=n; i++){
    graph[i].num=(i+1);
    graph[i].cost=-1;
    graph[i].done=false;
  }

  string s;

  cin>>m;
  getline(cin,s);

  int a,b,c,d;
  vector<string> vv;
  vv.reserve(4);
  vv.resize(4);

  while(m--){
    getline(cin,s);
    vv = splitAll(s,",");

    a = atoi( vv[0].c_str() );
    b = atoi( vv[1].c_str() );
    c = atoi( vv[2].c_str() );
    d = atoi( vv[3].c_str() );

    graph[a].edge_to.push_back(b);
    graph[a].edge_cost.push_back(c);
    graph[b].edge_to.push_back(a);
    graph[b].edge_cost.push_back(d);

  }

  int x1,x2,y1,y2;
  getline(cin,s);
  vv = splitAll(s,",");

  x1 = atoi( vv[0].c_str() );
  x2 = atoi( vv[1].c_str() );
  y1 = atoi( vv[2].c_str() );
  y2 = atoi( vv[3].c_str() );

  vector<Node> copy;
  copy.reserve(n+1);
  copy.assign(graph.begin(),graph.end());

  int rcost = dijkstra(graph,x2,x1);
  int gcost = dijkstra(copy,x1,x2);

  cout<<y1-y2-rcost-gcost<<endl;

}

Measured memory_bytes: 0
#coding:utf-8

S = int(input())

bik_dp = [0] * 5000
bik_dp[0] = 1

def bik(n):
    kon = 1
    if bik_dp[n] != 0:
        kon = bik_dp[n]
    else:
        kon = n * bik(n-1)
        bik_dp[n] = kon
    return kon

def comb(s,t):
    if s < t:
        k = s
        s = t
        t = k
    son = bik(s) // (bik(s-t) * bik(t))
    return son

ten = S // 3

ans = 0

for i in range(1,3000):
    nn = bik(i)

for i in range(1,ten + 1):
    ans += comb(S - 2 * i - 1,i - 1) % (10 ** 9 + 7)
    ans = ans % (10 ** 9 + 7)

print("{}".format(ans))

Measured memory_bytes: 14824
import bisect
max = 100000
m6 = [1]
m9 = [1]
i = 6
while i<max:
    m6.append(i)
    i*=6
i = 9
while i<max:
    m9.append(i)
    i*=9

def res(n):
    if n < 6:
        return n
    else:
        i6 = bisect.bisect(m6,n)-1
        i9 = bisect.bisect(m9,n)-1
        r = 1+min(res(n-m6[i6]),res(n-m9[i9]))
        return r
N = int(input())
print(res(N))

Measured memory_bytes: 3188
#include<iostream>
#include<iomanip>
#include<algorithm>

using namespace std;

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

int main(){
    int N,L;
    cin >> N >> L;
    string S[N];
    REP(i,N){
        cin >> S[i];
    }
    sort(S,S+N);
    REP(i,N){
        cout << S[i];
    }
}

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

int main(){
  char A, B, C;
  int D;
  string s="";
  cin >> A >> B >>C;
//  cout << A << endl;
//  cout << B << endl;
//  cout << C << endl;

  s+=A;
  s+=B;
  s+=C;

//  cout << s << endl;

  D = stoi(s);

//  cout << D << endl;
  if(D%4==0){
    cout << "YES"<<endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define FORE(i,a,b) for (int i=(int)(a);i<=(int)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define REPE(i,n) FOR(i,0,n)

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

int main() {
  int N,M,X,Y;cin>>N>>M>>X>>Y;
  vector<int> XS,YS;
  REP(i,N) {
    int x;cin>>x;
    XS.push_back(x);
  }
  REP(i,M) {
    int y;cin>>y;
    YS.push_back(y);
  }

  FOR(i,X+1,Y+1) {
    bool checker = true;
    REP(n,N) {
      if (XS[n] >= i) {
        checker = false;
      }
    }
    REP(m,M) {
      if (YS[m] < i) {
        checker = false;
      }
    }
    if (checker) {
      OUT("No War");
      return 0;
    }
  }
  OUT("War");

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		String op = sc.next();
		int B = sc.nextInt();
		
		if(op.equals("+")){
			System.out.println( A + B );
		}else if(op.equals("-")){
			System.out.print( A - B );
		}
	}
}


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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

template <typename A, typename B>
string to_string(pair<A, B> p){
    return "(" + to_string(p.fi) + ", " + to_string(p.se) + ")";
}

template <typename T>
string to_string(T v){
    string s = "{";
    bool first = true;
    for(const auto & x : v){
        if(!first) s += ", ";
        first = false;
        s += to_string(x);
    }
    return s + "}";
}

void debug_out(){ cerr << endl;}
template <typename First, typename... Next>
void debug_out(First F, Next... N){
    cerr << " " << to_string(F);
    debug_out(N...);
}

#ifdef LOCAL
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 1
#endif

const int N = 15;
vector<pii> t[N];

int main(){
    fcin;

    int n;
    cin >> n;

    for(int i = 0; i < n; i++){
        int a;  cin >> a;
        while(a--){
            int x, y;
            cin >> x >> y;
            x--;
            t[i].eb(x, y);
        }
    }

    int ans = 0;
    for(int i = 0; i < (1 << n); i++){
        vector<int> hon(n, 0);
        for(int j = 0; j < n; j++) hon[j] = ((i >> j) & 1);

        // 01  
        bool ok = true;
        for(int i = 0; i < n; i++){
            for(pii p : t[i]){
                if(hon[i] and p.se != hon[p.fi]) ok = false;
            }
        }

        if(ok) ans = max(ans, __builtin_popcount(i));
    }

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



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

using namespace std;

 int main(int argc, char const *argv[])
{
	string s1, s2,s3;

	cin>>s1>>s2>>s3;

	cout<<(char)toupper(s1[0])<<(char)toupper(s2[0])<<(char)toupper(s3[0])<<endl;
	return 0;
}


Measured memory_bytes: 256
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    inf=10**20
    n,k=map(int,readline().split())
    co=[list(map(int,readline().split())) for _ in range(n)]
    
    co.sort()
    
    x_range=[]
    for i in range(n-1):
        for j in range(i+1,n):
            x_range.append((co[i][0],co[j][0]))

    co.sort(key=lambda x:x[1])
    ans=inf
    for x in x_range:
        x_min=x[0]
        x_max=x[1]
        y_min=0
        y_max=0
        for under in range(n):
            cnt=0
            for i in range(under,n):
                if x_min<=co[i][0]<=x_max:
                    if cnt==0:
                        y_min=co[i][1]
                        cnt+=1
                    else:
                        y_max=co[i][1]
                        cnt+=1
                if cnt==k:
                    break
            if cnt==k:
                ans=min(ans,(x_max-x_min)*(y_max-y_min))

    print(ans)

if __name__=="__main__":
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector< vector<long long>>
#define mi map<int,int>
#define pi pair<int,int>

#define Fori(i,a,b) for(int i=a; i<b; i++)
#define Ford(i, a, b) for(int i=a; i>=b; i--)

#define pb push_back
#define mp make_pair

#define read(a, n) for(int i=0; i<n; i++) cin >> a[i];
#define print(x) cout << "X: == " << x << endl;
#define printMap(a) for(auto it=a.begin() ; it!= a.end() ; it++) {cout << it->first << "  " << it->second << endl; }
#define printVector(a) for(auto it = a.begin() ; it!= a.end() ;it++) {cout << *it << endl;}

#define MOD 1000000007
using namespace std;
int main() {
    IOS
    int n;
    cin >> n;
    int cnt = 0, ans = 0;
    Fori(i, 0, n) {
        int a, b;
        cin >> a >> b;
        if(a == b) cnt++;
        else cnt = 0;
        if(cnt >= 3) ans = 1;
    }
    if(ans) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 3660
K,S = map(int, input().split())

ans = 0
for i in range(K+1):
	if i > S:
		break
	if i + 2*K < S:
		continue
	for j in range(K+1):
		t = S - i - j
		if 0 <= t and t <= K:
			ans += 1 
print(ans)

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

int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    string root = "";
    int dx = tx - sx;
    int dy = ty - sy;
    for (int i = 0; i < dy; i++)
    {
        root += "U";
    }
    for (int i = 0; i < dx; i++)
    {
        root += "R";
    }
    for (int i = 0; i < dy; i++)
    {
        root += "D";
    }
    for (int i = 0; i < dx; i++)
    {
        root += "L";
    }
    root += "L";
    for (int i = 0; i < (dy + 1); i++)
    {
        root += "U";
    }
    for (int i = 0; i < (dx + 1); i++)
    {
        root += "R";
    }
    root += "DR";
    for (int i = 0; i < (dy + 1); i++)
    {
        root += "D";
    }
    for (int i = 0; i < (dx + 1); i++)
    {
        root += "L";
    }
    root += "U";
    cout << root << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
#include<string.h>
#include<set>
#include<functional>
using namespace std;

#define INF 1<<21
#define MOD 1000000007

char field[25][25];

int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
int W, H;
int ans;

void dfs(int x, int y) {
  field[y][x] = '#';
  ans++;
  for (int i = 0; i < 4; i++) {
	int nx = x + dx[i], ny = y + dy[i];
	if (1 <= nx&&nx <= W && 1 <= ny&&ny <= H&&field[ny][nx] == '.')dfs(nx, ny);
  }
  return;
}

int main() {
  while (1) {
	cin >> W >> H;
	if (H == 0 && W == 0)return 0;
	int sx, sy;
	memset(field, 0, sizeof(field));
	ans = 0;
	for (int i = 1; i <= H; i++) {
	  for (int j = 1; j <= W; j++) {
		cin >> field[i][j];
		if (field[i][j] == '@') {
		  sy = i;
		  sx = j;
		}
	  }
	}
	dfs(sx, sy);
	cout << ans << endl;
  }

}

Measured memory_bytes: 3136
#include <iostream>
#include <vector>
using namespace std;
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;

int N;
long long ma, mb;
vector<long long> a, b, c;

long long dp[51][510][510];

int main() {
    cin >> N >> ma >> mb;
    a.resize(N); b.resize(N); c.resize(N);
    for (int i = 0; i < N; ++i) cin >> a[i] >> b[i] >> c[i];
    
    for (int i = 0; i < 51; ++i) for (int j = 0; j < 510; ++j) for (int k = 0; k < 510; ++k) dp[i][j][k] = INF;
    dp[0][0][0] = 0;
    for (int i = 0; i < N; ++i) {
        for (int wa = 0; wa < 500; ++wa) {
            for (int wb = 0; wb < 500; ++wb) {
                if (dp[i][wa][wb] >= INF) continue;
                
                // 使わない
                chmin(dp[i+1][wa][wb], dp[i][wa][wb]);

                // 使う
                chmin(dp[i+1][wa+a[i]][wb+b[i]], dp[i][wa][wb] + c[i]);
            }
        }
    }
    long long res = INF;
    for (int wa = 1; wa < 500; ++wa) {
        for (int wb = 1; wb < 500; ++wb) {
            if (wa * mb != wb * ma) continue;
            chmin(res, dp[N][wa][wb]);
        }
    }
    if (res < INF) cout << res << endl;
    else cout << -1 << endl;
}


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

using namespace std;

#define int long long 
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int H[100000];

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

    int K, N;
    cin >> N >> K;
    for(int i = 0; i < N; ++i) cin >> H[i];
    sort(H, H + N);
    int res = INF;
    for(int i = 0; i < N - K + 1; ++i) chmin(res, H[i + K - 1] - H[i]);
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1024
#ABC096 C

h, w = map(int, input().split())
l = list(input() for i in range(h))

dx = [0, -1, 1, 0]
dy = [1, 0, 0, -1]

ok = True
for i in range(h):
    for j in range(w):
        if l[i][j] == '#':

            flg = False
            for k in range(4):
                x = j + dx[k]
                y = i + dy[k]

                if x < 0 or x >= w or y < 0 or y >= h:
                    continue

                if l[y][x] == '#':
                    flg = True
            if flg == False:
                ok = False
                break
    if ok == False:
        break

print('Yes' if ok else 'No')
        

Measured memory_bytes: 8800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s,t; cin >> s >> t;
  int k=s.size();
  for(int i=0;i<k;i++){
    if(s[i]!=t[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


struct UnionFind{
   vector<int> par;
   UnionFind(int n):par(n,-1){}
   int find(int x){
       if(par[x]<0)return x;
       return par[x]=find(par[x]);
   }
   bool unite(int x,int y){
       x=find(x);
       y=find(y);
       if(x==y)return false;
       if(par[x]>par[y]){
           par[y]+=par[x];
           par[x]=y;
       }
       else{
           par[x]+=par[y];
           par[y]=x;
       }
       return true;
   }

   bool same(int x,int y){
       return find(x)==find(y);
   }
   int size(int x){
       return -par[find(x)];
   }
};
int main(){
  	cin.tie(0);
  	ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    int a[n];
    rep(i,n)cin>>a[i];
    vector<vector<pair<int,int>>> v(n);
    vector<int> used(n);
    UnionFind uf(2*n);
    vector<int> ans(m,1e9);
    rep(i,m){
        int x,y;
        cin>>x>>y;
        --x;--y;
        v[x].push_back({y,i});
        v[y].push_back({x,i});
        if(a[x]==a[y]){
            if(used[x]&&used[y])continue;
            used[x]=used[y]=1;
            uf.unite(x,y+n);
            uf.unite(y,x+n);
            ans[i]=a[x];
        }
    }
    vector<int> ord(n);
    rep(i,n)ord[i]=i;
    sort(ord.begin(),ord.end(),[&](int x,int y){
        return a[x]<a[y];
    });
    for(auto i:ord){
        if(used[i])continue;
        for(auto p:v[i]){
            if(a[p.first]<a[i]){
                used[i]=1;
                uf.unite(p.first,i);
                uf.unite(p.first+n,i+n);
                ans[p.second]=a[i]-a[p.first];
                break;
            }
        }
        if(!used[i]){
            cout<<-1<<endl;
            return 0;
        }
    }
    string s = "";
    rep(i,n){
        if(uf.same(0,i))s += 'B';
        else {
            s += 'W';
            uf.unite(0,i+n);
            uf.unite(n,i);
        }
    }
    cout<<s<<endl;
    rep(i,m)cout<<ans[i]<<'\n';
    return 0;
}


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

const int maxi = 111111;
int a[maxi], k;

ll rem(ll val) {
    for(int i=1; i<=k; i++) {
        if(val % a[i] == 0) continue;
        else val -= val % a[i];
    }
    return val;
}

ll solveMax() {
    ll lo = 0, hi = 1e14, res = -1;
    int cnt = 60;

    while(cnt--) {
        ll mid = (lo + hi) / 2;
        if(rem(mid) == 2) res = mid;
        if(rem(mid) <= 2) lo = mid;
        else hi = mid;
    }

    return res;
}

ll solveMin() {
    ll lo = 0, hi = 1e14, res = -1;
    int cnt = 60;

    while(cnt--) {
        ll mid = (lo + hi) / 2;
        if(rem(mid) == 2) res = mid;
        if(rem(mid) < 2) lo = mid;
        else hi = mid;
    }

    return res;
}

int main() {
    cin>>k;

    for(int i=1; i <= k; i++) {
        cin>>a[i];
    }

    ll mx = solveMax(), mn = solveMin();

    if(mx == -1 || mn == -1) cout<<-1<<endl;
    else cout<<mn<<" "<<mx<<endl;
    return 0;
}


Measured memory_bytes: 640