akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	int[] num;
	int[] dice;
	int n, m;
	
	void calc(int d) {
		if (d == n) {
			int sum = 0;
			for (int i : dice)
				sum += i;
			num[sum]++;
		} else {
			for (int i = 1; i <= m; i++) {
				dice[d] = i;
				calc(d+1);
			}
		}
	}
	
	void run() {
		while (true) {
			int k;
			n = sc.nextInt(); m = sc.nextInt(); k = sc.nextInt();
			if (n == 0 && m == 0 && k == 0) break;
			
			double ans = 0;
			num = new int[n*m+1];
			dice = new int[n];
			calc(0);
			for (int i = n; i <= n*m; i++) {
				ans += num[i]/Math.pow(m, n)*Math.max(1, i-k);
			}
			
			out.println(ans);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 20516
#include<bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c;
  cin >>a >> b>> c;
  if(a >= b && b >= c || a >= c && c >= b) cout << a*10 + b + c << endl;
  else if(b >= c && c >= a || b >= a && a >= c) cout << b * 10 + a + c <<endl;
  else cout << c * 10 + a + b << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

int I[]={0,1};
int J[]={1,0};

int H,W;
char A[8][8];
int chk[8][8];

int main(){
    cin>>H>>W;
    rep(i,H) rep(j,W) cin>>A[i][j];

    queue<P> q;
    q.push(P(0,0));
    chk[0][0]=1;
    bool flag=false;
    while(!q.empty()){
        P p=q.front(); q.pop();
        if(p.first==H-1 && p.second==W-1){
            flag=true;
            break;
        }
        rep(k,2){
            int i=p.first+I[k];
            int j=p.second+J[k];
            if(i<=H && j<=W && A[i][j]=='#' && chk[i][j]==0){
                chk[i][j]=1;
                q.push(P(i,j));
            }
        }
    }

    if(!flag){
        cout<<"Impossible"<<endl;
        return 0;
    }

    int sum=0;
    rep(i,H){
        rep(j,W){
            if(A[i][j]=='#') sum++;
        }
    }

    string ans=sum==H+W-1?"Possible":"Impossible";
    cout<<ans<<endl;
}

Measured memory_bytes: 3568
// AOJ 0645 Deforestation
// 2018.3.31 bal4u

#include <stdio.h>
#include <string.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

#define INF 0x10101010
int a[32][32];
int dp[902][32][32];
int mv[4][2] = {{-1, 0},{0,1},{1,0},{0,-1}};

int main()
{
	int H, W, HW, len, r, c, nr, nc, i, t;

	H = in(), W = in(), HW = H*W;
	for (r = 0; r < H; r++) for (c = 0; c < W; c++) a[r][c] = in();

	memset(dp, INF, sizeof(dp));
	dp[0][0][0] = 0;
	for (len = 1; len < HW; len++) {
		for (r = 0; r < H; r++) for (c = 0; c < W; c++) {
			for (i = 0; i < 4; i++) {
				nr = r + mv[i][0], nc = c + mv[i][1];
				if (nr < 0 || nr >= H || nc < 0 || nc >= W) continue;
				if ((t=dp[len-1][r][c]) == INF) continue;
				t += ((len<<1)-1)*a[nr][nc];
				if (t < dp[len][nr][nc]) dp[len][nr][nc] = t;
			}
		}
	}
	t = INF;
	for (len = H+W-2; len < HW; len++) {
		if (t > dp[len][H-1][W-1]) t = dp[len][H-1][W-1];
	}
	printf("%d\n", t);
	return 0;
}


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

int A,B;
string s;

void solve() {
  scanf("%d %d", &A,&B);
  int ans=0;
  if (A-2*B>0) {
    ans = A-2*B;
  }

  cout << ans << "\n";
}

int main() {
  solve();
  return 0;
}


Measured memory_bytes: 256
import bisect
n = int(input())
l = map(int, input().split())
l = sorted(l)

cnt = 0
for i in range (n-2):
	for j in range (i+1, n-1):
		ab = l[i] + l[j]
		r = bisect.bisect_left(l, ab)
		cnt += r - j - 1

print (cnt)

Measured memory_bytes: 3188
from collections import defaultdict
N = int(input())
btn = [0] + [int(input()) for _ in range(N)]
i, ans = 1, 0
checked = defaultdict(int)
while 1:
  next = btn[i]
  ans += 1
  if next == 2:
    print(ans)
    break
  if checked[next] == 1:
    print(-1)
    break
  i = next
  checked[i] = 1


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

#define fo(i, n) for(ll i = 0; i < n; i++)
#define endl "\n"
#define of(i, n) for(ll i = n - 1; i >= 0; i--)
#define ll long long
#define vec vector<ll>
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)


ll mod= 1e9+7;

#define umap unordered_map

ll x,y;
ll ma,mi;
int nextmid(int p,int mid,bool b[])
{
    p++;
    ll zz= mid;
    while(zz--)
    {
        while(b[p]!=1&&p<=ma+1)
        {
            p++;
        }
        p++;
    }
    return p;
}
bool check(ll mid,bool b[])
{

    ll p = mi;
    ll cnt=1;
    while(cnt<=x&&p<=x)
    {
        p = nextmid(p,mid,b);
        cnt++;
    }
    cout<<cnt<<" "<<p<<endl;
    if(cnt==x && p<=ma) return true;
    else return false;
}
int dp[3001][3001];
int lcs(string s,string t)
{
    for(int i=1;i<=s.length();i++)
    {
        for(int j=1;j<=t.length();j++)
        {
            if(s[i-1]==t[j-1]) dp[i][j] = dp[i-1][j-1]+1;
            else dp[i][j] = max(dp[i][j-1],dp[i-1][j]);
        }
    }
    int n= dp[s.length()][t.length()];
    if(n==0) {cout<< "";return 0;}
   char lc[n+1];
   lc[n] = '\0';
   int i = s.length(), j = t.length();
   while (i > 0 && j > 0)
   {
      if (s[i-1] == t[j-1])
      {
          lc[n-1] = s[i-1];
          i--; j--; n--;
      }

      else if (dp[i-1][j] > dp[i][j-1])
         i--;
      else
         j--;
   }

   fo(i,dp[s.length()][t.length()]) cout<<lc[i];
return 1;
}

ll a[100010];
int main()
{
    fio;
    string s,t;
    cin>>s>>t;
    lcs(s,t);

}


Measured memory_bytes: 35456
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		solve();
	}

	private static void solve() {
		Scanner scn = new Scanner(System.in);
		PrintWriter pr = new PrintWriter(System.out);
		while(true){
			int N = scn.nextInt();
			int Q = scn.nextInt();
			int[] D = new int[101];
			if(N==0&&Q==0) break;
			for(int k=0;k<N;k++){
				int M = scn.nextInt();
				for(int s=0;s<M;s++){
					D[scn.nextInt()]++;
				}
			}
			int max = Q-1;
			int maxd = 0;
			for(int s=0;s<101;s++){
				if(D[s]>max){
					max = D[s];
					maxd = s;
				}
			}
			pr.println(maxd);
			
		}
		pr.flush();
		scn.close();
	}

}

Measured memory_bytes: 67872
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

int main(){
	int x, y, z;
	cin >> x >> y >> z;
	cout << (x - z) / (y + z) << endl;
}


Measured memory_bytes: 256
s_str = [ord(i) for i in input()]
t_str = [ord(i) for i in input()]

s = sorted(s_str)
t = sorted(t_str)

cnt_s = 1
cnt_t = 1
s_num = []
t_num = []

for i in range(len(s)-1):
    if s[i] == s[i+1]:
        cnt_s += 1
        if i == len(s)-2:
            s_num.append(cnt_s)
    else:
        s_num.append(cnt_s)
        cnt_s = 1
    if t[i] == t[i+1]:
        cnt_t += 1
        if i == len(s)-2:
            t_num.append(cnt_t)
    else:
        t_num.append(cnt_t)
        cnt_t = 1

s_num = sorted(s_num)
t_num = sorted(t_num)

if s_num == t_num:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 10508
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>

#define INF 100000000

using namespace std;

int main()
{

    string s;
    cin >> s;
    for (int i = 0; i < (int)s.length(); i++)
    {
        if (s[i] == ',')
            s[i] = ' ';
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(long long i=1;i<=n;i++)
#define pb push_back
using namespace std;
typedef long long ll;
long long n,k,W;
const ll maxn=500004;
ll a[maxn];
int main(){

   ll n;
   while(cin>>n)
    {
        cout<<n*(n-1)/2<<"\n";
    }
}


Measured memory_bytes: 256
x,y = input().split()
if x == "A":
  if y == "A":
    print("=")
  else:
    print("<")
elif x == "B":
  if y == "A":
    print(">")
  elif y == "B":
    print("=")
  else:
    print("<")
elif x == "C":
  if y == "A" or y == "B":
    print(">")
  elif y == "C":
    print("=")
  else:
    print("<")
elif x == "D":
  if y == "E" or y == "F":
    print("<")
  elif y == "D":
    print("=")
  else:
    print(">")
elif x == "E":
  if y == "F":
    print("<")
  elif y == "E":
    print("=")
  else:
    print(">")
else:
  if y == "F":
    print("=")
  else:
    print(">")

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

namespace ABC
{
    class Abc173
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            List<string> S = new List<string>();

            for (int i = 0; i < N; i++)
            {
                S.Add(Console.ReadLine());
            }

            Console.WriteLine($"AC x {S.Where(s => s == "AC").Count()}");
            Console.WriteLine($"WA x {S.Where(s => s == "WA").Count()}");
            Console.WriteLine($"TLE x {S.Where(s => s == "TLE").Count()}");
            Console.WriteLine($"RE x {S.Where(s => s == "RE").Count()}");

            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 33068
d = dict()
for i in "HSDC":
    d[i] = set()
for _ in range(int(input())):
    mark,num = input().split()
    d[mark].add(int(num))
for i in "SHCD":
    for j in range(1,14):
        if j not in d[i]:
            print(i,j)


Measured memory_bytes: 5596
main = do
    n <- readLn :: IO Int
    pn <- map read . words <$> getLine :: IO [Int]
    let x = sum $ zipWith (\x y -> if x == y then 0 else 1) [1..n] pn
    if x <= 2
        then putStrLn "YES"
        else putStrLn "NO"
    

Measured memory_bytes: 4016
import fractions

A, B, C, D = map(int, input().split())

x = fractions.gcd(C, D)
CD = x * (C // x) * (D // x)

Cm = B // C - (A - 1) // C
Dm = B // D - (A - 1) // D
CDm = B // CD - (A - 1) // CD

print(B + 1 - A - (Cm + Dm - CDm))

Measured memory_bytes: 5048
#

import sys
input=sys.stdin.readline

def main():
    N,K,Q=map(int,input().split())
    ps=[K-Q]*N
    for i in range(Q):
        A=int(input())
        ps[A-1]+=1
    for i in range(N):
        if ps[i]>0:
            print("Yes")
        else:
            print("No")
if __name__=="__main__":
    main()


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

//const Long MX = ;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout.precision(10);
	cout << fixed;
	 char c;
	cin >> c;
	if('a' <= c && c <= 'z'){
		cout << 'a' << endl;
	}else{
		cout << 'A' << endl;
	}
	return 0;
}


Measured memory_bytes: 3628
object Main extends App {
  import scala.io.StdIn._

  val Array(heights, width) = readLine.trim.split(' ').map(_.toInt)
  val scores = Array.tabulate(heights){_ ⇒ readLine.trim.split(' ').map(_.toInt)}.let{a ⇒
    val array = Array.tabulate(heights + 1){_ ⇒ Array.tabulate(width + 1){_ ⇒ 0}}
    for (y ← a.indices; x ← a(y).indices){
      array(y + 1)(x + 1) = a(y)(x)
      array(y + 1)(x + 1) += array(y)(x + 1) + array(y + 1)(x) - array(y)(x)
    }
    array
  }
  val target = new Target(Array.tabulate(heights){_ ⇒ readLine.trim.split(' ').map(_.toInt == 0)})
  val Array(h, w) = readLine.trim.split(' ').map(_.toInt)
  val pattern = new Pattern(Array.tabulate(h){_ ⇒ readLine.trim.split(' ').map(_.toInt == 0)})
  val suspects = (0 to width - w).flatMap(x ⇒ (0 to heights - h).map(y ⇒ Coordinate(x, y))).filter{o ⇒
      pattern.indices.forall(c ⇒ target(o + c) == pattern(c))
    }.map{o ⇒
      scores(o.y + h)(o.x + w) - scores(o.y)(o.x + w) - scores(o.y + h)(o.x) + scores(o.y)(o.x)
    }
  println(
    if (suspects.isEmpty) "NA"
    else suspects.max
  )
  class Pattern(private val state: Array[Array[Boolean]]) {
    val width = state.head.length
    val height = state.length
    val indices = (0 until width).flatMap(x ⇒ (0 until height).map(y ⇒ Coordinate(x, y)))
    def isValidIndex(coordinate: Coordinate) = (0 until width).contains(coordinate.x) && (0 until height).contains(coordinate.y)
    def apply(coordinate: Coordinate): Boolean = state(coordinate.y)(coordinate.x)
  }
  class Target(private val state: Array[Array[Boolean]]) {
    val width = state.head.length
    val height = state.length
    def isValidIndex(coordinate: Coordinate) = (0 until width).contains(coordinate.x) && (0 until height).contains(coordinate.y)
    def apply(coordinate: Coordinate): Boolean = state(coordinate.y)(coordinate.x)
  }
  case class Coordinate(x: Int, y: Int) {
    def +(that: Coordinate) = Coordinate(this.x + that.x, this.y + that.y)
  }
  implicit class Scope[T](val value: T) extends AnyVal{
    @inline
    def also(@inline func: T ⇒ Unit): T = {
      func(value)
      value
    }
    @inline
    def let[A](func: T ⇒ A): A = func(value)
  }
}


Measured memory_bytes: 46100
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

cusum_A = [0] * N
cusum_B = [0] * N
for i in range(N):
  cusum_A[i] = cusum_A[i-1] + A[i]
  cusum_B[i] = cusum_B[i-1] + B[i]

ans = 0
for i in range(N):
  if i == 0:
    total = cusum_A[i] + cusum_B[N-1]
  else:
    total = cusum_A[i] + cusum_B[N-1] - cusum_B[i-1]
  ans = max(ans, total)

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int col[707];
bool e[707][707];
bool ok=true;
int cnt[2];
bool dp[2][707];
int n;
void work(int x)
{
	cnt[col[x]]++;
	for(int i=1;i<=n;i++)
		if(e[x][i])
		{
			if(col[i]==-1)
			{
				col[i]=col[x]^1;
				work(i);
			}
			else if(col[i]!=(col[x]^1))
				ok=false;
		}
}
int main()
{
	int m,x,y,now=0,to=1;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			e[i][j]=(i!=j);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		e[x][y]=e[y][x]=false;
	}
	memset(dp,0,sizeof(dp));
	memset(col,-1,sizeof(col));
	dp[now][0]=true;
	for(int i=1;i<=n;i++)
		if(col[i]==-1)
		{
			cnt[0]=cnt[1]=0;
			col[i]=0;
			work(i);
			for(int j=0;j<=n;j++)
				if(dp[now][j])
				{
					dp[to][j+cnt[0]]=true;
					dp[to][j+cnt[1]]=true;
					dp[now][j]=false;
				}
			swap(now,to);
		}
	if(!ok)
		printf("-1");
	else
	{
		int ans=21474836;
		for(int i=0;i<=n;i++)
			if(dp[now][i])
				ans=min(ans,i*(i-1)/2+(n-i)*(n-i-1)/2);
		printf("%d",ans);
	}
	return 0;
}

Measured memory_bytes: 768
#include <stdio.h>

int stack[100000];
int pop[100000];

int main(void)
{
  int i, j;
  int shead, phead;
  int n;

  shead = 0;
  phead = 0;
  while (scanf("%d", &n) != EOF){
    if (n){
      stack[shead++] = n;
    }
    else{
      pop[phead++] = stack[--shead];
      /*  if (!shead){
	break;
	}*/
    }
  }
  for (i = 0; i < phead; i++){
    printf("%d\n", pop[i]);
  }

  return 0;
}

Measured memory_bytes: 604
mod = 10**9+7
H, W, K = map(int, input().split())
if W == 1:
    print(1)
    exit()
dp = [[0] * W for _ in range(H+1)]
dp[0][K-1] = 1
factor = [0] * (W-1)
for i in range(W-1):
    for j in range(1 << i):
        for k in range(i-1):
            if (j >> k) & (j >> (k+1)):
                break
        else:
            factor[i] += 1
for i in range(1, H+1):
    for j in range(W):
        for k in [-1, 0, 1]:
            if 0 <= j+k < W:
                left = max(min(j, j+k)-1, 0)
                right = max(W-max(j, j+k)-2, 0)
                dp[i][j] += dp[i-1][j+k] * factor[left] * factor[right]
        dp[i][j] %= mod
print(dp[H][0])


Measured memory_bytes: 3064
n,l = [int(i) for i in input().split(" ")]
L = [i for i in range(l,l+n)]
max = sum(L)
wei = 10000000000000
ans = 0
for i in range(n):
    tmp = 0
    for j in range(n):
        if i !=j:
            tmp+=L[j]
    if wei > abs(max - tmp):
        wei = abs(max - tmp)
        ans = tmp
print(ans)
                    
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

//最小値問題
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    llong n,k,h[100002],dp[100002];
    cin >> n >> k;
    rep(i,n){
        cin >> h[i];
        dp[i] = INF;
    }
    dp[0] = 0;
    for(llong i=1;i<n;i++){
        for(llong j=1;i-j>=0 && j<=k;j++){
            chmin(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int h1, m1, h2, m2, k;
        cin >> h1 >> m1 >> h2 >> m2 >> k;
        int val1 = h1 * 60 + m1;
        int val2 = h2 * 60 + m2;
        int val = val2 - val1;
        cout << max(0LL, val - k) << '\n';
    }
}

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

int main(void) {
    long long A, B;
    cin >> A >> B;

    int num = 1;
    while (1) {
        if ((((num * 8) / 100) == A) && (((num * 10) / 100) == B)) {
            break;
        }
        if (num > 1260) {
            num = -1;
            break;
        }
        num++;
    }

    cout << num << endl;
    return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = 1e9 + 7;
const int INF = 1e9;

int main() {
	cin.sync_with_stdio(false);
	int H, W;
	cin >> H >> W;
	int h, w;
	rep(i, H) {
		rep(j, W) {
			string s;
			cin >> s;
			if (s == "snuke") {
				h = i; w=j;
			}
		}
	}
	cout<<(char)('A' + w)<< h+1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  long long N, K;
  cin >> N >> K;
  vector<int> q(N);
  for(int i = 0; i < N; i++) {
    cin >> q.at(i);
  }
  sort(q.begin(), q.end());
  long long e = 0;
  for(int i = 0; i < N - K; i++) {
    e += q.at(i);
  }
  cout << e << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

void ans(int n)
{
	for (int i = 0;i < 3;i++)
	{
		cout << n;
	}
	cout << endl;
}


int main()
{
	int n;
	cin >> n;
	int a[3];

	a[0] = n / 100;
	a[1] = (n - a[0]*100) / 10;
	a[2] = (n - a[0]*100 - a[1]*10);


	if (a[0] == a[1] && a[0] == a[2])cout << n << endl;
	else if (a[0] > a[1]) ans(a[0]);
	else if (a[0] == a[1] && a[0] > a[2])ans(a[0]);
	else ans(++a[0]);
	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define a(i,n) for(int i=0;i<n;i++)
using namespace std;
int W[200001],H[200001],n,w,h,x,y,t,b;
int main(){
	cin>>n>>w>>h;
	a(i,n){
		cin>>x>>y>>t;
		x--; y--;
		W[max(0,x-t+1)]++;
		W[min(w,x+t+1)]--;
		H[max(0,y-t+1)]++;
		H[min(h,y+t+1)]--;
	}
	a(i,w){
		W[i+1] += W[i];
		if(W[i] == 0){
			b++;
			break;
		}
	}
	a(i,h){
		H[i+1] += H[i];
		if(H[i] == 0){
			b++;
			break;
		}
	}
	printf("%s\n",b==2?"No":"Yes");
}

Measured memory_bytes: 1904
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct Node{
  int key;
  struct Node *right;
  struct Node *left;
  struct Node *parent;
};

struct Node *root, *nil;

void insert(int k){
  struct Node *y=nil, *x=root, *z;

  z = malloc(sizeof(struct Node));
  z->key=k;
  z->right=nil;
  z->left=nil;
  while(x!=nil){
    y=x;
    if(z->key < x->key) x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==nil)root=z;
  else {
    if(z->key < y->key) y->left=z;
    else y->right=z;
  }
}

void inorder(struct Node *n){
  if(n==nil)return;
  inorder(n->left);
  printf(" %d",n->key);
  inorder(n->right);
}

void preorder(struct Node *n){
  if(n==nil)return;
  printf(" %d",n->key);
  preorder(n->left);
  preorder(n->right);
}

int main(){
  int i, n, s;
  char c[10];

  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%s", c);
    if(strcmp(c, "insert")==0){
      scanf("%d", &s);
      insert(s);
    }
    else if(strcmp(c, "print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 24036
use std::io::Read;

fn main() {
    let buf = {
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    };
    let out = solve(&buf);
    println!("{}", &out);
}

fn solve(buf: &str) -> String {
    let mut sc = Scanner::new(&buf);
    let n: usize = sc.read();
    let mut a: Vec<usize> = sc.read_vec(n);
    let mut ans = 0;

    for i in 1..n {
        if a[i] == a[i - 1] {
            ans += 1;
            a[i] = 10000000;
        }
    }
    ans.to_string()
}

struct Scanner<'a> {
    iter: std::str::SplitWhitespace<'a>,
}

impl<'a> Scanner<'a> {
    fn new(s: &'a str) -> Scanner<'a> {
        Scanner {
            iter: s.split_whitespace(),
        }
    }

    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.iter
            .next()
            .unwrap()
            .parse()
            .ok()
            .expect("parsing failed")
    }

    fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
}


Measured memory_bytes: 4352
class UnionFind:

    def __init__(self, n):
        self.n = n
        self.par = [i for i in range(n)]
        self.height = [0] * n
        self.size = [1] * n

    def find(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]

    def getsize(self, x):
        return self.size[self.find(x)]

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return
        if self.height[x] < self.height[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = self.par[x]
            self.size[x] += self.size[y]
            if self.height[x] == self.height[x]:
                self.height[x] += 1

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

N, M = map(int, input().split())
uf = UnionFind(M+1)
Lf = [None]*N
for i in range(N):
    tmp = list(map(int, input().split()))
    K, L = tmp[0], tmp[1:]
    for j in range(K-1):
        uf.unite(L[j], L[j+1])
    Lf[i] = L[0]
r = uf.find(Lf[0])
for i in range(1, N):
    if r != uf.find(Lf[i]):
        print('NO')
        exit()
print('YES')

Measured memory_bytes: 72864
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
const int INF = 1001001001;

int main()
{
    int a,b;
    string s;
    in a>>b>>s;
    bool flag=true;
    rep(i,s.size())
    {
        if(i!=a&&s[i]=='-')flag=false;
        if(s[a]!='-')flag=false;
    }
    if(flag)py;
    else pn;
}


Measured memory_bytes: 256
# om namah shBaPPaSitavayRam✊bomNS omNS


dic = {1:"pon",
      2:"hon",
      3:"bon",
      4:"hon",
      5:"hon",
      6:"pon",
      7:"hon",
      8:"pon",
      9:"hon",
      0:"pon"}
n = int(input())
print(dic.get(n%10))

Measured memory_bytes: 9128
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#define rep(i,n) for(int i = 0;i<(n);i++);
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 100100100100100;


int main() {
	ll A, B;
	cin >> A >> B;
	if (A >= 13)cout << B << endl;
	else if (A <= 12 && A >= 6) cout << B / 2 << endl;
	else cout << "0" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#define U_Fsize 200000
int n, k, l;
int U_Fx[U_Fsize];
int U_Fs[U_Fsize];
int U_Fq[U_Fsize];
long long x[U_Fsize];
long long y[U_Fsize];
long long z[U_Fsize];
int f[200000], ans[200000];
int a[100000], b[100000];
int c[100000], d[100000];
int U_Ff;
int root(int U_Fc) {
	if (U_Ff == 0) {
		for (int i = 0; i < U_Fsize; i++) {
			U_Fx[i] = -1;
			U_Fs[i] = -1;
		}
		U_Ff = 1;
	}
	int U_Ft = 0;
	while (U_Fx[U_Fc] >= 0) {
		U_Fq[U_Ft] = U_Fc;
		U_Fc = U_Fx[U_Fc];
		U_Ft++;
	}
	for (int i = U_Ft - 2; i >= 0; i--) {
		U_Fx[U_Fq[i]] = U_Fc;
	}
	return U_Fc;
}
void merge(int U_Fa, int U_Fb) {
	U_Fa = root(U_Fa);
	U_Fb = root(U_Fb);
	if (U_Fa == U_Fb)return;
	if (U_Fx[U_Fa] < U_Fx[U_Fb]) {
		U_Fs[U_Fa] += U_Fs[U_Fb];
		U_Fx[U_Fb] = U_Fa;
	}
	else if (U_Fx[U_Fa] == U_Fx[U_Fb]) {
		U_Fx[U_Fa]--;
		U_Fs[U_Fa] += U_Fs[U_Fb];
		U_Fx[U_Fb] = U_Fa;
	}
	else{
		U_Fs[U_Fb] += U_Fs[U_Fa];
		U_Fx[U_Fa] = U_Fb;
	}
}
int bubunnginoookisa(int U_Fd){
	U_Fd = root(U_Fd);
	return -U_Fs[U_Fd];
}
int main() {
	scanf("%d%d%d", &n, &k, &l);
	for (int i = 0; i < k; i++) {
		scanf("%d%d", a + i, b + i);
		a[i]--; b[i]--;
	}
	for (int i = 0; i < l; i++) {
		scanf("%d%d", c + i, d + i);
		c[i]--; d[i]--;
	}
	for (int i = 0; i < k; i++) {
		merge(a[i], b[i]);
	}
	for (int i = 0; i < n; i++) {
		x[i] = root(i);
	}
	U_Ff = 0;
	for (int i = 0; i < l; i++) {
		merge(c[i], d[i]);
	}
	for (int i = 0; i < n; i++) {
		y[i] = root(i);
	}
	for (int i = 0; i < n; i++) {
		z[i] = x[i] * 200000 + y[i];
		z[i] = z[i] * 200000 + i;
	}
	std::sort(z, z + n);
	f[0] = 1;
	for (int i = 1; i < n; i++) {
		if (z[i] / 200000 == z[i - 1] / 200000)f[i] = f[i - 1] + 1;
		else f[i] = 1;
	}
	for (int i = n - 1; i > 0; i--) {
		if (z[i] / 200000 == z[i - 1] / 200000)f[i - 1] = f[i];
	}
	for (int i = 0; i < n; i++) {
		ans[z[i] % 200000] = f[i];
	}
	for (int i = 0; i < n; i++) {
		if (i != n - 1)printf("%d ", ans[i]);
		else printf("%d\n", ans[i]);
	}
}

Measured memory_bytes: 10368
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int sg,sp;
int ans;
string s;
int main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='g')sg++;else sp++;
		if(sp>sg)
		{
			sp--;
			ans--;
		}
	}
	for(int i=(int)s.size()-1;i>=0;i--)
	{
		if(s[i]=='g')
		{
			ans++;
			sg--;
			sp++;
			if(sp>sg)
			{
				ans--;
				break;
			}
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vec<int> A(N+1),B(N+1);
    for(int i=1;i<=N;i++) cin >> A[i];
    vec<int> ans;
    for(int i=N;i>=1;i--){
        int now = A[i];
        for(int j=2*i;j<=N;j+=i) now ^= B[j];
        if(now){
            B[i] = 1;
            ans.push_back(i);
        }
    }
    int M = ans.size();
    cout << M << "\n";
    for(int i=0;i<M;i++) cout << ans[i] << (i!=M-1? " ":"\n");
}

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

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

    long long x, y, cnt = 0;
    cin >> x >> y;
    while(x <= y){
        x *= 2;
        cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
typedef long long ll;
typedef long double ld;
//typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<pair<ll,ll> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef pair<ll,pair<ll,ll> > iii;
#define PI 3.141592653589793
#define mod (ll)(1000*1000*1000+7)
//# define N 300005
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=((ans%m)*(a%m))%m; b/=2; a=((a%m)*(a%m))%m; } return ans%m; }
# define INF (ll)1e18
# define LN 20  
# define EPS 1e-9
typedef pair<ll,pair<ll,ll> > pii;
# define INF1 (ll)1e10
# define maxn 200005
# define offset 2000005
#define N 100005
const ld eps = 1e-10L;

/*void LPS()
{
	len = s.length();
    lps[0] = 0;
    for(ll i=1;i<len;i++){

        ll j = lps[i-1];
        while(j > 0 && s[j] != s[i])    j = lps[j-1];
        if(s[i] == s[j])    j++;
        lps[i] = j;
    }
}*/

/*************************************************
struct Coupon {
	ll l;
	ll r;
	ll id;

	Coupon(ll l, ll r, ll id): l(l), r(r), id(id) {} // Initialization

	bool operator<(const Coupon& c) { // Sorting
		return l < c.l;    
	}
};

**************************************************/

int a[maxn];
int n;
int k;
int dp[101][100002];

ll solve(int id,int left)
{
	//trace2(id,left);
	if(left<0)
		return 0;
	if(left>k)
		return 0;
	if(id==n+1)
	{
		return (left==0);
	}
	if(dp[id][left]!=-1)
		return dp[id][left];
	ll ans=(solve(id+1,max(0,left-a[id]))%mod)-(solve(id+1,left+1)%mod);
	if(ans<0)
		ans+=mod;
	ans%=mod;
	ans+=solve(id,left+1);
	ans%=mod;
	return dp[id][left]=ans;
}

int main()
{
	IOS;
	cin >> n >> k;
	for(int i=1;i<=n;i++)
		cin >> a[i];
	memset(dp,-1,sizeof dp);
	cout << solve(1,k);
}

Measured memory_bytes: 45952
list1 = [input() for i in range(5)]
num = int(input())
list1 = list(map(int,list1))
list2 = []

for i in range(5):
    for k in range(i+1,5):
        list2.append(list1[k]-list1[i])

if max(list2) <= num:
    print ("Yay!")
else:
    print(":(")


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

int main(){
  int H,W;
  cin >> H >> W;
  vector<string> S(H+1,"");
  for(int i=0;i<=W;i++)  S.at(0)+="#";
  for(int i=1;i<=H;i++){
    cin >> S.at(i);
    S.at(i)="#"+S.at(i);
  }
  //for(int i=0;i<=H;i++) cout << S.at(i) << endl;

  vector<vector<int>> dp(H+1,vector<int>(W+1,1e9));
  dp.at(1).at(1)=0;
  if(S.at(1).at(1)=='#')  dp.at(1).at(1)=1;
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      if(S.at(i).at(j)=='.'){
        dp.at(i).at(j)=min({dp.at(i).at(j),dp.at(i-1).at(j),dp.at(i).at(j-1)});
      }
      else if(S.at(i).at(j)=='#'){
        int tmp1;
        int tmp2;
        if(S.at(i-1).at(j)=='.')  tmp1=dp.at(i-1).at(j)+1;
        else  tmp1=dp.at(i-1).at(j);
        if(S.at(i).at(j-1)=='.')  tmp2=dp.at(i).at(j-1)+1;
        else  tmp2=dp.at(i).at(j-1);
        dp.at(i).at(j)=min({dp.at(i).at(j),tmp1,tmp2});
      }
    }
  }
  cout << dp.at(H).at(W) << endl;

  return 0;
}


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

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        Array.Sort(a);
        Array.Reverse(a);
        Console.WriteLine(4 * a[m - 1] * m >= a.Sum() ? "Yes" : "No");
    }
}


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


using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;

	if (a + b>= c)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;

}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
using namespace std;
using ll = long long;

const int MAX = 1000000;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

int main()
{

  //cout << fixed << setprecision(10);

  int x,a,b; cin >> x >> a >> b;

  if (b<=a){cout << "delicious";}
  else if (b<=a+x){cout << "safe";}
  else {cout << "dangerous";}

  return 0;
}


Measured memory_bytes: 256
S=input()

st1 = 0
st0 = 0

for i in range(len(S)):
    if S[i] == '1' and i%2==0:
        st0+=1
    elif S[i] == '0' and i%2==0:
        st1+=1
    elif S[i] == '1' and i%2!=0:
        st1+=1
    elif S[i] == '0' and i%2!=0:
        st0+=1

print(min(st1, st0))

Measured memory_bytes: 9264
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define V vector<int>
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

int cnt[1000010];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, p; cin >> n >> p;
	int ans = 1;
	map<int, int>mp;
	for (int i = 2; i <= sqrt(p); i++) {
		if (!prime(i))continue;
		while (p%i == 0) {
			mp[i]++; p /= i;
		}
		ans *= pow(i, mp[i] / n);
	}
	if (p != 1) {
		mp[p] = 1;
	}
	ans *= pow(p, mp[p] / n);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2432
open System

let [| N; M |] = stdin.ReadLine().Split(' ') |> Array.map int
let (S : String[]) = Array.zeroCreate (N + 2)
S.[0] <- new String('#', M + 2)
for i in 0..(N-1) do
  S.[i + 1] <- "#" + stdin.ReadLine() + "#"
S.[N+1] <- new String('#', M + 2)

for i in {0..(N+1)} do
  printfn "%s" S.[i]


Measured memory_bytes: 14160
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
vector <int> same,sorted;
int main()
{
    int N,x,i;
    scanf("%d",&N);
    for(i=0;i<N;i++)
    {
        scanf("%d",&x);
        same.push_back(x);
        sorted.push_back(x);
    }
    sort(sorted.begin(),sorted.end());
    int med=sorted[N/2];
    for(i=0;i<N;i++)
    {
        if(same[i]<med) printf("%d\n",med);
        else printf("%d\n",sorted[N/2-1]);
    }
}


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

using namespace std;

#define int long long

#ifndef bhupixb
    #define var(...)
    #define stl(...)
#endif

#define single_test

void solve() {
    string s;
    cin >> s;
    int mul = 0;
    for (char i : s) {
        mul = mul + (i - '0');
    }
    cout << (!(mul % 9) ? "Yes" : "No") << '\n';
}

signed main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    #ifndef single_test
        cin >> t;
    #endif
    for (int i = 1; i <= t; ++i) {
        // cout << "Case #" << i << ": ";
        solve();
    }

    return 0;
}

Measured memory_bytes: 3764
import java.util.ArrayList;
import java.util.Scanner;


public class Main {
	public static void main(String[] args){
		ArrayList<Integer> cars = new ArrayList<Integer>();
		Scanner sn = new Scanner(System.in);
		while(sn.hasNext()){
			int num = sn.nextInt();
			if(num == 0){
				System.out.println(cars.get(cars.size()-1));
				cars.remove(cars.size()-1);
			} else {
				cars.add(num);
			}
		}
	}
}

Measured memory_bytes: 17212
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using o_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define M 1000010

int main(){
	IOS;
	
	string s,t;
	cin>>s>>t;
	cout<<t<<s;
	
	return 0;
}



Measured memory_bytes: 256
N=int(input())
list_num=[]
for i in range(1,N+1):
    if i%3==0:
        list_num.append(i)
        
    else:
        s=str(i)
        if list(s).count('3')!=0:
            list_num.append(i)
            
list_num.sort()

[print(' ' + str(i),end='') for i in list_num]
print()


Measured memory_bytes: 6176
#include<bits/stdc++.h> 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vv = vector<vector<int>>;
using P = pair<int,int>;

bool func( int n ){
  if( n%10 == 9 ) return true;
  if( n == 0 ) return false;
  return func( n/10 );
}


int main(){
  int n;
  cin >> n;
  if( func(n) ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


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

public class Main {
        public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);
                String h = scan.next();
    String[] ha = h.split("");
                
    Map<String, Integer> map = new HashMap<String, Integer>();
    map.put(ha[0], 1);
    int sum = 0;

    for(int i = 1; i < 4; i++){
      if(map.containsKey(ha[i])){
        map.put(ha[i], map.get(ha[i]) + 1);
      }else{
        map.put(ha[i], 1);
      }

      
    }

for(String key : map.keySet()){
 if(map.get(key) != 2){
    System.out.println("No");
   return;
 }
}

    System.out.println("Yes");
        }
}

Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int h=scan.nextInt();
		int w=scan.nextInt();
		int hcheck[]=new int[h];
		int wcheck[]=new int[w];
		int grid[][]=new int[h][w];
		for(int i=0;i<h;i++) {
			String str = scan.next();
			hcheck[i]=1;
			int sum=0;
			for(int j=0;j<w;j++) {
				if(str.charAt(j)=='.')grid[i][j]=0;
				else grid[i][j]=1;

				sum+=grid[i][j];
			}
			if(sum==0)hcheck[i]=0;
		}
		scan.close();
		for(int i=0;i<w;i++) {
			wcheck[i]=1;
			int sum=0;
			for(int j=0;j<h;j++) {
				sum+=grid[j][i];
			}
			if(sum==0)wcheck[i]=0;
		}

		for(int i=0;i<h;i++) {
			if(hcheck[i]==1) {
				for(int j=0;j<w;j++) {
					if(wcheck[j]==1)System.out.print((grid[i][j]==1)? "#":".");
				}
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 22604
n=int(input())
s=input()
t=input()
p=i=0
if s[0]==t[0]:
    r=3
    p=1
    i+=1
else:
    r=6
    p=2
    i+=2
while i<n:
    if s[i]==t[i]:
        r=r*(3-p)%1000000007
        p=1
        i+=1
    else:
        r=r*(p+1)%1000000007
        p=2
        i+=2
print(r)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;

	ll ans = 0;
	for (int b = 1; b <= n; ++b) {
		ll p = n / b;
		ll g = p * max(0, b - k) + max(0, n % b - k + 1);
		ans += g;
	}
	if (k == 0) ans -= n;

	dunk(ans);
	
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), math.MaxInt32)
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		return []byte(f1())
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

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

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()

	N := readInt()
	H := make([]int, N)
	for i := range H {
		H[i] = readInt()
	}
	var ans, cur int
	for i := N - 1; 0 < i; i-- {
		if H[i-1] < H[i] {
			cur = 0
			continue
		}
		cur++
		ans = max(ans, cur)
	}
	println(ans)
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 3072
#include "bits/stdc++.h"
using namespace std;

int main(){
    int X , q , Ans = 0;
    scanf( "%d" , &X );
    q = X / 500;
    Ans = q * 1000;
    X = X % 500;
    q = X / 5;
    Ans += q * 5;
    printf( "%d\n" , Ans );
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int i, n;
	int score_a, score_b;
	int card_a, card_b;

	while(1){
		score_a = 0;
		score_b = 0;
		scanf("%d", &n);
		if(n == 0){
			return 0;
		}else{
			for(i=0;i<n;i++){
				scanf("%d %d", &card_a, &card_b);
				if(card_a < card_b){
					score_b = score_b + card_a + card_b;
				}else if(card_b < card_a){
					score_a = score_a + card_a + card_b;
				}else{
					score_a += card_a;
					score_b += card_b;
				}
			}
			printf("%d %d\n", score_a, score_b);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll dp[100100];

int main() {
	ll n,k;
  cin>>n>>k;
  rep(i,0,100100)dp[i]=1000000000000000000LL;
  dp[0] = 0;
  vector<ll> v;
  rep(i,0,n){
    ll a;
    cin>>a;
    v.pb(a);
  }
  rep(i,0,n){
    rep(j,1,k+1){
      if(i+j<n){
        dp[i+j] = min(dp[i+j],dp[i]+abs(v[i+j]-v[i]));
      }
    }
  }
  cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 2168
#include <stdio.h>
#include <malloc.h>
#include <string.h>

int main(void) {
  char s1, s2, s3, s4, s5, s6;
  scanf("%c", &s1);
  scanf("%c", &s1);
  scanf("%c", &s3);
  scanf("%c", &s4);
  scanf("%c", &s5);
  scanf("%c", &s6);
  if(s3 == s4 && s5 == s6) printf("Yes");
  else printf("No");

  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main() {
	int W,H,N;
	scanf("%d %d %d",&W, &H, &N);
	int tmin, tmax, ymin, ymax;
	tmin = ymin = 0;
	tmax = H;
	ymax = W;
	int a[N][3];
	for(int i=0; i<N; i++){
		scanf("%d %d %d", &a[i][0], &a[i][1], &a[i][2]);
	}
	for(int j=0; j<N; j++){
		if(a[j][2] == 1){ if(ymin < a[j][0]){ymin = a[j][0];} }
		else if(a[j][2] == 2){ if(ymax > a[j][0]){ymax = a[j][0];} }
		else if(a[j][2] == 3){ if(tmin < a[j][1]){tmin = a[j][1];} }
		else if(a[j][2] == 4){ if(tmax > a[j][1]){tmax = a[j][1];} }
	}
	int w = ymax-ymin;
	int h = tmax-tmin;
	int ans = w*h;
	if(w<=0 || h<=0){printf("0\n");}
	else {printf("%d\n", ans);}
	return 0;
}

Measured memory_bytes: 128